diff options
Diffstat (limited to 'cui/source')
224 files changed, 10616 insertions, 7301 deletions
diff --git a/cui/source/customize/CommandCategoryListBox.cxx b/cui/source/customize/CommandCategoryListBox.cxx index 7823607114e8..f7f3295a921d 100644 --- a/cui/source/customize/CommandCategoryListBox.cxx +++ b/cui/source/customize/CommandCategoryListBox.cxx @@ -35,7 +35,7 @@ // include search util #include <com/sun/star/util/SearchFlags.hpp> #include <com/sun/star/util/SearchAlgorithms2.hpp> -#include <tools/diagnose_ex.h> +#include <comphelper/diagnose_ex.hxx> #include <unotools/textsearch.hxx> #include <dialmgr.hxx> @@ -134,9 +134,8 @@ void CommandCategoryListBox::Init(const css::uno::Reference<css::uno::XComponent // Add the category of "All commands" m_aGroupInfo.push_back( std::make_unique<SfxGroupInfo_Impl>(SfxCfgKind::GROUP_ALLFUNCTIONS, 0)); - m_xControl->append( - OUString::number(reinterpret_cast<sal_Int64>(m_aGroupInfo.back().get())), - CuiResId(RID_SVXSTR_ALLFUNCTIONS)); + m_xControl->append(weld::toId(m_aGroupInfo.back().get()), + CuiResId(RID_CUISTR_ALLFUNCTIONS)); } // Separate the "All commands"category from the actual categories @@ -181,9 +180,7 @@ void CommandCategoryListBox::Init(const css::uno::Reference<css::uno::XComponent sal_Int16 nGroupID = a.second; m_aGroupInfo.push_back( std::make_unique<SfxGroupInfo_Impl>(SfxCfgKind::GROUP_FUNCTION, nGroupID)); - m_xControl->append( - OUString::number(reinterpret_cast<sal_Int64>(m_aGroupInfo.back().get())), - rGroupName); + m_xControl->append(weld::toId(m_aGroupInfo.back().get()), rGroupName); } // Separate regular commands from styles and macros @@ -192,15 +189,14 @@ void CommandCategoryListBox::Init(const css::uno::Reference<css::uno::XComponent // Add macros category m_aGroupInfo.push_back( std::make_unique<SfxGroupInfo_Impl>(SfxCfgKind::GROUP_SCRIPTCONTAINER, 0, nullptr)); - m_xControl->append(OUString::number(reinterpret_cast<sal_Int64>(m_aGroupInfo.back().get())), - CuiResId(RID_SVXSTR_MACROS)); + m_xControl->append(weld::toId(m_aGroupInfo.back().get()), CuiResId(RID_CUISTR_MACROS)); // Add styles category //TODO: last param should contain user data? m_aGroupInfo.push_back( std::make_unique<SfxGroupInfo_Impl>(SfxCfgKind::GROUP_STYLES, 0, nullptr)); - m_xControl->append(OUString::number(reinterpret_cast<sal_Int64>(m_aGroupInfo.back().get())), - CuiResId(RID_SVXSTR_GROUP_STYLES)); + m_xControl->append(weld::toId(m_aGroupInfo.back().get()), + CuiResId(RID_CUISTR_GROUP_STYLES)); } catch (const css::uno::RuntimeException&) { @@ -260,9 +256,7 @@ void CommandCategoryListBox::FillFunctionsList( pGrpInfo->sCommand = rInfo.Command; pGrpInfo->sLabel = sUIName; pGrpInfo->sTooltip = sTooltipLabel; - pFunctionListBox->append( - OUString::number(reinterpret_cast<sal_Int64>(m_aGroupInfo.back().get())), sUIName, - xImage); + pFunctionListBox->append(weld::toId(m_aGroupInfo.back().get()), sUIName, xImage); } } @@ -301,8 +295,7 @@ void CommandCategoryListBox::categorySelected(CuiConfigFunctionListBox* pFunctio const OUString& filterTerm, SaveInData* pCurrentSaveInData) { - SfxGroupInfo_Impl* pInfo - = reinterpret_cast<SfxGroupInfo_Impl*>(m_xControl->get_active_id().toInt64()); + SfxGroupInfo_Impl* pInfo = weld::fromId<SfxGroupInfo_Impl*>(m_xControl->get_active_id()); std::vector<std::unique_ptr<weld::TreeIter>> aNodesToExpand; pFunctionListBox->freeze(); pFunctionListBox->ClearAll(); @@ -318,7 +311,7 @@ void CommandCategoryListBox::categorySelected(CuiConfigFunctionListBox* pFunctio for (sal_Int32 nCurPos = 0; nCurPos < nEntryCount; ++nCurPos) { SfxGroupInfo_Impl* pCurrentInfo - = reinterpret_cast<SfxGroupInfo_Impl*>(m_xControl->get_id(nCurPos).toInt64()); + = weld::fromId<SfxGroupInfo_Impl*>(m_xControl->get_id(nCurPos)); if (!pCurrentInfo) //separator continue; @@ -392,11 +385,11 @@ void CommandCategoryListBox::categorySelected(CuiConfigFunctionListBox* pFunctio OUString sUIName; if (childGroup->getName() == "user") { - sUIName = CuiResId(RID_SVXSTR_MYMACROS); + sUIName = CuiResId(RID_CUISTR_MYMACROS); } else if (childGroup->getName() == "share") { - sUIName = CuiResId(RID_SVXSTR_PRODMACROS); + sUIName = CuiResId(RID_CUISTR_PRODMACROS); } else { @@ -411,9 +404,7 @@ void CommandCategoryListBox::categorySelected(CuiConfigFunctionListBox* pFunctio m_aGroupInfo.push_back(std::make_unique<SfxGroupInfo_Impl>( SfxCfgKind::GROUP_SCRIPTCONTAINER, 0)); std::unique_ptr<weld::TreeIter> xMacroGroup(pFunctionListBox->tree_append( - OUString::number( - reinterpret_cast<sal_Int64>(m_aGroupInfo.back().get())), - sUIName)); + weld::toId(m_aGroupInfo.back().get()), sUIName)); { // tdf#128010: Do not nag user asking to enable JRE: if it's disabled, @@ -455,8 +446,7 @@ void CommandCategoryListBox::categorySelected(CuiConfigFunctionListBox* pFunctio 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( - OUString::number(reinterpret_cast<sal_Int64>(m_aGroupInfo.back().get())), - pIt.sLabel)); + weld::toId(m_aGroupInfo.back().get()), pIt.sLabel)); const std::vector<SfxStyleInfo_Impl> lStyles = pStylesInfo->getStyles(pIt.sFamily); @@ -486,9 +476,8 @@ void CommandCategoryListBox::categorySelected(CuiConfigFunctionListBox* pFunctio m_aGroupInfo.back()->sCommand = pStyle->sCommand; m_aGroupInfo.back()->sLabel = pStyle->sLabel; - pFunctionListBox->append( - OUString::number(reinterpret_cast<sal_Int64>(m_aGroupInfo.back().get())), - sUIName, xFuncEntry.get()); + pFunctionListBox->append(weld::toId(m_aGroupInfo.back().get()), sUIName, + xFuncEntry.get()); } // Remove the style group from the list if no children @@ -547,8 +536,7 @@ void CommandCategoryListBox::addChildren( m_aGroupInfo.push_back(std::make_unique<SfxGroupInfo_Impl>( SfxCfgKind::GROUP_SCRIPTCONTAINER, 0, static_cast<void*>(child.get()))); std::unique_ptr<weld::TreeIter> xNewEntry(pFunctionListBox->tree_append( - OUString::number(reinterpret_cast<sal_Int64>(m_aGroupInfo.back().get())), sUIName, - parentEntry)); + weld::toId(m_aGroupInfo.back().get()), sUIName, parentEntry)); addChildren(xNewEntry.get(), child, pFunctionListBox, filterTerm, pCurrentSaveInData, rNodesToExpand); @@ -596,7 +584,7 @@ void CommandCategoryListBox::addChildren( if (description.isEmpty()) { - description = CuiResId(RID_SVXSTR_NOMACRODESC); + description = CuiResId(RID_CUISTR_NOMACRODESC); } OUString* pScriptURI = new OUString(uri); @@ -610,9 +598,8 @@ void CommandCategoryListBox::addChildren( m_aGroupInfo.back()->sCommand = uri; m_aGroupInfo.back()->sLabel = sUIName; m_aGroupInfo.back()->sHelpText = description; - pFunctionListBox->append( - OUString::number(reinterpret_cast<sal_Int64>(m_aGroupInfo.back().get())), sUIName, - xImage, parentEntry); + pFunctionListBox->append(weld::toId(m_aGroupInfo.back().get()), sUIName, xImage, + parentEntry); } } } diff --git a/cui/source/customize/CustomNotebookbarGenerator.cxx b/cui/source/customize/CustomNotebookbarGenerator.cxx index 392ea3e37a4e..1d013654d8f7 100644 --- a/cui/source/customize/CustomNotebookbarGenerator.cxx +++ b/cui/source/customize/CustomNotebookbarGenerator.cxx @@ -29,6 +29,7 @@ #include <com/sun/star/frame/ModuleManager.hpp> #include <unotools/confignode.hxx> #include <libxml/parser.h> +#include <o3tl/string_view.hxx> #define aUIPropertiesCount 3 @@ -73,11 +74,14 @@ static OUString lcl_getAppName(vcl::EnumContext::Application eApp) static OUString getAppNameRegistryPath() { vcl::EnumContext::Application eApp = vcl::EnumContext::Application::Any; - const Reference<frame::XFrame>& xFrame - = SfxViewFrame::Current()->GetFrame().GetFrameInterface(); - const Reference<frame::XModuleManager> xModuleManager - = frame::ModuleManager::create(::comphelper::getProcessComponentContext()); - eApp = vcl::EnumContext::GetApplicationEnum(xModuleManager->identify(xFrame)); + + if (SfxViewFrame* pViewFrame = SfxViewFrame::Current()) + { + const Reference<frame::XFrame>& xFrame = pViewFrame->GetFrame().GetFrameInterface(); + const Reference<frame::XModuleManager> xModuleManager + = frame::ModuleManager::create(::comphelper::getProcessComponentContext()); + eApp = vcl::EnumContext::GetApplicationEnum(xModuleManager->identify(xFrame)); + } OUString sAppName(lcl_getAppName(eApp)); return "org.openoffice.Office.UI.ToolbarMode/Applications/" + sAppName; @@ -180,14 +184,18 @@ static xmlDocPtr notebookbarXMLParser(const OString& rDocName, const OString& rU void CustomNotebookbarGenerator::modifyCustomizedUIFile(const Sequence<OUString>& sUIItemProperties) { - OString sCustomizedUIPath = getSystemPath(getCustomizedUIPath()); + const OUString sUIPath = getCustomizedUIPath(); + if (osl::File(sUIPath).open(osl_File_OpenFlag_Read) != osl::FileBase::E_None) + createCustomizedUIFile(); + + const OString sCustomizedUIPath = getSystemPath(sUIPath); for (auto const& aValue : sUIItemProperties) { std::vector<OString> aProperties(aUIPropertiesCount); for (sal_Int32 aIndex = 0; aIndex < aUIPropertiesCount; aIndex++) { sal_Int32 nPos = aIndex; - OUString sToken = aValue.getToken(nPos, ',', nPos); + std::u16string_view sToken = o3tl::getToken(aValue, nPos, ',', nPos); aProperties[aIndex] = OUStringToOString(sToken, RTL_TEXTENCODING_UTF8); } xmlDocPtr doc = notebookbarXMLParser(sCustomizedUIPath, aProperties[0], aProperties[1], @@ -257,16 +265,16 @@ Sequence<OUString> CustomNotebookbarGenerator::getCustomizedUIItem(OUString sNot return aValues; } -void CustomNotebookbarGenerator::setCustomizedUIItem(Sequence<OUString> sUIItemProperties, - OUString sNotebookbarConfigType) +void CustomNotebookbarGenerator::setCustomizedUIItem(const Sequence<OUString>& rUIItemProperties, + const OUString& rNotebookbarConfigType) { OUString aPath = getAppNameRegistryPath(); const utl::OConfigurationTreeRoot aAppNode(::comphelper::getProcessComponentContext(), aPath, true); const utl::OConfigurationNode aModesNode = aAppNode.openNode("Modes"); - const utl::OConfigurationNode aModeNode(aModesNode.openNode(sNotebookbarConfigType)); + const utl::OConfigurationNode aModeNode(aModesNode.openNode(rNotebookbarConfigType)); - css::uno::Any aUIItemProperties(makeAny(sUIItemProperties)); + css::uno::Any aUIItemProperties(rUIItemProperties); aModeNode.setNodeValue("UIItemProperties", aUIItemProperties); aAppNode.commit(); } diff --git a/cui/source/customize/SvxConfigPageHelper.cxx b/cui/source/customize/SvxConfigPageHelper.cxx index 52265ef093e6..59a2cdb64017 100644 --- a/cui/source/customize/SvxConfigPageHelper.cxx +++ b/cui/source/customize/SvxConfigPageHelper.cxx @@ -66,11 +66,11 @@ void SvxConfigPageHelper::InitImageType() { theImageType = css::ui::ImageType::COLOR_NORMAL | css::ui::ImageType::SIZE_DEFAULT; - if (SvtMiscOptions().GetCurrentSymbolsSize() == SFX_SYMBOLS_SIZE_LARGE) + if (SvtMiscOptions::GetCurrentSymbolsSize() == SFX_SYMBOLS_SIZE_LARGE) { theImageType |= css::ui::ImageType::SIZE_LARGE; } - else if (SvtMiscOptions().GetCurrentSymbolsSize() == SFX_SYMBOLS_SIZE_32) + else if (SvtMiscOptions::GetCurrentSymbolsSize() == SFX_SYMBOLS_SIZE_32) { theImageType |= css::ui::ImageType::SIZE_32; } @@ -248,7 +248,7 @@ OUString SvxConfigPageHelper::GetUIModuleName( if (a >>= aSeq) { - for (css::beans::PropertyValue const& rProp : std::as_const(aSeq)) + for (css::beans::PropertyValue const& rProp : aSeq) { if (rProp.Name == "ooSetupFactoryUIName") { @@ -282,7 +282,7 @@ bool SvxConfigPageHelper::GetMenuItemData( css::uno::Sequence<css::beans::PropertyValue> aProps; if (rItemContainer->getByIndex(nIndex) >>= aProps) { - for (css::beans::PropertyValue const& rProp : std::as_const(aProps)) + for (css::beans::PropertyValue const& rProp : aProps) { if (rProp.Name == ITEM_DESCRIPTOR_COMMANDURL) { @@ -325,7 +325,7 @@ bool SvxConfigPageHelper::GetToolbarItemData( css::uno::Sequence<css::beans::PropertyValue> aProps; if (rItemContainer->getByIndex(nIndex) >>= aProps) { - for (css::beans::PropertyValue const& rProp : std::as_const(aProps)) + for (css::beans::PropertyValue const& rProp : aProps) { if (rProp.Name == ITEM_DESCRIPTOR_COMMANDURL) { diff --git a/cui/source/customize/SvxMenuConfigPage.cxx b/cui/source/customize/SvxMenuConfigPage.cxx index 34cee1368d7a..4ee5ce9be0ca 100644 --- a/cui/source/customize/SvxMenuConfigPage.cxx +++ b/cui/source/customize/SvxMenuConfigPage.cxx @@ -20,6 +20,7 @@ #include <sal/config.h> #include <sal/log.hxx> +#include <dlgname.hxx> #include <vcl/weld.hxx> #include <vcl/svapp.hxx> #include <vcl/commandevent.hxx> @@ -34,8 +35,6 @@ #include <comphelper/processfactory.hxx> -#include <dlgname.hxx> - SvxMenuConfigPage::SvxMenuConfigPage(weld::Container* pPage, weld::DialogController* pController, const SfxItemSet& rSet, bool bIsMenuBar) : SvxConfigPage(pPage, pController, rSet) @@ -100,8 +99,7 @@ void SvxMenuConfigPage::ListModified() pEntries->clear(); for (int i = 0; i < m_xContentsListBox->n_children(); ++i) - pEntries->push_back( - reinterpret_cast<SvxConfigEntry*>(m_xContentsListBox->get_id(i).toInt64())); + pEntries->push_back(weld::fromId<SvxConfigEntry*>(m_xContentsListBox->get_id(i))); GetSaveInData()->SetModified(); GetTopLevelSelection()->SetModified(); @@ -123,7 +121,7 @@ IMPL_LINK(SvxMenuConfigPage, MenuEntriesSizeAllocHdl, const Size&, rSize, void) SvxMenuConfigPage::~SvxMenuConfigPage() { for (int i = 0, nCount = m_xSaveInListBox->get_count(); i < nCount; ++i) - delete reinterpret_cast<SaveInData*>(m_xSaveInListBox->get_id(i).toInt64()); + delete weld::fromId<SaveInData*>(m_xSaveInListBox->get_id(i)); m_xSaveInListBox->clear(); } @@ -136,7 +134,7 @@ void SvxMenuConfigPage::Init() ReloadTopLevelListBox(); - m_xTopLevelListBox->set_active(0); + m_xTopLevelListBox->set_active(m_xTopLevelListBox->get_count() ? 0 : -1); SelectElement(); m_xCommandCategoryListBox->Init(comphelper::getProcessComponentContext(), m_xFrame, @@ -154,8 +152,7 @@ void SvxMenuConfigPage::UpdateButtonStates() bool bIsSeparator = selection != -1 - && reinterpret_cast<SvxConfigEntry*>(m_xContentsListBox->get_id(selection).toInt64()) - ->IsSeparator(); + && weld::fromId<SvxConfigEntry*>(m_xContentsListBox->get_id(selection))->IsSeparator(); bool bIsValidSelection = (m_xContentsListBox->n_children() != 0 && selection != -1); m_xMoveUpButton->set_sensitive(bIsValidSelection && selection != 0); @@ -217,7 +214,7 @@ void SvxMenuConfigPage::DeleteSelectedContent() // get currently selected menu entry SvxConfigEntry* pMenuEntry - = reinterpret_cast<SvxConfigEntry*>(m_xContentsListBox->get_id(nActEntry).toInt64()); + = weld::fromId<SvxConfigEntry*>(m_xContentsListBox->get_id(nActEntry)); // get currently selected menu SvxConfigEntry* pMenu = GetTopLevelSelection(); @@ -243,7 +240,7 @@ void SvxMenuConfigPage::DeleteSelectedContent() short SvxMenuConfigPage::QueryReset() { - OUString msg = CuiResId(RID_SVXSTR_CONFIRM_MENU_RESET); + OUString msg = CuiResId(RID_CUISTR_CONFIRM_MENU_RESET); OUString saveInName = m_xSaveInListBox->get_active_text(); @@ -268,7 +265,7 @@ void SvxMenuConfigPage::SelectElement() rTreeView.bulk_insert_for_each( pEntries->size(), [this, &rTreeView, pEntries](weld::TreeIter& rIter, int nIdx) { auto const& entry = (*pEntries)[nIdx]; - OUString sId(OUString::number(reinterpret_cast<sal_Int64>(entry))); + OUString sId(weld::toId(entry)); rTreeView.set_id(rIter, sId); InsertEntryIntoUI(entry, rTreeView, rIter, true); }); @@ -277,7 +274,7 @@ void SvxMenuConfigPage::SelectElement() UpdateButtonStates(); } -IMPL_LINK(SvxMenuConfigPage, GearHdl, const OString&, rIdent, void) +IMPL_LINK(SvxMenuConfigPage, GearHdl, const OUString&, rIdent, void) { if (rIdent == "menu_gear_add") { @@ -300,11 +297,11 @@ IMPL_LINK(SvxMenuConfigPage, GearHdl, const OString&, rIdent, void) SvxConfigEntry* pMenuData = GetTopLevelSelection(); OUString sCurrentName(SvxConfigPageHelper::stripHotKey(pMenuData->GetName())); - OUString sDesc = CuiResId(RID_SVXSTR_LABEL_NEW_NAME); + OUString sDesc = CuiResId(RID_CUISTR_LABEL_NEW_NAME); SvxNameDialog aNameDialog(GetFrameWeld(), sCurrentName, sDesc); aNameDialog.set_help_id(HID_SVX_CONFIG_RENAME_MENU); - aNameDialog.set_title(CuiResId(RID_SVXSTR_RENAME_MENU)); + aNameDialog.set_title(CuiResId(RID_CUISTR_RENAME_MENU)); if (aNameDialog.run() == RET_OK) { @@ -360,7 +357,7 @@ IMPL_LINK_NOARG(SvxMenuConfigPage, AddCommandHdl, weld::Button&, void) if (nPos == -1) return; weld::TreeView& rTreeView = m_xContentsListBox->get_widget(); - SvxConfigEntry* pEntry = reinterpret_cast<SvxConfigEntry*>(rTreeView.get_id(nPos).toInt64()); + SvxConfigEntry* pEntry = weld::fromId<SvxConfigEntry*>(rTreeView.get_id(nPos)); InsertEntryIntoUI(pEntry, rTreeView, nPos, true); } @@ -373,7 +370,7 @@ IMPL_LINK_NOARG(SvxMenuConfigPage, RemoveCommandHdl, weld::Button&, void) } } -IMPL_LINK(SvxMenuConfigPage, InsertHdl, const OString&, rIdent, void) +IMPL_LINK(SvxMenuConfigPage, InsertHdl, const OUString&, rIdent, void) { weld::TreeView& rTreeView = m_xContentsListBox->get_widget(); if (rIdent == "insertseparator") @@ -386,11 +383,11 @@ IMPL_LINK(SvxMenuConfigPage, InsertHdl, const OString&, rIdent, void) else if (rIdent == "insertsubmenu") { OUString aNewName; - OUString aDesc = CuiResId(RID_SVXSTR_SUBMENU_NAME); + OUString aDesc = CuiResId(RID_CUISTR_SUBMENU_NAME); SvxNameDialog aNameDialog(GetFrameWeld(), aNewName, aDesc); aNameDialog.set_help_id(HID_SVX_CONFIG_NAME_SUBMENU); - aNameDialog.set_title(CuiResId(RID_SVXSTR_ADD_SUBMENU)); + aNameDialog.set_title(CuiResId(RID_CUISTR_ADD_SUBMENU)); if (aNameDialog.run() == RET_OK) { @@ -425,20 +422,20 @@ IMPL_LINK(SvxMenuConfigPage, InsertHdl, const OString&, rIdent, void) } } -IMPL_LINK(SvxMenuConfigPage, ModifyItemHdl, const OString&, rIdent, void) +IMPL_LINK(SvxMenuConfigPage, ModifyItemHdl, const OUString&, rIdent, void) { if (rIdent == "renameItem") { int nActEntry = m_xContentsListBox->get_selected_index(); SvxConfigEntry* pEntry - = reinterpret_cast<SvxConfigEntry*>(m_xContentsListBox->get_id(nActEntry).toInt64()); + = weld::fromId<SvxConfigEntry*>(m_xContentsListBox->get_id(nActEntry)); OUString aNewName(SvxConfigPageHelper::stripHotKey(pEntry->GetName())); - OUString aDesc = CuiResId(RID_SVXSTR_LABEL_NEW_NAME); + OUString aDesc = CuiResId(RID_CUISTR_LABEL_NEW_NAME); SvxNameDialog aNameDialog(GetFrameWeld(), aNewName, aDesc); aNameDialog.set_help_id(HID_SVX_CONFIG_RENAME_MENU_ITEM); - aNameDialog.set_title(CuiResId(RID_SVXSTR_RENAME_MENU)); + aNameDialog.set_title(CuiResId(RID_CUISTR_RENAME_MENU)); if (aNameDialog.run() == RET_OK) { @@ -477,7 +474,7 @@ IMPL_LINK_NOARG(SvxMenuConfigPage, ResetMenuHdl, weld::Button&, void) std::unique_ptr<weld::MessageDialog> xQueryBox(Application::CreateMessageDialog( GetFrameWeld(), VclMessageType::Question, VclButtonsType::YesNo, - CuiResId(RID_SVXSTR_CONFIRM_RESTORE_DEFAULT_MENU))); + CuiResId(RID_CUISTR_CONFIRM_RESTORE_DEFAULT_MENU))); // Resetting individual top-level menus is not possible at the moment. // So we are resetting only if it is a context menu @@ -531,8 +528,7 @@ IMPL_LINK(SvxMenuConfigPage, ContentContextMenuHdl, const CommandEvent&, rCEvt, bool bIsSeparator = nSelectIndex != -1 - && reinterpret_cast<SvxConfigEntry*>(m_xContentsListBox->get_id(nSelectIndex).toInt64()) - ->IsSeparator(); + && weld::fromId<SvxConfigEntry*>(m_xContentsListBox->get_id(nSelectIndex))->IsSeparator(); bool bIsValidSelection = (m_xContentsListBox->n_children() != 0 && nSelectIndex != -1); std::unique_ptr<weld::Builder> xBuilder( @@ -544,7 +540,7 @@ IMPL_LINK(SvxMenuConfigPage, ContentContextMenuHdl, const CommandEvent&, rCEvt, xContextMenu->set_visible("changeIcon", false); xContextMenu->set_visible("resetIcon", false); xContextMenu->set_visible("restoreDefault", false); - OString sCommand(xContextMenu->popup_at_rect( + OUString sCommand(xContextMenu->popup_at_rect( &rTreeView, tools::Rectangle(rCEvt.GetMousePosPixel(), Size(1, 1)))); if (sCommand == "remove") @@ -583,7 +579,7 @@ IMPL_LINK(SvxMenuConfigPage, FunctionContextMenuHdl, const CommandEvent&, rCEvt, xContextMenu->set_visible("changeIcon", false); xContextMenu->set_visible("resetIcon", false); xContextMenu->set_visible("restoreDefault", false); - OString sCommand(xContextMenu->popup_at_rect( + OUString sCommand(xContextMenu->popup_at_rect( &rTreeView, tools::Rectangle(rCEvt.GetMousePosPixel(), Size(1, 1)))); if (sCommand == "add") diff --git a/cui/source/customize/SvxNotebookbarConfigPage.cxx b/cui/source/customize/SvxNotebookbarConfigPage.cxx index 631c3b3c460f..7389d05b91d2 100644 --- a/cui/source/customize/SvxNotebookbarConfigPage.cxx +++ b/cui/source/customize/SvxNotebookbarConfigPage.cxx @@ -40,14 +40,13 @@ #include <sfx2/notebookbar/SfxNotebookBar.hxx> #include <unotools/configmgr.hxx> #include <comphelper/processfactory.hxx> +#include <o3tl/string_view.hxx> #include <com/sun/star/frame/theUICommandDescription.hpp> namespace uno = com::sun::star::uno; namespace frame = com::sun::star::frame; -namespace lang = com::sun::star::lang; namespace container = com::sun::star::container; namespace beans = com::sun::star::beans; -namespace graphic = com::sun::star::graphic; static bool isCategoryAvailable(std::u16string_view sClassId, std::u16string_view sUIItemId, std::u16string_view sActiveCategory, bool& isCategory) @@ -70,13 +69,13 @@ static OUString charToString(const char* cString) static OUString getFileName(std::u16string_view aFileName) { if (aFileName == u"notebookbar.ui") - return CuiResId(RID_SVXSTR_TABBED); + return CuiResId(RID_CUISTR_TABBED); else if (aFileName == u"notebookbar_compact.ui") - return CuiResId(RID_SVXSTR_TABBED_COMPACT); + return CuiResId(RID_CUISTR_TABBED_COMPACT); else if (aFileName == u"notebookbar_groupedbar_full.ui") - return CuiResId(RID_SVXSTR_GROUPEDBAR); + return CuiResId(RID_CUISTR_GROUPEDBAR); else if (aFileName == u"notebookbar_groupedbar_compact.ui") - return CuiResId(RID_SVXSTR_GROUPEDBAR_COMPACT); + return CuiResId(RID_CUISTR_GROUPEDBAR_COMPACT); else return "None"; } @@ -106,14 +105,11 @@ SvxNotebookbarConfigPage::SvxNotebookbarConfigPage(weld::Container* pPage, m_xDescriptionField->set_visible(false); m_xMoveUpButton->set_visible(false); m_xMoveDownButton->set_visible(false); - m_xAddCommandButton->set_visible(false); - m_xRemoveCommandButton->set_visible(false); + m_xCommandButtons->set_visible(false); m_xLeftFunctionLabel->set_visible(false); m_xSearchLabel->set_visible(false); m_xCategoryLabel->set_visible(false); - m_xInsertBtn->set_visible(false); - m_xModifyBtn->set_visible(false); - m_xResetBtn->set_visible(false); + m_xCustomizeBox->set_visible(false); m_xCustomizeLabel->set_visible(false); weld::TreeView& rCommandCategoryBox = m_xFunctions->get_widget(); @@ -144,7 +140,6 @@ void SvxNotebookbarConfigPage::Init() m_xTopLevelListBox->clear(); m_xContentsListBox->clear(); m_xSaveInListBox->clear(); - CustomNotebookbarGenerator::createCustomizedUIFile(); OUString sNotebookbarInterface = getFileName(m_sFileName); OUString sScopeName @@ -154,7 +149,7 @@ void SvxNotebookbarConfigPage::Init() m_xSaveInListBox->append(sSaveInListBoxID, sScopeName); m_xSaveInListBox->set_active_id(sSaveInListBoxID); - m_xTopLevelListBox->append("NotebookBar", CuiResId(RID_SVXSTR_ALL_COMMANDS)); + m_xTopLevelListBox->append("NotebookBar", CuiResId(RID_CUISTR_ALL_COMMANDS)); m_xTopLevelListBox->set_active_id("NotebookBar"); SelectElement(); } @@ -172,7 +167,7 @@ void SvxNotebookbarConfigPage::UpdateButtonStates() {} short SvxNotebookbarConfigPage::QueryReset() { - OUString msg = CuiResId(RID_SVXSTR_CONFIRM_TOOLBAR_RESET); + OUString msg = CuiResId(RID_CUISTR_CONFIRM_TOOLBAR_RESET); OUString saveInName = m_xSaveInListBox->get_active_text(); @@ -183,9 +178,8 @@ short SvxNotebookbarConfigPage::QueryReset() int nValue = xQueryBox->run(); if (nValue == RET_YES) { - OUString sOriginalUIPath = CustomNotebookbarGenerator::getOriginalUIPath(); - OUString sCustomizedUIPath = CustomNotebookbarGenerator::getCustomizedUIPath(); - osl::File::copy(sOriginalUIPath, sCustomizedUIPath); + osl::File::remove(CustomNotebookbarGenerator::getCustomizedUIPath()); + OUString sNotebookbarInterface = getFileName(m_sFileName); Sequence<OUString> sSequenceEntries; CustomNotebookbarGenerator::setCustomizedUIItem(sSequenceEntries, sNotebookbarInterface); @@ -221,7 +215,7 @@ void SvxConfigPage::InsertEntryIntoNotebookbarTabUI(std::u16string_view sClassId } OUString aLabel; - for (auto const& prop : std::as_const(aPropSeq)) + for (auto const& prop : aPropSeq) if (prop.Name == "Name") prop.Value >>= aLabel; @@ -317,8 +311,9 @@ void SvxNotebookbarConfigPage::searchNodeandAttribute(std::vector<NotebookbarEnt { sal_Int32 rPos = 0; aCategoryEntry.sDisplayName - = aCurItemEntry.sDisplayName.getToken(rPos, ' ', rPos) + " | " - + sUIItemId; + = OUString::Concat( + o3tl::getToken(aCurItemEntry.sDisplayName, rPos, ' ', rPos)) + + " | " + sUIItemId; } aCategoryList.push_back(aCategoryEntry); aCurItemEntry = aCategoryEntry; @@ -398,6 +393,13 @@ void SvxNotebookbarConfigPage::SelectElement() CustomNotebookbarGenerator::getCustomizedUIPath()); xmlDocPtr pDoc = xmlParseFile(sUIFileUIPath.getStr()); if (!pDoc) + { + sUIFileUIPath = CustomNotebookbarGenerator::getSystemPath( + CustomNotebookbarGenerator::getOriginalUIPath()); + pDoc = xmlParseFile(sUIFileUIPath.getStr()); + } + + if (!pDoc) return; xmlNodePtr pNodePtr = xmlDocGetRootElement(pDoc); @@ -408,9 +410,8 @@ void SvxNotebookbarConfigPage::SelectElement() if (m_xTopLevelListBox->get_count() == 1) { - for (std::size_t nIdx = 0; nIdx < aCategoryList.size(); nIdx++) - m_xTopLevelListBox->append(aCategoryList[nIdx].sUIItemId, - aCategoryList[nIdx].sDisplayName); + for (const auto& rCategory : aCategoryList) + m_xTopLevelListBox->append(rCategory.sUIItemId, rCategory.sDisplayName); } tools::ULong nStart = 0; if (aEntries[nStart].sClassId == "sfxlo-PriorityHBox" @@ -433,11 +434,10 @@ void SvxNotebookbarConfigPage::SelectElement() aEntries = std::move(aTempEntries); + static_cast<SvxNotebookbarEntriesListBox*>(m_xContentsListBox.get())->GetTooltipMap().clear(); weld::TreeView& rTreeView = m_xContentsListBox->get_widget(); rTreeView.bulk_insert_for_each( aEntries.size(), [this, &rTreeView, &aEntries](weld::TreeIter& rIter, int nIdx) { - OUString sId(OUString::number(nIdx)); - rTreeView.set_id(rIter, sId); if (aEntries[nIdx].sActionName != "Null") { if (aEntries[nIdx].sVisibleValue == "True") @@ -451,6 +451,13 @@ void SvxNotebookbarConfigPage::SelectElement() } InsertEntryIntoNotebookbarTabUI(aEntries[nIdx].sClassId, aEntries[nIdx].sDisplayName, aEntries[nIdx].sActionName, rTreeView, rIter); + if (aEntries[nIdx].sClassId != u"GtkSeparatorMenuItem" + && aEntries[nIdx].sClassId != u"GtkSeparator") + { + static_cast<SvxNotebookbarEntriesListBox*>(m_xContentsListBox.get()) + ->GetTooltipMap()[aEntries[nIdx].sDisplayName] + = aEntries[nIdx].sActionName; + } }); aEntries.clear(); @@ -465,6 +472,9 @@ SvxNotebookbarEntriesListBox::SvxNotebookbarEntriesListBox(std::unique_ptr<weld: m_xControl->connect_toggled(LINK(this, SvxNotebookbarEntriesListBox, CheckButtonHdl)); m_xControl->connect_key_press(Link<const KeyEvent&, bool>()); m_xControl->connect_key_press(LINK(this, SvxNotebookbarEntriesListBox, KeyInputHdl)); + // remove the inherited connect_query_tooltip then add the new one + m_xControl->connect_query_tooltip(Link<const weld::TreeIter&, OUString>()); + m_xControl->connect_query_tooltip(LINK(this, SvxNotebookbarEntriesListBox, QueryTooltip)); } SvxNotebookbarEntriesListBox::~SvxNotebookbarEntriesListBox() {} @@ -480,7 +490,7 @@ static void EditRegistryFile(std::u16string_view sUIItemId, const OUString& sSet for (int nIdx = 0; nIdx < aOldEntries.getLength(); nIdx++) { sal_Int32 rPos = 0; - OUString sFirstValue = aOldEntries[nIdx].getToken(rPos, ',', rPos); + std::u16string_view sFirstValue = o3tl::getToken(aOldEntries[nIdx], rPos, ',', rPos); if (sFirstValue == sUIItemId) { aOldEntries.getArray()[nIdx] = sSetEntry; @@ -538,4 +548,19 @@ IMPL_LINK(SvxNotebookbarEntriesListBox, KeyInputHdl, const KeyEvent&, rKeyEvent, return SvxMenuEntriesListBox::KeyInputHdl(rKeyEvent); } +IMPL_LINK(SvxNotebookbarEntriesListBox, QueryTooltip, const weld::TreeIter&, rIter, OUString) +{ + const OUString& rsCommand = m_aTooltipMap[m_xControl->get_id(rIter)]; + if (rsCommand.isEmpty()) + return OUString(); + OUString aModuleName(vcl::CommandInfoProvider::GetModuleIdentifier(m_pPage->GetFrame())); + auto aProperties = vcl::CommandInfoProvider::GetCommandProperties(rsCommand, aModuleName); + OUString sTooltipLabel = vcl::CommandInfoProvider::GetTooltipForCommand(rsCommand, aProperties, + m_pPage->GetFrame()); + return CuiResId(RID_CUISTR_COMMANDLABEL) + ": " + + m_xControl->get_text(rIter).replaceFirst("~", "") + "\n" + + CuiResId(RID_CUISTR_COMMANDNAME) + ": " + rsCommand + "\n" + + CuiResId(RID_CUISTR_COMMANDTIP) + ": " + sTooltipLabel.replaceFirst("~", ""); +} + /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/cui/source/customize/SvxToolbarConfigPage.cxx b/cui/source/customize/SvxToolbarConfigPage.cxx index 99a85d82f96e..1997de819d29 100644 --- a/cui/source/customize/SvxToolbarConfigPage.cxx +++ b/cui/source/customize/SvxToolbarConfigPage.cxx @@ -27,7 +27,7 @@ #include <sfx2/sfxsids.hrc> #include <svl/stritem.hxx> -#include <tools/diagnose_ex.h> +#include <comphelper/diagnose_ex.hxx> #include <algorithm> #include <helpids.h> @@ -38,9 +38,8 @@ #include <SvxConfigPageHelper.hxx> #include <dialmgr.hxx> -#include <comphelper/processfactory.hxx> - #include <dlgname.hxx> +#include <comphelper/processfactory.hxx> SvxToolbarConfigPage::SvxToolbarConfigPage(weld::Container* pPage, weld::DialogController* pController, @@ -106,7 +105,7 @@ SvxToolbarConfigPage::SvxToolbarConfigPage(weld::Container* pPage, m_aURLToSelect = ITEM_TOOLBAR_URL; m_aURLToSelect += "standardbar"; - const SfxPoolItem* pItem = rSet.GetItem(rSet.GetPool()->GetWhich(SID_CONFIG)); + const SfxPoolItem* pItem = rSet.GetItem(SID_CONFIG); if (pItem) { @@ -125,8 +124,7 @@ void SvxToolbarConfigPage::ListModified() pEntries->clear(); for (int i = 0; i < m_xContentsListBox->n_children(); ++i) - pEntries->push_back( - reinterpret_cast<SvxConfigEntry*>(m_xContentsListBox->get_id(i).toInt64())); + pEntries->push_back(weld::fromId<SvxConfigEntry*>(m_xContentsListBox->get_id(i))); GetSaveInData()->SetModified(); GetTopLevelSelection()->SetModified(); @@ -140,8 +138,7 @@ SvxToolbarConfigPage::~SvxToolbarConfigPage() { for (int i = 0, nCount = m_xSaveInListBox->get_count(); i < nCount; ++i) { - ToolbarSaveInData* pData - = reinterpret_cast<ToolbarSaveInData*>(m_xSaveInListBox->get_id(i).toInt64()); + ToolbarSaveInData* pData = weld::fromId<ToolbarSaveInData*>(m_xSaveInListBox->get_id(i)); delete pData; } m_xSaveInListBox->clear(); @@ -186,8 +183,7 @@ void SvxToolbarConfigPage::DeleteSelectedContent() return; // get currently selected entry - SvxConfigEntry* pEntry - = reinterpret_cast<SvxConfigEntry*>(m_xContentsListBox->get_id(nActEntry).toInt64()); + SvxConfigEntry* pEntry = weld::fromId<SvxConfigEntry*>(m_xContentsListBox->get_id(nActEntry)); SvxConfigEntry* pToolbar = GetTopLevelSelection(); @@ -246,13 +242,14 @@ void SvxToolbarConfigPage::Init() ReloadTopLevelListBox(); - sal_Int32 nPos = 0; + sal_Int32 nCount = m_xTopLevelListBox->get_count(); + sal_Int32 nPos = nCount > 0 ? 0 : -1; + if (!m_aURLToSelect.isEmpty()) { - for (sal_Int32 i = 0, nCount = m_xTopLevelListBox->get_count(); i < nCount; ++i) + for (sal_Int32 i = 0; i < nCount; ++i) { - SvxConfigEntry* pData - = reinterpret_cast<SvxConfigEntry*>(m_xTopLevelListBox->get_id(i).toInt64()); + SvxConfigEntry* pData = weld::fromId<SvxConfigEntry*>(m_xTopLevelListBox->get_id(i)); if (pData->GetCommand().equals(m_aURLToSelect)) { @@ -289,13 +286,13 @@ IMPL_LINK_NOARG(SvxToolbarConfigPage, SelectToolbarEntry, weld::TreeView&, void) UpdateButtonStates(); } -IMPL_LINK(SvxToolbarConfigPage, GearHdl, const OString&, rIdent, void) +IMPL_LINK(SvxToolbarConfigPage, GearHdl, const OUString&, rIdent, void) { SvxConfigEntry* pCurrentToolbar = GetTopLevelSelection(); if (rIdent == "toolbar_gear_add") { - OUString prefix = CuiResId(RID_SVXSTR_NEW_TOOLBAR); + OUString prefix = CuiResId(RID_CUISTR_NEW_TOOLBAR); OUString aNewName = SvxConfigPageHelper::generateCustomName(prefix, GetSaveInData()->GetEntries()); @@ -317,8 +314,8 @@ IMPL_LINK(SvxToolbarConfigPage, GearHdl, const OString&, rIdent, void) // Where to save the new toolbar? (i.e. Modulewise or documentwise) int nInsertPos = aNameDialog.m_xSaveInListBox->get_active(); - ToolbarSaveInData* pData = reinterpret_cast<ToolbarSaveInData*>( - m_xSaveInListBox->get_id(nInsertPos).toInt64()); + ToolbarSaveInData* pData + = weld::fromId<ToolbarSaveInData*>(m_xSaveInListBox->get_id(nInsertPos)); if (GetSaveInData() != pData) { @@ -333,7 +330,7 @@ IMPL_LINK(SvxToolbarConfigPage, GearHdl, const OString&, rIdent, void) pData->CreateToolbar(pToolbar); - OUString sId(OUString::number(reinterpret_cast<sal_Int64>(pToolbar))); + OUString sId(weld::toId(pToolbar)); m_xTopLevelListBox->append(sId, pToolbar->GetName()); m_xTopLevelListBox->set_active_id(sId); SelectElement(); @@ -352,17 +349,17 @@ IMPL_LINK(SvxToolbarConfigPage, GearHdl, const OString&, rIdent, void) else if (rIdent == "toolbar_gear_rename") { sal_Int32 nSelectionPos = m_xTopLevelListBox->get_active(); - SvxConfigEntry* pToolbar = reinterpret_cast<SvxConfigEntry*>( - m_xTopLevelListBox->get_id(nSelectionPos).toInt64()); + SvxConfigEntry* pToolbar + = weld::fromId<SvxConfigEntry*>(m_xTopLevelListBox->get_id(nSelectionPos)); ToolbarSaveInData* pSaveInData = static_cast<ToolbarSaveInData*>(GetSaveInData()); //Rename the toolbar OUString sCurrentName(SvxConfigPageHelper::stripHotKey(pToolbar->GetName())); - OUString sDesc = CuiResId(RID_SVXSTR_LABEL_NEW_NAME); + OUString sDesc = CuiResId(RID_CUISTR_LABEL_NEW_NAME); SvxNameDialog aNameDialog(GetFrameWeld(), sCurrentName, sDesc); aNameDialog.set_help_id(HID_SVX_CONFIG_RENAME_TOOLBAR); - aNameDialog.set_title(CuiResId(RID_SVXSTR_RENAME_TOOLBAR)); + aNameDialog.set_title(CuiResId(RID_CUISTR_RENAME_TOOLBAR)); if (aNameDialog.run() == RET_OK) { @@ -376,7 +373,7 @@ IMPL_LINK(SvxToolbarConfigPage, GearHdl, const OString&, rIdent, void) // have to use remove and insert to change the name m_xTopLevelListBox->remove(nSelectionPos); - OUString sId(OUString::number(reinterpret_cast<sal_Int64>(pToolbar))); + OUString sId(weld::toId(pToolbar)); m_xTopLevelListBox->insert(nSelectionPos, sNewName, &sId, nullptr, nullptr); m_xTopLevelListBox->set_active_id(sId); } @@ -429,7 +426,7 @@ IMPL_LINK_NOARG(SvxToolbarConfigPage, RemoveCommandHdl, weld::Button&, void) DeleteSelectedContent(); } -IMPL_LINK(SvxToolbarConfigPage, InsertHdl, const OString&, rIdent, void) +IMPL_LINK(SvxToolbarConfigPage, InsertHdl, const OUString&, rIdent, void) { if (rIdent == "insertseparator") { @@ -454,7 +451,7 @@ IMPL_LINK(SvxToolbarConfigPage, InsertHdl, const OString&, rIdent, void) } } -IMPL_LINK(SvxToolbarConfigPage, ModifyItemHdl, const OString&, rIdent, void) +IMPL_LINK(SvxToolbarConfigPage, ModifyItemHdl, const OUString&, rIdent, void) { bool bNeedsApply = false; @@ -471,14 +468,14 @@ IMPL_LINK(SvxToolbarConfigPage, ModifyItemHdl, const OString&, rIdent, void) { int nActEntry = m_xContentsListBox->get_selected_index(); SvxConfigEntry* pEntry - = reinterpret_cast<SvxConfigEntry*>(m_xContentsListBox->get_id(nActEntry).toInt64()); + = weld::fromId<SvxConfigEntry*>(m_xContentsListBox->get_id(nActEntry)); OUString aNewName(SvxConfigPageHelper::stripHotKey(pEntry->GetName())); - OUString aDesc = CuiResId(RID_SVXSTR_LABEL_NEW_NAME); + OUString aDesc = CuiResId(RID_CUISTR_LABEL_NEW_NAME); SvxNameDialog aNameDialog(GetFrameWeld(), aNewName, aDesc); aNameDialog.set_help_id(HID_SVX_CONFIG_RENAME_TOOLBAR_ITEM); - aNameDialog.set_title(CuiResId(RID_SVXSTR_RENAME_TOOLBAR)); + aNameDialog.set_title(CuiResId(RID_CUISTR_RENAME_TOOLBAR)); if (aNameDialog.run() == RET_OK) { @@ -497,7 +494,7 @@ IMPL_LINK(SvxToolbarConfigPage, ModifyItemHdl, const OString&, rIdent, void) { int nActEntry = m_xContentsListBox->get_selected_index(); SvxConfigEntry* pEntry - = reinterpret_cast<SvxConfigEntry*>(m_xContentsListBox->get_id(nActEntry).toInt64()); + = weld::fromId<SvxConfigEntry*>(m_xContentsListBox->get_id(nActEntry)); SvxIconSelectorDialog aIconDialog(GetFrameWeld(), GetSaveInData()->GetImageManager(), GetSaveInData()->GetParentImageManager()); @@ -532,7 +529,7 @@ IMPL_LINK(SvxToolbarConfigPage, ModifyItemHdl, const OString&, rIdent, void) m_xContentsListBox->remove(nActEntry); - OUString sId(OUString::number(reinterpret_cast<sal_Int64>(pEntry))); + OUString sId(weld::toId(pEntry)); m_xContentsListBox->insert(nActEntry, sId); m_xContentsListBox->set_toggle(nActEntry, pEntry->IsVisible() ? TRISTATE_TRUE : TRISTATE_FALSE); @@ -554,11 +551,11 @@ IMPL_LINK(SvxToolbarConfigPage, ModifyItemHdl, const OString&, rIdent, void) { int nActEntry = m_xContentsListBox->get_selected_index(); SvxConfigEntry* pEntry - = reinterpret_cast<SvxConfigEntry*>(m_xContentsListBox->get_id(nActEntry).toInt64()); - - css::uno::Reference<css::graphic::XGraphic> backup = pEntry->GetBackupGraphic(); + = weld::fromId<SvxConfigEntry*>(m_xContentsListBox->get_id(nActEntry)); - css::uno::Sequence<css::uno::Reference<css::graphic::XGraphic>> aGraphicSeq{ backup }; + css::uno::Sequence<css::uno::Reference<css::graphic::XGraphic>> aGraphicSeq{ + pEntry->GetBackupGraphic() + }; css::uno::Sequence<OUString> aURLSeq{ pEntry->GetCommand() }; @@ -569,7 +566,7 @@ IMPL_LINK(SvxToolbarConfigPage, ModifyItemHdl, const OString&, rIdent, void) m_xContentsListBox->remove(nActEntry); - OUString sId(OUString::number(reinterpret_cast<sal_Int64>(pEntry))); + OUString sId(weld::toId(pEntry)); m_xContentsListBox->insert(nActEntry, sId); m_xContentsListBox->set_toggle(nActEntry, pEntry->IsVisible() ? TRISTATE_TRUE : TRISTATE_FALSE); @@ -592,7 +589,7 @@ IMPL_LINK(SvxToolbarConfigPage, ModifyItemHdl, const OString&, rIdent, void) { int nActEntry = m_xContentsListBox->get_selected_index(); SvxConfigEntry* pEntry - = reinterpret_cast<SvxConfigEntry*>(m_xContentsListBox->get_id(nActEntry).toInt64()); + = weld::fromId<SvxConfigEntry*>(m_xContentsListBox->get_id(nActEntry)); ToolbarSaveInData* pSaveInData = static_cast<ToolbarSaveInData*>(GetSaveInData()); @@ -620,7 +617,7 @@ IMPL_LINK(SvxToolbarConfigPage, ModifyItemHdl, const OString&, rIdent, void) m_xContentsListBox->remove(nActEntry); - OUString sId(OUString::number(reinterpret_cast<sal_Int64>(pEntry))); + OUString sId(weld::toId(pEntry)); m_xContentsListBox->insert(nActEntry, sId); m_xContentsListBox->set_toggle(nActEntry, pEntry->IsVisible() ? TRISTATE_TRUE : TRISTATE_FALSE); @@ -655,11 +652,11 @@ IMPL_LINK_NOARG(SvxToolbarConfigPage, ResetToolbarHdl, weld::Button&, void) sal_Int32 nSelectionPos = m_xTopLevelListBox->get_active(); SvxConfigEntry* pToolbar - = reinterpret_cast<SvxConfigEntry*>(m_xTopLevelListBox->get_id(nSelectionPos).toInt64()); + = weld::fromId<SvxConfigEntry*>(m_xTopLevelListBox->get_id(nSelectionPos)); std::unique_ptr<weld::MessageDialog> xQueryBox(Application::CreateMessageDialog( GetFrameWeld(), VclMessageType::Question, VclButtonsType::YesNo, - CuiResId(RID_SVXSTR_CONFIRM_RESTORE_DEFAULT))); + CuiResId(RID_CUISTR_CONFIRM_RESTORE_DEFAULT))); if (xQueryBox->run() == RET_YES) { ToolbarSaveInData* pSaveInData = static_cast<ToolbarSaveInData*>(GetSaveInData()); @@ -677,8 +674,7 @@ void SvxToolbarConfigPage::UpdateButtonStates() bool bIsSeparator = selection != -1 - && reinterpret_cast<SvxConfigEntry*>(m_xContentsListBox->get_id(selection).toInt64()) - ->IsSeparator(); + && weld::fromId<SvxConfigEntry*>(m_xContentsListBox->get_id(selection))->IsSeparator(); bool bIsValidSelection = (m_xContentsListBox->n_children() != 0 && selection != -1); m_xMoveUpButton->set_sensitive(bIsValidSelection); @@ -696,7 +692,7 @@ void SvxToolbarConfigPage::UpdateButtonStates() short SvxToolbarConfigPage::QueryReset() { - OUString msg = CuiResId(RID_SVXSTR_CONFIRM_TOOLBAR_RESET); + OUString msg = CuiResId(RID_CUISTR_CONFIRM_TOOLBAR_RESET); OUString saveInName = m_xSaveInListBox->get_active_text(); @@ -751,7 +747,7 @@ void SvxToolbarConfigPage::SelectElement() SvxEntries* pEntries = pToolbar->GetEntries(); for (auto const& entry : *pEntries) { - OUString sId(OUString::number(reinterpret_cast<sal_Int64>(entry))); + OUString sId(weld::toId(entry)); m_xContentsListBox->insert(i, sId); if (entry->IsBinding() && !entry->IsSeparator()) m_xContentsListBox->set_toggle(i, entry->IsVisible() ? TRISTATE_TRUE : TRISTATE_FALSE); @@ -775,8 +771,7 @@ void SvxToolbarConfigPage::AddFunction(int nTarget) if (nNewLBEntry == -1) return; - SvxConfigEntry* pEntry - = reinterpret_cast<SvxConfigEntry*>(m_xContentsListBox->get_id(nNewLBEntry).toInt64()); + SvxConfigEntry* pEntry = weld::fromId<SvxConfigEntry*>(m_xContentsListBox->get_id(nNewLBEntry)); if (pEntry->IsBinding()) //TODO sep ? { @@ -811,8 +806,7 @@ SvxToolbarEntriesListBox::~SvxToolbarEntriesListBox() {} void SvxToolbarEntriesListBox::ChangedVisibility(int nRow) { - SvxConfigEntry* pEntryData - = reinterpret_cast<SvxConfigEntry*>(m_xControl->get_id(nRow).toInt64()); + SvxConfigEntry* pEntryData = weld::fromId<SvxConfigEntry*>(m_xControl->get_id(nRow)); if (pEntryData->IsBinding()) { @@ -838,8 +832,7 @@ IMPL_LINK(SvxToolbarEntriesListBox, KeyInputHdl, const KeyEvent&, rKeyEvent, boo if (rKeyEvent.GetKeyCode() == KEY_SPACE) { int nRow = m_xControl->get_selected_index(); - SvxConfigEntry* pEntryData - = reinterpret_cast<SvxConfigEntry*>(m_xControl->get_id(nRow).toInt64()); + SvxConfigEntry* pEntryData = weld::fromId<SvxConfigEntry*>(m_xControl->get_id(nRow)); if (pEntryData->IsBinding() && !pEntryData->IsSeparator()) { m_xControl->set_toggle(nRow, m_xControl->get_toggle(nRow) == TRISTATE_TRUE @@ -870,8 +863,7 @@ IMPL_LINK(SvxToolbarConfigPage, ContentContextMenuHdl, const CommandEvent&, rCEv bool bIsSeparator = nSelectIndex != -1 - && reinterpret_cast<SvxConfigEntry*>(m_xContentsListBox->get_id(nSelectIndex).toInt64()) - ->IsSeparator(); + && weld::fromId<SvxConfigEntry*>(m_xContentsListBox->get_id(nSelectIndex))->IsSeparator(); bool bIsValidSelection = (m_xContentsListBox->n_children() != 0 && nSelectIndex != -1); std::unique_ptr<weld::Builder> xBuilder( @@ -883,7 +875,7 @@ IMPL_LINK(SvxToolbarConfigPage, ContentContextMenuHdl, const CommandEvent&, rCEv xContextMenu->set_visible("changeIcon", bIsValidSelection && !bIsSeparator); xContextMenu->set_visible("resetIcon", bIsValidSelection && !bIsSeparator); xContextMenu->set_visible("restoreDefault", bIsValidSelection && !bIsSeparator); - OString sCommand(xContextMenu->popup_at_rect( + OUString sCommand(xContextMenu->popup_at_rect( &rTreeView, tools::Rectangle(rCEvt.GetMousePosPixel(), Size(1, 1)))); if (sCommand == "remove") @@ -923,7 +915,7 @@ IMPL_LINK(SvxToolbarConfigPage, FunctionContextMenuHdl, const CommandEvent&, rCE xContextMenu->set_visible("changeIcon", false); xContextMenu->set_visible("resetIcon", false); xContextMenu->set_visible("restoreDefault", false); - OString sCommand(xContextMenu->popup_at_rect( + OUString sCommand(xContextMenu->popup_at_rect( &rTreeView, tools::Rectangle(rCEvt.GetMousePosPixel(), Size(1, 1)))); if (sCommand == "add") diff --git a/cui/source/customize/acccfg.cxx b/cui/source/customize/acccfg.cxx index 476b10d2e8e4..027ac72968e8 100644 --- a/cui/source/customize/acccfg.cxx +++ b/cui/source/customize/acccfg.cxx @@ -63,13 +63,15 @@ #include <comphelper/sequenceashashmap.hxx> #include <config_features.h> +#include <com/sun/star/frame/LayoutManager.hpp> + // namespaces using namespace css; -constexpr OUStringLiteral FOLDERNAME_UICONFIG = u"Configurations2"; +constexpr OUString FOLDERNAME_UICONFIG = u"Configurations2"_ustr; -constexpr OUStringLiteral MEDIATYPE_PROPNAME = u"MediaType"; +constexpr OUString MEDIATYPE_PROPNAME = u"MediaType"_ustr; const sal_uInt16 KEYCODE_ARRAY[] = { KEY_F1, KEY_F2, @@ -184,11 +186,14 @@ const sal_uInt16 KEYCODE_ARRAY[] = { KEY_F1, KEY_MOD1 | KEY_X, KEY_MOD1 | KEY_Y, KEY_MOD1 | KEY_Z, + KEY_MOD1 | KEY_NUMBERSIGN, + KEY_MOD1 | KEY_COLON, KEY_MOD1 | KEY_SEMICOLON, KEY_MOD1 | KEY_QUOTELEFT, KEY_MOD1 | KEY_QUOTERIGHT, KEY_MOD1 | KEY_BRACKETLEFT, KEY_MOD1 | KEY_BRACKETRIGHT, + KEY_MOD1 | KEY_RIGHTCURLYBRACKET, KEY_MOD1 | KEY_POINT, KEY_MOD1 | KEY_COMMA, KEY_MOD1 | KEY_TILDE, @@ -267,11 +272,14 @@ const sal_uInt16 KEYCODE_ARRAY[] = { KEY_F1, KEY_SHIFT | KEY_MOD1 | KEY_X, KEY_SHIFT | KEY_MOD1 | KEY_Y, KEY_SHIFT | KEY_MOD1 | KEY_Z, + KEY_SHIFT | KEY_MOD1 | KEY_NUMBERSIGN, + KEY_SHIFT | KEY_MOD1 | KEY_COLON, KEY_SHIFT | KEY_MOD1 | KEY_SEMICOLON, KEY_SHIFT | KEY_MOD1 | KEY_QUOTELEFT, KEY_SHIFT | KEY_MOD1 | KEY_QUOTERIGHT, KEY_SHIFT | KEY_MOD1 | KEY_BRACKETLEFT, KEY_SHIFT | KEY_MOD1 | KEY_BRACKETRIGHT, + KEY_SHIFT | KEY_MOD1 | KEY_RIGHTCURLYBRACKET, KEY_SHIFT | KEY_MOD1 | KEY_POINT, KEY_SHIFT | KEY_MOD1 | KEY_COMMA, KEY_SHIFT | KEY_MOD1 | KEY_TILDE, @@ -346,11 +354,14 @@ const sal_uInt16 KEYCODE_ARRAY[] = { KEY_F1, KEY_MOD2 | KEY_X, KEY_MOD2 | KEY_Y, KEY_MOD2 | KEY_Z, + KEY_MOD2 | KEY_NUMBERSIGN, + KEY_MOD2 | KEY_COLON, KEY_MOD2 | KEY_SEMICOLON, KEY_MOD2 | KEY_QUOTELEFT, KEY_MOD2 | KEY_QUOTERIGHT, KEY_MOD2 | KEY_BRACKETLEFT, KEY_MOD2 | KEY_BRACKETRIGHT, + KEY_MOD2 | KEY_RIGHTCURLYBRACKET, KEY_MOD2 | KEY_POINT, KEY_MOD2 | KEY_COMMA, KEY_MOD2 | KEY_TILDE, @@ -423,11 +434,14 @@ const sal_uInt16 KEYCODE_ARRAY[] = { KEY_F1, KEY_SHIFT | KEY_MOD2 | KEY_X, KEY_SHIFT | KEY_MOD2 | KEY_Y, KEY_SHIFT | KEY_MOD2 | KEY_Z, + KEY_SHIFT | KEY_MOD2 | KEY_NUMBERSIGN, + KEY_SHIFT | KEY_MOD2 | KEY_COLON, KEY_SHIFT | KEY_MOD2 | KEY_SEMICOLON, KEY_SHIFT | KEY_MOD2 | KEY_QUOTELEFT, KEY_SHIFT | KEY_MOD2 | KEY_QUOTERIGHT, KEY_SHIFT | KEY_MOD2 | KEY_BRACKETLEFT, KEY_SHIFT | KEY_MOD2 | KEY_BRACKETRIGHT, + KEY_SHIFT | KEY_MOD2 | KEY_RIGHTCURLYBRACKET, KEY_SHIFT | KEY_MOD2 | KEY_POINT, KEY_SHIFT | KEY_MOD2 | KEY_COMMA, KEY_SHIFT | KEY_MOD2 | KEY_TILDE, @@ -501,11 +515,14 @@ const sal_uInt16 KEYCODE_ARRAY[] = { KEY_F1, KEY_MOD1 | KEY_MOD2 | KEY_X, KEY_MOD1 | KEY_MOD2 | KEY_Y, KEY_MOD1 | KEY_MOD2 | KEY_Z, + KEY_MOD1 | KEY_MOD2 | KEY_NUMBERSIGN, + KEY_MOD1 | KEY_MOD2 | KEY_COLON, KEY_MOD1 | KEY_MOD2 | KEY_SEMICOLON, KEY_MOD1 | KEY_MOD2 | KEY_QUOTELEFT, KEY_MOD1 | KEY_MOD2 | KEY_QUOTERIGHT, KEY_MOD1 | KEY_MOD2 | KEY_BRACKETLEFT, KEY_MOD1 | KEY_MOD2 | KEY_BRACKETRIGHT, + KEY_MOD1 | KEY_MOD2 | KEY_RIGHTCURLYBRACKET, KEY_MOD1 | KEY_MOD2 | KEY_POINT, KEY_MOD1 | KEY_MOD2 | KEY_COMMA, KEY_MOD1 | KEY_MOD2 | KEY_TILDE, @@ -578,11 +595,14 @@ const sal_uInt16 KEYCODE_ARRAY[] = { KEY_F1, KEY_SHIFT | KEY_MOD1 | KEY_MOD2 | KEY_X, KEY_SHIFT | KEY_MOD1 | KEY_MOD2 | KEY_Y, KEY_SHIFT | KEY_MOD1 | KEY_MOD2 | KEY_Z, + KEY_SHIFT | KEY_MOD1 | KEY_MOD2 | KEY_NUMBERSIGN, + KEY_SHIFT | KEY_MOD1 | KEY_MOD2 | KEY_COLON, KEY_SHIFT | KEY_MOD1 | KEY_MOD2 | KEY_SEMICOLON, KEY_SHIFT | KEY_MOD1 | KEY_MOD2 | KEY_QUOTELEFT, KEY_SHIFT | KEY_MOD1 | KEY_MOD2 | KEY_QUOTERIGHT, KEY_SHIFT | KEY_MOD1 | KEY_MOD2 | KEY_BRACKETLEFT, KEY_SHIFT | KEY_MOD1 | KEY_MOD2 | KEY_BRACKETRIGHT, + KEY_SHIFT | KEY_MOD1 | KEY_MOD2 | KEY_RIGHTCURLYBRACKET, KEY_SHIFT | KEY_MOD1 | KEY_MOD2 | KEY_POINT, KEY_SHIFT | KEY_MOD1 | KEY_MOD2 | KEY_COMMA, KEY_SHIFT | KEY_MOD1 | KEY_MOD2 | KEY_TILDE, @@ -657,11 +677,14 @@ const sal_uInt16 KEYCODE_ARRAY[] = { KEY_F1, KEY_MOD3 | KEY_X, KEY_MOD3 | KEY_Y, KEY_MOD3 | KEY_Z, + KEY_MOD2 | KEY_NUMBERSIGN, + KEY_MOD3 | KEY_COLON, KEY_MOD3 | KEY_SEMICOLON, KEY_MOD3 | KEY_QUOTELEFT, KEY_MOD3 | KEY_QUOTERIGHT, KEY_MOD3 | KEY_BRACKETLEFT, KEY_MOD3 | KEY_BRACKETRIGHT, + KEY_MOD3 | KEY_RIGHTCURLYBRACKET, KEY_MOD3 | KEY_POINT, KEY_MOD3 | KEY_COMMA, KEY_MOD3 | KEY_TILDE, @@ -740,11 +763,14 @@ const sal_uInt16 KEYCODE_ARRAY[] = { KEY_F1, KEY_SHIFT | KEY_MOD3 | KEY_X, KEY_SHIFT | KEY_MOD3 | KEY_Y, KEY_SHIFT | KEY_MOD3 | KEY_Z, + KEY_SHIFT | KEY_MOD3 | KEY_NUMBERSIGN, + KEY_SHIFT | KEY_MOD3 | KEY_COLON, KEY_SHIFT | KEY_MOD3 | KEY_SEMICOLON, KEY_SHIFT | KEY_MOD3 | KEY_QUOTELEFT, KEY_SHIFT | KEY_MOD3 | KEY_QUOTERIGHT, KEY_SHIFT | KEY_MOD3 | KEY_BRACKETLEFT, KEY_SHIFT | KEY_MOD3 | KEY_BRACKETRIGHT, + KEY_SHIFT | KEY_MOD3 | KEY_RIGHTCURLYBRACKET, KEY_SHIFT | KEY_MOD3 | KEY_POINT, KEY_SHIFT | KEY_MOD3 | KEY_COMMA, KEY_SHIFT | KEY_MOD3 | KEY_TILDE, @@ -785,7 +811,7 @@ const sal_uInt16 KEYCODE_ARRAY[] = { KEY_F1, #endif }; -const sal_uInt16 KEYCODE_ARRAY_SIZE = SAL_N_ELEMENTS(KEYCODE_ARRAY); +const sal_uInt16 KEYCODE_ARRAY_SIZE = std::size(KEYCODE_ARRAY); /** select the entry, which match the current key input ... excepting keys, which are used for the dialog itself. @@ -797,23 +823,24 @@ IMPL_LINK(SfxAcceleratorConfigPage, KeyInputHdl, const KeyEvent&, rKey, bool) sal_uInt16 nMod1 = aCode1.GetModifier(); // is it related to our list box ? - if ((nCode1 != KEY_DOWN) && (nCode1 != KEY_UP) && (nCode1 != KEY_LEFT) && (nCode1 != KEY_RIGHT) - && (nCode1 != KEY_PAGEUP) && (nCode1 != KEY_PAGEDOWN)) + if ((nCode1 == KEY_DOWN) || (nCode1 == KEY_UP) || (nCode1 == KEY_LEFT) || (nCode1 == KEY_RIGHT) + || (nCode1 == KEY_PAGEUP) || (nCode1 == KEY_PAGEDOWN)) + // no - handle it as normal dialog input + return false; + + for (int i = 0, nCount = m_xEntriesBox->n_children(); i < nCount; ++i) { - for (int i = 0, nCount = m_xEntriesBox->n_children(); i < nCount; ++i) + TAccInfo* pUserData = weld::fromId<TAccInfo*>(m_xEntriesBox->get_id(i)); + if (pUserData) { - TAccInfo* pUserData = reinterpret_cast<TAccInfo*>(m_xEntriesBox->get_id(i).toInt64()); - if (pUserData) - { - sal_uInt16 nCode2 = pUserData->m_aKey.GetCode(); - sal_uInt16 nMod2 = pUserData->m_aKey.GetModifier(); + sal_uInt16 nCode2 = pUserData->m_aKey.GetCode(); + sal_uInt16 nMod2 = pUserData->m_aKey.GetModifier(); - if (nCode1 == nCode2 && nMod1 == nMod2) - { - m_xEntriesBox->select(i); - m_xEntriesBox->scroll_to_row(i); - return true; - } + if (nCode1 == nCode2 && nMod1 == nMod2) + { + m_xEntriesBox->select(i); + m_xEntriesBox->scroll_to_row(i); + return true; } } } @@ -829,10 +856,10 @@ SfxAcceleratorConfigPage::SfxAcceleratorConfigPage(weld::Container* pPage, #if HAVE_FEATURE_SCRIPTING , m_pMacroInfoItem() #endif - , aLoadAccelConfigStr(CuiResId(RID_SVXSTR_LOADACCELCONFIG)) - , aSaveAccelConfigStr(CuiResId(RID_SVXSTR_SAVEACCELCONFIG)) + , aLoadAccelConfigStr(CuiResId(RID_CUISTR_LOADACCELCONFIG)) + , aSaveAccelConfigStr(CuiResId(RID_CUISTR_SAVEACCELCONFIG)) , aFilterAllStr(SfxResId(STR_SFX_FILTERNAME_ALL)) - , aFilterCfgStr(CuiResId(RID_SVXSTR_FILTERNAME_CFG)) + , aFilterCfgStr(CuiResId(RID_CUISTR_FILTERNAME_CFG)) , m_bStylesInfoInitialized(false) , m_aUpdateDataTimer("SfxAcceleratorConfigPage UpdateDataTimer") , m_aFillGroupIdle("SfxAcceleratorConfigPage m_aFillGroupIdle") @@ -850,16 +877,16 @@ SfxAcceleratorConfigPage::SfxAcceleratorConfigPage(weld::Container* pPage, , m_xResetButton(m_xBuilder->weld_button("reset")) { Size aSize(m_xEntriesBox->get_approximate_digit_width() * 40, - m_xEntriesBox->get_height_rows(12)); + m_xEntriesBox->get_height_rows(10)); m_xEntriesBox->set_size_request(aSize.Width(), aSize.Height()); aSize = Size(m_xEntriesBox->get_approximate_digit_width() * 19, - m_xEntriesBox->get_height_rows(10)); + m_xEntriesBox->get_height_rows(9)); m_xGroupLBox->set_size_request(aSize.Width(), aSize.Height()); aSize = Size(m_xEntriesBox->get_approximate_digit_width() * 21, - m_xEntriesBox->get_height_rows(10)); + m_xEntriesBox->get_height_rows(9)); m_xFunctionBox->set_size_request(aSize.Width(), aSize.Height()); aSize = Size(m_xEntriesBox->get_approximate_digit_width() * 20, - m_xEntriesBox->get_height_rows(10)); + m_xEntriesBox->get_height_rows(9)); m_xKeyBox->set_size_request(aSize.Width(), aSize.Height()); // install handler functions @@ -917,7 +944,7 @@ SfxAcceleratorConfigPage::~SfxAcceleratorConfigPage() // free memory - remove all dynamic user data for (int i = 0, nCount = m_xEntriesBox->n_children(); i < nCount; ++i) { - TAccInfo* pUserData = reinterpret_cast<TAccInfo*>(m_xEntriesBox->get_id(i).toInt64()); + TAccInfo* pUserData = weld::fromId<TAccInfo*>(m_xEntriesBox->get_id(i)); delete pUserData; } } @@ -1002,7 +1029,7 @@ void SfxAcceleratorConfigPage::Init(const uno::Reference<ui::XAcceleratorConfigu if (sKey.isEmpty()) continue; TAccInfo* pEntry = new TAccInfo(i1, 0 /*nListPos*/, aKey); - m_xEntriesBox->append(OUString::number(reinterpret_cast<sal_Int64>(pEntry)), sKey); + m_xEntriesBox->append(weld::toId(pEntry), sKey); int nPos = m_xEntriesBox->n_children() - 1; m_xEntriesBox->set_text(nPos, OUString(), 1); m_xEntriesBox->set_sensitive(nPos, true); @@ -1026,7 +1053,7 @@ void SfxAcceleratorConfigPage::Init(const uno::Reference<ui::XAcceleratorConfigu m_xEntriesBox->set_text(nPos, sLabel, 1); - TAccInfo* pEntry = reinterpret_cast<TAccInfo*>(m_xEntriesBox->get_id(nPos).toInt64()); + TAccInfo* pEntry = weld::fromId<TAccInfo*>(m_xEntriesBox->get_id(nPos)); pEntry->m_bIsConfigurable = true; pEntry->m_sCommand = sCommand; @@ -1044,7 +1071,7 @@ void SfxAcceleratorConfigPage::Init(const uno::Reference<ui::XAcceleratorConfigu continue; // Hardcoded function mapped so no ID possible and mark entry as not changeable - TAccInfo* pEntry = reinterpret_cast<TAccInfo*>(m_xEntriesBox->get_id(nPos).toInt64()); + TAccInfo* pEntry = weld::fromId<TAccInfo*>(m_xEntriesBox->get_id(nPos)); pEntry->m_bIsConfigurable = false; m_xEntriesBox->set_sensitive(nPos, false); @@ -1061,7 +1088,7 @@ void SfxAcceleratorConfigPage::Apply(const uno::Reference<ui::XAcceleratorConfig // physical ones! for (int i = 0, nCount = m_xEntriesBox->n_children(); i < nCount; ++i) { - TAccInfo* pUserData = reinterpret_cast<TAccInfo*>(m_xEntriesBox->get_id(i).toInt64()); + TAccInfo* pUserData = weld::fromId<TAccInfo*>(m_xEntriesBox->get_id(i)); OUString sCommand; awt::KeyEvent aAWTKey; @@ -1140,7 +1167,7 @@ IMPL_LINK_NOARG(SfxAcceleratorConfigPage, ChangeHdl, weld::Button&, void) if (nPos == -1) return; - TAccInfo* pEntry = reinterpret_cast<TAccInfo*>(m_xEntriesBox->get_id(nPos).toInt64()); + TAccInfo* pEntry = weld::fromId<TAccInfo*>(m_xEntriesBox->get_id(nPos)); OUString sNewCommand = m_xFunctionBox->GetCurCommand(); OUString sLabel = m_xFunctionBox->GetCurLabel(); if (sLabel.isEmpty()) @@ -1159,7 +1186,7 @@ IMPL_LINK_NOARG(SfxAcceleratorConfigPage, RemoveHdl, weld::Button&, void) if (nPos == -1) return; - TAccInfo* pEntry = reinterpret_cast<TAccInfo*>(m_xEntriesBox->get_id(nPos).toInt64()); + TAccInfo* pEntry = weld::fromId<TAccInfo*>(m_xEntriesBox->get_id(nPos)); // remove function name from selected entry m_xEntriesBox->set_text(nPos, OUString(), 1); @@ -1172,7 +1199,7 @@ IMPL_LINK(SfxAcceleratorConfigPage, SelectHdl, weld::TreeView&, rListBox, void) { if (&rListBox == m_xEntriesBox.get()) { - TAccInfo* pEntry = reinterpret_cast<TAccInfo*>(m_xEntriesBox->get_selected_id().toInt64()); + TAccInfo* pEntry = weld::fromId<TAccInfo*>(m_xEntriesBox->get_selected_id()); OUString sPossibleNewCommand = m_xFunctionBox->GetCurCommand(); @@ -1214,7 +1241,7 @@ IMPL_LINK(SfxAcceleratorConfigPage, SelectHdl, weld::TreeView&, rListBox, void) m_xChangeButton->set_sensitive(false); // #i36994 First selected can return null! - TAccInfo* pEntry = reinterpret_cast<TAccInfo*>(m_xEntriesBox->get_selected_id().toInt64()); + TAccInfo* pEntry = weld::fromId<TAccInfo*>(m_xEntriesBox->get_selected_id()); if (pEntry) { OUString sPossibleNewCommand = m_xFunctionBox->GetCurCommand(); @@ -1233,12 +1260,10 @@ IMPL_LINK(SfxAcceleratorConfigPage, SelectHdl, weld::TreeView&, rListBox, void) { for (int i = 0, nCount = m_xEntriesBox->n_children(); i < nCount; ++i) { - TAccInfo* pUserData - = reinterpret_cast<TAccInfo*>(m_xEntriesBox->get_id(i).toInt64()); + TAccInfo* pUserData = weld::fromId<TAccInfo*>(m_xEntriesBox->get_id(i)); if (pUserData && pUserData->m_sCommand == sPossibleNewCommand) { - m_xKeyBox->append(OUString::number(reinterpret_cast<sal_Int64>(pUserData)), - pUserData->m_aKey.GetName()); + m_xKeyBox->append(weld::toId(pUserData), pUserData->m_aKey.GetName()); } } } @@ -1248,7 +1273,7 @@ IMPL_LINK(SfxAcceleratorConfigPage, SelectHdl, weld::TreeView&, rListBox, void) { // goto selected "key" entry of the key box int nP2 = -1; - TAccInfo* pU2 = reinterpret_cast<TAccInfo*>(m_xKeyBox->get_selected_id().toInt64()); + TAccInfo* pU2 = weld::fromId<TAccInfo*>(m_xKeyBox->get_selected_id()); if (pU2) nP2 = MapKeyCodeToPos(pU2->m_aKey); if (nP2 != -1) @@ -1473,6 +1498,13 @@ bool SfxAcceleratorConfigPage::FillItemSet(SfxItemSet*) try { m_xAct->store(); + css::uno::Reference<css::beans::XPropertySet> xFrameProps(m_xFrame, + css::uno::UNO_QUERY_THROW); + css::uno::Reference<css::frame::XLayoutManager> xLayoutManager; + xFrameProps->getPropertyValue("LayoutManager") >>= xLayoutManager; + css::uno::Reference<css::beans::XPropertySet> xLayoutProps(xLayoutManager, + css::uno::UNO_QUERY_THROW); + xLayoutProps->setPropertyValue("RefreshContextToolbarToolTip", css::uno::Any(true)); } catch (const uno::RuntimeException&) { @@ -1511,10 +1543,9 @@ void SfxAcceleratorConfigPage::Reset(const SfxItemSet* rSet) RadioHdl(*m_xOfficeButton); #if HAVE_FEATURE_SCRIPTING - const SfxPoolItem* pMacroItem = nullptr; - if (SfxItemState::SET == rSet->GetItemState(SID_MACROINFO, true, &pMacroItem)) + if (const SfxMacroInfoItem* pMacroItem = rSet->GetItemIfSet(SID_MACROINFO)) { - m_pMacroInfoItem = &dynamic_cast<const SfxMacroInfoItem&>(*pMacroItem); + m_pMacroInfoItem = pMacroItem; m_xGroupLBox->SelectMacro(m_pMacroInfoItem); } #else @@ -1527,7 +1558,7 @@ sal_Int32 SfxAcceleratorConfigPage::MapKeyCodeToPos(const vcl::KeyCode& aKey) co sal_uInt16 nCode1 = aKey.GetCode() + aKey.GetModifier(); for (int i = 0, nCount = m_xEntriesBox->n_children(); i < nCount; ++i) { - TAccInfo* pUserData = reinterpret_cast<TAccInfo*>(m_xEntriesBox->get_id(i).toInt64()); + TAccInfo* pUserData = weld::fromId<TAccInfo*>(m_xEntriesBox->get_id(i)); if (pUserData) { sal_uInt16 nCode2 = pUserData->m_aKey.GetCode() + pUserData->m_aKey.GetModifier(); diff --git a/cui/source/customize/cfg.cxx b/cui/source/customize/cfg.cxx index 29ca8ccb96f6..ff5702121755 100644 --- a/cui/source/customize/cfg.cxx +++ b/cui/source/customize/cfg.cxx @@ -24,6 +24,7 @@ #include <stdlib.h> #include <typeinfo> +#include <utility> #include <vcl/stdtext.hxx> #include <vcl/commandinfoprovider.hxx> #include <vcl/event.hxx> @@ -35,6 +36,7 @@ #include <vcl/decoview.hxx> #include <vcl/virdev.hxx> +#include <sfx2/minfitem.hxx> #include <sfx2/sfxhelp.hxx> #include <sfx2/viewfrm.hxx> #include <sfx2/filedlghelper.hxx> @@ -42,7 +44,7 @@ #include <svl/stritem.hxx> #include <rtl/ustrbuf.hxx> #include <tools/debug.hxx> -#include <tools/diagnose_ex.h> +#include <comphelper/diagnose_ex.hxx> #include <toolkit/helper/vclunohelper.hxx> #include <algorithm> @@ -90,7 +92,7 @@ #include <comphelper/propertysequence.hxx> #include <comphelper/propertyvalue.hxx> #include <comphelper/processfactory.hxx> -#include <officecfg/Office/Common.hxx> +#include <config_features.h> namespace uno = com::sun::star::uno; namespace frame = com::sun::star::frame; @@ -215,18 +217,29 @@ SvxConfigDialog::SvxConfigDialog(weld::Window * pParent, const SfxItemSet* pInSe AddTabPage("keyboard", CreateKeyboardConfigPage, nullptr); AddTabPage("events", CreateSvxEventConfigPage, nullptr); - const SfxPoolItem* pItem = - pInSet->GetItem( pInSet->GetPool()->GetWhich( SID_CONFIG ) ); - - if ( pItem ) + if (const SfxPoolItem* pItem = pInSet->GetItem(SID_CONFIG)) { OUString text = static_cast<const SfxStringItem*>(pItem)->GetValue(); - if (text.startsWith( ITEM_TOOLBAR_URL ) ) - { SetCurPageId("toolbars"); - } + else if (text.startsWith( ITEM_EVENT_URL) ) + SetCurPageId("events"); } +#if HAVE_FEATURE_SCRIPTING + else if (pInSet->GetItemIfSet(SID_MACROINFO)) + { + // for the "assign" button in the Basic Macros chooser automatically switch + // to the keyboard tab in which this macro will be pre-selected for assigning + // to a keystroke + SetCurPageId("keyboard"); + } +#endif +} + +void SvxConfigDialog::ActivatePage(const OUString& rPage) +{ + SfxTabDialogController::ActivatePage(rPage); + GetResetButton()->set_visible(rPage != "keyboard"); } void SvxConfigDialog::SetFrame(const css::uno::Reference<css::frame::XFrame>& xFrame) @@ -244,7 +257,7 @@ void SvxConfigDialog::SetFrame(const css::uno::Reference<css::frame::XFrame>& xF RemoveTabPage("keyboard"); } -void SvxConfigDialog::PageCreated(const OString &rId, SfxTabPage& rPage) +void SvxConfigDialog::PageCreated(const OUString &rId, SfxTabPage& rPage) { if (rId == "menus" || rId == "keyboard" || rId == "notebookbar" || rId == "toolbars" || rId == "contextmenus") @@ -268,16 +281,16 @@ void SvxConfigDialog::PageCreated(const OString &rId, SfxTabPage& rPage) uno::Reference< css::ui::XImageManager>* SaveInData::xDefaultImgMgr = nullptr; SaveInData::SaveInData( - const uno::Reference< css::ui::XUIConfigurationManager >& xCfgMgr, - const uno::Reference< css::ui::XUIConfigurationManager >& xParentCfgMgr, + uno::Reference< css::ui::XUIConfigurationManager > xCfgMgr, + uno::Reference< css::ui::XUIConfigurationManager > xParentCfgMgr, const OUString& aModuleId, bool isDocConfig ) : bModified( false ), bDocConfig( isDocConfig ), bReadOnly( false ), - m_xCfgMgr( xCfgMgr ), - m_xParentCfgMgr( xParentCfgMgr ), + m_xCfgMgr(std::move( xCfgMgr )), + m_xParentCfgMgr(std::move( xParentCfgMgr )), m_aSeparatorSeq{ comphelper::makePropertyValue(ITEM_DESCRIPTOR_TYPE, css::ui::ItemType::SEPARATOR_LINE) } { @@ -479,7 +492,7 @@ void SaveInData::LoadSubMenus( const uno::Reference< container::XIndexAccess >& if ( a >>= aPropSeq ) { OUString aMenuLabel; - for ( const beans::PropertyValue& prop : std::as_const(aPropSeq) ) + for (const beans::PropertyValue& prop : aPropSeq) { if ( bContextMenu ) { @@ -710,7 +723,7 @@ OUString ContextMenuSaveInData::GetUIName( const OUString& rResourceURL ) catch ( const css::uno::Exception& ) {} - for ( const auto& aProp : std::as_const(aProps) ) + for (const auto& aProp : aProps) { if ( aProp.Name == ITEM_DESCRIPTOR_UINAME ) { @@ -738,7 +751,7 @@ SvxEntries* ContextMenuSaveInData::GetEntries() catch ( const css::lang::IllegalArgumentException& ) {} - for ( const auto& aElement : std::as_const(aElementsInfo) ) + for (const auto& aElement : aElementsInfo) { OUString aUrl; for ( const auto& aElementProp : aElement ) @@ -786,7 +799,7 @@ SvxEntries* ContextMenuSaveInData::GetEntries() catch ( const css::lang::IllegalArgumentException& ) {} - for ( const auto& aElement : std::as_const(aParentElementsInfo) ) + for (const auto& aElement : aParentElementsInfo) { OUString aUrl; for ( const auto& aElementProp : aElement ) @@ -932,6 +945,7 @@ SvxMenuEntriesListBox::SvxMenuEntriesListBox(std::unique_ptr<weld::TreeView> xCo m_xControl->enable_toggle_buttons(weld::ColumnToggleType::Check); CreateDropDown(); m_xControl->connect_key_press(LINK(this, SvxMenuEntriesListBox, KeyInputHdl)); + m_xControl->connect_query_tooltip(LINK(this, SvxMenuEntriesListBox, QueryTooltip)); } SvxMenuEntriesListBox::~SvxMenuEntriesListBox() @@ -963,6 +977,21 @@ IMPL_LINK(SvxMenuEntriesListBox, KeyInputHdl, const KeyEvent&, rKeyEvent, bool) return true; } +IMPL_LINK(SvxMenuEntriesListBox, QueryTooltip, const weld::TreeIter&, rIter, OUString) +{ + SvxConfigEntry *pEntry = weld::fromId<SvxConfigEntry*>(m_xControl->get_id(rIter)); + if (!pEntry || pEntry->GetCommand().isEmpty()) + return OUString(); + const OUString sCommand(pEntry->GetCommand()); + OUString aModuleName(vcl::CommandInfoProvider::GetModuleIdentifier(m_pPage->GetFrame())); + auto aProperties = vcl::CommandInfoProvider::GetCommandProperties(sCommand, aModuleName); + OUString sTooltipLabel = vcl::CommandInfoProvider::GetTooltipForCommand(sCommand, aProperties, + m_pPage->GetFrame()); + return CuiResId(RID_CUISTR_COMMANDLABEL) + ": " + pEntry->GetName().replaceFirst("~", "") + "\n" + + CuiResId(RID_CUISTR_COMMANDNAME) + ": " + sCommand + "\n" + + CuiResId(RID_CUISTR_COMMANDTIP) + ": " + sTooltipLabel.replaceFirst("~", ""); +} + /****************************************************************************** * * SvxConfigPage is the abstract base class on which the Menu and Toolbar @@ -988,9 +1017,11 @@ SvxConfigPage::SvxConfigPage(weld::Container* pPage, weld::DialogController* pCo , m_xMoveUpButton(m_xBuilder->weld_button("up")) , m_xMoveDownButton(m_xBuilder->weld_button("down")) , m_xSaveInListBox(m_xBuilder->weld_combo_box("savein")) + , m_xCustomizeBox(m_xBuilder->weld_widget("customizebox")) , m_xInsertBtn(m_xBuilder->weld_menu_button("insert")) , m_xModifyBtn(m_xBuilder->weld_menu_button("modify")) , m_xResetBtn(m_xBuilder->weld_button("defaultsbtn")) + , m_xCommandButtons(m_xBuilder->weld_widget("arrowgrid")) , m_xAddCommandButton(m_xBuilder->weld_button("add")) , m_xRemoveCommandButton(m_xBuilder->weld_button("remove")) { @@ -1023,7 +1054,7 @@ SvxConfigPage::~SvxConfigPage() int cnt = m_xSaveInListBox->get_count(); for(int i=0; i < cnt; ++i) { - SaveInData *pData = reinterpret_cast<SaveInData*>(m_xSaveInListBox->get_id(i).toInt64()); + SaveInData *pData = weld::fromId<SaveInData*>(m_xSaveInListBox->get_id(i)); delete pData; } } @@ -1075,7 +1106,7 @@ void SvxConfigPage::Reset( const SfxItemSet* ) if ( pModuleData != nullptr ) { - OUString sId(OUString::number(reinterpret_cast<sal_Int64>(pModuleData))); + OUString sId(weld::toId(pModuleData)); m_xSaveInListBox->append(sId, utl::ConfigManager::getProductName() + " " + aModuleName); } @@ -1106,7 +1137,7 @@ void SvxConfigPage::Reset( const SfxItemSet* ) if ( !pDocData->IsReadOnly() ) { - OUString sId(OUString::number(reinterpret_cast<sal_Int64>(pDocData))); + OUString sId(weld::toId(pDocData)); m_xSaveInListBox->append(sId, aTitle); } } @@ -1172,7 +1203,7 @@ void SvxConfigPage::Reset( const SfxItemSet* ) DBG_UNHANDLED_EXCEPTION("cui.customize"); } - for ( uno::Reference < frame::XFrame > const & xf : std::as_const(aFrameList) ) + for (uno::Reference<frame::XFrame> const& xf : aFrameList) { if ( xf.is() && xf != m_xFrame ) { @@ -1215,7 +1246,7 @@ void SvxConfigPage::Reset( const SfxItemSet* ) if ( pData && !pData->IsReadOnly() ) { - OUString sId(OUString::number(reinterpret_cast<sal_Int64>(pData))); + OUString sId(weld::toId(pData)); m_xSaveInListBox->append(sId, aTitle2); } } @@ -1262,8 +1293,11 @@ OUString SvxConfigPage::GetFrameWithDefaultAndIdentify( uno::Reference< frame::X _inout_rxFrame = xDesktop->getCurrentFrame(); } - if ( !_inout_rxFrame.is() && SfxViewFrame::Current() ) - _inout_rxFrame = SfxViewFrame::Current()->GetFrame().GetFrameInterface(); + if ( !_inout_rxFrame.is()) + { + if (SfxViewFrame* pViewFrame = SfxViewFrame::Current()) + _inout_rxFrame = pViewFrame->GetFrame().GetFrameInterface(); + } if ( !_inout_rxFrame.is() ) { @@ -1285,7 +1319,7 @@ OUString SvxConfigPage::GetScriptURL() const { OUString result; - SfxGroupInfo_Impl *pData = reinterpret_cast<SfxGroupInfo_Impl*>(m_xFunctions->get_selected_id().toInt64()); + SfxGroupInfo_Impl *pData = weld::fromId<SfxGroupInfo_Impl*>(m_xFunctions->get_selected_id()); if (pData) { if ( ( pData->nKind == SfxCfgKind::FUNCTION_SLOT ) || @@ -1313,7 +1347,7 @@ bool SvxConfigPage::FillItemSet( SfxItemSet* ) OUString sId = m_xSaveInListBox->get_id(i); if (sId != notebookbarTabScope) { - SaveInData* pData = reinterpret_cast<SaveInData*>(sId.toInt64()); + SaveInData* pData = weld::fromId<SaveInData*>(sId); result = pData->Apply(); } } @@ -1324,7 +1358,7 @@ IMPL_LINK_NOARG(SvxConfigPage, SelectSaveInLocation, weld::ComboBox&, void) { OUString sId = m_xSaveInListBox->get_active_id(); if (sId != notebookbarTabScope) - pCurrentSaveInData = reinterpret_cast<SaveInData*>(sId.toInt64()); + pCurrentSaveInData = weld::fromId<SaveInData*>(sId); Init(); } @@ -1337,7 +1371,7 @@ void SvxConfigPage::ReloadTopLevelListBox( SvxConfigEntry const * pToSelect ) { for (auto const& entryData : *GetSaveInData()->GetEntries()) { - OUString sId(OUString::number(reinterpret_cast<sal_Int64>(entryData))); + OUString sId(weld::toId(entryData)); m_xTopLevelListBox->append(sId, SvxConfigPageHelper::stripHotKey(entryData->GetName())); if (entryData == pToSelect) @@ -1371,7 +1405,7 @@ void SvxConfigPage::AddSubMenusToUI( { OUString subMenuTitle = OUString::Concat(rBaseTitle) + aMenuSeparatorStr + SvxConfigPageHelper::stripHotKey(entryData->GetName()); - OUString sId(OUString::number(reinterpret_cast<sal_Int64>(entryData))); + OUString sId(weld::toId(entryData)); m_xTopLevelListBox->append(sId, subMenuTitle); AddSubMenusToUI( subMenuTitle, entryData ); @@ -1496,7 +1530,7 @@ int SvxConfigPage::AppendEntry( int nCurEntry = nTarget != -1 ? nTarget : m_xContentsListBox->get_selected_index(); - OUString sId(OUString::number(reinterpret_cast<sal_Int64>(pNewEntryData))); + OUString sId(weld::toId(pNewEntryData)); if (nCurEntry == -1 || nCurEntry == m_xContentsListBox->n_children() - 1) { @@ -1507,7 +1541,7 @@ int SvxConfigPage::AppendEntry( else { SvxConfigEntry* pEntryData = - reinterpret_cast<SvxConfigEntry*>(m_xContentsListBox->get_id(nCurEntry).toInt64()); + weld::fromId<SvxConfigEntry*>(m_xContentsListBox->get_id(nCurEntry)); SvxEntries::iterator iter = pEntries->begin(); SvxEntries::const_iterator end = pEntries->end(); @@ -1549,7 +1583,7 @@ namespace template<typename itertype> void TmplInsertEntryIntoUI(SvxConfigEntry* pNewEntryData, weld::TreeView& rTreeView, itertype& rIter, SaveInData* pSaveInData, VirtualDevice& rDropDown, bool bMenu) { - OUString sId(OUString::number(reinterpret_cast<sal_Int64>(pNewEntryData))); + OUString sId(weld::toId(pNewEntryData)); rTreeView.set_id(rIter, sId); @@ -1619,16 +1653,16 @@ IMPL_LINK_NOARG(SvxConfigPage, SelectFunctionHdl, weld::TreeView&, void) } else { - SfxGroupInfo_Impl *pData = reinterpret_cast<SfxGroupInfo_Impl*>(m_xFunctions->get_selected_id().toInt64()); + SfxGroupInfo_Impl *pData = weld::fromId<SfxGroupInfo_Impl*>(m_xFunctions->get_selected_id()); if (pData) { bool bIsExperimental = vcl::CommandInfoProvider::IsExperimental(pData->sCommand, m_aModuleId); - OUString aExperimental = "\n" + CuiResId(RID_SVXSTR_COMMANDEXPERIMENTAL); - OUString aLabel = CuiResId(RID_SVXSTR_COMMANDLABEL) + ": " + pData->sLabel + "\n"; - OUString aName = CuiResId(RID_SVXSTR_COMMANDNAME) + ": " + pData->sCommand + "\n"; - OUString aTip = CuiResId(RID_SVXSTR_COMMANDTIP) + ": " + pData->sTooltip; + OUString aExperimental = "\n" + CuiResId(RID_CUISTR_COMMANDEXPERIMENTAL); + OUString aLabel = CuiResId(RID_CUISTR_COMMANDLABEL) + ": " + pData->sLabel + "\n"; + OUString aName = CuiResId(RID_CUISTR_COMMANDNAME) + ": " + pData->sCommand + "\n"; + OUString aTip = CuiResId(RID_CUISTR_COMMANDTIP) + ": " + pData->sTooltip; if (bIsExperimental) m_xDescriptionField->set_text(aLabel + aName + aTip + aExperimental); else @@ -1717,32 +1751,30 @@ bool SvxConfigPage::MoveEntryData(int nSourceEntry, int nTargetEntry) SvxEntries* pEntries = GetTopLevelSelection()->GetEntries(); SvxConfigEntry* pSourceData = - reinterpret_cast<SvxConfigEntry*>(m_xContentsListBox->get_id(nSourceEntry).toInt64()); + weld::fromId<SvxConfigEntry*>(m_xContentsListBox->get_id(nSourceEntry)); SvxConfigEntry* pTargetData = - reinterpret_cast<SvxConfigEntry*>(m_xContentsListBox->get_id(nTargetEntry).toInt64()); + weld::fromId<SvxConfigEntry*>(m_xContentsListBox->get_id(nTargetEntry)); - if ( pSourceData != nullptr && pTargetData != nullptr ) - { - // remove the source entry from our list - SvxConfigPageHelper::RemoveEntry( pEntries, pSourceData ); + if ( pSourceData == nullptr || pTargetData == nullptr ) + return false; - SvxEntries::iterator iter = pEntries->begin(); - SvxEntries::const_iterator end = pEntries->end(); + // remove the source entry from our list + SvxConfigPageHelper::RemoveEntry( pEntries, pSourceData ); - // advance the iterator to the position of the target entry - while (*iter != pTargetData && ++iter != end) ; + SvxEntries::iterator iter = pEntries->begin(); + SvxEntries::const_iterator end = pEntries->end(); - // insert the source entry at the position after the target - pEntries->insert( ++iter, pSourceData ); + // advance the iterator to the position of the target entry + while (*iter != pTargetData && ++iter != end) ; - GetSaveInData()->SetModified(); - GetTopLevelSelection()->SetModified(); + // insert the source entry at the position after the target + pEntries->insert( ++iter, pSourceData ); - return true; - } + GetSaveInData()->SetModified(); + GetTopLevelSelection()->SetModified(); - return false; + return true; } SvxMainMenuOrganizerDialog::SvxMainMenuOrganizerDialog( @@ -1763,7 +1795,7 @@ SvxMainMenuOrganizerDialog::SvxMainMenuOrganizerDialog( mpEntries.reset( new SvxEntries ); for (auto const& entry : *entries) { - m_xMenuListBox->append(OUString::number(reinterpret_cast<sal_uInt64>(entry)), + m_xMenuListBox->append(weld::toId(entry), SvxConfigPageHelper::stripHotKey(entry->GetName())); mpEntries->push_back(entry); if (entry == selection) @@ -1776,7 +1808,7 @@ SvxMainMenuOrganizerDialog::SvxMainMenuOrganizerDialog( if ( bCreateMenu ) { // Generate custom name for new menu - OUString prefix = CuiResId( RID_SVXSTR_NEW_MENU ); + OUString prefix = CuiResId( RID_CUISTR_NEW_MENU ); OUString newname = SvxConfigPageHelper::generateCustomName( prefix, entries ); OUString newurl = SvxConfigPageHelper::generateCustomMenuURL( mpEntries.get() ); @@ -1787,7 +1819,7 @@ SvxMainMenuOrganizerDialog::SvxMainMenuOrganizerDialog( pNewEntryData->SetUserDefined(); pNewEntryData->SetMain(); - m_sNewMenuEntryId = OUString::number(reinterpret_cast<sal_uInt64>(pNewEntryData)); + m_sNewMenuEntryId = weld::toId(pNewEntryData); m_xMenuListBox->append(m_sNewMenuEntryId, SvxConfigPageHelper::stripHotKey(pNewEntryData->GetName())); m_xMenuListBox->select(m_xMenuListBox->n_children() - 1); @@ -1803,7 +1835,7 @@ SvxMainMenuOrganizerDialog::SvxMainMenuOrganizerDialog( // hide name label and textfield m_xMenuBox->hide(); // change the title - m_xDialog->set_title(CuiResId(RID_SVXSTR_MOVE_MENU)); + m_xDialog->set_title(CuiResId(RID_CUISTR_MOVE_MENU)); } m_xMenuListBox->connect_changed(LINK(this, SvxMainMenuOrganizerDialog, SelectHdl)); @@ -1826,7 +1858,7 @@ IMPL_LINK_NOARG(SvxMainMenuOrganizerDialog, ModifyHdl, weld::Entry&, void) return; } - SvxConfigEntry* pNewEntryData = reinterpret_cast<SvxConfigEntry*>(m_sNewMenuEntryId.toUInt64()); + SvxConfigEntry* pNewEntryData = weld::fromId<SvxConfigEntry*>(m_sNewMenuEntryId); pNewEntryData->SetName(m_xMenuNameEdit->get_text()); const int nNewMenuPos = m_xMenuListBox->find_id(m_sNewMenuEntryId); @@ -1883,14 +1915,14 @@ SvxConfigEntry* SvxMainMenuOrganizerDialog::GetSelectedEntry() const int nSelected(m_xMenuListBox->get_selected_index()); if (nSelected == -1) return nullptr; - return reinterpret_cast<SvxConfigEntry*>(m_xMenuListBox->get_id(nSelected).toUInt64()); + return weld::fromId<SvxConfigEntry*>(m_xMenuListBox->get_id(nSelected)); } -SvxConfigEntry::SvxConfigEntry( const OUString& rDisplayName, - const OUString& rCommandURL, bool bPopup, bool bParentData ) +SvxConfigEntry::SvxConfigEntry( OUString aDisplayName, + OUString aCommandURL, bool bPopup, bool bParentData ) : nId( 1 ) - , aLabel(rDisplayName) - , aCommand(rCommandURL) + , aLabel(std::move(aDisplayName)) + , aCommand(std::move(aCommandURL)) , bPopUp(bPopup) , bStrEdited( false ) , bIsUserDefined( false ) @@ -1969,7 +2001,7 @@ sal_Int32 ToolbarSaveInData::GetSystemStyle( const OUString& rResourceURL ) if ( a >>= aProps ) { - for ( beans::PropertyValue const & prop : std::as_const(aProps) ) + for (beans::PropertyValue const& prop : aProps) { if ( prop.Name == ITEM_DESCRIPTOR_STYLE ) { @@ -2096,7 +2128,7 @@ OUString ToolbarSaveInData::GetSystemUIName( const OUString& rResourceURL ) if ( a >>= aProps ) { - for ( beans::PropertyValue const & prop : std::as_const(aProps) ) + for (beans::PropertyValue const& prop : aProps) { if ( prop.Name == ITEM_DESCRIPTOR_UINAME ) { @@ -2123,7 +2155,7 @@ OUString ToolbarSaveInData::GetSystemUIName( const OUString& rResourceURL ) uno::Sequence< beans::PropertyValue > aPropSeq; if ( a >>= aPropSeq ) { - for ( beans::PropertyValue const & prop : std::as_const(aPropSeq) ) + for (beans::PropertyValue const& prop : aPropSeq) { if ( prop.Name == ITEM_DESCRIPTOR_LABEL ) { @@ -2625,7 +2657,7 @@ void ToolbarSaveInData::LoadToolbar( uno::Sequence< beans::PropertyValue > aPropSeq; if ( a >>= aPropSeq ) { - for ( beans::PropertyValue const & prop : std::as_const(aPropSeq) ) + for (beans::PropertyValue const& prop : aPropSeq) { if ( prop.Name == "Name" ) { @@ -2661,7 +2693,6 @@ void ToolbarSaveInData::LoadToolbar( SvxNewToolbarDialog::SvxNewToolbarDialog(weld::Window* pWindow, const OUString& rName) : GenericDialogController(pWindow, "cui/ui/newtoolbardialog.ui", "NewToolbarDialog") , m_xEdtName(m_xBuilder->weld_entry("edit")) - , m_xBtnOK(m_xBuilder->weld_button("ok")) , m_xSaveInListBox(m_xBuilder->weld_combo_box("savein")) { m_xEdtName->set_text(rName); @@ -2678,11 +2709,11 @@ SvxNewToolbarDialog::~SvxNewToolbarDialog() * *******************************************************************************/ SvxIconSelectorDialog::SvxIconSelectorDialog(weld::Window *pWindow, - const uno::Reference< css::ui::XImageManager >& rXImageManager, - const uno::Reference< css::ui::XImageManager >& rXParentImageManager) + uno::Reference< css::ui::XImageManager > xImageManager, + uno::Reference< css::ui::XImageManager > xParentImageManager) : GenericDialogController(pWindow, "cui/ui/iconselectordialog.ui", "IconSelector") - , m_xImageManager(rXImageManager) - , m_xParentImageManager(rXParentImageManager) + , m_xImageManager(std::move(xImageManager)) + , m_xParentImageManager(std::move(xParentImageManager)) , m_xTbSymbol(new ValueSet(m_xBuilder->weld_scrolled_window("symbolswin", true))) , m_xTbSymbolWin(new weld::CustomWeld(*m_xBuilder, "symbolsToolbar", *m_xTbSymbol)) , m_xFtNote(m_xBuilder->weld_label("noteLabel")) @@ -2902,7 +2933,7 @@ IMPL_LINK_NOARG(SvxIconSelectorDialog, ImportHdl, weld::Button&, void) IMPL_LINK_NOARG(SvxIconSelectorDialog, DeleteHdl, weld::Button&, void) { - OUString message = CuiResId( RID_SVXSTR_DELETE_ICON_CONFIRM ); + OUString message = CuiResId( RID_CUISTR_DELETE_ICON_CONFIRM ); std::unique_ptr<weld::MessageDialog> xWarn(Application::CreateMessageDialog(m_xDialog.get(), VclMessageType::Warning, VclButtonsType::OkCancel, @@ -2912,8 +2943,7 @@ IMPL_LINK_NOARG(SvxIconSelectorDialog, DeleteHdl, weld::Button&, void) sal_uInt16 nId = m_xTbSymbol->GetSelectedItemId(); - OUString aSelImageText = m_xTbSymbol->GetItemText( nId ); - uno::Sequence< OUString > URLs { aSelImageText }; + uno::Sequence<OUString> URLs { m_xTbSymbol->GetItemText(nId) }; m_xTbSymbol->RemoveItem(nId); m_xImportedImageManager->removeImages( SvxConfigPageHelper::GetImageType(), URLs ); if ( m_xImportedImageManager->isModified() ) @@ -2995,7 +3025,7 @@ namespace OUString ReplaceIconName(std::u16string_view rMessage) { OUString name; - OUString message = CuiResId( RID_SVXSTR_REPLACE_ICON_WARNING ); + OUString message = CuiResId( RID_CUISTR_REPLACE_ICON_WARNING ); OUString placeholder("%ICONNAME" ); sal_Int32 pos = message.indexOf( placeholder ); if ( pos != -1 ) @@ -3014,10 +3044,10 @@ namespace SvxIconReplacementDialog(weld::Window *pParent, std::u16string_view rMessage, bool bYestoAll) : m_xQueryBox(Application::CreateMessageDialog(pParent, VclMessageType::Warning, VclButtonsType::NONE, ReplaceIconName(rMessage))) { - m_xQueryBox->set_title(CuiResId(RID_SVXSTR_REPLACE_ICON_CONFIRM)); + m_xQueryBox->set_title(CuiResId(RID_CUISTR_REPLACE_ICON_CONFIRM)); m_xQueryBox->add_button(GetStandardText(StandardButtonType::Yes), 2); if (bYestoAll) - m_xQueryBox->add_button(CuiResId(RID_SVXSTR_YESTOALL), 5); + m_xQueryBox->add_button(CuiResId(RID_CUISTR_YESTOALL), 5); m_xQueryBox->add_button(GetStandardText(StandardButtonType::No), 4); m_xQueryBox->add_button(GetStandardText(StandardButtonType::Cancel), 6); m_xQueryBox->set_default_response(2); diff --git a/cui/source/customize/cfgutil.cxx b/cui/source/customize/cfgutil.cxx index c68db3540114..3a2cdbc1b05e 100644 --- a/cui/source/customize/cfgutil.cxx +++ b/cui/source/customize/cfgutil.cxx @@ -49,14 +49,16 @@ #include <sal/log.hxx> #include <osl/diagnose.h> #include <dialmgr.hxx> -#include <tools/diagnose_ex.h> +#include <comphelper/diagnose_ex.hxx> #include <vcl/commandevent.hxx> #include <vcl/commandinfoprovider.hxx> #include <vcl/help.hxx> #include <vcl/svapp.hxx> +#include <o3tl/string_view.hxx> #include <sfx2/sidebar/ResourceManager.hxx> #include <sfx2/sidebar/Context.hxx> +#include <unotools/viewoptions.hxx> using namespace ::com::sun::star; using namespace ::com::sun::star::uno; @@ -77,7 +79,9 @@ const char CMDURL_STYLEPROT_ONLY[] = ".uno:StyleApply?"; const char CMDURL_SPART_ONLY [] = "Style:string="; const char CMDURL_FPART_ONLY [] = "FamilyName:string="; -constexpr OUStringLiteral STYLEPROP_UINAME = u"DisplayName"; +constexpr OUString STYLEPROP_UINAME = u"DisplayName"_ustr; +constexpr OUString MACRO_SELECTOR_CONFIGNAME = u"MacroSelectorDialog"_ustr; +constexpr OUString LAST_RUN_MACRO_INFO = u"LastRunMacro"_ustr; OUString SfxStylesInfo_Impl::generateCommand( std::u16string_view sFamily, std::u16string_view sStyle) @@ -242,7 +246,7 @@ std::vector< SfxStyleInfo_Impl > SfxStylesInfo_Impl::getStyles(const OUString& s OUString CuiConfigFunctionListBox::GetHelpText( bool bConsiderParent ) { - SfxGroupInfo_Impl *pData = reinterpret_cast<SfxGroupInfo_Impl*>(get_selected_id().toInt64()); + SfxGroupInfo_Impl *pData = weld::fromId<SfxGroupInfo_Impl*>(get_selected_id()); if (pData) { if ( pData->nKind == SfxCfgKind::FUNCTION_SLOT ) @@ -262,7 +266,7 @@ OUString CuiConfigFunctionListBox::GetHelpText( bool bConsiderParent ) OUString CuiConfigFunctionListBox::GetCurCommand() const { - SfxGroupInfo_Impl *pData = reinterpret_cast<SfxGroupInfo_Impl*>(get_selected_id().toInt64()); + SfxGroupInfo_Impl *pData = weld::fromId<SfxGroupInfo_Impl*>(get_selected_id()); if (!pData) return OUString(); return pData->sCommand; @@ -270,7 +274,7 @@ OUString CuiConfigFunctionListBox::GetCurCommand() const OUString CuiConfigFunctionListBox::GetCurLabel() const { - SfxGroupInfo_Impl *pData = reinterpret_cast<SfxGroupInfo_Impl*>(get_selected_id().toInt64()); + SfxGroupInfo_Impl *pData = weld::fromId<SfxGroupInfo_Impl*>(get_selected_id()); if (!pData) return OUString(); if (!pData->sLabel.isEmpty()) @@ -294,12 +298,12 @@ CuiConfigFunctionListBox::~CuiConfigFunctionListBox() IMPL_LINK(CuiConfigFunctionListBox, QueryTooltip, const weld::TreeIter&, rIter, OUString) { - SfxGroupInfo_Impl *pData = reinterpret_cast<SfxGroupInfo_Impl*>(m_xTreeView->get_id(rIter).toInt64()); + SfxGroupInfo_Impl *pData = weld::fromId<SfxGroupInfo_Impl*>(m_xTreeView->get_id(rIter)); if (!pData) return OUString(); - OUString aLabel = CuiResId(RID_SVXSTR_COMMANDLABEL) + ": "; - OUString aName = CuiResId(RID_SVXSTR_COMMANDNAME) + ": "; - OUString aTip = CuiResId(RID_SVXSTR_COMMANDTIP) + ": "; + OUString aLabel = CuiResId(RID_CUISTR_COMMANDLABEL) + ": "; + OUString aName = CuiResId(RID_CUISTR_COMMANDNAME) + ": "; + OUString aTip = CuiResId(RID_CUISTR_COMMANDTIP) + ": "; return aLabel + pData->sLabel + "\n" + aName + pData->sCommand+ "\n" + aTip + pData->sTooltip; } @@ -336,7 +340,7 @@ void CuiConfigFunctionListBox::ClearAll() OUString CuiConfigFunctionListBox::GetSelectedScriptURI() const { - SfxGroupInfo_Impl *pData = reinterpret_cast<SfxGroupInfo_Impl*>(get_selected_id().toInt64()); + SfxGroupInfo_Impl *pData = weld::fromId<SfxGroupInfo_Impl*>(get_selected_id()); if (pData && pData->nKind == SfxCfgKind::FUNCTION_SCRIPT) return *static_cast<OUString*>(pData->pObject); return OUString(); @@ -346,7 +350,6 @@ struct SvxConfigGroupBoxResource_Impl { OUString m_sMyMacros; OUString m_sProdMacros; - OUString m_sMacros; OUString m_sDlgMacros; OUString m_aStrGroupStyles; OUString m_aStrGroupSidebarDecks; @@ -355,12 +358,11 @@ struct SvxConfigGroupBoxResource_Impl }; SvxConfigGroupBoxResource_Impl::SvxConfigGroupBoxResource_Impl() : - m_sMyMacros(CuiResId(RID_SVXSTR_MYMACROS)), - m_sProdMacros(CuiResId(RID_SVXSTR_PRODMACROS)), - m_sMacros(CuiResId(RID_SVXSTR_BASICMACROS)), - m_sDlgMacros(CuiResId(RID_SVXSTR_PRODMACROS)), - m_aStrGroupStyles(CuiResId(RID_SVXSTR_GROUP_STYLES)), - m_aStrGroupSidebarDecks(CuiResId(RID_SVXSTR_GROUP_SIDEBARDECKS)) + m_sMyMacros(CuiResId(RID_CUISTR_MYMACROS)), + m_sProdMacros(CuiResId(RID_CUISTR_PRODMACROS)), + m_sDlgMacros(CuiResId(RID_CUISTR_PRODMACROS)), + m_aStrGroupStyles(CuiResId(RID_CUISTR_GROUP_STYLES)), + m_aStrGroupSidebarDecks(CuiResId(RID_CUISTR_GROUP_SIDEBARDECKS)) { } @@ -467,22 +469,16 @@ void CuiConfigGroupListBox::ClearAll() m_xTreeView->clear(); } -void CuiConfigGroupListBox::InitModule() +sal_Int32 CuiConfigGroupListBox::InitModule() { try { + // return the number of added groups css::uno::Reference< css::frame::XDispatchInformationProvider > xProvider(m_xFrame, css::uno::UNO_QUERY_THROW); css::uno::Sequence< sal_Int16 > lGroups = xProvider->getSupportedCommandGroups(); sal_Int32 c1 = lGroups.getLength(); sal_Int32 i1 = 0; - - if ( c1 ) - { - // Add All Commands category - aArr.push_back(std::make_unique<SfxGroupInfo_Impl>(SfxCfgKind::GROUP_ALLFUNCTIONS, 0)); - m_xTreeView->append(OUString::number(reinterpret_cast<sal_Int64>(aArr.back().get())), - CuiResId(RID_SVXSTR_ALLFUNCTIONS)); - } + sal_Int32 nAddedGroups = 0; for (i1=0; i1<c1; ++i1) { @@ -500,14 +496,16 @@ void CuiConfigGroupListBox::InitModule() { continue; } aArr.push_back( std::make_unique<SfxGroupInfo_Impl>( SfxCfgKind::GROUP_FUNCTION, nGroupID ) ); - m_xTreeView->append(OUString::number(reinterpret_cast<sal_Int64>(aArr.back().get())), - sGroupName); + m_xTreeView->append(weld::toId(aArr.back().get()), sGroupName); + nAddedGroups++; } + return nAddedGroups; } catch(const css::uno::RuntimeException&) { throw; } catch(const css::uno::Exception&) {} + return 0; } void CuiConfigGroupListBox::FillScriptList(const css::uno::Reference< css::script::browse::XBrowseNode >& xRootNode, @@ -594,7 +592,7 @@ void CuiConfigGroupListBox::FillScriptList(const css::uno::Reference< css::scrip aArr.push_back( std::make_unique<SfxGroupInfo_Impl>(SfxCfgKind::GROUP_SCRIPTCONTAINER, 0, static_cast<void *>( theChild.get()))); - OUString sId(OUString::number(reinterpret_cast<sal_Int64>(aArr.back().get()))); + OUString sId(weld::toId(aArr.back().get())); m_xTreeView->insert(pParentEntry, -1, &uiName, &sId, nullptr, nullptr, bChildOnDemand, m_xScratchIter.get()); m_xTreeView->set_image(*m_xScratchIter, aImage); } @@ -619,7 +617,7 @@ void CuiConfigGroupListBox::FillFunctionsList(const css::uno::Sequence<DispatchI pGrpInfo->sCommand = rInfo.Command; pGrpInfo->sLabel = sUIName; pGrpInfo->sTooltip = vcl::CommandInfoProvider::GetTooltipForCommand(rInfo.Command, aProperties, m_xFrame); - m_pFunctionListBox->append(OUString::number(reinterpret_cast<sal_Int64>(pGrpInfo)), sUIName); + m_pFunctionListBox->append(weld::toId(pGrpInfo), sUIName); } m_pFunctionListBox->thaw(); } @@ -634,6 +632,7 @@ void CuiConfigGroupListBox::Init(const css::uno::Reference< css::uno::XComponent m_xContext = xContext; m_xFrame = xFrame; + sal_Int32 nAddedGroups = 0; if( bEventMode ) { m_sModuleLongName = sModuleLongName; @@ -641,7 +640,7 @@ void CuiConfigGroupListBox::Init(const css::uno::Reference< css::uno::XComponent m_xModuleCategoryInfo.set(m_xGlobalCategoryInfo->getByName(m_sModuleLongName), css::uno::UNO_QUERY_THROW); m_xUICmdDescription = css::frame::theUICommandDescription::get( m_xContext ); - InitModule(); + nAddedGroups = InitModule(); } SAL_INFO("cui.customize", "** ** About to initialise SF Scripts"); @@ -658,7 +657,21 @@ void CuiConfigGroupListBox::Init(const css::uno::Reference< css::uno::XComponent // TODO exception handling } + m_xTreeView->thaw(); + m_xTreeView->make_sorted(); + m_xTreeView->make_unsorted(); + m_xTreeView->freeze(); + // add All Commands to the top + if ( bEventMode && nAddedGroups ) + { + aArr.insert(aArr.begin(), std::make_unique<SfxGroupInfo_Impl>(SfxCfgKind::GROUP_ALLFUNCTIONS, 0)); + OUString sId(weld::toId(aArr.front().get())); + OUString s(CuiResId(RID_CUISTR_ALLFUNCTIONS)); + m_xTreeView->insert(nullptr, 0, &s, &sId, nullptr, nullptr, false, nullptr); + } + + // add application macros to the end if ( rootNode.is() ) { if ( bEventMode ) @@ -670,7 +683,7 @@ void CuiConfigGroupListBox::Init(const css::uno::Reference< css::uno::XComponent aArr.push_back( std::make_unique<SfxGroupInfo_Impl>( SfxCfgKind::GROUP_SCRIPTCONTAINER, 0, static_cast<void *>(rootNode.get()))); OUString aTitle(xImp->m_sDlgMacros); - OUString sId(OUString::number(reinterpret_cast<sal_Int64>(aArr.back().get()))); + OUString sId(weld::toId(aArr.back().get())); m_xTreeView->insert(nullptr, -1, &aTitle, &sId, nullptr, nullptr, true, nullptr); } else @@ -681,17 +694,17 @@ void CuiConfigGroupListBox::Init(const css::uno::Reference< css::uno::XComponent } } - // add styles and sidebar decks + // add styles and sidebar decks to the end if ( bEventMode ) { aArr.push_back( std::make_unique<SfxGroupInfo_Impl>( SfxCfgKind::GROUP_STYLES, 0, nullptr ) ); // TODO last parameter should contain user data OUString sStyle(xImp->m_aStrGroupStyles); - OUString sId(OUString::number(reinterpret_cast<sal_Int64>(aArr.back().get()))); + OUString sId(weld::toId(aArr.back().get())); m_xTreeView->insert(nullptr, -1, &sStyle, &sId, nullptr, nullptr, true, nullptr); aArr.push_back( std::make_unique<SfxGroupInfo_Impl>(SfxCfgKind::GROUP_SIDEBARDECKS, 0)); OUString sSidebarDecks(xImp->m_aStrGroupSidebarDecks); - sId = OUString::number(reinterpret_cast<sal_Int64>(aArr.back().get())); + sId = weld::toId(aArr.back().get()); m_xTreeView->insert(nullptr, -1, &sSidebarDecks, &sId, nullptr, nullptr, false, nullptr); } @@ -826,7 +839,7 @@ void CuiConfigGroupListBox::GroupSelected() if (!m_xTreeView->get_selected(xIter.get())) return; - SfxGroupInfo_Impl *pInfo = reinterpret_cast<SfxGroupInfo_Impl*>(m_xTreeView->get_id(*xIter).toInt64()); + SfxGroupInfo_Impl *pInfo = weld::fromId<SfxGroupInfo_Impl*>(m_xTreeView->get_id(*xIter)); m_pFunctionListBox->freeze(); m_pFunctionListBox->ClearAll(); @@ -838,7 +851,7 @@ void CuiConfigGroupListBox::GroupSelected() bool bValidIter = m_xTreeView->get_iter_first(*xIter); while (bValidIter) { - SfxGroupInfo_Impl *pCurrentInfo = reinterpret_cast<SfxGroupInfo_Impl*>(m_xTreeView->get_id(*xIter).toInt64()); + SfxGroupInfo_Impl *pCurrentInfo = weld::fromId<SfxGroupInfo_Impl*>(m_xTreeView->get_id(*xIter)); if (pCurrentInfo->nKind == SfxCfgKind::GROUP_FUNCTION) { css::uno::Sequence< css::frame::DispatchInformation > lCommands; @@ -911,7 +924,7 @@ void CuiConfigGroupListBox::GroupSelected() m_pFunctionListBox->aArr.back()->sLabel = childNode->getName(); m_pFunctionListBox->aArr.back()->sHelpText = description; - OUString sId(OUString::number(reinterpret_cast<sal_Int64>(m_pFunctionListBox->aArr.back().get()))); + OUString sId(weld::toId(m_pFunctionListBox->aArr.back().get())); m_pFunctionListBox->append(sId, childNode->getName(), aImage); } } @@ -936,7 +949,7 @@ void CuiConfigGroupListBox::GroupSelected() m_pFunctionListBox->aArr.push_back(std::make_unique<SfxGroupInfo_Impl>(SfxCfgKind::GROUP_STYLES, 0, pStyle)); m_pFunctionListBox->aArr.back()->sCommand = pStyle->sCommand; m_pFunctionListBox->aArr.back()->sLabel = pStyle->sLabel; - OUString sId(OUString::number(reinterpret_cast<sal_Int64>(m_pFunctionListBox->aArr.back().get()))); + OUString sId(weld::toId(m_pFunctionListBox->aArr.back().get())); m_pFunctionListBox->append(sId, pStyle->sLabel); } } @@ -960,8 +973,7 @@ void CuiConfigGroupListBox::GroupSelected() m_pFunctionListBox->aArr.back()->sLabel = rDeck.msId; m_pFunctionListBox->aArr.back()->sTooltip = vcl::CommandInfoProvider::GetCommandShortcut(sCommand, m_xFrame); - m_pFunctionListBox->append(OUString::number(reinterpret_cast<sal_Int64>( - m_pFunctionListBox->aArr.back().get())), + m_pFunctionListBox->append(weld::toId(m_pFunctionListBox->aArr.back().get()), rDeck.msId); } @@ -985,7 +997,7 @@ void CuiConfigGroupListBox::GroupSelected() */ IMPL_LINK(CuiConfigGroupListBox, ExpandingHdl, const weld::TreeIter&, rIter, bool) { - SfxGroupInfo_Impl *pInfo = reinterpret_cast<SfxGroupInfo_Impl*>(m_xTreeView->get_id(rIter).toInt64()); + SfxGroupInfo_Impl *pInfo = weld::fromId<SfxGroupInfo_Impl*>(m_xTreeView->get_id(rIter)); switch ( pInfo->nKind ) { case SfxCfgKind::GROUP_SCRIPTCONTAINER: @@ -1008,7 +1020,7 @@ IMPL_LINK(CuiConfigGroupListBox, ExpandingHdl, const weld::TreeIter&, rIter, boo { SfxStyleInfo_Impl* pFamily = new SfxStyleInfo_Impl(lStyleFamily); aArr.push_back( std::make_unique<SfxGroupInfo_Impl>( SfxCfgKind::GROUP_STYLES, 0, pFamily )); - OUString sId(OUString::number(reinterpret_cast<sal_Int64>(aArr.back().get()))); + OUString sId(weld::toId(aArr.back().get())); m_xTreeView->insert(&rIter, -1, &pFamily->sLabel, &sId, nullptr, nullptr, false, nullptr); } } @@ -1025,27 +1037,21 @@ IMPL_LINK(CuiConfigGroupListBox, ExpandingHdl, const weld::TreeIter&, rIter, boo #if HAVE_FEATURE_SCRIPTING void CuiConfigGroupListBox::SelectMacro( const SfxMacroInfoItem *pItem ) { - SelectMacro( pItem->GetBasicManager()->GetName(), - pItem->GetQualifiedName() ); -} - -void CuiConfigGroupListBox::SelectMacro( std::u16string_view rBasic, - const OUString& rMacro ) -{ - const OUString aBasicName(OUString::Concat(rBasic) + " " + xImp->m_sMacros); + auto const rMacro = pItem->GetQualifiedName(); sal_Int32 nIdx {rMacro.lastIndexOf('.')}; - const OUString aMethod( rMacro.copy(nIdx+1) ); - OUString aLib; - OUString aModule; + const std::u16string_view aMethod( rMacro.subView(nIdx + 1) ); + std::u16string_view aLib; + std::u16string_view aModule; if ( nIdx>0 ) { // string contains at least 2 tokens nIdx = rMacro.lastIndexOf('.', nIdx); - if (nIdx>=0) + if (nIdx != -1) { // string contains at least 3 tokens - aLib = rMacro.getToken( 0, '.' ); - aModule = rMacro.getToken( 0, '.', ++nIdx ); + aLib = o3tl::getToken(rMacro, 0, '.' ); + sal_Int32 nIdx2 = nIdx + 1; + aModule = o3tl::getToken(rMacro, 0, '.', nIdx2 ); } } @@ -1056,45 +1062,61 @@ void CuiConfigGroupListBox::SelectMacro( std::u16string_view rBasic, do { OUString aEntryBas = m_xTreeView->get_text(*xIter); - if (aEntryBas == aBasicName) + if (aEntryBas == xImp->m_sDlgMacros) { m_xTreeView->expand_row(*xIter); - std::unique_ptr<weld::TreeIter> xLibIter = m_xTreeView->make_iterator(xIter.get()); - if (m_xTreeView->get_iter_first(*xLibIter)) + std::unique_ptr<weld::TreeIter> xLocationIter = m_xTreeView->make_iterator(xIter.get()); + if (m_xTreeView->iter_children(*xLocationIter)) { do { - OUString aEntryLib = m_xTreeView->get_text(*xLibIter); - if (aEntryLib == aLib) + m_xTreeView->expand_row(*xLocationIter); + std::unique_ptr<weld::TreeIter> xLibIter = m_xTreeView->make_iterator(xLocationIter.get()); + if (m_xTreeView->iter_children(*xLibIter)) { - m_xTreeView->expand_row(*xLibIter); - std::unique_ptr<weld::TreeIter> xModIter = m_xTreeView->make_iterator(xLibIter.get()); - if (m_xTreeView->get_iter_first(*xModIter)) + do { - do + OUString aEntryLib = m_xTreeView->get_text(*xLibIter); + if (aEntryLib == aLib) { - OUString aEntryMod = m_xTreeView->get_text(*xModIter); - if ( aEntryMod == aModule ) + m_xTreeView->expand_row(*xLibIter); + std::unique_ptr<weld::TreeIter> xModIter = m_xTreeView->make_iterator(xLibIter.get()); + if (m_xTreeView->iter_children(*xModIter)) { - m_xTreeView->expand_row(*xModIter); - m_xTreeView->scroll_to_row(*xModIter); - m_xTreeView->select(*xModIter); - for (int i = 0, nCount = m_pFunctionListBox->n_children(); i < nCount; ++i) + do { - OUString aEntryMethod = m_pFunctionListBox->get_text(i); - if (aEntryMethod == aMethod) + OUString aEntryMod = m_xTreeView->get_text(*xModIter); + if ( aEntryMod == aModule ) { - m_pFunctionListBox->select(i); - m_pFunctionListBox->scroll_to_row(i); - return; + m_xTreeView->expand_row(*xModIter); + m_xTreeView->scroll_to_row(*xModIter); + m_xTreeView->select(*xModIter); + GroupSelected(); + for (int i = 0, nCount = m_pFunctionListBox->n_children(); i < nCount; ++i) + { + OUString aEntryMethod = m_pFunctionListBox->get_text(i); + if (aEntryMethod == aMethod) + { + m_pFunctionListBox->select(i); + m_pFunctionListBox->scroll_to_row(i); + return; + } + } + m_xTreeView->collapse_row(*xModIter); } - } + } while (m_xTreeView->iter_next_sibling(*xModIter)); } - } while (m_xTreeView->iter_next_sibling(*xModIter)); - } + m_xTreeView->collapse_row(*xLibIter); + } + } while (m_xTreeView->iter_next_sibling(*xLibIter)); } - } while (m_xTreeView->iter_next_sibling(*xLibIter)); + m_xTreeView->collapse_row(*xLocationIter); + } while (m_xTreeView->iter_next_sibling(*xLocationIter)); } + // If the macro can't be located, preselect the "Application Macros" category: + m_xTreeView->scroll_to_row(*xIter); + m_xTreeView->select(*xIter); + return; } } while (m_xTreeView->iter_next_sibling(*xIter)); } @@ -1153,6 +1175,10 @@ SvxScriptSelectorDialog::SvxScriptSelectorDialog( m_aStylesInfo.init(aModuleName, xModel); m_xCategories->SetStylesInfo(&m_aStylesInfo); + // The following call is a workaround to make scroll_to_row work as expected in kf5/x11 + m_xDialog->resize_to_request(); + + LoadLastUsedMacro(); UpdateUI(); if (comphelper::LibreOfficeKit::isActive()) @@ -1191,7 +1217,7 @@ IMPL_LINK(SvxScriptSelectorDialog, ContextMenuHdl, const CommandEvent&, rCEvt, b xDropMenu->set_active("alphabetically", xTreeView.get_sort_order()); xDropMenu->set_active("properorder", !xTreeView.get_sort_order()); - OString sCommand(xPopup->popup_at_rect(&xTreeView, tools::Rectangle(rCEvt.GetMousePosPixel(), Size(1,1)))); + OUString sCommand(xPopup->popup_at_rect(&xTreeView, tools::Rectangle(rCEvt.GetMousePosPixel(), Size(1,1)))); if (sCommand == "alphabetically") { xTreeView.make_sorted(); @@ -1219,7 +1245,6 @@ SvxScriptSelectorDialog::UpdateUI() { OUString sMessage = m_xCommands->GetHelpText(); m_xDescriptionText->set_text(sMessage.isEmpty() ? m_sDefaultDesc : sMessage); - m_xOKButton->set_sensitive(true); } else @@ -1237,6 +1262,7 @@ IMPL_LINK(SvxScriptSelectorDialog, ClickHdl, weld::Button&, rButton, void) } else if (&rButton == m_xOKButton.get()) { + SaveLastUsedMacro(); m_xDialog->response(RET_OK); } } @@ -1244,7 +1270,7 @@ IMPL_LINK(SvxScriptSelectorDialog, ClickHdl, weld::Button&, rButton, void) void SvxScriptSelectorDialog::SetRunLabel() { - m_xOKButton->set_label(CuiResId(RID_SVXSTR_SELECTOR_RUN)); + m_xOKButton->set_label(CuiResId(RID_CUISTR_SELECTOR_RUN)); } OUString @@ -1255,7 +1281,7 @@ SvxScriptSelectorDialog::GetScriptURL() const std::unique_ptr<weld::TreeIter> xIter = m_xCommands->make_iterator(); if (m_xCommands->get_selected(xIter.get())) { - SfxGroupInfo_Impl *pData = reinterpret_cast<SfxGroupInfo_Impl*>(m_xCommands->get_id(*xIter).toInt64()); + SfxGroupInfo_Impl *pData = weld::fromId<SfxGroupInfo_Impl*>(m_xCommands->get_id(*xIter)); if ( ( pData->nKind == SfxCfgKind::FUNCTION_SLOT ) || ( pData->nKind == SfxCfgKind::FUNCTION_SCRIPT ) || ( pData->nKind == SfxCfgKind::GROUP_STYLES ) @@ -1268,4 +1294,100 @@ SvxScriptSelectorDialog::GetScriptURL() const return result; } +void +SvxScriptSelectorDialog::SaveLastUsedMacro() +{ + // Gets the current selection in the dialog as a series of selected entries + OUString sMacroInfo; + sMacroInfo = m_xCommands->get_selected_text(); + weld::TreeView& xCategories = m_xCategories->get_widget(); + std::unique_ptr<weld::TreeIter> xIter = xCategories.make_iterator(); + + if (!xCategories.get_selected(xIter.get())) + return; + + do + { + sMacroInfo = xCategories.get_text(*xIter) + "|" + sMacroInfo; + } while (xCategories.iter_parent(*xIter)); + + SvtViewOptions( EViewType::Dialog, MACRO_SELECTOR_CONFIGNAME ).SetUserItem( + LAST_RUN_MACRO_INFO, Any(sMacroInfo)); +} + +void +SvxScriptSelectorDialog::LoadLastUsedMacro() +{ + SvtViewOptions aDlgOpt( EViewType::Dialog, MACRO_SELECTOR_CONFIGNAME ); + if (!aDlgOpt.Exists()) + return; + + OUString sMacroInfo; + aDlgOpt.GetUserItem(LAST_RUN_MACRO_INFO) >>= sMacroInfo; + if (sMacroInfo.isEmpty()) + return; + + // Counts how many entries exist in the macro info string + sal_Int16 nInfoParts = 0; + sal_Int16 nLastIndex = sMacroInfo.indexOf('|'); + if (nLastIndex > -1) + { + nInfoParts = 1; + while ( nLastIndex != -1 ) + { + nInfoParts++; + nLastIndex = sMacroInfo.indexOf('|', nLastIndex + 1); + } + } + + weld::TreeView& xCategories = m_xCategories->get_widget(); + std::unique_ptr<weld::TreeIter> xIter = xCategories.make_iterator(); + if (!xCategories.get_iter_first(*xIter)) + return; + + // Expand the nodes in the category tree + OUString sNodeToExpand; + bool bIsIterValid; + sal_Int16 nOpenedNodes = 0; + for (sal_Int16 i=0; i<nInfoParts - 1; i++) + { + sNodeToExpand = sMacroInfo.getToken(i, '|'); + bIsIterValid = true; + while (bIsIterValid && xCategories.get_text(*xIter) != sNodeToExpand) + bIsIterValid = xCategories.iter_next_sibling(*xIter); + + if (bIsIterValid) + { + xCategories.expand_row(*xIter); + nOpenedNodes++; + } + if (xCategories.iter_has_child(*xIter)) + (void)xCategories.iter_children(*xIter); + else if (nOpenedNodes < nInfoParts - 1) + // If the number of levels in the tree is smaller than the + // number of parts in the macro info string, then return + return; + } + xCategories.select(*xIter); + xCategories.scroll_to_row(*xIter); + m_xCategories->GroupSelected(); + + // Select the macro in the command tree + weld::TreeView& xCommands = m_xCommands->get_widget(); + xIter = xCommands.make_iterator(); + if (!xCommands.get_iter_first(*xIter)) + return; + + OUString sMacroName = sMacroInfo.getToken(nInfoParts - 1, '|'); + bIsIterValid = true; + while (bIsIterValid && xCommands.get_text(*xIter) != sMacroName) + bIsIterValid = xCommands.iter_next_sibling(*xIter); + + if (bIsIterValid) + { + xCommands.scroll_to_row(*xIter); + xCommands.select(*xIter); + } +} + /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/cui/source/customize/eventdlg.cxx b/cui/source/customize/eventdlg.cxx index 54ebcdefa0c7..755fd16b416a 100644 --- a/cui/source/customize/eventdlg.cxx +++ b/cui/source/customize/eventdlg.cxx @@ -17,7 +17,7 @@ * the License at http://www.apache.org/licenses/LICENSE-2.0 . */ -#include <tools/diagnose_ex.h> +#include <comphelper/diagnose_ex.hxx> #include <com/sun/star/document/XEventsSupplier.hpp> #include <com/sun/star/frame/Desktop.hpp> #include <com/sun/star/frame/theGlobalEventBroadcaster.hpp> @@ -44,6 +44,7 @@ SvxEventConfigPage::SvxEventConfigPage(weld::Container* pPage, weld::DialogContr mpImpl->xEventLB = m_xBuilder->weld_tree_view("events"); mpImpl->xAssignPB = m_xBuilder->weld_button("macro"); mpImpl->xDeletePB = m_xBuilder->weld_button("delete"); + mpImpl->xDeleteAllPB = m_xBuilder->weld_button("deleteall"); mpImpl->xAssignComponentPB = m_xBuilder->weld_button("component"); mpImpl->xEventLB->set_size_request(mpImpl->xEventLB->get_approximate_digit_width() * 70, diff --git a/cui/source/customize/macropg.cxx b/cui/source/customize/macropg.cxx index 2074060a957a..79197be4bf43 100644 --- a/cui/source/customize/macropg.cxx +++ b/cui/source/customize/macropg.cxx @@ -20,7 +20,7 @@ #include <macropg.hxx> #include <svl/eitem.hxx> #include <tools/debug.hxx> -#include <tools/diagnose_ex.h> +#include <comphelper/diagnose_ex.hxx> #include <bitmaps.hlst> #include <cfgutil.hxx> #include <dialmgr.hxx> @@ -32,11 +32,13 @@ #include <svx/svxids.hrc> #include <strings.hrc> #include <comphelper/namedvaluecollection.hxx> +#include <o3tl/string_view.hxx> +#include <utility> using namespace ::com::sun::star; using namespace ::com::sun::star::uno; -constexpr OUStringLiteral aVndSunStarUNO = u"vnd.sun.star.UNO:"; +constexpr OUString aVndSunStarUNO = u"vnd.sun.star.UNO:"_ustr; SvxMacroTabPage_Impl::SvxMacroTabPage_Impl( const SfxItemSet& rAttrSet ) : bReadOnly(false) @@ -59,19 +61,20 @@ MacroEventListBox::MacroEventListBox(std::unique_ptr<weld::TreeView> xTreeView) // and it is not read only void SvxMacroTabPage_::EnableButtons() { + mpImpl->xDeleteAllPB->set_sensitive(m_nAssignedEvents != 0); int nEvent = mpImpl->xEventLB->get_selected_index(); - if (nEvent != -1) - { - mpImpl->xDeletePB->set_sensitive( !mpImpl->bReadOnly ); - mpImpl->xAssignPB->set_sensitive( !mpImpl->bReadOnly ); - if( mpImpl->xAssignComponentPB ) - mpImpl->xAssignComponentPB->set_sensitive( !mpImpl->bReadOnly ); - } + const EventPair* pEventPair = nEvent == -1 ? nullptr : LookupEvent(mpImpl->xEventLB->get_id(nEvent)); + const bool bAssigned = pEventPair && !pEventPair->second.isEmpty(); + mpImpl->xDeletePB->set_sensitive(!mpImpl->bReadOnly && bAssigned); + mpImpl->xAssignPB->set_sensitive(!mpImpl->bReadOnly); + if (mpImpl->xAssignComponentPB) + mpImpl->xAssignComponentPB->set_sensitive( !mpImpl->bReadOnly ); } SvxMacroTabPage_::SvxMacroTabPage_(weld::Container* pPage, weld::DialogController* pController, const OUString& rUIXMLDescription, - const OString& rID, const SfxItemSet& rAttrSet) + const OUString& rID, const SfxItemSet& rAttrSet) : SfxTabPage(pPage, pController, rUIXMLDescription, rID, &rAttrSet) + , m_nAssignedEvents(0) , bDocModified(false) , bAppEvents(false) , bInitialized(false) @@ -89,81 +92,81 @@ void SvxMacroTabPage_::InitResources() // Note: the order here controls the order in which the events are displayed in the UI! // the event name to UI string mappings for App Events - aDisplayNames.emplace_back( "OnStartApp", RID_SVXSTR_EVENT_STARTAPP ); - aDisplayNames.emplace_back( "OnCloseApp", RID_SVXSTR_EVENT_CLOSEAPP ); - aDisplayNames.emplace_back( "OnCreate", RID_SVXSTR_EVENT_CREATEDOC ); - aDisplayNames.emplace_back( "OnNew", RID_SVXSTR_EVENT_NEWDOC ); - aDisplayNames.emplace_back( "OnLoadFinished", RID_SVXSTR_EVENT_LOADDOCFINISHED ); - aDisplayNames.emplace_back( "OnLoad", RID_SVXSTR_EVENT_OPENDOC ); - aDisplayNames.emplace_back( "OnPrepareUnload", RID_SVXSTR_EVENT_PREPARECLOSEDOC ); - aDisplayNames.emplace_back( "OnUnload", RID_SVXSTR_EVENT_CLOSEDOC ) ; - aDisplayNames.emplace_back( "OnViewCreated", RID_SVXSTR_EVENT_VIEWCREATED ); - aDisplayNames.emplace_back( "OnPrepareViewClosing", RID_SVXSTR_EVENT_PREPARECLOSEVIEW ); - aDisplayNames.emplace_back( "OnViewClosed", RID_SVXSTR_EVENT_CLOSEVIEW ) ; - aDisplayNames.emplace_back( "OnFocus", RID_SVXSTR_EVENT_ACTIVATEDOC ); - aDisplayNames.emplace_back( "OnUnfocus", RID_SVXSTR_EVENT_DEACTIVATEDOC ); - aDisplayNames.emplace_back( "OnSave", RID_SVXSTR_EVENT_SAVEDOC ); - aDisplayNames.emplace_back( "OnSaveDone", RID_SVXSTR_EVENT_SAVEDOCDONE ); - aDisplayNames.emplace_back( "OnSaveFailed", RID_SVXSTR_EVENT_SAVEDOCFAILED ); - aDisplayNames.emplace_back( "OnSaveAs", RID_SVXSTR_EVENT_SAVEASDOC ); - aDisplayNames.emplace_back( "OnSaveAsDone", RID_SVXSTR_EVENT_SAVEASDOCDONE ); - aDisplayNames.emplace_back( "OnSaveAsFailed", RID_SVXSTR_EVENT_SAVEASDOCFAILED ); - aDisplayNames.emplace_back( "OnCopyTo", RID_SVXSTR_EVENT_COPYTODOC ); - aDisplayNames.emplace_back( "OnCopyToDone", RID_SVXSTR_EVENT_COPYTODOCDONE ); - aDisplayNames.emplace_back( "OnCopyToFailed", RID_SVXSTR_EVENT_COPYTODOCFAILED ); - aDisplayNames.emplace_back( "OnPrint", RID_SVXSTR_EVENT_PRINTDOC ); - aDisplayNames.emplace_back( "OnModifyChanged", RID_SVXSTR_EVENT_MODIFYCHANGED ); - aDisplayNames.emplace_back( "OnTitleChanged", RID_SVXSTR_EVENT_TITLECHANGED ); + aDisplayNames.emplace_back( "OnStartApp", RID_CUISTR_EVENT_STARTAPP ); + aDisplayNames.emplace_back( "OnCloseApp", RID_CUISTR_EVENT_CLOSEAPP ); + aDisplayNames.emplace_back( "OnCreate", RID_CUISTR_EVENT_CREATEDOC ); + aDisplayNames.emplace_back( "OnNew", RID_CUISTR_EVENT_NEWDOC ); + aDisplayNames.emplace_back( "OnLoadFinished", RID_CUISTR_EVENT_LOADDOCFINISHED ); + aDisplayNames.emplace_back( "OnLoad", RID_CUISTR_EVENT_OPENDOC ); + aDisplayNames.emplace_back( "OnPrepareUnload", RID_CUISTR_EVENT_PREPARECLOSEDOC ); + aDisplayNames.emplace_back( "OnUnload", RID_CUISTR_EVENT_CLOSEDOC ) ; + aDisplayNames.emplace_back( "OnViewCreated", RID_CUISTR_EVENT_VIEWCREATED ); + aDisplayNames.emplace_back( "OnPrepareViewClosing", RID_CUISTR_EVENT_PREPARECLOSEVIEW ); + aDisplayNames.emplace_back( "OnViewClosed", RID_CUISTR_EVENT_CLOSEVIEW ) ; + aDisplayNames.emplace_back( "OnFocus", RID_CUISTR_EVENT_ACTIVATEDOC ); + aDisplayNames.emplace_back( "OnUnfocus", RID_CUISTR_EVENT_DEACTIVATEDOC ); + aDisplayNames.emplace_back( "OnSave", RID_CUISTR_EVENT_SAVEDOC ); + aDisplayNames.emplace_back( "OnSaveDone", RID_CUISTR_EVENT_SAVEDOCDONE ); + aDisplayNames.emplace_back( "OnSaveFailed", RID_CUISTR_EVENT_SAVEDOCFAILED ); + aDisplayNames.emplace_back( "OnSaveAs", RID_CUISTR_EVENT_SAVEASDOC ); + aDisplayNames.emplace_back( "OnSaveAsDone", RID_CUISTR_EVENT_SAVEASDOCDONE ); + aDisplayNames.emplace_back( "OnSaveAsFailed", RID_CUISTR_EVENT_SAVEASDOCFAILED ); + aDisplayNames.emplace_back( "OnCopyTo", RID_CUISTR_EVENT_COPYTODOC ); + aDisplayNames.emplace_back( "OnCopyToDone", RID_CUISTR_EVENT_COPYTODOCDONE ); + aDisplayNames.emplace_back( "OnCopyToFailed", RID_CUISTR_EVENT_COPYTODOCFAILED ); + aDisplayNames.emplace_back( "OnPrint", RID_CUISTR_EVENT_PRINTDOC ); + aDisplayNames.emplace_back( "OnModifyChanged", RID_CUISTR_EVENT_MODIFYCHANGED ); + aDisplayNames.emplace_back( "OnTitleChanged", RID_CUISTR_EVENT_TITLECHANGED ); // application specific events - aDisplayNames.emplace_back( "OnMailMerge", RID_SVXSTR_EVENT_MAILMERGE ); - aDisplayNames.emplace_back( "OnMailMergeFinished", RID_SVXSTR_EVENT_MAILMERGE_END ); - aDisplayNames.emplace_back( "OnFieldMerge", RID_SVXSTR_EVENT_FIELDMERGE ); - aDisplayNames.emplace_back( "OnFieldMergeFinished", RID_SVXSTR_EVENT_FIELDMERGE_FINISHED ); - aDisplayNames.emplace_back( "OnPageCountChange", RID_SVXSTR_EVENT_PAGECOUNTCHANGE ); - aDisplayNames.emplace_back( "OnSubComponentOpened", RID_SVXSTR_EVENT_SUBCOMPONENT_OPENED ); - aDisplayNames.emplace_back( "OnSubComponentClosed", RID_SVXSTR_EVENT_SUBCOMPONENT_CLOSED ); - aDisplayNames.emplace_back( "OnSelect", RID_SVXSTR_EVENT_SELECTIONCHANGED ); - aDisplayNames.emplace_back( "OnDoubleClick", RID_SVXSTR_EVENT_DOUBLECLICK ); - aDisplayNames.emplace_back( "OnRightClick", RID_SVXSTR_EVENT_RIGHTCLICK ); - aDisplayNames.emplace_back( "OnCalculate", RID_SVXSTR_EVENT_CALCULATE ); - aDisplayNames.emplace_back( "OnChange", RID_SVXSTR_EVENT_CONTENTCHANGED ); + aDisplayNames.emplace_back( "OnMailMerge", RID_CUISTR_EVENT_MAILMERGE ); + aDisplayNames.emplace_back( "OnMailMergeFinished", RID_CUISTR_EVENT_MAILMERGE_END ); + aDisplayNames.emplace_back( "OnFieldMerge", RID_CUISTR_EVENT_FIELDMERGE ); + aDisplayNames.emplace_back( "OnFieldMergeFinished", RID_CUISTR_EVENT_FIELDMERGE_FINISHED ); + aDisplayNames.emplace_back( "OnPageCountChange", RID_CUISTR_EVENT_PAGECOUNTCHANGE ); + aDisplayNames.emplace_back( "OnSubComponentOpened", RID_CUISTR_EVENT_SUBCOMPONENT_OPENED ); + aDisplayNames.emplace_back( "OnSubComponentClosed", RID_CUISTR_EVENT_SUBCOMPONENT_CLOSED ); + aDisplayNames.emplace_back( "OnSelect", RID_CUISTR_EVENT_SELECTIONCHANGED ); + aDisplayNames.emplace_back( "OnDoubleClick", RID_CUISTR_EVENT_DOUBLECLICK ); + aDisplayNames.emplace_back( "OnRightClick", RID_CUISTR_EVENT_RIGHTCLICK ); + aDisplayNames.emplace_back( "OnCalculate", RID_CUISTR_EVENT_CALCULATE ); + aDisplayNames.emplace_back( "OnChange", RID_CUISTR_EVENT_CONTENTCHANGED ); // the event name to UI string mappings for forms & dialogs - aDisplayNames.emplace_back( "approveAction", RID_SVXSTR_EVENT_APPROVEACTIONPERFORMED ); - aDisplayNames.emplace_back( "actionPerformed", RID_SVXSTR_EVENT_ACTIONPERFORMED ); - aDisplayNames.emplace_back( "changed", RID_SVXSTR_EVENT_CHANGED ); - aDisplayNames.emplace_back( "textChanged", RID_SVXSTR_EVENT_TEXTCHANGED ); - aDisplayNames.emplace_back( "itemStateChanged", RID_SVXSTR_EVENT_ITEMSTATECHANGED ); - aDisplayNames.emplace_back( "focusGained", RID_SVXSTR_EVENT_FOCUSGAINED ); - aDisplayNames.emplace_back( "focusLost", RID_SVXSTR_EVENT_FOCUSLOST ); - aDisplayNames.emplace_back( "keyPressed", RID_SVXSTR_EVENT_KEYTYPED ); - aDisplayNames.emplace_back( "keyReleased", RID_SVXSTR_EVENT_KEYUP ); - aDisplayNames.emplace_back( "mouseEntered", RID_SVXSTR_EVENT_MOUSEENTERED ); - aDisplayNames.emplace_back( "mouseDragged", RID_SVXSTR_EVENT_MOUSEDRAGGED ); - aDisplayNames.emplace_back( "mouseMoved", RID_SVXSTR_EVENT_MOUSEMOVED ); - aDisplayNames.emplace_back( "mousePressed", RID_SVXSTR_EVENT_MOUSEPRESSED ); - aDisplayNames.emplace_back( "mouseReleased", RID_SVXSTR_EVENT_MOUSERELEASED ); - aDisplayNames.emplace_back( "mouseExited", RID_SVXSTR_EVENT_MOUSEEXITED ); - aDisplayNames.emplace_back( "approveReset", RID_SVXSTR_EVENT_APPROVERESETTED ); - aDisplayNames.emplace_back( "resetted", RID_SVXSTR_EVENT_RESETTED ); - aDisplayNames.emplace_back( "approveSubmit", RID_SVXSTR_EVENT_SUBMITTED ); - aDisplayNames.emplace_back( "approveUpdate", RID_SVXSTR_EVENT_BEFOREUPDATE ); - aDisplayNames.emplace_back( "updated", RID_SVXSTR_EVENT_AFTERUPDATE ); - aDisplayNames.emplace_back( "loaded", RID_SVXSTR_EVENT_LOADED ); - aDisplayNames.emplace_back( "reloading", RID_SVXSTR_EVENT_RELOADING ); - aDisplayNames.emplace_back( "reloaded", RID_SVXSTR_EVENT_RELOADED ); - aDisplayNames.emplace_back( "unloading", RID_SVXSTR_EVENT_UNLOADING ); - aDisplayNames.emplace_back( "unloaded", RID_SVXSTR_EVENT_UNLOADED ); - aDisplayNames.emplace_back( "confirmDelete", RID_SVXSTR_EVENT_CONFIRMDELETE ); - aDisplayNames.emplace_back( "approveRowChange", RID_SVXSTR_EVENT_APPROVEROWCHANGE ); - aDisplayNames.emplace_back( "rowChanged", RID_SVXSTR_EVENT_ROWCHANGE ); - aDisplayNames.emplace_back( "approveCursorMove", RID_SVXSTR_EVENT_POSITIONING ); - aDisplayNames.emplace_back( "cursorMoved", RID_SVXSTR_EVENT_POSITIONED ); - aDisplayNames.emplace_back( "approveParameter", RID_SVXSTR_EVENT_APPROVEPARAMETER ); - aDisplayNames.emplace_back( "errorOccured", RID_SVXSTR_EVENT_ERROROCCURRED ); - aDisplayNames.emplace_back( "adjustmentValueChanged", RID_SVXSTR_EVENT_ADJUSTMENTVALUECHANGED ); + aDisplayNames.emplace_back( "approveAction", RID_CUISTR_EVENT_APPROVEACTIONPERFORMED ); + aDisplayNames.emplace_back( "actionPerformed", RID_CUISTR_EVENT_ACTIONPERFORMED ); + aDisplayNames.emplace_back( "changed", RID_CUISTR_EVENT_CHANGED ); + aDisplayNames.emplace_back( "textChanged", RID_CUISTR_EVENT_TEXTCHANGED ); + aDisplayNames.emplace_back( "itemStateChanged", RID_CUISTR_EVENT_ITEMSTATECHANGED ); + aDisplayNames.emplace_back( "focusGained", RID_CUISTR_EVENT_FOCUSGAINED ); + aDisplayNames.emplace_back( "focusLost", RID_CUISTR_EVENT_FOCUSLOST ); + aDisplayNames.emplace_back( "keyPressed", RID_CUISTR_EVENT_KEYTYPED ); + aDisplayNames.emplace_back( "keyReleased", RID_CUISTR_EVENT_KEYUP ); + aDisplayNames.emplace_back( "mouseEntered", RID_CUISTR_EVENT_MOUSEENTERED ); + aDisplayNames.emplace_back( "mouseDragged", RID_CUISTR_EVENT_MOUSEDRAGGED ); + aDisplayNames.emplace_back( "mouseMoved", RID_CUISTR_EVENT_MOUSEMOVED ); + aDisplayNames.emplace_back( "mousePressed", RID_CUISTR_EVENT_MOUSEPRESSED ); + aDisplayNames.emplace_back( "mouseReleased", RID_CUISTR_EVENT_MOUSERELEASED ); + aDisplayNames.emplace_back( "mouseExited", RID_CUISTR_EVENT_MOUSEEXITED ); + aDisplayNames.emplace_back( "approveReset", RID_CUISTR_EVENT_APPROVERESETTED ); + aDisplayNames.emplace_back( "resetted", RID_CUISTR_EVENT_RESETTED ); + aDisplayNames.emplace_back( "approveSubmit", RID_CUISTR_EVENT_SUBMITTED ); + aDisplayNames.emplace_back( "approveUpdate", RID_CUISTR_EVENT_BEFOREUPDATE ); + aDisplayNames.emplace_back( "updated", RID_CUISTR_EVENT_AFTERUPDATE ); + aDisplayNames.emplace_back( "loaded", RID_CUISTR_EVENT_LOADED ); + aDisplayNames.emplace_back( "reloading", RID_CUISTR_EVENT_RELOADING ); + aDisplayNames.emplace_back( "reloaded", RID_CUISTR_EVENT_RELOADED ); + aDisplayNames.emplace_back( "unloading", RID_CUISTR_EVENT_UNLOADING ); + aDisplayNames.emplace_back( "unloaded", RID_CUISTR_EVENT_UNLOADED ); + aDisplayNames.emplace_back( "confirmDelete", RID_CUISTR_EVENT_CONFIRMDELETE ); + aDisplayNames.emplace_back( "approveRowChange", RID_CUISTR_EVENT_APPROVEROWCHANGE ); + aDisplayNames.emplace_back( "rowChanged", RID_CUISTR_EVENT_ROWCHANGE ); + aDisplayNames.emplace_back( "approveCursorMove", RID_CUISTR_EVENT_POSITIONING ); + aDisplayNames.emplace_back( "cursorMoved", RID_CUISTR_EVENT_POSITIONED ); + aDisplayNames.emplace_back( "approveParameter", RID_CUISTR_EVENT_APPROVEPARAMETER ); + aDisplayNames.emplace_back( "errorOccured", RID_CUISTR_EVENT_ERROROCCURRED ); + aDisplayNames.emplace_back( "adjustmentValueChanged", RID_CUISTR_EVENT_ADJUSTMENTVALUECHANGED ); } // the following method is called when the user clicks OK @@ -269,32 +272,31 @@ bool SvxMacroTabPage_::IsReadOnly() const namespace { - OUString GetEventDisplayText(const OUString &rURL) + std::u16string_view GetEventDisplayText(std::u16string_view rURL) { - if (rURL.isEmpty()) - return OUString(); - sal_Int32 nIndex = rURL.indexOf(aVndSunStarUNO); - bool bUNO = nIndex == 0; - OUString aPureMethod; + if (rURL.empty()) + return std::u16string_view(); + bool bUNO = o3tl::starts_with(rURL, aVndSunStarUNO); + std::u16string_view aPureMethod; if (bUNO) { - aPureMethod = rURL.copy(aVndSunStarUNO.getLength()); + aPureMethod = rURL.substr(aVndSunStarUNO.getLength()); } else { - aPureMethod = rURL.copy(strlen("vnd.sun.star.script:")); - aPureMethod = aPureMethod.copy( 0, aPureMethod.indexOf( '?' ) ); + aPureMethod = rURL.substr(strlen("vnd.sun.star.script:")); + aPureMethod = aPureMethod.substr( 0, aPureMethod.find( '?' ) ); } return aPureMethod; } - OUString GetEventDisplayImage(const OUString &rURL) + OUString GetEventDisplayImage(std::u16string_view rURL) { - if (rURL.isEmpty()) + if (rURL.empty()) return OUString(); - sal_Int32 nIndex = rURL.indexOf(aVndSunStarUNO); + size_t nIndex = rURL.find(aVndSunStarUNO); bool bUNO = nIndex == 0; - return bUNO ? OUString(RID_SVXBMP_COMPONENT) : OUString(RID_SVXBMP_MACRO); + return bUNO ? RID_SVXBMP_COMPONENT : RID_SVXBMP_MACRO; } } @@ -305,6 +307,7 @@ void SvxMacroTabPage_::DisplayAppEvents( bool appEvents) mpImpl->xEventLB->freeze(); mpImpl->xEventLB->clear(); + m_nAssignedEvents = 0; EventsHash* eventsHash; Reference< container::XNameReplace> nameReplace; if(bAppEvents) @@ -344,7 +347,10 @@ void SvxMacroTabPage_::DisplayAppEvents( bool appEvents) int nRow = mpImpl->xEventLB->n_children(); mpImpl->xEventLB->append(sEventName, displayName); mpImpl->xEventLB->set_image(nRow, GetEventDisplayImage(eventURL), 1); - mpImpl->xEventLB->set_text(nRow, GetEventDisplayText(eventURL), 2); + mpImpl->xEventLB->set_text(nRow, OUString(GetEventDisplayText(eventURL)), 2); + + if (!eventURL.isEmpty()) + ++m_nAssignedEvents; } mpImpl->xEventLB->thaw(); @@ -374,20 +380,37 @@ IMPL_LINK_NOARG( SvxMacroTabPage_, SelectEvent_Impl, weld::TreeView&, void) IMPL_LINK( SvxMacroTabPage_, AssignDeleteHdl_Impl, weld::Button&, rBtn, void ) { - GenericHandler_Impl(this, &rBtn); + GenericHandler_Impl(&rBtn); } IMPL_LINK_NOARG( SvxMacroTabPage_, DoubleClickHdl_Impl, weld::TreeView&, bool) { - GenericHandler_Impl(this, nullptr); + GenericHandler_Impl(nullptr); return true; } +const EventPair* SvxMacroTabPage_::LookupEvent(const OUString& rEventName) +{ + const EventPair* pRet = nullptr; + if (bAppEvents) + { + EventsHash::iterator h_it = m_appEventsHash.find(rEventName); + if (h_it != m_appEventsHash.end() ) + pRet = &h_it->second; + } + else + { + EventsHash::iterator h_it = m_docEventsHash.find(rEventName); + if (h_it != m_docEventsHash.end() ) + pRet = &h_it->second; + } + return pRet; +} + // handler for double click on the listbox, and for the assign/delete buttons -void SvxMacroTabPage_::GenericHandler_Impl(SvxMacroTabPage_* pThis, const weld::Button* pBtn) +void SvxMacroTabPage_::GenericHandler_Impl(const weld::Button* pBtn) { - SvxMacroTabPage_Impl* pImpl = pThis->mpImpl.get(); - weld::TreeView& rListBox = *pImpl->xEventLB; + weld::TreeView& rListBox = *mpImpl->xEventLB; int nEntry = rListBox.get_selected_index(); if (nEntry == -1) { @@ -395,95 +418,125 @@ void SvxMacroTabPage_::GenericHandler_Impl(SvxMacroTabPage_* pThis, const weld:: return; } - const bool bAssEnabled = pBtn != pImpl->xDeletePB.get() && pImpl->xAssignPB->get_sensitive(); + const bool bAssEnabled = pBtn != mpImpl->xDeletePB.get() && mpImpl->xAssignPB->get_sensitive(); OUString sEventName = rListBox.get_id(nEntry); OUString sEventURL; OUString sEventType; - if(pThis->bAppEvents) - { - EventsHash::iterator h_it = pThis->m_appEventsHash.find(sEventName); - if(h_it != pThis->m_appEventsHash.end() ) - { - sEventType = h_it->second.first; - sEventURL = h_it->second.second; - } - } - else + if (const EventPair* pEventPair = LookupEvent(sEventName)) { - EventsHash::iterator h_it = pThis->m_docEventsHash.find(sEventName); - if(h_it != pThis->m_docEventsHash.end() ) - { - sEventType = h_it->second.first; - sEventURL = h_it->second.second; - } + sEventType = pEventPair->first; + sEventURL = pEventPair->second; } + if (!sEventURL.isEmpty()) + --m_nAssignedEvents; + bool bDoubleClick = (pBtn == nullptr); bool bUNOAssigned = sEventURL.startsWith( aVndSunStarUNO ); - if( pBtn == pImpl->xDeletePB.get() ) + if (pBtn == mpImpl->xDeletePB.get()) { // delete pressed sEventType = "Script" ; sEventURL.clear(); - if(!pThis->bAppEvents) - pThis->bDocModified = true; + if (!bAppEvents) + bDocModified = true; } else if ( ( ( pBtn != nullptr ) - && ( pBtn == pImpl->xAssignComponentPB.get() ) + && ( pBtn == mpImpl->xAssignComponentPB.get() ) ) || ( bDoubleClick && bUNOAssigned ) ) { - AssignComponentDialog aAssignDlg(pThis->GetFrameWeld(), sEventURL); + AssignComponentDialog aAssignDlg(GetFrameWeld(), sEventURL); short ret = aAssignDlg.run(); if( ret ) { sEventType = "UNO"; sEventURL = aAssignDlg.getURL(); - if(!pThis->bAppEvents) - pThis->bDocModified = true; + if (!bAppEvents) + bDocModified = true; } } else if( bAssEnabled ) { // assign pressed - SvxScriptSelectorDialog aDlg(pThis->GetFrameWeld(), pThis->GetFrame()); + SvxScriptSelectorDialog aDlg(GetFrameWeld(), GetFrame()); short ret = aDlg.run(); if ( ret ) { sEventType = "Script"; sEventURL = aDlg.GetScriptURL(); - if(!pThis->bAppEvents) - pThis->bDocModified = true; + if (!bAppEvents) + bDocModified = true; } } // update the hashes - if(pThis->bAppEvents) + if (bAppEvents) { - EventsHash::iterator h_it = pThis->m_appEventsHash.find(sEventName); + EventsHash::iterator h_it = m_appEventsHash.find(sEventName); h_it->second.first = sEventType; h_it->second.second = sEventURL; } else { - EventsHash::iterator h_it = pThis->m_docEventsHash.find(sEventName); + EventsHash::iterator h_it = m_docEventsHash.find(sEventName); h_it->second.first = sEventType; h_it->second.second = sEventURL; } + if (!sEventURL.isEmpty()) + ++m_nAssignedEvents; + rListBox.set_image(nEntry, GetEventDisplayImage(sEventURL), 1); - rListBox.set_text(nEntry, GetEventDisplayText(sEventURL), 2); + rListBox.set_text(nEntry, OUString(GetEventDisplayText(sEventURL)), 2); rListBox.select(nEntry ); rListBox.scroll_to_row(nEntry); - pThis->EnableButtons(); + EnableButtons(); +} + +IMPL_LINK_NOARG(SvxMacroTabPage_, DeleteAllHdl_Impl, weld::Button&, void) +{ + OUString sEventType = "Script" ; + OUString sEmptyString; + + mpImpl->xEventLB->all_foreach([this, &sEventType, &sEmptyString](weld::TreeIter& rEntry) { + weld::TreeView& rListBox = *mpImpl->xEventLB; + OUString sEventName = rListBox.get_id(rEntry); + // update the hashes + if (bAppEvents) + { + EventsHash::iterator h_it = m_appEventsHash.find(sEventName); + assert(h_it != m_appEventsHash.end()); + h_it->second.first = sEventType; + h_it->second.second = sEmptyString; + } + else + { + EventsHash::iterator h_it = m_docEventsHash.find(sEventName); + assert(h_it != m_docEventsHash.end()); + h_it->second.first = sEventType; + h_it->second.second = sEmptyString; + } + + rListBox.set_image(rEntry, sEmptyString, 1); + rListBox.set_text(rEntry, sEmptyString, 2); + return false; + }); + + if (!bAppEvents) + bDocModified = true; + + m_nAssignedEvents = 0; + + EnableButtons(); } // pass in the XNameReplace. @@ -496,6 +549,7 @@ void SvxMacroTabPage_::InitAndSetHandler( const Reference< container::XNameRepla Link<weld::Button&,void> aLnk(LINK(this, SvxMacroTabPage_, AssignDeleteHdl_Impl )); mpImpl->xDeletePB->connect_clicked(aLnk); mpImpl->xAssignPB->connect_clicked(aLnk); + mpImpl->xDeleteAllPB->connect_clicked(LINK(this, SvxMacroTabPage_, DeleteAllHdl_Impl)); if( mpImpl->xAssignComponentPB ) mpImpl->xAssignComponentPB->connect_clicked( aLnk ); mpImpl->xEventLB->connect_row_activated( LINK(this, SvxMacroTabPage_, DoubleClickHdl_Impl ) ); @@ -548,7 +602,7 @@ void SvxMacroTabPage_::InitAndSetHandler( const Reference< container::XNameRepla // returns the two props EventType & Script for a given event name Any SvxMacroTabPage_::GetPropsByName( const OUString& eventName, EventsHash& eventsHash ) { - const std::pair< OUString, OUString >& rAssignedEvent( eventsHash[ eventName ] ); + const EventPair& rAssignedEvent(eventsHash[eventName]); Any aReturn; ::comphelper::NamedValueCollection aProps; @@ -564,7 +618,7 @@ Any SvxMacroTabPage_::GetPropsByName( const OUString& eventName, EventsHash& eve // converts the Any returned by GetByName into a pair which can be stored in // the EventHash -std::pair< OUString, OUString > SvxMacroTabPage_::GetPairFromAny( const Any& aAny ) +EventPair SvxMacroTabPage_::GetPairFromAny( const Any& aAny ) { Sequence< beans::PropertyValue > props; OUString type, url; @@ -589,6 +643,7 @@ SvxMacroTabPage::SvxMacroTabPage(weld::Container* pPage, weld::DialogController* mpImpl->xEventLB->get_height_rows(9)); mpImpl->xAssignPB = m_xBuilder->weld_button("assign"); mpImpl->xDeletePB = m_xBuilder->weld_button("delete"); + mpImpl->xDeleteAllPB = m_xBuilder->weld_button("deleteall"); mpImpl->xAssignComponentPB = m_xBuilder->weld_button("component"); SetFrame( _rxDocumentFrame ); @@ -625,9 +680,9 @@ IMPL_LINK_NOARG(AssignComponentDialog, ButtonHandler, weld::Button&, void) m_xDialog->response(RET_OK); } -AssignComponentDialog::AssignComponentDialog(weld::Window* pParent, const OUString& rURL) +AssignComponentDialog::AssignComponentDialog(weld::Window* pParent, OUString aURL) : GenericDialogController(pParent, "cui/ui/assigncomponentdialog.ui", "AssignComponent") - , maURL( rURL ) + , maURL(std::move( aURL )) , mxMethodEdit(m_xBuilder->weld_entry("methodEntry")) , mxOKButton(m_xBuilder->weld_button("ok")) { diff --git a/cui/source/customize/macropg_impl.hxx b/cui/source/customize/macropg_impl.hxx index 2a36d0f5cada..1073e4bb36ff 100644 --- a/cui/source/customize/macropg_impl.hxx +++ b/cui/source/customize/macropg_impl.hxx @@ -30,6 +30,7 @@ public: std::unique_ptr<weld::Button> xAssignPB; std::unique_ptr<weld::Button> xAssignComponentPB; std::unique_ptr<weld::Button> xDeletePB; + std::unique_ptr<weld::Button> xDeleteAllPB; std::unique_ptr<weld::TreeView> xEventLB; bool bReadOnly; bool bIDEDialogMode; @@ -46,7 +47,7 @@ private: DECL_LINK(ButtonHandler, weld::Button&, void); public: - AssignComponentDialog(weld::Window* pParent, const OUString& rURL); + AssignComponentDialog(weld::Window* pParent, OUString aURL); virtual ~AssignComponentDialog() override; const OUString& getURL() const { return maURL; } diff --git a/cui/source/dialogs/AdditionsDialog.cxx b/cui/source/dialogs/AdditionsDialog.cxx index ec173740bc63..4d39ad937664 100644 --- a/cui/source/dialogs/AdditionsDialog.cxx +++ b/cui/source/dialogs/AdditionsDialog.cxx @@ -12,7 +12,6 @@ #include <algorithm> #include <cmath> -#include <string_view> #include <config_folders.h> @@ -30,7 +29,7 @@ #include <rtl/bootstrap.hxx> #include <tools/urlobj.hxx> #include <tools/stream.hxx> -#include <tools/diagnose_ex.h> +#include <comphelper/diagnose_ex.hxx> #include <comphelper/processfactory.hxx> #include <vcl/virdev.hxx> #include <vcl/svapp.hxx> @@ -55,18 +54,14 @@ #include <orcus/json_parser.hpp> #include <orcus/config.hpp> +#include <bitmaps.hlst> + #define PAGE_SIZE 30 using namespace css; using ::com::sun::star::uno::Reference; -using ::com::sun::star::uno::XComponentContext; -using ::com::sun::star::uno::UNO_QUERY_THROW; using ::com::sun::star::uno::Exception; -using ::com::sun::star::graphic::GraphicProvider; -using ::com::sun::star::graphic::XGraphicProvider; using ::com::sun::star::uno::Sequence; -using ::com::sun::star::beans::PropertyValue; -using ::com::sun::star::graphic::XGraphic; using namespace com::sun::star; using namespace ::com::sun::star::uno; @@ -135,7 +130,7 @@ void parseResponse(const std::string& rResponse, std::vector<AdditionInfo>& aAdd { aJsonDoc.load(rResponse, aConfig); } - catch (const orcus::json::parse_error&) + catch (const orcus::parse_error&) { TOOLS_WARN_EXCEPTION("cui.dialogs", "Invalid JSON file from the extensions API"); return; @@ -230,7 +225,7 @@ bool getPreviewFile(const AdditionInfo& aAdditionInfo, OUString& sPreviewFile) return true; } -void LoadImage(const OUString& rPreviewFile, std::shared_ptr<AdditionsItem> pCurrentItem) +void LoadImage(std::u16string_view rPreviewFile, std::shared_ptr<AdditionsItem> pCurrentItem) { const sal_Int8 Margin = 6; @@ -280,6 +275,11 @@ SearchAndParseThread::SearchAndParseThread(AdditionsDialog* pDialog, const bool , m_bExecute(true) , m_bIsFirstLoading(isFirstLoading) { + // if we are running a UITest, e.g. UITest_sw_options then + // don't attempt to downloading anything + static const bool bUITest = getenv("LIBO_TEST_UNIT"); + + m_bUITest = bUITest; } SearchAndParseThread::~SearchAndParseThread() {} @@ -289,7 +289,8 @@ void SearchAndParseThread::Append(AdditionInfo& additionInfo) if (!m_bExecute) return; OUString aPreviewFile; - bool bResult = getPreviewFile(additionInfo, aPreviewFile); // info vector json data + bool bResult + = !m_bUITest && getPreviewFile(additionInfo, aPreviewFile); // info vector json data if (!bResult) { @@ -382,7 +383,7 @@ void SearchAndParseThread::CheckInstalledExtensions() SolarMutexGuard aGuard; rInfo->m_xButtonInstall->set_sensitive(false); rInfo->m_xButtonInstall->set_label( - CuiResId(RID_SVXSTR_ADDITIONS_INSTALLEDBUTTON)); + CuiResId(RID_CUISTR_ADDITIONS_INSTALLEDBUTTON)); } } } @@ -394,16 +395,16 @@ void SearchAndParseThread::execute() { OUString sProgress; if (m_bIsFirstLoading) - sProgress = CuiResId(RID_SVXSTR_ADDITIONS_LOADING); + sProgress = CuiResId(RID_CUISTR_ADDITIONS_LOADING); else - sProgress = CuiResId(RID_SVXSTR_ADDITIONS_SEARCHING); + sProgress = CuiResId(RID_CUISTR_ADDITIONS_SEARCHING); m_pAdditionsDialog->SetProgress( sProgress); // Loading or searching according to being first call or not if (m_bIsFirstLoading) { - std::string sResponse = ucbGet(m_pAdditionsDialog->m_sURL); + std::string sResponse = !m_bUITest ? ucbGet(m_pAdditionsDialog->m_sURL) : ""; parseResponse(sResponse, m_pAdditionsDialog->m_aAllExtensionsVector); std::sort(m_pAdditionsDialog->m_aAllExtensionsVector.begin(), m_pAdditionsDialog->m_aAllExtensionsVector.end(), @@ -428,7 +429,6 @@ AdditionsDialog::AdditionsDialog(weld::Window* pParent, const OUString& sAdditio , m_aSearchDataTimer("AdditionsDialog SearchDataTimer") , m_xEntrySearch(m_xBuilder->weld_entry("entrySearch")) , m_xButtonClose(m_xBuilder->weld_button("buttonClose")) - , m_xMenuButtonSettings(m_xBuilder->weld_menu_button("buttonGear")) , m_xContentWindow(m_xBuilder->weld_scrolled_window("contentWindow")) , m_xContentGrid(m_xBuilder->weld_container("contentGrid")) , m_xLabelProgress(m_xBuilder->weld_label("labelProgress")) @@ -448,19 +448,43 @@ AdditionsDialog::AdditionsDialog(weld::Window* pParent, const OUString& sAdditio m_nMaxItemCount = PAGE_SIZE; // Dialog initialization item count m_nCurrentListItemCount = 0; // First, there is no item on the list. - OUString titlePrefix = CuiResId(RID_SVXSTR_ADDITIONS_DIALOG_TITLE_PREFIX); + OUString titlePrefix = CuiResId(RID_CUISTR_ADDITIONS_DIALOG_TITLE_PREFIX); if (!m_sTag.isEmpty()) - { - this->set_title(titlePrefix + ": " + sAdditionsTag); + { // tdf#142564 localize extension category names + OUString sDialogTitle = ""; + if (sAdditionsTag == "Templates") + { + sDialogTitle = CuiResId(RID_CUISTR_ADDITIONS_TEMPLATES); + } + else if (sAdditionsTag == "Dictionary") + { + sDialogTitle = CuiResId(RID_CUISTR_ADDITIONS_DICTIONARY); + } + else if (sAdditionsTag == "Gallery") + { + sDialogTitle = CuiResId(RID_CUISTR_ADDITIONS_GALLERY); + } + else if (sAdditionsTag == "Icons") + { + sDialogTitle = CuiResId(RID_CUISTR_ADDITIONS_ICONS); + } + else if (sAdditionsTag == "Color Palette") + { + sDialogTitle = CuiResId(RID_CUISTR_ADDITIONS_PALETTES); + } + this->set_title(sDialogTitle); } else { this->set_title(titlePrefix); m_sTag = "allextensions"; // Means empty parameter } + + OUString sEncodedURLPart = INetURLObject::encode(m_sTag, INetURLObject::PART_PCHAR, + INetURLObject::EncodeMechanism::All); + //FIXME: Temporary URL - v0 is not using actual api - OUString rURL = "https://extensions.libreoffice.org/api/v0/" + m_sTag + ".json"; - m_sURL = rURL; + m_sURL = "https://extensions.libreoffice.org/api/v0/" + sEncodedURLPart + ".json"; m_xExtensionManager = deployment::ExtensionManager::get(::comphelper::getProcessComponentContext()); @@ -580,19 +604,15 @@ AdditionsItem::AdditionsItem(weld::Widget* pParent, AdditionsDialog* pParentDial , m_xLinkButtonWebsite(m_xBuilder->weld_link_button("btnWebsite")) , m_xLabelName(m_xBuilder->weld_label("lbName")) , m_xLabelAuthor(m_xBuilder->weld_label("labelAuthor")) - , m_xLabelDesc(m_xBuilder->weld_label("labelDesc")) // no change (print description) , m_xLabelDescription(m_xBuilder->weld_label("labelDescription")) , m_xLabelLicense(m_xBuilder->weld_label("lbLicenseText")) , m_xLabelVersion(m_xBuilder->weld_label("lbVersionText")) - , m_xLabelComments(m_xBuilder->weld_label("labelComments")) // no change , m_xLinkButtonComments(m_xBuilder->weld_link_button("linkButtonComments")) , m_xImageVoting1(m_xBuilder->weld_image("imageVoting1")) , m_xImageVoting2(m_xBuilder->weld_image("imageVoting2")) , m_xImageVoting3(m_xBuilder->weld_image("imageVoting3")) , m_xImageVoting4(m_xBuilder->weld_image("imageVoting4")) , m_xImageVoting5(m_xBuilder->weld_image("imageVoting5")) - , m_xLabelNoVoting(m_xBuilder->weld_label("votingLabel")) - , m_xImageDownloadNumber(m_xBuilder->weld_image("imageDownloadNumber")) , m_xLabelDownloadNumber(m_xBuilder->weld_label("labelDownloadNumber")) , m_xButtonShowMore(m_xBuilder->weld_button("buttonShowMore")) , m_pParentDialog(pParentDialog) @@ -611,8 +631,8 @@ AdditionsItem::AdditionsItem(weld::Widget* pParent, AdditionsDialog* pParentDial if (additionInfo.sName.getLength() > maxExtensionNameLength) { - OUString sShortName = additionInfo.sName.copy(0, maxExtensionNameLength - 3); - sExtensionName = sShortName + "..."; + std::u16string_view sShortName = additionInfo.sName.subView(0, maxExtensionNameLength - 3); + sExtensionName = OUString::Concat(sShortName) + "..."; } else { @@ -625,19 +645,19 @@ AdditionsItem::AdditionsItem(weld::Widget* pParent, AdditionsDialog* pParentDial switch (std::isnan(aExtensionRating) ? 0 : int(std::clamp(aExtensionRating, 0.0, 5.0))) { case 5: - m_xImageVoting5->set_from_icon_name("cmd/sc_stars-full.png"); + m_xImageVoting5->set_from_icon_name(RID_SVXBMP_STARS_FULL); [[fallthrough]]; case 4: - m_xImageVoting4->set_from_icon_name("cmd/sc_stars-full.png"); + m_xImageVoting4->set_from_icon_name(RID_SVXBMP_STARS_FULL); [[fallthrough]]; case 3: - m_xImageVoting3->set_from_icon_name("cmd/sc_stars-full.png"); + m_xImageVoting3->set_from_icon_name(RID_SVXBMP_STARS_FULL); [[fallthrough]]; case 2: - m_xImageVoting2->set_from_icon_name("cmd/sc_stars-full.png"); + m_xImageVoting2->set_from_icon_name(RID_SVXBMP_STARS_FULL); [[fallthrough]]; case 1: - m_xImageVoting1->set_from_icon_name("cmd/sc_stars-full.png"); + m_xImageVoting1->set_from_icon_name(RID_SVXBMP_STARS_FULL); break; } @@ -647,7 +667,7 @@ AdditionsItem::AdditionsItem(weld::Widget* pParent, AdditionsDialog* pParentDial if (!additionInfo.sAuthorName.equalsIgnoreAsciiCase("null")) m_xLabelAuthor->set_label(additionInfo.sAuthorName); - m_xButtonInstall->set_label(CuiResId(RID_SVXSTR_ADDITIONS_INSTALLBUTTON)); + m_xButtonInstall->set_label(CuiResId(RID_CUISTR_ADDITIONS_INSTALLBUTTON)); m_xLabelLicense->set_label(additionInfo.sLicense); m_xLabelVersion->set_label(">=" + additionInfo.sCompatibleVersion); m_xLinkButtonComments->set_label(additionInfo.sCommentNumber); @@ -725,14 +745,14 @@ IMPL_LINK_NOARG(AdditionsItem, ShowMoreHdl, weld::Button&, void) IMPL_LINK_NOARG(AdditionsItem, InstallHdl, weld::Button&, void) { - m_xButtonInstall->set_label(CuiResId(RID_SVXSTR_ADDITIONS_INSTALLING)); + m_xButtonInstall->set_label(CuiResId(RID_CUISTR_ADDITIONS_INSTALLING)); m_xButtonInstall->set_sensitive(false); OUString aExtensionFile; bool bResult = getExtensionFile(aExtensionFile); // info vector json data if (!bResult) { - m_xButtonInstall->set_label(CuiResId(RID_SVXSTR_ADDITIONS_INSTALLBUTTON)); + m_xButtonInstall->set_label(CuiResId(RID_CUISTR_ADDITIONS_INSTALLBUTTON)); m_xButtonInstall->set_sensitive(true); SAL_INFO("cui.dialogs", "Couldn't get the extension file."); @@ -745,36 +765,36 @@ IMPL_LINK_NOARG(AdditionsItem, InstallHdl, weld::Button&, void) { m_pParentDialog->m_xExtensionManager->addExtension( aExtensionFile, uno::Sequence<beans::NamedValue>(), "user", xAbortChannel, pCmdEnv); - m_xButtonInstall->set_label(CuiResId(RID_SVXSTR_ADDITIONS_INSTALLEDBUTTON)); + m_xButtonInstall->set_label(CuiResId(RID_CUISTR_ADDITIONS_INSTALLEDBUTTON)); } catch (const ucb::CommandFailedException) { TOOLS_WARN_EXCEPTION("cui.dialogs", ""); - m_xButtonInstall->set_label(CuiResId(RID_SVXSTR_ADDITIONS_INSTALLBUTTON)); + m_xButtonInstall->set_label(CuiResId(RID_CUISTR_ADDITIONS_INSTALLBUTTON)); m_xButtonInstall->set_sensitive(true); } catch (const ucb::CommandAbortedException) { TOOLS_WARN_EXCEPTION("cui.dialogs", ""); - m_xButtonInstall->set_label(CuiResId(RID_SVXSTR_ADDITIONS_INSTALLBUTTON)); + m_xButtonInstall->set_label(CuiResId(RID_CUISTR_ADDITIONS_INSTALLBUTTON)); m_xButtonInstall->set_sensitive(true); } catch (const deployment::DeploymentException) { TOOLS_WARN_EXCEPTION("cui.dialogs", ""); - m_xButtonInstall->set_label(CuiResId(RID_SVXSTR_ADDITIONS_INSTALLBUTTON)); + m_xButtonInstall->set_label(CuiResId(RID_CUISTR_ADDITIONS_INSTALLBUTTON)); m_xButtonInstall->set_sensitive(true); } catch (const lang::IllegalArgumentException) { TOOLS_WARN_EXCEPTION("cui.dialogs", ""); - m_xButtonInstall->set_label(CuiResId(RID_SVXSTR_ADDITIONS_INSTALLBUTTON)); + m_xButtonInstall->set_label(CuiResId(RID_CUISTR_ADDITIONS_INSTALLBUTTON)); m_xButtonInstall->set_sensitive(true); } catch (const css::uno::Exception) { TOOLS_WARN_EXCEPTION("cui.dialogs", ""); - m_xButtonInstall->set_label(CuiResId(RID_SVXSTR_ADDITIONS_INSTALLBUTTON)); + m_xButtonInstall->set_label(CuiResId(RID_CUISTR_ADDITIONS_INSTALLBUTTON)); m_xButtonInstall->set_sensitive(true); } } @@ -827,7 +847,7 @@ void TmpRepositoryCommandEnv::update(uno::Any const& /*Status */) {} void TmpRepositoryCommandEnv::pop() {} -IMPL_LINK(AdditionsDialog, GearHdl, const OString&, rIdent, void) +IMPL_LINK(AdditionsDialog, GearHdl, const OUString&, rIdent, void) { if (rIdent == "gear_sort_voting") { diff --git a/cui/source/dialogs/DiagramDialog.cxx b/cui/source/dialogs/DiagramDialog.cxx index 97ae0ca3d80d..b63d6cb6e313 100644 --- a/cui/source/dialogs/DiagramDialog.cxx +++ b/cui/source/dialogs/DiagramDialog.cxx @@ -10,20 +10,24 @@ #include <DiagramDialog.hxx> #include <comphelper/dispatchcommand.hxx> -#include <svx/DiagramDataInterface.hxx> +#include <svx/svdogrp.hxx> +#include <svx/svdmodel.hxx> +#include <svx/svdundo.hxx> #include <com/sun/star/beans/PropertyValue.hpp> +#include <svx/diagram/datamodel.hxx> +#include <svx/diagram/IDiagramHelper.hxx> -DiagramDialog::DiagramDialog(weld::Window* pWindow, - std::shared_ptr<DiagramDataInterface> pDiagramData) +DiagramDialog::DiagramDialog(weld::Window* pWindow, SdrObjGroup& rDiagram) : GenericDialogController(pWindow, "cui/ui/diagramdialog.ui", "DiagramDialog") - , mpDiagramData(pDiagramData) - , mpBtnOk(m_xBuilder->weld_button("btnOk")) + , m_rDiagram(rDiagram) + , m_nUndos(0) , mpBtnCancel(m_xBuilder->weld_button("btnCancel")) , mpBtnAdd(m_xBuilder->weld_button("btnAdd")) , mpBtnRemove(m_xBuilder->weld_button("btnRemove")) , mpTreeDiagram(m_xBuilder->weld_tree_view("treeDiagram")) , mpTextAdd(m_xBuilder->weld_text_view("textAdd")) { + mpBtnCancel->connect_clicked(LINK(this, DiagramDialog, OnAddCancel)); mpBtnAdd->connect_clicked(LINK(this, DiagramDialog, OnAddClick)); mpBtnRemove->connect_clicked(LINK(this, DiagramDialog, OnRemoveClick)); @@ -37,12 +41,51 @@ DiagramDialog::DiagramDialog(weld::Window* pWindow, }); } +IMPL_LINK_NOARG(DiagramDialog, OnAddCancel, weld::Button&, void) +{ + // If the user cancels the dialog, undo all changes done so far. It may + // even be feasible to then delete the redo-stack, since it stays + // available (?) - but it does no harm either... + while (0 != m_nUndos) + { + comphelper::dispatchCommand(".uno:Undo", {}); + m_nUndos--; + } + + m_xDialog->response(RET_CANCEL); +} + IMPL_LINK_NOARG(DiagramDialog, OnAddClick, weld::Button&, void) { + if (!m_rDiagram.isDiagram()) + return; + OUString sText = mpTextAdd->get_text(); - if (!sText.isEmpty()) + const std::shared_ptr< svx::diagram::IDiagramHelper >& pDiagramHelper(m_rDiagram.getDiagramHelper()); + + if (pDiagramHelper && !sText.isEmpty()) { - OUString sNodeId = mpDiagramData->addNode(sText); + SdrModel& rDrawModel(m_rDiagram.getSdrModelFromSdrObject()); + const bool bUndo(rDrawModel.IsUndoEnabled()); + svx::diagram::DiagramDataStatePtr aStartState; + + if (bUndo) + { + // rescue all start state Diagram-defining data + aStartState = pDiagramHelper->extractDiagramDataState(); + } + + OUString sNodeId = pDiagramHelper->addNode(sText); + + if (bUndo) + { + // create undo action. That will internally secure the + // current Diagram-defining data as end state + rDrawModel.AddUndo( + rDrawModel.GetSdrUndoFactory().CreateUndoDiagramModelData(m_rDiagram, aStartState)); + m_nUndos++; + } + std::unique_ptr<weld::TreeIter> pEntry(mpTreeDiagram->make_iterator()); mpTreeDiagram->insert(nullptr, -1, &sText, &sNodeId, nullptr, nullptr, false, pEntry.get()); mpTreeDiagram->select(*pEntry); @@ -52,11 +95,35 @@ IMPL_LINK_NOARG(DiagramDialog, OnAddClick, weld::Button&, void) IMPL_LINK_NOARG(DiagramDialog, OnRemoveClick, weld::Button&, void) { + if (!m_rDiagram.isDiagram()) + return; + std::unique_ptr<weld::TreeIter> pEntry(mpTreeDiagram->make_iterator()); - if (mpTreeDiagram->get_selected(pEntry.get())) + const std::shared_ptr< svx::diagram::IDiagramHelper >& pDiagramHelper(m_rDiagram.getDiagramHelper()); + + if (pDiagramHelper && mpTreeDiagram->get_selected(pEntry.get())) { - if (mpDiagramData->removeNode(mpTreeDiagram->get_id(*pEntry))) + SdrModel& rDrawModel(m_rDiagram.getSdrModelFromSdrObject()); + const bool bUndo(rDrawModel.IsUndoEnabled()); + svx::diagram::DiagramDataStatePtr aStartState; + + if (bUndo) { + // rescue all start state Diagram-defining data + aStartState = pDiagramHelper->extractDiagramDataState(); + } + + if (pDiagramHelper->removeNode(mpTreeDiagram->get_id(*pEntry))) + { + if (bUndo) + { + // create undo action. That will internally secure the + // current Diagram-defining data as end state + rDrawModel.AddUndo(rDrawModel.GetSdrUndoFactory().CreateUndoDiagramModelData( + m_rDiagram, aStartState)); + m_nUndos++; + } + mpTreeDiagram->remove(*pEntry); comphelper::dispatchCommand(".uno:RegenerateDiagram", {}); } @@ -65,7 +132,15 @@ IMPL_LINK_NOARG(DiagramDialog, OnRemoveClick, weld::Button&, void) void DiagramDialog::populateTree(const weld::TreeIter* pParent, const OUString& rParentId) { - auto aItems = mpDiagramData->getChildren(rParentId); + if (!m_rDiagram.isDiagram()) + return; + + const std::shared_ptr< svx::diagram::IDiagramHelper >& pDiagramHelper(m_rDiagram.getDiagramHelper()); + + if (!pDiagramHelper) + return; + + auto aItems = pDiagramHelper->getChildren(rParentId); for (auto& aItem : aItems) { std::unique_ptr<weld::TreeIter> pEntry(mpTreeDiagram->make_iterator()); diff --git a/cui/source/dialogs/FontFeaturesDialog.cxx b/cui/source/dialogs/FontFeaturesDialog.cxx index 4735de194255..e9aba0a6e409 100644 --- a/cui/source/dialogs/FontFeaturesDialog.cxx +++ b/cui/source/dialogs/FontFeaturesDialog.cxx @@ -10,20 +10,25 @@ #include <FontFeaturesDialog.hxx> #include <rtl/ustrbuf.hxx> +#include <utility> #include <vcl/font/FeatureParser.hxx> #include <FontFeatures.hxx> -#include <svtools/colorcfg.hxx> #include <unordered_set> using namespace css; namespace cui { -FontFeaturesDialog::FontFeaturesDialog(weld::Window* pParent, OUString const& rFontName) +FontFeaturesDialog::FontFeaturesDialog(weld::Window* pParent, OUString aFontName) : GenericDialogController(pParent, "cui/ui/fontfeaturesdialog.ui", "FontFeaturesDialog") - , m_sFontName(rFontName) + , m_sFontName(std::move(aFontName)) , m_xContentWindow(m_xBuilder->weld_scrolled_window("contentWindow")) + , m_xContentBox(m_xBuilder->weld_container("contentBox")) , m_xContentGrid(m_xBuilder->weld_container("contentGrid")) + , m_xStylisticSetsBox(m_xBuilder->weld_container("stylisticSetsBox")) + , m_xStylisticSetsGrid(m_xBuilder->weld_container("stylisticSetsGrid")) + , m_xCharacterVariantsBox(m_xBuilder->weld_container("characterVariantsBox")) + , m_xCharacterVariantsGrid(m_xBuilder->weld_container("characterVariantsGrid")) , m_xPreviewWindow(new weld::CustomWeld(*m_xBuilder, "preview", m_aPreviewWindow)) { initialize(); @@ -50,7 +55,7 @@ static sal_Int32 makeEnumComboBox(weld::ComboBox& rNameBox, void FontFeaturesDialog::initialize() { ScopedVclPtrInstance<VirtualDevice> aVDev(*Application::GetDefaultDevice(), - DeviceFormat::DEFAULT, DeviceFormat::DEFAULT); + DeviceFormat::WITH_ALPHA); std::vector<vcl::font::Feature> rFontFeatures = getFontFeatureList(m_sFontName, *aVDev); std::unordered_set<sal_uInt32> aDoneFeatures; @@ -58,7 +63,7 @@ void FontFeaturesDialog::initialize() for (vcl::font::Feature const& rFontFeature : rFontFeatures) { - sal_uInt32 nFontFeatureCode = rFontFeature.m_aID.m_aFeatureCode; + sal_uInt32 nFontFeatureCode = rFontFeature.m_nCode; if (!aDoneFeatures.insert(nFontFeatureCode).second) continue; rFilteredFontFeatures.push_back(rFontFeature); @@ -66,9 +71,11 @@ void FontFeaturesDialog::initialize() int nRowHeight = fillGrid(rFilteredFontFeatures); + auto nFeaturesHeight = m_xContentBox->get_preferred_size().Height() + + m_xStylisticSetsBox->get_preferred_size().Height() + + m_xCharacterVariantsBox->get_preferred_size().Height(); m_xContentWindow->set_size_request( - -1, std::min(std::max(m_xContentWindow->get_preferred_size().Height(), - m_xContentGrid->get_preferred_size().Height()), + -1, std::min(std::max(m_xContentWindow->get_preferred_size().Height(), nFeaturesHeight), static_cast<tools::Long>(300L))); if (nRowHeight) @@ -87,31 +94,50 @@ int FontFeaturesDialog::fillGrid(std::vector<vcl::font::Feature> const& rFontFea vcl::font::FeatureParser aParser(m_sFontName); auto aExistingFeatures = aParser.getFeaturesMap(); - sal_Int32 i = 0; + sal_Int32 nIdx, nStylisticSets(0), nCharacterVariants(0), nOtherFeatures(0); for (vcl::font::Feature const& rFontFeature : rFontFeatures) { - sal_uInt32 nFontFeatureCode = rFontFeature.m_aID.m_aFeatureCode; + sal_uInt32 nFontFeatureCode = rFontFeature.m_nCode; vcl::font::FeatureDefinition aDefinition; if (rFontFeature.m_aDefinition) aDefinition = rFontFeature.m_aDefinition; if (!aDefinition) - aDefinition = { nFontFeatureCode, nullptr }; + aDefinition = { nFontFeatureCode, "" }; - m_aFeatureItems.emplace_back(m_xContentGrid.get()); + if (rFontFeature.isStylisticSet()) + { + nIdx = nStylisticSets++; + m_xStylisticSetsBox->set_visible(true); + m_aFeatureItems.emplace_back( + std::make_unique<FontFeatureItem>(m_xStylisticSetsGrid.get())); + } + else if (rFontFeature.isCharacterVariant()) + { + nIdx = nCharacterVariants++; + m_xCharacterVariantsBox->set_visible(true); + m_aFeatureItems.emplace_back( + std::make_unique<FontFeatureItem>(m_xCharacterVariantsGrid.get())); + } + else + { + nIdx = nOtherFeatures++; + m_xContentBox->set_visible(true); + m_aFeatureItems.emplace_back(std::make_unique<FontFeatureItem>(m_xContentGrid.get())); + } - uint32_t nValue = 0; + int32_t nValue = 0; if (aExistingFeatures.find(nFontFeatureCode) != aExistingFeatures.end()) nValue = aExistingFeatures.at(nFontFeatureCode); else nValue = aDefinition.getDefault(); - FontFeatureItem& aCurrentItem = m_aFeatureItems.back(); + FontFeatureItem& aCurrentItem = *m_aFeatureItems.back(); aCurrentItem.m_aFeatureCode = nFontFeatureCode; aCurrentItem.m_nDefault = aDefinition.getDefault(); - sal_Int32 nGridPositionX = (i % 2) * 2; - sal_Int32 nGridPositionY = i / 2; + sal_Int32 nGridPositionX = (nIdx % 2) * 2; + sal_Int32 nGridPositionY = nIdx / 2; aCurrentItem.m_xContainer->set_grid_left_attach(nGridPositionX); aCurrentItem.m_xContainer->set_grid_top_attach(nGridPositionY); @@ -133,16 +159,25 @@ int FontFeaturesDialog::fillGrid(std::vector<vcl::font::Feature> const& rFontFea } else { - aCurrentItem.m_xCheck->set_active(nValue > 0); + if (nValue < 0) + { + aCurrentItem.m_xCheck->set_state(TRISTATE_INDET); + aCurrentItem.m_aTriStateEnabled.bTriStateEnabled = true; + aCurrentItem.m_aTriStateEnabled.eState = TRISTATE_INDET; + } + else + { + aCurrentItem.m_xCheck->set_state(nValue > 0 ? TRISTATE_TRUE : TRISTATE_FALSE); + aCurrentItem.m_aTriStateEnabled.bTriStateEnabled = false; + aCurrentItem.m_aTriStateEnabled.eState = aCurrentItem.m_xCheck->get_state(); + } aCurrentItem.m_xCheck->set_label(aDefinition.getDescription()); - aCurrentItem.m_xCheck->connect_toggled(aCheckBoxToggleHandler); + aCurrentItem.m_aToggleHdl = aCheckBoxToggleHandler; aCurrentItem.m_xCheck->show(); } nRowHeight = std::max<int>(nRowHeight, aCurrentItem.m_xContainer->get_preferred_size().Height()); - - i++; } return nRowHeight; @@ -163,6 +198,13 @@ void FontFeaturesDialog::updateFontPreview() m_aPreviewWindow.SetFont(rPreviewFont, rPreviewFontCJK, rPreviewFontCTL); } +IMPL_LINK(FontFeatureItem, CheckBoxToggledHdl, weld::Toggleable&, rToggle, void) +{ + m_aTriStateEnabled.ButtonToggled(rToggle); + m_aTriStateEnabled.bTriStateEnabled = false; + m_aToggleHdl.Call(rToggle); +} + IMPL_LINK_NOARG(FontFeaturesDialog, CheckBoxToggledHdl, weld::Toggleable&, void) { updateFontPreview(); @@ -179,11 +221,12 @@ OUString FontFeaturesDialog::createFontNameWithFeatures() OUStringBuffer sNameSuffix; bool bFirst = true; - for (const FontFeatureItem& rItem : m_aFeatureItems) + for (const auto& rEntry : m_aFeatureItems) { + const FontFeatureItem& rItem(*rEntry); if (rItem.m_xCheck->get_visible()) { - if (sal_uInt32(rItem.m_xCheck->get_active()) != rItem.m_nDefault) + if (rItem.m_xCheck->get_state() != TRISTATE_INDET) { if (!bFirst) sNameSuffix.append(vcl::font::FeatureSeparator); @@ -191,7 +234,7 @@ OUString FontFeaturesDialog::createFontNameWithFeatures() bFirst = false; sNameSuffix.append(vcl::font::featureCodeAsString(rItem.m_aFeatureCode)); - if (!rItem.m_xCheck->get_active()) + if (rItem.m_xCheck->get_state() == TRISTATE_FALSE) sNameSuffix.append("=0"); } } @@ -205,16 +248,14 @@ OUString FontFeaturesDialog::createFontNameWithFeatures() else bFirst = false; - sNameSuffix.append(vcl::font::featureCodeAsString(rItem.m_aFeatureCode)); - sNameSuffix.append("="); - sNameSuffix.append(OUString::number(nSelection)); + sNameSuffix.append(vcl::font::featureCodeAsString(rItem.m_aFeatureCode) + "=" + + OUString::number(nSelection)); } } } sResultFontName = vcl::font::trimFontNameFeatures(m_sFontName); if (!sNameSuffix.isEmpty()) - sResultFontName - += OUStringChar(vcl::font::FeaturePrefix) + sNameSuffix.makeStringAndClear(); + sResultFontName += OUStringChar(vcl::font::FeaturePrefix) + sNameSuffix; return sResultFontName; } diff --git a/cui/source/dialogs/GraphicTestsDialog.cxx b/cui/source/dialogs/GraphicTestsDialog.cxx index 555ef3bd888c..ad0c25aab1f5 100644 --- a/cui/source/dialogs/GraphicTestsDialog.cxx +++ b/cui/source/dialogs/GraphicTestsDialog.cxx @@ -11,9 +11,17 @@ #include <comphelper/processfactory.hxx> #include <comphelper/DirectoryHelper.hxx> #include <osl/file.hxx> +#include <svx/FileExportedDialog.hxx> #include <unotools/ZipPackageHelper.hxx> #include <GraphicsTestsDialog.hxx> #include <vcl/test/GraphicsRenderTests.hxx> +#include <svl/svlresid.hxx> +#include <svl/svl.hrc> +#include <vcl/svapp.hxx> + +#include <dialmgr.hxx> +#include <strings.hrc> +#include <ImageViewerDialog.hxx> GraphicTestEntry::GraphicTestEntry(weld::Container* pParent, weld::Dialog* pDialog, OUString aTestName, OUString aTestStatus, Bitmap aTestBitmap) @@ -28,17 +36,18 @@ GraphicTestEntry::GraphicTestEntry(weld::Container* pParent, weld::Dialog* pDial m_xTestButton->set_label(aTestStatus); m_xTestButton->set_tooltip_text(aTestName); m_xTestButton->set_background( - aTestStatus == "PASSED" + aTestStatus == SvlResId(GRTSTR_PASSED) ? COL_LIGHTGREEN - : aTestStatus == "QUIRKY" ? COL_YELLOW - : aTestStatus == "FAILED" ? COL_LIGHTRED : COL_LIGHTGRAY); + : aTestStatus == SvlResId(GRTSTR_QUIRKY) + ? COL_YELLOW + : aTestStatus == SvlResId(GRTSTR_FAILED) ? COL_LIGHTRED : COL_LIGHTGRAY); m_xTestButton->connect_clicked(LINK(this, GraphicTestEntry, HandleResultViewRequest)); m_xContainer->show(); } IMPL_LINK(GraphicTestEntry, HandleResultViewRequest, weld::Button&, rButton, void) { - if (rButton.get_label() == "SKIPPED") + if (rButton.get_label() == SvlResId(GRTSTR_SKIPPED)) { return; } @@ -64,14 +73,14 @@ short GraphicsTestsDialog::run() { GraphicsRenderTests aTestObject; aTestObject.run(true); - OUString aResultLog = aTestObject.getResultString() - + "\n(Click on any test to view its resultant bitmap image)"; + OUString aResultLog + = aTestObject.getResultString(true) + "\n" + CuiResId(RID_CUISTR_CLICK_RESULT); m_xResultLog->set_text(aResultLog); sal_Int32 nTestNumber = 0; - for (const VclTestResult& test : aTestObject.getTestResults()) + for (VclTestResult& test : aTestObject.getTestResults()) { auto xGpTest = std::make_unique<GraphicTestEntry>(m_xContainerBox.get(), m_xDialog.get(), - test.getTestName(), test.getStatus(), + test.getTestName(), test.getStatus(true), test.getBitmap()); m_xContainerBox->reorder_child(xGpTest->get_widget(), nTestNumber++); m_xGraphicTestEntries.push_back(std::move(xGpTest)); @@ -92,13 +101,11 @@ IMPL_LINK_NOARG(GraphicsTestsDialog, HandleDownloadRequest, weld::Button&, void) { std::unique_ptr<weld::MessageDialog> xBox( Application::CreateMessageDialog(m_xDialog.get(), VclMessageType::Warning, - VclButtonsType::Ok, "Creation of Zip file failed!")); + VclButtonsType::Ok, CuiResId(RID_CUISTR_ZIPFAIL))); xBox->run(); return; } - FileExportedDialog aDialog( - m_xDialog.get(), - "The results have been successfully saved in the file 'GraphicTestResults.zip' !"); + FileExportedDialog aDialog(m_xDialog.get(), CuiResId(RID_CUISTR_SAVED)); aDialog.run(); } diff --git a/cui/source/dialogs/QrCodeGenDialog.cxx b/cui/source/dialogs/QrCodeGenDialog.cxx index fad04c944ee0..d99290404629 100644 --- a/cui/source/dialogs/QrCodeGenDialog.cxx +++ b/cui/source/dialogs/QrCodeGenDialog.cxx @@ -19,6 +19,7 @@ #include <vcl/svapp.hxx> #if ENABLE_ZXING +#include <ZXVersion.h> #include <rtl/strbuf.hxx> #ifdef __GNUC__ @@ -27,15 +28,21 @@ #endif #include <BarcodeFormat.h> -#include <BitArray.h> #include <BitMatrix.h> #include <MultiFormatWriter.h> -#include <TextUtfEncoding.h> #ifdef __GNUC__ #pragma GCC diagnostic pop #endif +#if HAVE_ZXING_TOSVG +#include <BitMatrixIO.h> +#endif + +#if ZXING_VERSION_MAJOR < 2 +#include <TextUtfEncoding.h> +#endif + #endif // ENABLE_ZXING #include <com/sun/star/beans/XPropertySet.hpp> @@ -74,12 +81,12 @@ namespace { #if ENABLE_ZXING // Implementation adapted from the answer: https://stackoverflow.com/questions/10789059/create-qr-code-in-vector-image/60638350#60638350 +#if !HAVE_ZXING_TOSVG OString ConvertToSVGFormat(const ZXing::BitMatrix& bitmatrix) { OStringBuffer sb; const int width = bitmatrix.width(); const int height = bitmatrix.height(); - ZXing::BitArray row(width); sb.append("<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n" "<svg xmlns=\"http://www.w3.org/2000/svg\" version=\"1.1\" viewBox=\"0 0 " + OString::number(width) + " " + OString::number(height) @@ -87,10 +94,9 @@ OString ConvertToSVGFormat(const ZXing::BitMatrix& bitmatrix) "<path d=\""); for (int i = 0; i < height; ++i) { - bitmatrix.getRow(i, row); for (int j = 0; j < width; ++j) { - if (row.get(j)) + if (bitmatrix.get(j, i)) { sb.append("M" + OString::number(j) + "," + OString::number(i) + "h1v1h-1z"); } @@ -99,8 +105,9 @@ OString ConvertToSVGFormat(const ZXing::BitMatrix& bitmatrix) sb.append("\"/>\n</svg>"); return sb.toString(); } +#endif -std::string GetBarCodeType(const int& type) +std::string GetBarCodeType(int type) { switch (type) { @@ -141,12 +148,20 @@ OString GenerateQRCode(std::u16string_view aQRText, tools::Long aQRECC, int aQRB } OString o = OUStringToOString(aQRText, RTL_TEXTENCODING_UTF8); - std::string QRText(o.getStr(), o.getLength()); + std::string QRText(o); ZXing::BarcodeFormat format = ZXing::BarcodeFormatFromString(GetBarCodeType(aQRType)); auto writer = ZXing::MultiFormatWriter(format).setMargin(aQRBorder).setEccLevel(bqrEcc); writer.setEncoding(ZXing::CharacterSet::UTF8); +#if ZXING_VERSION_MAJOR >= 2 + ZXing::BitMatrix bitmatrix = writer.encode(QRText, 0, 0); +#else ZXing::BitMatrix bitmatrix = writer.encode(ZXing::TextUtfEncoding::FromUtf8(QRText), 0, 0); +#endif +#if HAVE_ZXING_TOSVG + return OString(ZXing::ToSVG(bitmatrix)); +#else return ConvertToSVGFormat(bitmatrix); +#endif } #endif @@ -156,7 +171,7 @@ QrCodeGenDialog::QrCodeGenDialog(weld::Widget* pParent, Reference<XModel> xModel bool bEditExisting) : GenericDialogController(pParent, "cui/ui/qrcodegen.ui", "QrCodeGenDialog") , m_xModel(std::move(xModel)) - , m_xEdittext(m_xBuilder->weld_entry("edit_text")) + , m_xEdittext(m_xBuilder->weld_text_view("edit_text")) , m_xECC{ m_xBuilder->weld_radio_button("button_low"), m_xBuilder->weld_radio_button("button_medium"), m_xBuilder->weld_radio_button("button_quartile"), @@ -167,6 +182,8 @@ QrCodeGenDialog::QrCodeGenDialog(weld::Widget* pParent, Reference<XModel> xModel , mpParent(pParent) #endif { + m_xEdittext->set_size_request(m_xEdittext->get_approximate_digit_width() * 28, + m_xEdittext->get_height_rows(6)); if (!bEditExisting) { // TODO: This only works in Writer doc. Should also work in shapes @@ -219,7 +236,7 @@ short QrCodeGenDialog::run() { std::unique_ptr<weld::MessageDialog> xBox(Application::CreateMessageDialog( mpParent, VclMessageType::Warning, VclButtonsType::Ok, - CuiResId(RID_SVXSTR_QRCODEDATALONG))); + CuiResId(RID_CUISTR_QRCODEDATALONG))); xBox->run(); } } @@ -232,6 +249,36 @@ short QrCodeGenDialog::run() #endif } +bool QrCodeGenDialog::runAsync(const std::shared_ptr<QrCodeGenDialog>& rController, + const std::function<void(sal_Int32)>& rFunc) +{ +#if ENABLE_ZXING + + weld::GenericDialogController::runAsync(rController, [rController, rFunc](sal_Int32 nResult) { + if (nResult == RET_OK) + { + try + { + rController->Apply(); + } + catch (const std::exception&) + { + std::unique_ptr<weld::MessageDialog> xBox(Application::CreateMessageDialog( + rController->GetParent(), VclMessageType::Warning, VclButtonsType::Ok, + CuiResId(RID_CUISTR_QRCODEDATALONG))); + xBox->run(); + } + } + + rFunc(nResult); + }); +#else + (void)rController; + (void)rFunc; +#endif + return true; +} + void QrCodeGenDialog::Apply() { #if ENABLE_ZXING diff --git a/cui/source/dialogs/SignSignatureLineDialog.cxx b/cui/source/dialogs/SignSignatureLineDialog.cxx index 83d108290ade..d3e0bfb5b65e 100644 --- a/cui/source/dialogs/SignSignatureLineDialog.cxx +++ b/cui/source/dialogs/SignSignatureLineDialog.cxx @@ -33,7 +33,6 @@ #include <com/sun/star/graphic/XGraphicProvider.hpp> #include <com/sun/star/security/CertificateKind.hpp> #include <com/sun/star/security/XCertificate.hpp> -#include <com/sun/star/ui/dialogs/FilePicker.hpp> #include <com/sun/star/ui/dialogs/TemplateDescription.hpp> #include <com/sun/star/ui/dialogs/XFilePicker3.hpp> @@ -42,8 +41,6 @@ using namespace css; using namespace css::uno; using namespace css::beans; using namespace css::frame; -using namespace css::io; -using namespace css::lang; using namespace css::frame; using namespace css::text; using namespace css::graphic; @@ -148,7 +145,7 @@ IMPL_LINK_NOARG(SignSignatureLineDialog, loadImage, weld::Button&, void) IMPL_LINK_NOARG(SignSignatureLineDialog, clearImage, weld::Button&, void) { - m_xSignatureImage.set(nullptr); + m_xSignatureImage.clear(); m_xBtnLoadImage->set_label(m_sOriginalImageBtnLabel); ValidateFields(); } @@ -157,7 +154,7 @@ IMPL_LINK_NOARG(SignSignatureLineDialog, chooseCertificate, weld::Button&, void) { // Document needs to be saved before selecting a certificate SfxObjectShell* pShell = SfxObjectShell::Current(); - if (!pShell->PrepareForSigning(m_xDialog.get())) + if (!pShell || !pShell->PrepareForSigning(m_xDialog.get())) return; Reference<XCertificate> xSignCertificate @@ -194,6 +191,12 @@ void SignSignatureLineDialog::Apply() } SfxObjectShell* pShell = SfxObjectShell::Current(); + if (!pShell) + { + SAL_WARN("cui.dialogs", "No SfxObjectShell!"); + return; + } + Reference<XGraphic> xValidGraphic = getSignedGraphic(true); Reference<XGraphic> xInvalidGraphic = getSignedGraphic(false); pShell->SignSignatureLine(m_xDialog.get(), m_aSignatureLineId, m_xSelectedCertifate, @@ -208,7 +211,7 @@ css::uno::Reference<css::graphic::XGraphic> SignSignatureLineDialog::getSignedGr aSvgImage = aSvgImage.replaceAll("[SIGNER_TITLE]", getCDataString(m_aSuggestedSignerTitle)); OUString aIssuerLine - = CuiResId(RID_SVXSTR_SIGNATURELINE_SIGNED_BY) + = CuiResId(RID_CUISTR_SIGNATURELINE_SIGNED_BY) .replaceFirst("%1", svx::SignatureLineHelper::getSignerName(m_xSelectedCertifate)); aSvgImage = aSvgImage.replaceAll("[SIGNED_BY]", getCDataString(aIssuerLine)); if (bValid) diff --git a/cui/source/dialogs/SignatureLineDialogBase.cxx b/cui/source/dialogs/SignatureLineDialogBase.cxx index 4e591124bc44..fb154c34319d 100644 --- a/cui/source/dialogs/SignatureLineDialogBase.cxx +++ b/cui/source/dialogs/SignatureLineDialogBase.cxx @@ -18,7 +18,7 @@ using namespace css::uno; using namespace css::frame; SignatureLineDialogBase::SignatureLineDialogBase(weld::Widget* pParent, Reference<XModel> xModel, - const OUString& rUIFile, const OString& rDialogId) + const OUString& rUIFile, const OUString& rDialogId) : GenericDialogController(pParent, rUIFile, rDialogId) , m_xModel(std::move(xModel)) { @@ -26,10 +26,8 @@ SignatureLineDialogBase::SignatureLineDialogBase(weld::Widget* pParent, Referenc short SignatureLineDialogBase::run() { - short nRet = GenericDialogController::run(); - if (nRet == RET_OK) - Apply(); - return nRet; + assert(false && "these dialogs are async now"); + return -1; } OUString SignatureLineDialogBase::getCDataString(std::u16string_view rString) diff --git a/cui/source/dialogs/SpellAttrib.hxx b/cui/source/dialogs/SpellAttrib.hxx index d732aad69ba1..cdc0cf26661e 100644 --- a/cui/source/dialogs/SpellAttrib.hxx +++ b/cui/source/dialogs/SpellAttrib.hxx @@ -22,6 +22,7 @@ #include <com/sun/star/uno/Sequence.h> #include <com/sun/star/lang/Locale.hpp> #include <com/sun/star/linguistic2/XProofreader.hpp> +#include <utility> namespace svx{ struct SpellErrorDescription @@ -37,21 +38,21 @@ struct SpellErrorDescription OUString sRuleId; SpellErrorDescription( bool bGrammar, - const OUString& rText, - const css::lang::Locale& rLocale, + OUString aText, + css::lang::Locale _aLocale, const css::uno::Sequence< OUString >& rSuggestions, - css::uno::Reference< css::linguistic2::XProofreader > const & rxGrammarChecker, + css::uno::Reference< css::linguistic2::XProofreader > _xGrammarChecker, const OUString* pDialogTitle = nullptr, const OUString* pExplanation = nullptr, const OUString* pRuleId = nullptr, const OUString* pExplanationURL = nullptr ) : bIsGrammarError( bGrammar ), - sErrorText( rText ), + sErrorText(std::move( aText )), sDialogTitle( ), sExplanation( ), sExplanationURL( ), - aLocale( rLocale ), - xGrammarChecker( rxGrammarChecker ), + aLocale(std::move( _aLocale )), + xGrammarChecker(std::move( _xGrammarChecker )), aSuggestions( rSuggestions ) { if( pDialogTitle ) diff --git a/cui/source/dialogs/SpellDialog.cxx b/cui/source/dialogs/SpellDialog.cxx index dae7b92c9155..9dd877f80cf9 100644 --- a/cui/source/dialogs/SpellDialog.cxx +++ b/cui/source/dialogs/SpellDialog.cxx @@ -26,6 +26,7 @@ #include <svl/undo.hxx> #include <tools/debug.hxx> #include <unotools/lingucfg.hxx> +#include <editeng/editund2.hxx> #include <editeng/colritem.hxx> #include <editeng/eeitem.hxx> #include <editeng/langitem.hxx> @@ -50,6 +51,7 @@ #include <SpellDialog.hxx> #include <optlingu.hxx> #include <treeopt.hxx> +#include <svtools/colorcfg.hxx> #include <svtools/langtab.hxx> #include <sal/log.hxx> #include <i18nlangtag/languagetag.hxx> @@ -160,6 +162,7 @@ SpellDialog::SpellDialog(SpellDialogChildWindow* pChildWindow, : SfxModelessDialogController (_pBindings, pChildWindow, pParent, "cui/ui/spellingdialog.ui", "SpellingDialog") , aDialogUndoLink(LINK (this, SpellDialog, DialogUndoHdl)) + , m_pInitHdlEvent(nullptr) , bFocusLocked(true) , rParent(*pChildWindow) , pImpl( new SpellDialog_Impl ) @@ -171,7 +174,7 @@ SpellDialog::SpellDialog(SpellDialogChildWindow* pChildWindow, , m_xExplainFT(m_xBuilder->weld_label("explain")) , m_xExplainLink(m_xBuilder->weld_link_button("explainlink")) , m_xNotInDictFT(m_xBuilder->weld_label("notindictft")) - , m_xSentenceED(new SentenceEditWindow_Impl) + , m_xSentenceED(new SentenceEditWindow_Impl(m_xBuilder->weld_scrolled_window("scrolledwindow", true))) , m_xSuggestionFT(m_xBuilder->weld_label("suggestionsft")) , m_xSuggestionLB(m_xBuilder->weld_tree_view("suggestionslb")) , m_xIgnorePB(m_xBuilder->weld_button("ignore")) @@ -218,11 +221,19 @@ SpellDialog::SpellDialog(SpellDialogChildWindow* pChildWindow, //InitHdl wants to use virtual methods, so it //can't be called during the ctor, so init //it on next event cycle post-ctor - Application::PostUserEvent(LINK(this, SpellDialog, InitHdl)); + m_pInitHdlEvent = Application::PostUserEvent(LINK(this, SpellDialog, InitHdl)); } SpellDialog::~SpellDialog() { + if (m_xOptionsDlg) + { + m_xOptionsDlg->response(RET_CANCEL); + m_xOptionsDlg.reset(); + } + + if (m_pInitHdlEvent) + Application::RemoveUserEvent(m_pInitHdlEvent); if (pImpl) { // save possibly modified user-dictionaries @@ -351,6 +362,11 @@ void SpellDialog::SpellContinue_Impl(std::unique_ptr<UndoChangeGroupGuard>* pGua //then GetNextSentence() has to be called followed again by MarkNextError() //MarkNextError is not initially called if the UndoEdit mode is active bool bNextSentence = false; + if (!m_xSentenceED) + { + return; + } + if(!((!m_xSentenceED->IsUndoEditMode() && m_xSentenceED->MarkNextError( bIgnoreCurrentError, xSpell )) || ( bNextSentence = GetNextSentence_Impl(pGuard, bUseSavedSentence, m_xSentenceED->IsUndoEditMode()) && m_xSentenceED->MarkNextError( false, xSpell )))) return; @@ -364,16 +380,10 @@ void SpellDialog::SpellContinue_Impl(std::unique_ptr<UndoChangeGroupGuard>* pGua { m_xNotInDictFT.get(), m_xSentenceED->GetDrawingArea(), - m_xLanguageFT.get(), - nullptr + m_xLanguageFT.get() }; - sal_Int32 nIdx = 0; - do - { - aControls[nIdx]->set_sensitive(true); - } - while(aControls[++nIdx]); - + for (weld::Widget* pWidget : aControls) + pWidget->set_sensitive(true); } if( bNextSentence ) { @@ -387,6 +397,7 @@ void SpellDialog::SpellContinue_Impl(std::unique_ptr<UndoChangeGroupGuard>* pGua */ IMPL_LINK_NOARG( SpellDialog, InitHdl, void*, void) { + m_pInitHdlEvent = nullptr; m_xDialog->freeze(); //show or hide AutoCorrect depending on the modules abilities m_xAutoCorrPB->set_visible(rParent.HasAutoCorrection()); @@ -401,7 +412,9 @@ IMPL_LINK_NOARG( SpellDialog, InitHdl, void*, void) InitUserDicts(); LockFocusChanges(true); - if( m_xChangePB->get_sensitive() ) + if(m_xSentenceED->IsEnabled()) + m_xSentenceED->GrabFocus(); + else if( m_xChangePB->get_sensitive() ) m_xChangePB->grab_focus(); else if( m_xIgnorePB->get_sensitive() ) m_xIgnorePB->grab_focus(); @@ -456,19 +469,22 @@ IMPL_LINK_NOARG(SpellDialog, CheckGrammarHdl, weld::Toggleable&, void) void SpellDialog::StartSpellOptDlg_Impl() { - SfxItemSetFixed<SID_AUTOSPELL_CHECK,SID_AUTOSPELL_CHECK> aSet( SfxGetpApp()->GetPool() ); - SfxSingleTabDialogController aDlg(m_xDialog.get(), &aSet, "cui/ui/spelloptionsdialog.ui", "SpellOptionsDialog"); + auto xSet = std::make_shared<SfxItemSetFixed<SID_AUTOSPELL_CHECK,SID_AUTOSPELL_CHECK>>( SfxGetpApp()->GetPool() ); + m_xOptionsDlg = std::make_shared<SfxSingleTabDialogController>( + m_xDialog.get(), xSet.get(), "content", "cui/ui/spelloptionsdialog.ui", "SpellOptionsDialog"); - std::unique_ptr<SfxTabPage> xPage = SvxLinguTabPage::Create(aDlg.get_content_area(), &aDlg, &aSet); + std::unique_ptr<SfxTabPage> xPage = SvxLinguTabPage::Create(m_xOptionsDlg->get_content_area(), m_xOptionsDlg.get(), xSet.get()); static_cast<SvxLinguTabPage*>(xPage.get())->HideGroups( GROUP_MODULES ); - aDlg.SetTabPage(std::move(xPage)); - if (RET_OK == aDlg.run()) - { - InitUserDicts(); - const SfxItemSet* pOutSet = aDlg.GetOutputItemSet(); - if(pOutSet) - OfaTreeOptionsDialog::ApplyLanguageOptions(*pOutSet); - } + m_xOptionsDlg->SetTabPage(std::move(xPage)); + weld::GenericDialogController::runAsync(m_xOptionsDlg, [this, xSet] (sal_uInt32 nResult) { + if (RET_OK == nResult) + { + InitUserDicts(); + const SfxItemSet* pOutSet = m_xOptionsDlg->GetOutputItemSet(); + if(pOutSet) + OfaTreeOptionsDialog::ApplyLanguageOptions(*pOutSet); + } + }); } namespace @@ -713,8 +729,7 @@ void SpellDialog::Close() // section - in that case, the cursor can move from the editable field to // the protected area, and the slots get disabled because of // SfxDisableFlags::SwOnProtectedCursor (see FN_SPELL_GRAMMAR_DIALOG in .sdi). - SfxViewFrame* pViewFrame = SfxViewFrame::Current(); - if (pViewFrame) + if (SfxViewFrame* pViewFrame = SfxViewFrame::Current()) pViewFrame->ToggleChildWindow(rParent.GetType()); } @@ -828,15 +843,15 @@ int SpellDialog::InitUserDicts() IMPL_LINK_NOARG(SpellDialog, AddToDictClickHdl, weld::Button&, void) { - AddToDictionaryExecute(OString::number(1)); + AddToDictionaryExecute(OUString::number(1)); } -IMPL_LINK(SpellDialog, AddToDictSelectHdl, const OString&, rIdent, void) +IMPL_LINK(SpellDialog, AddToDictSelectHdl, const OUString&, rIdent, void) { AddToDictionaryExecute(rIdent); } -void SpellDialog::AddToDictionaryExecute(const OString& rItemId) +void SpellDialog::AddToDictionaryExecute(const OUString& rItemId) { auto xGuard(std::make_unique<UndoChangeGroupGuard>(*m_xSentenceED)); @@ -945,7 +960,7 @@ void SpellDialog::Activate() void SpellDialog::Deactivate() { - SfxModelessDialogController::Activate(); + SfxModelessDialogController::Deactivate(); ToplevelFocusChanged(); } @@ -969,15 +984,11 @@ void SpellDialog::InvalidateDialog() m_xChangePB.get(), m_xChangeAllPB.get(), m_xAutoCorrPB.get(), - m_xUndoPB.get(), - nullptr + m_xUndoPB.get() }; - sal_Int16 i = 0; - while(aDisableArr[i]) - { - aDisableArr[i]->set_sensitive(false); - i++; - } + for (weld::Widget* pWidget : aDisableArr) + pWidget->set_sensitive(false); + SfxModelessDialogController::Deactivate(); } @@ -1119,13 +1130,15 @@ bool SpellDialog::ApplyChangeAllList_Impl(SpellPortions& rSentence, bool &bHasRe return bRet; } -SentenceEditWindow_Impl::SentenceEditWindow_Impl() - : m_pSpellDialog(nullptr) +SentenceEditWindow_Impl::SentenceEditWindow_Impl(std::unique_ptr<weld::ScrolledWindow> xScrolledWindow) + : m_xScrolledWindow(std::move(xScrolledWindow)) + , m_pSpellDialog(nullptr) , m_pToolbar(nullptr) , m_nErrorStart(0) , m_nErrorEnd(0) , m_bIsUndoEditMode(false) { + m_xScrolledWindow->connect_vadjustment_changed(LINK(this, SentenceEditWindow_Impl, ScrollHdl)); } void SentenceEditWindow_Impl::SetDrawingArea(weld::DrawingArea* pDrawingArea) @@ -1136,6 +1149,90 @@ void SentenceEditWindow_Impl::SetDrawingArea(weld::DrawingArea* pDrawingArea) WeldEditView::SetDrawingArea(pDrawingArea); // tdf#132288 don't merge equal adjacent attributes m_xEditEngine->DisableAttributeExpanding(); + + m_xEditEngine->SetStatusEventHdl(LINK(this, SentenceEditWindow_Impl, EditStatusHdl)); + + SetDocumentColor(pDrawingArea); +} + +void SentenceEditWindow_Impl::SetDocumentColor(weld::DrawingArea* pDrawingArea) +{ + if (!pDrawingArea || !m_xEditView || !m_xEditEngine) + return; + // tdf#142631 use document background color in this widget + Color aBgColor = svtools::ColorConfig().GetColorValue(svtools::DOCCOLOR).nColor; + OutputDevice& rDevice = pDrawingArea->get_ref_device(); + rDevice.SetBackground(aBgColor); + m_xEditView->SetBackgroundColor(aBgColor); + m_xEditEngine->SetBackgroundColor(aBgColor); +} + +void SentenceEditWindow_Impl::StyleUpdated() +{ + SetDocumentColor(GetDrawingArea()); + WeldEditView::StyleUpdated(); +} + +IMPL_LINK_NOARG(SentenceEditWindow_Impl, EditStatusHdl, EditStatus&, void) +{ + SetScrollBarRange(); + DoScroll(); +} + +IMPL_LINK_NOARG(SentenceEditWindow_Impl, ScrollHdl, weld::ScrolledWindow&, void) +{ + DoScroll(); +} + +void SentenceEditWindow_Impl::DoScroll() +{ + if (m_xEditView) + { + auto currentDocPos = m_xEditView->GetVisArea().Top(); + auto nDiff = currentDocPos - m_xScrolledWindow->vadjustment_get_value(); + // we expect SetScrollBarRange callback to be triggered by Scroll + // to set where we ended up + m_xEditView->Scroll(0, nDiff); + } +} + +void SentenceEditWindow_Impl::EditViewScrollStateChange() +{ + // editengine height has changed or editview scroll pos has changed + SetScrollBarRange(); +} + +void SentenceEditWindow_Impl::SetScrollBarRange() +{ + EditEngine *pEditEngine = GetEditEngine(); + if (!pEditEngine) + return; + if (!m_xScrolledWindow) + return; + EditView* pEditView = GetEditView(); + if (!pEditView) + return; + + int nVUpper = pEditEngine->GetTextHeight(); + int nVCurrentDocPos = pEditView->GetVisArea().Top(); + const Size aOut(pEditView->GetOutputArea().GetSize()); + int nVStepIncrement = aOut.Height() * 2 / 10; + int nVPageIncrement = aOut.Height() * 8 / 10; + int nVPageSize = aOut.Height(); + + /* limit the page size to below nUpper because gtk's gtk_scrolled_window_start_deceleration has + effectively... + + lower = gtk_adjustment_get_lower + upper = gtk_adjustment_get_upper - gtk_adjustment_get_page_size + + and requires that upper > lower or the deceleration animation never ends + */ + nVPageSize = std::min(nVPageSize, nVUpper); + + m_xScrolledWindow->vadjustment_configure(nVCurrentDocPos, 0, nVUpper, + nVStepIncrement, nVPageIncrement, nVPageSize); + m_xScrolledWindow->set_vpolicy(nVUpper > nVPageSize ? VclPolicyType::ALWAYS : VclPolicyType::NEVER); } SentenceEditWindow_Impl::~SentenceEditWindow_Impl() @@ -1163,7 +1260,10 @@ namespace void ExtractErrorDescription(const EECharAttrib& rEECharAttrib, SpellErrorDescription& rSpellErrorDescription) { css::uno::Sequence<css::uno::Any> aSequence; - static_cast<const SfxGrabBagItem*>(rEECharAttrib.pAttr)->GetGrabBag().find("SpellErrorDescription")->second >>= aSequence; + const auto pGrabBag = static_cast<const SfxGrabBagItem*>(rEECharAttrib.pAttr)->GetGrabBag(); + const auto iter = pGrabBag.find("SpellErrorDescription"); + assert(iter != pGrabBag.end()); + iter->second >>= aSequence; rSpellErrorDescription.fromSequence(aSequence); } } @@ -1487,6 +1587,8 @@ bool SentenceEditWindow_Impl::KeyInput(const KeyEvent& rKeyEvt) //start position if (!IsUndoEditMode() && bIsErrorActive) { + aAttribList.clear(); + m_xEditEngine->GetCharAttribs(0, aAttribList); const EECharAttrib* pFontColor = FindCharAttrib(nCursor, EE_CHAR_COLOR, aAttribList); const EECharAttrib* pErrorAttrib = FindCharAttrib(m_nErrorStart, EE_CHAR_GRABBAG, aAttribList); if (pFontColor && pErrorAttrib) @@ -1518,7 +1620,7 @@ void SentenceEditWindow_Impl::Init(weld::Toolbar* pToolbar) m_pToolbar->connect_clicked(LINK(this,SentenceEditWindow_Impl,ToolbarHdl)); } -IMPL_LINK(SentenceEditWindow_Impl, ToolbarHdl, const OString&, rCurItemId, void) +IMPL_LINK(SentenceEditWindow_Impl, ToolbarHdl, const OUString&, rCurItemId, void) { if (rCurItemId == "paste") { @@ -1667,8 +1769,12 @@ void SentenceEditWindow_Impl::MoveErrorMarkTo(sal_Int32 nStart, sal_Int32 nEnd, m_xEditEngine->RemoveAttribs(aAll, false, EE_CHAR_WEIGHT_CJK); m_xEditEngine->RemoveAttribs(aAll, false, EE_CHAR_WEIGHT_CTL); + // tdf#116566 Use color defined in the current Color Scheme + Color aSpellErrorCollor = svtools::ColorConfig().GetColorValue(svtools::SPELL).nColor; + Color aGrammarErrorCollor = svtools::ColorConfig().GetColorValue(svtools::GRAMMAR).nColor; + SfxItemSet aSet(m_xEditEngine->GetEmptyItemSet()); - aSet.Put(SvxColorItem(bGrammarError ? COL_LIGHTBLUE : COL_LIGHTRED, EE_CHAR_COLOR)); + aSet.Put(SvxColorItem(bGrammarError ? aGrammarErrorCollor : aSpellErrorCollor, EE_CHAR_COLOR)); aSet.Put(SvxWeightItem(WEIGHT_BOLD, EE_CHAR_WEIGHT)); aSet.Put(SvxWeightItem(WEIGHT_BOLD, EE_CHAR_WEIGHT_CJK)); aSet.Put(SvxWeightItem(WEIGHT_BOLD, EE_CHAR_WEIGHT_CTL)); @@ -1683,6 +1789,8 @@ void SentenceEditWindow_Impl::MoveErrorMarkTo(sal_Int32 nStart, sal_Int32 nEnd, if (!bCurrentSelectionInRange) { m_xEditView->SetSelection(ESelection(0, nStart)); + // tdf#157148 ensure current location is auto-scrolled to be visible + m_xEditView->ShowCursor(); } Invalidate(); @@ -1816,7 +1924,7 @@ void SentenceEditWindow_Impl::SetAlternatives( const Reference< XSpellAlternativ aLocale = xAlt->getLocale(); aAlts = xAlt->getAlternatives(); } - SpellErrorDescription aDesc( false, aWord, aLocale, aAlts, nullptr); + SpellErrorDescription aDesc( false, aWord, std::move(aLocale), aAlts, nullptr); SfxGrabBagItem aSpellErrorDescription(EE_CHAR_GRABBAG); aSpellErrorDescription.GetGrabBag()["SpellErrorDescription"] <<= aDesc.toSequence(); SetAttrib(aSpellErrorDescription, m_nErrorStart, m_nErrorEnd); @@ -1945,7 +2053,6 @@ svx::SpellPortions SentenceEditWindow_Impl::CreateSpellPortions() const aPortion1.eLanguage = eLang; aPortion1.sText = m_xEditEngine->GetText(ESelection(0, nStart, 0, aStart->nPosition)); - bool bIsIgnoreError = m_aIgnoreErrorsAt.find( nStart ) != m_aIgnoreErrorsAt.end(); if( bIsIgnoreError ) { @@ -1977,7 +2084,7 @@ svx::SpellPortions SentenceEditWindow_Impl::CreateSpellPortions() const aPortion2.sText = aLeftOverText.makeStringAndClear(); aRet.push_back( aPortion2 ); } - else + else if (!aLeftOverText.isEmpty() && !aRet.empty()) { // we just need to append the left-over text to the last portion (which had no errors) aRet[ aRet.size() - 1 ].sText += aLeftOverText; } @@ -1989,7 +2096,7 @@ svx::SpellPortions SentenceEditWindow_Impl::CreateSpellPortions() const void SentenceEditWindow_Impl::Undo() { - SfxUndoManager& rUndoMgr = m_xEditEngine->GetUndoManager(); + EditUndoManager& rUndoMgr = m_xEditEngine->GetUndoManager(); DBG_ASSERT(GetUndoActionCount(), "no undo actions available" ); if(!GetUndoActionCount()) return; @@ -2008,13 +2115,13 @@ void SentenceEditWindow_Impl::Undo() void SentenceEditWindow_Impl::ResetUndo() { - SfxUndoManager& rUndo = m_xEditEngine->GetUndoManager(); + EditUndoManager& rUndo = m_xEditEngine->GetUndoManager(); rUndo.Clear(); } void SentenceEditWindow_Impl::AddUndoAction( std::unique_ptr<SfxUndoAction> pAction ) { - SfxUndoManager& rUndoMgr = m_xEditEngine->GetUndoManager(); + EditUndoManager& rUndoMgr = m_xEditEngine->GetUndoManager(); rUndoMgr.AddUndoAction(std::move(pAction)); GetSpellDialog()->m_xUndoPB->set_sensitive(true); } @@ -2063,15 +2170,10 @@ void SentenceEditWindow_Impl::SetUndoEditMode(bool bSet) pSpellDialog->m_xLanguageLB->get_widget(), pSpellDialog->m_xAddToDictMB.get(), pSpellDialog->m_xAddToDictPB.get(), - pSpellDialog->m_xAutoCorrPB.get(), - nullptr + pSpellDialog->m_xAutoCorrPB.get() }; - sal_Int32 nIdx = 0; - do - { - aControls[nIdx]->set_sensitive(false); - } - while(aControls[++nIdx]); + for (weld::Widget* pWidget : aControls) + pWidget->set_sensitive(false); //remove error marks ESelection aAll(0, 0, 0, EE_TEXTPOS_ALL); diff --git a/cui/source/dialogs/about.cxx b/cui/source/dialogs/about.cxx index 7216ca55e3b8..ce82e418cf9e 100644 --- a/cui/source/dialogs/about.cxx +++ b/cui/source/dialogs/about.cxx @@ -17,13 +17,18 @@ * the License at http://www.apache.org/licenses/LICENSE-2.0 . */ +#include <sal/config.h> + +#include <cassert> + #include <about.hxx> #include <osl/process.h> //osl_getProcessLocale +#include <rtl/bootstrap.hxx> #include <sal/log.hxx> //SAL_WARN +#include <vcl/graph.hxx> //Graphic #include <vcl/settings.hxx> //GetSettings #include <vcl/svapp.hxx> //Application:: -#include <vcl/virdev.hxx> //VirtualDevice #include <vcl/weld.hxx> #include <unotools/resmgr.hxx> //Translate @@ -100,24 +105,24 @@ AboutDialog::AboutDialog(weld::Window *pParent) ? "shell/logo_inverted" : "shell/logo", aBackgroundBitmap, nWidth * 0.8)) { - ScopedVclPtr<VirtualDevice> m_pVirDev = - m_pBrandImage->create_virtual_device(); - m_pVirDev->SetOutputSizePixel(aBackgroundBitmap.GetSizePixel()); - m_pVirDev->DrawBitmapEx(Point(0, 0), aBackgroundBitmap); - m_pBrandImage->set_image(m_pVirDev.get()); - m_pVirDev.disposeAndClear(); + // Eliminate white background when Skia is disabled by not drawing the + // background bitmap to a VirtualDevice. On most platforms, non-Skia + // VirtualDevices will be filled with a solid color when drawing + // the bitmap. + Graphic aGraphic(aBackgroundBitmap); + m_pBrandImage->set_image(aGraphic.GetXGraphic()); } if (SfxApplication::loadBrandSvg("shell/about", aBackgroundBitmap, nWidth * 0.9)) { - ScopedVclPtr<VirtualDevice> m_pVirDev = - m_pAboutImage->create_virtual_device(); - m_pVirDev->SetOutputSizePixel(aBackgroundBitmap.GetSizePixel()); - m_pVirDev->DrawBitmapEx(Point(0, 0), aBackgroundBitmap); - m_pAboutImage->set_image(m_pVirDev.get()); - m_pVirDev.disposeAndClear(); + // Eliminate white background when Skia is disabled by not drawing the + // background bitmap to a VirtualDevice. On most platforms, non-Skia + // VirtualDevices will be filled with a solid color when drawing + // the bitmap. + Graphic aGraphic(aBackgroundBitmap); + m_pAboutImage->set_image(aGraphic.GetXGraphic()); } // Links - m_pCreditsButton->set_uri(CuiResId(RID_SVXSTR_ABOUT_CREDITS_URL)); + m_pCreditsButton->set_uri(officecfg::Office::Common::Menus::CreditsURL::get()); OUString sURL(officecfg::Office::Common::Help::StartCenter::InfoURL::get()); localizeWebserviceURI(sURL); @@ -136,23 +141,16 @@ AboutDialog::AboutDialog(weld::Window *pParent) AboutDialog::~AboutDialog() {} -bool AboutDialog::IsStringValidGitHash(const OUString &hash) { - for (int i = 0; i < hash.getLength(); i++) { - if (!std::isxdigit(hash[i])) { - return false; - } - } - return true; +bool AboutDialog::IsStringValidGitHash(std::u16string_view hash) { + return std::all_of(hash.begin(), hash.end(), + [](auto &rSymbol) { return std::isxdigit(rSymbol); }); } OUString AboutDialog::GetVersionString() { - OUString sVersion = CuiResId(TranslateId(nullptr, "%ABOUTBOXPRODUCTVERSION%ABOUTBOXPRODUCTVERSIONSUFFIX")); - -#ifdef _WIN64 - sVersion += " (x64)"; -#elif defined(_WIN32) - sVersion += " (x86)"; -#endif + OUString arch; + auto const ok = rtl::Bootstrap::get("_ARCH", arch); + assert(ok); (void) ok; + OUString sVersion = CuiResId(TranslateId(nullptr, "%ABOUTBOXPRODUCTVERSION%ABOUTBOXPRODUCTVERSIONSUFFIX")) + " (" + arch + ")"; #if HAVE_FEATURE_COMMUNITY_FLAVOR sVersion += " / LibreOffice Community"; @@ -192,9 +190,9 @@ OUString AboutDialog::GetLocaleString(const bool bLocalized) { Application::GetSettings().GetUILanguageTag().getBcp47(); OUString sUILocaleStr; if (bLocalized) - sUILocaleStr = CuiResId(RID_SVXSTR_ABOUT_UILOCALE); + sUILocaleStr = CuiResId(RID_CUISTR_ABOUT_UILOCALE); else - sUILocaleStr = Translate::get(RID_SVXSTR_ABOUT_UILOCALE, Translate::Create("cui", LanguageTag("en-US"))); + sUILocaleStr = Translate::get(RID_CUISTR_ABOUT_UILOCALE, Translate::Create("cui", LanguageTag("en-US"))); if (sUILocaleStr.indexOf("$LOCALE") == -1) { SAL_WARN("cui.dialogs", "translated uilocale string in translations " @@ -216,14 +214,11 @@ OUString AboutDialog::GetMiscString() { sMisc = EXTRA_BUILDID "\n"; } - OUString aCalcMode = "Calc: "; // Calc calculation mode + OUString aCalcMode; // Calc calculation mode #if HAVE_FEATURE_OPENCL - bool bOpenCL = openclwrapper::GPUEnv::isOpenCLEnabled(); - if (bOpenCL) - aCalcMode += "CL"; -#else - const bool bOpenCL = false; + if (openclwrapper::GPUEnv::isOpenCLEnabled()) + aCalcMode += " CL"; #endif static const bool bThreadingProhibited = @@ -231,32 +226,31 @@ OUString AboutDialog::GetMiscString() { bool bThreadedCalc = officecfg::Office::Calc::Formula::Calculation:: UseThreadedCalculationForFormulaGroups::get(); - if (!bThreadingProhibited && !bOpenCL && bThreadedCalc) { - if (!aCalcMode.endsWith(" ")) - aCalcMode += " "; - aCalcMode += "threaded"; + if (!bThreadingProhibited && bThreadedCalc) { + aCalcMode += " threaded"; } if (officecfg::Office::Calc::Defaults::Sheet::JumboSheets::get()) { - if (!aCalcMode.endsWith(" ")) - aCalcMode += " "; - aCalcMode += "Jumbo"; + aCalcMode += " Jumbo"; } - sMisc += aCalcMode; + + if (aCalcMode.isEmpty()) + aCalcMode = " default"; + sMisc += "Calc:" + aCalcMode; return sMisc; } OUString AboutDialog::GetCopyrightString() { - OUString sVendorTextStr(CuiResId(RID_SVXSTR_ABOUT_VENDOR)); + OUString sVendorTextStr(CuiResId(RID_CUISTR_ABOUT_VENDOR)); OUString aCopyrightString = - sVendorTextStr + "\n" + CuiResId(RID_SVXSTR_ABOUT_COPYRIGHT) + "\n"; + sVendorTextStr + "\n" + CuiResId(RID_CUISTR_ABOUT_COPYRIGHT) + "\n"; if (utl::ConfigManager::getProductName() == "LibreOffice") - aCopyrightString += CuiResId(RID_SVXSTR_ABOUT_BASED_ON); + aCopyrightString += CuiResId(RID_CUISTR_ABOUT_BASED_ON); else - aCopyrightString += CuiResId(RID_SVXSTR_ABOUT_DERIVED); + aCopyrightString += CuiResId(RID_CUISTR_ABOUT_DERIVED); return aCopyrightString; } diff --git a/cui/source/dialogs/colorpicker.cxx b/cui/source/dialogs/colorpicker.cxx index 3b9a81dddde3..290025929d5a 100644 --- a/cui/source/dialogs/colorpicker.cxx +++ b/cui/source/dialogs/colorpicker.cxx @@ -26,9 +26,8 @@ #include <com/sun/star/awt/XWindow.hpp> #include <comphelper/propertyvalue.hxx> -#include <cppuhelper/compbase.hxx> +#include <comphelper/compbase.hxx> #include <cppuhelper/supportsservice.hxx> -#include <cppuhelper/basemutex.hxx> #include <vcl/customweld.hxx> #include <vcl/event.hxx> #include <vcl/svapp.hxx> @@ -201,6 +200,7 @@ class ColorFieldControl : public weld::CustomWidgetController public: ColorFieldControl() : meMode( DefaultMode ) + , mnBaseValue(USHRT_MAX) , mdX( -1.0 ) , mdY( -1.0 ) , mbMouseCaptured(false) @@ -230,7 +230,7 @@ public: void UpdatePosition(); void Modify(); - void SetValues(Color aColor, ColorMode eMode, double x, double y); + void SetValues(sal_uInt16 nBaseValue, ColorMode eMode, double x, double y); double GetX() const { return mdX;} double GetY() const { return mdY;} @@ -238,7 +238,7 @@ public: private: ColorMode meMode; - Color maColor; + sal_uInt16 mnBaseValue; double mdX; double mdY; bool mbMouseCaptured; @@ -307,11 +307,6 @@ void ColorFieldControl::UpdateBitmap() sal_uInt8* pRGB_Vert = maRGB_Vert.data(); sal_uInt16* pPercent_Vert = maPercent_Vert.data(); - Color aBitmapColor(maColor); - - sal_uInt16 nHue, nSat, nBri; - maColor.RGBtoHSB(nHue, nSat, nBri); - // this has been unlooped for performance reason, please do not merge back! sal_uInt16 y = nHeight,x; @@ -321,40 +316,43 @@ void ColorFieldControl::UpdateBitmap() case HUE: while (y--) { - nBri = pPercent_Vert[y]; + sal_uInt16 nBri = pPercent_Vert[y]; x = nWidth; while (x--) { - nSat = pPercent_Horiz[x]; - mxBitmap->DrawPixel(Point(x,y), Color::HSBtoRGB(nHue, nSat, nBri)); + sal_uInt16 nSat = pPercent_Horiz[x]; + mxBitmap->DrawPixel(Point(x,y), Color::HSBtoRGB(mnBaseValue, nSat, nBri)); } } break; case SATURATION: while (y--) { - nBri = pPercent_Vert[y]; + sal_uInt16 nBri = pPercent_Vert[y]; x = nWidth; while (x--) { - nHue = pGrad_Horiz[x]; - mxBitmap->DrawPixel(Point(x,y), Color::HSBtoRGB(nHue, nSat, nBri)); + sal_uInt16 nHue = pGrad_Horiz[x]; + mxBitmap->DrawPixel(Point(x,y), Color::HSBtoRGB(nHue, mnBaseValue, nBri)); } } break; case BRIGHTNESS: while (y--) { - nSat = pPercent_Vert[y]; + sal_uInt16 nSat = pPercent_Vert[y]; x = nWidth; while (x--) { - nHue = pGrad_Horiz[x]; - mxBitmap->DrawPixel(Point(x,y), Color::HSBtoRGB(nHue, nSat, nBri)); + sal_uInt16 nHue = pGrad_Horiz[x]; + mxBitmap->DrawPixel(Point(x,y), Color::HSBtoRGB(nHue, nSat, mnBaseValue)); } } break; case RED: + { + Color aBitmapColor; + aBitmapColor.SetRed(mnBaseValue); while (y--) { aBitmapColor.SetGreen(pRGB_Vert[y]); @@ -366,7 +364,11 @@ void ColorFieldControl::UpdateBitmap() } } break; + } case GREEN: + { + Color aBitmapColor; + aBitmapColor.SetGreen(mnBaseValue); while (y--) { aBitmapColor.SetRed(pRGB_Vert[y]); @@ -378,7 +380,11 @@ void ColorFieldControl::UpdateBitmap() } } break; + } case BLUE: + { + Color aBitmapColor; + aBitmapColor.SetBlue(mnBaseValue); while (y--) { aBitmapColor.SetGreen(pRGB_Vert[y]); @@ -390,9 +396,12 @@ void ColorFieldControl::UpdateBitmap() } } break; + } } } +constexpr int nCenterOffset = 5; + void ColorFieldControl::ShowPosition( const Point& rPos, bool bUpdate ) { if (!mxBitmap) @@ -419,8 +428,8 @@ void ColorFieldControl::ShowPosition( const Point& rPos, bool bUpdate ) nY = aSize.Height() - 1; Point aPos = maPosition; - maPosition.setX( nX - 5 ); - maPosition.setY( nY - 5 ); + maPosition.setX( nX - nCenterOffset ); + maPosition.setY( nY - nCenterOffset ); Invalidate(tools::Rectangle(aPos, Size(11, 11))); Invalidate(tools::Rectangle(maPosition, Size(11, 11))); @@ -428,8 +437,6 @@ void ColorFieldControl::ShowPosition( const Point& rPos, bool bUpdate ) { mdX = double(nX) / double(aSize.Width() - 1.0); mdY = double(aSize.Height() - 1.0 - nY) / double(aSize.Height() - 1.0); - - maColor = mxBitmap->GetPixel(Point(nX, nY)); } } @@ -464,20 +471,21 @@ void ColorFieldControl::Paint(vcl::RenderContext& rRenderContext, const tools::R if (!mxBitmap) UpdateBitmap(); - if (mxBitmap) - { - Size aSize(GetOutputSizePixel()); - rRenderContext.DrawOutDev(Point(0, 0), aSize, Point(0, 0), aSize, *mxBitmap); - } + if (!mxBitmap) + return; + + Size aSize(GetOutputSizePixel()); + rRenderContext.DrawOutDev(Point(0, 0), aSize, Point(0, 0), aSize, *mxBitmap); // draw circle around current color - if (maColor.IsDark()) - rRenderContext.SetLineColor( COL_WHITE ); + Point aPos(maPosition.X() + nCenterOffset, maPosition.Y() + nCenterOffset); + Color aColor = mxBitmap->GetPixel(aPos); + if (aColor.IsDark()) + rRenderContext.SetLineColor(COL_WHITE); else - rRenderContext.SetLineColor( COL_BLACK ); + rRenderContext.SetLineColor(COL_BLACK); rRenderContext.SetFillColor(); - rRenderContext.DrawEllipse(::tools::Rectangle(maPosition, Size(11, 11))); } @@ -493,13 +501,13 @@ void ColorFieldControl::Modify() maModifyHdl.Call( *this ); } -void ColorFieldControl::SetValues( Color aColor, ColorMode eMode, double x, double y ) +void ColorFieldControl::SetValues(sal_uInt16 nBaseValue, ColorMode eMode, double x, double y) { - bool bUpdateBitmap = (maColor!= aColor) || (meMode != eMode); - if( !(bUpdateBitmap || (mdX != x) || (mdY != y)) ) + bool bUpdateBitmap = (mnBaseValue != nBaseValue) || (meMode != eMode); + if (!bUpdateBitmap && mdX == x && mdY == y) return; - maColor = aColor; + mnBaseValue = nBaseValue; meMode = eMode; mdX = x; mdY = y; @@ -887,7 +895,9 @@ void ColorPickerDialog::update_color( UpdateFlags n ) sal_uInt8 nGreen = toInt(mdGreen,255.0); sal_uInt8 nBlue = toInt(mdBlue,255.0); - Color aColor(nRed, nGreen, nBlue); + sal_uInt16 nHue = toInt(mdHue, 1.0); + sal_uInt16 nSat = toInt(mdSat, 100.0); + sal_uInt16 nBri = toInt(mdBri, 100.0); if (n & UpdateFlags::RGB) // update RGB { @@ -906,9 +916,9 @@ void ColorPickerDialog::update_color( UpdateFlags n ) if (n & UpdateFlags::HSB ) // update HSB { - m_xMFHue->set_value(toInt(mdHue, 1.0), FieldUnit::DEGREE); - m_xMFSaturation->set_value(toInt( mdSat, 100.0), FieldUnit::PERCENT); - m_xMFBrightness->set_value(toInt( mdBri, 100.0), FieldUnit::PERCENT); + m_xMFHue->set_value(nHue, FieldUnit::DEGREE); + m_xMFSaturation->set_value(nSat, FieldUnit::PERCENT); + m_xMFBrightness->set_value(nBri, FieldUnit::PERCENT); } if (n & UpdateFlags::ColorChooser ) // update Color Chooser 1 @@ -916,26 +926,28 @@ void ColorPickerDialog::update_color( UpdateFlags n ) switch( meMode ) { case HUE: - m_aColorField.SetValues(aColor, meMode, mdSat, mdBri); + m_aColorField.SetValues(nHue, meMode, mdSat, mdBri); break; case SATURATION: - m_aColorField.SetValues(aColor, meMode, mdHue / 360.0, mdBri); + m_aColorField.SetValues(nSat, meMode, mdHue / 360.0, mdBri); break; case BRIGHTNESS: - m_aColorField.SetValues(aColor, meMode, mdHue / 360.0, mdSat); + m_aColorField.SetValues(nBri, meMode, mdHue / 360.0, mdSat); break; case RED: - m_aColorField.SetValues(aColor, meMode, mdBlue, mdGreen); + m_aColorField.SetValues(nRed, meMode, mdBlue, mdGreen); break; case GREEN: - m_aColorField.SetValues(aColor, meMode, mdBlue, mdRed); + m_aColorField.SetValues(nGreen, meMode, mdBlue, mdRed); break; case BLUE: - m_aColorField.SetValues(aColor, meMode, mdRed, mdGreen); + m_aColorField.SetValues(nBlue, meMode, mdRed, mdGreen); break; } } + Color aColor(nRed, nGreen, nBlue); + if (n & UpdateFlags::ColorSlider) // update Color Chooser 2 { switch (meMode) @@ -1209,12 +1221,11 @@ void ColorPickerDialog::setColorComponent( ColorComponent nComp, double dValue ) } } -typedef ::cppu::WeakComponentImplHelper< XServiceInfo, XExecutableDialog, XAsynchronousExecutableDialog, XInitialization, XPropertyAccess > ColorPickerBase; +typedef ::comphelper::WeakComponentImplHelper< XServiceInfo, XExecutableDialog, XAsynchronousExecutableDialog, XInitialization, XPropertyAccess > ColorPickerBase; namespace { -class ColorPicker : protected ::cppu::BaseMutex, // Struct for right initialization of mutex member! Must be first of baseclasses. - public ColorPickerBase +class ColorPicker : public ColorPickerBase { public: explicit ColorPicker(); @@ -1255,12 +1266,11 @@ com_sun_star_cui_ColorPicker_get_implementation( } -constexpr OUStringLiteral gsColorKey( u"Color" ); +constexpr OUString gsColorKey( u"Color"_ustr ); constexpr OUStringLiteral gsModeKey( u"Mode" ); ColorPicker::ColorPicker() - : ColorPickerBase( m_aMutex ) - , mnColor( 0 ) + : mnColor( 0 ) , mnMode( 0 ) { } @@ -1335,12 +1345,13 @@ void SAL_CALL ColorPicker::setDialogTitle( const OUString& ) void SAL_CALL ColorPicker::startExecuteModal( const css::uno::Reference< css::ui::dialogs::XDialogClosedListener >& xListener ) { std::shared_ptr<ColorPickerDialog> xDlg = std::make_shared<ColorPickerDialog>(Application::GetFrameWeld(mxParent), mnColor, mnMode); - weld::DialogController::runAsync(xDlg, [this, xDlg, xListener] (sal_Int32 nResult) { + rtl::Reference<ColorPicker> xThis(this); + weld::DialogController::runAsync(xDlg, [xThis=std::move(xThis), xDlg, xListener] (sal_Int32 nResult) { if (nResult) - mnColor = xDlg->GetColor(); + xThis->mnColor = xDlg->GetColor(); sal_Int16 nRet = static_cast<sal_Int16>(nResult); - css::ui::dialogs::DialogClosedEvent aEvent( *this, nRet ); + css::ui::dialogs::DialogClosedEvent aEvent( *xThis, nRet ); xListener->dialogClosed( aEvent ); }); } diff --git a/cui/source/dialogs/cuicharmap.cxx b/cui/source/dialogs/cuicharmap.cxx deleted file mode 100644 index b5a6dc106aae..000000000000 --- a/cui/source/dialogs/cuicharmap.cxx +++ /dev/null @@ -1,1277 +0,0 @@ -/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ -/* - * This file is part of the LibreOffice project. - * - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. - * - * This file incorporates work covered by the following license notice: - * - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed - * with this work for additional information regarding copyright - * ownership. The ASF licenses this file to you under the Apache - * License, Version 2.0 (the "License"); you may not use this file - * except in compliance with the License. You may obtain a copy of - * the License at http://www.apache.org/licenses/LICENSE-2.0 . - */ - -#include <sal/config.h> - -#include <stdio.h> - -#include <vcl/svapp.hxx> -#include <svl/eitem.hxx> -#include <svl/intitem.hxx> -#include <svl/itempool.hxx> - -#include <rtl/textenc.h> -#include <svx/ucsubset.hxx> -#include <vcl/settings.hxx> -#include <vcl/fontcharmap.hxx> -#include <vcl/virdev.hxx> -#include <svl/stritem.hxx> -#include <o3tl/temporary.hxx> -#include <officecfg/Office/Common.hxx> -#include <com/sun/star/beans/PropertyValue.hpp> -#include <comphelper/processfactory.hxx> -#include <comphelper/propertyvalue.hxx> -#include <comphelper/dispatchcommand.hxx> - -#include <dialmgr.hxx> -#include <cui/cuicharmap.hxx> -#include <sfx2/app.hxx> -#include <svx/svxids.hrc> -#include <editeng/editids.hrc> -#include <editeng/fontitem.hxx> -#include <strings.hrc> -#include <unicode/uchar.h> -#include <unicode/utypes.h> - -using namespace css; - -SvxCharacterMap::SvxCharacterMap(weld::Widget* pParent, const SfxItemSet* pSet, - const css::uno::Reference<css::frame::XFrame>& rFrame) - : SfxDialogController(pParent, "cui/ui/specialcharacters.ui", "SpecialCharactersDialog") - , m_xVirDev(VclPtr<VirtualDevice>::Create()) - , isSearchMode(true) - , m_xFrame(rFrame) - , mxContext(comphelper::getProcessComponentContext()) - , m_aRecentCharView{SvxCharView(m_xVirDev), - SvxCharView(m_xVirDev), - SvxCharView(m_xVirDev), - SvxCharView(m_xVirDev), - SvxCharView(m_xVirDev), - SvxCharView(m_xVirDev), - SvxCharView(m_xVirDev), - SvxCharView(m_xVirDev), - SvxCharView(m_xVirDev), - SvxCharView(m_xVirDev), - SvxCharView(m_xVirDev), - SvxCharView(m_xVirDev), - SvxCharView(m_xVirDev), - SvxCharView(m_xVirDev), - SvxCharView(m_xVirDev), - SvxCharView(m_xVirDev)} - , m_aFavCharView{SvxCharView(m_xVirDev), - SvxCharView(m_xVirDev), - SvxCharView(m_xVirDev), - SvxCharView(m_xVirDev), - SvxCharView(m_xVirDev), - SvxCharView(m_xVirDev), - SvxCharView(m_xVirDev), - SvxCharView(m_xVirDev), - SvxCharView(m_xVirDev), - SvxCharView(m_xVirDev), - SvxCharView(m_xVirDev), - SvxCharView(m_xVirDev), - SvxCharView(m_xVirDev), - SvxCharView(m_xVirDev), - SvxCharView(m_xVirDev), - SvxCharView(m_xVirDev)} - , m_aShowChar(m_xVirDev) - , m_xOKBtn(m_xFrame.is() ? m_xBuilder->weld_button("insert") : m_xBuilder->weld_button("ok")) - , m_xFontText(m_xBuilder->weld_label("fontft")) - , m_xFontLB(m_xBuilder->weld_combo_box("fontlb")) - , m_xSubsetText(m_xBuilder->weld_label("subsetft")) - , m_xSubsetLB(m_xBuilder->weld_combo_box("subsetlb")) - , m_xSearchText(m_xBuilder->weld_entry("search")) - , m_xHexCodeText(m_xBuilder->weld_entry("hexvalue")) - , m_xDecimalCodeText(m_xBuilder->weld_entry("decimalvalue")) - , m_xFavouritesBtn(m_xBuilder->weld_button("favbtn")) - , m_xCharName(m_xBuilder->weld_label("charname")) - , m_xRecentGrid(m_xBuilder->weld_widget("viewgrid")) - , m_xFavGrid(m_xBuilder->weld_widget("favgrid")) - , m_xShowChar(new weld::CustomWeld(*m_xBuilder, "showchar", m_aShowChar)) - , m_xRecentCharView{std::make_unique<weld::CustomWeld>(*m_xBuilder, "viewchar1", m_aRecentCharView[0]), - std::make_unique<weld::CustomWeld>(*m_xBuilder, "viewchar2", m_aRecentCharView[1]), - std::make_unique<weld::CustomWeld>(*m_xBuilder, "viewchar3", m_aRecentCharView[2]), - std::make_unique<weld::CustomWeld>(*m_xBuilder, "viewchar4", m_aRecentCharView[3]), - std::make_unique<weld::CustomWeld>(*m_xBuilder, "viewchar5", m_aRecentCharView[4]), - std::make_unique<weld::CustomWeld>(*m_xBuilder, "viewchar6", m_aRecentCharView[5]), - std::make_unique<weld::CustomWeld>(*m_xBuilder, "viewchar7", m_aRecentCharView[6]), - std::make_unique<weld::CustomWeld>(*m_xBuilder, "viewchar8", m_aRecentCharView[7]), - std::make_unique<weld::CustomWeld>(*m_xBuilder, "viewchar9", m_aRecentCharView[8]), - std::make_unique<weld::CustomWeld>(*m_xBuilder, "viewchar10", m_aRecentCharView[9]), - std::make_unique<weld::CustomWeld>(*m_xBuilder, "viewchar11", m_aRecentCharView[10]), - std::make_unique<weld::CustomWeld>(*m_xBuilder, "viewchar12", m_aRecentCharView[11]), - std::make_unique<weld::CustomWeld>(*m_xBuilder, "viewchar13", m_aRecentCharView[12]), - std::make_unique<weld::CustomWeld>(*m_xBuilder, "viewchar14", m_aRecentCharView[13]), - std::make_unique<weld::CustomWeld>(*m_xBuilder, "viewchar15", m_aRecentCharView[14]), - std::make_unique<weld::CustomWeld>(*m_xBuilder, "viewchar16", m_aRecentCharView[15])} - , m_xFavCharView{std::make_unique<weld::CustomWeld>(*m_xBuilder, "favchar1", m_aFavCharView[0]), - std::make_unique<weld::CustomWeld>(*m_xBuilder, "favchar2", m_aFavCharView[1]), - std::make_unique<weld::CustomWeld>(*m_xBuilder, "favchar3", m_aFavCharView[2]), - std::make_unique<weld::CustomWeld>(*m_xBuilder, "favchar4", m_aFavCharView[3]), - std::make_unique<weld::CustomWeld>(*m_xBuilder, "favchar5", m_aFavCharView[4]), - std::make_unique<weld::CustomWeld>(*m_xBuilder, "favchar6", m_aFavCharView[5]), - std::make_unique<weld::CustomWeld>(*m_xBuilder, "favchar7", m_aFavCharView[6]), - std::make_unique<weld::CustomWeld>(*m_xBuilder, "favchar8", m_aFavCharView[7]), - std::make_unique<weld::CustomWeld>(*m_xBuilder, "favchar9", m_aFavCharView[8]), - std::make_unique<weld::CustomWeld>(*m_xBuilder, "favchar10", m_aFavCharView[9]), - std::make_unique<weld::CustomWeld>(*m_xBuilder, "favchar11", m_aFavCharView[10]), - std::make_unique<weld::CustomWeld>(*m_xBuilder, "favchar12", m_aFavCharView[11]), - std::make_unique<weld::CustomWeld>(*m_xBuilder, "favchar13", m_aFavCharView[12]), - std::make_unique<weld::CustomWeld>(*m_xBuilder, "favchar14", m_aFavCharView[13]), - std::make_unique<weld::CustomWeld>(*m_xBuilder, "favchar15", m_aFavCharView[14]), - std::make_unique<weld::CustomWeld>(*m_xBuilder, "favchar16", m_aFavCharView[15])} - , m_xShowSet(new SvxShowCharSet(m_xBuilder->weld_scrolled_window("showscroll", true), m_xVirDev)) - , m_xShowSetArea(new weld::CustomWeld(*m_xBuilder, "showcharset", *m_xShowSet)) - , m_xSearchSet(new SvxSearchCharSet(m_xBuilder->weld_scrolled_window("searchscroll", true), m_xVirDev)) - , m_xSearchSetArea(new weld::CustomWeld(*m_xBuilder, "searchcharset", *m_xSearchSet)) -{ - m_aShowChar.SetCentered(true); - m_xFontLB->make_sorted(); - //lock the size request of this widget to the width of all possible entries - fillAllSubsets(*m_xSubsetLB); - m_xSubsetLB->set_size_request(m_xSubsetLB->get_preferred_size().Width(), -1); - m_xCharName->set_size_request(m_aShowChar.get_preferred_size().Width(), m_xCharName->get_text_height() * 4); - //lock the size request of this widget to the width of the original .ui string - m_xHexCodeText->set_size_request(m_xHexCodeText->get_preferred_size().Width(), -1); - //so things don't jump around if all the children are hidden - m_xRecentGrid->set_size_request(-1, m_aRecentCharView[0].get_preferred_size().Height()); - m_xFavGrid->set_size_request(-1, m_aFavCharView[0].get_preferred_size().Height()); - - init(); - - const SfxInt32Item* pCharItem = SfxItemSet::GetItem<SfxInt32Item>(pSet, SID_ATTR_CHAR, false); - if ( pCharItem ) - SetChar( pCharItem->GetValue() ); - - const SfxBoolItem* pDisableItem = SfxItemSet::GetItem<SfxBoolItem>(pSet, FN_PARAM_2, false); - if ( pDisableItem && pDisableItem->GetValue() ) - DisableFontSelection(); - - const SvxFontItem* pFontItem = SfxItemSet::GetItem<SvxFontItem>(pSet, SID_ATTR_CHAR_FONT, false); - const SfxStringItem* pFontNameItem = SfxItemSet::GetItem<SfxStringItem>(pSet, SID_FONT_NAME, false); - if ( pFontItem ) - { - vcl::Font aTmpFont( pFontItem->GetFamilyName(), pFontItem->GetStyleName(), GetCharFont().GetFontSize() ); - aTmpFont.SetCharSet( pFontItem->GetCharSet() ); - aTmpFont.SetPitch( pFontItem->GetPitch() ); - SetCharFont( aTmpFont ); - } - else if ( pFontNameItem ) - { - vcl::Font aTmpFont( GetCharFont() ); - aTmpFont.SetFamilyName( pFontNameItem->GetValue() ); - SetCharFont( aTmpFont ); - } - - m_xOutputSet.reset(new SfxAllItemSet(pSet ? *pSet->GetPool() : SfxGetpApp()->GetPool())); - m_xShowSet->Show(); - m_xSearchSet->Hide(); -} - -short SvxCharacterMap::run() -{ - if( SvxShowCharSet::getSelectedChar() == ' ') - { - m_xOKBtn->set_sensitive(false); - setFavButtonState(u"", u""); - } - else - { - sal_UCS4 cChar = m_xShowSet->GetSelectCharacter(); - // using the new UCS4 constructor - OUString aOUStr( &cChar, 1 ); - m_aShowChar.SetText(aOUStr); - - setFavButtonState(aOUStr, m_aShowChar.GetFont().GetFamilyName()); - m_xOKBtn->set_sensitive(true); - } - - return SfxDialogController::run(); -} - -void SvxCharacterMap::SetChar( sal_UCS4 c ) -{ - m_xShowSet->SelectCharacter( c ); - setFavButtonState(OUString(&c, 1), aFont.GetFamilyName()); -} - -sal_UCS4 SvxCharacterMap::GetChar() const -{ - return m_aShowChar.GetText().iterateCodePoints(&o3tl::temporary(sal_Int32(0))); -} - -void SvxCharacterMap::DisableFontSelection() -{ - m_xFontText->set_sensitive(false); - m_xFontLB->set_sensitive(false); -} - - -void SvxCharacterMap::getRecentCharacterList() -{ - //retrieve recent character list - const css::uno::Sequence< OUString > rRecentCharList( officecfg::Office::Common::RecentCharacters::RecentCharacterList::get() ); - for (OUString const & s : rRecentCharList) - { - maRecentCharList.push_back(s); - } - - //retrieve recent character font list - const css::uno::Sequence< OUString > rRecentCharFontList( officecfg::Office::Common::RecentCharacters::RecentCharacterFontList::get() ); - for (OUString const & s : rRecentCharFontList) - { - maRecentCharFontList.push_back(s); - } - - // tdf#135997: make sure that the two lists are same length - const auto nCommonLength = std::min(maRecentCharList.size(), maRecentCharFontList.size()); - maRecentCharList.resize(nCommonLength); - maRecentCharFontList.resize(nCommonLength); -} - - -void SvxCharacterMap::getFavCharacterList() -{ - maFavCharList.clear(); - maFavCharFontList.clear(); - //retrieve recent character list - const css::uno::Sequence< OUString > rFavCharList( officecfg::Office::Common::FavoriteCharacters::FavoriteCharacterList::get() ); - for (const OUString& s : rFavCharList) - { - maFavCharList.push_back(s); - } - - //retrieve recent character font list - const css::uno::Sequence< OUString > rFavCharFontList( officecfg::Office::Common::FavoriteCharacters::FavoriteCharacterFontList::get() ); - for (const OUString& s : rFavCharFontList) - { - maFavCharFontList.push_back(s); - } - - // tdf#135997: make sure that the two lists are same length - const auto nCommonLength = std::min(maFavCharList.size(), maFavCharFontList.size()); - maFavCharList.resize(nCommonLength); - maFavCharFontList.resize(nCommonLength); -} - -static std::pair<std::deque<OUString>::const_iterator, std::deque<OUString>::const_iterator> -findInPair(std::u16string_view str1, const std::deque<OUString>& rContainer1, - std::u16string_view str2, const std::deque<OUString>& rContainer2) -{ - assert(rContainer1.size() == rContainer2.size()); - - if (auto it1 = std::find(rContainer1.begin(), rContainer1.end(), str1); - it1 != rContainer1.end()) - { - auto it2 = rContainer2.begin() + (it1 - rContainer1.begin()); - if (*it2 == str2) - return { it1, it2 }; - } - return { rContainer1.end(), rContainer2.end() }; -} - -std::pair<std::deque<OUString>::const_iterator, std::deque<OUString>::const_iterator> -SvxCharacterMap::getRecentChar(std::u16string_view sTitle, std::u16string_view rFont) const -{ - return findInPair(sTitle, maRecentCharList, rFont, maRecentCharFontList); -} - -std::pair<std::deque<OUString>::const_iterator, std::deque<OUString>::const_iterator> -SvxCharacterMap::getFavChar(std::u16string_view sTitle, std::u16string_view rFont) const -{ - return findInPair(sTitle, maFavCharList, rFont, maFavCharFontList); -} - - -void SvxCharacterMap::updateRecentCharControl() -{ - assert(maRecentCharList.size() == maRecentCharFontList.size()); - - int i = 0; - for ( std::deque< OUString >::iterator it = maRecentCharList.begin(), it2 = maRecentCharFontList.begin(); - it != maRecentCharList.end() && it2 != maRecentCharFontList.end(); - ++it, ++it2, i++) - { - m_aRecentCharView[i].SetText(*it); - vcl::Font rFont = m_aRecentCharView[i].GetFont(); - rFont.SetFamilyName( *it2 ); - m_aRecentCharView[i].SetFont(rFont); - m_aRecentCharView[i].Show(); - } - - for(; i < 16 ; i++) - { - m_aRecentCharView[i].SetText(OUString()); - m_aRecentCharView[i].Hide(); - } -} - -void SvxCharacterMap::updateRecentCharacterList(const OUString& sTitle, const OUString& rFont) -{ - // if recent char to be added is already in list, remove it - if( const auto& [itChar, itChar2] = getRecentChar(sTitle, rFont); - itChar != maRecentCharList.end() && itChar2 != maRecentCharFontList.end() ) - { - maRecentCharList.erase( itChar ); - maRecentCharFontList.erase( itChar2); - } - - if (maRecentCharList.size() == 16) - { - maRecentCharList.pop_back(); - maRecentCharFontList.pop_back(); - } - - maRecentCharList.push_front(sTitle); - maRecentCharFontList.push_front(rFont); - - css::uno::Sequence< OUString > aRecentCharList(maRecentCharList.size()); - auto aRecentCharListRange = asNonConstRange(aRecentCharList); - css::uno::Sequence< OUString > aRecentCharFontList(maRecentCharFontList.size()); - auto aRecentCharFontListRange = asNonConstRange(aRecentCharFontList); - - for (size_t i = 0; i < maRecentCharList.size(); ++i) - { - aRecentCharListRange[i] = maRecentCharList[i]; - aRecentCharFontListRange[i] = maRecentCharFontList[i]; - } - - std::shared_ptr<comphelper::ConfigurationChanges> batch(comphelper::ConfigurationChanges::create(mxContext)); - officecfg::Office::Common::RecentCharacters::RecentCharacterList::set(aRecentCharList, batch); - officecfg::Office::Common::RecentCharacters::RecentCharacterFontList::set(aRecentCharFontList, batch); - batch->commit(); - - updateRecentCharControl(); -} - - -void SvxCharacterMap::updateFavCharacterList(const OUString& sTitle, const OUString& rFont) -{ - // if Fav char to be added is already in list, remove it - if( const auto& [itChar, itChar2] = getFavChar(sTitle, rFont); - itChar != maFavCharList.end() && itChar2 != maFavCharFontList.end() ) - { - maFavCharList.erase( itChar ); - maFavCharFontList.erase( itChar2); - } - - if (maFavCharList.size() == 16) - { - maFavCharList.pop_back(); - maFavCharFontList.pop_back(); - } - - maFavCharList.push_back(sTitle); - maFavCharFontList.push_back(rFont); - - css::uno::Sequence< OUString > aFavCharList(maFavCharList.size()); - auto aFavCharListRange = asNonConstRange(aFavCharList); - css::uno::Sequence< OUString > aFavCharFontList(maFavCharFontList.size()); - auto aFavCharFontListRange = asNonConstRange(aFavCharFontList); - - for (size_t i = 0; i < maFavCharList.size(); ++i) - { - aFavCharListRange[i] = maFavCharList[i]; - aFavCharFontListRange[i] = maFavCharFontList[i]; - } - - std::shared_ptr<comphelper::ConfigurationChanges> batch(comphelper::ConfigurationChanges::create(mxContext)); - officecfg::Office::Common::FavoriteCharacters::FavoriteCharacterList::set(aFavCharList, batch); - officecfg::Office::Common::FavoriteCharacters::FavoriteCharacterFontList::set(aFavCharFontList, batch); - batch->commit(); -} - - -void SvxCharacterMap::updateFavCharControl() -{ - assert(maFavCharList.size() == maFavCharFontList.size()); - - int i = 0; - for ( std::deque< OUString >::iterator it = maFavCharList.begin(), it2 = maFavCharFontList.begin(); - it != maFavCharList.end() && it2 != maFavCharFontList.end(); - ++it, ++it2, i++) - { - m_aFavCharView[i].SetText(*it); - vcl::Font rFont = m_aFavCharView[i].GetFont(); - rFont.SetFamilyName( *it2 ); - m_aFavCharView[i].SetFont(rFont); - m_aFavCharView[i].Show(); - } - - for(; i < 16 ; i++) - { - m_aFavCharView[i].SetText(OUString()); - m_aFavCharView[i].Hide(); - } - m_xShowSet->getFavCharacterList(); - m_xSearchSet->getFavCharacterList(); -} - -void SvxCharacterMap::deleteFavCharacterFromList(std::u16string_view sTitle, std::u16string_view rFont) -{ - // if Fav char is found, remove it - if( const auto& [itChar, itChar2] = getFavChar(sTitle, rFont); - itChar != maFavCharList.end() && itChar2 != maFavCharFontList.end() ) - { - maFavCharList.erase( itChar ); - maFavCharFontList.erase( itChar2); - } - - css::uno::Sequence< OUString > aFavCharList(maFavCharList.size()); - auto aFavCharListRange = asNonConstRange(aFavCharList); - css::uno::Sequence< OUString > aFavCharFontList(maFavCharFontList.size()); - auto aFavCharFontListRange = asNonConstRange(aFavCharFontList); - - for (size_t i = 0; i < maFavCharList.size(); ++i) - { - aFavCharListRange[i] = maFavCharList[i]; - aFavCharFontListRange[i] = maFavCharFontList[i]; - } - - std::shared_ptr<comphelper::ConfigurationChanges> batch(comphelper::ConfigurationChanges::create(mxContext)); - officecfg::Office::Common::FavoriteCharacters::FavoriteCharacterList::set(aFavCharList, batch); - officecfg::Office::Common::FavoriteCharacters::FavoriteCharacterFontList::set(aFavCharFontList, batch); - batch->commit(); -} - -void SvxCharacterMap::init() -{ - aFont = m_xVirDev->GetFont(); - aFont.SetTransparent( true ); - aFont.SetFamily( FAMILY_DONTKNOW ); - aFont.SetPitch( PITCH_DONTKNOW ); - aFont.SetCharSet( RTL_TEXTENCODING_DONTKNOW ); - - OUString aDefStr( aFont.GetFamilyName() ); - OUString aLastName; - int nCount = m_xVirDev->GetFontFaceCollectionCount(); - std::vector<weld::ComboBoxEntry> aEntries; - aEntries.reserve(nCount); - for (int i = 0; i < nCount; ++i) - { - OUString aFontName( m_xVirDev->GetFontMetricFromCollection( i ).GetFamilyName() ); - if (aFontName != aLastName) - { - aLastName = aFontName; - aEntries.emplace_back(aFontName, OUString::number(i)); - } - } - m_xFontLB->insert_vector(aEntries, true); - // the font may not be in the list => - // try to find a font name token in list and select found font, - // else select topmost entry - bool bFound = (m_xFontLB->find_text(aDefStr) == -1); - if (!bFound) - { - sal_Int32 nIndex = 0; - do - { - OUString aToken = aDefStr.getToken(0, ';', nIndex); - if (m_xFontLB->find_text(aToken) != -1) - { - aDefStr = aToken; - bFound = true; - break; - } - } - while ( nIndex >= 0 ); - } - - if (bFound) - m_xFontLB->set_active_text(aDefStr); - else if (m_xFontLB->get_count() ) - m_xFontLB->set_active(0); - FontSelectHdl(*m_xFontLB); - if (m_xSubsetLB->get_count()) - m_xSubsetLB->set_active(0); - - m_xFontLB->connect_changed(LINK( this, SvxCharacterMap, FontSelectHdl)); - m_xSubsetLB->connect_changed(LINK( this, SvxCharacterMap, SubsetSelectHdl)); - m_xOKBtn->connect_clicked(LINK(this, SvxCharacterMap, InsertClickHdl)); - m_xOKBtn->show(); - - m_xShowSet->SetDoubleClickHdl( LINK( this, SvxCharacterMap, CharDoubleClickHdl ) ); - m_xShowSet->SetSelectHdl( LINK( this, SvxCharacterMap, CharSelectHdl ) ); - m_xShowSet->SetHighlightHdl( LINK( this, SvxCharacterMap, CharHighlightHdl ) ); - m_xShowSet->SetPreSelectHdl( LINK( this, SvxCharacterMap, CharPreSelectHdl ) ); - m_xShowSet->SetFavClickHdl( LINK( this, SvxCharacterMap, FavClickHdl ) ); - - m_xSearchSet->SetDoubleClickHdl( LINK( this, SvxCharacterMap, SearchCharDoubleClickHdl ) ); - m_xSearchSet->SetSelectHdl( LINK( this, SvxCharacterMap, SearchCharSelectHdl ) ); - m_xSearchSet->SetHighlightHdl( LINK( this, SvxCharacterMap, SearchCharHighlightHdl ) ); - m_xSearchSet->SetPreSelectHdl( LINK( this, SvxCharacterMap, SearchCharPreSelectHdl ) ); - m_xSearchSet->SetFavClickHdl( LINK( this, SvxCharacterMap, FavClickHdl ) ); - - m_xDecimalCodeText->connect_changed( LINK( this, SvxCharacterMap, DecimalCodeChangeHdl ) ); - m_xHexCodeText->connect_changed( LINK( this, SvxCharacterMap, HexCodeChangeHdl ) ); - m_xFavouritesBtn->connect_clicked( LINK(this, SvxCharacterMap, FavSelectHdl)); - - // tdf#117038 set the buttons width to its max possible width so it doesn't - // make layout change when the label changes - m_xFavouritesBtn->set_label(CuiResId(RID_SVXSTR_REMOVE_FAVORITES)); - auto nMaxWidth = m_xFavouritesBtn->get_preferred_size().Width(); - m_xFavouritesBtn->set_label(CuiResId(RID_SVXSTR_ADD_FAVORITES)); - nMaxWidth = std::max(nMaxWidth, m_xFavouritesBtn->get_preferred_size().Width()); - m_xFavouritesBtn->set_size_request(nMaxWidth, -1); - - if( SvxShowCharSet::getSelectedChar() == ' ') - { - m_xOKBtn->set_sensitive(false); - } - else - { - sal_UCS4 cChar = m_xShowSet->GetSelectCharacter(); - // using the new UCS4 constructor - OUString aOUStr( &cChar, 1 ); - m_aShowChar.SetText(aOUStr); - - setFavButtonState(aOUStr, aDefStr); - m_xOKBtn->set_sensitive(true); - } - - getRecentCharacterList(); - updateRecentCharControl(); - - getFavCharacterList(); - updateFavCharControl(); - - bool bHasInsert = m_xFrame.is(); - - for(int i = 0; i < 16; i++) - { - m_aRecentCharView[i].SetHasInsert(bHasInsert); - m_aRecentCharView[i].setMouseClickHdl(LINK(this,SvxCharacterMap, CharClickHdl)); - m_aRecentCharView[i].setClearClickHdl(LINK(this,SvxCharacterMap, RecentClearClickHdl)); - m_aRecentCharView[i].setClearAllClickHdl(LINK(this,SvxCharacterMap, RecentClearAllClickHdl)); - m_aFavCharView[i].SetHasInsert(bHasInsert); - m_aFavCharView[i].setMouseClickHdl(LINK(this,SvxCharacterMap, CharClickHdl)); - m_aFavCharView[i].setClearClickHdl(LINK(this,SvxCharacterMap, FavClearClickHdl)); - m_aFavCharView[i].setClearAllClickHdl(LINK(this,SvxCharacterMap, FavClearAllClickHdl)); - } - - setCharName(90); - - m_xSearchText->connect_focus_in(LINK( this, SvxCharacterMap, SearchFieldGetFocusHdl )); - m_xSearchText->connect_changed(LINK(this, SvxCharacterMap, SearchUpdateHdl)); -} - -bool SvxCharacterMap::isFavChar(std::u16string_view sTitle, std::u16string_view rFont) -{ - const auto& [itChar, itFont] = getFavChar(sTitle, rFont); - return itChar != maFavCharList.end() && itFont != maFavCharFontList.end(); -} - - -void SvxCharacterMap::setFavButtonState(std::u16string_view sTitle, std::u16string_view rFont) -{ - if(sTitle.empty() || rFont.empty()) - { - m_xFavouritesBtn->set_sensitive(false); - return; - } - else - m_xFavouritesBtn->set_sensitive(true); - - if (isFavChar(sTitle, rFont)) - { - m_xFavouritesBtn->set_label(CuiResId(RID_SVXSTR_REMOVE_FAVORITES)); - } - else - { - if(maFavCharList.size() == 16) - { - m_xFavouritesBtn->set_sensitive(false); - } - - m_xFavouritesBtn->set_label(CuiResId(RID_SVXSTR_ADD_FAVORITES)); - } -} - - -void SvxCharacterMap::SetCharFont( const vcl::Font& rFont ) -{ - // first get the underlying info in order to get font names - // like "Times New Roman;Times" resolved - vcl::Font aTmp(m_xVirDev->GetFontMetric(rFont)); - - if (aTmp.GetFamilyName() == "StarSymbol" && m_xFontLB->find_text(aTmp.GetFamilyName()) == -1) - { - //if for some reason, like font in an old document, StarSymbol is requested and it's not available, then - //try OpenSymbol instead - aTmp.SetFamilyName("OpenSymbol"); - } - - if (m_xFontLB->find_text(aTmp.GetFamilyName()) == -1) - return; - - m_xFontLB->set_active_text(aTmp.GetFamilyName()); - aFont = aTmp; - FontSelectHdl(*m_xFontLB); - if (m_xSubsetLB->get_count()) - m_xSubsetLB->set_active(0); -} - -void SvxCharacterMap::fillAllSubsets(weld::ComboBox& rListBox) -{ - SubsetMap aAll(nullptr); - std::vector<weld::ComboBoxEntry> aEntries; - for (auto & subset : aAll.GetSubsetMap()) - aEntries.emplace_back(subset.GetName()); - rListBox.insert_vector(aEntries, true); -} - -void SvxCharacterMap::insertCharToDoc(const OUString& sGlyph) -{ - if(sGlyph.isEmpty()) - return; - - if (m_xFrame.is()) { - uno::Sequence<beans::PropertyValue> aArgs{ - comphelper::makePropertyValue("Symbols", sGlyph), - comphelper::makePropertyValue("FontName", aFont.GetFamilyName()) - }; - comphelper::dispatchCommand(".uno:InsertSymbol", m_xFrame, aArgs); - - updateRecentCharacterList(sGlyph, aFont.GetFamilyName()); - - } else { - sal_UCS4 cChar = sGlyph.iterateCodePoints(&o3tl::temporary(sal_Int32(0))); - const SfxItemPool* pPool = m_xOutputSet->GetPool(); - m_xOutputSet->Put( SfxStringItem( pPool->GetWhich(SID_CHARMAP), sGlyph ) ); - m_xOutputSet->Put( SvxFontItem( aFont.GetFamilyType(), aFont.GetFamilyName(), - aFont.GetStyleName(), aFont.GetPitch(), aFont.GetCharSet(), pPool->GetWhich(SID_ATTR_CHAR_FONT) ) ); - m_xOutputSet->Put( SfxStringItem( pPool->GetWhich(SID_FONT_NAME), aFont.GetFamilyName() ) ); - m_xOutputSet->Put( SfxInt32Item( pPool->GetWhich(SID_ATTR_CHAR), cChar ) ); - } -} - -IMPL_LINK_NOARG(SvxCharacterMap, FontSelectHdl, weld::ComboBox&, void) -{ - const sal_uInt32 nFont = m_xFontLB->get_active_id().toUInt32(); - aFont = m_xVirDev->GetFontMetricFromCollection(nFont); - aFont.SetWeight( WEIGHT_DONTKNOW ); - aFont.SetItalic( ITALIC_NONE ); - aFont.SetWidthType( WIDTH_DONTKNOW ); - aFont.SetPitch( PITCH_DONTKNOW ); - aFont.SetFamily( FAMILY_DONTKNOW ); - - // notify children using this font - m_xShowSet->SetFont( aFont ); - m_xSearchSet->SetFont( aFont ); - m_aShowChar.SetFont( aFont ); - - // setup unicode subset listbar with font specific subsets, - // hide unicode subset listbar for symbol fonts - // TODO: get info from the Font once it provides it - pSubsetMap.reset(); - m_xSubsetLB->clear(); - - bool bNeedSubset = (aFont.GetCharSet() != RTL_TEXTENCODING_SYMBOL); - if (bNeedSubset) - { - FontCharMapRef xFontCharMap = m_xShowSet->GetFontCharMap(); - pSubsetMap.reset(new SubsetMap( xFontCharMap )); - - // update subset listbox for new font's unicode subsets - for (auto const& subset : pSubsetMap->GetSubsetMap()) - { - m_xSubsetLB->append(OUString::number(reinterpret_cast<sal_uInt64>(&subset)), subset.GetName()); - // NOTE: subset must live at least as long as the selected font - } - - if (m_xSubsetLB->get_count() <= 1) - bNeedSubset = false; - } - - m_xSubsetText->set_sensitive(bNeedSubset); - m_xSubsetLB->set_sensitive(bNeedSubset); - - if (isSearchMode) - { - // tdf#137294 do this after modifying m_xSubsetLB sensitivity to - // restore insensitive for the search case - SearchUpdateHdl(*m_xSearchText); - SearchCharHighlightHdl(m_xSearchSet.get()); - } - - // tdf#118304 reselect current glyph to see if its still there in new font - selectCharByCode(Radix::hexadecimal); -} - -void SvxCharacterMap::toggleSearchView(bool state) -{ - isSearchMode = state; - m_xHexCodeText->set_editable(!state); - m_xDecimalCodeText->set_editable(!state); - m_xSubsetLB->set_sensitive(!state); - - if(state) - { - m_xSearchSet->Show(); - m_xShowSet->Hide(); - } - else - { - m_xSearchSet->Hide(); - m_xShowSet->Show(); - } -} - -void SvxCharacterMap::setCharName(sal_UCS4 nDecimalValue) -{ - /* get the character name */ - UErrorCode errorCode = U_ZERO_ERROR; - // icu has a private uprv_getMaxCharNameLength function which returns the max possible - // length of this property. Unicode 3.2 max char name length was 83 - char buffer[100]; - u_charName(nDecimalValue, U_UNICODE_CHAR_NAME, buffer, sizeof(buffer), &errorCode); - if (U_SUCCESS(errorCode)) - m_xCharName->set_label(OUString::createFromAscii(buffer)); -} - -IMPL_LINK_NOARG(SvxCharacterMap, SubsetSelectHdl, weld::ComboBox&, void) -{ - const sal_Int32 nPos = m_xSubsetLB->get_active(); - const Subset* pSubset = reinterpret_cast<const Subset*>(m_xSubsetLB->get_active_id().toUInt64()); - - if( pSubset && !isSearchMode) - { - sal_UCS4 cFirst = pSubset->GetRangeMin(); - m_xShowSet->SelectCharacter( cFirst ); - - setFavButtonState(OUString(&cFirst, 1), aFont.GetFamilyName()); - m_xSubsetLB->set_active(nPos); - } - else if( pSubset && isSearchMode) - { - m_xSearchSet->SelectCharacter( pSubset ); - - const Subset* curSubset = nullptr; - if( pSubsetMap ) - curSubset = pSubsetMap->GetSubsetByUnicode( m_xSearchSet->GetSelectCharacter() ); - if( curSubset ) - m_xSubsetLB->set_active_text(curSubset->GetName()); - else - m_xSubsetLB->set_active(-1); - - sal_UCS4 sChar = m_xSearchSet->GetSelectCharacter(); - setFavButtonState(OUString(&sChar, 1), aFont.GetFamilyName()); - } -} - -IMPL_LINK(SvxCharacterMap, RecentClearClickHdl, SvxCharView*, rView, void) -{ - const OUString& sTitle = rView->GetText(); - OUString sFont = rView->GetFont().GetFamilyName(); - - // if recent char to be added is already in list, remove it - if( const auto& [itChar, itChar2] = getRecentChar(sTitle, sFont); - itChar != maRecentCharList.end() && itChar2 != maRecentCharFontList.end() ) - { - maRecentCharList.erase( itChar ); - maRecentCharFontList.erase( itChar2); - } - - css::uno::Sequence< OUString > aRecentCharList(maRecentCharList.size()); - auto aRecentCharListRange = asNonConstRange(aRecentCharList); - css::uno::Sequence< OUString > aRecentCharFontList(maRecentCharFontList.size()); - auto aRecentCharFontListRange = asNonConstRange(aRecentCharFontList); - - for (size_t i = 0; i < maRecentCharList.size(); ++i) - { - aRecentCharListRange[i] = maRecentCharList[i]; - aRecentCharFontListRange[i] = maRecentCharFontList[i]; - } - - std::shared_ptr<comphelper::ConfigurationChanges> batch(comphelper::ConfigurationChanges::create(mxContext)); - officecfg::Office::Common::RecentCharacters::RecentCharacterList::set(aRecentCharList, batch); - officecfg::Office::Common::RecentCharacters::RecentCharacterFontList::set(aRecentCharFontList, batch); - batch->commit(); - - updateRecentCharControl(); -} - -IMPL_LINK_NOARG(SvxCharacterMap, RecentClearAllClickHdl, SvxCharView*, void) -{ - css::uno::Sequence< OUString > aRecentCharList(0); - css::uno::Sequence< OUString > aRecentCharFontList(0); - - maRecentCharList.clear(); - maRecentCharFontList.clear(); - - std::shared_ptr<comphelper::ConfigurationChanges> batch(comphelper::ConfigurationChanges::create(mxContext)); - officecfg::Office::Common::RecentCharacters::RecentCharacterList::set(aRecentCharList, batch); - officecfg::Office::Common::RecentCharacters::RecentCharacterFontList::set(aRecentCharFontList, batch); - batch->commit(); - - updateRecentCharControl(); -} - -IMPL_LINK(SvxCharacterMap, FavClearClickHdl, SvxCharView*, rView, void) -{ - deleteFavCharacterFromList(rView->GetText(), rView->GetFont().GetFamilyName()); - updateFavCharControl(); -} - -IMPL_LINK_NOARG(SvxCharacterMap, FavClearAllClickHdl, SvxCharView*, void) -{ - css::uno::Sequence< OUString > aFavCharList(0); - css::uno::Sequence< OUString > aFavCharFontList(0); - - maFavCharList.clear(); - maFavCharFontList.clear(); - - std::shared_ptr<comphelper::ConfigurationChanges> batch(comphelper::ConfigurationChanges::create(mxContext)); - officecfg::Office::Common::FavoriteCharacters::FavoriteCharacterList::set(aFavCharList, batch); - officecfg::Office::Common::FavoriteCharacters::FavoriteCharacterFontList::set(aFavCharFontList, batch); - batch->commit(); - - updateFavCharControl(); -} - -IMPL_LINK_NOARG(SvxCharacterMap, SearchFieldGetFocusHdl, weld::Widget&, void) -{ - m_xOKBtn->set_sensitive(false); -} - -IMPL_LINK_NOARG(SvxCharacterMap, SearchUpdateHdl, weld::Entry&, void) -{ - if (!m_xSearchText->get_text().isEmpty()) - { - m_xSearchSet->ClearPreviousData(); - OUString aKeyword = m_xSearchText->get_text(); - - toggleSearchView(true); - - FontCharMapRef xFontCharMap = m_xSearchSet->GetFontCharMap(); - - sal_UCS4 sChar = xFontCharMap->GetFirstChar(); - while(sChar != xFontCharMap->GetLastChar()) - { - UErrorCode errorCode = U_ZERO_ERROR; - char buffer[100]; - u_charName(sChar, U_UNICODE_CHAR_NAME, buffer, sizeof(buffer), &errorCode); - if (U_SUCCESS(errorCode)) - { - OUString sName = OUString::createFromAscii(buffer); - if(!sName.isEmpty() && sName.toAsciiLowerCase().indexOf(aKeyword.toAsciiLowerCase()) >= 0) - m_xSearchSet->AppendCharToList(sChar); - } - sChar = xFontCharMap->GetNextChar(sChar); - } - //for last char - UErrorCode errorCode = U_ZERO_ERROR; - char buffer[100]; - u_charName(sChar, U_UNICODE_CHAR_NAME, buffer, sizeof(buffer), &errorCode); - if (U_SUCCESS(errorCode)) - { - OUString sName = OUString::createFromAscii(buffer); - if(!sName.isEmpty() && sName.toAsciiLowerCase().indexOf(aKeyword.toAsciiLowerCase()) >= 0) - m_xSearchSet->AppendCharToList(sChar); - } - } - else - { - toggleSearchView(false); - } -} - - -IMPL_LINK(SvxCharacterMap, CharClickHdl, SvxCharView*, rView, void) -{ - rView->GrabFocus(); - - m_aShowChar.SetText( rView->GetText() ); - m_aShowChar.SetFont(rView->GetFont()); - m_aShowChar.Invalidate(); - - setFavButtonState(rView->GetText(), rView->GetFont().GetFamilyName());//check state - - // Get the hexadecimal code - OUString charValue = rView->GetText(); - sal_UCS4 cChar = charValue.iterateCodePoints(&o3tl::temporary(sal_Int32(1)), -1); - OUString aHexText = OUString::number(cChar, 16).toAsciiUpperCase(); - - // Get the decimal code - OUString aDecimalText = OUString::number(cChar); - - m_xHexCodeText->set_text(aHexText); - m_xDecimalCodeText->set_text(aDecimalText); - setCharName(cChar); - - rView->Invalidate(); - m_xOKBtn->set_sensitive(true); -} - -IMPL_LINK_NOARG(SvxCharacterMap, CharDoubleClickHdl, SvxShowCharSet*, void) -{ - sal_UCS4 cChar = m_xShowSet->GetSelectCharacter(); - // using the new UCS4 constructor - OUString aOUStr( &cChar, 1 ); - setFavButtonState(aOUStr, aFont.GetFamilyName()); - insertCharToDoc(aOUStr); -} - -IMPL_LINK_NOARG(SvxCharacterMap, SearchCharDoubleClickHdl, SvxShowCharSet*, void) -{ - sal_UCS4 cChar = m_xSearchSet->GetSelectCharacter(); - // using the new UCS4 constructor - OUString aOUStr( &cChar, 1 ); - setFavButtonState(aOUStr, aFont.GetFamilyName()); - insertCharToDoc(aOUStr); -} - -IMPL_LINK_NOARG(SvxCharacterMap, CharSelectHdl, SvxShowCharSet*, void) -{ - m_xOKBtn->set_sensitive(true); -} - -IMPL_LINK_NOARG(SvxCharacterMap, SearchCharSelectHdl, SvxShowCharSet*, void) -{ - m_xOKBtn->set_sensitive(true); -} - -IMPL_LINK_NOARG(SvxCharacterMap, InsertClickHdl, weld::Button&, void) -{ - OUString sChar = m_aShowChar.GetText(); - insertCharToDoc(sChar); - // Need to update recent character list, when OK button does not insert - if(!m_xFrame.is()) - updateRecentCharacterList(sChar, aFont.GetFamilyName()); - m_xDialog->response(RET_OK); -} - -IMPL_LINK_NOARG(SvxCharacterMap, FavSelectHdl, weld::Button&, void) -{ - if (m_xFavouritesBtn->get_label().match(CuiResId(RID_SVXSTR_ADD_FAVORITES))) - { - updateFavCharacterList(m_aShowChar.GetText(), m_aShowChar.GetFont().GetFamilyName()); - setFavButtonState(m_aShowChar.GetText(), m_aShowChar.GetFont().GetFamilyName()); - } - else - { - deleteFavCharacterFromList(m_aShowChar.GetText(), m_aShowChar.GetFont().GetFamilyName()); - m_xFavouritesBtn->set_label(CuiResId(RID_SVXSTR_ADD_FAVORITES)); - m_xFavouritesBtn->set_sensitive(false); - } - - updateFavCharControl(); -} - -IMPL_LINK_NOARG(SvxCharacterMap, FavClickHdl, SvxShowCharSet*, void) -{ - getFavCharacterList(); - updateFavCharControl(); -} - -IMPL_LINK_NOARG(SvxCharacterMap, CharHighlightHdl, SvxShowCharSet*, void) -{ - OUString aText; - sal_UCS4 cChar = m_xShowSet->GetSelectCharacter(); - bool bSelect = (cChar > 0); - - // show char sample - if ( bSelect ) - { - // using the new UCS4 constructor - aText = OUString( &cChar, 1 ); - // Get the hexadecimal code - OUString aHexText = OUString::number(cChar, 16).toAsciiUpperCase(); - // Get the decimal code - OUString aDecimalText = OUString::number(cChar); - setCharName(cChar); - - // Update the hex and decimal codes only if necessary - if (!m_xHexCodeText->get_text().equalsIgnoreAsciiCase(aHexText)) - m_xHexCodeText->set_text(aHexText); - if (m_xDecimalCodeText->get_text() != aDecimalText) - m_xDecimalCodeText->set_text( aDecimalText ); - - const Subset* pSubset = nullptr; - if( pSubsetMap ) - pSubset = pSubsetMap->GetSubsetByUnicode( cChar ); - if( pSubset ) - m_xSubsetLB->set_active_text(pSubset->GetName()); - else - m_xSubsetLB->set_active(-1); - } - - m_aShowChar.SetText( aText ); - m_aShowChar.SetFont( aFont ); - m_aShowChar.Invalidate(); - - setFavButtonState(aText, aFont.GetFamilyName()); -} - -IMPL_LINK_NOARG(SvxCharacterMap, SearchCharHighlightHdl, SvxShowCharSet*, void) -{ - OUString aText; - sal_UCS4 cChar = m_xSearchSet->GetSelectCharacter(); - bool bSelect = (cChar > 0); - - // show char sample - if ( bSelect ) - { - aText = OUString( &cChar, 1 ); - // Get the hexadecimal code - OUString aHexText = OUString::number(cChar, 16).toAsciiUpperCase(); - // Get the decimal code - OUString aDecimalText = OUString::number(cChar); - setCharName(cChar); - - // Update the hex and decimal codes only if necessary - if (!m_xHexCodeText->get_text().equalsIgnoreAsciiCase(aHexText)) - m_xHexCodeText->set_text(aHexText); - if (m_xDecimalCodeText->get_text() != aDecimalText) - m_xDecimalCodeText->set_text( aDecimalText ); - - const Subset* pSubset = nullptr; - if( pSubsetMap ) - pSubset = pSubsetMap->GetSubsetByUnicode( cChar ); - if( pSubset ) - m_xSubsetLB->set_active_text(pSubset->GetName()); - else - m_xSubsetLB->set_active(-1); - } - - if(m_xSearchSet->HasFocus()) - { - m_aShowChar.SetText( aText ); - m_aShowChar.SetFont( aFont ); - m_aShowChar.Invalidate(); - - setFavButtonState(aText, aFont.GetFamilyName()); - } -} - -void SvxCharacterMap::selectCharByCode(Radix radix) -{ - OUString aCodeString; - switch(radix) - { - case Radix::decimal: - aCodeString = m_xDecimalCodeText->get_text(); - break; - case Radix::hexadecimal: - aCodeString = m_xHexCodeText->get_text(); - break; - } - // Convert the code back to a character using the appropriate radix - sal_UCS4 cChar = aCodeString.toUInt32(static_cast<sal_Int16> (radix)); - // Use FontCharMap::HasChar(sal_UCS4 cChar) to see if the desired character is in the font - FontCharMapRef xFontCharMap = m_xShowSet->GetFontCharMap(); - if (xFontCharMap->HasChar(cChar)) - // Select the corresponding character - SetChar(cChar); - else { - m_xCharName->set_label(CuiResId(RID_SVXSTR_MISSING_CHAR)); - m_aShowChar.SetText(" "); - switch(radix) - { - case Radix::decimal: - m_xHexCodeText->set_text(OUString::number(cChar, 16)); - break; - case Radix::hexadecimal: - m_xDecimalCodeText->set_text(OUString::number(cChar)); - break; - } - } -} - -IMPL_LINK_NOARG(SvxCharacterMap, DecimalCodeChangeHdl, weld::Entry&, void) -{ - selectCharByCode(Radix::decimal); -} - -IMPL_LINK_NOARG(SvxCharacterMap, HexCodeChangeHdl, weld::Entry&, void) -{ - selectCharByCode(Radix::hexadecimal); -} - -IMPL_LINK_NOARG(SvxCharacterMap, CharPreSelectHdl, SvxShowCharSet*, void) -{ - // adjust subset selection - if( pSubsetMap ) - { - sal_UCS4 cChar = m_xShowSet->GetSelectCharacter(); - - setFavButtonState(OUString(&cChar, 1), aFont.GetFamilyName()); - const Subset* pSubset = pSubsetMap->GetSubsetByUnicode( cChar ); - if( pSubset ) - m_xSubsetLB->set_active_text(pSubset->GetName()); - } - - m_xOKBtn->set_sensitive(true); -} - -IMPL_LINK_NOARG(SvxCharacterMap, SearchCharPreSelectHdl, SvxShowCharSet*, void) -{ - // adjust subset selection - if( pSubsetMap ) - { - sal_UCS4 cChar = m_xSearchSet->GetSelectCharacter(); - - setFavButtonState(OUString(&cChar, 1), aFont.GetFamilyName()); - const Subset* pSubset = pSubsetMap->GetSubsetByUnicode( cChar ); - if( pSubset ) - m_xSubsetLB->set_active_text(pSubset->GetName()); - } - - m_xOKBtn->set_sensitive(true); -} - -// class SvxShowText ===================================================== -SvxShowText::SvxShowText(const VclPtr<VirtualDevice>& rVirDev) - : m_xVirDev(rVirDev) - , mnY(0) - , mbCenter(false) -{ -} - -void SvxShowText::SetDrawingArea(weld::DrawingArea* pDrawingArea) -{ - CustomWidgetController::SetDrawingArea(pDrawingArea); - vcl::Font aFont = m_xVirDev->GetFont(); - Size aFontSize(aFont.GetFontSize().Width() * 5, aFont.GetFontSize().Height() * 5); - aFont.SetFontSize(aFontSize); - m_xVirDev->Push(PUSH_ALLFONT); - m_xVirDev->SetFont(aFont); - pDrawingArea->set_size_request(m_xVirDev->approximate_digit_width() + 2 * 12, - m_xVirDev->LogicToPixel(aFontSize).Height() * 2); - m_xVirDev->Pop(); -} - -void SvxShowText::Paint(vcl::RenderContext& rRenderContext, const tools::Rectangle&) -{ - rRenderContext.SetFont(m_aFont); - - Color aTextCol = rRenderContext.GetTextColor(); - Color aFillCol = rRenderContext.GetFillColor(); - - const StyleSettings& rStyleSettings = Application::GetSettings().GetStyleSettings(); - const Color aWindowTextColor(rStyleSettings.GetDialogTextColor()); - const Color aWindowColor(rStyleSettings.GetWindowColor()); - rRenderContext.SetTextColor(aWindowTextColor); - rRenderContext.SetFillColor(aWindowColor); - - const OUString aText = GetText(); - - Size aSize(GetOutputSizePixel()); - tools::Long nAvailWidth = aSize.Width(); - tools::Long nWinHeight = aSize.Height(); - - bool bGotBoundary = true; - bool bShrankFont = false; - vcl::Font aOrigFont(rRenderContext.GetFont()); - Size aFontSize(aOrigFont.GetFontSize()); - ::tools::Rectangle aBoundRect; - - for (tools::Long nFontHeight = aFontSize.Height(); nFontHeight > 0; nFontHeight -= 5) - { - if (!rRenderContext.GetTextBoundRect( aBoundRect, aText ) || aBoundRect.IsEmpty()) - { - bGotBoundary = false; - break; - } - if (!mbCenter) - break; - //only shrink in the single glyph large view mode - tools::Long nTextWidth = aBoundRect.GetWidth(); - if (nAvailWidth > nTextWidth) - break; - vcl::Font aFont(aOrigFont); - aFontSize.setHeight( nFontHeight ); - aFont.SetFontSize(aFontSize); - rRenderContext.SetFont(aFont); - mnY = (nWinHeight - rRenderContext.GetTextHeight()) / 2; - bShrankFont = true; - } - - Point aPoint(2, mnY); - // adjust position using ink boundary if possible - if (!bGotBoundary) - aPoint.setX( (aSize.Width() - rRenderContext.GetTextWidth(aText)) / 2 ); - else - { - // adjust position before it gets out of bounds - aBoundRect += aPoint; - - // shift back vertically if needed - int nYLDelta = aBoundRect.Top(); - int nYHDelta = aSize.Height() - aBoundRect.Bottom(); - if( nYLDelta <= 0 ) - aPoint.AdjustY( -(nYLDelta - 1) ); - else if( nYHDelta <= 0 ) - aPoint.AdjustY(nYHDelta - 1 ); - - if (mbCenter) - { - // move glyph to middle of cell - aPoint.setX( -aBoundRect.Left() + (aSize.Width() - aBoundRect.GetWidth()) / 2 ); - } - else - { - // shift back horizontally if needed - int nXLDelta = aBoundRect.Left(); - int nXHDelta = aSize.Width() - aBoundRect.Right(); - if( nXLDelta <= 0 ) - aPoint.AdjustX( -(nXLDelta - 1) ); - else if( nXHDelta <= 0 ) - aPoint.AdjustX(nXHDelta - 1 ); - } - } - - rRenderContext.DrawRect(tools::Rectangle(Point(0, 0), aSize)); - rRenderContext.DrawText(aPoint, aText); - rRenderContext.SetTextColor(aTextCol); - rRenderContext.SetFillColor(aFillCol); - if (bShrankFont) - rRenderContext.SetFont(aOrigFont); -} - -void SvxShowText::SetFont( const vcl::Font& rFont ) -{ - tools::Long nWinHeight = GetOutputSizePixel().Height(); - - m_aFont = rFont; - m_aFont.SetWeight(WEIGHT_NORMAL); - m_aFont.SetAlignment(ALIGN_TOP); - m_aFont.SetFontSize(m_xVirDev->PixelToLogic(Size(0, nWinHeight / 2))); - m_aFont.SetTransparent(true); - - m_xVirDev->Push(PUSH_ALLFONT); - m_xVirDev->SetFont(m_aFont); - mnY = (nWinHeight - m_xVirDev->GetTextHeight()) / 2; - m_xVirDev->Pop(); - - Invalidate(); -} - -void SvxShowText::Resize() -{ - SetFont(GetFont()); //force recalculation of size -} - -void SvxShowText::SetText(const OUString& rText) -{ - m_sText = rText; - Invalidate(); -} - -/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/cui/source/dialogs/cuifmsearch.cxx b/cui/source/dialogs/cuifmsearch.cxx index 18f9cae66536..eff48a747fe7 100644 --- a/cui/source/dialogs/cuifmsearch.cxx +++ b/cui/source/dialogs/cuifmsearch.cxx @@ -31,12 +31,11 @@ #include <comphelper/processfactory.hxx> #include <comphelper/string.hxx> #include <svx/svxdlg.hxx> +#include <o3tl/string_view.hxx> using namespace css::uno; -using namespace css::i18n; using namespace ::svxform; using namespace css::sdbc; -using namespace css::util; #define MAX_HISTORY_ENTRIES 50 @@ -159,7 +158,7 @@ FmSearchDialog::~FmSearchDialog() m_pSearchEngine.reset(); } -void FmSearchDialog::Init(const OUString& strVisibleFields, const OUString& sInitialText) +void FmSearchDialog::Init(std::u16string_view strVisibleFields, const OUString& sInitialText) { //the initialization of all the Controls m_prbSearchForText->connect_toggled(LINK(this, FmSearchDialog, OnToggledSearchRadio)); @@ -203,11 +202,11 @@ void FmSearchDialog::Init(const OUString& strVisibleFields, const OUString& sIni m_plbPosition->set_active(MATCHING_ANYWHERE); // the field listbox - if (!strVisibleFields.isEmpty()) + if (!strVisibleFields.empty()) { sal_Int32 nPos {0}; do { - m_plbField->append_text(strVisibleFields.getToken(0, ';', nPos)); + m_plbField->append_text(OUString(o3tl::getToken(strVisibleFields, 0, ';', nPos))); } while (nPos>=0); } @@ -311,15 +310,20 @@ IMPL_LINK(FmSearchDialog, OnClickedSpecialSettings, weld::Button&, rButton, void if (m_ppbApproxSettings.get() == &rButton) { SvxAbstractDialogFactory* pFact = SvxAbstractDialogFactory::Create(); - ScopedVclPtr<AbstractSvxSearchSimilarityDialog> pDlg(pFact->CreateSvxSearchSimilarityDialog(m_xDialog.get(), m_pSearchEngine->GetLevRelaxed(), m_pSearchEngine->GetLevOther(), + + VclPtr<AbstractSvxSearchSimilarityDialog> pDlg(pFact->CreateSvxSearchSimilarityDialog(m_xDialog.get(), m_pSearchEngine->GetLevRelaxed(), m_pSearchEngine->GetLevOther(), m_pSearchEngine->GetLevShorter(), m_pSearchEngine->GetLevLonger() )); - if (pDlg->Execute() == RET_OK) + pDlg->StartExecuteAsync([pDlg, this](sal_Int32 nResult){ + + if (nResult == RET_OK) { m_pSearchEngine->SetLevRelaxed( pDlg->IsRelaxed() ); m_pSearchEngine->SetLevOther( pDlg->GetOther() ); m_pSearchEngine->SetLevShorter(pDlg->GetShorter() ); m_pSearchEngine->SetLevLonger( pDlg->GetLonger() ); } + pDlg->disposeOnce(); + }); } else if (m_pSoundsLikeCJKSettings.get() == &rButton) { diff --git a/cui/source/dialogs/cuigaldlg.cxx b/cui/source/dialogs/cuigaldlg.cxx index 118fb06cce00..9a1a2e26a4ed 100644 --- a/cui/source/dialogs/cuigaldlg.cxx +++ b/cui/source/dialogs/cuigaldlg.cxx @@ -24,6 +24,7 @@ #include <algorithm> #include <cassert> +#include <utility> #include <vcl/errinf.hxx> #include <ucbhelper/content.hxx> #include <vcl/svapp.hxx> @@ -46,13 +47,13 @@ #include <com/sun/star/sdbc/XRow.hpp> #include <com/sun/star/ucb/ContentCreationException.hpp> #include <com/sun/star/ucb/XContentAccess.hpp> -#include <com/sun/star/ui/dialogs/FolderPicker.hpp> #include <com/sun/star/ui/dialogs/XAsynchronousExecutableDialog.hpp> #include <dialmgr.hxx> #include <strings.hrc> #include <svx/dialmgr.hxx> #include <svx/strings.hrc> #include <osl/diagnose.h> +#include <o3tl/string_view.hxx> using namespace ::ucbhelper; using namespace ::cppu; @@ -65,11 +66,11 @@ using namespace ::com::sun::star::uno; SearchThread::SearchThread(SearchProgress* pProgress, TPGalleryThemeProperties* pBrowser, - const INetURLObject& rStartURL) + INetURLObject aStartURL) : Thread("cuiSearchThread") , mpProgress(pProgress) , mpBrowser(pBrowser) - , maStartURL(rStartURL) + , maStartURL(std::move(aStartURL)) { } @@ -188,9 +189,9 @@ void SearchThread::ImplSearch( const INetURLObject& rStartURL, } } -SearchProgress::SearchProgress(weld::Window* pParent, TPGalleryThemeProperties* pTabPage, const INetURLObject& rStartURL) +SearchProgress::SearchProgress(weld::Window* pParent, TPGalleryThemeProperties* pTabPage, INetURLObject aStartURL) : GenericDialogController(pParent, "cui/ui/gallerysearchprogress.ui", "GallerySearchProgress") - , startUrl_(rStartURL) + , startUrl_(std::move(aStartURL)) , m_pTabPage(pTabPage) , m_xFtSearchDir(m_xBuilder->weld_label("dir")) , m_xFtSearchType(m_xBuilder->weld_label("file")) @@ -335,7 +336,8 @@ IMPL_LINK_NOARG(TakeProgress, CleanUpHdl, void*, void) if( !aRemoveEntries[ i ] ) aRemainingVector.push_back( m_pTabPage->aFoundList[i] ); - m_pTabPage->aFoundList = std::move(aRemainingVector); + std::swap(m_pTabPage->aFoundList, aRemainingVector); + aRemainingVector.clear(); // refill list box for( i = 0, nCount = aRemoveEntries.size(); i < nCount; ++i ) @@ -343,10 +345,8 @@ IMPL_LINK_NOARG(TakeProgress, CleanUpHdl, void*, void) aRemainingVector.push_back(m_pTabPage->m_xLbxFound->get_text(i)); m_pTabPage->m_xLbxFound->clear(); - for( i = 0, nCount = aRemainingVector.size(); i < nCount; ++i ) m_pTabPage->m_xLbxFound->append_text(aRemainingVector[i]); - aRemainingVector.clear(); m_pTabPage->m_xLbxFound->thaw(); @@ -457,7 +457,7 @@ IMPL_LINK_NOARG(GalleryIdDialog, ClickOkHdl, weld::Button&, void) if ((pInfo->GetId() == nId) && (pInfo->GetThemeName() != m_pThm->GetName())) { - OUString aStr = CuiResId( RID_SVXSTR_GALLERY_ID_EXISTS ) + + OUString aStr = CuiResId( RID_CUISTR_GALLERY_ID_EXISTS ) + " (" + pInfo->GetThemeName() + ")"; std::unique_ptr<weld::MessageDialog> xInfoBox(Application::CreateMessageDialog(m_xDialog.get(), @@ -487,12 +487,12 @@ GalleryThemeProperties::GalleryThemeProperties(weld::Widget* pParent, OUString aText = m_xDialog->get_title().replaceFirst( "%1", pData->pTheme->GetName() ); if (pData->pTheme->IsReadOnly()) - aText += " " + CuiResId( RID_SVXSTR_GALLERY_READONLY ); + aText += " " + CuiResId( RID_CUISTR_GALLERY_READONLY ); m_xDialog->set_title(aText); } -void GalleryThemeProperties::PageCreated(const OString& rId, SfxTabPage &rPage) +void GalleryThemeProperties::PageCreated(const OUString& rId, SfxTabPage &rPage) { if (rId == "general") static_cast<TPGalleryThemeGeneral&>( rPage ).SetXChgData( pData ); @@ -518,7 +518,7 @@ void TPGalleryThemeGeneral::SetXChgData( ExchangeData* _pData ) GalleryTheme* pThm = pData->pTheme; OUString aOutStr( OUString::number(pThm->GetObjectCount()) ); - OUString aObjStr( CuiResId( RID_SVXSTR_GALLERYPROPS_OBJECT ) ); + OUString aObjStr( CuiResId( RID_CUISTR_GALLERYPROPS_OBJECT ) ); OUString aAccess; OUString aType( SvxResId( RID_SVXSTR_GALLERYPROPS_GALTHEME ) ); bool bReadOnly = pThm->IsReadOnly(); @@ -528,7 +528,7 @@ void TPGalleryThemeGeneral::SetXChgData( ExchangeData* _pData ) m_xEdtMSName->set_sensitive(!bReadOnly); if( pThm->IsReadOnly() ) - aType += CuiResId( RID_SVXSTR_GALLERY_READONLY ); + aType += CuiResId( RID_CUISTR_GALLERY_READONLY ); m_xFtMSShowType->set_label(aType); m_xFtMSShowPath->set_label(pThm->getThemeURL().GetMainURL(INetURLObject::DecodeMechanism::Unambiguous)); @@ -611,7 +611,7 @@ void TPGalleryThemeProperties::SetXChgData( ExchangeData* _pData ) m_xCbbFileType->connect_changed(LINK(this, TPGalleryThemeProperties, SelectFileTypeHdl)); m_xLbxFound->connect_row_activated(LINK(this, TPGalleryThemeProperties, DClickFoundHdl)); m_xLbxFound->connect_changed(LINK(this, TPGalleryThemeProperties, SelectFoundHdl)); - m_xLbxFound->append_text(CuiResId(RID_SVXSTR_GALLERY_NOFILES)); + m_xLbxFound->append_text(CuiResId(RID_CUISTR_GALLERY_NOFILES)); m_xLbxFound->show(); FillFilterList(); @@ -621,7 +621,7 @@ void TPGalleryThemeProperties::SetXChgData( ExchangeData* _pData ) m_xCbxPreview->set_sensitive(false); } -void TPGalleryThemeProperties::StartSearchFiles( const OUString& _rFolderURL, short _nDlgResult ) +void TPGalleryThemeProperties::StartSearchFiles( std::u16string_view _rFolderURL, short _nDlgResult ) { if ( RET_OK == _nDlgResult ) { @@ -707,7 +707,7 @@ void TPGalleryThemeProperties::FillFilterList() #if HAVE_FEATURE_AVMEDIA // media filters - static constexpr OUStringLiteral aWildcard = u"*."; + static constexpr OUString aWildcard = u"*."_ustr; ::avmedia::FilterNameVector aFilters= ::avmedia::MediaWindow::getMediaFilters(); for(const std::pair<OUString,OUString> & aFilter : aFilters) @@ -756,7 +756,7 @@ void TPGalleryThemeProperties::FillFilterList() { if ( !aExtensions.isEmpty() ) aExtensions += ";"; - aExtensions += aWildcard + aFilter.second.getToken( 0, ';', nIndex ); + aExtensions += OUString::Concat(aWildcard) + o3tl::getToken(aFilter.second, 0, ';', nIndex ); } } #endif @@ -767,7 +767,7 @@ void TPGalleryThemeProperties::FillFilterList() #endif std::unique_ptr<FilterEntry> pFilterEntry(new FilterEntry); - pFilterEntry->aFilterName = CuiResId(RID_SVXSTR_GALLERY_ALLFILES); + pFilterEntry->aFilterName = CuiResId(RID_CUISTR_GALLERY_ALLFILES); pFilterEntry->aFilterName = addExtension(pFilterEntry->aFilterName, aExtensions); m_xCbbFileType->insert_text(0, pFilterEntry->aFilterName); m_xCbbFileType->set_active(0); @@ -909,7 +909,7 @@ IMPL_LINK_NOARG(TPGalleryThemeProperties, ClickTakeHdl, weld::Button&, void) if (!m_xLbxFound->count_selected_rows() || !bEntriesFound) { - SvxOpenGraphicDialog aDlg(CuiResId(RID_SVXSTR_KEY_GALLERY_DIR), GetFrameWeld()); + SvxOpenGraphicDialog aDlg(CuiResId(RID_CUISTR_KEY_GALLERY_DIR), GetFrameWeld()); aDlg.EnableLink(false); aDlg.AsLink(false); @@ -991,7 +991,7 @@ void TPGalleryThemeProperties::EndSearchProgressHdl(sal_Int32 /*nResult*/) } else { - m_xLbxFound->append_text(CuiResId(RID_SVXSTR_GALLERY_NOFILES)); + m_xLbxFound->append_text(CuiResId(RID_CUISTR_GALLERY_NOFILES)); m_xBtnTakeAll->set_sensitive(false); m_xCbxPreview->set_sensitive(false); bEntriesFound = false; diff --git a/cui/source/dialogs/cuigrfflt.cxx b/cui/source/dialogs/cuigrfflt.cxx index c67ee92d141c..69896cd53c0d 100644 --- a/cui/source/dialogs/cuigrfflt.cxx +++ b/cui/source/dialogs/cuigrfflt.cxx @@ -124,7 +124,7 @@ void CuiGraphicPreviewWindow::Resize() } GraphicFilterDialog::GraphicFilterDialog(weld::Window* pParent, - const OUString& rUIXMLDescription, const OString& rID, + const OUString& rUIXMLDescription, const OUString& rID, const Graphic& rGraphic) : GenericDialogController(pParent, rUIXMLDescription, rID) , maTimer("cui GraphicFilterDialog maTimer") @@ -192,8 +192,8 @@ Graphic GraphicFilterMosaic::GetFilteredGraphic( const Graphic& rGraphic, Graphic aRet; tools::Long nTileWidth = static_cast<tools::Long>(mxMtrWidth->get_value(FieldUnit::PIXEL)); tools::Long nTileHeight = static_cast<tools::Long>(mxMtrHeight->get_value(FieldUnit::PIXEL)); - const Size aSize( std::max( FRound( nTileWidth * fScaleX ), tools::Long(1) ), - std::max( FRound( nTileHeight * fScaleY ), tools::Long(1) ) ); + const Size aSize( std::max( basegfx::fround<tools::Long>( nTileWidth * fScaleX ), tools::Long(1) ), + std::max( basegfx::fround<tools::Long>( nTileHeight * fScaleY ), tools::Long(1) ) ); if( rGraphic.IsAnimated() ) { @@ -270,7 +270,7 @@ GraphicFilterSolarize::GraphicFilterSolarize(weld::Window* pParent, const Graphi , mxMtrThreshold(m_xBuilder->weld_metric_spin_button("value", FieldUnit::PERCENT)) , mxCbxInvert(m_xBuilder->weld_check_button("invert")) { - mxMtrThreshold->set_value(FRound(cGreyThreshold / 2.55), FieldUnit::PERCENT); + mxMtrThreshold->set_value(basegfx::fround(cGreyThreshold / 2.55), FieldUnit::PERCENT); mxMtrThreshold->connect_value_changed(LINK(this, GraphicFilterSolarize, EditModifyHdl)); mxCbxInvert->set_active(bInvert); @@ -290,7 +290,7 @@ IMPL_LINK_NOARG(GraphicFilterSolarize, EditModifyHdl, weld::MetricSpinButton&, v Graphic GraphicFilterSolarize::GetFilteredGraphic( const Graphic& rGraphic, double, double ) { Graphic aRet; - sal_uInt8 nGreyThreshold = static_cast<sal_uInt8>(FRound(mxMtrThreshold->get_value(FieldUnit::PERCENT) * 2.55)); + sal_uInt8 nGreyThreshold = basegfx::fround<sal_uInt8>(mxMtrThreshold->get_value(FieldUnit::PERCENT) * 2.55); if( rGraphic.IsAnimated() ) { @@ -431,21 +431,21 @@ GraphicFilterEmboss::~GraphicFilterEmboss() Graphic GraphicFilterEmboss::GetFilteredGraphic( const Graphic& rGraphic, double, double ) { Graphic aRet; - sal_uInt16 nAzim, nElev; + Degree100 nAzim, nElev; switch (maCtlLight.GetActualRP()) { default: OSL_FAIL("svx::GraphicFilterEmboss::GetFilteredGraphic(), unknown Reference Point!" ); [[fallthrough]]; - case RectPoint::LT: nAzim = 4500; nElev = 4500; break; - case RectPoint::MT: nAzim = 9000; nElev = 4500; break; - case RectPoint::RT: nAzim = 13500; nElev = 4500; break; - case RectPoint::LM: nAzim = 0; nElev = 4500; break; - case RectPoint::MM: nAzim = 0; nElev = 9000; break; - case RectPoint::RM: nAzim = 18000; nElev = 4500; break; - case RectPoint::LB: nAzim = 31500; nElev = 4500; break; - case RectPoint::MB: nAzim = 27000; nElev = 4500; break; - case RectPoint::RB: nAzim = 22500; nElev = 4500; break; + case RectPoint::LT: nAzim = 4500_deg100; nElev = 4500_deg100; break; + case RectPoint::MT: nAzim = 9000_deg100; nElev = 4500_deg100; break; + case RectPoint::RT: nAzim = 13500_deg100; nElev = 4500_deg100; break; + case RectPoint::LM: nAzim = 0_deg100; nElev = 4500_deg100; break; + case RectPoint::MM: nAzim = 0_deg100; nElev = 9000_deg100; break; + case RectPoint::RM: nAzim = 18000_deg100; nElev = 4500_deg100; break; + case RectPoint::LB: nAzim = 31500_deg100; nElev = 4500_deg100; break; + case RectPoint::MB: nAzim = 27000_deg100; nElev = 4500_deg100; break; + case RectPoint::RB: nAzim = 22500_deg100; nElev = 4500_deg100; break; } if( rGraphic.IsAnimated() ) diff --git a/cui/source/dialogs/cuihyperdlg.cxx b/cui/source/dialogs/cuihyperdlg.cxx index 66068c084274..4fec600441fd 100644 --- a/cui/source/dialogs/cuihyperdlg.cxx +++ b/cui/source/dialogs/cuihyperdlg.cxx @@ -79,6 +79,9 @@ void SvxHlinkCtrl::StateChangedAtToolBoxControl( sal_uInt16 nSID, SfxItemState e } } +// tdf#90496 - remember last used view in hyperlink dialog +OUString SvxHpLinkDlg::msRememberedPageId("internet"); + //# # //# Hyperlink - Dialog # //# # @@ -106,15 +109,25 @@ SvxHpLinkDlg::SvxHpLinkDlg(SfxBindings* pBindings, SfxChildWindow* pChild, weld: // Buttons m_xOKBtn->show(); - m_xApplyBtn->show(); m_xCancelBtn->show(); - m_xHelpBtn->show(); - m_xResetBtn->show(); + + if (comphelper::LibreOfficeKit::isActive()) + { + m_xApplyBtn->hide(); + m_xHelpBtn->hide(); + m_xResetBtn->hide(); + } + else + { + m_xApplyBtn->show(); + m_xHelpBtn->show(); + m_xResetBtn->show(); + } mbGrabFocus = true; // set OK/Cancel - button - m_xCancelBtn->set_label(CuiResId(RID_SVXSTR_HYPDLG_CLOSEBUT)); + m_xCancelBtn->set_label(CuiResId(RID_CUISTR_HYPDLG_CLOSEBUT)); // create itemset for tabpages mpItemSet = std::make_unique<SfxItemSetFixed<SID_HYPERLINK_GETLINK, @@ -134,7 +147,8 @@ SvxHpLinkDlg::SvxHpLinkDlg(SfxBindings* pBindings, SfxChildWindow* pChild, weld: AddTabPage("newdocument", SvxHyperlinkNewDocTp::Create); } - SetCurPageId("internet"); + // tdf#90496 - remember last used view in hyperlink dialog + SetCurPageId(msRememberedPageId); // Init Dialog Start(); @@ -177,8 +191,7 @@ void SvxHpLinkDlg::Close() { if (IsClosing()) return; - SfxViewFrame* pViewFrame = SfxViewFrame::Current(); - if (pViewFrame) + if (SfxViewFrame* pViewFrame = SfxViewFrame::Current()) pViewFrame->ToggleChildWindow(SID_HYPERLINK_DIALOG); } @@ -189,17 +202,14 @@ void SvxHpLinkDlg::Apply() SvxHyperlinkTabPageBase* pCurrentPage = static_cast<SvxHyperlinkTabPageBase*>( GetTabPage( GetCurPageId() ) ); - if ( pCurrentPage->AskApply() ) - { - pCurrentPage->FillItemSet( &aItemSet ); + pCurrentPage->FillItemSet( &aItemSet ); - const SvxHyperlinkItem *aItem = aItemSet.GetItem(SID_HYPERLINK_SETLINK); - if ( !aItem->GetURL().isEmpty() ) - GetDispatcher()->ExecuteList(SID_HYPERLINK_SETLINK, - SfxCallMode::ASYNCHRON | SfxCallMode::RECORD, { aItem }); + const SvxHyperlinkItem *aItem = aItemSet.GetItem(SID_HYPERLINK_SETLINK); + if ( !aItem->GetURL().isEmpty() ) + GetDispatcher()->ExecuteList(SID_HYPERLINK_SETLINK, + SfxCallMode::ASYNCHRON | SfxCallMode::RECORD, { aItem }); - static_cast<SvxHyperlinkTabPageBase*>( GetTabPage( GetCurPageId() ) )->DoApply(); - } + static_cast<SvxHyperlinkTabPageBase*>( GetTabPage( GetCurPageId() ) )->DoApply(); } /// Click on OK button @@ -226,7 +236,7 @@ IMPL_LINK_NOARG(SvxHpLinkDlg, ClickApplyHdl_Impl, weld::Button&, void) |************************************************************************/ void SvxHpLinkDlg::SetPage ( SvxHyperlinkItem const * pItem ) { - OString sPageId("internet"); + OUString sPageId("internet"); OUString aStrURL(pItem->GetURL()); INetURLObject aURL(aStrURL); diff --git a/cui/source/dialogs/dlgname.cxx b/cui/source/dialogs/dlgname.cxx index ffa540bbca5b..09b6158fde00 100644 --- a/cui/source/dialogs/dlgname.cxx +++ b/cui/source/dialogs/dlgname.cxx @@ -19,13 +19,16 @@ #include <dlgname.hxx> +#include <comphelper/string.hxx> + /************************************************************************* |* |* Dialog for editing a name |* \************************************************************************/ -SvxNameDialog::SvxNameDialog(weld::Window* pParent, const OUString& rName, const OUString& rDesc) +SvxNameDialog::SvxNameDialog(weld::Window* pParent, const OUString& rName, const OUString& rDesc, + const OUString& rTitle) : GenericDialogController(pParent, "cui/ui/namedialog.ui", "NameDialog") , m_xEdtName(m_xBuilder->weld_entry("name_entry")) , m_xFtDescription(m_xBuilder->weld_label("description_label")) @@ -36,14 +39,16 @@ SvxNameDialog::SvxNameDialog(weld::Window* pParent, const OUString& rName, const m_xEdtName->select_region(0, -1); ModifyHdl(*m_xEdtName); m_xEdtName->connect_changed(LINK(this, SvxNameDialog, ModifyHdl)); + if (!rTitle.isEmpty()) + set_title(rTitle); } IMPL_LINK_NOARG(SvxNameDialog, ModifyHdl, weld::Entry&, void) { - // Do not allow empty names + // Do not allow empty names, unless custom CheckNameHdl is specified bool bEnable; if (m_aCheckNameHdl.IsSet()) - bEnable = !m_xEdtName->get_text().isEmpty() && m_aCheckNameHdl.Call(*this); + bEnable = m_aCheckNameHdl.Call(*this); else bEnable = !m_xEdtName->get_text().isEmpty(); m_xBtnOK->set_sensitive(bEnable); @@ -57,6 +62,28 @@ IMPL_LINK_NOARG(SvxNameDialog, ModifyHdl, weld::Entry&, void) m_xEdtName->set_tooltip_text(rTip); } +SvxNumberDialog::SvxNumberDialog(weld::Window* pParent, const OUString& rDesc, sal_Int64 nValue, + sal_Int64 nMin, sal_Int64 nMax) + : GenericDialogController(pParent, "cui/ui/numberdialog.ui", "NumberDialog") + , m_xEdtNumber(m_xBuilder->weld_spin_button("number_spinbtn")) + , m_xFtDescription(m_xBuilder->weld_label("description_label")) +{ + m_xFtDescription->set_label(rDesc); + m_xEdtNumber->set_min(nMin); + m_xEdtNumber->set_max(nMax); + m_xEdtNumber->set_value(nValue); +} + +SvxDecimalNumberDialog::SvxDecimalNumberDialog(weld::Window* pParent, const OUString& rDesc, + double fValue) + : GenericDialogController(pParent, "cui/ui/numberdialog.ui", "NumberDialog") + , m_xEdtNumber(m_xBuilder->weld_formatted_spin_button("number_spinbtn")) + , m_xFtDescription(m_xBuilder->weld_label("description_label")) +{ + m_xFtDescription->set_label(rDesc); + m_xEdtNumber->GetFormatter().SetValue(fValue); +} + // #i68101# // Dialog for editing Object Name // plus uniqueness-callback-linkHandler @@ -87,10 +114,14 @@ IMPL_LINK_NOARG(SvxObjectNameDialog, ModifyHdl, weld::Entry&, void) // Dialog for editing Object Title and Description SvxObjectTitleDescDialog::SvxObjectTitleDescDialog(weld::Window* pParent, const OUString& rTitle, - const OUString& rDescription) + const OUString& rDescription, + bool const isDecorative) : GenericDialogController(pParent, "cui/ui/objecttitledescdialog.ui", "ObjectTitleDescDialog") + , m_xTitleFT(m_xBuilder->weld_label("object_title_label")) , m_xEdtTitle(m_xBuilder->weld_entry("object_title_entry")) + , m_xDescriptionFT(m_xBuilder->weld_label("desc_label")) , m_xEdtDescription(m_xBuilder->weld_text_view("desc_entry")) + , m_xDecorativeCB(m_xBuilder->weld_check_button("decorative")) { //lock height to initial height m_xEdtDescription->set_size_request(-1, m_xEdtDescription->get_text_height() * 5); @@ -100,6 +131,154 @@ SvxObjectTitleDescDialog::SvxObjectTitleDescDialog(weld::Window* pParent, const // activate title m_xEdtTitle->select_region(0, -1); + + m_xDecorativeCB->set_active(isDecorative); + m_xDecorativeCB->connect_toggled(LINK(this, SvxObjectTitleDescDialog, DecorativeHdl)); + DecorativeHdl(*m_xDecorativeCB); +} + +IMPL_LINK_NOARG(SvxObjectTitleDescDialog, DecorativeHdl, weld::Toggleable&, void) +{ + bool const bEnable(!m_xDecorativeCB->get_active()); + m_xEdtTitle->set_sensitive(bEnable); + m_xTitleFT->set_sensitive(bEnable); + m_xEdtDescription->set_sensitive(bEnable); + m_xDescriptionFT->set_sensitive(bEnable); +} + +SvxListDialog::SvxListDialog(weld::Window* pParent) + : GenericDialogController(pParent, "cui/ui/listdialog.ui", "ListDialog") + , m_aMode(ListMode::String) + , m_xList(m_xBuilder->weld_tree_view("assignlist")) + , m_xAddBtn(m_xBuilder->weld_button("addbtn")) + , m_xRemoveBtn(m_xBuilder->weld_button("removebtn")) + , m_xEditBtn(m_xBuilder->weld_button("editbtn")) +{ + m_xList->set_size_request(m_xList->get_approximate_digit_width() * 54, + m_xList->get_height_rows(6)); + m_xAddBtn->connect_clicked(LINK(this, SvxListDialog, AddHdl_Impl)); + m_xRemoveBtn->connect_clicked(LINK(this, SvxListDialog, RemoveHdl_Impl)); + m_xEditBtn->connect_clicked(LINK(this, SvxListDialog, EditHdl_Impl)); + m_xList->connect_changed(LINK(this, SvxListDialog, SelectHdl_Impl)); + m_xList->connect_row_activated(LINK(this, SvxListDialog, DblClickHdl_Impl)); + + SelectionChanged(); +} + +SvxListDialog::~SvxListDialog() {} + +IMPL_LINK_NOARG(SvxListDialog, AddHdl_Impl, weld::Button&, void) +{ + SvxNameDialog aNameDlg(m_xDialog.get(), "", ""); + + if (!aNameDlg.run()) + return; + OUString sNewText = comphelper::string::strip(aNameDlg.GetName(), ' '); + if (!sNewText.isEmpty()) + { + m_xList->insert_text(-1, sNewText); + m_xList->select(-1); + } +} + +IMPL_LINK_NOARG(SvxListDialog, EditHdl_Impl, weld::Button&, void) { EditEntry(); } + +IMPL_LINK_NOARG(SvxListDialog, SelectHdl_Impl, weld::TreeView&, void) { SelectionChanged(); } + +IMPL_LINK_NOARG(SvxListDialog, DblClickHdl_Impl, weld::TreeView&, bool) +{ + EditEntry(); + return true; } +IMPL_LINK_NOARG(SvxListDialog, RemoveHdl_Impl, weld::Button&, void) +{ + int nPos = m_xList->get_selected_index(); + if (nPos == -1) + return; + m_xList->remove(nPos); + int nCount = m_xList->n_children(); + if (nCount) + { + if (nPos >= nCount) + nPos = nCount - 1; + m_xList->select(nPos); + } + SelectionChanged(); +} + +void SvxListDialog::SelectionChanged() +{ + bool bEnable = m_xList->get_selected_index() != -1; + m_xRemoveBtn->set_sensitive(bEnable); + m_xEditBtn->set_sensitive(bEnable); +} + +std::vector<OUString> SvxListDialog::GetEntries() +{ + int nCount = m_xList->n_children(); + std::vector<OUString> aList; + aList.reserve(nCount); + for (int i = 0; i < nCount; ++i) + aList.push_back(m_xList->get_text(i)); + return aList; +} + +void SvxListDialog::SetEntries(std::vector<OUString> const& rEntries) +{ + m_xList->clear(); + for (auto const& sEntry : rEntries) + { + m_xList->append_text(sEntry); + } + SelectionChanged(); +} + +void SvxListDialog::EditEntry() +{ + int nPos = m_xList->get_selected_index(); + if (nPos == -1) + return; + + OUString sOldText(m_xList->get_selected_text()); + OUString sNewText; + + if (m_aMode == ListMode::String) + { + SvxNameDialog aNameDlg(m_xDialog.get(), sOldText, ""); + if (!aNameDlg.run()) + return; + sNewText = comphelper::string::strip(aNameDlg.GetName(), ' '); + } + else if (m_aMode == ListMode::Int16 || m_aMode == ListMode::Int32 || m_aMode == ListMode::Int64) + { + sal_Int64 nMin = m_aMode == ListMode::Int16 + ? SAL_MIN_INT16 + : m_aMode == ListMode::Int32 ? SAL_MIN_INT32 : SAL_MIN_INT64; + sal_Int64 nMax = m_aMode == ListMode::Int16 + ? SAL_MAX_INT16 + : m_aMode == ListMode::Int32 ? SAL_MAX_INT32 : SAL_MAX_INT64; + SvxNumberDialog aNumberDlg(m_xDialog.get(), "", sOldText.toInt64(), nMin, nMax); + if (!aNumberDlg.run()) + return; + sNewText = OUString::number(aNumberDlg.GetNumber()); + } + else if (m_aMode == ListMode::Double) + { + SvxDecimalNumberDialog aNumberDlg(m_xDialog.get(), "", sOldText.toDouble()); + if (!aNumberDlg.run()) + return; + sNewText = OUString::number(aNumberDlg.GetNumber()); + } + + if (!sNewText.isEmpty() && sNewText != sOldText) + { + m_xList->remove(nPos); + m_xList->insert_text(nPos, sNewText); + m_xList->select(nPos); + } +} + +void SvxListDialog::SetMode(ListMode aMode) { m_aMode = aMode; }; + /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/cui/source/dialogs/hangulhanjadlg.cxx b/cui/source/dialogs/hangulhanjadlg.cxx index ec46262284c5..fb25df938e17 100644 --- a/cui/source/dialogs/hangulhanjadlg.cxx +++ b/cui/source/dialogs/hangulhanjadlg.cxx @@ -28,7 +28,6 @@ #include <osl/diagnose.h> #include <tools/debug.hxx> #include <i18nlangtag/languagetag.hxx> -#include <vcl/svapp.hxx> #include <vcl/virdev.hxx> #include <vcl/weldutils.hxx> #include <unotools/lingucfg.hxx> @@ -452,8 +451,8 @@ namespace svx m_xSuggestions->set_size_request(m_xOriginalWord->get_approximate_digit_width() * 42, m_xOriginalWord->get_text_height() * 5); - const OUString sHangul(CuiResId(RID_SVXSTR_HANGUL)); - const OUString sHanja(CuiResId(RID_SVXSTR_HANJA)); + const OUString sHangul(CuiResId(RID_CUISTR_HANGUL)); + const OUString sHanja(CuiResId(RID_CUISTR_HANJA)); m_xHanjaAbove->init( sHangul, sHanja, PseudoRubyText::eAbove ); m_xHanjaBelow->init( sHangul, sHanja, PseudoRubyText::eBelow ); m_xHangulAbove->init( sHanja, sHangul, PseudoRubyText::eAbove ); @@ -623,8 +622,7 @@ namespace svx pNewDefButton = m_xFind.get(); } - pOldDefButton->set_has_default(false); - pNewDefButton->set_has_default(true); + m_xDialog->change_default_widget(pOldDefButton, pNewDefButton); } OUString HangulHanjaConversionDialog::GetCurrentSuggestion( ) const @@ -1432,7 +1430,7 @@ namespace svx HangulHanjaEditDictDialog::HangulHanjaEditDictDialog(weld::Window* pParent, HHDictList& _rDictList, sal_uInt32 nSelDict) : GenericDialogController(pParent, "cui/ui/hangulhanjaeditdictdialog.ui", "HangulHanjaEditDictDialog") - , m_aEditHintText ( CuiResId(RID_SVXSTR_EDITHINT) ) + , m_aEditHintText ( CuiResId(RID_CUISTR_EDITHINT) ) , m_rDictList ( _rDictList ) , m_nCurrentDict ( 0xFFFFFFFF ) , m_nTopPos ( 0 ) diff --git a/cui/source/dialogs/hldocntp.cxx b/cui/source/dialogs/hldocntp.cxx index 8d8628ded6ed..d58077a431f4 100644 --- a/cui/source/dialogs/hldocntp.cxx +++ b/cui/source/dialogs/hldocntp.cxx @@ -25,9 +25,8 @@ #include <svl/stritem.hxx> #include <com/sun/star/awt/XTopWindow.hpp> #include <com/sun/star/uno/Reference.h> -#include <com/sun/star/uno/Sequence.h> -#include <com/sun/star/beans/PropertyValue.hpp> #include <com/sun/star/uno/Exception.hpp> +#include <utility> #include <vcl/svapp.hxx> #include <vcl/weld.hxx> #include <tools/urlobj.hxx> @@ -37,14 +36,13 @@ #include <unotools/ucbhelper.hxx> #include <comphelper/processfactory.hxx> -#include <com/sun/star/ui/dialogs/FolderPicker.hpp> +#include <com/sun/star/ui/dialogs/XFolderPicker2.hpp> #include <com/sun/star/ui/dialogs/ExecutableDialogResults.hpp> #include <cuihyperdlg.hxx> #include <dialmgr.hxx> #include <strings.hrc> -using namespace ::com::sun::star::lang; using namespace ::com::sun::star::ui::dialogs; using namespace ::com::sun::star::uno; @@ -62,13 +60,13 @@ struct DocumentTypeData { OUString aStrURL; OUString aStrExt; - DocumentTypeData (const OUString& aURL, const OUString& aExt) : aStrURL(aURL), aStrExt(aExt) + DocumentTypeData (OUString aURL, OUString aExt) : aStrURL(std::move(aURL)), aStrExt(std::move(aExt)) {} }; } -bool SvxHyperlinkNewDocTp::ImplGetURLObject( const OUString& rPath, const OUString& rBase, INetURLObject& aURLObject ) const +bool SvxHyperlinkNewDocTp::ImplGetURLObject( const OUString& rPath, std::u16string_view rBase, INetURLObject& aURLObject ) const { bool bIsValidURL = !rPath.isEmpty(); if ( bIsValidURL ) @@ -94,7 +92,7 @@ bool SvxHyperlinkNewDocTp::ImplGetURLObject( const OUString& rPath, const OUStri { sal_Int32 nPos = m_xLbDocTypes->get_selected_index(); if (nPos != -1) - aURLObject.SetExtension(reinterpret_cast<DocumentTypeData*>(m_xLbDocTypes->get_id(nPos).toInt64())->aStrExt); + aURLObject.SetExtension(weld::fromId<DocumentTypeData*>(m_xLbDocTypes->get_id(nPos))->aStrExt); } } @@ -138,7 +136,7 @@ SvxHyperlinkNewDocTp::~SvxHyperlinkNewDocTp () if (m_xLbDocTypes) { for (sal_Int32 n = 0, nEntryCount = m_xLbDocTypes->n_children(); n < nEntryCount; ++n) - delete reinterpret_cast<DocumentTypeData*>(m_xLbDocTypes->get_id(n).toInt64()); + delete weld::fromId<DocumentTypeData*>(m_xLbDocTypes->get_id(n)); m_xLbDocTypes = nullptr; } } @@ -186,7 +184,7 @@ void SvxHyperlinkNewDocTp::FillDocumentList() OUString aStrDefExt(pFilter->GetDefaultExtension()); DocumentTypeData *pTypeData = new DocumentTypeData(aDocumentUrl, aStrDefExt.copy(2)); - OUString sId(OUString::number(reinterpret_cast<sal_Int64>(pTypeData))); + OUString sId(weld::toId(pTypeData)); m_xLbDocTypes->append(sId, aTitleName); } } @@ -200,7 +198,7 @@ void SvxHyperlinkNewDocTp::FillDocumentList() |* |************************************************************************/ -void SvxHyperlinkNewDocTp::GetCurentItemData ( OUString& rStrURL, OUString& aStrName, +void SvxHyperlinkNewDocTp::GetCurrentItemData ( OUString& rStrURL, OUString& aStrName, OUString& aStrIntName, OUString& aStrFrame, SvxLinkInsertMode& eMode ) { @@ -236,25 +234,6 @@ void SvxHyperlinkNewDocTp::SetInitFocus() m_xCbbPath->grab_focus(); } -/************************************************************************* -|* -|* Ask page whether an insert is possible -|* -\************************************************************************/ -bool SvxHyperlinkNewDocTp::AskApply() -{ - INetURLObject aINetURLObject; - bool bRet = ImplGetURLObject(m_xCbbPath->get_active_text(), m_xCbbPath->GetBaseURL(), aINetURLObject); - if ( !bRet ) - { - std::unique_ptr<weld::MessageDialog> xWarn(Application::CreateMessageDialog(mpDialog->getDialog(), - VclMessageType::Warning, VclButtonsType::Ok, - CuiResId(RID_SVXSTR_HYPDLG_NOVALIDFILENAME))); - xWarn->run(); - } - return bRet; -} - namespace { struct ExecuteInfo @@ -294,12 +273,12 @@ IMPL_STATIC_LINK(SvxHyperlinkNewDocTp, DispatchDocument, void*, p, void) SfxStringItem aFlags (SID_OPTIONS, aStrFlags); // open url - const SfxPoolItem* pReturn = xExecuteInfo->pDispatcher->ExecuteList( - SID_OPENDOC, SfxCallMode::SYNCHRON, - { &aName, &aFlags, &aFrame, &aReferer }); + const SfxPoolItemHolder aResult(xExecuteInfo->pDispatcher->ExecuteList( + SID_OPENDOC, SfxCallMode::SYNCHRON, + { &aName, &aFlags, &aFrame, &aReferer })); // save new doc - const SfxViewFrameItem *pItem = dynamic_cast<const SfxViewFrameItem*>( pReturn ); // SJ: pReturn is NULL if the Hyperlink + const SfxViewFrameItem *pItem = dynamic_cast<const SfxViewFrameItem*>(aResult.getItem()); // aResult is NULL if the Hyperlink if ( pItem ) // creation is cancelled #106216# { pViewFrame = pItem->GetFrame(); @@ -307,7 +286,6 @@ IMPL_STATIC_LINK(SvxHyperlinkNewDocTp, DispatchDocument, void*, p, void) { SfxStringItem aNewName( SID_FILE_NAME, xExecuteInfo->aURL.GetMainURL( INetURLObject::DecodeMechanism::NONE ) ); SfxUnoFrameItem aDocFrame( SID_FILLFRAME, pViewFrame->GetFrame().GetFrameInterface() ); - fprintf(stderr, "is there a frame int %p\n", pViewFrame->GetFrame().GetFrameInterface().get() ); pViewFrame->GetDispatcher()->ExecuteList( SID_SAVEASDOC, SfxCallMode::SYNCHRON, { &aNewName }, { &aDocFrame }); @@ -368,7 +346,7 @@ void SvxHyperlinkNewDocTp::DoApply() { std::unique_ptr<weld::MessageDialog> xWarn(Application::CreateMessageDialog(mpDialog->getDialog(), VclMessageType::Warning, VclButtonsType::YesNo, - CuiResId(RID_SVXSTR_HYPERDLG_QUERYOVERWRITE))); + CuiResId(RID_CUISTR_HYPERDLG_QUERYOVERWRITE))); bCreate = xWarn->run() == RET_YES; } } @@ -388,7 +366,7 @@ void SvxHyperlinkNewDocTp::DoApply() if (nPos == -1) nPos = 0; pExecuteInfo->aURL = aURL; - pExecuteInfo->aStrDocName = reinterpret_cast<DocumentTypeData*>(m_xLbDocTypes->get_id(nPos).toInt64())->aStrURL; + pExecuteInfo->aStrDocName = weld::fromId<DocumentTypeData*>(m_xLbDocTypes->get_id(nPos))->aStrURL; // current document pExecuteInfo->xFrame = GetDispatcher()->GetFrame()->GetFrame().GetFrameInterface(); @@ -452,7 +430,7 @@ IMPL_LINK_NOARG(SvxHyperlinkNewDocTp, ClickNewHdl_Impl, weld::Button&, void) { // get private-url const sal_Int32 nPos = m_xLbDocTypes->get_selected_index(); - aNewURL.setExtension(reinterpret_cast<DocumentTypeData*>(m_xLbDocTypes->get_id(nPos).toInt64())->aStrExt); + aNewURL.setExtension(weld::fromId<DocumentTypeData*>(m_xLbDocTypes->get_id(nPos))->aStrExt); } if( aNewURL.GetProtocol() == INetProtocol::File ) diff --git a/cui/source/dialogs/hldoctp.cxx b/cui/source/dialogs/hldoctp.cxx index 152a7ec7fbc1..a1c1454b69de 100644 --- a/cui/source/dialogs/hldoctp.cxx +++ b/cui/source/dialogs/hldoctp.cxx @@ -127,7 +127,7 @@ OUString SvxHyperlinkDocTp::GetCurrentURL () const |* retrieve and prepare data from dialog-fields |* |************************************************************************/ -void SvxHyperlinkDocTp::GetCurentItemData ( OUString& rStrURL, OUString& aStrName, +void SvxHyperlinkDocTp::GetCurrentItemData ( OUString& rStrURL, OUString& aStrName, OUString& aStrIntName, OUString& aStrFrame, SvxLinkInsertMode& eMode ) { @@ -304,7 +304,7 @@ void SvxHyperlinkDocTp::SetMarkStr ( const OUString& aStrMark ) |* retrieve kind of pathstr |* |************************************************************************/ -SvxHyperlinkDocTp::EPathType SvxHyperlinkDocTp::GetPathType ( const OUString& rStrPath ) +SvxHyperlinkDocTp::EPathType SvxHyperlinkDocTp::GetPathType ( std::u16string_view rStrPath ) { INetURLObject aURL( rStrPath, INetProtocol::File ); diff --git a/cui/source/dialogs/hlinettp.cxx b/cui/source/dialogs/hlinettp.cxx index c26420d5703a..610cdd8aea5e 100644 --- a/cui/source/dialogs/hlinettp.cxx +++ b/cui/source/dialogs/hlinettp.cxx @@ -24,7 +24,6 @@ #include <hlinettp.hxx> #include <hlmarkwn_def.hxx> -constexpr OUStringLiteral sAnonymous = u"anonymous"; /************************************************************************* |* @@ -37,15 +36,8 @@ SvxHyperlinkInternetTp::SvxHyperlinkInternetTp(weld::Container* pParent, : SvxHyperlinkTabPageBase(pParent, pDlg, "cui/ui/hyperlinkinternetpage.ui", "HyperlinkInternetPage", pItemSet) , m_bMarkWndOpen(false) - , m_xRbtLinktypInternet(xBuilder->weld_radio_button("linktyp_internet")) - , m_xRbtLinktypFTP(xBuilder->weld_radio_button("linktyp_ftp")) , m_xCbbTarget(new SvxHyperURLBox(xBuilder->weld_combo_box("target"))) , m_xFtTarget(xBuilder->weld_label("target_label")) - , m_xFtLogin(xBuilder->weld_label("login_label")) - , m_xEdLogin(xBuilder->weld_entry("login")) - , m_xFtPassword(xBuilder->weld_label("password_label")) - , m_xEdPassword(xBuilder->weld_entry("password")) - , m_xCbAnonymous(xBuilder->weld_check_button("anonymous")) { // gtk_size_group_set_ignore_hidden, "Measuring the size of hidden widgets // ... they will report a size of 0 nowadays, and thus, their size will @@ -63,15 +55,7 @@ SvxHyperlinkInternetTp::SvxHyperlinkInternetTp(weld::Container* pParent, SetExchangeSupport (); - // set defaults - m_xRbtLinktypInternet->set_active(true); - // set handlers - Link<weld::Toggleable&, void> aLink( LINK ( this, SvxHyperlinkInternetTp, Click_SmartProtocol_Impl ) ); - m_xRbtLinktypInternet->connect_toggled( aLink ); - m_xRbtLinktypFTP->connect_toggled( aLink ); - m_xCbAnonymous->connect_toggled( LINK ( this, SvxHyperlinkInternetTp, ClickAnonymousHdl_Impl ) ); - m_xEdLogin->connect_changed( LINK ( this, SvxHyperlinkInternetTp, ModifiedLoginHdl_Impl ) ); m_xCbbTarget->connect_focus_out( LINK ( this, SvxHyperlinkInternetTp, LostFocusTargetHdl_Impl ) ); m_xCbbTarget->connect_changed( LINK ( this, SvxHyperlinkInternetTp, ModifiedTargetHdl_Impl ) ); maTimer.SetInvokeHandler ( LINK ( this, SvxHyperlinkInternetTp, TimeoutHdl_Impl ) ); @@ -91,19 +75,6 @@ void SvxHyperlinkInternetTp::FillDlgFields(const OUString& rStrURL) INetURLObject aURL(rStrURL); OUString aStrScheme(GetSchemeFromURL(rStrURL)); - // set additional controls for FTP: Username / Password - if (aStrScheme.startsWith(INET_FTP_SCHEME)) - { - if ( aURL.GetUser().toAsciiLowerCase().startsWith( sAnonymous ) ) - setAnonymousFTPUser(); - else - setFTPUser(aURL.GetUser(), aURL.GetPass()); - - //do not show password and user in url - if(!aURL.GetUser().isEmpty() || !aURL.GetPass().isEmpty() ) - aURL.SetUserAndPass(u"", u""); - } - // set URL-field // Show the scheme, #72740 if ( aURL.GetProtocol() != INetProtocol::NotValid ) @@ -114,38 +85,13 @@ void SvxHyperlinkInternetTp::FillDlgFields(const OUString& rStrURL) SetScheme(aStrScheme); } -void SvxHyperlinkInternetTp::setAnonymousFTPUser() -{ - m_xEdLogin->set_text(sAnonymous); - SvAddressParser aAddress(SvtUserOptions().GetEmail()); - m_xEdPassword->set_text(aAddress.Count() ? aAddress.GetEmailAddress(0) : OUString()); - - m_xFtLogin->set_sensitive(false); - m_xFtPassword->set_sensitive(false); - m_xEdLogin->set_sensitive(false); - m_xEdPassword->set_sensitive(false); - m_xCbAnonymous->set_active(true); -} - -void SvxHyperlinkInternetTp::setFTPUser(const OUString& rUser, const OUString& rPassword) -{ - m_xEdLogin->set_text(rUser); - m_xEdPassword->set_text(rPassword); - - m_xFtLogin->set_sensitive(true); - m_xFtPassword->set_sensitive(true); - m_xEdLogin->set_sensitive(true); - m_xEdPassword->set_sensitive(true); - m_xCbAnonymous->set_active(false); -} - /************************************************************************* |* |* retrieve and prepare data from dialog-fields |* |************************************************************************/ -void SvxHyperlinkInternetTp::GetCurentItemData ( OUString& rStrURL, OUString& aStrName, +void SvxHyperlinkInternetTp::GetCurrentItemData ( OUString& rStrURL, OUString& aStrName, OUString& aStrIntName, OUString& aStrFrame, SvxLinkInsertMode& eMode ) { @@ -158,17 +104,7 @@ OUString SvxHyperlinkInternetTp::CreateAbsoluteURL() const // erase leading and trailing whitespaces OUString aStrURL(m_xCbbTarget->get_active_text().trim()); - INetURLObject aURL(aStrURL); - - if( aURL.GetProtocol() == INetProtocol::NotValid ) - { - aURL.SetSmartProtocol( GetSmartProtocolFromButtons() ); - aURL.SetSmartURL(aStrURL); - } - - // username and password for ftp-url - if( aURL.GetProtocol() == INetProtocol::Ftp && !m_xEdLogin->get_text().isEmpty() ) - aURL.SetUserAndPass ( m_xEdLogin->get_text(), m_xEdPassword->get_text() ); + INetURLObject aURL(aStrURL, GetSmartProtocolFromButtons()); if ( aURL.GetProtocol() != INetProtocol::NotValid ) return aURL.GetMainURL( INetURLObject::DecodeMechanism::ToIUri ); @@ -223,42 +159,12 @@ IMPL_LINK_NOARG(SvxHyperlinkInternetTp, TimeoutHdl_Impl, Timer *, void) RefreshMarkWindow(); } -/************************************************************************* -|* -|* Contents of editfield "Login" modified -|* -|************************************************************************/ -IMPL_LINK_NOARG(SvxHyperlinkInternetTp, ModifiedLoginHdl_Impl, weld::Entry&, void) -{ - OUString aStrLogin ( m_xEdLogin->get_text() ); - if ( aStrLogin.equalsIgnoreAsciiCase( sAnonymous ) ) - { - m_xCbAnonymous->set_active(true); - ClickAnonymousHdl_Impl(*m_xCbAnonymous); - } -} - void SvxHyperlinkInternetTp::SetScheme(std::u16string_view rScheme) { - //if rScheme is empty or unknown the default behaviour is like it where HTTP - bool bFTP = o3tl::starts_with(rScheme, INET_FTP_SCHEME); - bool bInternet = !bFTP; - - //update protocol button selection: - m_xRbtLinktypFTP->set_active(bFTP); - m_xRbtLinktypInternet->set_active(bInternet); - //update target: RemoveImproperProtocol(rScheme); m_xCbbTarget->SetSmartProtocol( GetSmartProtocolFromButtons() ); - //show/hide special fields for FTP: - m_xFtLogin->set_visible( bFTP ); - m_xFtPassword->set_visible( bFTP ); - m_xEdLogin->set_visible( bFTP ); - m_xEdPassword->set_visible( bFTP ); - m_xCbAnonymous->set_visible( bFTP ); - //update 'link target in document'-window and opening-button if (o3tl::starts_with(rScheme, INET_HTTP_SCHEME) || rScheme.empty()) { @@ -293,64 +199,13 @@ void SvxHyperlinkInternetTp::RemoveImproperProtocol(std::u16string_view aProperS } } -OUString SvxHyperlinkInternetTp::GetSchemeFromButtons() const +INetProtocol SvxHyperlinkInternetTp::GetSmartProtocolFromButtons() { - if( m_xRbtLinktypFTP->get_active() ) - return INET_FTP_SCHEME; - return INET_HTTP_SCHEME; -} - -INetProtocol SvxHyperlinkInternetTp::GetSmartProtocolFromButtons() const -{ - if( m_xRbtLinktypFTP->get_active() ) - { - return INetProtocol::Ftp; - } return INetProtocol::Http; } /************************************************************************* |* -|* Click on Radiobutton : Internet or FTP -|* -|************************************************************************/ -IMPL_LINK(SvxHyperlinkInternetTp, Click_SmartProtocol_Impl, weld::Toggleable&, rButton, void) -{ - if (!rButton.get_active()) - return; - OUString aScheme = GetSchemeFromButtons(); - SetScheme(aScheme); -} - -/************************************************************************* -|* -|* Click on Checkbox : Anonymous user -|* -|************************************************************************/ -IMPL_LINK_NOARG(SvxHyperlinkInternetTp, ClickAnonymousHdl_Impl, weld::Toggleable&, void) -{ - // disable login-editfields if checked - if ( m_xCbAnonymous->get_active() ) - { - if ( m_xEdLogin->get_text().toAsciiLowerCase().startsWith( sAnonymous ) ) - { - maStrOldUser.clear(); - maStrOldPassword.clear(); - } - else - { - maStrOldUser = m_xEdLogin->get_text(); - maStrOldPassword = m_xEdPassword->get_text(); - } - - setAnonymousFTPUser(); - } - else - setFTPUser(maStrOldUser, maStrOldPassword); -} - -/************************************************************************* -|* |* Combobox Target lost the focus |* |************************************************************************/ @@ -361,7 +216,7 @@ IMPL_LINK_NOARG(SvxHyperlinkInternetTp, LostFocusTargetHdl_Impl, weld::Widget&, void SvxHyperlinkInternetTp::RefreshMarkWindow() { - if (m_xRbtLinktypInternet->get_active() && IsMarkWndVisible()) + if (IsMarkWndVisible()) { weld::WaitObject aWait(mpDialog->getDialog()); OUString aStrURL( CreateAbsoluteURL() ); diff --git a/cui/source/dialogs/hlmailtp.cxx b/cui/source/dialogs/hlmailtp.cxx index 521af033b422..2d25bed91747 100644 --- a/cui/source/dialogs/hlmailtp.cxx +++ b/cui/source/dialogs/hlmailtp.cxx @@ -37,7 +37,6 @@ SvxHyperlinkMailTp::SvxHyperlinkMailTp(weld::Container* pParent, SvxHpLinkDlg* p : SvxHyperlinkTabPageBase(pParent, pDlg, "cui/ui/hyperlinkmailpage.ui", "HyperlinkMailPage", pItemSet) , m_xCbbReceiver(new SvxHyperURLBox(xBuilder->weld_combo_box("receiver"))) , m_xBtAdrBook(xBuilder->weld_button("addressbook")) - , m_xFtSubject(xBuilder->weld_label("subject_label")) , m_xEdSubject(xBuilder->weld_entry("subject")) { m_xCbbReceiver->SetSmartProtocol(INetProtocol::Mailto); @@ -109,7 +108,7 @@ void SvxHyperlinkMailTp::FillDlgFields(const OUString& rStrURL) |* retrieve and prepare data from dialog-fields |* |************************************************************************/ -void SvxHyperlinkMailTp::GetCurentItemData ( OUString& rStrURL, OUString& aStrName, +void SvxHyperlinkMailTp::GetCurrentItemData ( OUString& rStrURL, OUString& aStrName, OUString& aStrIntName, OUString& aStrFrame, SvxLinkInsertMode& eMode ) { @@ -120,13 +119,7 @@ void SvxHyperlinkMailTp::GetCurentItemData ( OUString& rStrURL, OUString& aStrNa OUString SvxHyperlinkMailTp::CreateAbsoluteURL() const { OUString aStrURL = m_xCbbReceiver->get_active_text(); - INetURLObject aURL(aStrURL); - - if( aURL.GetProtocol() == INetProtocol::NotValid ) - { - aURL.SetSmartProtocol( INetProtocol::Mailto ); - aURL.SetSmartURL(aStrURL); - } + INetURLObject aURL(aStrURL, INetProtocol::Mailto); // subject for EMail-url if( aURL.GetProtocol() == INetProtocol::Mailto ) @@ -216,8 +209,7 @@ IMPL_LINK_NOARG(SvxHyperlinkMailTp, ModifiedReceiverHdl_Impl, weld::ComboBox&, v |************************************************************************/ IMPL_STATIC_LINK_NOARG(SvxHyperlinkMailTp, ClickAdrBookHdl_Impl, weld::Button&, void) { - SfxViewFrame* pViewFrame = SfxViewFrame::Current(); - if( pViewFrame ) + if (SfxViewFrame* pViewFrame = SfxViewFrame::Current()) { SfxItemPool &rPool = pViewFrame->GetPool(); SfxRequest aReq(SID_VIEW_DATA_SOURCE_BROWSER, SfxCallMode::SLOT, rPool); diff --git a/cui/source/dialogs/hlmarkwn.cxx b/cui/source/dialogs/hlmarkwn.cxx index 45b9a75eb2eb..cf90450450ad 100644 --- a/cui/source/dialogs/hlmarkwn.cxx +++ b/cui/source/dialogs/hlmarkwn.cxx @@ -19,6 +19,7 @@ #include <dialmgr.hxx> #include <o3tl/any.hxx> +#include <comphelper/propertyvalue.hxx> #include <unotools/viewoptions.hxx> #include <vcl/graph.hxx> @@ -78,25 +79,33 @@ SvxHlinkDlgMarkWnd::SvxHlinkDlgMarkWnd(weld::Window* pParentDialog, SvxHyperlink mxBtApply->connect_clicked( LINK ( this, SvxHlinkDlgMarkWnd, ClickApplyHdl_Impl ) ); mxBtClose->connect_clicked( LINK ( this, SvxHlinkDlgMarkWnd, ClickCloseHdl_Impl ) ); mxLbTree->connect_row_activated( LINK ( this, SvxHlinkDlgMarkWnd, DoubleClickApplyHdl_Impl ) ); + + // tdf#149935 - remember last used position and size + SvtViewOptions aDlgOpt(EViewType::Dialog, m_xDialog->get_help_id()); + if (aDlgOpt.Exists()) + m_xDialog->set_window_state(aDlgOpt.GetWindowState()); } SvxHlinkDlgMarkWnd::~SvxHlinkDlgMarkWnd() { ClearTree(); + // tdf#149935 - remember last used position and size + SvtViewOptions aDlgOpt(EViewType::Dialog, m_xDialog->get_help_id()); + aDlgOpt.SetWindowState(m_xDialog->get_window_state(vcl::WindowDataMask::PosSize)); } void SvxHlinkDlgMarkWnd::ErrorChanged() { if (mnError == LERR_NOENTRIES) { - OUString aStrMessage = CuiResId( RID_SVXSTR_HYPDLG_ERR_LERR_NOENTRIES ); + OUString aStrMessage = CuiResId( RID_CUISTR_HYPDLG_ERR_LERR_NOENTRIES ); mxError->set_label(aStrMessage); mxError->show(); mxLbTree->hide(); } else if (mnError == LERR_DOCNOTOPEN) { - OUString aStrMessage = CuiResId( RID_SVXSTR_HYPDLG_ERR_LERR_DOCNOTOPEN ); + OUString aStrMessage = CuiResId( RID_CUISTR_HYPDLG_ERR_LERR_DOCNOTOPEN ); mxError->set_label(aStrMessage); mxError->show(); mxLbTree->hide(); @@ -125,7 +134,12 @@ sal_uInt16 SvxHlinkDlgMarkWnd::SetError( sal_uInt16 nError) // Move window void SvxHlinkDlgMarkWnd::MoveTo(const Point& rNewPos) { - m_xDialog->window_move(rNewPos.X(), rNewPos.Y()); + // tdf#149935 - remember last used position and size + SvtViewOptions aDlgOpt(EViewType::Dialog, m_xDialog->get_help_id()); + if (aDlgOpt.Exists()) + m_xDialog->set_window_state(aDlgOpt.GetWindowState()); + else + m_xDialog->window_move(rNewPos.X(), rNewPos.Y()); } namespace @@ -158,9 +172,9 @@ namespace } } -constexpr OUStringLiteral TG_SETTING_MANAGER = u"TargetInDocument"; -constexpr OUStringLiteral TG_SETTING_LASTMARK = u"LastSelectedMark"; -constexpr OUStringLiteral TG_SETTING_LASTPATH = u"LastSelectedPath"; +constexpr OUString TG_SETTING_MANAGER = u"TargetInDocument"_ustr; +constexpr OUString TG_SETTING_LASTMARK = u"LastSelectedMark"_ustr; +constexpr OUString TG_SETTING_LASTPATH = u"LastSelectedPath"_ustr; void SvxHlinkDlgMarkWnd::RestoreLastSelection() { @@ -239,9 +253,7 @@ bool SvxHlinkDlgMarkWnd::RefreshFromDoc(const OUString& aURL) { try { - uno::Sequence< beans::PropertyValue > aArg(1); - aArg.getArray()[0].Name = "Hidden"; - aArg.getArray()[0].Value <<= true; + uno::Sequence< beans::PropertyValue > aArg { comphelper::makePropertyValue("Hidden", true) }; xComp = xDesktop->loadComponentFromURL( aURL, "_blank", 0, aArg ); } catch( const io::IOException& ) @@ -294,9 +306,9 @@ int SvxHlinkDlgMarkWnd::FillTree( const uno::Reference< container::XNameAccess > const sal_Int32 nLinks = aNames.getLength(); const OUString* pNames = aNames.getConstArray(); - static const OUStringLiteral aProp_LinkDisplayName( u"LinkDisplayName" ); - static const OUStringLiteral aProp_LinkTarget( u"com.sun.star.document.LinkTarget" ); - static const OUStringLiteral aProp_LinkDisplayBitmap( u"LinkDisplayBitmap" ); + static constexpr OUStringLiteral aProp_LinkDisplayName( u"LinkDisplayName" ); + static constexpr OUStringLiteral aProp_LinkTarget( u"com.sun.star.document.LinkTarget" ); + static constexpr OUStringLiteral aProp_LinkDisplayBitmap( u"LinkDisplayBitmap" ); for( sal_Int32 i = 0; i < nLinks; i++ ) { uno::Any aAny; @@ -334,7 +346,7 @@ int SvxHlinkDlgMarkWnd::FillTree( const uno::Reference< container::XNameAccess > // create userdata TargetData *pData = new TargetData ( aLink, bIsTarget ); - OUString sId(OUString::number(reinterpret_cast<sal_Int64>(pData))); + OUString sId(weld::toId(pData)); std::unique_ptr<weld::TreeIter> xEntry(mxLbTree->make_iterator()); if (pParentEntry) @@ -367,7 +379,7 @@ int SvxHlinkDlgMarkWnd::FillTree( const uno::Reference< container::XNameAccess > // push if the inserted entry is a child if (nOutlineLevel > aHeadingsParentEntryStack.top().second) aHeadingsParentEntryStack.push( - std::pair(std::move(xEntry), nOutlineLevel)); + std::pair(mxLbTree->make_iterator(xEntry.get()), nOutlineLevel)); } else { @@ -420,7 +432,7 @@ void SvxHlinkDlgMarkWnd::ClearTree() while (bEntry) { - TargetData* pUserData = reinterpret_cast<TargetData*>(mxLbTree->get_id(*xEntry).toInt64()); + TargetData* pUserData = weld::fromId<TargetData*>(mxLbTree->get_id(*xEntry)); delete pUserData; bEntry = mxLbTree->iter_next(*xEntry); @@ -438,7 +450,7 @@ std::unique_ptr<weld::TreeIter> SvxHlinkDlgMarkWnd::FindEntry (std::u16string_vi while (bEntry && !bFound) { - TargetData* pUserData = reinterpret_cast<TargetData*>(mxLbTree->get_id(*xEntry).toInt64()); + TargetData* pUserData = weld::fromId<TargetData*>(mxLbTree->get_id(*xEntry)); if (aStrName == pUserData->aUStrLinkname) bFound = true; else @@ -457,8 +469,7 @@ bool SvxHlinkDlgMarkWnd::SelectEntry(std::u16string_view aStrMark) std::unique_ptr<weld::TreeIter> xEntry = FindEntry(aStrMark); if (!xEntry) return false; - mxLbTree->select(*xEntry); - mxLbTree->scroll_to_row(*xEntry); + mxLbTree->set_cursor(*xEntry); return true; } @@ -475,7 +486,7 @@ IMPL_LINK_NOARG(SvxHlinkDlgMarkWnd, ClickApplyHdl_Impl, weld::Button&, void) bool bEntry = mxLbTree->get_cursor(xEntry.get()); if (bEntry) { - TargetData* pData = reinterpret_cast<TargetData*>(mxLbTree->get_id(*xEntry).toInt64()); + TargetData* pData = weld::fromId<TargetData*>(mxLbTree->get_id(*xEntry)); if (pData->bIsTarget) { mpParent->SetMarkStr(pData->aUStrLinkname); @@ -490,7 +501,7 @@ IMPL_LINK_NOARG(SvxHlinkDlgMarkWnd, ClickCloseHdl_Impl, weld::Button&, void) bool bEntry = mxLbTree->get_cursor(xEntry.get()); if (bEntry) { - TargetData* pUserData = reinterpret_cast<TargetData*>(mxLbTree->get_id(*xEntry).toInt64()); + TargetData* pUserData = weld::fromId<TargetData*>(mxLbTree->get_id(*xEntry)); OUString sLastSelectedMark = pUserData->aUStrLinkname; std::deque<OUString> aLastSelectedPath; diff --git a/cui/source/dialogs/hltpbase.cxx b/cui/source/dialogs/hltpbase.cxx index 987cf97514a9..7f2230e1d87a 100644 --- a/cui/source/dialogs/hltpbase.cxx +++ b/cui/source/dialogs/hltpbase.cxx @@ -37,8 +37,7 @@ #include <strings.hrc> #include <dialmgr.hxx> #include <bitmaps.hlst> - -using namespace ::ucbhelper; +#include <com/sun/star/datatransfer/UnsupportedFlavorException.hpp> namespace { @@ -105,7 +104,7 @@ sal_Int8 SvxHyperURLBox::ExecuteDrop( const ExecuteDropEvent& rEvt ) SvxHyperlinkTabPageBase::SvxHyperlinkTabPageBase(weld::Container* pParent, SvxHpLinkDlg* pDlg, const OUString& rUIXMLDescription, - const OString& rID, + const OUString& rID, const SfxItemSet* pItemSet) : IconChoicePage(pParent, rUIXMLDescription, rID, pItemSet) , mxCbbFrame(xBuilder->weld_combo_box("frame")) @@ -240,9 +239,9 @@ void SvxHyperlinkTabPageBase::FillStandardDlgFields ( const SvxHyperlinkItem* pH mxCbbFrame->set_active(nPos); // Form - OUString aStrFormText = CuiResId( RID_SVXSTR_HYPERDLG_FROM_TEXT ); + OUString aStrFormText = CuiResId( RID_CUISTR_HYPERDLG_FROM_TEXT ); - OUString aStrFormButton = CuiResId( RID_SVXSTR_HYPERDLG_FORM_BUTTON ); + OUString aStrFormButton = CuiResId( RID_CUISTR_HYPERDLG_FORM_BUTTON ); if( pHyperlinkItem->GetInsertMode() & HLINK_HTMLMODE ) { @@ -292,13 +291,6 @@ void SvxHyperlinkTabPageBase::DoApply () // default-implementation : do nothing } -// Ask page whether an insert is possible -bool SvxHyperlinkTabPageBase::AskApply () -{ - // default-implementation - return true; -} - // This method would be called from bookmark-window to set new mark-string void SvxHyperlinkTabPageBase::SetMarkStr ( const OUString& /*aStrMark*/ ) { @@ -329,8 +321,8 @@ void SvxHyperlinkTabPageBase::DisableClose(bool _bDisable) // Click on imagebutton : Script IMPL_LINK_NOARG(SvxHyperlinkTabPageBase, ClickScriptHdl_Impl, weld::Button&, void) { - SvxHyperlinkItem *pHyperlinkItem = const_cast<SvxHyperlinkItem*>(static_cast<const SvxHyperlinkItem *>( - GetItemSet().GetItem (SID_HYPERLINK_GETLINK))); + SvxHyperlinkItem *pHyperlinkItem = const_cast<SvxHyperlinkItem*>( + GetItemSet().GetItem (SID_HYPERLINK_GETLINK)); if (!pHyperlinkItem || pHyperlinkItem->GetMacroEvents() == HyperDialogEvent::NONE) return; @@ -353,13 +345,13 @@ IMPL_LINK_NOARG(SvxHyperlinkTabPageBase, ClickScriptHdl_Impl, weld::Button&, voi SfxMacroTabPage *pMacroPage = aDlg.GetTabPage(); if ( pHyperlinkItem->GetMacroEvents() & HyperDialogEvent::MouseOverObject ) - pMacroPage->AddEvent( CuiResId(RID_SVXSTR_HYPDLG_MACROACT1), + pMacroPage->AddEvent( CuiResId(RID_CUISTR_HYPDLG_MACROACT1), SvMacroItemId::OnMouseOver ); if ( pHyperlinkItem->GetMacroEvents() & HyperDialogEvent::MouseClickObject ) - pMacroPage->AddEvent( CuiResId(RID_SVXSTR_HYPDLG_MACROACT2), + pMacroPage->AddEvent( CuiResId(RID_CUISTR_HYPDLG_MACROACT2), SvMacroItemId::OnClick); if ( pHyperlinkItem->GetMacroEvents() & HyperDialogEvent::MouseOutObject ) - pMacroPage->AddEvent( CuiResId(RID_SVXSTR_HYPDLG_MACROACT3), + pMacroPage->AddEvent( CuiResId(RID_CUISTR_HYPDLG_MACROACT3), SvMacroItemId::OnMouseOut); // execute dlg short nRet = aDlg.run(); @@ -378,16 +370,16 @@ IMPL_LINK_NOARG(SvxHyperlinkTabPageBase, ClickScriptHdl_Impl, weld::Button&, voi // Get Macro-Infos HyperDialogEvent SvxHyperlinkTabPageBase::GetMacroEvents() const { - const SvxHyperlinkItem *pHyperlinkItem = static_cast<const SvxHyperlinkItem *>( - GetItemSet().GetItem (SID_HYPERLINK_GETLINK)); + const SvxHyperlinkItem *pHyperlinkItem = + GetItemSet().GetItem (SID_HYPERLINK_GETLINK); return pHyperlinkItem ? pHyperlinkItem->GetMacroEvents() : HyperDialogEvent(); } SvxMacroTableDtor* SvxHyperlinkTabPageBase::GetMacroTable() { - const SvxHyperlinkItem *pHyperlinkItem = static_cast<const SvxHyperlinkItem *>( - GetItemSet().GetItem (SID_HYPERLINK_GETLINK)); + const SvxHyperlinkItem *pHyperlinkItem = + GetItemSet().GetItem (SID_HYPERLINK_GETLINK); return const_cast<SvxMacroTableDtor*>(pHyperlinkItem->GetMacroTable()); } @@ -452,19 +444,52 @@ void SvxHyperlinkTabPageBase::Reset( const SfxItemSet& rItemSet) // Set dialog-fields from create-itemset maStrInitURL.clear(); - const SvxHyperlinkItem *pHyperlinkItem = static_cast<const SvxHyperlinkItem *>( - rItemSet.GetItem (SID_HYPERLINK_GETLINK)); + const SvxHyperlinkItem *pHyperlinkItem = + rItemSet.GetItem (SID_HYPERLINK_GETLINK); if ( pHyperlinkItem ) { + // tdf#146576 - propose clipboard content when inserting a hyperlink + OUString aStrURL(pHyperlinkItem->GetURL()); + // Store initial URL + maStrInitURL = aStrURL; + if (aStrURL.isEmpty()) + { + if (auto xClipboard = GetSystemClipboard()) + { + if (auto xTransferable = xClipboard->getContents()) + { + css::datatransfer::DataFlavor aFlavor; + SotExchange::GetFormatDataFlavor(SotClipboardFormatId::STRING, aFlavor); + if (xTransferable->isDataFlavorSupported(aFlavor)) + { + OUString aClipBoardContent; + try + { + if (xTransferable->getTransferData(aFlavor) >>= aClipBoardContent) + { + INetURLObject aURL; + aURL.SetSmartURL(aClipBoardContent); + if (!aURL.HasError()) + aStrURL + = aURL.GetMainURL(INetURLObject::DecodeMechanism::Unambiguous); + } + } + // tdf#158345: Opening Hyperlink dialog leads to crash + // MimeType = "text/plain;charset=utf-16" + catch(const css::datatransfer::UnsupportedFlavorException&) + { + } + } + } + } + } + // set dialog-fields FillStandardDlgFields (pHyperlinkItem); // set all other fields - FillDlgFields ( pHyperlinkItem->GetURL() ); - - // Store initial URL - maStrInitURL = pHyperlinkItem->GetURL(); + FillDlgFields(aStrURL); } } @@ -474,7 +499,7 @@ bool SvxHyperlinkTabPageBase::FillItemSet( SfxItemSet* rOut) OUString aStrURL, aStrName, aStrIntName, aStrFrame; SvxLinkInsertMode eMode; - GetCurentItemData ( aStrURL, aStrName, aStrIntName, aStrFrame, eMode); + GetCurrentItemData ( aStrURL, aStrName, aStrIntName, aStrFrame, eMode); if ( aStrName.isEmpty() ) //automatically create a visible name if the link is created without name aStrName = CreateUiNameFromURL(aStrURL); @@ -493,8 +518,8 @@ void SvxHyperlinkTabPageBase::ActivatePage( const SfxItemSet& rItemSet ) { // Set dialog-fields from input-itemset - const SvxHyperlinkItem *pHyperlinkItem = static_cast<const SvxHyperlinkItem *>( - rItemSet.GetItem (SID_HYPERLINK_GETLINK)); + const SvxHyperlinkItem *pHyperlinkItem = + rItemSet.GetItem (SID_HYPERLINK_GETLINK); if ( pHyperlinkItem ) { @@ -517,7 +542,7 @@ DeactivateRC SvxHyperlinkTabPageBase::DeactivatePage( SfxItemSet* _pSet) OUString aStrURL, aStrName, aStrIntName, aStrFrame; SvxLinkInsertMode eMode; - GetCurentItemData ( aStrURL, aStrName, aStrIntName, aStrFrame, eMode); + GetCurrentItemData ( aStrURL, aStrName, aStrIntName, aStrFrame, eMode); HyperDialogEvent nEvents = GetMacroEvents(); SvxMacroTableDtor* pTable = GetMacroTable(); diff --git a/cui/source/dialogs/hyphen.cxx b/cui/source/dialogs/hyphen.cxx index 0535902d4447..10ad1d9bba5b 100644 --- a/cui/source/dialogs/hyphen.cxx +++ b/cui/source/dialogs/hyphen.cxx @@ -27,6 +27,7 @@ #include <sal/log.hxx> #include <i18nlangtag/languagetag.hxx> #include <tools/debug.hxx> +#include <utility> #define HYPH_POS_CHAR '=' @@ -158,11 +159,11 @@ OUString SvxHyphenWordDialog::EraseUnusableHyphens_Impl() } // 2) remove all hyphenation positions from the start that are not considered by the core - const OUString aSearchRange( aTxt.copy( 0, nPos1 ) ); - sal_Int32 nPos2 = aSearchRange.lastIndexOf( '-' ); // the '-' position the core will use by default - if (nPos2 != -1 ) + const std::u16string_view aSearchRange( aTxt.subView( 0, nPos1 ) ); + size_t nPos2 = aSearchRange.rfind( '-' ); // the '-' position the core will use by default + if (nPos2 != std::u16string_view::npos && nPos2 != 0) { - OUString aLeft( aSearchRange.copy( 0, nPos2 ) ); + OUString aLeft( aSearchRange.substr( 0, nPos2 ) ); nPos = 0; while (nPos != -1) { @@ -170,6 +171,8 @@ OUString SvxHyphenWordDialog::EraseUnusableHyphens_Impl() aLeft = aLeft.replaceFirst( aTmp, "", &nPos ); if (nPos != -1) ++m_nHyphenationPositionsOffset; + if (nPos >= aLeft.getLength()) // tdf#158837 + break; } aTxt = aTxt.replaceAt( 0, nPos2, aLeft ); } @@ -402,13 +405,13 @@ IMPL_LINK_NOARG(SvxHyphenWordDialog, GetFocusHdl_Impl, weld::Widget&, void) // class SvxHyphenWordDialog --------------------------------------------- SvxHyphenWordDialog::SvxHyphenWordDialog( - const OUString &rWord, LanguageType nLang, + OUString aWord, LanguageType nLang, weld::Widget* pParent, uno::Reference< linguistic2::XHyphenator > const &xHyphen, SvxSpellWrapper* pWrapper) : SfxDialogController(pParent, "cui/ui/hyphenate.ui", "HyphenateDialog") , m_pHyphWrapper(pWrapper) - , m_aActWord(rWord) + , m_aActWord(std::move(aWord)) , m_nActLanguage(nLang) , m_nMaxHyphenationPos(0) , m_nOldPos(0) diff --git a/cui/source/dialogs/iconcdlg.cxx b/cui/source/dialogs/iconcdlg.cxx index 6e6ffaf5c53a..9bda9d215dcf 100644 --- a/cui/source/dialogs/iconcdlg.cxx +++ b/cui/source/dialogs/iconcdlg.cxx @@ -18,6 +18,7 @@ */ #include <iconcdlg.hxx> +#include <comphelper/lok.hxx> #include <cuihyperdlg.hxx> #include <cassert> @@ -31,7 +32,7 @@ \**********************************************************************/ IconChoicePage::IconChoicePage(weld::Container* pParent, - const OUString& rUIXMLDescription, const OString& rID, + const OUString& rUIXMLDescription, const OUString& rID, const SfxItemSet* pItemSet) : xBuilder(Application::CreateBuilder(pParent, rUIXMLDescription)) , xContainer(xBuilder->weld_container(rID)) @@ -70,7 +71,7 @@ bool IconChoicePage::QueryClose() | add new page | \**********************************************************************/ -void SvxHpLinkDlg::AddTabPage(const OString& rId, CreatePage pCreateFunc /* != 0 */) +void SvxHpLinkDlg::AddTabPage(const OUString& rId, CreatePage pCreateFunc /* != 0 */) { weld::Container* pPage = m_xIconCtrl->get_page(rId); maPageList.emplace_back(new IconChoicePageData(rId, pCreateFunc(pPage, this, pSet))); @@ -83,9 +84,9 @@ void SvxHpLinkDlg::AddTabPage(const OString& rId, CreatePage pCreateFunc /* != 0 | Show / Hide page or button | \**********************************************************************/ -void SvxHpLinkDlg::ShowPage(const OString& rId) +void SvxHpLinkDlg::ShowPage(const OUString& rId) { - OString sOldPageId = GetCurPageId(); + OUString sOldPageId = GetCurPageId(); bool bInvalidate = sOldPageId != rId; if (bInvalidate) { @@ -104,7 +105,7 @@ void SvxHpLinkDlg::ShowPage(const OString& rId) | select a page | \**********************************************************************/ -IMPL_LINK(SvxHpLinkDlg, ChosePageHdl_Impl, const OString&, rId, void) +IMPL_LINK(SvxHpLinkDlg, ChosePageHdl_Impl, const OUString&, rId, void) { if (rId != msCurrentPageId) { @@ -148,7 +149,11 @@ void SvxHpLinkDlg::ActivatePageImpl() pData->xPage->ActivatePage( *pExampleSet ); m_xDialog->set_help_id(pData->xPage->GetHelpId()); - m_xResetBtn->show(); + // tdf#90496 - remember last used view in hyperlink dialog + msRememberedPageId = msCurrentPageId; + + if (!comphelper::LibreOfficeKit::isActive()) + m_xResetBtn->show(); } void SvxHpLinkDlg::DeActivatePageImpl () @@ -280,7 +285,7 @@ void SvxHpLinkDlg::Start() | \**********************************************************************/ -IconChoicePageData* SvxHpLinkDlg::GetPageData ( std::string_view rId ) +IconChoicePageData* SvxHpLinkDlg::GetPageData ( std::u16string_view rId ) { IconChoicePageData *pRet = nullptr; for (const auto & pData : maPageList) @@ -300,7 +305,7 @@ IconChoicePageData* SvxHpLinkDlg::GetPageData ( std::string_view rId ) | \**********************************************************************/ -void SvxHpLinkDlg::SwitchPage( const OString& rId ) +void SvxHpLinkDlg::SwitchPage( const OUString& rId ) { m_xIconCtrl->set_current_page(rId); } diff --git a/cui/source/dialogs/insdlg.cxx b/cui/source/dialogs/insdlg.cxx index eddc80a83b09..e4c1c6687768 100644 --- a/cui/source/dialogs/insdlg.cxx +++ b/cui/source/dialogs/insdlg.cxx @@ -41,7 +41,8 @@ #include <tools/urlobj.hxx> #include <tools/debug.hxx> #include <tools/stream.hxx> -#include <tools/diagnose_ex.h> +#include <comphelper/diagnose_ex.hxx> +#include <utility> #include <vcl/image.hxx> #include <vcl/weld.hxx> #include <vcl/svapp.hxx> @@ -57,7 +58,6 @@ using namespace ::com::sun::star; using namespace ::com::sun::star::lang; using namespace ::com::sun::star::uno; -using namespace ::com::sun::star::container; using namespace ::com::sun::star::ui::dialogs; bool InsertObjectDialog_Impl::IsCreateNew() const @@ -71,10 +71,10 @@ uno::Reference< io::XInputStream > InsertObjectDialog_Impl::GetIconIfIconified( } InsertObjectDialog_Impl::InsertObjectDialog_Impl(weld::Window* pParent, - const OUString& rUIXMLDescription, const OString& rID, - const css::uno::Reference < css::embed::XStorage >& xStorage) + const OUString& rUIXMLDescription, const OUString& rID, + css::uno::Reference < css::embed::XStorage > xStorage) : GenericDialogController(pParent, rUIXMLDescription, rID) - , m_xStorage( xStorage ) + , m_xStorage(std::move( xStorage )) , aCnt( m_xStorage ) { } @@ -94,7 +94,7 @@ IMPL_LINK_NOARG(SvInsertOleDlg, BrowseHdl, weld::Button&, void) // add filter try { - xFilePicker->appendFilter(CuiResId(RID_SVXSTR_FILTER_ALL), "*.*"); + xFilePicker->appendFilter(CuiResId(RID_CUISTR_FILTER_ALL), "*.*"); } catch( const IllegalArgumentException& ) { @@ -195,8 +195,7 @@ short SvInsertOleDlg::run() uno::Reference<task::XStatusIndicator> xProgress; OUString aProgressText; - SfxViewFrame* pFrame = SfxViewFrame::Current(); - if (pFrame) + if (SfxViewFrame* pFrame = SfxViewFrame::Current()) { // Have a current frame, create a matching progressbar, but don't start it yet. uno::Reference<frame::XFrame> xFrame @@ -208,7 +207,7 @@ short SvInsertOleDlg::run() xProgress = xProgressFactory->createStatusIndicator(); if (xProgress) { - aProgressText = CuiResId(RID_SVXSTR_OLE_INSERT); + aProgressText = CuiResId(RID_CUISTR_OLE_INSERT); } } } @@ -301,8 +300,7 @@ short SvInsertOleDlg::run() // create object from media descriptor uno::Reference<task::XStatusIndicator> xProgress; - SfxViewFrame* pFrame = SfxViewFrame::Current(); - if (pFrame) + if (SfxViewFrame* pFrame = SfxViewFrame::Current()) { // Have a current frame, create visual indication that insert is in progress. uno::Reference<frame::XFrame> xFrame = pFrame->GetFrame().GetFrameInterface(); @@ -312,7 +310,7 @@ short SvInsertOleDlg::run() xProgress = xProgressFactory->createStatusIndicator(); if (xProgress) { - OUString aOleInsert(CuiResId(RID_SVXSTR_OLE_INSERT)); + OUString aOleInsert(CuiResId(RID_CUISTR_OLE_INSERT)); xProgress->start(aOleInsert, 100); } } @@ -624,7 +622,7 @@ IMPL_LINK_NOARG( SfxInsertFloatingFrameDialog, OpenHdl, weld::Button&, void) SfxFilterFlags::NONE, SfxFilterFlags::NONE, m_xDialog.get()); // set the title - aFileDlg.SetTitle(CuiResId(RID_SVXSTR_SELECT_FILE_IFRAME)); + aFileDlg.SetTitle(CuiResId(RID_CUISTR_SELECT_FILE_IFRAME)); // show the dialog if ( aFileDlg.Execute() == ERRCODE_NONE ) diff --git a/cui/source/dialogs/insrc.cxx b/cui/source/dialogs/insrc.cxx index 862963275df8..6c09c8ce4560 100644 --- a/cui/source/dialogs/insrc.cxx +++ b/cui/source/dialogs/insrc.cxx @@ -31,29 +31,44 @@ sal_uInt16 SvxInsRowColDlg::getInsertCount() const return m_xCountEdit->get_value(); } -SvxInsRowColDlg::SvxInsRowColDlg(weld::Window* pParent, bool bColumn, const OString& rHelpId) +SvxInsRowColDlg::SvxInsRowColDlg(weld::Window* pParent, bool bColumn, const OUString& rHelpId) : GenericDialogController(pParent, "cui/ui/insertrowcolumn.ui", "InsertRowColumnDialog") , m_xCountEdit(m_xBuilder->weld_spin_button("insert_number")) , m_xBeforeBtn(m_xBuilder->weld_radio_button("insert_before")) , m_xAfterBtn(m_xBuilder->weld_radio_button("insert_after")) { - m_xDialog->set_title(bColumn ? CuiResId(RID_SVXSTR_COL) : CuiResId(RID_SVXSTR_ROW)); + m_xDialog->set_title(bColumn ? CuiResId(RID_CUISTR_COL) : CuiResId(RID_CUISTR_ROW)); // tdf#119293 if (bColumn) { - m_xBeforeBtn->set_label(CuiResId(RID_SVXSTR_INSERTCOL_BEFORE)); - m_xAfterBtn->set_label(CuiResId(RID_SVXSTR_INSERTCOL_AFTER)); + m_xBeforeBtn->set_label(CuiResId(RID_CUISTR_INSERTCOL_BEFORE)); + m_xAfterBtn->set_label(CuiResId(RID_CUISTR_INSERTCOL_AFTER)); } else { - m_xBeforeBtn->set_label(CuiResId(RID_SVXSTR_INSERTROW_BEFORE)); - m_xAfterBtn->set_label(CuiResId(RID_SVXSTR_INSERTROW_AFTER)); + m_xBeforeBtn->set_label(CuiResId(RID_CUISTR_INSERTROW_BEFORE)); + m_xAfterBtn->set_label(CuiResId(RID_CUISTR_INSERTROW_AFTER)); } m_xDialog->set_help_id(rHelpId); } -short SvxInsRowColDlg::Execute() +short SvxAbstractInsRowColDlg_Impl::Execute() { - return run(); + return m_xDlg->run(); +} + +bool SvxAbstractInsRowColDlg_Impl::StartExecuteAsync(AsyncContext &rCtx) +{ + return weld::GenericDialogController::runAsync(m_xDlg, rCtx.maEndDialogFn); +} + +bool SvxAbstractInsRowColDlg_Impl::isInsertBefore() const +{ + return m_xDlg->isInsertBefore(); +} + +sal_uInt16 SvxAbstractInsRowColDlg_Impl::getInsertCount() const +{ + return m_xDlg->getInsertCount(); } /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/cui/source/dialogs/linkdlg.cxx b/cui/source/dialogs/linkdlg.cxx index 01026742da15..b31c5d74a783 100644 --- a/cui/source/dialogs/linkdlg.cxx +++ b/cui/source/dialogs/linkdlg.cxx @@ -21,7 +21,7 @@ #include <o3tl/safeint.hxx> #include <vcl/svapp.hxx> -#include <tools/diagnose_ex.h> +#include <comphelper/diagnose_ex.hxx> #include <tools/debug.hxx> #include <tools/urlobj.hxx> #include <vcl/idle.hxx> @@ -37,7 +37,7 @@ #include <sfx2/objsh.hxx> #include <com/sun/star/ui/dialogs/ExecutableDialogResults.hpp> -#include <com/sun/star/ui/dialogs/FolderPicker.hpp> +#include <com/sun/star/ui/dialogs/XFolderPicker2.hpp> #include <comphelper/processfactory.hxx> #include <dialmgr.hxx> @@ -149,7 +149,7 @@ void SvBaseLinksDlg::LinksSelectHdl(weld::TreeView* pSvTabListBox) { // possibly deselect old entries in case of multi-selection int nSelEntry = pSvTabListBox->get_selected_index(); - SvBaseLink* pLink = reinterpret_cast<SvBaseLink*>(pSvTabListBox->get_id(nSelEntry).toInt64()); + SvBaseLink* pLink = weld::fromId<SvBaseLink*>(pSvTabListBox->get_id(nSelEntry)); SvBaseLinkObjectType nObjectType = pLink->GetObjType(); if(!isClientFileType(nObjectType)) { @@ -161,7 +161,7 @@ void SvBaseLinksDlg::LinksSelectHdl(weld::TreeView* pSvTabListBox) std::vector<int> aRows = pSvTabListBox->get_selected_rows(); for (auto nEntry : aRows) { - pLink = reinterpret_cast<SvBaseLink*>(pSvTabListBox->get_id(nEntry).toInt64()); + pLink = weld::fromId<SvBaseLink*>(pSvTabListBox->get_id(nEntry)); DBG_ASSERT(pLink, "Where is the Link?"); if (!pLink) continue; @@ -255,7 +255,7 @@ IMPL_LINK_NOARG(SvBaseLinksDlg, UpdateNowClickHdl, weld::Button&, void) std::vector<int> aRows = m_xTbLinks->get_selected_rows(); for (int nFndPos : aRows) { - aLnkArr.push_back( reinterpret_cast<SvBaseLink*>( m_xTbLinks->get_id(nFndPos).toInt64() ) ); + aLnkArr.push_back( weld::fromId<SvBaseLink*>( m_xTbLinks->get_id(nFndPos) ) ); aPosArr.push_back( nFndPos ); } @@ -281,7 +281,7 @@ IMPL_LINK_NOARG(SvBaseLinksDlg, UpdateNowClickHdl, weld::Button&, void) SetManager( pNewMgr ); - OUString sId = OUString::number(reinterpret_cast<sal_Int64>(aLnkArr[0])); + OUString sId = weld::toId(aLnkArr[0]); int nE = m_xTbLinks->find_id(sId); if (nE == -1) nE = m_xTbLinks->get_selected_index(); @@ -306,7 +306,7 @@ IMPL_LINK_NOARG(SvBaseLinksDlg, ChangeSourceClickHdl, weld::Button&, void) OUString sType, sFile, sLinkName; OUString sFilter; - SvBaseLink* pLink = reinterpret_cast<SvBaseLink*>(m_xTbLinks->get_id(aRows[0]).toInt64()); + SvBaseLink* pLink = weld::fromId<SvBaseLink*>(m_xTbLinks->get_id(aRows[0])); sfx2::LinkManager::GetDisplayNames( pLink, &sType, &sFile ); INetURLObject aUrl(sFile); if(aUrl.GetProtocol() == INetProtocol::File) @@ -322,7 +322,7 @@ IMPL_LINK_NOARG(SvBaseLinksDlg, ChangeSourceClickHdl, weld::Button&, void) for (auto nRow : aRows) { - pLink = reinterpret_cast<SvBaseLink*>(m_xTbLinks->get_id(nRow).toInt64()); + pLink = weld::fromId<SvBaseLink*>(m_xTbLinks->get_id(nRow)); DBG_ASSERT(pLink,"Where is the link?"); if (!pLink) continue; @@ -409,7 +409,7 @@ IMPL_LINK_NOARG( SvBaseLinksDlg, BreakLinkClickHdl, weld::Button&, void ) SvBaseLinkMemberList aLinkList; for (auto nRow : aRows) { - SvBaseLink* pLink = reinterpret_cast<SvBaseLink*>(m_xTbLinks->get_id(nRow).toInt64()); + SvBaseLink* pLink = weld::fromId<SvBaseLink*>(m_xTbLinks->get_id(nRow)); if (pLink) aLinkList.push_back(pLink); } @@ -452,7 +452,7 @@ IMPL_LINK_NOARG( SvBaseLinksDlg, UpdateWaitingHdl, Timer*, void ) m_xTbLinks->freeze(); for (int nPos = m_xTbLinks->n_children(); nPos; --nPos) { - tools::SvRef<SvBaseLink> xLink( reinterpret_cast<SvBaseLink*>(m_xTbLinks->get_id(nPos).toInt64()) ); + tools::SvRef<SvBaseLink> xLink( weld::fromId<SvBaseLink*>(m_xTbLinks->get_id(nPos)) ); if( xLink.is() ) { OUString sCur( ImplGetStateStr( *xLink ) ), @@ -583,7 +583,7 @@ void SvBaseLinksDlg::InsertEntry(const SvBaseLink& rLink, int nPos, bool bSelect nPos = m_xTbLinks->n_children(); m_xTbLinks->insert(nPos); m_xTbLinks->set_text(nPos, aTxt, 0); - m_xTbLinks->set_id(nPos, OUString::number(reinterpret_cast<sal_Int64>(&rLink))); + m_xTbLinks->set_id(nPos, weld::toId(&rLink)); if( SvBaseLinkObjectType::ClientGraphic == rLink.GetObjType() ) m_xTbLinks->set_text(nPos, sFilter, 1); else @@ -601,7 +601,7 @@ SvBaseLink* SvBaseLinksDlg::GetSelEntry(int* pPos) { if (pPos) *pPos = nPos; - return reinterpret_cast<SvBaseLink*>(m_xTbLinks->get_id(nPos).toInt64()); + return weld::fromId<SvBaseLink*>(m_xTbLinks->get_id(nPos)); } return nullptr; } diff --git a/cui/source/dialogs/multipat.cxx b/cui/source/dialogs/multipat.cxx index aba063eb7b13..e385a6ccface 100644 --- a/cui/source/dialogs/multipat.cxx +++ b/cui/source/dialogs/multipat.cxx @@ -30,12 +30,12 @@ #include <strings.hrc> #include <comphelper/processfactory.hxx> -#include <com/sun/star/ui/dialogs/FolderPicker.hpp> +#include <com/sun/star/ui/dialogs/XFolderPicker2.hpp> #include <com/sun/star/ui/dialogs/ExecutableDialogResults.hpp> #include <unotools/pathoptions.hxx> +#include <o3tl/string_view.hxx> -using namespace ::com::sun::star::lang; using namespace ::com::sun::star::ui::dialogs; using namespace ::com::sun::star::uno; @@ -262,16 +262,16 @@ OUString SvxPathSelectDialog::GetPath() const return sNewPath.makeStringAndClear(); } -void SvxMultiPathDialog::SetPath( const OUString& rPath ) +void SvxMultiPathDialog::SetPath( std::u16string_view rPath ) { - if ( !rPath.isEmpty() ) + if ( !rPath.empty() ) { const sal_Unicode cDelim = SVT_SEARCHPATH_DELIMITER; int nCount = 0; sal_Int32 nIndex = 0; do { - const OUString sPath = rPath.getToken( 0, cDelim, nIndex ); + const OUString sPath( o3tl::getToken(rPath, 0, cDelim, nIndex ) ); OUString sSystemPath; bool bIsSystemPath = osl::FileBase::getSystemPathFromFileURL(sPath, sSystemPath) == osl::FileBase::E_None; @@ -292,14 +292,14 @@ void SvxMultiPathDialog::SetPath( const OUString& rPath ) SelectHdl_Impl(*m_xRadioLB); } -void SvxPathSelectDialog::SetPath(const OUString& rPath) +void SvxPathSelectDialog::SetPath(std::u16string_view rPath) { - if ( !rPath.isEmpty() ) + if ( !rPath.empty() ) { sal_Int32 nIndex = 0; do { - const OUString sPath = rPath.getToken( 0, SVT_SEARCHPATH_DELIMITER, nIndex ); + const OUString sPath( o3tl::getToken(rPath, 0, SVT_SEARCHPATH_DELIMITER, nIndex ) ); OUString sSystemPath; bool bIsSystemPath = osl::FileBase::getSystemPathFromFileURL(sPath, sSystemPath) == osl::FileBase::E_None; diff --git a/cui/source/dialogs/passwdomdlg.cxx b/cui/source/dialogs/passwdomdlg.cxx index d84595ac89a7..a7e95a29f3b4 100644 --- a/cui/source/dialogs/passwdomdlg.cxx +++ b/cui/source/dialogs/passwdomdlg.cxx @@ -17,50 +17,72 @@ * the License at http://www.apache.org/licenses/LICENSE-2.0 . */ +#include <sfx2/objsh.hxx> +#include <svl/PasswordHelper.hxx> #include <vcl/svapp.hxx> +#include <officecfg/Office/Common.hxx> #include <passwdomdlg.hxx> #include <strings.hrc> #include <dialmgr.hxx> IMPL_LINK_NOARG(PasswordToOpenModifyDialog, OkBtnClickHdl, weld::Button&, void) { - bool bInvalidState = !m_xOpenReadonlyCB->get_active() && + bool bInvalidState = !m_xOpenReadonlyCB->get_active() && !m_bAllowEmpty && m_xPasswdToOpenED->get_text().isEmpty() && m_xPasswdToModifyED->get_text().isEmpty(); if (bInvalidState) { - std::unique_ptr<weld::MessageDialog> xErrorBox(Application::CreateMessageDialog(m_xDialog.get(), + m_xErrorBox.reset(Application::CreateMessageDialog(m_xDialog.get(), VclMessageType::Warning, VclButtonsType::Ok, m_bIsPasswordToModify? m_aInvalidStateForOkButton : m_aInvalidStateForOkButton_v2)); - xErrorBox->run(); + m_xErrorBox->runAsync(m_xErrorBox, [](sal_Int32 /*nResult*/) {}); } - else // check for mismatched passwords... + else // check for mismatched passwords and password policy { + if (m_oPasswordPolicy) + { + if (!SvPasswordHelper::PasswordMeetsPolicy(m_xPasswdToOpenED->get_text(), + m_oPasswordPolicy)) + { + m_xPasswdToOpenED->grab_focus(); + return; + } + + if (m_xOpenReadonlyCB->get_active() + && !SvPasswordHelper::PasswordMeetsPolicy(m_xPasswdToModifyED->get_text(), + m_oPasswordPolicy)) + { + m_xPasswdToModifyED->grab_focus(); + return; + } + } + const bool bToOpenMatch = m_xPasswdToOpenED->get_text() == m_xReenterPasswdToOpenED->get_text(); const bool bToModifyMatch = m_xPasswdToModifyED->get_text() == m_xReenterPasswdToModifyED->get_text(); const int nMismatch = (bToOpenMatch? 0 : 1) + (bToModifyMatch? 0 : 1); if (nMismatch > 0) { - std::unique_ptr<weld::MessageDialog> xErrorBox(Application::CreateMessageDialog(m_xDialog.get(), + m_xErrorBox.reset(Application::CreateMessageDialog(m_xDialog.get(), VclMessageType::Warning, VclButtonsType::Ok, nMismatch == 1 ? m_aOneMismatch : m_aTwoMismatch)); - xErrorBox->run(); - - weld::Entry* pEdit = !bToOpenMatch ? m_xPasswdToOpenED.get() : m_xPasswdToModifyED.get(); - weld::Entry* pRepeatEdit = !bToOpenMatch? m_xReenterPasswdToOpenED.get() : m_xReenterPasswdToModifyED.get(); - if (nMismatch == 1) - { - pEdit->set_text( "" ); - pRepeatEdit->set_text( "" ); - } - else if (nMismatch == 2) + m_xErrorBox->runAsync(m_xErrorBox, [this, bToOpenMatch, nMismatch](sal_Int32 /*nResult*/) { - m_xPasswdToOpenED->set_text( "" ); - m_xReenterPasswdToOpenED->set_text( "" ); - m_xPasswdToModifyED->set_text( "" ); - m_xReenterPasswdToModifyED->set_text( "" ); - } - pEdit->grab_focus(); + weld::Entry* pEdit = !bToOpenMatch ? m_xPasswdToOpenED.get() : m_xPasswdToModifyED.get(); + weld::Entry* pRepeatEdit = !bToOpenMatch? m_xReenterPasswdToOpenED.get() : m_xReenterPasswdToModifyED.get(); + if (nMismatch == 1) + { + pEdit->set_text( "" ); + pRepeatEdit->set_text( "" ); + } + else if (nMismatch == 2) + { + m_xPasswdToOpenED->set_text( "" ); + m_xReenterPasswdToOpenED->set_text( "" ); + m_xPasswdToModifyED->set_text( "" ); + m_xReenterPasswdToModifyED->set_text( "" ); + } + pEdit->grab_focus(); + }); } else { @@ -71,24 +93,57 @@ IMPL_LINK_NOARG(PasswordToOpenModifyDialog, OkBtnClickHdl, weld::Button&, void) IMPL_LINK(PasswordToOpenModifyDialog, ChangeHdl, weld::Entry&, rEntry, void) { + auto aPasswordText = rEntry.get_text(); + weld::Label* pIndicator = nullptr; - int nLength = rEntry.get_text().getLength(); + weld::LevelBar* pLevelBar = nullptr; if (&rEntry == m_xPasswdToOpenED.get()) + { pIndicator = m_xPasswdToOpenInd.get(); + pLevelBar = m_xPasswdToOpenBar.get(); + } else if (&rEntry == m_xReenterPasswdToOpenED.get()) + { pIndicator = m_xReenterPasswdToOpenInd.get(); + } else if (&rEntry == m_xPasswdToModifyED.get()) + { pIndicator = m_xPasswdToModifyInd.get(); + pLevelBar = m_xPasswdToModifyBar.get(); + } else if (&rEntry == m_xReenterPasswdToModifyED.get()) + { pIndicator = m_xReenterPasswdToModifyInd.get(); + } assert(pIndicator); - pIndicator->set_visible(nLength >= m_nMaxPasswdLen); + + bool bPasswordMeetsPolicy + = SvPasswordHelper::PasswordMeetsPolicy(aPasswordText, m_oPasswordPolicy); + if (pLevelBar) + { + rEntry.set_message_type(bPasswordMeetsPolicy ? weld::EntryMessageType::Normal + : weld::EntryMessageType::Error); + pIndicator->set_visible(!bPasswordMeetsPolicy); + } + + // if password doesn't meet policy cap the percentage at 70% + if (pLevelBar) + pLevelBar->set_percentage( + std::min(SvPasswordHelper::GetPasswordStrengthPercentage(aPasswordText), + bPasswordMeetsPolicy ? std::numeric_limits<double>::max() : 70.0)); + + if (m_nMaxPasswdLen) + { + int nLength = aPasswordText.getLength(); + pIndicator->set_visible(nLength >= m_nMaxPasswdLen); + } } PasswordToOpenModifyDialog::PasswordToOpenModifyDialog(weld::Window * pParent, sal_uInt16 nMaxPasswdLen, bool bIsPasswordToModify) : SfxDialogController(pParent, "cui/ui/password.ui", "PasswordDialog") , m_xPasswdToOpenED(m_xBuilder->weld_entry("newpassEntry")) , m_xPasswdToOpenInd(m_xBuilder->weld_label("newpassIndicator")) + , m_xPasswdToOpenBar(m_xBuilder->weld_level_bar("passlevelbar")) , m_xReenterPasswdToOpenED(m_xBuilder->weld_entry("confirmpassEntry")) , m_xReenterPasswdToOpenInd(m_xBuilder->weld_label("confirmpassIndicator")) , m_xOptionsExpander(m_xBuilder->weld_expander("expander")) @@ -97,33 +152,59 @@ PasswordToOpenModifyDialog::PasswordToOpenModifyDialog(weld::Window * pParent, s , m_xPasswdToModifyFT(m_xBuilder->weld_label("label7")) , m_xPasswdToModifyED(m_xBuilder->weld_entry("newpassroEntry")) , m_xPasswdToModifyInd(m_xBuilder->weld_label("newpassroIndicator")) + , m_xPasswdToModifyBar(m_xBuilder->weld_level_bar("ropasslevelbar")) , m_xReenterPasswdToModifyFT(m_xBuilder->weld_label("label8")) , m_xReenterPasswdToModifyED(m_xBuilder->weld_entry("confirmropassEntry")) , m_xReenterPasswdToModifyInd(m_xBuilder->weld_label("confirmropassIndicator")) - , m_aOneMismatch( CuiResId( RID_SVXSTR_ONE_PASSWORD_MISMATCH ) ) - , m_aTwoMismatch( CuiResId( RID_SVXSTR_TWO_PASSWORDS_MISMATCH ) ) - , m_aInvalidStateForOkButton( CuiResId( RID_SVXSTR_INVALID_STATE_FOR_OK_BUTTON ) ) - , m_aInvalidStateForOkButton_v2( CuiResId( RID_SVXSTR_INVALID_STATE_FOR_OK_BUTTON_V2 ) ) + , m_aOneMismatch( CuiResId( RID_CUISTR_ONE_PASSWORD_MISMATCH ) ) + , m_aTwoMismatch( CuiResId( RID_CUISTR_TWO_PASSWORDS_MISMATCH ) ) + , m_aInvalidStateForOkButton( CuiResId( RID_CUISTR_INVALID_STATE_FOR_OK_BUTTON ) ) + , m_aInvalidStateForOkButton_v2( CuiResId( RID_CUISTR_INVALID_STATE_FOR_OK_BUTTON_V2 ) ) + , m_oPasswordPolicy(officecfg::Office::Common::Security::Scripting::PasswordPolicy::get()) , m_nMaxPasswdLen(nMaxPasswdLen) , m_bIsPasswordToModify( bIsPasswordToModify ) + , m_bAllowEmpty( false ) { m_xOk->connect_clicked(LINK(this, PasswordToOpenModifyDialog, OkBtnClickHdl)); - - if (nMaxPasswdLen) + m_xPasswdToOpenED->connect_changed(LINK(this, PasswordToOpenModifyDialog, ChangeHdl)); + m_xPasswdToModifyED->connect_changed(LINK(this, PasswordToOpenModifyDialog, ChangeHdl)); + if(m_oPasswordPolicy || nMaxPasswdLen) { - OUString aIndicatorTemplate(CuiResId(RID_SVXSTR_PASSWORD_LEN_INDICATOR).replaceFirst("%1", OUString::number(nMaxPasswdLen))); - m_xPasswdToOpenED->set_max_length( nMaxPasswdLen ); - m_xPasswdToOpenED->connect_changed(LINK(this, PasswordToOpenModifyDialog, ChangeHdl)); - m_xPasswdToOpenInd->set_label(aIndicatorTemplate); - m_xReenterPasswdToOpenED->set_max_length( nMaxPasswdLen ); m_xReenterPasswdToOpenED->connect_changed(LINK(this, PasswordToOpenModifyDialog, ChangeHdl)); - m_xReenterPasswdToOpenInd->set_label(aIndicatorTemplate); - m_xPasswdToModifyED->set_max_length( nMaxPasswdLen ); - m_xPasswdToModifyED->connect_changed(LINK(this, PasswordToOpenModifyDialog, ChangeHdl)); - m_xPasswdToModifyInd->set_label(aIndicatorTemplate); - m_xReenterPasswdToModifyED->set_max_length( nMaxPasswdLen ); m_xReenterPasswdToModifyED->connect_changed(LINK(this, PasswordToOpenModifyDialog, ChangeHdl)); - m_xReenterPasswdToModifyInd->set_label(aIndicatorTemplate); + + OUString aIndicatorText{}; + OUString aMaxPassLengthIndicator{ CuiResId(RID_CUISTR_PASSWORD_LEN_INDICATOR) + .replaceFirst("%1", + OUString::number(nMaxPasswdLen)) }; + if (m_oPasswordPolicy && nMaxPasswdLen) + { + aIndicatorText + = officecfg::Office::Common::Security::Scripting::PasswordPolicyErrorMessage::get() + + "\n" + aMaxPassLengthIndicator; + } + else if (m_oPasswordPolicy) + { + aIndicatorText + = officecfg::Office::Common::Security::Scripting::PasswordPolicyErrorMessage::get(); + } + else if (nMaxPasswdLen) + { + aIndicatorText = aMaxPassLengthIndicator; + } + + m_xPasswdToOpenInd->set_label(aIndicatorText); + m_xReenterPasswdToOpenInd->set_label(aMaxPassLengthIndicator); + m_xPasswdToModifyInd->set_label(aIndicatorText); + m_xReenterPasswdToModifyInd->set_label(aMaxPassLengthIndicator); + + if (nMaxPasswdLen) + { + m_xPasswdToOpenED->set_max_length(nMaxPasswdLen); + m_xReenterPasswdToOpenED->set_max_length(nMaxPasswdLen); + m_xPasswdToModifyED->set_max_length(nMaxPasswdLen); + m_xReenterPasswdToModifyED->set_max_length(nMaxPasswdLen); + } } m_xPasswdToOpenED->grab_focus(); @@ -131,11 +212,32 @@ PasswordToOpenModifyDialog::PasswordToOpenModifyDialog(weld::Window * pParent, s m_xOptionsExpander->set_sensitive(bIsPasswordToModify); if (!bIsPasswordToModify) m_xOptionsExpander->hide(); + else if (SfxObjectShell* pSh = SfxObjectShell::Current()) + { + if (pSh->IsLoadReadonly()) + { + m_xOpenReadonlyCB->set_active(true); + m_xOptionsExpander->set_expanded(true); + } + } m_xOpenReadonlyCB->connect_toggled(LINK(this, PasswordToOpenModifyDialog, ReadonlyOnOffHdl)); ReadonlyOnOffHdl(*m_xOpenReadonlyCB); } +PasswordToOpenModifyDialog::~PasswordToOpenModifyDialog() +{ + if (m_xErrorBox) + { + m_xErrorBox->response(RET_CANCEL); + } +} + +void PasswordToOpenModifyDialog::AllowEmpty() +{ + m_bAllowEmpty = true; +} + OUString PasswordToOpenModifyDialog::GetPasswordToOpen() const { const bool bPasswdOk = diff --git a/cui/source/dialogs/pastedlg.cxx b/cui/source/dialogs/pastedlg.cxx index d86d277cc34f..423637e9d9e9 100644 --- a/cui/source/dialogs/pastedlg.cxx +++ b/cui/source/dialogs/pastedlg.cxx @@ -85,7 +85,7 @@ void SvPasteObjectDialog::PreGetFormat( const TransferableDataHelper &rHelper ) TransferableObjectDescriptor aDesc; if (rHelper.HasFormat(SotClipboardFormatId::OBJECTDESCRIPTOR)) { - (void)const_cast<TransferableDataHelper&>(rHelper).GetTransferableObjectDescriptor( + (void)rHelper.GetTransferableObjectDescriptor( SotClipboardFormatId::OBJECTDESCRIPTOR, aDesc); } const DataFlavorExVector* pFormats = &rHelper.GetDataFlavorExVector(); @@ -204,7 +204,7 @@ SotClipboardFormatId SvPasteObjectDialog::GetFormat( const TransferableDataHelpe TransferableObjectDescriptor aDesc; if (rHelper.HasFormat(SotClipboardFormatId::OBJECTDESCRIPTOR)) { - (void)const_cast<TransferableDataHelper&>(rHelper).GetTransferableObjectDescriptor( + (void)rHelper.GetTransferableObjectDescriptor( SotClipboardFormatId::OBJECTDESCRIPTOR, aDesc); } const DataFlavorExVector* pFormats = &rHelper.GetDataFlavorExVector(); diff --git a/cui/source/dialogs/postdlg.cxx b/cui/source/dialogs/postdlg.cxx index 6bd7766b04c2..1bcb6b7a0156 100644 --- a/cui/source/dialogs/postdlg.cxx +++ b/cui/source/dialogs/postdlg.cxx @@ -52,30 +52,24 @@ SvxPostItDialog::SvxPostItDialog(weld::Widget* pParent, const SfxItemSet& rCoreS m_xOKBtn->connect_clicked( LINK( this, SvxPostItDialog, OKHdl ) ); bool bNew = true; - sal_uInt16 nWhich = 0; m_xPrevBtn->set_visible(bPrevNext); m_xNextBtn->set_visible(bPrevNext); - nWhich = m_rSet.GetPool()->GetWhich( SID_ATTR_POSTIT_AUTHOR ); OUString aAuthorStr, aDateStr; - if (m_rSet.GetItemState( nWhich ) >= SfxItemState::DEFAULT) + if (m_rSet.GetItemState( SID_ATTR_POSTIT_AUTHOR ) >= SfxItemState::DEFAULT) { bNew = false; - const SvxPostItAuthorItem& rAuthor = - static_cast<const SvxPostItAuthorItem&>(m_rSet.Get(nWhich)); + const SvxPostItAuthorItem& rAuthor = m_rSet.Get(SID_ATTR_POSTIT_AUTHOR); aAuthorStr = rAuthor.GetValue(); } else aAuthorStr = SvtUserOptions().GetID(); - nWhich = m_rSet.GetPool()->GetWhich( SID_ATTR_POSTIT_DATE ); - - if (m_rSet.GetItemState( nWhich ) >= SfxItemState::DEFAULT) + if (m_rSet.GetItemState( SID_ATTR_POSTIT_DATE ) >= SfxItemState::DEFAULT) { - const SvxPostItDateItem& rDate = - static_cast<const SvxPostItDateItem&>(m_rSet.Get( nWhich )); + const SvxPostItDateItem& rDate = m_rSet.Get( SID_ATTR_POSTIT_DATE ); aDateStr = rDate.GetValue(); } else @@ -84,13 +78,10 @@ SvxPostItDialog::SvxPostItDialog(weld::Widget* pParent, const SfxItemSet& rCoreS aDateStr = rLocaleWrapper.getDate( Date( Date::SYSTEM ) ); } - nWhich = m_rSet.GetPool()->GetWhich( SID_ATTR_POSTIT_TEXT ); - OUString aTextStr; - if (m_rSet.GetItemState( nWhich ) >= SfxItemState::DEFAULT) + if (m_rSet.GetItemState( SID_ATTR_POSTIT_TEXT ) >= SfxItemState::DEFAULT) { - const SvxPostItTextItem& rText = - static_cast<const SvxPostItTextItem&>(m_rSet.Get( nWhich )); + const SvxPostItTextItem& rText = m_rSet.Get( SID_ATTR_POSTIT_TEXT ); aTextStr = rText.GetValue(); } @@ -162,12 +153,9 @@ IMPL_LINK_NOARG(SvxPostItDialog, OKHdl, weld::Button&, void) { const LocaleDataWrapper& rLocaleWrapper( Application::GetSettings().GetLocaleDataWrapper() ); m_xOutSet.reset(new SfxItemSet(m_rSet)); - m_xOutSet->Put( SvxPostItAuthorItem(SvtUserOptions().GetID(), - m_rSet.GetPool()->GetWhich( SID_ATTR_POSTIT_AUTHOR ) ) ); - m_xOutSet->Put( SvxPostItDateItem(rLocaleWrapper.getDate( Date( Date::SYSTEM ) ), - m_rSet.GetPool()->GetWhich( SID_ATTR_POSTIT_DATE ) ) ); - m_xOutSet->Put( SvxPostItTextItem(m_xEditED->get_text(), - m_rSet.GetPool()->GetWhich( SID_ATTR_POSTIT_TEXT ) ) ); + m_xOutSet->Put( SvxPostItAuthorItem(SvtUserOptions().GetID(), SID_ATTR_POSTIT_AUTHOR ) ); + m_xOutSet->Put( SvxPostItDateItem(rLocaleWrapper.getDate( Date( Date::SYSTEM ) ), SID_ATTR_POSTIT_DATE ) ); + m_xOutSet->Put( SvxPostItTextItem(m_xEditED->get_text(), SID_ATTR_POSTIT_TEXT ) ); m_xDialog->response(RET_OK); } diff --git a/cui/source/dialogs/screenshotannotationdlg.cxx b/cui/source/dialogs/screenshotannotationdlg.cxx index 802453d2206c..fca03c02d42d 100644 --- a/cui/source/dialogs/screenshotannotationdlg.cxx +++ b/cui/source/dialogs/screenshotannotationdlg.cxx @@ -35,7 +35,7 @@ #include <vcl/bitmapex.hxx> #include <vcl/customweld.hxx> #include <vcl/event.hxx> -#include <vcl/pngwrite.hxx> +#include <vcl/filter/PngImageWriter.hxx> #include <vcl/svapp.hxx> #include <vcl/salgtype.hxx> #include <vcl/virdev.hxx> @@ -202,7 +202,7 @@ ScreenshotAnnotationDlg_Impl::ScreenshotAnnotationDlg_Impl( mxVirtualBufferDevice(nullptr), mpHilighted(nullptr), maPicture(this), - maSaveAsText(CuiResId(RID_SVXSTR_SAVE_SCREENSHOT_AS)) + maSaveAsText(CuiResId(RID_CUISTR_SAVE_SCREENSHOT_AS)) { VclPtr<VirtualDevice> xParentDialogSurface(rParentDialog.screenshot()); maParentDialogSize = xParentDialogSurface->GetOutputSizePixel(); @@ -232,7 +232,7 @@ ScreenshotAnnotationDlg_Impl::ScreenshotAnnotationDlg_Impl( maDimmedDialogBitmap.Adjust(-15, 0, 0, 0, 0); // init paint buffering VirtualDevice - mxVirtualBufferDevice = VclPtr<VirtualDevice>::Create(*Application::GetDefaultDevice(), DeviceFormat::DEFAULT); + mxVirtualBufferDevice = VclPtr<VirtualDevice>::Create(*Application::GetDefaultDevice(), DeviceFormat::WITHOUT_ALPHA); mxVirtualBufferDevice->SetOutputSizePixel(maParentDialogSize); mxVirtualBufferDevice->SetFillColor(COL_TRANSPARENT); @@ -252,7 +252,7 @@ ScreenshotAnnotationDlg_Impl::ScreenshotAnnotationDlg_Impl( if (mxText) { mxText->set_size_request(400, mxText->get_height_rows(10)); - OUString aHelpId = OStringToOUString( mrParentDialog.get_help_id(), RTL_TEXTENCODING_UTF8 ); + OUString aHelpId = mrParentDialog.get_help_id(); Size aSizeCm = Application::GetDefaultDevice()->PixelToLogic(maParentDialogSize, MapMode(MapUnit::MapCM)); maMainMarkupText = lcl_ParagraphWithImage( aHelpId, aSizeCm ); mxText->set_text( maMainMarkupText ); @@ -276,7 +276,7 @@ IMPL_LINK_NOARG(ScreenshotAnnotationDlg_Impl, saveButtonHandler, weld::Button&, // 'save screenshot...' pressed, offer to save maParentDialogBitmap // as PNG image, use *.id file name as screenshot file name offering // get a suggestion for the filename from buildable name - OString aDerivedFileName = mrParentDialog.get_buildable_name(); + OUString aDerivedFileName = mrParentDialog.get_buildable_name(); auto xFileDlg = std::make_unique<sfx2::FileDialogHelper>(ui::dialogs::TemplateDescription::FILESAVE_AUTOEXTENSION, FileDialogFlags::NONE, mpParentWindow); @@ -293,7 +293,7 @@ IMPL_LINK_NOARG(ScreenshotAnnotationDlg_Impl, saveButtonHandler, weld::Button&, xFilePicker->appendFilter("*.png", "*.png"); xFilePicker->setCurrentFilter("*.png"); - xFilePicker->setDefaultName(OStringToOUString(aDerivedFileName, RTL_TEXTENCODING_UTF8)); + xFilePicker->setDefaultName(aDerivedFileName); xFilePicker->setMultiSelectionMode(false); if (xFilePicker->execute() != ui::dialogs::ExecutableDialogResults::OK) @@ -341,8 +341,8 @@ IMPL_LINK_NOARG(ScreenshotAnnotationDlg_Impl, saveButtonHandler, weld::Button&, mxVirtualBufferDevice->GetOutputSizePixel())); // write as PNG - vcl::PNGWriter aPNGWriter(aTargetBitmap); - aPNGWriter.Write(aNew); + vcl::PngImageWriter aPNGWriter(aNew); + aPNGWriter.write(aTargetBitmap); } weld::ScreenShotEntry* ScreenshotAnnotationDlg_Impl::CheckHit(const basegfx::B2IPoint& rPosition) @@ -546,10 +546,7 @@ bool ScreenshotAnnotationDlg_Impl::MouseButtonUp() OUStringBuffer aBookmarks(maMainMarkupText); for (auto&& rCandidate : maSelected) - { - OUString aHelpId = OStringToOUString( rCandidate->GetHelpId(), RTL_TEXTENCODING_UTF8 ); - aBookmarks.append(lcl_Bookmark( aHelpId )); - } + aBookmarks.append(lcl_Bookmark(rCandidate->GetHelpId())); mxText->set_text( aBookmarks.makeStringAndClear() ); bRepaint = true; diff --git a/cui/source/dialogs/scriptdlg.cxx b/cui/source/dialogs/scriptdlg.cxx index acbdad7a1b16..67bb456b7d61 100644 --- a/cui/source/dialogs/scriptdlg.cxx +++ b/cui/source/dialogs/scriptdlg.cxx @@ -50,10 +50,11 @@ #include <comphelper/SetFlagContextHelper.hxx> #include <comphelper/documentinfo.hxx> #include <comphelper/processfactory.hxx> +#include <o3tl/string_view.hxx> #include <svtools/imagemgr.hxx> #include <tools/urlobj.hxx> -#include <tools/diagnose_ex.h> +#include <comphelper/diagnose_ex.hxx> using namespace ::com::sun::star; using namespace css::uno; @@ -63,7 +64,7 @@ using namespace css::document; void SvxScriptOrgDialog::delUserData(const weld::TreeIter& rIter) { - SFEntry* pUserData = reinterpret_cast<SFEntry*>(m_xScriptsBox->get_id(rIter).toInt64()); + SFEntry* pUserData = weld::fromId<SFEntry*>(m_xScriptsBox->get_id(rIter)); if (pUserData) { delete pUserData; @@ -127,9 +128,6 @@ void SvxScriptOrgDialog::Init( std::u16string_view language ) Sequence< Reference< browse::XBrowseNode > > children; - OUString userStr("user"); - OUString const shareStr("share"); - try { Reference< browse::XBrowseNodeFactory > xFac = browse::theBrowseNodeFactory::get(xCtx); @@ -149,22 +147,20 @@ void SvxScriptOrgDialog::Init( std::u16string_view language ) } Reference<XModel> xDocumentModel; - for ( const Reference< browse::XBrowseNode >& childNode : std::as_const(children) ) + for (const Reference<browse::XBrowseNode>& childNode : children) { bool app = false; OUString uiName = childNode->getName(); OUString factoryURL; - if ( uiName == userStr || uiName == shareStr ) + if (uiName == "user") { app = true; - if ( uiName == userStr ) - { - uiName = m_sMyMacros; - } - else - { - uiName = m_sProdMacros; - } + uiName = m_sMyMacros; + } + else if (uiName == "share") + { + app = true; + uiName = m_sProdMacros; } else { @@ -182,7 +178,7 @@ void SvxScriptOrgDialog::Init( std::u16string_view language ) } catch(const uno::Exception&) {} - for ( const beans::PropertyValue& prop : std::as_const(moduleDescr)) + for (const beans::PropertyValue& prop : moduleDescr) { if ( prop.Name == "ooSetupFactoryEmptyDocumentURL" ) { @@ -196,7 +192,7 @@ void SvxScriptOrgDialog::Init( std::u16string_view language ) Reference< browse::XBrowseNode > langEntries = getLangNodeFromRootNode( childNode, language ); - insertEntry( uiName, app ? OUString(RID_CUIBMP_HARDDISK) : OUString(RID_CUIBMP_DOC), + insertEntry( uiName, app ? RID_CUIBMP_HARDDISK : RID_CUIBMP_DOC, nullptr, true, std::make_unique< SFEntry >( langEntries, xDocumentModel ), factoryURL, false ); } @@ -282,7 +278,7 @@ void SvxScriptOrgDialog::RequestSubEntries(const weld::TreeIter& rRootEntry, Ref // if we catch an exception in getChildNodes then no entries are added } - for ( const Reference< browse::XBrowseNode >& childNode : std::as_const(children) ) + for (const Reference<browse::XBrowseNode>& childNode : children) { OUString name( childNode->getName() ); if ( childNode->getType() != browse::BrowseNodeTypes::SCRIPT) @@ -298,9 +294,9 @@ void SvxScriptOrgDialog::RequestSubEntries(const weld::TreeIter& rRootEntry, Ref void SvxScriptOrgDialog::insertEntry(const OUString& rText, const OUString& rBitmap, const weld::TreeIter* pParent, bool bChildrenOnDemand, std::unique_ptr<SFEntry> && aUserData, - const OUString& factoryURL, bool bSelect) + std::u16string_view factoryURL, bool bSelect) { - if (rBitmap == RID_CUIBMP_DOC && !factoryURL.isEmpty()) + if (rBitmap == RID_CUIBMP_DOC && !factoryURL.empty()) { OUString aImage = SvFileInformationManager::GetFileImageId(INetURLObject(factoryURL)); insertEntry(rText, aImage, pParent, bChildrenOnDemand, std::move(aUserData), bSelect); @@ -313,7 +309,7 @@ void SvxScriptOrgDialog::insertEntry( const OUString& rText, const OUString& rBitmap, const weld::TreeIter* pParent, bool bChildrenOnDemand, std::unique_ptr<SFEntry> && aUserData, bool bSelect) { - OUString sId(OUString::number(reinterpret_cast<sal_Int64>(aUserData.release()))); // XXX possible leak + OUString sId(weld::toId(aUserData.release())); // XXX possible leak m_xScriptsBox->insert(pParent, -1, &rText, &sId, nullptr, nullptr, bChildrenOnDemand, m_xScratchIter.get()); m_xScriptsBox->set_image(*m_xScratchIter, rBitmap); @@ -326,7 +322,7 @@ void SvxScriptOrgDialog::insertEntry( IMPL_LINK(SvxScriptOrgDialog, ExpandingHdl, const weld::TreeIter&, rIter, bool) { - SFEntry* userData = reinterpret_cast<SFEntry*>(m_xScriptsBox->get_id(rIter).toInt64()); + SFEntry* userData = weld::fromId<SFEntry*>(m_xScriptsBox->get_id(rIter)); Reference< browse::XBrowseNode > node; Reference< XModel > model; @@ -370,21 +366,21 @@ CuiInputDialog::CuiInputDialog(weld::Window * pParent, InputDialogMode nMode) // ScriptOrgDialog ------------------------------------------------------------ -SvxScriptOrgDialog::SvxScriptOrgDialog(weld::Window* pParent, const OUString& language) +SvxScriptOrgDialog::SvxScriptOrgDialog(weld::Window* pParent, OUString language) : SfxDialogController(pParent, "cui/ui/scriptorganizer.ui", "ScriptOrganizerDialog") , m_pParent(pParent) - , m_sLanguage(language) - , m_delErrStr(CuiResId(RID_SVXSTR_DELFAILED)) - , m_delErrTitleStr(CuiResId(RID_SVXSTR_DELFAILED_TITLE)) - , m_delQueryStr(CuiResId(RID_SVXSTR_DELQUERY)) - , m_delQueryTitleStr(CuiResId(RID_SVXSTR_DELQUERY_TITLE)) - , m_createErrStr(CuiResId(RID_SVXSTR_CREATEFAILED)) - , m_createDupStr(CuiResId(RID_SVXSTR_CREATEFAILEDDUP)) - , m_createErrTitleStr(CuiResId(RID_SVXSTR_CREATEFAILED_TITLE)) - , m_renameErrStr(CuiResId(RID_SVXSTR_RENAMEFAILED)) - , m_renameErrTitleStr(CuiResId(RID_SVXSTR_RENAMEFAILED_TITLE)) - , m_sMyMacros(CuiResId(RID_SVXSTR_MYMACROS)) - , m_sProdMacros(CuiResId(RID_SVXSTR_PRODMACROS)) + , m_sLanguage(std::move(language)) + , m_delErrStr(CuiResId(RID_CUISTR_DELFAILED)) + , m_delErrTitleStr(CuiResId(RID_CUISTR_DELFAILED_TITLE)) + , m_delQueryStr(CuiResId(RID_CUISTR_DELQUERY)) + , m_delQueryTitleStr(CuiResId(RID_CUISTR_DELQUERY_TITLE)) + , m_createErrStr(CuiResId(RID_CUISTR_CREATEFAILED)) + , m_createDupStr(CuiResId(RID_CUISTR_CREATEFAILEDDUP)) + , m_createErrTitleStr(CuiResId(RID_CUISTR_CREATEFAILED_TITLE)) + , m_renameErrStr(CuiResId(RID_CUISTR_RENAMEFAILED)) + , m_renameErrTitleStr(CuiResId(RID_CUISTR_RENAMEFAILED_TITLE)) + , m_sMyMacros(CuiResId(RID_CUISTR_MYMACROS)) + , m_sProdMacros(CuiResId(RID_CUISTR_PRODMACROS)) , m_xScriptsBox(m_xBuilder->weld_tree_view("scripts")) , m_xScratchIter(m_xScriptsBox->make_iterator()) , m_xRunButton(m_xBuilder->weld_button("ok")) @@ -530,7 +526,7 @@ IMPL_LINK_NOARG(SvxScriptOrgDialog, ScriptSelectHdl, weld::TreeView&, void) if (!m_xScriptsBox->get_selected(xIter.get())) return; - SFEntry* userData = reinterpret_cast<SFEntry*>(m_xScriptsBox->get_id(*xIter).toInt64()); + SFEntry* userData = weld::fromId<SFEntry*>(m_xScriptsBox->get_id(*xIter)); Reference< browse::XBrowseNode > node; if (userData) @@ -558,7 +554,7 @@ IMPL_LINK(SvxScriptOrgDialog, ButtonHdl, weld::Button&, rButton, void) std::unique_ptr<weld::TreeIter> xIter = m_xScriptsBox->make_iterator(); if (!m_xScriptsBox->get_selected(xIter.get())) return; - SFEntry* userData = reinterpret_cast<SFEntry*>(m_xScriptsBox->get_id(*xIter).toInt64()); + SFEntry* userData = weld::fromId<SFEntry*>(m_xScriptsBox->get_id(*xIter)); if (!userData) return; @@ -602,7 +598,7 @@ IMPL_LINK(SvxScriptOrgDialog, ButtonHdl, weld::Button&, rButton, void) bool bParent = m_xScriptsBox->iter_parent(*xParentIter); while (bParent && !mspNode.is() ) { - SFEntry* mspUserData = reinterpret_cast<SFEntry*>(m_xScriptsBox->get_id(*xParentIter).toInt64()); + SFEntry* mspUserData = weld::fromId<SFEntry*>(m_xScriptsBox->get_id(*xParentIter)); mspNode.set( mspUserData->GetNode() , UNO_QUERY ); bParent = m_xScriptsBox->iter_parent(*xParentIter); } @@ -679,7 +675,7 @@ IMPL_LINK(SvxScriptOrgDialog, ButtonHdl, weld::Button&, rButton, void) Reference< browse::XBrowseNode > SvxScriptOrgDialog::getBrowseNode(const weld::TreeIter& rEntry) { Reference< browse::XBrowseNode > node; - SFEntry* userData = reinterpret_cast<SFEntry*>(m_xScriptsBox->get_id(rEntry).toInt64()); + SFEntry* userData = weld::fromId<SFEntry*>(m_xScriptsBox->get_id(rEntry)); if (userData) { node = userData->GetNode(); @@ -690,7 +686,7 @@ Reference< browse::XBrowseNode > SvxScriptOrgDialog::getBrowseNode(const weld::T Reference< XModel > SvxScriptOrgDialog::getModel(const weld::TreeIter& rEntry) { Reference< XModel > model; - SFEntry* userData = reinterpret_cast<SFEntry*>(m_xScriptsBox->get_id(rEntry).toInt64()); + SFEntry* userData = weld::fromId<SFEntry*>(m_xScriptsBox->get_id(rEntry)); if ( userData ) { model = userData->GetModel(); @@ -755,9 +751,9 @@ void SvxScriptOrgDialog::createEntry(const weld::TreeIter& rEntry) if(extnPos>0) extn = nodeName.copy(extnPos); } - for( const Reference< browse::XBrowseNode >& n : std::as_const(childNodes) ) + for (const Reference<browse::XBrowseNode>& n : childNodes) { - if (OUStringConcatenation(aNewName+extn) == n->getName()) + if (Concat2View(aNewName+extn) == n->getName()) { bFound = true; break; @@ -782,9 +778,9 @@ void SvxScriptOrgDialog::createEntry(const weld::TreeIter& rEntry) { OUString aUserSuppliedName = aNewDlg.GetObjectName(); bValid = true; - for( const Reference< browse::XBrowseNode >& n : std::as_const(childNodes) ) + for (const Reference<browse::XBrowseNode>& n : childNodes) { - if (OUStringConcatenation(aUserSuppliedName+extn) == n->getName()) + if (Concat2View(aUserSuppliedName+extn) == n->getName()) { bValid = false; OUString aError = m_createErrStr + m_createDupStr; @@ -818,8 +814,7 @@ void SvxScriptOrgDialog::createEntry(const weld::TreeIter& rEntry) try { Any aResult = xInv->invoke( "Creatable", args, outIndex, outArgs ); - Reference< browse::XBrowseNode > newNode( aResult, UNO_QUERY ); - aChildNode = newNode; + aChildNode.set(aResult, UNO_QUERY); } catch( Exception const & ) @@ -852,7 +847,7 @@ void SvxScriptOrgDialog::createEntry(const weld::TreeIter& rEntry) // loaded, this will prevent RequestingChildren ( called // from vcl via RequestingChildren ) from // creating new ( duplicate ) children - SFEntry* userData = reinterpret_cast<SFEntry*>(m_xScriptsBox->get_id(rEntry).toInt64()); + SFEntry* userData = weld::fromId<SFEntry*>(m_xScriptsBox->get_id(rEntry)); if ( userData && !userData->isLoaded() ) { userData->setLoaded(); @@ -899,8 +894,7 @@ void SvxScriptOrgDialog::renameEntry(const weld::TreeIter& rEntry) try { Any aResult = xInv->invoke( "Renamable", args, outIndex, outArgs ); - Reference< browse::XBrowseNode > newNode( aResult, UNO_QUERY ); - aChildNode = newNode; + aChildNode.set(aResult, UNO_QUERY); } catch( Exception const & ) @@ -1034,8 +1028,7 @@ void SvxScriptOrgDialog::StoreCurrentSelection() aDescription = ";" + aDescription; } while (bEntry); - OUString sDesc( aDescription ); - m_lastSelection[ m_sLanguage ] = sDesc; + m_lastSelection[m_sLanguage] = aDescription; } void SvxScriptOrgDialog::RestorePreviousSelection() @@ -1048,7 +1041,7 @@ void SvxScriptOrgDialog::RestorePreviousSelection() sal_Int32 nIndex = 0; while (nIndex != -1) { - OUString aTmp( aStoredEntry.getToken( 0, ';', nIndex ) ); + std::u16string_view aTmp( o3tl::getToken(aStoredEntry, 0, ';', nIndex ) ); bool bTmpEntry; if (!xEntry) @@ -1090,14 +1083,14 @@ namespace { OUString ReplaceString( const OUString& source, - const OUString& token, + std::u16string_view token, std::u16string_view value ) { sal_Int32 pos = source.indexOf( token ); if ( pos != -1 && !value.empty() ) { - return source.replaceAt( pos, token.getLength(), value ); + return source.replaceAt( pos, token.size(), value ); } else { @@ -1113,20 +1106,20 @@ OUString FormatErrorString( std::u16string_view type, std::u16string_view message ) { - OUString result = unformatted.copy( 0 ); + OUString result = unformatted; - result = ReplaceString(result, "%LANGUAGENAME", language ); - result = ReplaceString(result, "%SCRIPTNAME", script ); - result = ReplaceString(result, "%LINENUMBER", line ); + result = ReplaceString(result, u"%LANGUAGENAME", language ); + result = ReplaceString(result, u"%SCRIPTNAME", script ); + result = ReplaceString(result, u"%LINENUMBER", line ); if ( !type.empty() ) { - result += "\n\n" + CuiResId(RID_SVXSTR_ERROR_TYPE_LABEL) + " " + type; + result += "\n\n" + CuiResId(RID_CUISTR_ERROR_TYPE_LABEL) + " " + type; } if ( !message.empty() ) { - result += "\n\n" + CuiResId(RID_SVXSTR_ERROR_MESSAGE_LABEL) + " " + message; + result += "\n\n" + CuiResId(RID_CUISTR_ERROR_MESSAGE_LABEL) + " " + message; } return result; @@ -1135,7 +1128,7 @@ OUString FormatErrorString( OUString GetErrorMessage( const provider::ScriptErrorRaisedException& eScriptError ) { - OUString unformatted = CuiResId( RID_SVXSTR_ERROR_AT_LINE ); + OUString unformatted = CuiResId( RID_CUISTR_ERROR_AT_LINE ); OUString unknown("UNKNOWN"); OUString language = unknown; @@ -1160,11 +1153,11 @@ OUString GetErrorMessage( if ( eScriptError.lineNum != -1 ) { line = OUString::number( eScriptError.lineNum ); - unformatted = CuiResId( RID_SVXSTR_ERROR_AT_LINE ); + unformatted = CuiResId( RID_CUISTR_ERROR_AT_LINE ); } else { - unformatted = CuiResId( RID_SVXSTR_ERROR_RUNNING ); + unformatted = CuiResId( RID_CUISTR_ERROR_RUNNING ); } return FormatErrorString( @@ -1174,7 +1167,7 @@ OUString GetErrorMessage( OUString GetErrorMessage( const provider::ScriptExceptionRaisedException& eScriptException ) { - OUString unformatted = CuiResId( RID_SVXSTR_EXCEPTION_AT_LINE ); + OUString unformatted = CuiResId( RID_CUISTR_EXCEPTION_AT_LINE ); OUString unknown("UNKNOWN"); OUString language = unknown; @@ -1200,11 +1193,11 @@ OUString GetErrorMessage( if ( eScriptException.lineNum != -1 ) { line = OUString::number( eScriptException.lineNum ); - unformatted = CuiResId( RID_SVXSTR_EXCEPTION_AT_LINE ); + unformatted = CuiResId( RID_CUISTR_EXCEPTION_AT_LINE ); } else { - unformatted = CuiResId( RID_SVXSTR_EXCEPTION_RUNNING ); + unformatted = CuiResId( RID_CUISTR_EXCEPTION_RUNNING ); } if ( !eScriptException.exceptionType.isEmpty() ) @@ -1219,7 +1212,7 @@ OUString GetErrorMessage( OUString GetErrorMessage( const provider::ScriptFrameworkErrorException& sError ) { - OUString unformatted = CuiResId( RID_SVXSTR_FRAMEWORK_ERROR_RUNNING ); + OUString unformatted = CuiResId( RID_CUISTR_FRAMEWORK_ERROR_RUNNING ); OUString language("UNKNOWN"); @@ -1237,9 +1230,8 @@ OUString GetErrorMessage( } if ( sError.errorType == provider::ScriptFrameworkErrorType::NOTSUPPORTED ) { - message = - CuiResId( RID_SVXSTR_ERROR_LANG_NOT_SUPPORTED ); - message = ReplaceString(message, "%LANGUAGENAME", language ); + message = CuiResId(RID_CUISTR_ERROR_LANG_NOT_SUPPORTED); + message = ReplaceString(message, u"%LANGUAGENAME", language ); } else @@ -1302,12 +1294,11 @@ OUString GetErrorMessage( const css::uno::Any& aException ) void SvxScriptErrorDialog::ShowAsyncErrorDialog( weld::Window* pParent, css::uno::Any const & aException ) { SolarMutexGuard aGuard; - OUString sMessage = GetErrorMessage( aException ); // Pass a copy of the message to the ShowDialog method as the // SvxScriptErrorDialog may be deleted before ShowDialog is called DialogData* pData = new DialogData; - pData->sMessage = sMessage; + pData->sMessage = GetErrorMessage(aException); pData->pParent = pParent; Application::PostUserEvent( LINK( nullptr, SvxScriptErrorDialog, ShowDialog ), @@ -1320,17 +1311,16 @@ IMPL_STATIC_LINK( SvxScriptErrorDialog, ShowDialog, void*, p, void ) OUString message = xData->sMessage; if ( message.isEmpty() ) - message = CuiResId( RID_SVXSTR_ERROR_TITLE ); + message = CuiResId( RID_CUISTR_ERROR_TITLE ); std::shared_ptr<weld::MessageDialog> xBox; xBox.reset(Application::CreateMessageDialog( xData->pParent, VclMessageType::Warning, VclButtonsType::Ok, - message, - comphelper::LibreOfficeKit::isActive())); + message)); - xBox->set_title(CuiResId(RID_SVXSTR_ERROR_TITLE)); + xBox->set_title(CuiResId(RID_CUISTR_ERROR_TITLE)); xBox->runAsync(xBox, [](sal_Int32 /*nResult*/) {}); } diff --git a/cui/source/dialogs/sdrcelldlg.cxx b/cui/source/dialogs/sdrcelldlg.cxx index fda8b4ce1385..6b10e5c688e3 100644 --- a/cui/source/dialogs/sdrcelldlg.cxx +++ b/cui/source/dialogs/sdrcelldlg.cxx @@ -21,11 +21,16 @@ #include <cuitabarea.hxx> #include <svx/svdmodel.hxx> #include <border.hxx> +#include <paragrph.hxx> +#include <svl/intitem.hxx> +#include <svl/cjkoptions.hxx> +#include <svx/flagsdef.hxx> +#include <svx/svxids.hrc> #include <svx/dialogs.hrc> -SvxFormatCellsDialog::SvxFormatCellsDialog(weld::Window* pParent, const SfxItemSet* pAttr, const SdrModel& rModel) - : SfxTabDialogController(pParent, "cui/ui/formatcellsdialog.ui", "FormatCellsDialog", pAttr) - , mrOutAttrs(*pAttr) +SvxFormatCellsDialog::SvxFormatCellsDialog(weld::Window* pParent, const SfxItemSet& rAttr, const SdrModel& rModel, bool bStyle) + : SfxTabDialogController(pParent, "cui/ui/formatcellsdialog.ui", "FormatCellsDialog", &rAttr, bStyle) + , mrOutAttrs(rAttr) , mpColorTab(rModel.GetColorList()) , mnColorTabState ( ChangeType::NONE ) , mpGradientList(rModel.GetGradientList()) @@ -37,10 +42,32 @@ SvxFormatCellsDialog::SvxFormatCellsDialog(weld::Window* pParent, const SfxItemS AddTabPage("effects", RID_SVXPAGE_CHAR_EFFECTS); AddTabPage("border", RID_SVXPAGE_BORDER ); AddTabPage("area", RID_SVXPAGE_AREA); - AddTabPage("shadow", SvxShadowTabPage::Create, nullptr); + + if (bStyle) + { + AddTabPage("position", RID_SVXPAGE_CHAR_POSITION); + AddTabPage("highlight", RID_SVXPAGE_BKG); + AddTabPage("indentspacing", RID_SVXPAGE_STD_PARAGRAPH); + AddTabPage("alignment", SvxParaAlignTabPage::Create, SvxParaAlignTabPage::GetSdrRanges); + RemoveTabPage("shadow"); + } + else + { + RemoveTabPage("position"); + RemoveTabPage("highlight"); + RemoveTabPage("indentspacing"); + RemoveTabPage("alignment"); + AddTabPage("shadow", SvxShadowTabPage::Create, nullptr); + RemoveStandardButton(); + } + + if (bStyle && SvtCJKOptions::IsAsianTypographyEnabled()) + AddTabPage("asian", RID_SVXPAGE_PARA_ASIAN); + else + RemoveTabPage("asian"); } -void SvxFormatCellsDialog::PageCreated(const OString& rId, SfxTabPage &rPage) +void SvxFormatCellsDialog::PageCreated(const OUString& rId, SfxTabPage &rPage) { if (rId == "area") { @@ -62,6 +89,16 @@ void SvxFormatCellsDialog::PageCreated(const OString& rId, SfxTabPage &rPage) static_cast<SvxShadowTabPage&>(rPage).SetColorList( mpColorTab ); static_cast<SvxShadowTabPage&>(rPage).SetColorChgd( &mnColorTabState ); } + else if (rId == "alignment") + { + static_cast<SvxParaAlignTabPage&>(rPage).EnableSdrVertAlign(); + } + else if (rId == "highlight") + { + SfxAllItemSet aSet(*(GetInputSetImpl()->GetPool())); + aSet.Put(SfxUInt32Item(SID_FLAG_TYPE,static_cast<sal_uInt32>(SvxBackgroundTabFlags::SHOW_CHAR_BKGCOLOR))); + rPage.PageCreated(aSet); + } else SfxTabDialogController::PageCreated(rId, rPage); } diff --git a/cui/source/dialogs/showcols.cxx b/cui/source/dialogs/showcols.cxx index b089f5f8e14b..ae468b02009a 100644 --- a/cui/source/dialogs/showcols.cxx +++ b/cui/source/dialogs/showcols.cxx @@ -19,13 +19,12 @@ #include <showcols.hxx> -#include <osl/diagnose.h> #include <com/sun/star/beans/XPropertySet.hpp> #include <comphelper/types.hxx> #include <tools/debug.hxx> -#include <tools/diagnose_ex.h> +#include <comphelper/diagnose_ex.hxx> -constexpr OUStringLiteral CUIFM_PROP_HIDDEN = u"Hidden"; +constexpr OUString CUIFM_PROP_HIDDEN = u"Hidden"_ustr; constexpr OUStringLiteral CUIFM_PROP_LABEL = u"Label"; FmShowColsDialog::FmShowColsDialog(weld::Window* pParent) diff --git a/cui/source/dialogs/srchxtra.cxx b/cui/source/dialogs/srchxtra.cxx index d857f77c42df..f8080f537775 100644 --- a/cui/source/dialogs/srchxtra.cxx +++ b/cui/source/dialogs/srchxtra.cxx @@ -59,14 +59,12 @@ SvxSearchFormatDialog::~SvxSearchFormatDialog() { } -void SvxSearchFormatDialog::PageCreated(const OString& rId, SfxTabPage& rPage) +void SvxSearchFormatDialog::PageCreated(const OUString& rId, SfxTabPage& rPage) { if (rId == "font") { const FontList* pApm_pFontList = nullptr; - SfxObjectShell* pSh = SfxObjectShell::Current(); - - if ( pSh ) + if (SfxObjectShell* pSh = SfxObjectShell::Current()) { const SvxFontListItem* pFLItem = static_cast<const SvxFontListItem*>( pSh->GetItem( SID_ATTR_CHAR_FONTLIST )); @@ -119,42 +117,44 @@ SvxSearchAttributeDialog::SvxSearchAttributeDialog(weld::Window* pParent, SfxObjectShell* pSh = SfxObjectShell::Current(); DBG_ASSERT( pSh, "No DocShell" ); - - SfxItemPool& rPool = pSh->GetPool(); - SfxItemSet aSet( rPool, pWhRanges ); - SfxWhichIter aIter( aSet ); - sal_uInt16 nWhich = aIter.FirstWhich(); - - while ( nWhich ) + if (pSh) { - sal_uInt16 nSlot = rPool.GetSlotId( nWhich ); - if ( nSlot >= SID_SVX_START ) + SfxItemPool& rPool = pSh->GetPool(); + SfxItemSet aSet( rPool, pWhRanges ); + SfxWhichIter aIter( aSet ); + sal_uInt16 nWhich = aIter.FirstWhich(); + + while ( nWhich ) { - bool bChecked = false, bFound = false; - for ( sal_uInt16 i = 0; !bFound && i < rList.Count(); ++i ) + sal_uInt16 nSlot = rPool.GetSlotId( nWhich ); + if ( nSlot >= SID_SVX_START ) { - if ( nSlot == rList[i].nSlot ) + bool bChecked = false, bFound = false; + for ( sal_uInt16 i = 0; !bFound && i < rList.Count(); ++i ) { - bFound = true; - if ( IsInvalidItem( rList[i].pItem ) ) - bChecked = true; + if ( nSlot == rList[i].nSlot ) + { + bFound = true; + if ( IsInvalidItem( rList[i].aItemPtr.getItem() ) ) + bChecked = true; + } } - } - // item resources are in svx - sal_uInt32 nId = SvxAttrNameTable::FindIndex(nSlot); - if (RESARRAY_INDEX_NOTFOUND != nId) - { - m_xAttrLB->append(); - const int nRow = m_xAttrLB->n_children() - 1; - m_xAttrLB->set_toggle(nRow, bChecked ? TRISTATE_TRUE : TRISTATE_FALSE); - m_xAttrLB->set_text(nRow, SvxAttrNameTable::GetString(nId), 0); - m_xAttrLB->set_id(nRow, OUString::number(nSlot)); + // item resources are in svx + sal_uInt32 nId = SvxAttrNameTable::FindIndex(nSlot); + if (RESARRAY_INDEX_NOTFOUND != nId) + { + m_xAttrLB->append(); + const int nRow = m_xAttrLB->n_children() - 1; + m_xAttrLB->set_toggle(nRow, bChecked ? TRISTATE_TRUE : TRISTATE_FALSE); + m_xAttrLB->set_text(nRow, SvxAttrNameTable::GetString(nId), 0); + m_xAttrLB->set_id(nRow, OUString::number(nSlot)); + } + else + SAL_WARN( "cui.dialogs", "no resource for slot id " << static_cast<sal_Int32>(nSlot) ); } - else - SAL_WARN( "cui.dialogs", "no resource for slot id " << static_cast<sal_Int32>(nSlot) ); + nWhich = aIter.NextWhich(); } - nWhich = aIter.NextWhich(); } m_xAttrLB->make_sorted(); @@ -167,28 +167,24 @@ SvxSearchAttributeDialog::~SvxSearchAttributeDialog() IMPL_LINK_NOARG(SvxSearchAttributeDialog, OKHdl, weld::Button&, void) { - SearchAttrItem aInvalidItem; - aInvalidItem.pItem = INVALID_POOL_ITEM; + DBG_ASSERT( SfxObjectShell::Current(), "No DocShell" ); + SfxItemPool& rPool(SfxObjectShell::Current()->GetPool()); for (int i = 0, nCount = m_xAttrLB->n_children(); i < nCount; ++i) { - sal_uInt16 nSlot = m_xAttrLB->get_id(i).toUInt32(); - bool bChecked = m_xAttrLB->get_toggle(i) == TRISTATE_TRUE; + const sal_uInt16 nSlot(m_xAttrLB->get_id(i).toUInt32()); + const bool bChecked(TRISTATE_TRUE == m_xAttrLB->get_toggle(i)); sal_uInt16 j; for ( j = rList.Count(); j; ) { - SearchAttrItem& rItem = rList[ --j ]; + SearchAttrInfo& rItem = rList[ --j ]; if( rItem.nSlot == nSlot ) { if( bChecked ) - { - if( !IsInvalidItem( rItem.pItem ) ) - delete rItem.pItem; - rItem.pItem = INVALID_POOL_ITEM; - } - else if( IsInvalidItem( rItem.pItem ) ) - rItem.pItem = nullptr; + rItem.aItemPtr = SfxPoolItemHolder(rPool, INVALID_POOL_ITEM); + else if( IsInvalidItem( rItem.aItemPtr.getItem() ) ) + rItem.aItemPtr = SfxPoolItemHolder(); j = 1; break; } @@ -196,14 +192,13 @@ IMPL_LINK_NOARG(SvxSearchAttributeDialog, OKHdl, weld::Button&, void) if ( !j && bChecked ) { - aInvalidItem.nSlot = nSlot; - rList.Insert( aInvalidItem ); + rList.Insert( { nSlot, SfxPoolItemHolder(rPool, INVALID_POOL_ITEM) }); } } // remove invalid items (pItem == NULL) for ( sal_uInt16 n = rList.Count(); n; ) - if ( !rList[ --n ].pItem ) + if ( !rList[ --n ].aItemPtr.getItem() ) rList.Remove( n ); m_xDialog->response(RET_OK); diff --git a/cui/source/dialogs/thesdlg.cxx b/cui/source/dialogs/thesdlg.cxx index a9f4883f4c70..ea98a44a3c9e 100644 --- a/cui/source/dialogs/thesdlg.cxx +++ b/cui/source/dialogs/thesdlg.cxx @@ -165,8 +165,8 @@ void SvxThesaurusDialog::LookUp_Impl() m_xAlternativesCT->set_visible(m_bWordFound); m_xNotFound->set_visible(!m_bWordFound); - if (m_bWordFound) - Application::PostUserEvent(LINK(this, SvxThesaurusDialog, SelectFirstHdl_Impl)); + if (m_bWordFound && !m_nSelectFirstEvent) + m_nSelectFirstEvent = Application::PostUserEvent(LINK(this, SvxThesaurusDialog, SelectFirstHdl_Impl)); if (m_xWordCB->find_text(aText) == -1) m_xWordCB->append_text(aText); @@ -217,13 +217,15 @@ IMPL_LINK( SvxThesaurusDialog, AlternativesDoubleClickHdl_Impl, weld::TreeView&, //! workaround to set the selection since calling SelectEntryPos within //! the double click handler does not work - Application::PostUserEvent(LINK(this, SvxThesaurusDialog, SelectFirstHdl_Impl)); + if (!m_nSelectFirstEvent) + m_nSelectFirstEvent = Application::PostUserEvent(LINK(this, SvxThesaurusDialog, SelectFirstHdl_Impl)); return true; } IMPL_LINK_NOARG(SvxThesaurusDialog, SelectFirstHdl_Impl, void *, void) { + m_nSelectFirstEvent = nullptr; if (m_xAlternativesCT->n_children() >= 2) { m_xAlternativesCT->select(1); // pos 0 is a 'header' that is not selectable @@ -249,6 +251,7 @@ SvxThesaurusDialog::SvxThesaurusDialog( , m_xReplaceEdit(m_xBuilder->weld_entry("replaceed")) , m_xLangLB(m_xBuilder->weld_combo_box("langcb")) , m_xReplaceBtn(m_xBuilder->weld_button("ok")) + , m_nSelectFirstEvent(nullptr) { m_aModifyIdle.SetInvokeHandler( LINK( this, SvxThesaurusDialog, ModifyTimer_Hdl ) ); m_aModifyIdle.SetPriority( TaskPriority::LOWEST ); @@ -312,10 +315,17 @@ SvxThesaurusDialog::SvxThesaurusDialog( // disable controls if service is missing if (!xThesaurus.is()) m_xDialog->set_sensitive(false); + else + m_xWordCB->grab_focus(); } SvxThesaurusDialog::~SvxThesaurusDialog() { + if (m_nSelectFirstEvent) + { + Application::RemoveUserEvent(m_nSelectFirstEvent); + m_nSelectFirstEvent = nullptr; + } } IMPL_LINK_NOARG(SvxThesaurusDialog, ReplaceBtnHdl_Impl, weld::Button&, void) diff --git a/cui/source/dialogs/tipofthedaydlg.cxx b/cui/source/dialogs/tipofthedaydlg.cxx index 34193bff90de..40bb606130f2 100644 --- a/cui/source/dialogs/tipofthedaydlg.cxx +++ b/cui/source/dialogs/tipofthedaydlg.cxx @@ -26,8 +26,8 @@ #include <vcl/graphicfilter.hxx> #include <vcl/help.hxx> #include <vcl/window.hxx> +#include <vcl/ImageTree.hxx> -#include <com/sun/star/frame/XDesktop2.hpp> #include <com/sun/star/frame/XDispatch.hpp> #include <com/sun/star/frame/XDispatchProvider.hpp> #include <com/sun/star/util/URL.hpp> @@ -43,13 +43,14 @@ #include <unotools/resmgr.hxx> #include <unotools/configmgr.hxx> #include <com/sun/star/beans/PropertyValue.hpp> +#include <bitmaps.hlst> //size of preview const Size ThumbSize(150, 150); TipOfTheDayDialog::TipOfTheDayDialog(weld::Window* pParent) : GenericDialogController(pParent, "cui/ui/tipofthedaydialog.ui", "TipOfTheDayDialog") - , m_pParent(pParent) + , m_xParent(pParent ? pParent->GetXWindow() : nullptr) , m_pText(m_xBuilder->weld_label("lbText")) , m_pShowTip(m_xBuilder->weld_check_button("cbShowTip")) , m_pNext(m_xBuilder->weld_button("btnNext")) @@ -61,15 +62,11 @@ TipOfTheDayDialog::TipOfTheDayDialog(weld::Window* pParent) m_nCurrentTip = officecfg::Office::Common::Misc::LastTipOfTheDayID::get(); m_pPreview->set_size_request(ThumbSize.Width(), ThumbSize.Height()); - if (pParent != nullptr) + if (m_xParent.is()) { - css::uno::Reference<css::awt::XWindow> xWindow = pParent->GetXWindow(); - if (xWindow.is()) - { - VclPtr<vcl::Window> xVclWin(VCLUnoHelper::GetWindow(xWindow)); - if (xVclWin != nullptr) - xVclWin->AddEventListener(LINK(this, TipOfTheDayDialog, Terminated)); - } + VclPtr<vcl::Window> xVclWin(VCLUnoHelper::GetWindow(m_xParent)); + if (xVclWin != nullptr) + xVclWin->AddEventListener(LINK(this, TipOfTheDayDialog, Terminated)); } const auto t0 = std::chrono::system_clock::now().time_since_epoch(); @@ -92,7 +89,10 @@ TipOfTheDayDialog::TipOfTheDayDialog(weld::Window* pParent) IMPL_LINK(TipOfTheDayDialog, Terminated, VclWindowEvent&, rEvent, void) { if (rEvent.GetId() == VclEventId::ObjectDying) + { + m_xParent.clear(); TipOfTheDayDialog::response(RET_OK); + } } TipOfTheDayDialog::~TipOfTheDayDialog() @@ -103,15 +103,11 @@ TipOfTheDayDialog::~TipOfTheDayDialog() officecfg::Office::Common::Misc::ShowTipOfTheDay::set(m_pShowTip->get_active(), xChanges); xChanges->commit(); - if (m_pParent != nullptr) + if (m_xParent.is()) { - css::uno::Reference<css::awt::XWindow> xWindow = m_pParent->GetXWindow(); - if (xWindow.is()) - { - VclPtr<vcl::Window> xVclWin(VCLUnoHelper::GetWindow(xWindow)); - if (xVclWin != nullptr) - xVclWin->RemoveEventListener(LINK(this, TipOfTheDayDialog, Terminated)); - } + VclPtr<vcl::Window> xVclWin(VCLUnoHelper::GetWindow(m_xParent)); + if (xVclWin != nullptr) + xVclWin->RemoveEventListener(LINK(this, TipOfTheDayDialog, Terminated)); } } @@ -123,17 +119,30 @@ static bool file_exists(const OUString& fileName) void TipOfTheDayDialog::UpdateTip() { - constexpr sal_Int32 nNumberOfTips = SAL_N_ELEMENTS(TIPOFTHEDAY_STRINGARRAY); + constexpr sal_Int32 nNumberOfTips = std::size(TIPOFTHEDAY_STRINGARRAY); - if ((m_nCurrentTip >= nNumberOfTips) || (m_nCurrentTip < 0)) - m_nCurrentTip = 0; + for (;;) + { + if ((m_nCurrentTip >= nNumberOfTips) || (m_nCurrentTip < 0)) + m_nCurrentTip = 0; + if (std::get<1>(TIPOFTHEDAY_STRINGARRAY[m_nCurrentTip]) + == "svx/ui/safemodedialog/SafeModeDialog" + && !officecfg::Office::Common::Misc::OfferSafeMode::get()) + { + ++m_nCurrentTip; + } + else + { + break; + } + } //title m_xDialog->set_title(CuiResId(STR_TITLE) .replaceFirst("%CURRENT", OUString::number(m_nCurrentTip + 1)) .replaceFirst("%TOTAL", OUString::number(nNumberOfTips))); - auto[sTip, sLink, sImage] = TIPOFTHEDAY_STRINGARRAY[m_nCurrentTip]; + auto[sTip, sLink, sImage, nType] = TIPOFTHEDAY_STRINGARRAY[m_nCurrentTip]; // text //replace MOD1 & MOD2 shortcuts depending on platform @@ -155,8 +164,7 @@ void TipOfTheDayDialog::UpdateTip() { m_pLink->set_visible(false); //show the link only if the UNO command is available in the current module - SfxViewFrame* pViewFrame = SfxViewFrame::Current(); - if (pViewFrame) + if (SfxViewFrame* pViewFrame = SfxViewFrame::Current()) { const auto xFrame = pViewFrame->GetFrame().GetFrameInterface(); const css::uno::Reference<css::frame::XDispatchProvider> xDispatchProvider( @@ -213,11 +221,22 @@ void TipOfTheDayDialog::UpdateTip() OUString aURL("$BRAND_BASE_DIR/$BRAND_SHARE_SUBDIR/tipoftheday/"); rtl::Bootstrap::expandMacros(aURL); OUString aImageName = sImage; - // use default image if none is available with the number - if (aImageName.isEmpty() || !file_exists(aURL + aImageName)) - aImageName = "tipoftheday.png"; Graphic aGraphic; - GraphicFilter::LoadGraphic(aURL + aImageName, OUString(), aGraphic); + + if (!aImageName.isEmpty() && file_exists(aURL + aImageName)) + GraphicFilter::LoadGraphic(aURL + aImageName, OUString(), aGraphic); + else + { + const OUString sModuleImage[5] + = { RID_SVXBMP_TOTD_WRITER, RID_SVXBMP_TOTD_CALC, RID_SVXBMP_TOTD_DRAW, + RID_SVXBMP_TOTD_IMPRESS, RID_SVXBMP_TOTD_SOFFICE }; + const OUString aIconTheme + = Application::GetSettings().GetStyleSettings().DetermineIconTheme(); + BitmapEx aBmpEx; + ImageTree::get().loadImage(sModuleImage[nType], aIconTheme, aBmpEx, true, + ImageLoadFlags::IgnoreDarkTheme); + aGraphic = aBmpEx; + } if (!aGraphic.IsAnimated()) { diff --git a/cui/source/dialogs/toolbarmodedlg.cxx b/cui/source/dialogs/toolbarmodedlg.cxx index e3064451cae3..54918e7fdcd4 100644 --- a/cui/source/dialogs/toolbarmodedlg.cxx +++ b/cui/source/dialogs/toolbarmodedlg.cxx @@ -67,11 +67,9 @@ static OUString GetCurrentApp() static OUString GetCurrentMode() { OUString sResult; - if (SfxViewFrame* pViewFrame = SfxViewFrame::Current()) + if (SfxViewFrame::Current()) { - const auto xCurrentFrame = pViewFrame->GetFrame().GetFrameInterface(); const auto xContext = comphelper::getProcessComponentContext(); - const auto xModuleManager = css::frame::ModuleManager::create(xContext); const utl::OConfigurationTreeRoot aAppNode( xContext, "org.openoffice.Office.UI.ToolbarMode/Applications/" + GetCurrentApp(), true); if (aAppNode.isValid()) @@ -96,12 +94,12 @@ ToolbarmodeDialog::ToolbarmodeDialog(weld::Window* pParent) (m_xBuilder->weld_radio_button("rbButton9")) } , m_pInfoLabel(m_xBuilder->weld_label("lbInfo")) { - static_assert(SAL_N_ELEMENTS(m_pRadioButtons) == SAL_N_ELEMENTS(TOOLBARMODES_ARRAY)); + static_assert(SAL_N_ELEMENTS(m_pRadioButtons) == std::size(TOOLBARMODES_ARRAY)); Link<weld::Toggleable&, void> aLink = LINK(this, ToolbarmodeDialog, SelectToolbarmode); const OUString sCurrentMode = GetCurrentMode(); - for (tools::ULong i = 0; i < SAL_N_ELEMENTS(m_pRadioButtons); i++) + for (std::size_t i = 0; i < std::size(m_pRadioButtons); ++i) { m_pRadioButtons[i]->connect_toggled(aLink); if (sCurrentMode == std::get<1>(TOOLBARMODES_ARRAY[i])) @@ -112,7 +110,7 @@ ToolbarmodeDialog::ToolbarmodeDialog(weld::Window* pParent) } } - m_pApply->set_label(CuiResId(RID_SVXSTR_UI_APPLYALL).replaceFirst("%MODULE", GetCurrentApp())); + m_pApply->set_label(CuiResId(RID_CUISTR_UI_APPLYALL).replaceFirst("%MODULE", GetCurrentApp())); m_pApply->connect_clicked(LINK(this, ToolbarmodeDialog, OnApplyClick)); m_pApplyAll->connect_clicked(LINK(this, ToolbarmodeDialog, OnApplyClick)); @@ -133,7 +131,7 @@ static bool file_exists(const OUString& fileName) int ToolbarmodeDialog::GetActiveRadioButton() { - for (tools::ULong i = 0; i < SAL_N_ELEMENTS(m_pRadioButtons); i++) + for (std::size_t i = 0; i < std::size(m_pRadioButtons); ++i) { if (m_pRadioButtons[i]->get_active()) return i; @@ -181,7 +179,7 @@ IMPL_LINK(ToolbarmodeDialog, OnApplyClick, weld::Button&, rButton, void) if (&rButton == m_pApplyAll.get()) { std::shared_ptr<comphelper::ConfigurationChanges> aBatch( - comphelper::ConfigurationChanges::create(::comphelper::getProcessComponentContext())); + comphelper::ConfigurationChanges::create()); officecfg::Office::UI::ToolbarMode::ActiveWriter::set(sCmd, aBatch); officecfg::Office::UI::ToolbarMode::ActiveCalc::set(sCmd, aBatch); officecfg::Office::UI::ToolbarMode::ActiveImpress::set(sCmd, aBatch); @@ -189,21 +187,19 @@ IMPL_LINK(ToolbarmodeDialog, OnApplyClick, weld::Button&, rButton, void) aBatch->commit(); OUString sCurrentApp = GetCurrentApp(); - if (SfxViewFrame* pViewFrame = SfxViewFrame::Current()) + if (SfxViewFrame::Current()) { - const auto xCurrentFrame = pViewFrame->GetFrame().GetFrameInterface(); const auto xContext = comphelper::getProcessComponentContext(); - const auto xModuleManager = css::frame::ModuleManager::create(xContext); const utl::OConfigurationTreeRoot aAppNode( xContext, "org.openoffice.Office.UI.ToolbarMode/Applications/", true); if (sCurrentApp != "Writer") - aAppNode.setNodeValue("Writer/Active", css::uno::makeAny(sCmd)); + aAppNode.setNodeValue("Writer/Active", css::uno::Any(sCmd)); if (sCurrentApp != "Calc") - aAppNode.setNodeValue("Calc/Active", css::uno::makeAny(sCmd)); + aAppNode.setNodeValue("Calc/Active", css::uno::Any(sCmd)); if (sCurrentApp != "Impress") - aAppNode.setNodeValue("Impress/Active", css::uno::makeAny(sCmd)); + aAppNode.setNodeValue("Impress/Active", css::uno::Any(sCmd)); if (sCurrentApp != "Draw") - aAppNode.setNodeValue("Draw/Active", css::uno::makeAny(sCmd)); + aAppNode.setNodeValue("Draw/Active", css::uno::Any(sCmd)); aAppNode.commit(); }; } diff --git a/cui/source/dialogs/whatsnew.cxx b/cui/source/dialogs/whatsnew.cxx new file mode 100644 index 000000000000..31ad380d8cf9 --- /dev/null +++ b/cui/source/dialogs/whatsnew.cxx @@ -0,0 +1,172 @@ +/* -*- 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/. + */ + +#include <whatsnew.hxx> +#include <whatsnew.hrc> + +#include <dialmgr.hxx> +#include <comphelper/DirectoryHelper.hxx> +#include <rtl/bootstrap.hxx> +#include <vcl/graphicfilter.hxx> +#include <vcl/svapp.hxx> +#include <vcl/gdimtf.hxx> + +constexpr tools::Long TEXT_HEIGHT(120); +constexpr tools::Long PROGRESS_DOTSIZE(24); +constexpr tools::Long PROGRESS_DOTSPACING(4); + +WhatsNewDialog::WhatsNewDialog(weld::Window* pParent, const bool bWelcome) + : GenericDialogController(pParent, "cui/ui/whatsnewdialog.ui", "WhatsNewDialog") + , m_bWelcome(bWelcome) + , m_aPreview() + , m_aProgress() + , m_pPrevBtn(m_xBuilder->weld_button("btnPrev")) + , m_pNextBtn(m_xBuilder->weld_button("btnNext")) + , m_pProgress(new weld::CustomWeld(*m_xBuilder, "imProgress", m_aProgress)) + , m_pImage(new weld::CustomWeld(*m_xBuilder, "imNews", m_aPreview)) +{ + if (m_bWelcome) + m_xDialog->set_title(CuiResId(STR_WELCOME)); + m_pPrevBtn->set_sensitive(false); + + m_pPrevBtn->connect_clicked(LINK(this, WhatsNewDialog, OnPrevClick)); + m_pNextBtn->connect_clicked(LINK(this, WhatsNewDialog, OnNextClick)); + + m_nNumberOfNews = m_bWelcome ? std::size(WELCOME_STRINGARRAY) : std::size(WHATSNEW_STRINGARRAY); + m_nCurrentNews = 0; + m_pNextBtn->set_sensitive(m_nNumberOfNews > 1); + m_pProgress->set_size_request(m_nNumberOfNews * (PROGRESS_DOTSIZE + PROGRESS_DOTSPACING), + PROGRESS_DOTSIZE + 1); + + LoadImage(); +} + +WhatsNewDialog::~WhatsNewDialog() {} + +void WhatsNewDialog::LoadImage() +{ + if (m_nCurrentNews < m_nNumberOfNews) + { + auto[sText, sImage] = m_bWelcome ? WELCOME_STRINGARRAY[m_nCurrentNews] + : WHATSNEW_STRINGARRAY[m_nCurrentNews]; + OUString aURL("$BRAND_BASE_DIR/$BRAND_SHARE_SUBDIR/whatsnew/"); + rtl::Bootstrap::expandMacros(aURL); + + const bool bFileExists = comphelper::DirectoryHelper::fileExists(aURL + sImage); + if (!sImage.isEmpty() && bFileExists) + m_aPreview.Update(aURL + sImage, CuiResId(sText)); + + m_aProgress.Update(m_nCurrentNews, m_nNumberOfNews); + } +} + +IMPL_LINK_NOARG(WhatsNewDialog, OnPrevClick, weld::Button&, void) +{ + m_nCurrentNews--; + if (m_nCurrentNews == 0) + m_pPrevBtn->set_sensitive(false); + m_pNextBtn->set_sensitive(true); + LoadImage(); +} + +IMPL_LINK_NOARG(WhatsNewDialog, OnNextClick, weld::Button&, void) +{ + m_nCurrentNews++; + if (m_nCurrentNews == m_nNumberOfNews - 1) + m_pNextBtn->set_sensitive(false); + m_pPrevBtn->set_sensitive(true); + LoadImage(); +} + +void WhatsNewImg::Paint(vcl::RenderContext& rRenderContext, const tools::Rectangle&) +{ + const StyleSettings rSettings(Application::GetSettings().GetStyleSettings()); + + //clear + rRenderContext.SetBackground(Wallpaper(rSettings.GetDialogColor())); + rRenderContext.Erase(); + + //background image + Graphic aGraphic; + GraphicFilter::LoadGraphic(m_sImage, OUString(), aGraphic); + const Size aGraphicSize(aGraphic.GetSizePixel()); + + if (aGraphic.IsAnimated()) + aGraphic.StartAnimation(rRenderContext, Point(), aGraphicSize); + else + aGraphic.Draw(rRenderContext, Point(), aGraphicSize); + + tools::Rectangle aRect(Point(0, aGraphicSize.Height() - TEXT_HEIGHT), + Size(aGraphicSize.Width(), TEXT_HEIGHT)); + + //transparent text background + ScopedVclPtrInstance<VirtualDevice> aVDev; + GDIMetaFile aMetafile; + + aMetafile.Record(aVDev.get()); + aMetafile.SetPrefSize(aRect.GetSize()); + aVDev->SetOutputSize(aRect.GetSize()); + aVDev->SetBackground(Color(0x10, 0x68, 0x02)); + aVDev->Erase(); + aMetafile.Stop(); + + Gradient aVCLGradient; + aVCLGradient.SetStyle(css::awt::GradientStyle_LINEAR); + aVCLGradient.SetStartColor(COL_GRAY); + aVCLGradient.SetEndColor(COL_GRAY); + aVCLGradient.SetStartIntensity(33); + aVCLGradient.SetEndIntensity(66); + + rRenderContext.DrawTransparent(aMetafile, aRect.TopLeft(), aRect.GetSize(), aVCLGradient); + + //text + vcl::Font aFont = rRenderContext.GetFont(); + const Size aFontSize = aFont.GetFontSize(); + aFont.SetFontSize(Size(0, 24)); + aFont.SetColor(COL_WHITE); + aFont.SetWeight(WEIGHT_BOLD); + rRenderContext.SetFont(aFont); + + DrawTextFlags nDrawTextStyle(DrawTextFlags::MultiLine | DrawTextFlags::WordBreak + | DrawTextFlags::EndEllipsis); + const bool bIsRTL = rRenderContext.GetTextIsRTL(m_sText, 0, m_sText.getLength()); + if (bIsRTL) + nDrawTextStyle |= DrawTextFlags::Right; + + aRect.shrink(6); + aRect.setWidth(rRenderContext.GetOutputSizePixel().Width() - 12); + rRenderContext.DrawText(aRect, m_sText, nDrawTextStyle); + + aFont.SetFontSize(aFontSize); + aFont.SetWeight(WEIGHT_NORMAL); + rRenderContext.SetFont(aFont); +} + +void WhatsNewProgress::Paint(vcl::RenderContext& rRenderContext, const tools::Rectangle&) +{ + const StyleSettings rSettings(Application::GetSettings().GetStyleSettings()); + rRenderContext.SetBackground(rSettings.GetDialogColor()); + rRenderContext.Erase(); + rRenderContext.SetAntialiasing(AntialiasingFlags::Enable); + + tools::Rectangle aRect(Point(0, 0), Size(PROGRESS_DOTSIZE, PROGRESS_DOTSIZE)); + for (sal_Int32 i = 0; i < m_nTotal; i++) + { + if (i == m_nCurrent) + rRenderContext.SetFillColor(rSettings.GetAccentColor()); + else + rRenderContext.SetFillColor(COL_WHITE); + rRenderContext.DrawEllipse(aRect); + + aRect.AdjustLeft(PROGRESS_DOTSIZE + PROGRESS_DOTSPACING); + aRect.AdjustRight(PROGRESS_DOTSIZE + PROGRESS_DOTSPACING); + } +} + +/* vim:set shiftwidth=4 softtabstop=4 expandtab cinoptions=b1,g0,N-s cinkeys+=0=break: */
\ No newline at end of file diff --git a/cui/source/dialogs/widgettestdlg.cxx b/cui/source/dialogs/widgettestdlg.cxx new file mode 100644 index 000000000000..51ecef3105d0 --- /dev/null +++ b/cui/source/dialogs/widgettestdlg.cxx @@ -0,0 +1,57 @@ +/* -*- 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 <widgettestdlg.hxx> +#include <bitmaps.hlst> + +WidgetTestDialog::WidgetTestDialog(weld::Window* pParent) + : GenericDialogController(pParent, "cui/ui/widgettestdialog.ui", "WidgetTestDialog") +{ + m_xOKButton = m_xBuilder->weld_button("ok_btn"); + m_xCancelButton = m_xBuilder->weld_button("cancel_btn"); + m_xTreeView = m_xBuilder->weld_tree_view("contenttree"); + m_xTreeView2 = m_xBuilder->weld_tree_view("contenttree2"); + + m_xOKButton->connect_clicked(LINK(this, WidgetTestDialog, OkHdl)); + m_xCancelButton->connect_clicked(LINK(this, WidgetTestDialog, CancelHdl)); + + FillTreeView(); +} + +WidgetTestDialog::~WidgetTestDialog() {} + +IMPL_LINK_NOARG(WidgetTestDialog, OkHdl, weld::Button&, void) { m_xDialog->response(RET_OK); } + +IMPL_LINK_NOARG(WidgetTestDialog, CancelHdl, weld::Button&, void) +{ + m_xDialog->response(RET_CANCEL); +} + +void WidgetTestDialog::FillTreeView() +{ + OUString aImage1(RID_SVXBMP_CELL_LR); + OUString aImage2(RID_SVXBMP_SHADOW_BOT_LEFT); + + for (size_t nCount = 0; nCount < 4; nCount++) + { + OUString sText = OUString::Concat("Test ") + OUString::Concat(OUString::number(nCount)); + std::unique_ptr<weld::TreeIter> xEntry = m_xTreeView->make_iterator(); + m_xTreeView->insert(nullptr, -1, &sText, &sText, nullptr, nullptr, false, xEntry.get()); + m_xTreeView->set_image(*xEntry, (nCount % 2 == 0) ? aImage1 : aImage2); + + m_xTreeView2->append(); + m_xTreeView2->set_image(nCount, (nCount % 2 == 0) ? aImage1 : aImage2); + m_xTreeView2->set_text(nCount, "First Column", 0); + m_xTreeView2->set_text( + nCount, OUString::Concat("Row ") + OUString::Concat(OUString::number(nCount)), 1); + m_xTreeView2->set_id(nCount, OUString::number(nCount)); + } +} + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/cui/source/dialogs/zoom.cxx b/cui/source/dialogs/zoom.cxx index 90999d96798a..7bef6a5b9860 100644 --- a/cui/source/dialogs/zoom.cxx +++ b/cui/source/dialogs/zoom.cxx @@ -168,9 +168,7 @@ SvxZoomDialog::SvxZoomDialog(weld::Window* pParent, const SfxItemSet& rCoreSet) // maybe get the old value first const SfxUInt16Item* pOldUserItem = nullptr; - SfxObjectShell* pShell = SfxObjectShell::Current(); - - if (pShell) + if (SfxObjectShell* pShell = SfxObjectShell::Current()) pOldUserItem = pShell->GetItem(SID_ATTR_ZOOM_USER); if (pOldUserItem) @@ -185,7 +183,7 @@ SvxZoomDialog::SvxZoomDialog(weld::Window* pParent, const SfxItemSet& rCoreSet) SetLimits(nMin, nMax); m_xUserEdit->set_value(nValue, FieldUnit::PERCENT); - const SfxPoolItem& rItem = m_rSet.Get(m_rSet.GetPool()->GetWhich(SID_ATTR_ZOOM)); + const SfxPoolItem& rItem = m_rSet.Get(SID_ATTR_ZOOM); if (auto pZoomItem = dynamic_cast<const SvxZoomItem*>(&rItem)) { @@ -228,11 +226,8 @@ SvxZoomDialog::SvxZoomDialog(weld::Window* pParent, const SfxItemSet& rCoreSet) SetFactor(nZoom); } - const SfxPoolItem* pPoolViewLayoutItem = nullptr; - if (SfxItemState::SET == m_rSet.GetItemState(SID_ATTR_VIEWLAYOUT, false, &pPoolViewLayoutItem)) + if (const SvxViewLayoutItem* pViewLayoutItem = m_rSet.GetItemIfSet(SID_ATTR_VIEWLAYOUT, false)) { - const SvxViewLayoutItem* pViewLayoutItem - = static_cast<const SvxViewLayoutItem*>(pPoolViewLayoutItem); const sal_uInt16 nColumns = pViewLayoutItem->GetValue(); const bool bBookMode = pViewLayoutItem->IsBookMode(); @@ -269,7 +264,7 @@ SvxZoomDialog::SvxZoomDialog(weld::Window* pParent, const SfxItemSet& rCoreSet) else { // hide view layout related controls: - m_xViewFrame->set_sensitive(false); + m_xViewFrame->set_visible(false); } } @@ -344,9 +339,8 @@ IMPL_LINK_NOARG(SvxZoomDialog, OKHdl, weld::Button&, void) { if (m_bModified) { - SvxZoomItem aZoomItem(SvxZoomType::PERCENT, 0, m_rSet.GetPool()->GetWhich(SID_ATTR_ZOOM)); - SvxViewLayoutItem aViewLayoutItem(0, false, - m_rSet.GetPool()->GetWhich(SID_ATTR_VIEWLAYOUT)); + SvxZoomItem aZoomItem(SvxZoomType::PERCENT, 0, SID_ATTR_ZOOM); + SvxViewLayoutItem aViewLayoutItem(0, false, SID_ATTR_VIEWLAYOUT); sal_uInt16 nFactor = GetFactor(); @@ -388,9 +382,7 @@ IMPL_LINK_NOARG(SvxZoomDialog, OKHdl, weld::Button&, void) m_pOutSet->Put(aViewLayoutItem); // memorize value from the UserEdit beyond the dialog - SfxObjectShell* pShell = SfxObjectShell::Current(); - - if (pShell) + if (SfxObjectShell* pShell = SfxObjectShell::Current()) { sal_uInt16 nZoomValue = static_cast<sal_uInt16>(m_xUserEdit->get_value(FieldUnit::PERCENT)); diff --git a/cui/source/factory/cuiexp.cxx b/cui/source/factory/cuiexp.cxx index 06557be56779..28b83f6a8780 100644 --- a/cui/source/factory/cuiexp.cxx +++ b/cui/source/factory/cuiexp.cxx @@ -19,18 +19,50 @@ #include "dlgfact.hxx" #include <sal/types.h> +#include <cppuhelper/supportsservice.hxx> +#include <com/sun/star/lang/XUnoTunnel.hpp> -namespace cui +/// anonymous implementation namespace +namespace { -static AbstractDialogFactory_Impl* GetFactory() +class GetCreateDialogFactoryService + : public ::cppu::WeakImplHelper<css::lang::XServiceInfo, css::lang::XUnoTunnel> { - static AbstractDialogFactory_Impl* pFactory = new AbstractDialogFactory_Impl; - return pFactory; -} -} +public: + // css::lang::XServiceInfo: + virtual OUString SAL_CALL getImplementationName() override + { + return "com.sun.star.cui.GetCreateDialogFactoryService"; + } + virtual sal_Bool SAL_CALL supportsService(const OUString& serviceName) override + { + return cppu::supportsService(this, serviceName); + } + virtual css::uno::Sequence<OUString> SAL_CALL getSupportedServiceNames() override + { + return { "com.sun.star.cui.GetCreateDialogFactoryService" }; + } + + // XUnoTunnel + virtual sal_Int64 SAL_CALL + getSomething(const ::css::uno::Sequence<::sal_Int8>& /*aIdentifier*/) override + { + // Noting that we have to return a pointer to **VclAbstractDialogFactory** otherwise + // the dynamic_casting on the other end will fail on Windows (possibly because of the virtual base involved). + static VclAbstractDialogFactory* pFactory = new AbstractDialogFactory_Impl; + return reinterpret_cast<sal_Int64>(pFactory); + } +}; + +} // closing anonymous implementation namespace extern "C" { -SAL_DLLPUBLIC_EXPORT VclAbstractDialogFactory* CreateDialogFactory() { return ::cui::GetFactory(); } +SAL_DLLPUBLIC_EXPORT css::uno::XInterface* +com_sun_star_cui_GetCreateDialogFactoryService(css::uno::XComponentContext*, + css::uno::Sequence<css::uno::Any> const&) +{ + return cppu::acquire(new GetCreateDialogFactoryService); +} } /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/cui/source/factory/dlgfact.cxx b/cui/source/factory/dlgfact.cxx index bd3130fd0fc7..9c422c4f71a6 100644 --- a/cui/source/factory/dlgfact.cxx +++ b/cui/source/factory/dlgfact.cxx @@ -18,11 +18,13 @@ */ #include <config_extensions.h> +#include <config_wasm_strip.h> #include <align.hxx> #include "dlgfact.hxx" #include <about.hxx> +#include <whatsnew.hxx> #include <sfx2/app.hxx> #include <sfx2/basedlgs.hxx> #include <sfx2/pageids.hxx> @@ -31,7 +33,7 @@ #include <numfmt.hxx> #include <splitcelldlg.hxx> #include <cuiimapwnd.hxx> -#include <cui/cuicharmap.hxx> +#include <svx/cuicharmap.hxx> #include <srchxtra.hxx> #include <textanim.hxx> #include <autocdlg.hxx> @@ -46,7 +48,6 @@ #include <cuisrchdlg.hxx> #include <cuitbxform.hxx> #include <optdict.hxx> -#include <dlgname.hxx> #include <multipat.hxx> #include <cuihyperdlg.hxx> #include <cuifmsearch.hxx> @@ -88,6 +89,7 @@ #include <hyphen.hxx> #include <thesdlg.hxx> #include <tipofthedaydlg.hxx> +#include <widgettestdlg.hxx> #include <toolbarmodedlg.hxx> #include <DiagramDialog.hxx> #include <fileextcheckdlg.hxx> @@ -101,36 +103,36 @@ using ::com::sun::star::uno::Reference; using namespace svx; -IMPL_ABSTDLG_CLASS(AbstractAdditionsDialog) -IMPL_ABSTDLG_CLASS(AbstractDiagramDialog) +IMPL_ABSTDLG_CLASS_ASYNC(AbstractAdditionsDialog, weld::GenericDialogController) +IMPL_ABSTDLG_CLASS_ASYNC(AbstractDiagramDialog, DiagramDialog) IMPL_ABSTDLG_CLASS(AbstractFmInputRecordNoDialog) IMPL_ABSTDLG_CLASS(AbstractFmSearchDialog) IMPL_ABSTDLG_CLASS(AbstractFmShowColsDialog) IMPL_ABSTDLG_CLASS(AbstractGalleryIdDialog) -IMPL_ABSTDLG_CLASS(AbstractGraphicFilterDialog) +IMPL_ABSTDLG_CLASS_ASYNC(AbstractGraphicFilterDialog, GraphicFilterDialog) IMPL_ABSTDLG_CLASS(AbstractHangulHanjaConversionDialog) -IMPL_ABSTDLG_CLASS(AbstractHyphenWordDialog) IMPL_ABSTDLG_CLASS(AbstractInsertObjectDialog) -IMPL_ABSTDLG_CLASS(AbstractLinksDialog) -IMPL_ABSTDLG_CLASS(AbstractPasswordToOpenModifyDialog) -IMPL_ABSTDLG_CLASS(AbstractQrCodeGenDialog) +IMPL_ABSTDLG_CLASS_ASYNC(AbstractLinksDialog, SvBaseLinksDlg) IMPL_ABSTDLG_CLASS(AbstractScreenshotAnnotationDlg) -IMPL_ABSTDLG_CLASS(AbstractSignatureLineDialog) -IMPL_ABSTDLG_CLASS(AbstractSignSignatureLineDialog) -IMPL_ABSTDLG_CLASS(AbstractSvxCharacterMapDialog) +IMPL_ABSTDLG_CLASS_ASYNC(AbstractSignatureLineDialog, SignatureLineDialog) +IMPL_ABSTDLG_CLASS_ASYNC(AbstractSignSignatureLineDialog, SignSignatureLineDialog) +IMPL_ABSTDLG_CLASS_ASYNC(AbstractSvxCharacterMapDialog, SvxCharacterMap) +IMPL_ABSTDLG_CLASS(AbstractSecurityOptionsDialog) IMPL_ABSTDLG_CLASS(AbstractSvxHpLinkDlg) IMPL_ABSTDLG_CLASS(AbstractSvxJSearchOptionsDialog) IMPL_ABSTDLG_CLASS(AbstractSvxMultiPathDialog) IMPL_ABSTDLG_CLASS(AbstractSvxNameDialog) IMPL_ABSTDLG_CLASS(AbstractSvxNewDictionaryDialog) -IMPL_ABSTDLG_CLASS(AbstractSvxObjectNameDialog) -IMPL_ABSTDLG_CLASS(AbstractSvxObjectTitleDescDialog) +IMPL_ABSTDLG_CLASS_ASYNC(AbstractSvxObjectNameDialog, SvxObjectNameDialog) +IMPL_ABSTDLG_CLASS_ASYNC(AbstractSvxObjectTitleDescDialog, SvxObjectTitleDescDialog) IMPL_ABSTDLG_CLASS(AbstractSvxPathSelectDialog) IMPL_ABSTDLG_CLASS(AbstractSvxPostItDialog) -IMPL_ABSTDLG_CLASS(AbstractSvxSearchSimilarityDialog) +IMPL_ABSTDLG_CLASS_ASYNC(AbstractSvxSearchSimilarityDialog,SvxSearchSimilarityDialog) IMPL_ABSTDLG_CLASS(AbstractSvxZoomDialog) IMPL_ABSTDLG_CLASS(AbstractTitleDialog) IMPL_ABSTDLG_CLASS(AbstractURLDlg) +IMPL_ABSTDLG_CLASS_ASYNC(AbstractPasswordToOpenModifyDialog,weld::DialogController) +IMPL_ABSTDLG_CLASS_ASYNC(AbstractQrCodeGenDialog,QrCodeGenDialog) IMPL_ABSTDLG_CLASS_ASYNC(AbstractPasteDialog,SfxDialogController) IMPL_ABSTDLG_CLASS_ASYNC(AbstractScriptSelectorDialog,SfxDialogController) IMPL_ABSTDLG_CLASS_ASYNC(AbstractSpellDialog,SfxDialogController) @@ -141,7 +143,17 @@ IMPL_ABSTDLG_CLASS_ASYNC(AbstractThesaurusDialog,SfxDialogController) IMPL_ABSTDLG_CLASS_ASYNC(CuiAbstractControllerAsync,weld::DialogController) IMPL_ABSTDLG_CLASS_ASYNC(CuiAbstractTabController,SfxTabDialogController) IMPL_ABSTDLG_CLASS(CuiAbstractController) -IMPL_ABSTDLG_CLASS(CuiAbstractSingleTabController) +IMPL_ABSTDLG_CLASS_ASYNC(CuiAbstractSingleTabController, SfxSingleTabDialogController) +IMPL_ABSTDLG_CLASS_ASYNC(CuiAbstractWidgetTestControllerAsync,weld::GenericDialogController) + +short AbstractHyphenWordDialog_Impl::Execute() +{ +#if !ENABLE_WASM_STRIP_HUNSPELL + return m_xDlg->run(); +#else + return 0; +#endif +} const SfxItemSet* AbstractSvxCharacterMapDialog_Impl::GetOutputItemSet() const { @@ -153,7 +165,7 @@ void AbstractSvxCharacterMapDialog_Impl::SetText(const OUString& rStr) m_xDlg->set_title(rStr); } -void CuiAbstractTabController_Impl::SetCurPageId( const OString &rName ) +void CuiAbstractTabController_Impl::SetCurPageId( const OUString &rName ) { m_xDlg->SetCurPageId( rName ); } @@ -179,12 +191,12 @@ void CuiAbstractTabController_Impl::SetText( const OUString& rStr ) m_xDlg->set_title(rStr); } -std::vector<OString> CuiAbstractTabController_Impl::getAllPageUIXMLDescriptions() const +std::vector<OUString> CuiAbstractTabController_Impl::getAllPageUIXMLDescriptions() const { return m_xDlg->getAllPageUIXMLDescriptions(); } -bool CuiAbstractTabController_Impl::selectPageByUIXMLDescription(const OString& rUIXMLDescription) +bool CuiAbstractTabController_Impl::selectPageByUIXMLDescription(const OUString& rUIXMLDescription) { return m_xDlg->selectPageByUIXMLDescription(rUIXMLDescription); } @@ -194,7 +206,7 @@ BitmapEx CuiAbstractTabController_Impl::createScreenshot() const return m_xDlg->createScreenshot(); } -OString CuiAbstractTabController_Impl::GetScreenshotId() const +OUString CuiAbstractTabController_Impl::GetScreenshotId() const { return m_xDlg->GetScreenshotId(); } @@ -454,7 +466,7 @@ bool AbstractSvxSearchSimilarityDialog_Impl::IsRelaxed() } // AbstractSvxTransformTabDialog implementations just forwards everything to the dialog -void AbstractSvxTransformTabDialog_Impl::SetCurPageId( const OString& rName ) +void AbstractSvxTransformTabDialog_Impl::SetCurPageId( const OUString& rName ) { m_xDlg->SetCurPageId( rName ); } @@ -486,7 +498,7 @@ void AbstractSvxTransformTabDialog_Impl::SetValidateFramePosLink( const Link<Svx } // AbstractSvxCaptionDialog implementations just forwards everything to the dialog -void AbstractSvxCaptionDialog_Impl::SetCurPageId( const OString& rName ) +void AbstractSvxCaptionDialog_Impl::SetCurPageId( const OUString& rName ) { m_xDlg->SetCurPageId(rName); } @@ -536,18 +548,18 @@ tools::Long AbstractFmInputRecordNoDialog_Impl::GetValue() const return m_xDlg->GetNewDictionary(); } -void AbstractSvxNameDialog_Impl::GetName(OUString& rName) +OUString AbstractSvxNameDialog_Impl::GetName() { - rName = m_xDlg->GetName(); + return m_xDlg->GetName(); } -void AbstractSvxNameDialog_Impl::SetCheckNameHdl( const Link<AbstractSvxNameDialog&,bool>& rLink, bool bCheckImmediately ) +void AbstractSvxNameDialog_Impl::SetCheckNameHdl( const Link<AbstractSvxNameDialog&,bool>& rLink ) { aCheckNameHdl = rLink; if( rLink.IsSet() ) - m_xDlg->SetCheckNameHdl( LINK(this, AbstractSvxNameDialog_Impl, CheckNameHdl), bCheckImmediately ); + m_xDlg->SetCheckNameHdl( LINK(this, AbstractSvxNameDialog_Impl, CheckNameHdl) ); else - m_xDlg->SetCheckNameHdl( Link<SvxNameDialog&,bool>(), bCheckImmediately ); + m_xDlg->SetCheckNameHdl( Link<SvxNameDialog&,bool>() ); } void AbstractSvxNameDialog_Impl::SetCheckNameTooltipHdl( const Link<AbstractSvxNameDialog&,OUString>& rLink) @@ -559,12 +571,12 @@ void AbstractSvxNameDialog_Impl::SetCheckNameTooltipHdl( const Link<AbstractSvxN m_xDlg->SetCheckNameTooltipHdl( Link<SvxNameDialog&,OUString>()); } -void AbstractSvxNameDialog_Impl::SetEditHelpId(const OString& rHelpId) +void AbstractSvxNameDialog_Impl::SetEditHelpId(const OUString& rHelpId) { m_xDlg->SetEditHelpId(rHelpId); } -void AbstractSvxNameDialog_Impl::SetHelpId(const OString& rHelpId) +void AbstractSvxNameDialog_Impl::SetHelpId(const OUString& rHelpId) { m_xDlg->set_help_id(rHelpId); } @@ -584,9 +596,9 @@ IMPL_LINK_NOARG(AbstractSvxNameDialog_Impl, CheckNameTooltipHdl, SvxNameDialog&, return aCheckNameTooltipHdl.Call(*this); } -void AbstractSvxObjectNameDialog_Impl::GetName(OUString& rName) +OUString AbstractSvxObjectNameDialog_Impl::GetName() { - rName = m_xDlg->GetName(); + return m_xDlg->GetName(); } void AbstractSvxObjectNameDialog_Impl::SetCheckNameHdl(const Link<AbstractSvxObjectNameDialog&,bool>& rLink) @@ -608,14 +620,19 @@ IMPL_LINK_NOARG(AbstractSvxObjectNameDialog_Impl, CheckNameHdl, SvxObjectNameDia return aCheckNameHdl.Call(*this); } -void AbstractSvxObjectTitleDescDialog_Impl::GetTitle(OUString& rTitle) +OUString AbstractSvxObjectTitleDescDialog_Impl::GetTitle() +{ + return m_xDlg->GetTitle(); +} + +OUString AbstractSvxObjectTitleDescDialog_Impl::GetDescription() { - rTitle = m_xDlg->GetTitle(); + return m_xDlg->GetDescription(); } -void AbstractSvxObjectTitleDescDialog_Impl::GetDescription(OUString& rDescription) +bool AbstractSvxObjectTitleDescDialog_Impl::IsDecorative() { - rDescription = m_xDlg->GetDescription(); + return m_xDlg->IsDecorative(); } OUString AbstractSvxMultiPathDialog_Impl::GetPath() const @@ -679,7 +696,7 @@ Graphic AbstractGraphicFilterDialog_Impl::GetFilteredGraphic(const Graphic& rGra } // AbstractSvxAreaTabDialog implementations just forwards everything to the dialog -void AbstractSvxAreaTabDialog_Impl::SetCurPageId( const OString& rName ) +void AbstractSvxAreaTabDialog_Impl::SetCurPageId( const OUString& rName ) { m_xDlg->SetCurPageId( rName ); } @@ -792,52 +809,64 @@ bool AbstractPasswordToOpenModifyDialog_Impl::IsRecommendToOpenReadonly() const return m_xDlg->IsRecommendToOpenReadonly(); } +void AbstractPasswordToOpenModifyDialog_Impl::Response(sal_Int32 nResult) +{ + m_xDlg->response(nResult); +} + +void AbstractPasswordToOpenModifyDialog_Impl::AllowEmpty() +{ + m_xDlg->AllowEmpty(); +} + // Create dialogs with simplest interface VclPtr<VclAbstractDialog> AbstractDialogFactory_Impl::CreateVclDialog(weld::Window* pParent, sal_uInt32 nResId) { - std::unique_ptr<OfaTreeOptionsDialog> xDlg; switch ( nResId ) { - case SID_OPTIONS_TREEDIALOG : case SID_OPTIONS_DATABASES : + { + Reference< frame::XFrame > xFrame; + auto xDlg = std::make_shared<OfaTreeOptionsDialog>(pParent, xFrame, /*bActivateLastSelection*/false); + xDlg->ActivatePage(SID_SB_DBREGISTEROPTIONS); + return VclPtr<CuiAbstractControllerAsync_Impl>::Create(std::move(xDlg)); + } + case SID_OPTIONS_TREEDIALOG : case SID_LANGUAGE_OPTIONS : { bool bActivateLastSelection = false; if (nResId == SID_OPTIONS_TREEDIALOG) bActivateLastSelection = true; Reference< frame::XFrame > xFrame; - xDlg = std::make_unique<OfaTreeOptionsDialog>(pParent, xFrame, bActivateLastSelection); - if (nResId == SID_OPTIONS_DATABASES) - { - xDlg->ActivatePage(SID_SB_DBREGISTEROPTIONS); - } - else if (nResId == SID_LANGUAGE_OPTIONS) + auto xDlg = std::make_unique<OfaTreeOptionsDialog>(pParent, xFrame, bActivateLastSelection); + if (nResId == SID_LANGUAGE_OPTIONS) { //open the tab page "tools/options/languages" xDlg->ActivatePage(OFA_TP_LANGUAGES_FOR_SET_DOCUMENT_LANGUAGE); } + return VclPtr<CuiAbstractController_Impl>::Create(std::move(xDlg)); } break; + default: - break; + assert(false); + return nullptr; } - - if (xDlg) - return VclPtr<CuiAbstractController_Impl>::Create(std::move(xDlg)); - return nullptr; } VclPtr<VclAbstractDialog> AbstractDialogFactory_Impl::CreateFrameDialog(weld::Window* pParent, const Reference< frame::XFrame >& rxFrame, - sal_uInt32 nResId, const OUString& rParameter ) + sal_uInt32 nResId, sal_uInt16 nPageId, const OUString& rParameter) { std::unique_ptr<OfaTreeOptionsDialog> xDlg; if (SID_OPTIONS_TREEDIALOG == nResId || SID_OPTIONS_DATABASES == nResId) { // only activate last page if we don't want to activate a special page - bool bActivateLastSelection = ( nResId != SID_OPTIONS_DATABASES && rParameter.isEmpty() ); + bool bActivateLastSelection = ( nResId != SID_OPTIONS_DATABASES && rParameter.isEmpty() && !nPageId); xDlg = std::make_unique<OfaTreeOptionsDialog>(pParent, rxFrame, bActivateLastSelection); if ( nResId == SID_OPTIONS_DATABASES ) xDlg->ActivatePage(SID_SB_DBREGISTEROPTIONS); + else if (nPageId) + xDlg->ActivatePage(nPageId); else if ( !rParameter.isEmpty() ) xDlg->ActivatePage( rParameter ); } @@ -847,6 +876,16 @@ VclPtr<VclAbstractDialog> AbstractDialogFactory_Impl::CreateFrameDialog(weld::Wi return nullptr; } +VclPtr<AbstractSecurityOptionsDialog> AbstractDialogFactory_Impl::CreateSvxSecurityOptionsDialog(weld::Window* pParent) +{ + return VclPtr<AbstractSecurityOptionsDialog_Impl>::Create(std::make_unique<svx::SecurityOptionsDialog>(pParent)); +} + +bool AbstractSecurityOptionsDialog_Impl::SetSecurityOptions() +{ + return m_xDlg->SetSecurityOptions(); +} + // TabDialog outside the drawing layer VclPtr<SfxAbstractTabDialog> AbstractDialogFactory_Impl::CreateAutoCorrTabDialog(weld::Window* pParent, const SfxItemSet* pAttrSet) { @@ -895,7 +934,16 @@ VclPtr<AbstractHyphenWordDialog> AbstractDialogFactory_Impl::CreateHyphenWordDia css::uno::Reference< css::linguistic2::XHyphenator > &xHyphen, SvxSpellWrapper* pWrapper) { +#if !ENABLE_WASM_STRIP_EXTRA return VclPtr<AbstractHyphenWordDialog_Impl>::Create(std::make_unique<SvxHyphenWordDialog>(rWord, nLang, pParent, xHyphen, pWrapper)); +#else + (void) pParent; + (void) rWord; + (void) nLang; + (void) xHyphen; + (void) pWrapper; + return nullptr; +#endif } VclPtr<AbstractFmShowColsDialog> AbstractDialogFactory_Impl::CreateFmShowColsDialog(weld::Window* pParent) @@ -1057,9 +1105,9 @@ VclPtr<VclAbstractDialog> AbstractDialogFactory_Impl::CreateSvxEditDictionaryDia } VclPtr<AbstractSvxNameDialog> AbstractDialogFactory_Impl::CreateSvxNameDialog(weld::Window* pParent, - const OUString& rName, const OUString& rDesc) + const OUString& rName, const OUString& rDesc, const OUString& rTitle) { - return VclPtr<AbstractSvxNameDialog_Impl>::Create(std::make_unique<SvxNameDialog>(pParent, rName, rDesc)); + return VclPtr<AbstractSvxNameDialog_Impl>::Create(std::make_unique<SvxNameDialog>(pParent, rName, rDesc, rTitle)); } VclPtr<AbstractSvxObjectNameDialog> AbstractDialogFactory_Impl::CreateSvxObjectNameDialog(weld::Window* pParent, const OUString& rName) @@ -1067,9 +1115,9 @@ VclPtr<AbstractSvxObjectNameDialog> AbstractDialogFactory_Impl::CreateSvxObjectN return VclPtr<AbstractSvxObjectNameDialog_Impl>::Create(std::make_unique<SvxObjectNameDialog>(pParent, rName)); } -VclPtr<AbstractSvxObjectTitleDescDialog> AbstractDialogFactory_Impl::CreateSvxObjectTitleDescDialog(weld::Window* pParent, const OUString& rTitle, const OUString& rDescription) +VclPtr<AbstractSvxObjectTitleDescDialog> AbstractDialogFactory_Impl::CreateSvxObjectTitleDescDialog(weld::Window* pParent, const OUString& rTitle, const OUString& rDescription, bool const isDecorative) { - return VclPtr<AbstractSvxObjectTitleDescDialog_Impl>::Create(std::make_unique<SvxObjectTitleDescDialog>(pParent, rTitle, rDescription)); + return VclPtr<AbstractSvxObjectTitleDescDialog_Impl>::Create(std::make_unique<SvxObjectTitleDescDialog>(pParent, rTitle, rDescription, isDecorative)); } VclPtr<AbstractSvxMultiPathDialog> AbstractDialogFactory_Impl::CreateSvxMultiPathDialog(weld::Window* pParent) @@ -1137,9 +1185,11 @@ VclPtr<AbstractGraphicFilterDialog> AbstractDialogFactory_Impl::CreateGraphicFil VclPtr<AbstractSvxAreaTabDialog> AbstractDialogFactory_Impl::CreateSvxAreaTabDialog(weld::Window* pParent, const SfxItemSet* pAttr, SdrModel* pModel, - bool bShadow) + bool bShadow, + bool bSlideBackground) { - return VclPtr<AbstractSvxAreaTabDialog_Impl>::Create(std::make_shared<SvxAreaTabDialog>(pParent, pAttr, pModel, bShadow)); + return VclPtr<AbstractSvxAreaTabDialog_Impl>::Create( + std::make_shared<SvxAreaTabDialog>(pParent, pAttr, pModel, bShadow, bSlideBackground)); } VclPtr<SfxAbstractTabDialog> AbstractDialogFactory_Impl::CreateSvxLineTabDialog(weld::Window* pParent, const SfxItemSet* pAttr, //add forSvxLineTabDialog @@ -1198,17 +1248,18 @@ public: :m_aItems( SfxGetpApp()->GetPool(), svl::Items<SID_ATTR_MACROITEM, SID_ATTR_MACROITEM> ) { m_aItems.Put( SfxBoolItem( SID_ATTR_MACROITEM, _bUnoDialogMode ) ); - m_xDlg.reset(new SvxMacroAssignDlg(_pParent, _rxDocumentFrame, m_aItems, _rxEvents, _nInitiallySelectedEvent)); + m_xDlg = std::make_shared<SvxMacroAssignDlg>(_pParent, _rxDocumentFrame, m_aItems, _rxEvents, _nInitiallySelectedEvent); } virtual short Execute() override; + virtual bool StartExecuteAsync(VclAbstractDialog::AsyncContext &rCtx) override; private: SfxItemSet m_aItems; - std::unique_ptr<SvxMacroAssignDlg> m_xDlg; + std::shared_ptr<SvxMacroAssignDlg> m_xDlg; }; -IMPL_ABSTDLG_CLASS(SvxMacroAssignDialog) +IMPL_ABSTDLG_CLASS_ASYNC(SvxMacroAssignDialog, SvxMacroAssignDlg) } @@ -1372,7 +1423,7 @@ VclPtr<SfxAbstractInsertObjectDialog> AbstractDialogFactory_Impl::CreateInsertOb if ( pDlg ) { - pDlg->SetHelpId( OUStringToOString( rCommand, RTL_TEXTENCODING_UTF8 ) ); + pDlg->SetHelpId(rCommand); return VclPtr<AbstractInsertObjectDialog_Impl>::Create( std::move(pDlg) ); } return nullptr; @@ -1384,7 +1435,7 @@ VclPtr<VclAbstractDialog> AbstractDialogFactory_Impl::CreateEditObjectDialog(wel if ( rCommand == ".uno:InsertObjectFloatingFrame" ) { auto pDlg = std::make_unique<SfxInsertFloatingFrameDialog>(pParent, xObj); - pDlg->SetHelpId( OUStringToOString( rCommand, RTL_TEXTENCODING_UTF8 ) ); + pDlg->SetHelpId(rCommand); return VclPtr<AbstractInsertObjectDialog_Impl>::Create( std::move(pDlg) ); } return nullptr; @@ -1403,9 +1454,9 @@ VclPtr<SfxAbstractLinksDialog> AbstractDialogFactory_Impl::CreateLinksDialog(wel return VclPtr<AbstractLinksDialog_Impl>::Create(std::move(xLinkDlg)); } -VclPtr<SfxAbstractTabDialog> AbstractDialogFactory_Impl::CreateSvxFormatCellsDialog(weld::Window* pParent, const SfxItemSet* pAttr, const SdrModel& rModel) +VclPtr<SfxAbstractTabDialog> AbstractDialogFactory_Impl::CreateSvxFormatCellsDialog(weld::Window* pParent, const SfxItemSet& rAttr, const SdrModel& rModel, bool bStyle) { - return VclPtr<CuiAbstractTabController_Impl>::Create(std::make_shared<SvxFormatCellsDialog>(pParent, pAttr, rModel)); + return VclPtr<CuiAbstractTabController_Impl>::Create(std::make_shared<SvxFormatCellsDialog>(pParent, rAttr, rModel, bStyle)); } VclPtr<SvxAbstractSplitTableDialog> AbstractDialogFactory_Impl::CreateSvxSplitTableDialog(weld::Window* pParent, bool bIsTableVertical, tools::Long nMaxVertical) @@ -1423,9 +1474,9 @@ VclPtr<VclAbstractDialog> AbstractDialogFactory_Impl::CreateOptionsDialog(weld:: return VclPtr<CuiAbstractController_Impl>::Create(std::make_unique<OfaTreeOptionsDialog>(pParent, rExtensionId)); } -VclPtr<SvxAbstractInsRowColDlg> AbstractDialogFactory_Impl::CreateSvxInsRowColDlg(weld::Window* pParent, bool bCol, const OString& rHelpId) +VclPtr<SvxAbstractInsRowColDlg> AbstractDialogFactory_Impl::CreateSvxInsRowColDlg(weld::Window* pParent, bool bCol, const OUString& rHelpId) { - return VclPtr<SvxInsRowColDlg>::Create(pParent, bCol, rHelpId); + return VclPtr<SvxAbstractInsRowColDlg_Impl>::Create(std::make_shared<SvxInsRowColDlg>(pParent, bCol, rHelpId)); } VclPtr<AbstractPasswordToOpenModifyDialog> AbstractDialogFactory_Impl::CreatePasswordToOpenModifyDialog( @@ -1458,7 +1509,7 @@ VclPtr<AbstractQrCodeGenDialog> AbstractDialogFactory_Impl::CreateQrCodeGenDialo weld::Window* pParent, const Reference<XModel> xModel, bool bEditExisting) { return VclPtr<AbstractQrCodeGenDialog_Impl>::Create( - std::make_unique<QrCodeGenDialog>(pParent, xModel, bEditExisting)); + std::make_shared<QrCodeGenDialog>(pParent, xModel, bEditExisting)); } VclPtr<AbstractAdditionsDialog> AbstractDialogFactory_Impl::CreateAdditionsDialog( @@ -1470,7 +1521,7 @@ VclPtr<AbstractAdditionsDialog> AbstractDialogFactory_Impl::CreateAdditionsDialo #else (void) pParent; (void) sAdditionsTag; - return VclPtr<AbstractAdditionsDialog>(nullptr); + return nullptr; #endif } @@ -1482,10 +1533,35 @@ AbstractDialogFactory_Impl::CreateAboutDialog(weld::Window* pParent) } VclPtr<VclAbstractDialog> +AbstractDialogFactory_Impl::CreateWhatsNewDialog(weld::Window* pParent, const bool bWelcome) +{ +#if !ENABLE_WASM_STRIP_PINGUSER + return VclPtr<CuiAbstractControllerAsync_Impl>::Create( + std::make_shared<WhatsNewDialog>(pParent, bWelcome)); +#else + (void) pParent; + (void) bWelcome; + return nullptr; +#endif +} + +VclPtr<VclAbstractDialog> AbstractDialogFactory_Impl::CreateTipOfTheDayDialog(weld::Window* pParent) { +#if !ENABLE_WASM_STRIP_PINGUSER return VclPtr<CuiAbstractControllerAsync_Impl>::Create( std::make_shared<TipOfTheDayDialog>(pParent)); +#else + (void) pParent; + return nullptr; +#endif +} + +VclPtr<VclAbstractDialog> +AbstractDialogFactory_Impl::CreateWidgetTestDialog(weld::Window* pParent) +{ + return VclPtr<CuiAbstractWidgetTestControllerAsync_Impl>::Create( + std::make_shared<WidgetTestDialog>(pParent)); } VclPtr<VclAbstractDialog> @@ -1496,10 +1572,12 @@ AbstractDialogFactory_Impl::CreateToolbarmodeDialog(weld::Window* pParent) } VclPtr<AbstractDiagramDialog> -AbstractDialogFactory_Impl::CreateDiagramDialog(weld::Window* pParent, std::shared_ptr<DiagramDataInterface> pDiagramData) +AbstractDialogFactory_Impl::CreateDiagramDialog( + weld::Window* pParent, + SdrObjGroup& rDiagram) { return VclPtr<AbstractDiagramDialog_Impl>::Create( - std::make_unique<DiagramDialog>(pParent, pDiagramData)); + std::make_unique<DiagramDialog>(pParent, rDiagram)); } #ifdef _WIN32 diff --git a/cui/source/factory/dlgfact.hxx b/cui/source/factory/dlgfact.hxx index 5a07bf8e95fb..6b4a548fe3fc 100644 --- a/cui/source/factory/dlgfact.hxx +++ b/cui/source/factory/dlgfact.hxx @@ -26,7 +26,8 @@ #include <com/sun/star/frame/XFrame.hpp> #include <cfgutil.hxx> -#include <cui/cuicharmap.hxx> +#include <svx/cuicharmap.hxx> +#include <dlgname.hxx> #include <cuifmsearch.hxx> #include <cuigaldlg.hxx> #include <cuigrfflt.hxx> @@ -35,7 +36,6 @@ #include <cuisrchdlg.hxx> #include <cuitabarea.hxx> #include <cuitbxform.hxx> -#include <dlgname.hxx> #include <DiagramDialog.hxx> #include <hangulhanjadlg.hxx> #include <hyphen.hxx> @@ -49,6 +49,7 @@ #include <postdlg.hxx> #include <QrCodeGenDialog.hxx> #include <screenshotannotationdlg.hxx> +#include <securityoptions.hxx> #include <showcols.hxx> #include <SignatureLineDialog.hxx> #include <SignSignatureLineDialog.hxx> @@ -109,8 +110,12 @@ DECL_ABSTDLG_CLASS_UNIQUE(CuiAbstractController, VclAbstractDialog, weld::Dialog DECL_ABSTDLG_CLASS_SHARED_ASYNC(CuiAbstractControllerAsync, VclAbstractDialog, weld::DialogController) }; +// CuiAbstractWidgetTestControllerAsync_Impl +DECL_ABSTDLG_CLASS_SHARED_ASYNC(CuiAbstractWidgetTestControllerAsync, VclAbstractDialog, weld::GenericDialogController) +}; + // CuiAbstractSingleTabController_Impl -DECL_ABSTDLG_CLASS_UNIQUE(CuiAbstractSingleTabController, SfxAbstractDialog, SfxSingleTabDialogController) +DECL_ABSTDLG_CLASS_SHARED_ASYNC(CuiAbstractSingleTabController, SfxAbstractDialog, SfxSingleTabDialogController) virtual const SfxItemSet* GetOutputItemSet() const override; //From class Window. virtual void SetText( const OUString& rStr ) override; @@ -118,17 +123,17 @@ DECL_ABSTDLG_CLASS_UNIQUE(CuiAbstractSingleTabController, SfxAbstractDialog, Sfx // CuiAbstractTabController_Impl DECL_ABSTDLG_CLASS_SHARED_ASYNC(CuiAbstractTabController, SfxAbstractTabDialog, SfxTabDialogController) - virtual void SetCurPageId( const OString &rName ) override; + virtual void SetCurPageId( const OUString &rName ) override; virtual const SfxItemSet* GetOutputItemSet() const override; virtual WhichRangesContainer GetInputRanges( const SfxItemPool& pItem ) override; virtual void SetInputSet( const SfxItemSet* pInSet ) override; virtual void SetText( const OUString& rStr ) override; // screenshotting - virtual std::vector<OString> getAllPageUIXMLDescriptions() const override; - virtual bool selectPageByUIXMLDescription(const OString& rUIXMLDescription) override; + virtual std::vector<OUString> getAllPageUIXMLDescriptions() const override; + virtual bool selectPageByUIXMLDescription(const OUString& rUIXMLDescription) override; virtual BitmapEx createScreenshot() const override; - virtual OString GetScreenshotId() const override; + virtual OUString GetScreenshotId() const override; }; // AbstractHangulHanjaConversionDialog_Impl @@ -216,7 +221,7 @@ DECL_ABSTDLG_CLASS(AbstractURLDlg, URLDlg) }; // AbstractSvxSearchSimilarityDialog_Impl -DECL_ABSTDLG_CLASS(AbstractSvxSearchSimilarityDialog,SvxSearchSimilarityDialog) +DECL_ABSTDLG_CLASS_ASYNC(AbstractSvxSearchSimilarityDialog,SvxSearchSimilarityDialog) virtual sal_uInt16 GetOther() override; virtual sal_uInt16 GetShorter() override; virtual sal_uInt16 GetLonger() override; @@ -231,7 +236,7 @@ DECL_ABSTDLG_CLASS(AbstractSvxJSearchOptionsDialog,SvxJSearchOptionsDialog) // AbstractSvxTransformTabDialog_Impl DECL_ABSTDLG_CLASS_ASYNC(AbstractSvxTransformTabDialog,SvxTransformTabDialog) virtual void SetValidateFramePosLink( const Link<SvxSwFrameValidation&,void>& rLink ) override; - virtual void SetCurPageId( const OString& rName ) override; + virtual void SetCurPageId( const OUString& rName ) override; virtual const SfxItemSet* GetOutputItemSet() const override; virtual WhichRangesContainer GetInputRanges( const SfxItemPool& pItem ) override; virtual void SetInputSet( const SfxItemSet* pInSet ) override; @@ -241,7 +246,7 @@ DECL_ABSTDLG_CLASS_ASYNC(AbstractSvxTransformTabDialog,SvxTransformTabDialog) // AbstractSvxCaptionDialog_Impl DECL_ABSTDLG_CLASS_ASYNC(AbstractSvxCaptionDialog,SvxCaptionTabDialog) virtual void SetValidateFramePosLink( const Link<SvxSwFrameValidation&,void>& rLink ) override; - virtual void SetCurPageId( const OString& rName ) override; + virtual void SetCurPageId( const OUString& rName ) override; virtual const SfxItemSet* GetOutputItemSet() const override; virtual WhichRangesContainer GetInputRanges( const SfxItemPool& pItem ) override; virtual void SetInputSet( const SfxItemSet* pInSet ) override; @@ -261,12 +266,12 @@ DECL_ABSTDLG_CLASS(AbstractSvxNewDictionaryDialog,SvxNewDictionaryDialog) // AbstractSvxNameDialog_Impl DECL_ABSTDLG_CLASS(AbstractSvxNameDialog,SvxNameDialog) - virtual void GetName( OUString& rName ) override ; - virtual void SetCheckNameHdl( const Link<AbstractSvxNameDialog&,bool>& rLink, bool bCheckImmediately = false ) override ; + virtual OUString GetName() override; + virtual void SetCheckNameHdl( const Link<AbstractSvxNameDialog&,bool>& rLink ) override ; virtual void SetCheckNameTooltipHdl( const Link<AbstractSvxNameDialog&, OUString>& rLink ) override ; - virtual void SetEditHelpId(const OString&) override ; + virtual void SetEditHelpId(const OUString&) override ; //from class Window - virtual void SetHelpId( const OString& ) override ; + virtual void SetHelpId( const OUString& ) override ; virtual void SetText( const OUString& rStr ) override ; private: @@ -280,8 +285,8 @@ class SvxObjectNameDialog; class SvxObjectTitleDescDialog; // AbstractSvxObjectNameDialog_Impl -DECL_ABSTDLG_CLASS(AbstractSvxObjectNameDialog,SvxObjectNameDialog) - virtual void GetName(OUString& rName) override ; +DECL_ABSTDLG_CLASS_ASYNC(AbstractSvxObjectNameDialog,SvxObjectNameDialog) + virtual OUString GetName() override; virtual void SetCheckNameHdl(const Link<AbstractSvxObjectNameDialog&,bool>& rLink) override; private: @@ -290,9 +295,10 @@ private: }; // AbstractSvxObjectTitleDescDialog_Impl -DECL_ABSTDLG_CLASS(AbstractSvxObjectTitleDescDialog,SvxObjectTitleDescDialog) - virtual void GetTitle(OUString& rName) override; - virtual void GetDescription(OUString& rName) override; +DECL_ABSTDLG_CLASS_ASYNC(AbstractSvxObjectTitleDescDialog,SvxObjectTitleDescDialog) + virtual OUString GetTitle() override; + virtual OUString GetDescription() override; + virtual bool IsDecorative() override; }; // AbstractSvxMultiPathDialog_Impl @@ -324,13 +330,13 @@ DECL_ABSTDLG_CLASS(AbstractFmSearchDialog,FmSearchDialog) }; // AbstractGraphicFilterDialog_Impl -DECL_ABSTDLG_CLASS(AbstractGraphicFilterDialog,GraphicFilterDialog) +DECL_ABSTDLG_CLASS_ASYNC(AbstractGraphicFilterDialog,GraphicFilterDialog) virtual Graphic GetFilteredGraphic( const Graphic& rGraphic, double fScaleX, double fScaleY ) override; }; // AbstractSvxAreaTabDialog_Impl DECL_ABSTDLG_CLASS_ASYNC(AbstractSvxAreaTabDialog,SvxAreaTabDialog) - virtual void SetCurPageId(const OString& rName) override; + virtual void SetCurPageId(const OUString& rName) override; virtual const SfxItemSet* GetOutputItemSet() const override; virtual WhichRangesContainer GetInputRanges( const SfxItemPool& pItem ) override; virtual void SetInputSet(const SfxItemSet* pInSet) override; @@ -355,7 +361,7 @@ DECL_ABSTDLG_CLASS_SHARED_ASYNC(AbstractPasteDialog,SfxAbstractPasteDialog,SvPas }; // AbstractLinksDialog_Impl -DECL_ABSTDLG_CLASS_UNIQUE(AbstractLinksDialog,SfxAbstractLinksDialog,SvBaseLinksDlg) +DECL_ABSTDLG_CLASS_SHARED_ASYNC(AbstractLinksDialog,SfxAbstractLinksDialog,SvBaseLinksDlg) }; // AbstractSvxPostItDialog_Impl @@ -379,14 +385,16 @@ private: }; // AbstractPasswordToOpenModifyDialog_Impl -DECL_ABSTDLG_CLASS(AbstractPasswordToOpenModifyDialog,PasswordToOpenModifyDialog) +DECL_ABSTDLG_CLASS_SHARED_ASYNC(AbstractPasswordToOpenModifyDialog,AbstractPasswordToOpenModifyDialog, PasswordToOpenModifyDialog) virtual OUString GetPasswordToOpen() const override; virtual OUString GetPasswordToModify() const override; virtual bool IsRecommendToOpenReadonly() const override; + virtual void Response(sal_Int32) override; + virtual void AllowEmpty() override; }; // AbstractSvxCharacterMapDialog_Impl -DECL_ABSTDLG_CLASS_UNIQUE(AbstractSvxCharacterMapDialog,SfxAbstractDialog,SvxCharacterMap) +DECL_ABSTDLG_CLASS_SHARED_ASYNC(AbstractSvxCharacterMapDialog,SfxAbstractDialog,SvxCharacterMap) virtual const SfxItemSet* GetOutputItemSet() const override; virtual void SetText(const OUString& rStr) override; }; @@ -395,24 +403,31 @@ DECL_ABSTDLG_CLASS_UNIQUE(AbstractSvxCharacterMapDialog,SfxAbstractDialog,SvxCha DECL_ABSTDLG_CLASS(AbstractScreenshotAnnotationDlg,ScreenshotAnnotationDlg) }; +// AbstractSecurityOptionsDialog_Impl +DECL_ABSTDLG_CLASS(AbstractSecurityOptionsDialog, svx::SecurityOptionsDialog) + virtual bool SetSecurityOptions() override; +}; + // AbstractSignatureLineDialog_Impl -DECL_ABSTDLG_CLASS(AbstractSignatureLineDialog,SignatureLineDialog) +DECL_ABSTDLG_CLASS_ASYNC(AbstractSignatureLineDialog,SignatureLineDialog) + virtual void Apply() override { m_xDlg->Apply(); } }; // AbstractQrCodeGenDialog_Impl -DECL_ABSTDLG_CLASS(AbstractQrCodeGenDialog,QrCodeGenDialog) +DECL_ABSTDLG_CLASS_ASYNC(AbstractQrCodeGenDialog,QrCodeGenDialog) }; // AbstractSignSignatureLineDialog_Impl -DECL_ABSTDLG_CLASS(AbstractSignSignatureLineDialog,SignSignatureLineDialog) +DECL_ABSTDLG_CLASS_ASYNC(AbstractSignSignatureLineDialog,SignSignatureLineDialog) + virtual void Apply() override { m_xDlg->Apply(); } }; // AbstractAdditionsDialog_Impl -DECL_ABSTDLG_CLASS(AbstractAdditionsDialog,AdditionsDialog) +DECL_ABSTDLG_CLASS_ASYNC(AbstractAdditionsDialog,weld::GenericDialogController) }; // AbstractDiagramDialog_Impl -DECL_ABSTDLG_CLASS(AbstractDiagramDialog,DiagramDialog) +DECL_ABSTDLG_CLASS_ASYNC(AbstractDiagramDialog,DiagramDialog) }; //AbstractDialogFactory_Impl implementations @@ -432,8 +447,7 @@ public: const SfxItemSet& rAttr, const css::uno::Reference< css::frame::XFrame >& rFrame) override; virtual VclPtr<VclAbstractDialog> CreateFrameDialog(weld::Window* pParent, const css::uno::Reference< css::frame::XFrame >& rxFrame, - sal_uInt32 nResId, - const OUString& rParameter ) override; + sal_uInt32 nResId, sal_uInt16 nPageId, const OUString& rParameter) override; virtual VclPtr<SfxAbstractTabDialog> CreateAutoCorrTabDialog(weld::Window* pParent, const SfxItemSet* pAttrSet) override; virtual VclPtr<SfxAbstractTabDialog> CreateCustomizeTabDialog(weld::Window* pParent, const SfxItemSet* pAttrSet, @@ -514,10 +528,10 @@ public: virtual VclPtr<AbstractSvxNewDictionaryDialog> CreateSvxNewDictionaryDialog(weld::Window* pParent) override; virtual VclPtr<VclAbstractDialog> CreateSvxEditDictionaryDialog(weld::Window* pParent, const OUString& rName) override; virtual VclPtr<AbstractSvxNameDialog> CreateSvxNameDialog(weld::Window* pParent, - const OUString& rName, const OUString& rDesc) override; + const OUString& rName, const OUString& rDesc, const OUString& rTitle = "") override; // #i68101# virtual VclPtr<AbstractSvxObjectNameDialog> CreateSvxObjectNameDialog(weld::Window* pParent, const OUString& rName) override; - virtual VclPtr<AbstractSvxObjectTitleDescDialog> CreateSvxObjectTitleDescDialog(weld::Window* pParent, const OUString& rTitle, const OUString& rDescription) override; + virtual VclPtr<AbstractSvxObjectTitleDescDialog> CreateSvxObjectTitleDescDialog(weld::Window* pParent, const OUString& rTitle, const OUString& rDescription, bool isDecorative) override; virtual VclPtr<AbstractSvxMultiPathDialog> CreateSvxMultiPathDialog(weld::Window* pParent) override; virtual VclPtr<AbstractSvxMultiPathDialog> CreateSvxPathSelectDialog(weld::Window* pParent) override; virtual VclPtr<AbstractSvxHpLinkDlg> CreateSvxHpLinkDlg(SfxChildWindow* pChild, SfxBindings* pBindings, weld::Window* pParent) override; @@ -541,7 +555,8 @@ public: virtual VclPtr<AbstractSvxAreaTabDialog> CreateSvxAreaTabDialog(weld::Window* pParent, const SfxItemSet* pAttr, SdrModel* pModel, - bool bShadow) override; + bool bShadow, + bool bSlideBackground) override; virtual VclPtr<SfxAbstractTabDialog> CreateSvxLineTabDialog(weld::Window* pParent, const SfxItemSet* pAttr, SdrModel* pModel, const SdrObject* pObj, @@ -570,7 +585,7 @@ public: const sal_uInt16 _nInitiallySelectedEvent ) override; - virtual VclPtr<SfxAbstractTabDialog> CreateSvxFormatCellsDialog(weld::Window* pParent, const SfxItemSet* pAttr, const SdrModel& rModel) override; + virtual VclPtr<SfxAbstractTabDialog> CreateSvxFormatCellsDialog(weld::Window* pParent, const SfxItemSet& rAttr, const SdrModel& rModel, bool bStyle) override; virtual VclPtr<SvxAbstractSplitTableDialog> CreateSvxSplitTableDialog(weld::Window* pParent, bool bIsTableVertical, tools::Long nMaxVertical) override; @@ -579,12 +594,14 @@ public: virtual VclPtr<VclAbstractDialog> CreateOptionsDialog( weld::Window* pParent, const OUString& rExtensionId ) override; - virtual VclPtr<SvxAbstractInsRowColDlg> CreateSvxInsRowColDlg(weld::Window* pParent, bool bCol, const OString& rHelpId) override; + virtual VclPtr<SvxAbstractInsRowColDlg> CreateSvxInsRowColDlg(weld::Window* pParent, bool bCol, const OUString& rHelpId) override; virtual VclPtr<AbstractPasswordToOpenModifyDialog> CreatePasswordToOpenModifyDialog(weld::Window* pParent, sal_uInt16 nMaxPasswdLen, bool bIsPasswordToModify) override; virtual VclPtr<AbstractScreenshotAnnotationDlg> CreateScreenshotAnnotationDlg(weld::Dialog& rParentDialog) override; + virtual VclPtr<AbstractSecurityOptionsDialog> CreateSvxSecurityOptionsDialog(weld::Window* pParent) override; + virtual VclPtr<AbstractSignatureLineDialog> CreateSignatureLineDialog(weld::Window* pParent, const css::uno::Reference<css::frame::XModel> xModel, bool bEditExisting) override; @@ -602,13 +619,17 @@ public: virtual VclPtr<VclAbstractDialog> CreateAboutDialog(weld::Window* pParent) override; + virtual VclPtr<VclAbstractDialog> CreateWhatsNewDialog(weld::Window* pParent, const bool bWelcome) override; + virtual VclPtr<VclAbstractDialog> CreateTipOfTheDayDialog(weld::Window* pParent) override; + virtual VclPtr<VclAbstractDialog> CreateWidgetTestDialog(weld::Window* pParent) override; + virtual VclPtr<VclAbstractDialog> CreateToolbarmodeDialog(weld::Window* pParent) override; virtual VclPtr<AbstractDiagramDialog> CreateDiagramDialog( weld::Window* pParent, - std::shared_ptr<DiagramDataInterface> pDiagramData) override; + SdrObjGroup& rDiagram) override; #ifdef _WIN32 virtual VclPtr<VclAbstractDialog> CreateFileExtCheckDialog(weld::Window* pParent, diff --git a/cui/source/factory/init.cxx b/cui/source/factory/init.cxx index 87f3105a0875..6b363f9bf543 100644 --- a/cui/source/factory/init.cxx +++ b/cui/source/factory/init.cxx @@ -17,7 +17,7 @@ * the License at http://www.apache.org/licenses/LICENSE-2.0 . */ -#include <cui/cuicharmap.hxx> +#include <svx/cuicharmap.hxx> // hook to call special character dialog for edits // caution: needs C-Linkage since dynamically loaded via symbol name @@ -32,9 +32,8 @@ SAL_DLLPUBLIC_EXPORT bool GetSpecialCharsForEdit(weld::Widget* i_pParent, const if (aDlg.run() == RET_OK) { sal_UCS4 cChar = aDlg.GetChar(); - // using the new UCS4 constructor - OUString aOUStr( &cChar, 1 ); - o_rResult = aOUStr; + // using the UCS4 constructor + o_rResult = OUString(&cChar, 1); bRet = true; } return bRet; diff --git a/cui/source/inc/AdditionsDialog.hxx b/cui/source/inc/AdditionsDialog.hxx index 0e7620b38268..559a4ca911ff 100644 --- a/cui/source/inc/AdditionsDialog.hxx +++ b/cui/source/inc/AdditionsDialog.hxx @@ -58,7 +58,7 @@ class AdditionsDialog : public weld::GenericDialogController private: Timer m_aSearchDataTimer; - DECL_LINK(GearHdl, const OString&, void); + DECL_LINK(GearHdl, const OUString&, void); DECL_LINK(SearchUpdateHdl, weld::Entry&, void); DECL_LINK(ImplUpdateDataHdl, Timer*, void); DECL_LINK(FocusOut_Impl, weld::Widget&, void); @@ -68,7 +68,6 @@ public: css::uno::Reference<css::deployment::XExtensionManager> m_xExtensionManager; std::unique_ptr<weld::Entry> m_xEntrySearch; std::unique_ptr<weld::Button> m_xButtonClose; - std::unique_ptr<weld::MenuButton> m_xMenuButtonSettings; std::vector<std::shared_ptr<AdditionsItem>> m_aAdditionsItems; // UI components std::vector<AdditionInfo> m_aAllExtensionsVector; // Stores the all extensions' info @@ -117,19 +116,15 @@ public: std::unique_ptr<weld::LinkButton> m_xLinkButtonWebsite; std::unique_ptr<weld::Label> m_xLabelName; std::unique_ptr<weld::Label> m_xLabelAuthor; - std::unique_ptr<weld::Label> m_xLabelDesc; std::unique_ptr<weld::Label> m_xLabelDescription; std::unique_ptr<weld::Label> m_xLabelLicense; std::unique_ptr<weld::Label> m_xLabelVersion; - std::unique_ptr<weld::Label> m_xLabelComments; std::unique_ptr<weld::LinkButton> m_xLinkButtonComments; std::unique_ptr<weld::Image> m_xImageVoting1; std::unique_ptr<weld::Image> m_xImageVoting2; std::unique_ptr<weld::Image> m_xImageVoting3; std::unique_ptr<weld::Image> m_xImageVoting4; std::unique_ptr<weld::Image> m_xImageVoting5; - std::unique_ptr<weld::Label> m_xLabelNoVoting; - std::unique_ptr<weld::Image> m_xImageDownloadNumber; std::unique_ptr<weld::Label> m_xLabelDownloadNumber; std::unique_ptr<weld::Button> m_xButtonShowMore; AdditionsDialog* m_pParentDialog; @@ -143,6 +138,7 @@ private: AdditionsDialog* m_pAdditionsDialog; std::atomic<bool> m_bExecute; bool m_bIsFirstLoading; + bool m_bUITest; void Search(); void Append(AdditionInfo& additionInfo); diff --git a/cui/source/inc/CustomNotebookbarGenerator.hxx b/cui/source/inc/CustomNotebookbarGenerator.hxx index b06848dbb955..a7149879aef0 100644 --- a/cui/source/inc/CustomNotebookbarGenerator.hxx +++ b/cui/source/inc/CustomNotebookbarGenerator.hxx @@ -35,8 +35,8 @@ public: static void getFileNameAndAppName(OUString& sAppName, OUString& sNotebookbarUIFileName); static void modifyCustomizedUIFile(const Sequence<OUString>& sUIItemProperties); static void createCustomizedUIFile(); - static void setCustomizedUIItem(Sequence<OUString> sUIItemProperties, - OUString sNotebookbarConfigType); + static void setCustomizedUIItem(const Sequence<OUString>& rUIItemProperties, + const OUString& rNotebookbarConfigType); }; /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/cui/source/inc/DiagramDialog.hxx b/cui/source/inc/DiagramDialog.hxx index adc8328969a8..a612e092a8e7 100644 --- a/cui/source/inc/DiagramDialog.hxx +++ b/cui/source/inc/DiagramDialog.hxx @@ -12,24 +12,26 @@ #include <tools/link.hxx> #include <vcl/weld.hxx> -class DiagramDataInterface; +class SdrObjGroup; /** Edit Diagram dialog */ class DiagramDialog : public weld::GenericDialogController { public: - DiagramDialog(weld::Window* pWindow, std::shared_ptr<DiagramDataInterface> pDiagramData); + DiagramDialog(weld::Window* pWindow, SdrObjGroup& rDiagram); virtual ~DiagramDialog() override; private: - std::shared_ptr<DiagramDataInterface> mpDiagramData; - std::unique_ptr<weld::Button> mpBtnOk; + SdrObjGroup& m_rDiagram; + sal_uInt32 m_nUndos; + std::unique_ptr<weld::Button> mpBtnCancel; std::unique_ptr<weld::Button> mpBtnAdd; std::unique_ptr<weld::Button> mpBtnRemove; std::unique_ptr<weld::TreeView> mpTreeDiagram; std::unique_ptr<weld::TextView> mpTextAdd; + DECL_LINK(OnAddCancel, weld::Button&, void); DECL_LINK(OnAddClick, weld::Button&, void); DECL_LINK(OnRemoveClick, weld::Button&, void); diff --git a/cui/source/inc/FontFeaturesDialog.hxx b/cui/source/inc/FontFeaturesDialog.hxx index aee4da9f3c72..93ba0cb9f80d 100644 --- a/cui/source/inc/FontFeaturesDialog.hxx +++ b/cui/source/inc/FontFeaturesDialog.hxx @@ -22,34 +22,45 @@ struct FontFeatureItem { FontFeatureItem(weld::Widget* pParent) : m_aFeatureCode(0) - , m_nDefault(0) + , m_nDefault(-1) , m_xBuilder(Application::CreateBuilder(pParent, "cui/ui/fontfragment.ui")) , m_xContainer(m_xBuilder->weld_widget("fontentry")) , m_xText(m_xBuilder->weld_label("label")) , m_xCombo(m_xBuilder->weld_combo_box("combo")) , m_xCheck(m_xBuilder->weld_check_button("check")) { + m_xCheck->connect_toggled(LINK(this, FontFeatureItem, CheckBoxToggledHdl)); } sal_uInt32 m_aFeatureCode; - sal_uInt32 m_nDefault; + sal_Int32 m_nDefault; + weld::TriStateEnabled m_aTriStateEnabled; + Link<weld::Toggleable&, void> m_aToggleHdl; std::unique_ptr<weld::Builder> m_xBuilder; std::unique_ptr<weld::Widget> m_xContainer; std::unique_ptr<weld::Label> m_xText; std::unique_ptr<weld::ComboBox> m_xCombo; std::unique_ptr<weld::CheckButton> m_xCheck; + +private: + DECL_LINK(CheckBoxToggledHdl, weld::Toggleable&, void); }; class FontFeaturesDialog : public weld::GenericDialogController { private: - std::vector<FontFeatureItem> m_aFeatureItems; + std::vector<std::unique_ptr<FontFeatureItem>> m_aFeatureItems; OUString m_sFontName; OUString m_sResultFontName; SvxFontPrevWindow m_aPreviewWindow; std::unique_ptr<weld::ScrolledWindow> m_xContentWindow; + std::unique_ptr<weld::Container> m_xContentBox; std::unique_ptr<weld::Container> m_xContentGrid; + std::unique_ptr<weld::Container> m_xStylisticSetsBox; + std::unique_ptr<weld::Container> m_xStylisticSetsGrid; + std::unique_ptr<weld::Container> m_xCharacterVariantsBox; + std::unique_ptr<weld::Container> m_xCharacterVariantsGrid; std::unique_ptr<weld::CustomWeld> m_xPreviewWindow; void initialize(); @@ -62,7 +73,7 @@ private: DECL_LINK(CheckBoxToggledHdl, weld::Toggleable&, void); public: - FontFeaturesDialog(weld::Window* pParent, OUString const& rFontName); + FontFeaturesDialog(weld::Window* pParent, OUString aFontName); ~FontFeaturesDialog() override; virtual short run() override; diff --git a/cui/source/inc/GraphicsTestsDialog.hxx b/cui/source/inc/GraphicsTestsDialog.hxx index 3f8a151f8080..2bf18de5dde7 100644 --- a/cui/source/inc/GraphicsTestsDialog.hxx +++ b/cui/source/inc/GraphicsTestsDialog.hxx @@ -8,13 +8,9 @@ */ #pragma once -#include <vcl/bitmapex.hxx> -#include <vcl/svapp.hxx> +#include <vcl/bitmap.hxx> #include <vcl/weld.hxx> #include <tools/link.hxx> -#include <svx/FileExportedDialog.hxx> - -#include "ImageViewerDialog.hxx" #include <vector> diff --git a/cui/source/inc/QrCodeGenDialog.hxx b/cui/source/inc/QrCodeGenDialog.hxx index 165bc6d75f4a..02037ad4cdf6 100644 --- a/cui/source/inc/QrCodeGenDialog.hxx +++ b/cui/source/inc/QrCodeGenDialog.hxx @@ -24,16 +24,21 @@ public: bool bEditExisting); virtual short run() override; + static bool runAsync(const std::shared_ptr<QrCodeGenDialog>& rController, + const std::function<void(sal_Int32)>& rFunc); -protected: - css::uno::Reference<css::frame::XModel> m_xModel; void Apply(); +#if ENABLE_ZXING + weld::Widget* GetParent() { return mpParent; } +#endif private: - std::unique_ptr<weld::Entry> m_xEdittext; + css::uno::Reference<css::frame::XModel> m_xModel; + std::unique_ptr<weld::TextView> m_xEdittext; std::unique_ptr<weld::RadioButton> m_xECC[4]; std::unique_ptr<weld::SpinButton> m_xSpinBorder; std::unique_ptr<weld::ComboBox> m_xComboType; + #if ENABLE_ZXING weld::Widget* mpParent; #endif diff --git a/cui/source/inc/SignSignatureLineDialog.hxx b/cui/source/inc/SignSignatureLineDialog.hxx index 5abe1969e32c..7c894a16a0b3 100644 --- a/cui/source/inc/SignSignatureLineDialog.hxx +++ b/cui/source/inc/SignSignatureLineDialog.hxx @@ -20,6 +20,8 @@ class SignSignatureLineDialog : public SignatureLineDialogBase public: SignSignatureLineDialog(weld::Widget* pParent, css::uno::Reference<css::frame::XModel> xModel); + void Apply(); + private: std::unique_ptr<weld::Entry> m_xEditName; std::unique_ptr<weld::TextView> m_xEditComment; @@ -42,7 +44,6 @@ private: void ValidateFields(); css::uno::Reference<css::graphic::XGraphic> getSignedGraphic(bool bValid); - virtual void Apply() override; DECL_LINK(clearImage, weld::Button&, void); DECL_LINK(loadImage, weld::Button&, void); diff --git a/cui/source/inc/SignatureLineDialog.hxx b/cui/source/inc/SignatureLineDialog.hxx index 73b093f601a5..e686cb4a4123 100644 --- a/cui/source/inc/SignatureLineDialog.hxx +++ b/cui/source/inc/SignatureLineDialog.hxx @@ -19,6 +19,8 @@ public: SignatureLineDialog(weld::Widget* pParent, css::uno::Reference<css::frame::XModel> xModel, bool bEditExisting); + void Apply(); + private: std::unique_ptr<weld::Entry> m_xEditName; std::unique_ptr<weld::Entry> m_xEditTitle; @@ -29,8 +31,6 @@ private: css::uno::Reference<css::beans::XPropertySet> m_xExistingShapeProperties; OUString m_aSignatureLineId; - - virtual void Apply() override; }; /* vim:set shiftwidth=4 softtabstop=4 expandtab cinoptions=b1,g0,N-s cinkeys+=0=break: */ diff --git a/cui/source/inc/SignatureLineDialogBase.hxx b/cui/source/inc/SignatureLineDialogBase.hxx index 3cc645819be8..4e0a3f298e5b 100644 --- a/cui/source/inc/SignatureLineDialogBase.hxx +++ b/cui/source/inc/SignatureLineDialogBase.hxx @@ -21,13 +21,12 @@ class SignatureLineDialogBase : public weld::GenericDialogController { public: SignatureLineDialogBase(weld::Widget* pParent, css::uno::Reference<css::frame::XModel> xModel, - const OUString& rUIFile, const OString& rDialogId); + const OUString& rUIFile, const OUString& rDialogId); virtual short run() override; protected: css::uno::Reference<css::frame::XModel> m_xModel; - virtual void Apply() = 0; static OUString getCDataString(std::u16string_view rString); }; diff --git a/cui/source/inc/SpellDialog.hxx b/cui/source/inc/SpellDialog.hxx index 69f491fc6586..81d68e214314 100644 --- a/cui/source/inc/SpellDialog.hxx +++ b/cui/source/inc/SpellDialog.hxx @@ -46,6 +46,7 @@ struct SpellErrorDescription; class SentenceEditWindow_Impl : public WeldEditView { private: + std::unique_ptr<weld::ScrolledWindow> m_xScrolledWindow; std::set<sal_Int32> m_aIgnoreErrorsAt; SpellDialog* m_pSpellDialog; weld::Toolbar* m_pToolbar; @@ -61,14 +62,21 @@ private: bool GetErrorDescription(SpellErrorDescription& rSpellErrorDescription, sal_Int32 nPosition); - DECL_LINK(ToolbarHdl, const OString&, void); + DECL_LINK(ScrollHdl, weld::ScrolledWindow&, void); + DECL_LINK(EditStatusHdl, EditStatus&, void); + DECL_LINK(ToolbarHdl, const OUString&, void); + + void DoScroll(); + void SetScrollBarRange(); protected: virtual bool KeyInput( const KeyEvent& rKEvt ) override; + virtual void StyleUpdated() override; public: - SentenceEditWindow_Impl(); + SentenceEditWindow_Impl(std::unique_ptr<weld::ScrolledWindow> xScrolledWindow); virtual void SetDrawingArea(weld::DrawingArea* pDrawingArea) override; + virtual void EditViewScrollStateChange() override; void SetSpellDialog(SpellDialog* pDialog) { m_pSpellDialog = pDialog; } virtual ~SentenceEditWindow_Impl() override; @@ -113,6 +121,8 @@ public: void MoveErrorEnd(tools::Long nOffset); void ResetIgnoreErrorsAt() { m_aIgnoreErrorsAt.clear(); } + + void SetDocumentColor(weld::DrawingArea* pDrawingArea); }; // class SvxSpellDialog --------------------------------------------- @@ -130,7 +140,7 @@ private: OUString m_sTitleSpellingGrammar; Link<SpellUndoAction_Impl&,void> aDialogUndoLink; - + ImplSVEvent * m_pInitHdlEvent; bool bFocusLocked; svx::SpellDialogChildWindow& rParent; @@ -143,7 +153,6 @@ private: std::unique_ptr<weld::Label> m_xAltTitle; std::unique_ptr<weld::Label> m_xResumeFT; std::unique_ptr<weld::Label> m_xNoSuggestionsFT; - std::unique_ptr<weld::Label> m_xIgnoreOnceFT; std::unique_ptr<weld::Label> m_xLanguageFT; std::unique_ptr<SvxLanguageBox> m_xLanguageLB; std::unique_ptr<weld::Label> m_xExplainFT; @@ -166,6 +175,7 @@ private: std::unique_ptr<weld::Button> m_xClosePB; std::unique_ptr<weld::Toolbar> m_xToolbar; std::unique_ptr<weld::CustomWeld> m_xSentenceEDWeld; + std::shared_ptr<SfxSingleTabDialogController> m_xOptionsDlg; DECL_LINK(ChangeHdl, weld::Button&, void); DECL_LINK(DoubleClickChangeHdl, weld::TreeView&, bool); @@ -177,14 +187,14 @@ private: DECL_LINK(CancelHdl, weld::Button&, void); DECL_LINK(ModifyHdl, LinkParamNone*, void); DECL_LINK(UndoHdl, weld::Button&, void); - DECL_LINK(AddToDictSelectHdl, const OString&, void); + DECL_LINK(AddToDictSelectHdl, const OUString&, void); DECL_LINK(AddToDictClickHdl, weld::Button&, void); DECL_LINK(LanguageSelectHdl, weld::ComboBox&, void); DECL_LINK(DialogUndoHdl, SpellUndoAction_Impl&, void); DECL_LINK(InitHdl, void*, void); - void AddToDictionaryExecute(const OString& rItemId); + void AddToDictionaryExecute(const OUString& rItemId); void StartSpellOptDlg_Impl(); int InitUserDicts(); void UpdateBoxes_Impl(bool bCallFromSelectHdl = false); diff --git a/cui/source/inc/SvxMenuConfigPage.hxx b/cui/source/inc/SvxMenuConfigPage.hxx index bc8fba3f5780..36fee041de76 100644 --- a/cui/source/inc/SvxMenuConfigPage.hxx +++ b/cui/source/inc/SvxMenuConfigPage.hxx @@ -33,15 +33,15 @@ private: DECL_LINK(ContentContextMenuHdl, const CommandEvent&, bool); DECL_LINK(FunctionContextMenuHdl, const CommandEvent&, bool); - DECL_LINK(GearHdl, const OString&, void); + DECL_LINK(GearHdl, const OUString&, void); DECL_LINK(SelectCategory, weld::ComboBox&, void); DECL_LINK(AddCommandHdl, weld::Button&, void); DECL_LINK(RemoveCommandHdl, weld::Button&, void); - DECL_LINK(InsertHdl, const OString&, void); - DECL_LINK(ModifyItemHdl, const OString&, void); + DECL_LINK(InsertHdl, const OUString&, void); + DECL_LINK(ModifyItemHdl, const OUString&, void); DECL_LINK(ResetMenuHdl, weld::Button&, void); DECL_LINK(MenuEntriesSizeAllocHdl, const Size&, void); diff --git a/cui/source/inc/SvxNotebookbarConfigPage.hxx b/cui/source/inc/SvxNotebookbarConfigPage.hxx index 7e417463ab30..672d2e8299e4 100644 --- a/cui/source/inc/SvxNotebookbarConfigPage.hxx +++ b/cui/source/inc/SvxNotebookbarConfigPage.hxx @@ -74,13 +74,19 @@ public: class SvxNotebookbarEntriesListBox final : public SvxMenuEntriesListBox { + typedef std::unordered_map<OUString, OUString> TooltipMap; + TooltipMap m_aTooltipMap; + void ChangedVisibility(int nRow); DECL_LINK(CheckButtonHdl, const weld::TreeView::iter_col&, void); DECL_LINK(KeyInputHdl, const KeyEvent&, bool); + DECL_LINK(QueryTooltip, const weld::TreeIter& rIter, OUString); public: SvxNotebookbarEntriesListBox(std::unique_ptr<weld::TreeView> xControl, SvxConfigPage* pPg); virtual ~SvxNotebookbarEntriesListBox() override; + + TooltipMap& GetTooltipMap() { return m_aTooltipMap; } }; /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/cui/source/inc/SvxToolbarConfigPage.hxx b/cui/source/inc/SvxToolbarConfigPage.hxx index e035d6b7ef31..28fe658f2cca 100644 --- a/cui/source/inc/SvxToolbarConfigPage.hxx +++ b/cui/source/inc/SvxToolbarConfigPage.hxx @@ -32,7 +32,7 @@ private: DECL_LINK(SelectToolbarEntry, weld::TreeView&, void); DECL_LINK(MoveHdl, weld::Button&, void); - DECL_LINK(GearHdl, const OString&, void); + DECL_LINK(GearHdl, const OUString&, void); DECL_LINK(SelectCategory, weld::ComboBox&, void); @@ -42,8 +42,8 @@ private: DECL_LINK(AddCommandHdl, weld::Button&, void); DECL_LINK(RemoveCommandHdl, weld::Button&, void); - DECL_LINK(InsertHdl, const OString&, void); - DECL_LINK(ModifyItemHdl, const OString&, void); + DECL_LINK(InsertHdl, const OUString&, void); + DECL_LINK(ModifyItemHdl, const OUString&, void); DECL_LINK(ResetToolbarHdl, weld::Button&, void); virtual void ListModified() override; diff --git a/cui/source/inc/about.hxx b/cui/source/inc/about.hxx index 2cfc65a894f4..42eae5467eab 100644 --- a/cui/source/inc/about.hxx +++ b/cui/source/inc/about.hxx @@ -46,7 +46,7 @@ private: static OUString GetMiscString(); static OUString GetCopyrightString(); - static bool IsStringValidGitHash(const OUString& hash); + static bool IsStringValidGitHash(std::u16string_view hash); DECL_LINK(HandleClick, weld::Button&, void); diff --git a/cui/source/inc/align.hxx b/cui/source/inc/align.hxx index 2be30aec6c71..caea33e42150 100644 --- a/cui/source/inc/align.hxx +++ b/cui/source/inc/align.hxx @@ -40,6 +40,8 @@ #include <svx/frmdirlbox.hxx> #include <vcl/weld.hxx> +class SfxEnumItemInterface; + namespace svx { @@ -62,7 +64,7 @@ private: void InitVsRefEgde(); void UpdateEnableControls(); - bool HasAlignmentChanged( const SfxItemSet& rNew, sal_uInt16 nWhich ) const; + bool HasAlignmentChanged( const SfxItemSet& rNew, TypedWhichId<SfxEnumItemInterface> nWhich ) const; DECL_LINK(UpdateEnableHdl, weld::ComboBox&, void); DECL_LINK(StackedClickHdl, weld::Toggleable&, void); @@ -92,7 +94,6 @@ private: std::unique_ptr<weld::CheckButton> m_xCbStacked; std::unique_ptr<weld::CheckButton> m_xCbAsianMode; - std::unique_ptr<weld::Widget> m_xBoxDirection; std::unique_ptr<weld::CheckButton> m_xBtnWrap; std::unique_ptr<weld::CheckButton> m_xBtnHyphen; std::unique_ptr<weld::CheckButton> m_xBtnShrink; diff --git a/cui/source/inc/autocdlg.hxx b/cui/source/inc/autocdlg.hxx index ca7d778830ea..2677b8535ebe 100644 --- a/cui/source/inc/autocdlg.hxx +++ b/cui/source/inc/autocdlg.hxx @@ -20,12 +20,13 @@ #include <sfx2/tabdlg.hxx> #include <svx/langbox.hxx> +#include <unotools/collatorwrapper.hxx> #include <map> #include <set> +#include <utility> class CharClass; -class CollatorWrapper; class SmartTagMgr; namespace editeng { class SortedAutoCompleteStrings; } @@ -56,6 +57,7 @@ private: OUString m_sStartCap; OUString m_sBoldUnderline; OUString m_sURL; + OUString m_sDOI; OUString m_sNoDblSpaces; OUString m_sDash; OUString m_sAccidentalCaps; @@ -91,9 +93,11 @@ class OfaSwAutoFmtOptionsPage : public SfxTabPage OUString sNoDblSpaces; OUString sCorrectCapsLock; OUString sDetectURL; + OUString sDetectDOI; OUString sDash; OUString sRightMargin; OUString sNum; + OUString sBulletsAfterSpace; OUString sBorder; OUString sTable; OUString sReplaceTemplates; @@ -135,9 +139,9 @@ struct DoubleString OUString sShort; OUString sLong; void* pUserData; ///< CheckBox -> form. Text Bool -> selection text - DoubleString(const OUString& rShort, const OUString& rLong) - : sShort(rShort) - , sLong(rLong) + DoubleString(OUString aShort, OUString aLong) + : sShort(std::move(aShort)) + , sLong(std::move(aLong)) , pUserData(nullptr) { } @@ -165,7 +169,7 @@ private: std::set<OUString> aFormatText; std::map<LanguageType, DoubleStringArray> aDoubleStringTable; - std::unique_ptr<CollatorWrapper> pCompareClass; + CollatorWrapper maCompareClass; std::unique_ptr<CharClass> pCharClass; LanguageType eLang; @@ -226,7 +230,7 @@ class OfaAutocorrExceptPage : public SfxTabPage { private: StringsTable aStringsTable; - std::unique_ptr<CollatorWrapper> pCompareClass; + CollatorWrapper maCompareClass; LanguageType eLang; std::unique_ptr<weld::Entry> m_xAbbrevED; diff --git a/cui/source/inc/backgrnd.hxx b/cui/source/inc/backgrnd.hxx index 450fbdaaa27f..3d50d69e95f4 100644 --- a/cui/source/inc/backgrnd.hxx +++ b/cui/source/inc/backgrnd.hxx @@ -37,23 +37,28 @@ class SvxBrushItem; class SvxBkgTabPage : public SvxAreaTabPage { - static const WhichRangesContainer pPageRanges; + static const WhichRangesContainer pBkgRanges; std::unique_ptr<weld::ComboBox> m_xTblLBox; - bool bHighlighting : 1; - bool bCharBackColor : 1; - SfxItemSet maSet; - std::unique_ptr<SfxItemSet> m_pResetSet; + bool m_bHighlighting = false; + bool m_bCharBackColor = false; + + // m_aAttrSet is used to convert between SvxBrushItem and XFILL item attributes and also to + // allow for cell, row, and table backgrounds to be set in one Table dialog opening. + SfxItemSet m_aAttrSet; sal_Int32 m_nActPos = -1; DECL_LINK(TblDestinationHdl_Impl, weld::ComboBox&, void); + + void SetActiveTableDestinationBrushItem(); + public: SvxBkgTabPage(weld::Container* pPage, weld::DialogController* pController, const SfxItemSet& rInAttrs); virtual ~SvxBkgTabPage() override; // returns the area of the which-values - static WhichRangesContainer GetRanges() { return pPageRanges; } + static WhichRangesContainer GetRanges() { return pBkgRanges; } static std::unique_ptr<SfxTabPage> Create( weld::Container* pPage, weld::DialogController* pController, const SfxItemSet* ); virtual bool FillItemSet( SfxItemSet* ) override; diff --git a/cui/source/inc/bbdlg.hxx b/cui/source/inc/bbdlg.hxx index 1c7a289723a6..c18b5b3da4e6 100644 --- a/cui/source/inc/bbdlg.hxx +++ b/cui/source/inc/bbdlg.hxx @@ -32,7 +32,7 @@ public: bool bEnableSelector, bool bEnableDrawingLayerFillStyles); protected: - virtual void PageCreated(const OString& rPageId, SfxTabPage& rTabPage) override; + virtual void PageCreated(const OUString& rPageId, SfxTabPage& rTabPage) override; private: bool mbEnableBackgroundSelector : 1; ///< for Border/Background diff --git a/cui/source/inc/border.hxx b/cui/source/inc/border.hxx index 2a3d14ed5062..accb555930dc 100644 --- a/cui/source/inc/border.hxx +++ b/cui/source/inc/border.hxx @@ -77,7 +77,6 @@ private: class SvxBorderTabPage : public SfxTabPage { static const WhichRangesContainer pRanges; - static const std::vector<int> m_aLineWidths; public: SvxBorderTabPage(weld::Container* pPage, weld::DialogController* pController, const SfxItemSet& rCoreAttrs); @@ -178,7 +177,7 @@ private: void FillPresetVS(); void FillShadowVS(); void FillValueSets(); - void SetLineWidth(sal_Int64 nWidth); + void SetLineWidth(sal_Int64 nWidth, sal_Int32 nRemovedType = 0); // Filler void FillLineListBox_Impl(); diff --git a/cui/source/inc/cfg.hxx b/cui/source/inc/cfg.hxx index 361e801d723c..1ae5b23a2999 100644 --- a/cui/source/inc/cfg.hxx +++ b/cui/source/inc/cfg.hxx @@ -40,23 +40,24 @@ #include "cfgutil.hxx" #include "CommandCategoryListBox.hxx" -inline constexpr OUStringLiteral notebookbarTabScope = u"notebookbarTabScope"; +inline constexpr OUString notebookbarTabScope = u"notebookbarTabScope"_ustr; -inline constexpr OUStringLiteral ITEM_DESCRIPTOR_COMMANDURL = u"CommandURL"; -inline constexpr OUStringLiteral ITEM_DESCRIPTOR_CONTAINER = u"ItemDescriptorContainer"; -inline constexpr OUStringLiteral ITEM_DESCRIPTOR_LABEL = u"Label"; -inline constexpr OUStringLiteral ITEM_DESCRIPTOR_TYPE = u"Type"; -inline constexpr OUStringLiteral ITEM_DESCRIPTOR_STYLE = u"Style"; -inline constexpr OUStringLiteral ITEM_DESCRIPTOR_ISVISIBLE = u"IsVisible"; -inline constexpr OUStringLiteral ITEM_DESCRIPTOR_RESOURCEURL = u"ResourceURL"; -inline constexpr OUStringLiteral ITEM_DESCRIPTOR_UINAME = u"UIName"; +inline constexpr OUString ITEM_DESCRIPTOR_COMMANDURL = u"CommandURL"_ustr; +inline constexpr OUString ITEM_DESCRIPTOR_CONTAINER = u"ItemDescriptorContainer"_ustr; +inline constexpr OUString ITEM_DESCRIPTOR_LABEL = u"Label"_ustr; +inline constexpr OUString ITEM_DESCRIPTOR_TYPE = u"Type"_ustr; +inline constexpr OUString ITEM_DESCRIPTOR_STYLE = u"Style"_ustr; +inline constexpr OUString ITEM_DESCRIPTOR_ISVISIBLE = u"IsVisible"_ustr; +inline constexpr OUString ITEM_DESCRIPTOR_RESOURCEURL = u"ResourceURL"_ustr; +inline constexpr OUString ITEM_DESCRIPTOR_UINAME = u"UIName"_ustr; -inline constexpr OUStringLiteral ITEM_MENUBAR_URL = u"private:resource/menubar/menubar"; -inline constexpr OUStringLiteral ITEM_TOOLBAR_URL = u"private:resource/toolbar/"; +inline constexpr OUString ITEM_MENUBAR_URL = u"private:resource/menubar/menubar"_ustr; +inline constexpr OUString ITEM_TOOLBAR_URL = u"private:resource/toolbar/"_ustr; +inline constexpr OUString ITEM_EVENT_URL = u"private:resource/event/"_ustr; -inline constexpr OUStringLiteral CUSTOM_TOOLBAR_STR = u"custom_toolbar_"; +inline constexpr OUString CUSTOM_TOOLBAR_STR = u"custom_toolbar_"_ustr; -inline constexpr OUStringLiteral aMenuSeparatorStr = u" | "; +inline constexpr OUString aMenuSeparatorStr = u" | "_ustr; class SvxConfigEntry; class SvxConfigPage; @@ -68,10 +69,12 @@ class SvxConfigDialog : public SfxTabDialogController private: css::uno::Reference< css::frame::XFrame > m_xFrame; + virtual void ActivatePage(const OUString& rPage) override; + public: SvxConfigDialog(weld::Window*, const SfxItemSet*); - virtual void PageCreated(const OString& rId, SfxTabPage &rPage) override; + virtual void PageCreated(const OUString& rId, SfxTabPage &rPage) override; void SetFrame(const css::uno::Reference< css::frame::XFrame >& xFrame); }; @@ -113,8 +116,8 @@ protected: public: SaveInData( - const css::uno::Reference < css::ui::XUIConfigurationManager >& xCfgMgr, - const css::uno::Reference < css::ui::XUIConfigurationManager >& xParentCfgMgr, + css::uno::Reference < css::ui::XUIConfigurationManager > xCfgMgr, + css::uno::Reference < css::ui::XUIConfigurationManager > xParentCfgMgr, const OUString& aModuleId, bool docConfig ); @@ -253,8 +256,8 @@ private: public: - SvxConfigEntry( const OUString& rDisplayName, - const OUString& rCommandURL, + SvxConfigEntry( OUString aDisplayName, + OUString aCommandURL, bool bPopup, bool bParentData ); @@ -348,6 +351,7 @@ public: } DECL_LINK(KeyInputHdl, const KeyEvent&, bool); + DECL_LINK(QueryTooltip, const weld::TreeIter& rIter, OUString); void CreateDropDown(); }; @@ -408,12 +412,14 @@ protected: std::unique_ptr<weld::ComboBox> m_xSaveInListBox; + std::unique_ptr<weld::Widget> m_xCustomizeBox; std::unique_ptr<weld::MenuButton> m_xInsertBtn; std::unique_ptr<weld::MenuButton> m_xModifyBtn; // Used to reset the selected toolbar/menu/context menu std::unique_ptr<weld::Button> m_xResetBtn; // Middle buttons + std::unique_ptr<weld::Widget> m_xCommandButtons; std::unique_ptr<weld::Button> m_xAddCommandButton; std::unique_ptr<weld::Button> m_xRemoveCommandButton; @@ -496,7 +502,7 @@ public: SvxConfigEntry* GetTopLevelSelection() { - return reinterpret_cast<SvxConfigEntry*>(m_xTopLevelListBox->get_active_id().toInt64()); + return weld::fromId<SvxConfigEntry*>(m_xTopLevelListBox->get_active_id()); } /** identifies the module in the given frame. If the frame is <NULL/>, a default @@ -599,7 +605,6 @@ class SvxNewToolbarDialog : public weld::GenericDialogController { private: std::unique_ptr<weld::Entry> m_xEdtName; - std::unique_ptr<weld::Button> m_xBtnOK; public: std::unique_ptr<weld::ComboBox> m_xSaveInListBox; @@ -647,8 +652,8 @@ public: SvxIconSelectorDialog( weld::Window *pWindow, - const css::uno::Reference< css::ui::XImageManager >& rXImageManager, - const css::uno::Reference< css::ui::XImageManager >& rXParentImageManager); + css::uno::Reference< css::ui::XImageManager > xImageManager, + css::uno::Reference< css::ui::XImageManager > xParentImageManager); virtual ~SvxIconSelectorDialog() override; diff --git a/cui/source/inc/cfgutil.hxx b/cui/source/inc/cfgutil.hxx index 8040b90afa8f..b1f22e4065b9 100644 --- a/cui/source/inc/cfgutil.hxx +++ b/cui/source/inc/cfgutil.hxx @@ -204,7 +204,7 @@ class CuiConfigGroupListBox css::uno::Reference< css::uno::XComponentContext > const & xCtx, std::u16string_view docName); - void InitModule(); + sal_Int32 InitModule(); void FillScriptList(const css::uno::Reference< css::script::browse::XBrowseNode >& xRootNode, const weld::TreeIter* pParentEntry); void FillFunctionsList(const css::uno::Sequence< css::frame::DispatchInformation >& xCommands); @@ -230,7 +230,6 @@ public: void GroupSelected(); #if HAVE_FEATURE_SCRIPTING void SelectMacro(const SfxMacroInfoItem*); - void SelectMacro(std::u16string_view, const OUString&); #endif void SetStylesInfo(SfxStylesInfo_Impl* pStyles); }; @@ -264,6 +263,8 @@ public: OUString GetScriptURL() const; void SetRunLabel(); + void SaveLastUsedMacro(); + void LoadLastUsedMacro(); }; /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/cui/source/inc/chardlg.hxx b/cui/source/inc/chardlg.hxx index be4db989b57d..b484c7419b83 100644 --- a/cui/source/inc/chardlg.hxx +++ b/cui/source/inc/chardlg.hxx @@ -39,7 +39,7 @@ protected: bool m_bPreviewBackgroundToCharacter; - SvxCharBasePage(weld::Container* pPage, weld::DialogController* pController, const OUString& rUIXMLDescription, const OString& rID, const SfxItemSet& rAttrSet); + SvxCharBasePage(weld::Container* pPage, weld::DialogController* pController, const OUString& rUIXMLDescription, const OUString& rID, const SfxItemSet& rAttrSet); void SetPrevFontWidthScale( const SfxItemSet& rSet ); void SetPrevFontEscapement( sal_uInt8 nProp, sal_uInt8 nEscProp, short nEsc ); @@ -65,7 +65,7 @@ private: std::unique_ptr<SvxCharNamePage_Impl> m_pImpl; - std::unique_ptr<weld::Widget> m_xWestFrame; + std::unique_ptr<weld::Notebook> m_xWestern; std::unique_ptr<weld::Label> m_xWestFontNameFT; std::unique_ptr<weld::ComboBox> m_xWestFontNameLB; std::unique_ptr<weld::Label> m_xWestFontStyleFT; @@ -74,10 +74,10 @@ private: std::unique_ptr<FontSizeBox> m_xWestFontSizeLB; std::unique_ptr<weld::Label> m_xWestFontLanguageFT; std::unique_ptr<SvxLanguageBox> m_xWestFontLanguageLB; - std::unique_ptr<weld::Label> m_xWestFontTypeFT; std::unique_ptr<weld::Button> m_xWestFontFeaturesButton; + std::unique_ptr<weld::Label> m_xWestFontTypeFT; - std::unique_ptr<weld::Widget> m_xEastFrame; + std::unique_ptr<weld::Notebook> m_xCJK_CTL; std::unique_ptr<weld::Label> m_xEastFontNameFT; std::unique_ptr<weld::ComboBox> m_xEastFontNameLB; std::unique_ptr<weld::Label> m_xEastFontStyleFT; @@ -86,10 +86,9 @@ private: std::unique_ptr<FontSizeBox> m_xEastFontSizeLB; std::unique_ptr<weld::Label> m_xEastFontLanguageFT; std::unique_ptr<SvxLanguageBox> m_xEastFontLanguageLB; - std::unique_ptr<weld::Label> m_xEastFontTypeFT; std::unique_ptr<weld::Button> m_xEastFontFeaturesButton; + std::unique_ptr<weld::Label> m_xEastFontTypeFT; - std::unique_ptr<weld::Widget> m_xCTLFrame; std::unique_ptr<weld::Label> m_xCTLFontNameFT; std::unique_ptr<weld::ComboBox> m_xCTLFontNameLB; std::unique_ptr<weld::Label> m_xCTLFontStyleFT; @@ -98,8 +97,8 @@ private: std::unique_ptr<FontSizeBox> m_xCTLFontSizeLB; std::unique_ptr<weld::Label> m_xCTLFontLanguageFT; std::unique_ptr<SvxLanguageBox> m_xCTLFontLanguageLB; - std::unique_ptr<weld::Label> m_xCTLFontTypeFT; std::unique_ptr<weld::Button> m_xCTLFontFeaturesButton; + std::unique_ptr<weld::Label> m_xCTLFontTypeFT; //for getting FontFeatures ScopedVclPtrInstance<VirtualDevice> m_xVDev; @@ -168,7 +167,6 @@ private: bool m_bNewFontColor; bool m_bEnableNoneFontColor; Color m_aOrigFontColor; - sal_uInt16 m_nHtmlMode; weld::TriStateEnabled m_aOutlineState; weld::TriStateEnabled m_aShadowState; @@ -271,6 +269,7 @@ private: std::unique_ptr<weld::MetricSpinButton> m_xKerningMF; std::unique_ptr<weld::CheckButton> m_xPairKerningBtn; + std::unique_ptr<weld::CheckButton> m_xNoHyphenationBtn; void Initialize(); void UpdatePreview_Impl( sal_uInt8 nProp, sal_uInt8 nEscProp, short nEsc ); diff --git a/cui/source/inc/connect.hxx b/cui/source/inc/connect.hxx index 8b7119f0dcaf..73891d0ff8e6 100644 --- a/cui/source/inc/connect.hxx +++ b/cui/source/inc/connect.hxx @@ -55,6 +55,8 @@ private: DECL_LINK(ChangeAttrEditHdl_Impl, weld::MetricSpinButton&, void); DECL_LINK(ChangeAttrListBoxHdl_Impl, weld::ComboBox&, void); + template<class T> + void SetMetricValueAndSave(const SfxItemSet *rAttrs, weld::MetricSpinButton &rField, TypedWhichId<T> nWhich); public: SvxConnectionPage(weld::Container* pPage, weld::DialogController* pController, const SfxItemSet& rInAttrs); diff --git a/cui/source/inc/cuifmsearch.hxx b/cui/source/inc/cuifmsearch.hxx index 46284c6d8d4d..29484ef8f69c 100644 --- a/cui/source/inc/cuifmsearch.hxx +++ b/cui/source/inc/cuifmsearch.hxx @@ -133,7 +133,7 @@ public: inline void SetActiveField(const OUString& strField); private: - void Init(const OUString& strVisibleFields, const OUString& strInitialText); + void Init(std::u16string_view strVisibleFields, const OUString& strInitialText); // only to be used out of the constructors void OnFound(const css::uno::Any& aCursorPos, sal_Int16 nFieldPos); diff --git a/cui/source/inc/cuigaldlg.hxx b/cui/source/inc/cuigaldlg.hxx index 0850cd0bcb02..cac63d8a6b1e 100644 --- a/cui/source/inc/cuigaldlg.hxx +++ b/cui/source/inc/cuigaldlg.hxx @@ -39,7 +39,7 @@ class SearchProgress; class TakeProgress; class TPGalleryThemeProperties; -typedef std::vector< sal_uLong > TokenList_impl; +typedef std::vector< sal_Int32 > TokenList_impl; struct FilterEntry { @@ -65,7 +65,7 @@ public: SearchThread(SearchProgress* pProgress, TPGalleryThemeProperties* pBrowser, - const INetURLObject& rStartURL); + INetURLObject aStartURL); }; class SearchProgress : public weld::GenericDialogController @@ -81,7 +81,7 @@ private: DECL_LINK(ClickCancelBtn, weld::Button&, void); public: - SearchProgress(weld::Window* pParent, TPGalleryThemeProperties* pTabPage, const INetURLObject& rStartURL); + SearchProgress(weld::Window* pParent, TPGalleryThemeProperties* pTabPage, INetURLObject aStartURL); void LaunchThread(); virtual ~SearchProgress() override; @@ -182,7 +182,7 @@ class GalleryThemeProperties : public SfxTabDialogController { ExchangeData* pData; - virtual void PageCreated(const OString& rId, SfxTabPage &rPage) override; + virtual void PageCreated(const OUString& rId, SfxTabPage &rPage) override; public: GalleryThemeProperties(weld::Widget* pParent, ExchangeData* pData, SfxItemSet const * pItemSet); @@ -268,7 +268,7 @@ public: void SetXChgData( ExchangeData* pData ); const ExchangeData* GetXChgData() const { return pData; } - void StartSearchFiles( const OUString& _rFolderURL, short _nDlgResult ); + void StartSearchFiles( std::u16string_view _rFolderURL, short _nDlgResult ); static std::unique_ptr<SfxTabPage> Create(weld::Container* pPage, weld::DialogController* pController, const SfxItemSet* rSet); }; diff --git a/cui/source/inc/cuigrfflt.hxx b/cui/source/inc/cuigrfflt.hxx index 122ac87724da..075c74c29f42 100644 --- a/cui/source/inc/cuigrfflt.hxx +++ b/cui/source/inc/cuigrfflt.hxx @@ -79,7 +79,7 @@ protected: public: - GraphicFilterDialog(weld::Window* pParent, const OUString& rUIXMLDescription, const OString& rID, const Graphic& rGraphic); + GraphicFilterDialog(weld::Window* pParent, const OUString& rUIXMLDescription, const OUString& rID, const Graphic& rGraphic); virtual Graphic GetFilteredGraphic(const Graphic& rGraphic, double fScaleX, double fScaleY) = 0; }; diff --git a/cui/source/inc/cuihyperdlg.hxx b/cui/source/inc/cuihyperdlg.hxx index b43361edfea1..8423d8c49759 100644 --- a/cui/source/inc/cuihyperdlg.hxx +++ b/cui/source/inc/cuihyperdlg.hxx @@ -67,7 +67,9 @@ private: std::vector< std::unique_ptr<IconChoicePageData> > maPageList; - OString msCurrentPageId; + OUString msCurrentPageId; + // tdf#90496 - remember last used view in hyperlink dialog + static OUString msRememberedPageId; const SfxItemSet* pSet; std::unique_ptr<SfxItemSet> pOutSet; @@ -87,17 +89,17 @@ private: std::unique_ptr<weld::Button> m_xHelpBtn; std::unique_ptr<weld::Button> m_xResetBtn; - DECL_LINK( ChosePageHdl_Impl, const OString&, void ); + DECL_LINK( ChosePageHdl_Impl, const OUString&, void ); - IconChoicePageData* GetPageData ( std::string_view rId ); + IconChoicePageData* GetPageData ( std::u16string_view rId ); - void SwitchPage( const OString& rId ); + void SwitchPage( const OUString& rId ); DECL_LINK( ResetHdl, weld::Button&, void) ; DECL_LINK (ClickOkHdl_Impl, weld::Button&, void ); DECL_LINK (ClickApplyHdl_Impl, weld::Button&, void ); - IconChoicePage* GetTabPage( std::string_view rPageId ) + IconChoicePage* GetTabPage( std::u16string_view rPageId ) { return GetPageData(rPageId)->xPage.get(); } void ActivatePageImpl (); @@ -113,11 +115,11 @@ public: virtual ~SvxHpLinkDlg () override; // interface - void AddTabPage(const OString &rId, CreatePage pCreateFunc /* != NULL */); + void AddTabPage(const OUString &rId, CreatePage pCreateFunc /* != NULL */); - void SetCurPageId( const OString& rId ) { msCurrentPageId = rId; SwitchPage(rId ); } - const OString & GetCurPageId() const { return msCurrentPageId; } - void ShowPage( const OString& rId ); + void SetCurPageId( const OUString& rId ) { msCurrentPageId = rId; SwitchPage(rId ); } + const OUString& GetCurPageId() const { return msCurrentPageId; } + void ShowPage( const OUString& rId ); /// gives via map converted local slots if applicable WhichRangesContainer GetInputRanges( const SfxItemPool& ); diff --git a/cui/source/inc/cuioptgenrl.hxx b/cui/source/inc/cuioptgenrl.hxx index 42cdbbec3aa9..0ee8cacb6c50 100644 --- a/cui/source/inc/cuioptgenrl.hxx +++ b/cui/source/inc/cuioptgenrl.hxx @@ -32,10 +32,16 @@ class SvxGeneralTabPage : public SfxTabPage private: // the "Use data for document properties" checkbox std::unique_ptr<weld::CheckButton> m_xUseDataCB; + std::unique_ptr<weld::Widget> m_xUseDataImg; std::unique_ptr<weld::Widget> m_xCryptoFrame; std::unique_ptr<weld::ComboBox> m_xSigningKeyLB; + std::unique_ptr<weld::Label> m_xSigningKeyFT; + std::unique_ptr<weld::Widget> m_xSigningKeyImg; std::unique_ptr<weld::ComboBox> m_xEncryptionKeyLB; + std::unique_ptr<weld::Label> m_xEncryptionKeyFT; + std::unique_ptr<weld::Widget> m_xEncryptionKeyImg; std::unique_ptr<weld::CheckButton> m_xEncryptToSelfCB; + std::unique_ptr<weld::Widget> m_xEncryptToSelfImg; // rows struct Row; std::vector<std::shared_ptr<Row> > vRows; @@ -64,6 +70,8 @@ public: static std::unique_ptr<SfxTabPage> Create( weld::Container* pPage, weld::DialogController* pController, const SfxItemSet* rAttrSet ); + virtual OUString GetAllStrings() override; + virtual bool FillItemSet( SfxItemSet* rSet ) override; virtual void Reset( const SfxItemSet* rSet ) override; }; diff --git a/cui/source/inc/cuitabarea.hxx b/cui/source/inc/cuitabarea.hxx index b5af2475a218..3e810c5b0dbe 100644 --- a/cui/source/inc/cuitabarea.hxx +++ b/cui/source/inc/cuitabarea.hxx @@ -108,14 +108,15 @@ class SvxAreaTabDialog final : public SfxTabDialogController ChangeType mnGradientListState; ChangeType mnHatchingListState; - virtual void PageCreated(const OString& rId, SfxTabPage &rPage) override; + virtual void PageCreated(const OUString& rId, SfxTabPage &rPage) override; virtual short Ok() override; DECL_LINK(CancelHdlImpl, weld::Button&, void); void SavePalettes(); public: - SvxAreaTabDialog(weld::Window* pParent, const SfxItemSet* pAttr, SdrModel* pModel, bool bShadow); + SvxAreaTabDialog(weld::Window* pParent, const SfxItemSet* pAttr, SdrModel* pModel, bool bShadow, + bool bSlideBackground); void SetNewColorList( XColorListRef const & pColorList ) { mpNewColorList = pColorList; } @@ -168,6 +169,9 @@ class SvxTransparenceTabPage : public SfxTabPage std::unique_ptr<weld::CustomWeld> m_xCtlBitmapPreview; std::unique_ptr<weld::CustomWeld> m_xCtlXRectPreview; + // MCGR: Preserve ColorStops until we have a UI to edit these + basegfx::BColorStops maColorStops; + DECL_LINK(ClickTransOffHdl_Impl, weld::Toggleable&, void); DECL_LINK(ClickTransLinearHdl_Impl, weld::Toggleable&, void); DECL_LINK(ClickTransGradientHdl_Impl, weld::Toggleable&, void ); @@ -183,6 +187,9 @@ class SvxTransparenceTabPage : public SfxTabPage bool InitPreview ( const SfxItemSet& rSet ); void InvalidatePreview (bool bEnable = true ); + // MCGR: Preserve ColorStops until we have a UI to edit these + basegfx::BColorStops createColorStops(); + public: SvxTransparenceTabPage(weld::Container* pPage, weld::DialogController* pController, const SfxItemSet& rInAttrs); virtual ~SvxTransparenceTabPage() override; @@ -241,11 +248,11 @@ protected: std::unique_ptr<weld::Toggleable> m_xBtnHatch; std::unique_ptr<weld::Toggleable> m_xBtnBitmap; std::unique_ptr<weld::Toggleable> m_xBtnPattern; + std::unique_ptr<weld::Toggleable> m_xBtnUseBackground; void SetOptimalSize(weld::DialogController* pController); void SelectFillType( weld::Toggleable& rButton, const SfxItemSet* _pSet = nullptr ); - SfxTabPage* GetFillTabPage() { return m_xFillTabPage.get(); } bool IsBtnClicked() const { return m_bBtnClicked; } @@ -260,12 +267,18 @@ private: DeactivateRC DeactivatePage_Impl( SfxItemSet* pSet ); public: - SvxAreaTabPage(weld::Container* pPage, weld::DialogController* pController, const SfxItemSet& rInAttrs); + SvxAreaTabPage(weld::Container* pPage, weld::DialogController* pController, + const SfxItemSet& rInAttrs, bool bSlideBackground = false); virtual ~SvxAreaTabPage() override; static std::unique_ptr<SfxTabPage> Create( weld::Container* pPage, weld::DialogController* pController, const SfxItemSet* ); + static std::unique_ptr<SfxTabPage> + CreateWithSlideBackground(weld::Container* pPage, weld::DialogController* pController, + const SfxItemSet*); static WhichRangesContainer GetRanges() { return pAreaRanges; } + virtual OUString GetAllStrings() override; + virtual bool FillItemSet( SfxItemSet* ) override; virtual void Reset( const SfxItemSet * ) override; virtual void ActivatePage( const SfxItemSet& rSet ) override; @@ -279,7 +292,7 @@ public: void SetBitmapList( XBitmapListRef const & pBmpLst) { m_pBitmapList = pBmpLst; } void SetPatternList( XPatternListRef const &pPtrnLst ) { m_pPatternList = pPtrnLst; } virtual void PageCreated(const SfxAllItemSet& aSet) override; - void CreatePage(sal_Int32 nId, SfxTabPage* pTab); + void CreatePage(sal_Int32 nId, SfxTabPage& rTab); void SetColorChgd( ChangeType* pIn ) { m_pnColorListState = pIn; } void SetGrdChgd( ChangeType* pIn ) { m_pnGradientListState = pIn; } void SetHtchChgd( ChangeType* pIn ) { m_pnHatchingListState = pIn; } @@ -355,6 +368,9 @@ private: XFillAttrSetItem m_aXFillAttr; SfxItemSet& m_rXFSet; + // MCGR: Preserve ColorStops until we have a UI to edit these + basegfx::BColorStops m_aColorStops; + SvxXRectPreview m_aCtlPreview; std::unique_ptr<weld::ComboBox> m_xLbGradientType; std::unique_ptr<weld::Label> m_xFtCenter; @@ -394,6 +410,9 @@ private: void SetControlState_Impl( css::awt::GradientStyle eXGS ); sal_Int32 SearchGradientList(std::u16string_view rGradientName); + // MCGR: Preserve ColorStops until we have a UI to edit these + basegfx::BColorStops createColorStops(); + public: SvxGradientTabPage(weld::Container* pPage, weld::DialogController* pController, const SfxItemSet& rInAttrs); virtual ~SvxGradientTabPage() override; @@ -639,10 +658,8 @@ private: ColorModel eCM; - Color aPreviousColor; - Color aCurrentColor; - - css::uno::Reference< css::uno::XComponentContext > m_context; + Color m_aPreviousColor; + NamedColor m_aCurrentColor; PaletteManager maPaletteManager; SvxXRectPreview m_aCtlPreviewOld; @@ -698,7 +715,7 @@ private: DECL_LINK(SelectPaletteLBHdl, weld::ComboBox&, void); DECL_LINK( SelectValSetHdl_Impl, ValueSet*, void ); DECL_LINK( SelectColorModeHdl_Impl, weld::Toggleable&, void ); - void ChangeColor(const Color &rNewColor, bool bUpdatePreset = true); + void ChangeColor(const NamedColor &rNewColor, bool bUpdatePreset = true); void SetColorModel(ColorModel eModel); void ChangeColorModel(); void UpdateColorValues( bool bUpdatePreset = true ); @@ -730,8 +747,6 @@ public: void SetColorChgd( ChangeType* pIn ) { pnColorListState = pIn; } - void SetCtlPreviewOld( const SfxItemSet& rAttrs ) { m_aCtlPreviewOld.SetAttributes( rAttrs ); } - virtual void FillUserData() override; }; diff --git a/cui/source/inc/cuitabline.hxx b/cui/source/inc/cuitabline.hxx index 704852b187fe..1122a2017f00 100644 --- a/cui/source/inc/cuitabline.hxx +++ b/cui/source/inc/cuitabline.hxx @@ -54,7 +54,7 @@ class SvxLineTabDialog final : public SfxTabDialogController sal_Int32 nPosDashLb; sal_Int32 nPosLineEndLb; - virtual void PageCreated(const OString& rId, SfxTabPage &rPage) override; + virtual void PageCreated(const OUString& rId, SfxTabPage &rPage) override; virtual short Ok() override; DECL_LINK(CancelHdlImpl, weld::Button&, void); @@ -96,7 +96,7 @@ private: bool m_bNewSize; /// a graphic to be displayed in the preview in case that an automatic symbol is chosen Graphic m_aAutoSymbolGraphic; - tools::Long m_nSymbolType; + sal_Int32 m_nSymbolType; /// attributes for the shown symbols; only necessary if not equal to line properties std::unique_ptr<SfxItemSet> m_xSymbolAttr; @@ -170,7 +170,7 @@ private: std::unique_ptr<weld::CheckButton> m_xSymbolRatioCB; // handler for gallery popup menu button + size - DECL_LINK(GraphicHdl_Impl, const OString&, void); + DECL_LINK(GraphicHdl_Impl, const OUString&, void); DECL_LINK(SizeHdl_Impl, weld::MetricSpinButton&, void); DECL_LINK(MenuCreateHdl_Impl, weld::Toggleable&, void); DECL_LINK(RatioHdl_Impl, weld::Toggleable&, void); diff --git a/cui/source/inc/dbregister.hxx b/cui/source/inc/dbregister.hxx index 3e8b592228bb..3b26e5190cb0 100644 --- a/cui/source/inc/dbregister.hxx +++ b/cui/source/inc/dbregister.hxx @@ -20,6 +20,7 @@ #pragma once #include <rtl/ustring.hxx> +#include <tools/solar.h> #include <sfx2/basedlgs.hxx> #include <sfx2/tabdlg.hxx> @@ -29,7 +30,7 @@ namespace svx class DbRegistrationOptionsPage : public SfxTabPage { private: - sal_uLong m_nOldCount; + size_t m_nOldCount; bool m_bModified; std::unique_ptr<weld::Button> m_xNew; @@ -72,6 +73,8 @@ namespace svx static std::unique_ptr<SfxTabPage> Create( weld::Container* pPage, weld::DialogController* pController, const SfxItemSet* rSet ); + virtual OUString GetAllStrings() override; + virtual bool FillItemSet( SfxItemSet* rSet ) override; virtual void Reset( const SfxItemSet* rSet ) override; virtual void FillUserData() override; @@ -88,7 +91,7 @@ namespace svx SfxItemSet m_aRegistrationItems; protected: - RegistrationItemSetHolder( const SfxItemSet& _rMasterSet ); + RegistrationItemSetHolder( SfxItemSet _aMasterSet ); ~RegistrationItemSetHolder(); protected: diff --git a/cui/source/inc/dlgname.hxx b/cui/source/inc/dlgname.hxx deleted file mode 100644 index 0baa56b61948..000000000000 --- a/cui/source/inc/dlgname.hxx +++ /dev/null @@ -1,119 +0,0 @@ -/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ -/* - * This file is part of the LibreOffice project. - * - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. - * - * This file incorporates work covered by the following license notice: - * - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed - * with this work for additional information regarding copyright - * ownership. The ASF licenses this file to you under the Apache - * License, Version 2.0 (the "License"); you may not use this file - * except in compliance with the License. You may obtain a copy of - * the License at http://www.apache.org/licenses/LICENSE-2.0 . - */ -#pragma once - -#include <vcl/weld.hxx> - -/// Dialog for editing a name -class SvxNameDialog : public weld::GenericDialogController -{ -private: - std::unique_ptr<weld::Entry> m_xEdtName; - std::unique_ptr<weld::Label> m_xFtDescription; - std::unique_ptr<weld::Button> m_xBtnOK; - - Link<SvxNameDialog&, bool> m_aCheckNameHdl; - Link<SvxNameDialog&, OUString> m_aCheckNameTooltipHdl; - - DECL_LINK(ModifyHdl, weld::Entry&, void); - -public: - SvxNameDialog(weld::Window* pWindow, const OUString& rName, const OUString& rDesc); - - OUString GetName() const { return m_xEdtName->get_text(); } - - /** add a callback Link that is called whenever the content of the edit - field is changed. The Link result determines whether the OK - Button is enabled (> 0) or disabled (== 0). - - @param rLink a Callback declared with DECL_DLLPRIVATE_LINK and implemented with - IMPL_LINK, that is executed on modification. - - @param bCheckImmediately If true, the Link is called directly after - setting it. It is recommended to set this flag to true to avoid - an inconsistent state if the initial String (given in the CTOR) - does not satisfy the check condition. - - @todo Remove the parameter bCheckImmediately and incorporate the 'true' - behaviour as default. - */ - void SetCheckNameHdl(const Link<SvxNameDialog&, bool>& rLink, bool bCheckImmediately) - { - m_aCheckNameHdl = rLink; - if (bCheckImmediately) - m_xBtnOK->set_sensitive(rLink.Call(*this)); - } - - void SetCheckNameTooltipHdl(const Link<SvxNameDialog&, OUString>& rLink) - { - m_aCheckNameTooltipHdl = rLink; - m_xBtnOK->set_tooltip_text(rLink.Call(*this)); - } - - void SetEditHelpId(const OString& aHelpId) { m_xEdtName->set_help_id(aHelpId); } -}; - -/** #i68101# - Dialog for editing Object name - plus uniqueness-callback-linkHandler */ -class SvxObjectNameDialog : public weld::GenericDialogController -{ -private: - // name - std::unique_ptr<weld::Entry> m_xEdtName; - - // buttons - std::unique_ptr<weld::Button> m_xBtnOK; - - // callback link for name uniqueness - Link<SvxObjectNameDialog&, bool> aCheckNameHdl; - - DECL_LINK(ModifyHdl, weld::Entry&, void); - -public: - // constructor - SvxObjectNameDialog(weld::Window* pWindow, const OUString& rName); - - // data access - OUString GetName() const { return m_xEdtName->get_text(); } - - // set handler - void SetCheckNameHdl(const Link<SvxObjectNameDialog&, bool>& rLink) { aCheckNameHdl = rLink; } -}; - -/** #i68101# - Dialog for editing Object Title and Description */ -class SvxObjectTitleDescDialog : public weld::GenericDialogController -{ -private: - // title - std::unique_ptr<weld::Entry> m_xEdtTitle; - - // description - std::unique_ptr<weld::TextView> m_xEdtDescription; - -public: - // constructor - SvxObjectTitleDescDialog(weld::Window* pWindow, const OUString& rTitle, const OUString& rDesc); - // data access - OUString GetTitle() const { return m_xEdtTitle->get_text(); } - OUString GetDescription() const { return m_xEdtDescription->get_text(); } -}; - -/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/cui/source/inc/grfpage.hxx b/cui/source/inc/grfpage.hxx index 35653eaf6ade..673062b7593a 100644 --- a/cui/source/inc/grfpage.hxx +++ b/cui/source/inc/grfpage.hxx @@ -49,13 +49,14 @@ class SvxGrfCropPage : public SfxTabPage { friend class VclPtr<SvxGrfCropPage>; - OUString aGraphicName; - Size aOrigSize; - Size aOrigPixelSize; - Size aPageSize; - tools::Long nOldWidth; - tools::Long nOldHeight; - bool bSetOrigSize; + OUString m_aGraphicName; + Size m_aOrigSize; + Size m_aOrigPixelSize; + Size m_aPageSize; + tools::Long m_nOldWidth; + tools::Long m_nOldHeight; + bool m_bSetOrigSize; + sal_Int32 m_aPreferredDPI; SvxCropExample m_aExampleWN; @@ -79,6 +80,8 @@ class SvxGrfCropPage : public SfxTabPage std::unique_ptr<weld::Label> m_xOrigSizeFT; std::unique_ptr<weld::Button> m_xOrigSizePB; + std::unique_ptr<weld::Button> m_xUncropPB; + // Example std::unique_ptr<weld::CustomWeld> m_xExampleWN; @@ -86,13 +89,14 @@ class SvxGrfCropPage : public SfxTabPage DECL_LINK(SizeHdl, weld::MetricSpinButton&, void); DECL_LINK(CropModifyHdl, weld::MetricSpinButton&, void); DECL_LINK(OrigSizeHdl, weld::Button&, void); + DECL_LINK(UncropHdl, weld::Button&, void); void CalcZoom(); void CalcMinMaxBorder(); void GraphicHasChanged(bool bFound); virtual void ActivatePage(const SfxItemSet& rSet) override; - static Size GetGrfOrigSize(const Graphic&); + Size GetGrfOrigSize(const Graphic& rGraphic); public: SvxGrfCropPage(weld::Container* pPage, weld::DialogController* pController, const SfxItemSet &rSet); static std::unique_ptr<SfxTabPage> Create( weld::Container* pPage, weld::DialogController* pController, const SfxItemSet *rSet ); diff --git a/cui/source/inc/helpids.h b/cui/source/inc/helpids.h index 2ac2fbd0b02c..8f9af7fd9570 100644 --- a/cui/source/inc/helpids.h +++ b/cui/source/inc/helpids.h @@ -18,33 +18,35 @@ */ #pragma once -inline constexpr OStringLiteral HID_OPTIONS_COLORCONFIG_SAVE_SCHEME - = "CUI_HID_OPTIONS_COLORCONFIG_SAVE_SCHEME"; -inline constexpr OStringLiteral HID_OFA_FONT_SUBST_CLB = "CUI_HID_OFA_FONT_SUBST_CLB"; -inline constexpr OStringLiteral HID_DBPATH_CTL_PATH = "CUI_HID_DBPATH_CTL_PATH"; +#include <rtl/ustring.hxx> + +inline constexpr OUString HID_OPTIONS_COLORCONFIG_SAVE_SCHEME + = u"CUI_HID_OPTIONS_COLORCONFIG_SAVE_SCHEME"_ustr; +inline constexpr OUString HID_OFA_FONT_SUBST_CLB = u"CUI_HID_OFA_FONT_SUBST_CLB"_ustr; +inline constexpr OUString HID_DBPATH_CTL_PATH = u"CUI_HID_DBPATH_CTL_PATH"_ustr; #define HID_DBPATH_HEADERBAR "CUI_HID_DBPATH_HEADERBAR" -inline constexpr OStringLiteral HID_OFADLG_TREELISTBOX = "CUI_HID_OFADLG_TREELISTBOX"; -inline constexpr OStringLiteral HID_SVX_CONFIG_TOOLBAR = "CUI_HID_SVX_CONFIG_TOOLBAR"; -inline constexpr OStringLiteral HID_SVX_CONFIG_TOOLBAR_CONTENTS - = "CUI_HID_SVX_CONFIG_TOOLBAR_CONTENTS"; -inline constexpr OStringLiteral HID_SVX_CONFIG_NOTEBOOKBAR_CONTENTS - = "CUI_HID_SVX_CONFIG_NOTEBOOKBAR_CONTENTS"; -inline constexpr OStringLiteral HID_HANGULDLG_SUGGESTIONS_GRID - = "CUI_HID_HANGULDLG_SUGGESTIONS_GRID"; -inline constexpr OStringLiteral HID_HANGULDLG_SUGGESTIONS_LIST - = "CUI_HID_HANGULDLG_SUGGESTIONS_LIST"; -inline constexpr OStringLiteral HID_SVX_CONFIG_NAME_SUBMENU = "CUI_HID_SVX_CONFIG_NAME_SUBMENU"; -inline constexpr OStringLiteral HID_SVX_CONFIG_RENAME_MENU = "CUI_HID_SVX_CONFIG_RENAME_MENU"; -inline constexpr OStringLiteral HID_SVX_CONFIG_RENAME_MENU_ITEM - = "CUI_HID_SVX_CONFIG_RENAME_MENU_ITEM"; -inline constexpr OStringLiteral HID_SVX_CONFIG_RENAME_TOOLBAR = "CUI_HID_SVX_CONFIG_RENAME_TOOLBAR"; -inline constexpr OStringLiteral HID_SVX_CONFIG_RENAME_TOOLBAR_ITEM - = "CUI_HID_SVX_CONFIG_RENAME_TOOLBAR_ITEM"; -inline constexpr OStringLiteral HID_SVX_UP_TOOLBAR_ITEM = "CUI_HID_SVX_UP_TOOLBAR_ITEM"; -inline constexpr OStringLiteral HID_SVX_DOWN_TOOLBAR_ITEM = "CUI_HID_SVX_DOWN_TOOLBAR_ITEM"; -inline constexpr OStringLiteral HID_SVX_SAVE_IN = "CUI_HID_SVX_SAVE_IN"; -inline constexpr OStringLiteral HID_SVX_TOPLEVELLISTBOX = "CUI_HID_SVX_TOPLEVELLISTBOX"; -inline constexpr OStringLiteral HID_SVX_DESCFIELD = "CUI_HID_SVX_DESCFIELD"; -inline constexpr OStringLiteral HID_MACRO_HEADERTABLISTBOX = "CUI_HID_MACRO_HEADERTABLISTBOX"; +inline constexpr OUString HID_OFADLG_TREELISTBOX = u"CUI_HID_OFADLG_TREELISTBOX"_ustr; +inline constexpr OUString HID_SVX_CONFIG_TOOLBAR = u"CUI_HID_SVX_CONFIG_TOOLBAR"_ustr; +inline constexpr OUString HID_SVX_CONFIG_TOOLBAR_CONTENTS + = u"CUI_HID_SVX_CONFIG_TOOLBAR_CONTENTS"_ustr; +inline constexpr OUString HID_SVX_CONFIG_NOTEBOOKBAR_CONTENTS + = u"CUI_HID_SVX_CONFIG_NOTEBOOKBAR_CONTENTS"_ustr; +inline constexpr OUString HID_HANGULDLG_SUGGESTIONS_GRID + = u"CUI_HID_HANGULDLG_SUGGESTIONS_GRID"_ustr; +inline constexpr OUString HID_HANGULDLG_SUGGESTIONS_LIST + = u"CUI_HID_HANGULDLG_SUGGESTIONS_LIST"_ustr; +inline constexpr OUString HID_SVX_CONFIG_NAME_SUBMENU = u"CUI_HID_SVX_CONFIG_NAME_SUBMENU"_ustr; +inline constexpr OUString HID_SVX_CONFIG_RENAME_MENU = u"CUI_HID_SVX_CONFIG_RENAME_MENU"_ustr; +inline constexpr OUString HID_SVX_CONFIG_RENAME_MENU_ITEM + = u"CUI_HID_SVX_CONFIG_RENAME_MENU_ITEM"_ustr; +inline constexpr OUString HID_SVX_CONFIG_RENAME_TOOLBAR = u"CUI_HID_SVX_CONFIG_RENAME_TOOLBAR"_ustr; +inline constexpr OUString HID_SVX_CONFIG_RENAME_TOOLBAR_ITEM + = u"CUI_HID_SVX_CONFIG_RENAME_TOOLBAR_ITEM"_ustr; +inline constexpr OUString HID_SVX_UP_TOOLBAR_ITEM = u"CUI_HID_SVX_UP_TOOLBAR_ITEM"_ustr; +inline constexpr OUString HID_SVX_DOWN_TOOLBAR_ITEM = u"CUI_HID_SVX_DOWN_TOOLBAR_ITEM"_ustr; +inline constexpr OUString HID_SVX_SAVE_IN = u"CUI_HID_SVX_SAVE_IN"_ustr; +inline constexpr OUString HID_SVX_TOPLEVELLISTBOX = u"CUI_HID_SVX_TOPLEVELLISTBOX"_ustr; +inline constexpr OUString HID_SVX_DESCFIELD = u"CUI_HID_SVX_DESCFIELD"_ustr; +inline constexpr OUString HID_MACRO_HEADERTABLISTBOX = u"CUI_HID_MACRO_HEADERTABLISTBOX"_ustr; /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/cui/source/inc/hldocntp.hxx b/cui/source/inc/hldocntp.hxx index 95a11dd9f1fc..68bce1650a00 100644 --- a/cui/source/inc/hldocntp.hxx +++ b/cui/source/inc/hldocntp.hxx @@ -34,7 +34,7 @@ private: std::unique_ptr<weld::Button> m_xBtCreate; std::unique_ptr<weld::TreeView> m_xLbDocTypes; - bool ImplGetURLObject( const OUString& rPath, const OUString& rBase, INetURLObject& aURLObject ) const; + bool ImplGetURLObject( const OUString& rPath, std::u16string_view rBase, INetURLObject& aURLObject ) const; void FillDocumentList (); DECL_LINK (ClickNewHdl_Impl, weld::Button&, void ); @@ -42,7 +42,7 @@ private: protected: void FillDlgFields(const OUString& rStrURL) override; - void GetCurentItemData ( OUString& rStrURL, OUString& aStrName, + void GetCurrentItemData ( OUString& rStrURL, OUString& aStrName, OUString& aStrIntName, OUString& aStrFrame, SvxLinkInsertMode& eMode ) override; @@ -52,7 +52,6 @@ public: static std::unique_ptr<IconChoicePage> Create(weld::Container* pWindow, SvxHpLinkDlg* pDlg, const SfxItemSet* pItemSet); - virtual bool AskApply () override; virtual void DoApply () override; virtual void SetInitFocus() override; diff --git a/cui/source/inc/hldoctp.hxx b/cui/source/inc/hldoctp.hxx index 73f6218eabc5..61005a42d635 100644 --- a/cui/source/inc/hldoctp.hxx +++ b/cui/source/inc/hldoctp.hxx @@ -49,10 +49,10 @@ private: DECL_LINK( TimeoutHdl_Impl, Timer *, void ); ///< Handler for timer -timeout enum class EPathType { Invalid, ExistsFile }; - static EPathType GetPathType ( const OUString& rStrPath ); + static EPathType GetPathType ( std::u16string_view rStrPath ); void FillDlgFields(const OUString& rStrURL) override; - void GetCurentItemData ( OUString& rStrURL, OUString& aStrName, + void GetCurrentItemData ( OUString& rStrURL, OUString& aStrName, OUString& aStrIntName, OUString& aStrFrame, SvxLinkInsertMode& eMode ) override; virtual bool ShouldOpenMarkWnd () override {return m_bMarkWndOpen;} diff --git a/cui/source/inc/hlinettp.hxx b/cui/source/inc/hlinettp.hxx index c2340fdde2f7..366d8243a8b6 100644 --- a/cui/source/inc/hlinettp.hxx +++ b/cui/source/inc/hlinettp.hxx @@ -34,24 +34,11 @@ class SvxHyperlinkInternetTp : public SvxHyperlinkTabPageBase { private: - OUString maStrOldUser; - OUString maStrOldPassword; - bool m_bMarkWndOpen; - std::unique_ptr<weld::RadioButton> m_xRbtLinktypInternet; - std::unique_ptr<weld::RadioButton> m_xRbtLinktypFTP; std::unique_ptr<SvxHyperURLBox> m_xCbbTarget; std::unique_ptr<weld::Label> m_xFtTarget; - std::unique_ptr<weld::Label> m_xFtLogin; - std::unique_ptr<weld::Entry> m_xEdLogin; - std::unique_ptr<weld::Label> m_xFtPassword; - std::unique_ptr<weld::Entry> m_xEdPassword; - std::unique_ptr<weld::CheckButton> m_xCbAnonymous; - - DECL_LINK( Click_SmartProtocol_Impl, weld::Toggleable&, void ); ///< Radiobutton toggled: Type HTTP or FTP - DECL_LINK( ClickAnonymousHdl_Impl, weld::Toggleable&, void ); ///< Checkbox : Anonymous User - DECL_LINK( ModifiedLoginHdl_Impl, weld::Entry&, void ); ///< Contents of editfield "Login" modified + DECL_LINK( LostFocusTargetHdl_Impl, weld::Widget&, void ); ///< Combobox "Target" lost its focus DECL_LINK( ModifiedTargetHdl_Impl, weld::ComboBox&, void ); ///< Contents of editfield "Target" modified @@ -60,21 +47,18 @@ private: void SetScheme(std::u16string_view rScheme); void RemoveImproperProtocol(std::u16string_view rProperScheme); - OUString GetSchemeFromButtons() const; - INetProtocol GetSmartProtocolFromButtons() const; + static INetProtocol GetSmartProtocolFromButtons(); OUString CreateAbsoluteURL() const; - void setAnonymousFTPUser(); - void setFTPUser(const OUString& rUser, const OUString& rPassword); void RefreshMarkWindow(); protected: virtual void FillDlgFields(const OUString& rStrURL) override; - virtual void GetCurentItemData ( OUString& rStrURL, OUString& aStrName, + virtual void GetCurrentItemData ( OUString& rStrURL, OUString& aStrName, OUString& aStrIntName, OUString& aStrFrame, SvxLinkInsertMode& eMode ) override; - virtual bool ShouldOpenMarkWnd () override {return ( m_bMarkWndOpen && m_xRbtLinktypInternet->get_active() );} + virtual bool ShouldOpenMarkWnd () override { return false; } virtual void SetMarkWndShouldOpen (bool bOpen) override {m_bMarkWndOpen=bOpen;} public: diff --git a/cui/source/inc/hlmailtp.hxx b/cui/source/inc/hlmailtp.hxx index 8b8bc39d88cb..b7c76c52cb18 100644 --- a/cui/source/inc/hlmailtp.hxx +++ b/cui/source/inc/hlmailtp.hxx @@ -31,7 +31,6 @@ class SvxHyperlinkMailTp : public SvxHyperlinkTabPageBase private: std::unique_ptr<SvxHyperURLBox> m_xCbbReceiver; std::unique_ptr<weld::Button> m_xBtAdrBook; - std::unique_ptr<weld::Label> m_xFtSubject; std::unique_ptr<weld::Entry> m_xEdSubject; DECL_STATIC_LINK(SvxHyperlinkMailTp, ClickAdrBookHdl_Impl, weld::Button&, void); @@ -45,7 +44,7 @@ private: protected: virtual void FillDlgFields(const OUString& rStrURL) override; - virtual void GetCurentItemData ( OUString& rStrURL, OUString& aStrName, + virtual void GetCurrentItemData ( OUString& rStrURL, OUString& aStrName, OUString& aStrIntName, OUString& aStrFrame, SvxLinkInsertMode& eMode ) override; diff --git a/cui/source/inc/hltpbase.hxx b/cui/source/inc/hltpbase.hxx index 2ad0007c83cb..acb84198ad25 100644 --- a/cui/source/inc/hltpbase.hxx +++ b/cui/source/inc/hltpbase.hxx @@ -75,7 +75,7 @@ protected: void InitStdControls (); void FillStandardDlgFields ( const SvxHyperlinkItem* pHyperlinkItem ); virtual void FillDlgFields(const OUString& rStrURL) = 0; - virtual void GetCurentItemData ( OUString& rStrURL, OUString& aStrName, + virtual void GetCurrentItemData ( OUString& rStrURL, OUString& aStrName, OUString& aStrIntName, OUString& aStrFrame, SvxLinkInsertMode& eMode ) = 0; @@ -94,7 +94,7 @@ public: weld::Container* pParent, SvxHpLinkDlg* pDlg, const OUString& rUIXMLDescription, - const OString& rID, + const OUString& rID, const SfxItemSet* pItemSet ); virtual ~SvxHyperlinkTabPageBase () override; @@ -105,7 +105,6 @@ public: mxDocumentFrame = rxDocumentFrame; } - virtual bool AskApply (); virtual void DoApply (); virtual void SetInitFocus(); virtual void SetMarkStr ( const OUString& aStrMark ); diff --git a/cui/source/inc/hyphen.hxx b/cui/source/inc/hyphen.hxx index cb8104c70315..0b304e9439f9 100644 --- a/cui/source/inc/hyphen.hxx +++ b/cui/source/inc/hyphen.hxx @@ -71,7 +71,7 @@ class SvxHyphenWordDialog : public SfxDialogController DECL_LINK(CursorChangeHdl_Impl, weld::Entry&, void); public: - SvxHyphenWordDialog(const OUString &rWord, LanguageType nLang, + SvxHyphenWordDialog(OUString aWord, LanguageType nLang, weld::Widget* pParent, css::uno::Reference<css::linguistic2::XHyphenator> const &xHyphen, SvxSpellWrapper* pWrapper); diff --git a/cui/source/inc/iconcdlg.hxx b/cui/source/inc/iconcdlg.hxx index 5cf1ab54f6d7..e31aaa74e0db 100644 --- a/cui/source/inc/iconcdlg.hxx +++ b/cui/source/inc/iconcdlg.hxx @@ -20,6 +20,7 @@ #include <rtl/ustring.hxx> #include <sfx2/tabdlg.hxx> +#include <utility> // forward-declarations struct IconChoicePageData; @@ -31,21 +32,6 @@ class SfxItemSet; // Create-Function typedef std::unique_ptr<IconChoicePage> (*CreatePage)(weld::Container* pParent, SvxHpLinkDlg* pDlg, const SfxItemSet* pAttrSet); -/// Data-structure for pages in dialog -struct IconChoicePageData -{ - OString sId; - std::unique_ptr<IconChoicePage> xPage; ///< the TabPage itself - bool bRefresh; ///< Flag: page has to be newly initialized - - // constructor - IconChoicePageData(const OString& rId, std::unique_ptr<IconChoicePage> xInPage) - : sId(rId) - , xPage(std::move(xInPage)) - , bRefresh(false) - {} -}; - class IconChoicePage { protected: @@ -58,12 +44,12 @@ private: protected: - IconChoicePage(weld::Container* pParent, const OUString& rUIXMLDescription, const OString& rID, const SfxItemSet* pItemSet); + IconChoicePage(weld::Container* pParent, const OUString& rUIXMLDescription, const OUString& rID, const SfxItemSet* pItemSet); public: virtual ~IconChoicePage(); - OString GetHelpId() const { return xContainer->get_help_id(); } + OUString GetHelpId() const { return xContainer->get_help_id(); } const SfxItemSet& GetItemSet() const { return *pSet; } @@ -78,4 +64,19 @@ public: virtual bool QueryClose(); }; +/// Data-structure for pages in dialog +struct IconChoicePageData +{ + OUString sId; + std::unique_ptr<IconChoicePage> xPage; ///< the TabPage itself + bool bRefresh; ///< Flag: page has to be newly initialized + + // constructor + IconChoicePageData(OUString aId, std::unique_ptr<IconChoicePage> xInPage) + : sId(std::move(aId)) + , xPage(std::move(xInPage)) + , bRefresh(false) + {} +}; + /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/cui/source/inc/insdlg.hxx b/cui/source/inc/insdlg.hxx index c76658470450..61c707507087 100644 --- a/cui/source/inc/insdlg.hxx +++ b/cui/source/inc/insdlg.hxx @@ -36,12 +36,12 @@ protected: comphelper::EmbeddedObjectContainer aCnt; InsertObjectDialog_Impl(weld::Window * pParent, - const OUString& rUIXMLDescription, const OString& rID, - const css::uno::Reference < css::embed::XStorage >& xStorage); + const OUString& rUIXMLDescription, const OUString& rID, + css::uno::Reference < css::embed::XStorage > xStorage); public: const css::uno::Reference<css::embed::XEmbeddedObject>& GetObject() const { return m_xObj; } virtual css::uno::Reference<css::io::XInputStream> GetIconIfIconified(OUString* pGraphicMediaType); - void SetHelpId(const OString& rHelpId) { m_xDialog->set_help_id(rHelpId); } + void SetHelpId(const OUString& rHelpId) { m_xDialog->set_help_id(rHelpId); } virtual bool IsCreateNew() const; }; diff --git a/cui/source/inc/insrc.hxx b/cui/source/inc/insrc.hxx index e003795383dc..9ab7f0fed466 100644 --- a/cui/source/inc/insrc.hxx +++ b/cui/source/inc/insrc.hxx @@ -22,7 +22,7 @@ #include <svx/svxdlg.hxx> #include <vcl/weld.hxx> -class SvxInsRowColDlg : public SvxAbstractInsRowColDlg, public weld::GenericDialogController +class SvxInsRowColDlg : public weld::GenericDialogController { private: std::unique_ptr<weld::SpinButton> m_xCountEdit; @@ -30,10 +30,23 @@ private: std::unique_ptr<weld::RadioButton> m_xAfterBtn; public: - SvxInsRowColDlg(weld::Window* pParent, bool bCol, const OString& rHelpId); + SvxInsRowColDlg(weld::Window* pParent, bool bCol, const OUString& rHelpId); - virtual short Execute() override; + bool isInsertBefore() const; + sal_uInt16 getInsertCount() const; +}; + +class SvxAbstractInsRowColDlg_Impl final : public SvxAbstractInsRowColDlg +{ + std::shared_ptr<SvxInsRowColDlg> m_xDlg; +public: + explicit SvxAbstractInsRowColDlg_Impl(std::shared_ptr<SvxInsRowColDlg> p) + : m_xDlg(std::move(p)) + { + } + virtual short Execute() override; + virtual bool StartExecuteAsync(AsyncContext& rCtx) override; virtual bool isInsertBefore() const override; virtual sal_uInt16 getInsertCount() const override; }; diff --git a/cui/source/inc/labdlg.hxx b/cui/source/inc/labdlg.hxx index 8146ec388f53..5d7f778d5c38 100644 --- a/cui/source/inc/labdlg.hxx +++ b/cui/source/inc/labdlg.hxx @@ -102,7 +102,7 @@ private: Link<SvxSwFrameValidation&,void> aValidateLink; - virtual void PageCreated(const OString& rId, SfxTabPage &rPage) override; + virtual void PageCreated(const OUString& rId, SfxTabPage &rPage) override; public: SvxCaptionTabDialog(weld::Window* pParent, const SdrView* pView, diff --git a/cui/source/inc/macroass.hxx b/cui/source/inc/macroass.hxx index ea365b225747..ba3c1de11717 100644 --- a/cui/source/inc/macroass.hxx +++ b/cui/source/inc/macroass.hxx @@ -29,6 +29,7 @@ class SfxMacroTabPage_; class SfxMacroTabPage_Impl; +class Timer; class SfxMacroTabPage final : public SfxTabPage { diff --git a/cui/source/inc/macropg.hxx b/cui/source/inc/macropg.hxx index 39e4ef284384..2f2471bb09eb 100644 --- a/cui/source/inc/macropg.hxx +++ b/cui/source/inc/macropg.hxx @@ -30,7 +30,8 @@ #include <unordered_map> #include <vector> -typedef std::unordered_map< OUString, std::pair< OUString, OUString > > EventsHash; +typedef std::pair<OUString, OUString> EventPair; +typedef std::unordered_map<OUString, EventPair> EventsHash; struct EventDisplayName { @@ -54,8 +55,10 @@ class SvxMacroTabPage_ : public SfxTabPage DECL_LINK( SelectEvent_Impl, weld::TreeView&, void ); DECL_LINK( AssignDeleteHdl_Impl, weld::Button&, void ); DECL_LINK( DoubleClickHdl_Impl, weld::TreeView&, bool ); + DECL_LINK( DeleteAllHdl_Impl, weld::Button&, void ); - static void GenericHandler_Impl( SvxMacroTabPage_* pThis, const weld::Button* pBtn ); + void GenericHandler_Impl(const weld::Button* pBtn); + const EventPair* LookupEvent(const OUString& rEventName); css::uno::Reference< css::container::XNameReplace > m_xAppEvents; protected: @@ -64,14 +67,15 @@ protected: css::uno::Reference< css::util::XModifiable > m_xModifiable; EventsHash m_appEventsHash; EventsHash m_docEventsHash; + int m_nAssignedEvents; bool bDocModified, bAppEvents, bInitialized; std::vector< EventDisplayName > aDisplayNames; - SvxMacroTabPage_(weld::Container* pPage, weld::DialogController* pController, const OUString& rUIXMLDescription, const OString& rID, const SfxItemSet& rItemSet); + SvxMacroTabPage_(weld::Container* pPage, weld::DialogController* pController, const OUString& rUIXMLDescription, const OUString& rID, const SfxItemSet& rItemSet); void EnableButtons(); static css::uno::Any GetPropsByName( const OUString& eventName, EventsHash& eventsHash ); - static std::pair< OUString, OUString > GetPairFromAny( const css::uno::Any& aAny ); + static EventPair GetPairFromAny(const css::uno::Any& aAny); public: diff --git a/cui/source/inc/multipat.hxx b/cui/source/inc/multipat.hxx index 3f747f21aadd..258e446e80f8 100644 --- a/cui/source/inc/multipat.hxx +++ b/cui/source/inc/multipat.hxx @@ -20,16 +20,6 @@ #include <vcl/weld.hxx> -// define ---------------------------------------------------------------- - -// different delimiter for Unix (:) and Windows (;) - -#ifdef UNX -#define CLASSPATH_DELIMITER ':' -#else -#define CLASSPATH_DELIMITER ';' -#endif - class SvxMultiPathDialog : public weld::GenericDialogController { private: @@ -50,7 +40,7 @@ public: virtual ~SvxMultiPathDialog() override; OUString GetPath() const; - void SetPath(const OUString& rPath); + void SetPath(std::u16string_view rPath); void SetTitle(const OUString& rTitle) { m_xDialog->set_title(rTitle); } }; @@ -69,7 +59,7 @@ public: SvxPathSelectDialog(weld::Window* pParent); OUString GetPath() const; - void SetPath( const OUString& rPath ); + void SetPath( std::u16string_view rPath ); void SetTitle(const OUString& rTitle) { m_xDialog->set_title(rTitle); } }; diff --git a/cui/source/inc/newtabledlg.hxx b/cui/source/inc/newtabledlg.hxx index b62e1199e44d..4a34cb37712c 100644 --- a/cui/source/inc/newtabledlg.hxx +++ b/cui/source/inc/newtabledlg.hxx @@ -37,7 +37,7 @@ public: class SvxNewTableDialogWrapper : public SvxAbstractNewTableDialog { private: - std::shared_ptr<weld::DialogController> m_xDlg; + std::shared_ptr<SvxNewTableDialog> m_xDlg; public: SvxNewTableDialogWrapper(weld::Window* pParent) @@ -52,18 +52,16 @@ public: virtual sal_Int32 getRows() const override { - SvxNewTableDialog* pDlg = dynamic_cast<SvxNewTableDialog*>(m_xDlg.get()); - if (pDlg) - return pDlg->getRows(); + if (m_xDlg) + return m_xDlg->getRows(); return 0; } virtual sal_Int32 getColumns() const override { - SvxNewTableDialog* pDlg = dynamic_cast<SvxNewTableDialog*>(m_xDlg.get()); - if (pDlg) - return pDlg->getColumns(); + if (m_xDlg) + return m_xDlg->getColumns(); return 0; } diff --git a/cui/source/inc/numpages.hxx b/cui/source/inc/numpages.hxx index c4f6961f82b0..7c34d49fcc62 100644 --- a/cui/source/inc/numpages.hxx +++ b/cui/source/inc/numpages.hxx @@ -25,9 +25,10 @@ #include <editeng/numdef.hxx> #include <editeng/svxenum.hxx> #include <svtools/ctrlbox.hxx> +#include <svx/numberingpreview.hxx> #include <vcl/customweld.hxx> #include <vcl/timer.hxx> -#include <cui/numberingpreview.hxx> +#include <svx/dlgutil.hxx> #define MN_GALLERY_ENTRY 100 @@ -63,8 +64,7 @@ class SvxSingleNumPickTabPage final : public SfxTabPage sal_uInt16 nActNumLvl; bool bModified : 1; bool bPreset : 1; - - sal_uInt16 nNumItemId; + TypedWhichId<SvxNumBulletItem> nNumItemId; std::unique_ptr<SvxNumValueSet> m_xExamplesVS; std::unique_ptr<weld::CustomWeld> m_xExamplesVSWin; @@ -92,7 +92,7 @@ class SvxBulletPickTabPage final : public SfxTabPage sal_uInt16 nActNumLvl; bool bModified : 1; bool bPreset : 1; - sal_uInt16 nNumItemId; + TypedWhichId<SvxNumBulletItem> nNumItemId; OUString sBulletCharFormatName; @@ -129,7 +129,7 @@ class SvxNumPickTabPage final : public SfxTabPage std::unique_ptr<SvxNumRule> pActNum; std::unique_ptr<SvxNumRule> pSaveNum; sal_uInt16 nActNumLvl; - sal_uInt16 nNumItemId; + TypedWhichId<SvxNumBulletItem> nNumItemId; bool bModified : 1; bool bPreset : 1; @@ -164,7 +164,7 @@ class SvxBitmapPickTabPage final : public SfxTabPage std::unique_ptr<SvxNumRule> pActNum; std::unique_ptr<SvxNumRule> pSaveNum; sal_uInt16 nActNumLvl; - sal_uInt16 nNumItemId; + TypedWhichId<SvxNumBulletItem> nNumItemId; MapUnit eCoreUnit; bool bModified : 1; bool bPreset : 1; @@ -216,9 +216,11 @@ class SvxNumOptionsTabPage : public SfxTabPage sal_uInt8 nBullet; sal_uInt16 nActNumLvl; - sal_uInt16 nNumItemId; + TypedWhichId<SvxNumBulletItem> nNumItemId; MapUnit eCoreUnit; + SvxRatioConnector m_aRatioTop; + SvxRatioConnector m_aRatioBottom; SvxNumberingPreview m_aPreviewWIN; std::unique_ptr<weld::Widget> m_xGrid; std::unique_ptr<weld::TreeView> m_xLevelLB; @@ -236,6 +238,7 @@ class SvxNumOptionsTabPage : public SfxTabPage std::unique_ptr<weld::MetricSpinButton> m_xBulRelSizeMF; std::unique_ptr<weld::Label> m_xAllLevelFT; std::unique_ptr<weld::SpinButton> m_xAllLevelNF; + std::unique_ptr<weld::CheckButton> m_xIsLegalCB; std::unique_ptr<weld::Label> m_xStartFT; std::unique_ptr<weld::SpinButton> m_xStartED; std::unique_ptr<weld::Label> m_xBulletFT; @@ -247,6 +250,9 @@ class SvxNumOptionsTabPage : public SfxTabPage std::unique_ptr<weld::Label> m_xHeightFT; std::unique_ptr<weld::MetricSpinButton> m_xHeightMF; std::unique_ptr<weld::CheckButton> m_xRatioCB; + std::unique_ptr<weld::Image> m_xCbxScaleImg; + std::unique_ptr<weld::CustomWeld> m_xImgRatioTop; + std::unique_ptr<weld::CustomWeld> m_xImgRatioBottom; std::unique_ptr<weld::Label> m_xOrientFT; std::unique_ptr<weld::ComboBox> m_xOrientLB; std::unique_ptr<weld::Widget> m_xAllLevelsFrame; @@ -266,7 +272,7 @@ class SvxNumOptionsTabPage : public SfxTabPage DECL_LINK(LevelHdl_Impl, weld::TreeView&, void); DECL_LINK(LevelHdl, void *, void); DECL_LINK(PopupActivateHdl_Impl, weld::Toggleable&, void); - DECL_LINK(GraphicHdl_Impl, const OString&, void); + DECL_LINK(GraphicHdl_Impl, const OUString&, void); DECL_LINK(BulletHdl_Impl, weld::Button&, void); DECL_LINK(SizeHdl_Impl, weld::MetricSpinButton&, void); DECL_LINK(RatioHdl_Impl, weld::Toggleable&, void); @@ -274,6 +280,7 @@ class SvxNumOptionsTabPage : public SfxTabPage DECL_LINK(EditModifyHdl_Impl, weld::Entry&, void); DECL_LINK(SpinModifyHdl_Impl, weld::SpinButton&, void); DECL_LINK(AllLevelHdl_Impl, weld::SpinButton&, void); + DECL_LINK(IsLegalHdl_Impl, weld::Toggleable&, void); DECL_LINK(OrientHdl_Impl, weld::ComboBox&, void); DECL_LINK(SameLevelHdl_Impl, weld::Toggleable&, void); DECL_LINK(BulColorHdl_Impl, ColorListBox&, void); @@ -312,7 +319,7 @@ class SvxNumPositionTabPage : public SfxTabPage ImplSVEvent* m_pLevelHdlEvent; sal_uInt16 nActNumLvl; - sal_uInt16 nNumItemId; + TypedWhichId<SvxNumBulletItem> nNumItemId; MapUnit eCoreUnit; bool bModified : 1; diff --git a/cui/source/inc/optasian.hxx b/cui/source/inc/optasian.hxx index 9d9815ea49f0..31a622f7a50d 100644 --- a/cui/source/inc/optasian.hxx +++ b/cui/source/inc/optasian.hxx @@ -53,6 +53,9 @@ public: static std::unique_ptr<SfxTabPage> Create(weld::Container* pPage, weld::DialogController* pController, const SfxItemSet* rAttrSet); static WhichRangesContainer GetRanges(); + + virtual OUString GetAllStrings() override; + virtual bool FillItemSet(SfxItemSet* rSet) override; virtual void Reset(const SfxItemSet* rSet) override; }; diff --git a/cui/source/inc/optdict.hxx b/cui/source/inc/optdict.hxx index e2dcf55953a8..8e382cc32e8f 100644 --- a/cui/source/inc/optdict.hxx +++ b/cui/source/inc/optdict.hxx @@ -89,7 +89,6 @@ private: DECL_LINK(NewDelActionHdl, weld::Entry&, bool); DECL_LINK(ModifyHdl, weld::Entry&, void); DECL_LINK(EntrySizeAllocHdl, const Size&, void); - DECL_STATIC_LINK(SvxEditDictionaryDialog, InsertTextHdl, OUString&, bool); bool NewDelHdl(const weld::Widget*); void ShowWords_Impl( sal_uInt16 nId ); diff --git a/cui/source/inc/optlingu.hxx b/cui/source/inc/optlingu.hxx index 365acfbbb0fb..6c5657acf7bd 100644 --- a/cui/source/inc/optlingu.hxx +++ b/cui/source/inc/optlingu.hxx @@ -22,6 +22,7 @@ #include <svx/langbox.hxx> #include <com/sun/star/uno/Reference.hxx> #include <com/sun/star/uno/Sequence.hxx> +#include <com/sun/star/configuration/ReadWriteAccess.hpp> namespace com::sun::star{ namespace beans{ @@ -60,6 +61,8 @@ class SvxEditModulesDlg : public weld::GenericDialogController std::unique_ptr<weld::Button> m_xClosePB; std::unique_ptr<SvxLanguageBox> m_xLanguageLB; + css::uno::Reference< css::configuration::XReadWriteAccess> m_xReadWriteAccess; + DECL_LINK( SelectHdl_Impl, weld::TreeView&, void ); DECL_LINK( UpDownHdl_Impl, weld::Button&, void ); DECL_LINK( ClickHdl_Impl, weld::Button&, void ); @@ -84,6 +87,8 @@ private: OUString sWordsWithDigits; OUString sSpellSpecial; OUString sSpellAuto; + OUString sSpellClosedCompound; + OUString sSpellHyphenatedCompound; OUString sGrammarAuto; OUString sNumMinWordlen; OUString sNumPreBreak; @@ -118,6 +123,7 @@ private: std::unique_ptr<weld::Button> m_xLinguDicsDelPB; std::unique_ptr<weld::TreeView> m_xLinguOptionsCLB; std::unique_ptr<weld::Button> m_xLinguOptionsEditPB; + std::unique_ptr<weld::Box> m_xMoreDictsBox; std::unique_ptr<weld::LinkButton> m_xMoreDictsLink; void AddDicBoxEntry( const css::uno::Reference< css::linguistic2::XDictionary > &rxDic, sal_uInt16 nIdx ); @@ -139,6 +145,8 @@ public: static std::unique_ptr<SfxTabPage> Create( weld::Container* pPage, weld::DialogController* pController, const SfxItemSet* rSet ); virtual ~SvxLinguTabPage() override; + virtual OUString GetAllStrings() override; + virtual bool FillItemSet( SfxItemSet* rSet ) override; virtual void Reset( const SfxItemSet* rSet ) override; diff --git a/cui/source/inc/optpath.hxx b/cui/source/inc/optpath.hxx index c3b9aafbbae5..ccfeb70e0072 100644 --- a/cui/source/inc/optpath.hxx +++ b/cui/source/inc/optpath.hxx @@ -56,13 +56,15 @@ private: void GetPathList( SvtPathOptions::Paths _nPathHandle, OUString& _rInternalPath, OUString& _rUserPath, OUString& _rWritablePath, bool& _rReadOnly ); void SetPathList( SvtPathOptions::Paths _nPathHandle, - const OUString& _rUserPath, const OUString& _rWritablePath ); + std::u16string_view _rUserPath, const OUString& _rWritablePath ); public: SvxPathTabPage( weld::Container* pPage, weld::DialogController* pController, const SfxItemSet& rSet ); static std::unique_ptr<SfxTabPage> Create( weld::Container* pPage, weld::DialogController* pController, const SfxItemSet* rSet ); virtual ~SvxPathTabPage() override; + virtual OUString GetAllStrings() override; + virtual bool FillItemSet( SfxItemSet* rSet ) override; virtual void Reset( const SfxItemSet* rSet ) override; }; diff --git a/cui/source/inc/page.hxx b/cui/source/inc/page.hxx index 02af8079a88c..151569ac4634 100644 --- a/cui/source/inc/page.hxx +++ b/cui/source/inc/page.hxx @@ -38,7 +38,6 @@ <SvxSizeItem>: <SID_ATTR_MAXSIZE> <SvxULSpaceItem>: <SID_ATTR_LRSPACE> <SvxLRSpaceItem>: <SID_ATTR_ULSPACE> - <SfxAllEnumItem>: <SID_ATTR_PAPERTRAY> <SvxPaperBinItem>: <SID_ATTR_PAPERBIN> <SvxBoolItem>: <SID_ATTR_EXT1> <SvxBoolItem>: <SID_ATTR_EXT2> @@ -93,7 +92,6 @@ private: std::unique_ptr<SvxPaperSizeListBox> m_xPaperSizeBox; std::unique_ptr<weld::MetricSpinButton> m_xPaperWidthEdit; std::unique_ptr<weld::MetricSpinButton> m_xPaperHeightEdit; - std::unique_ptr<weld::Label> m_xOrientationFT; std::unique_ptr<weld::RadioButton> m_xPortraitBtn; std::unique_ptr<weld::RadioButton> m_xLandscapeBtn; std::unique_ptr<weld::Label> m_xTextFlowLbl; diff --git a/cui/source/inc/paragrph.hxx b/cui/source/inc/paragrph.hxx index 73cc5faf32cd..b35111f43b33 100644 --- a/cui/source/inc/paragrph.hxx +++ b/cui/source/inc/paragrph.hxx @@ -46,29 +46,29 @@ private: tools::Long nWidth; tools::Long nMinFixDist; bool bRelativeMode; - OUString sAbsDist; SvxParaPrevWindow m_aExampleWin; - // indention - std::unique_ptr<SvxRelativeField> m_xLeftIndent; + // indentation + bool m_bSplitLRSpace = false; ///< which items to use? + SvxRelativeField m_aLeftIndent; - std::unique_ptr<weld::Label> m_xRightLabel; - std::unique_ptr<SvxRelativeField> m_xRightIndent; + SvxRelativeField m_aRightIndent; std::unique_ptr<weld::Label> m_xFLineLabel; - std::unique_ptr<SvxRelativeField> m_xFLineIndent; + SvxRelativeField m_aFLineIndent; std::unique_ptr<weld::CheckButton> m_xAutoCB; // distance - std::unique_ptr<SvxRelativeField> m_xTopDist; - std::unique_ptr<SvxRelativeField> m_xBottomDist; + SvxRelativeField m_aTopDist; + SvxRelativeField m_aBottomDist; std::unique_ptr<weld::CheckButton> m_xContextualCB; // line spacing std::unique_ptr<weld::ComboBox> m_xLineDist; std::unique_ptr<weld::MetricSpinButton> m_xLineDistAtPercentBox; std::unique_ptr<weld::MetricSpinButton> m_xLineDistAtMetricBox; + std::unique_ptr<weld::MetricSpinButton> m_xLineDistAtPlaceHolderBox; std::unique_ptr<weld::Label> m_xLineDistAtLabel; std::unique_ptr<weld::Label> m_xAbsDist; @@ -112,7 +112,6 @@ public: void EnableRegisterMode(); void EnableContextualMode(); void EnableAutoFirstLine(); - void EnableAbsLineDist(tools::Long nMinTwip); void EnableNegativeMode(); virtual void PageCreated(const SfxAllItemSet& aSet) override; }; @@ -121,7 +120,9 @@ public: class SvxParaAlignTabPage : public SfxTabPage { - static const WhichRangesContainer pAlignRanges; + static const WhichRangesContainer pAlignRanges, pSdrAlignRanges; + + bool m_bSdrVertAlign; SvxParaPrevWindow m_aExampleWin; @@ -144,8 +145,9 @@ class SvxParaAlignTabPage : public SfxTabPage //vertical alignment std::unique_ptr<weld::Widget> m_xVertAlignFL; std::unique_ptr<weld::ComboBox> m_xVertAlignLB; + std::unique_ptr<weld::Label> m_xVertAlign; + std::unique_ptr<weld::Label> m_xVertAlignSdr; - std::unique_ptr<weld::Widget> m_xPropertiesFL; std::unique_ptr<svx::FrameDirectionListBox> m_xTextDirectionLB; DECL_LINK(AlignHdl_Impl, weld::Toggleable&, void); @@ -164,12 +166,14 @@ public: virtual ~SvxParaAlignTabPage() override; static WhichRangesContainer GetRanges() { return pAlignRanges; } + static WhichRangesContainer GetSdrRanges() { return pSdrAlignRanges; } virtual bool FillItemSet( SfxItemSet* rSet ) override; virtual void Reset( const SfxItemSet* rSet ) override; virtual void ChangesApplied() override; void EnableJustifyExt(); + void EnableSdrVertAlign(); virtual void PageCreated(const SfxAllItemSet& aSet) override; }; @@ -213,10 +217,13 @@ private: weld::TriStateEnabled aPageBreakState; weld::TriStateEnabled aApplyCollState; weld::TriStateEnabled aPageNumState; - weld::TriStateEnabled aKeepTogetherState; + weld::TriStateEnabled aAllowSplitState; weld::TriStateEnabled aKeepParaState; weld::TriStateEnabled aOrphanState; weld::TriStateEnabled aWidowState; + weld::TriStateEnabled aAcrossColumnState; + weld::TriStateEnabled aAcrossPageState; + weld::TriStateEnabled aAcrossSpreadState; bool bPageBreak; bool bHtmlMode; @@ -225,12 +232,19 @@ private: // hyphenation std::unique_ptr<weld::CheckButton> m_xHyphenBox; std::unique_ptr<weld::CheckButton> m_xHyphenNoCapsBox; + std::unique_ptr<weld::CheckButton> m_xHyphenNoLastWordBox; std::unique_ptr<weld::Label> m_xBeforeText; std::unique_ptr<weld::SpinButton> m_xExtHyphenBeforeBox; std::unique_ptr<weld::Label> m_xAfterText; std::unique_ptr<weld::SpinButton> m_xExtHyphenAfterBox; + std::unique_ptr<weld::Label> m_xCompoundBeforeText; + std::unique_ptr<weld::SpinButton> m_xExtCompoundHyphenBeforeBox; std::unique_ptr<weld::Label> m_xMaxHyphenLabel; std::unique_ptr<weld::SpinButton> m_xMaxHyphenEdit; + std::unique_ptr<weld::Label> m_xMinWordLabel; + std::unique_ptr<weld::SpinButton> m_xMinWordLength; + std::unique_ptr<weld::Label> m_xHyphenZoneLabel; + SvxRelativeField m_aHyphenZone; // pagebreak std::unique_ptr<weld::CheckButton> m_xPageBreakBox; @@ -244,7 +258,7 @@ private: std::unique_ptr<weld::SpinButton> m_xPagenumEdit; // paragraph division - std::unique_ptr<weld::CheckButton> m_xKeepTogetherBox; + std::unique_ptr<weld::CheckButton> m_xAllowSplitBox; std::unique_ptr<weld::CheckButton> m_xKeepParaBox; // orphan/widow @@ -256,16 +270,22 @@ private: std::unique_ptr<weld::SpinButton> m_xWidowRowNo; std::unique_ptr<weld::Label> m_xWidowRowLabel; + // avoid hyphenation across + std::unique_ptr<weld::Label> m_xAcrossText; + std::unique_ptr<weld::CheckButton> m_xAcrossColumnBox; + std::unique_ptr<weld::CheckButton> m_xAcrossPageBox; + std::unique_ptr<weld::CheckButton> m_xAcrossSpreadBox; + void HyphenClickHdl(); void PageNumBoxClickHdl(); void ApplyCollClickHdl(); void PageBreakHdl(); - void KeepTogetherHdl(); + void AllowSplitHdl(); void OrphanHdl(); void WidowHdl(); DECL_LINK(PageBreakHdl_Impl, weld::Toggleable&, void); - DECL_LINK(KeepTogetherHdl_Impl, weld::Toggleable&, void); + DECL_LINK(AllowSplitHdl_Impl, weld::Toggleable&, void); DECL_LINK(WidowHdl_Impl, weld::Toggleable&, void); DECL_LINK(OrphanHdl_Impl, weld::Toggleable&, void); DECL_LINK(HyphenClickHdl_Impl, weld::Toggleable&, void); @@ -274,6 +294,9 @@ private: DECL_LINK(PageBreakTypeHdl_Impl, weld::ComboBox&, void); DECL_LINK(PageNumBoxClickHdl_Impl, weld::Toggleable&, void); DECL_LINK(KeepParaBoxClickHdl_Impl, weld::Toggleable&, void); + DECL_LINK(AcrossColumnHdl_Impl, weld::Toggleable&, void); + DECL_LINK(AcrossPageHdl_Impl, weld::Toggleable&, void); + DECL_LINK(AcrossSpreadHdl_Impl, weld::Toggleable&, void); virtual void PageCreated(const SfxAllItemSet& aSet) override; }; diff --git a/cui/source/inc/passwdomdlg.hxx b/cui/source/inc/passwdomdlg.hxx index 2e13cc1b616c..1077195f7a85 100644 --- a/cui/source/inc/passwdomdlg.hxx +++ b/cui/source/inc/passwdomdlg.hxx @@ -25,6 +25,7 @@ class PasswordToOpenModifyDialog : public SfxDialogController { std::unique_ptr<weld::Entry> m_xPasswdToOpenED; std::unique_ptr<weld::Label> m_xPasswdToOpenInd; + std::unique_ptr<weld::LevelBar> m_xPasswdToOpenBar; std::unique_ptr<weld::Entry> m_xReenterPasswdToOpenED; std::unique_ptr<weld::Label> m_xReenterPasswdToOpenInd; std::unique_ptr<weld::Expander> m_xOptionsExpander; @@ -33,17 +34,21 @@ class PasswordToOpenModifyDialog : public SfxDialogController std::unique_ptr<weld::Label> m_xPasswdToModifyFT; std::unique_ptr<weld::Entry> m_xPasswdToModifyED; std::unique_ptr<weld::Label> m_xPasswdToModifyInd; + std::unique_ptr<weld::LevelBar> m_xPasswdToModifyBar; std::unique_ptr<weld::Label> m_xReenterPasswdToModifyFT; std::unique_ptr<weld::Entry> m_xReenterPasswdToModifyED; std::unique_ptr<weld::Label> m_xReenterPasswdToModifyInd; + std::shared_ptr<weld::MessageDialog> m_xErrorBox; OUString m_aOneMismatch; OUString m_aTwoMismatch; OUString m_aInvalidStateForOkButton; OUString m_aInvalidStateForOkButton_v2; + std::optional<OUString> m_oPasswordPolicy; int m_nMaxPasswdLen; bool m_bIsPasswordToModify; + bool m_bAllowEmpty; DECL_LINK(OkBtnClickHdl, weld::Button&, void); @@ -57,11 +62,13 @@ public: PasswordToOpenModifyDialog(weld::Window* pParent, sal_uInt16 nMaxPasswdLen /* 0 -> no max len enforced */, bool bIsPasswordToModify ); + ~PasswordToOpenModifyDialog(); // AbstractPasswordToOpenModifyDialog OUString GetPasswordToOpen() const; OUString GetPasswordToModify() const; bool IsRecommendToOpenReadonly() const; + void AllowEmpty(); }; /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/cui/source/inc/scriptdlg.hxx b/cui/source/inc/scriptdlg.hxx index d2e5cae7f27d..b1b014771dae 100644 --- a/cui/source/inc/scriptdlg.hxx +++ b/cui/source/inc/scriptdlg.hxx @@ -76,7 +76,6 @@ public: class SvxScriptOrgDialog : public SfxDialogController { -protected: weld::Window* m_pParent; OUString m_sLanguage; static Selection_hash m_lastSelection; @@ -124,7 +123,7 @@ protected: const weld::TreeIter* pParent, bool bChildrenOnDemand, std::unique_ptr< SFEntry > && aUserData, - const OUString& factoryURL, bool bSelect); + std::u16string_view factoryURL, bool bSelect); void insertEntry(OUString const & rText, OUString const & rBitmap, const weld::TreeIter* pParent, bool bChildrenOnDemand, @@ -143,7 +142,7 @@ protected: public: // prob need another arg in the ctor // to specify the language or provider - SvxScriptOrgDialog(weld::Window* pParent, const OUString& language); + SvxScriptOrgDialog(weld::Window* pParent, OUString language); virtual ~SvxScriptOrgDialog() override; virtual short run() override; diff --git a/cui/source/inc/sdrcelldlg.hxx b/cui/source/inc/sdrcelldlg.hxx index 5b7e9ca71a20..46f34c0dae28 100644 --- a/cui/source/inc/sdrcelldlg.hxx +++ b/cui/source/inc/sdrcelldlg.hxx @@ -38,9 +38,9 @@ private: XPatternListRef mpPatternList; public: - SvxFormatCellsDialog(weld::Window* pParent, const SfxItemSet* pAttr, const SdrModel& rModel); + SvxFormatCellsDialog(weld::Window* pParent, const SfxItemSet& rAttr, const SdrModel& rModel, bool bStyle); - virtual void PageCreated(const OString& rId, SfxTabPage &rPage) override; + virtual void PageCreated(const OUString& rId, SfxTabPage &rPage) override; }; diff --git a/cui/source/options/securityoptions.hxx b/cui/source/inc/securityoptions.hxx index dc05f5bb8150..a86b4f0c605a 100644 --- a/cui/source/options/securityoptions.hxx +++ b/cui/source/inc/securityoptions.hxx @@ -22,7 +22,6 @@ namespace svx { - class SecurityOptionsDialog : public weld::GenericDialogController { private: @@ -43,18 +42,44 @@ namespace svx std::unique_ptr<weld::Widget> m_xCtrlHyperlinkImg; std::unique_ptr<weld::CheckButton> m_xBlockUntrustedRefererLinksCB; std::unique_ptr<weld::Widget> m_xBlockUntrustedRefererLinksImg; + std::unique_ptr<weld::CheckButton> m_xDisableActiveContentCB; + std::unique_ptr<weld::Widget> m_xDisableActiveContentImg; + + std::unique_ptr<weld::CheckButton> m_xRedlineinfoCB; + std::unique_ptr<weld::Widget> m_xRedlineinfoImg; + std::unique_ptr<weld::CheckButton> m_xDocPropertiesCB; + std::unique_ptr<weld::Widget> m_xDocPropertiesImg; + std::unique_ptr<weld::CheckButton> m_xNoteAuthorCB; + std::unique_ptr<weld::Widget> m_xNoteAuthorImg; + std::unique_ptr<weld::CheckButton> m_xDocumentVersionCB; + std::unique_ptr<weld::Widget> m_xDocumentVersionImg; + std::unique_ptr<weld::CheckButton> m_xPrinterSettingsCB; + std::unique_ptr<weld::Widget> m_xPrinterSettingsImg; public: SecurityOptionsDialog(weld::Window* pParent); + void init(); + bool IsSaveOrSendDocsChecked() const { return m_xSaveOrSendDocsCB->get_active(); } bool IsSignDocsChecked() const { return m_xSignDocsCB->get_active(); } bool IsPrintDocsChecked() const { return m_xPrintDocsCB->get_active(); } bool IsCreatePdfChecked() const { return m_xCreatePdfCB->get_active(); } bool IsRemovePersInfoChecked() const { return m_xRemovePersInfoCB->get_active(); } + bool IsRemoveRedlineInfoChecked() const { return m_xRedlineinfoCB->get_active(); } + bool IsRemoveDocUserInfoChecked() const { return m_xDocPropertiesCB->get_active(); } + bool IsRemoveNoteAuthorInfoChecked() const { return m_xNoteAuthorCB->get_active(); } + bool IsRemoveDocVersionInfoChecked() const { return m_xDocumentVersionCB->get_active(); } + bool IsKeepPrinterSettingsChecked() const { return m_xPrinterSettingsCB->get_active(); } bool IsRecommPasswdChecked() const { return m_xRecommPasswdCB->get_active(); } bool IsCtrlHyperlinkChecked() const { return m_xCtrlHyperlinkCB->get_active(); } bool IsBlockUntrustedRefererLinksChecked() const { return m_xBlockUntrustedRefererLinksCB->get_active(); } + bool IsDisableActiveContentChecked() const { return m_xDisableActiveContentCB->get_active(); } + + DECL_LINK(ShowPersonalInfosToggle, weld::Toggleable&, void); + + bool SetSecurityOptions(); + void changeKeepSecurityInfosEnabled(); }; } diff --git a/cui/source/inc/srchxtra.hxx b/cui/source/inc/srchxtra.hxx index e95fccd413fd..712abc8b55bc 100644 --- a/cui/source/inc/srchxtra.hxx +++ b/cui/source/inc/srchxtra.hxx @@ -30,7 +30,7 @@ public: virtual ~SvxSearchFormatDialog() override; protected: - virtual void PageCreated(const OString& rId, SfxTabPage &rPage) override; + virtual void PageCreated(const OUString& rId, SfxTabPage &rPage) override; private: std::unique_ptr<FontList> m_pFontList; diff --git a/cui/source/inc/swpossizetabpage.hxx b/cui/source/inc/swpossizetabpage.hxx index eb73196986bf..2e5a15fbebbb 100644 --- a/cui/source/inc/swpossizetabpage.hxx +++ b/cui/source/inc/swpossizetabpage.hxx @@ -21,6 +21,7 @@ #include <sfx2/tabdlg.hxx> #include <svx/swframeexample.hxx> #include <vcl/weld.hxx> +#include <svx/dlgutil.hxx> // SvxSwPosSizeTabPage - position and size page for Writer drawing objects struct FrmMap; @@ -55,10 +56,15 @@ class SvxSwPosSizeTabPage : public SfxTabPage TriState m_nProtectSizeState; SwFrameExample m_aExampleWN; + SvxRatioConnector m_aRatioTop; + SvxRatioConnector m_aRatioBottom; std::unique_ptr<weld::MetricSpinButton> m_xWidthMF; std::unique_ptr<weld::MetricSpinButton> m_xHeightMF; std::unique_ptr<weld::CheckButton> m_xKeepRatioCB; + std::unique_ptr<weld::Image> m_xCbxScaleImg; + std::unique_ptr<weld::CustomWeld> m_xImgRatioTop; + std::unique_ptr<weld::CustomWeld> m_xImgRatioBottom; std::unique_ptr<weld::RadioButton> m_xToPageRB; std::unique_ptr<weld::RadioButton> m_xToParaRB; std::unique_ptr<weld::RadioButton> m_xToCharRB; @@ -91,6 +97,7 @@ class SvxSwPosSizeTabPage : public SfxTabPage DECL_LINK(MirrorHdl, weld::Toggleable&, void); DECL_LINK(ModifyHdl, weld::MetricSpinButton&, void); DECL_LINK(ProtectHdl, weld::Toggleable&, void); + DECL_LINK(RatioHdl_Impl, weld::Toggleable&, void); void InitPos(RndStdIds nAnchorType, sal_uInt16 nH, sal_uInt16 nHRel, sal_uInt16 nV, sal_uInt16 nVRel, diff --git a/cui/source/inc/textanim.hxx b/cui/source/inc/textanim.hxx index 8f4767e22fe8..010d3954716c 100644 --- a/cui/source/inc/textanim.hxx +++ b/cui/source/inc/textanim.hxx @@ -96,7 +96,7 @@ class SvxTextTabDialog : public SfxTabDialogController private: const SdrView* pView; - virtual void PageCreated(const OString& rId, SfxTabPage &rPage) override; + virtual void PageCreated(const OUString& rId, SfxTabPage &rPage) override; public: SvxTextTabDialog(weld::Window* pParent, const SfxItemSet* pAttr, const SdrView* pView); diff --git a/cui/source/inc/textattr.hxx b/cui/source/inc/textattr.hxx index d48e87b7d759..a6a7f2bd6f46 100644 --- a/cui/source/inc/textattr.hxx +++ b/cui/source/inc/textattr.hxx @@ -19,7 +19,7 @@ #pragma once #include <svx/dlgctrl.hxx> -#include <svx/svdobj.hxx> +#include <svx/svdobjkind.hxx> class SdrView; diff --git a/cui/source/inc/thesdlg.hxx b/cui/source/inc/thesdlg.hxx index de085d678682..05865d68d92f 100644 --- a/cui/source/inc/thesdlg.hxx +++ b/cui/source/inc/thesdlg.hxx @@ -26,6 +26,8 @@ #include <memory> #include <stack> +struct ImplSVEvent; + class SvxThesaurusDialog : public SfxDialogController { Idle m_aModifyIdle; @@ -43,6 +45,7 @@ class SvxThesaurusDialog : public SfxDialogController std::unique_ptr<weld::Entry> m_xReplaceEdit; std::unique_ptr<weld::ComboBox> m_xLangLB; std::unique_ptr<weld::Button> m_xReplaceBtn; + ImplSVEvent* m_nSelectFirstEvent; public: virtual ~SvxThesaurusDialog() override; diff --git a/cui/source/inc/tipofthedaydlg.hxx b/cui/source/inc/tipofthedaydlg.hxx index 69af1996e454..1f86d1bf238c 100644 --- a/cui/source/inc/tipofthedaydlg.hxx +++ b/cui/source/inc/tipofthedaydlg.hxx @@ -27,7 +27,7 @@ class TipOfTheDayDialog : public weld::GenericDialogController { private: CuiGraphicPreviewWindow m_aPreview; - weld::Window* m_pParent; + css::uno::Reference<css::awt::XWindow> m_xParent; std::unique_ptr<weld::Label> m_pText; std::unique_ptr<weld::CheckButton> m_pShowTip; diff --git a/cui/source/inc/transfrm.hxx b/cui/source/inc/transfrm.hxx index 30b789dc73c4..78ffd84e2794 100644 --- a/cui/source/inc/transfrm.hxx +++ b/cui/source/inc/transfrm.hxx @@ -19,6 +19,7 @@ #pragma once #include <svx/dlgctrl.hxx> +#include <svx/dlgutil.hxx> #include <svx/dialcontrol.hxx> #include <svx/anchorid.hxx> #include <basegfx/range/b2drange.hxx> @@ -41,7 +42,7 @@ private: SvxAnchorIds nAnchorCtrls; Link<SvxSwFrameValidation&,void> aValidateLink; - virtual void PageCreated(const OString& rId, SfxTabPage &rPage) override; + virtual void PageCreated(const OUString& rId, SfxTabPage &rPage) override; public: SvxTransformTabDialog(weld::Window* pParent, const SfxItemSet* pAttr, @@ -91,6 +92,9 @@ private: SvxRectCtl m_aCtlPos; SvxRectCtl m_aCtlSize; + SvxRatioConnector m_aRatioTop; + SvxRatioConnector m_aRatioBottom; + // position std::unique_ptr<weld::Widget> m_xFlPosition; std::unique_ptr<weld::MetricSpinButton> m_xMtrPosX; @@ -104,6 +108,9 @@ private: std::unique_ptr<weld::Label> m_xFtHeight; std::unique_ptr<weld::MetricSpinButton> m_xMtrHeight; std::unique_ptr<weld::CheckButton> m_xCbxScale; + std::unique_ptr<weld::Image> m_xCbxScaleImg; + std::unique_ptr<weld::CustomWeld> m_xImgRatioTop; + std::unique_ptr<weld::CustomWeld> m_xImgRatioBottom; std::unique_ptr<weld::CustomWeld> m_xCtlSize; // protect diff --git a/cui/source/inc/treeopt.hxx b/cui/source/inc/treeopt.hxx index 541726b27a90..6d07d0981d5a 100644 --- a/cui/source/inc/treeopt.hxx +++ b/cui/source/inc/treeopt.hxx @@ -25,6 +25,9 @@ #include <sfx2/basedlgs.hxx> #include <svtools/restartdialog.hxx> +#include <utility> +#include <i18nutil/searchopt.hxx> +#include <vcl/timer.hxx> class SfxModule; class SfxShell; @@ -36,8 +39,8 @@ struct OrderedEntry sal_Int32 m_nIndex; OUString m_sId; - OrderedEntry( sal_Int32 nIndex, const OUString& rId ) : - m_nIndex( nIndex ), m_sId( rId ) {} + OrderedEntry( sal_Int32 nIndex, OUString aId ) : + m_nIndex( nIndex ), m_sId(std::move( aId )) {} }; @@ -61,15 +64,15 @@ struct OptionsLeaf OUString m_sGroupId; sal_Int32 m_nGroupIndex; - OptionsLeaf( const OUString& rLabel, - const OUString& rPageURL, - const OUString& rEventHdl, - const OUString& rGroupId, + OptionsLeaf( OUString aLabel, + OUString aPageURL, + OUString aEventHdl, + OUString aGroupId, sal_Int32 nGroupIndex ) : - m_sLabel( rLabel ), - m_sPageURL( rPageURL ), - m_sEventHdl( rEventHdl ), - m_sGroupId( rGroupId ), + m_sLabel(std::move( aLabel )), + m_sPageURL(std::move( aPageURL )), + m_sEventHdl(std::move( aEventHdl )), + m_sGroupId(std::move( aGroupId )), m_nGroupIndex( nGroupIndex ) {} }; @@ -84,11 +87,11 @@ struct OptionsNode std::vector< std::vector< std::unique_ptr<OptionsLeaf> > > m_aGroupedLeaves; - OptionsNode( const OUString& rId, - const OUString& rLabel, + OptionsNode( OUString aId, + OUString aLabel, bool bAllModules ) : - m_sId( rId ), - m_sLabel( rLabel ), + m_sId(std::move( aId )), + m_sLabel(std::move( aLabel )), m_bAllModules( bAllModules ) {} }; @@ -113,6 +116,7 @@ struct Module; class ExtensionsTabPage; class SvxColorTabPage; struct OptionsGroupInfo; +struct OptionsPageIdInfo; class OfaTreeOptionsDialog final: public SfxOkDialogController { @@ -123,11 +127,38 @@ private: std::unique_ptr<weld::TreeView> xTreeLB; std::unique_ptr<weld::Container> xTabBox; + std::unique_ptr<weld::Entry> m_xSearchEdit; weld::Window* m_pParent; std::unique_ptr<weld::TreeIter> xCurrentPageEntry; + // For search + Timer m_aUpdateDataTimer; + i18nutil::SearchOptions2 m_options; + + bool bIsFirtsInitialize; + std::vector<OptionsPageIdInfo*> m_aTreePageIds; + typedef std::vector<std::pair<sal_uInt16, std::vector<sal_uInt16>>> VectorOfMatchedIds; + + void generalOptions(const std::vector<sal_uInt16>& vPageId = {}); // SID_GENERAL_OPTIONS + void loadAndSaveOptions(const std::vector<sal_uInt16>& vPageId = {}); // SID_FILTER_DLG + void languageOptions(const std::vector<sal_uInt16>& vPageId = {}); // SID_LANGUAGE_OPTIONS + void writerOptions(const std::vector<sal_uInt16>& vPageId = {}); // SID_SW_EDITOPTIONS + void writerWebOptions(const std::vector<sal_uInt16>& vPageId = {}); // SID_SW_ONLINEOPTIONS + void calcOptions(const std::vector<sal_uInt16>& vPageId = {}); // SID_SC_EDITOPTIONS + void impressOptions(const std::vector<sal_uInt16>& vPageId = {}); // SID_SD_EDITOPTIONS + void drawOptions(const std::vector<sal_uInt16>& vPageId = {}); // SID_SD_GRAPHIC_OPTIONS + void mathOptions(const std::vector<sal_uInt16>& vPageId = {}); // SID_SM_EDITOPTIONS + void databaseOptions(const std::vector<sal_uInt16>& vPageId = {}); // SID_SB_STARBASEOPTIONS + void chartOptions(const std::vector<sal_uInt16>& vPageId = {}); // SID_SCH_EDITOPTIONS + void internetOptions(const std::vector<sal_uInt16>& vPageId = {}); // SID_INET_DLG + + void clearOptionsDialog(); + void selectFirstEntry(); + void storeOptionsTree(); + void showDialog(VectorOfMatchedIds& pSearchIds); + OUString sTitle; bool bForgetSelection; @@ -141,14 +172,13 @@ private: css::uno::Reference < css::awt::XContainerWindowProvider > m_xContainerWinProvider; + css::uno::Reference<css::frame::XFrame> m_xFrame; static LastPageSaver* pLastPageSaver; std::optional<SfxItemSet> CreateItemSet( sal_uInt16 nId ); static void ApplyItemSet( sal_uInt16 nId, const SfxItemSet& rSet ); - void InitTreeAndHandler(); void Initialize( const css::uno::Reference< css::frame::XFrame >& _xFrame ); - void InitWidgets(); void LoadExtensionOptions( std::u16string_view rExtensionId ); static OUString GetModuleIdentifier( const css::uno::Reference< @@ -163,8 +193,13 @@ private: DECL_LINK(BackHdl_Impl, weld::Button&, void); DECL_LINK(ApplyHdl_Impl, weld::Button&, void); DECL_LINK(HelpHdl_Impl, weld::Widget&, bool); + DECL_LINK(SearchUpdateHdl, weld::Entry&, void); + DECL_LINK(ImplUpdateDataHdl, Timer*, void); + DECL_LINK(FocusOut_Impl, weld::Widget&, void); void ResetCurrentPageFromConfig(); void SelectHdl_Impl(); + void initializeCurrentDialog(OptionsPageInfo*& pPageInfo, + std::unique_ptr<weld::TreeIter>& xEntry); void InitItemSets(OptionsGroupInfo& rGroupInfo); @@ -173,6 +208,13 @@ private: virtual weld::Button& GetOKButton() const override { return *xOkPB; } virtual const SfxItemSet* GetExampleSet() const override { return nullptr; } + int applySearchFilter(const OUString& rSearchTerm); + + void ImplDestroy(); + + // Common initialization + OfaTreeOptionsDialog(weld::Window* pParent, bool fromExtensionManager); + public: OfaTreeOptionsDialog(weld::Window* pParent, const css::uno::Reference< css::frame::XFrame >& _xFrame, @@ -189,8 +231,12 @@ public: void ActivatePage( const OUString& rPageURL ); void ApplyItemSets(); - // helper functions to call the language settings TabPage from the SpellDialog + // default value initializes all dialogs + void initializeFirstNDialog(sal_Int16 nNumberOfNode = -1); + + // helper functions to call the Languages and Locales TabPage from the SpellDialog static void ApplyLanguageOptions(const SfxItemSet& rSet); + static OUString getCurrentFactory_Impl( const css::uno::Reference< css::frame::XFrame >& _xFrame ); void SetNeedsRestart( svtools::RestartReason eReason ); }; @@ -219,7 +265,7 @@ private: public: ExtensionsTabPage( weld::Container* pParent, - const OUString& rPageURL, const OUString& rEvtHdl, + OUString rPageURL, OUString aEvtHdl, const css::uno::Reference< css::awt::XContainerWindowProvider >& rProvider ); @@ -235,4 +281,13 @@ public: void SavePage(); }; +// class TreeOptHelper --------------------------------------------------- + +class TreeOptHelper +{ +public: + static void storeStringsOfDialog(sal_uInt16 nPageId, const OUString& sPageStrings); + static OUString getStringsFromDialog(sal_uInt16 nPageId); +}; + /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/cui/source/inc/whatsnew.hxx b/cui/source/inc/whatsnew.hxx new file mode 100644 index 000000000000..979fff919df2 --- /dev/null +++ b/cui/source/inc/whatsnew.hxx @@ -0,0 +1,79 @@ +/* -*- 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/. + */ + +#pragma once + +#include <vcl/customweld.hxx> +#include <vcl/weld.hxx> +#include "cuigrfflt.hxx" + +class WhatsNewImg : public weld::CustomWidgetController +{ + OUString m_sImage; + OUString m_sText; + virtual void Paint(vcl::RenderContext& rRenderContext, const tools::Rectangle&) override; + +public: + WhatsNewImg() {} + void Update(const OUString& sImage, const OUString& sText) + { + m_sImage = sImage; + m_sText = sText; + SetAccessibleName(m_sText); + Invalidate(); + } +}; + +class WhatsNewProgress : public weld::CustomWidgetController +{ + sal_Int32 m_nTotal; + sal_Int32 m_nCurrent; + virtual void Paint(vcl::RenderContext& rRenderContext, const tools::Rectangle&) override; + +public: + WhatsNewProgress() + : m_nTotal(0) + , m_nCurrent(0) + { + } + void Update(const sal_Int32 nCurrent, const sal_Int32 nTotal) + { + m_nTotal = nTotal; + m_nCurrent = nCurrent; + Invalidate(); + } +}; + +class WhatsNewDialog : public weld::GenericDialogController +{ +private: + const bool m_bWelcome; + + WhatsNewImg m_aPreview; + WhatsNewProgress m_aProgress; + + std::unique_ptr<weld::Button> m_pPrevBtn; + std::unique_ptr<weld::Button> m_pNextBtn; + std::unique_ptr<weld::CustomWeld> m_pProgress; + std::unique_ptr<weld::CustomWeld> m_pImage; + + DECL_LINK(OnPrevClick, weld::Button&, void); + DECL_LINK(OnNextClick, weld::Button&, void); + + void LoadImage(); // loads WHATSNEW_STRINGARRAY[m_nCurrentNews] + + sal_Int32 m_nNumberOfNews; + sal_Int32 m_nCurrentNews; + +public: + WhatsNewDialog(weld::Window* pParent, const bool bWelcome); + virtual ~WhatsNewDialog() override; +}; + +/* vim:set shiftwidth=4 softtabstop=4 expandtab cinoptions=b1,g0,N-s cinkeys+=0=break: */ diff --git a/cui/source/options/certpath.cxx b/cui/source/options/certpath.cxx index 0932ac2e7a84..5cccccf1995c 100644 --- a/cui/source/options/certpath.cxx +++ b/cui/source/options/certpath.cxx @@ -11,12 +11,12 @@ #include <osl/file.hxx> #include <osl/security.hxx> #include <sfx2/filedlghelper.hxx> -#include <tools/diagnose_ex.h> +#include <comphelper/diagnose_ex.hxx> #include "certpath.hxx" #include <com/sun/star/xml/crypto/NSSInitializer.hpp> #include <com/sun/star/ui/dialogs/ExecutableDialogResults.hpp> -#include <com/sun/star/ui/dialogs/FolderPicker.hpp> +#include <com/sun/star/ui/dialogs/XFolderPicker2.hpp> #include <comphelper/processfactory.hxx> using namespace ::com::sun::star; @@ -60,7 +60,7 @@ void CertPathDialog::Init() "thunderbird" }; - for (const auto& rNSSProfile : std::as_const(aProductList)) + for (const auto& rNSSProfile : aProductList) { if (rNSSProfile.Type == mozilla::MozillaProductType_Default) { diff --git a/cui/source/options/cfgchart.cxx b/cui/source/options/cfgchart.cxx index 5649c4ea53f3..8d1bd5e4130e 100644 --- a/cui/source/options/cfgchart.cxx +++ b/cui/source/options/cfgchart.cxx @@ -23,6 +23,8 @@ #include "cfgchart.hxx" #include <dialmgr.hxx> #include <strings.hrc> +#include <utility> +#include <officecfg/Office/Chart.hxx> #define ROW_COLOR_COUNT 12 @@ -115,14 +117,14 @@ OUString SvxChartColorTable::getDefaultName( size_t _nIndex ) { OUString aName; - OUString sDefaultNamePrefix; - OUString sDefaultNamePostfix; - OUString aResName( CuiResId( RID_SVXSTR_DIAGRAM_ROW ) ); + std::u16string_view sDefaultNamePrefix; + std::u16string_view sDefaultNamePostfix; + OUString aResName( CuiResId( RID_CUISTR_DIAGRAM_ROW ) ); sal_Int32 nPos = aResName.indexOf( "$(ROW)" ); if( nPos != -1 ) { - sDefaultNamePrefix = aResName.copy( 0, nPos ); - sDefaultNamePostfix = aResName.copy( nPos + sizeof( "$(ROW)" ) - 1 ); + sDefaultNamePrefix = aResName.subView( 0, nPos ); + sDefaultNamePostfix = aResName.subView( nPos + sizeof( "$(ROW)" ) - 1 ); } else { @@ -158,109 +160,63 @@ bool SvxChartColorTable::operator==( const SvxChartColorTable & _rOther ) const -SvxChartOptions::SvxChartOptions() : - ::utl::ConfigItem( "Office.Chart" ), - mbIsInitialized( false ), - maPropertyNames{ "DefaultColor/Series" } +SvxChartColorTable SvxChartOptions::GetDefaultColors() { -} + // 1. default colors for series + uno::Sequence< sal_Int64 > aColorSeq = officecfg::Office::Chart::DefaultColor::Series::get(); -SvxChartOptions::~SvxChartOptions() -{ -} - -const SvxChartColorTable& SvxChartOptions::GetDefaultColors() -{ - if ( !mbIsInitialized ) - mbIsInitialized = RetrieveOptions(); - return maDefColors; -} - -void SvxChartOptions::SetDefaultColors( const SvxChartColorTable& aCol ) -{ - maDefColors = aCol; - SetModified(); -} + sal_Int32 nCount = aColorSeq.getLength(); + Color aCol; -bool SvxChartOptions::RetrieveOptions() -{ - // get sequence containing all properties - - uno::Sequence< OUString > aNames = GetPropertyNames(); - uno::Sequence< uno::Any > aProperties( aNames.getLength()); - aProperties = GetProperties( aNames ); - - if( aProperties.getLength() == aNames.getLength()) + // create strings for entry names + OUString aResName( CuiResId( RID_CUISTR_DIAGRAM_ROW ) ); + std::u16string_view aPrefix, aPostfix; + OUString aName; + sal_Int32 nPos = aResName.indexOf( "$(ROW)" ); + if( nPos != -1 ) { - // 1. default colors for series - maDefColors.clear(); - uno::Sequence< sal_Int64 > aColorSeq; - aProperties[ 0 ] >>= aColorSeq; - - sal_Int32 nCount = aColorSeq.getLength(); - Color aCol; - - // create strings for entry names - OUString aResName( CuiResId( RID_SVXSTR_DIAGRAM_ROW ) ); - OUString aPrefix, aPostfix, aName; - sal_Int32 nPos = aResName.indexOf( "$(ROW)" ); - if( nPos != -1 ) - { - aPrefix = aResName.copy( 0, nPos ); - sal_Int32 idx = nPos + sizeof( "$(ROW)" ) - 1; - aPostfix = aResName.copy( idx ); - } - else - aPrefix = aResName; - - // set color values - for( sal_Int32 i=0; i < nCount; i++ ) - { - aCol = Color(ColorTransparency, aColorSeq[ i ]); - - aName = aPrefix + OUString::number(i + 1) + aPostfix; - - maDefColors.append( XColorEntry( aCol, aName )); - } - return true; + aPrefix = aResName.subView( 0, nPos ); + sal_Int32 idx = nPos + sizeof( "$(ROW)" ) - 1; + aPostfix = aResName.subView( idx ); } - return false; -} - -void SvxChartOptions::ImplCommit() -{ - uno::Sequence< OUString > aNames = GetPropertyNames(); - uno::Sequence< uno::Any > aValues( aNames.getLength()); + else + aPrefix = aResName; - if( aValues.hasElements() ) + // set color values + SvxChartColorTable aDefColors; + for( sal_Int32 i=0; i < nCount; i++ ) { - // 1. default colors for series - // convert list to sequence - const size_t nCount = maDefColors.size(); - uno::Sequence< sal_Int64 > aColors( nCount ); - auto aColorsRange = asNonConstRange(aColors); - for( size_t i=0; i < nCount; i++ ) - { - Color aData = maDefColors.getColor( i ); - aColorsRange[ i ] = sal_uInt32(aData); - } + aCol = Color(ColorTransparency, aColorSeq[ i ]); + + aName = aPrefix + OUString::number(i + 1) + aPostfix; - aValues.getArray()[0] <<= aColors; + aDefColors.append( XColorEntry( aCol, aName )); } - PutProperties( aNames, aValues ); + return aDefColors; } -void SvxChartOptions::Notify( const css::uno::Sequence< OUString >& ) +void SvxChartOptions::SetDefaultColors( const SvxChartColorTable& rDefColors ) { + // 1. default colors for series + // convert list to sequence + const size_t nCount = rDefColors.size(); + uno::Sequence< sal_Int64 > aColors( nCount ); + auto aColorsRange = asNonConstRange(aColors); + for( size_t i=0; i < nCount; i++ ) + { + Color aData = rDefColors.getColor( i ); + aColorsRange[ i ] = sal_uInt32(aData); + } + std::shared_ptr<comphelper::ConfigurationChanges> batch(comphelper::ConfigurationChanges::create()); + officecfg::Office::Chart::DefaultColor::Series::set(aColors, batch); + batch->commit(); } - - -SvxChartColorTableItem::SvxChartColorTableItem( sal_uInt16 nWhich_, const SvxChartColorTable& aTable ) : +SvxChartColorTableItem::SvxChartColorTableItem( sal_uInt16 nWhich_, SvxChartColorTable aTable ) : SfxPoolItem( nWhich_ ), - m_aColorTable( aTable ) + m_aColorTable(std::move( aTable )) { } diff --git a/cui/source/options/cfgchart.hxx b/cui/source/options/cfgchart.hxx index acbe41a9b41e..ce39b0a1734a 100644 --- a/cui/source/options/cfgchart.hxx +++ b/cui/source/options/cfgchart.hxx @@ -19,10 +19,8 @@ #pragma once -#include <unotools/configitem.hxx> #include <svl/poolitem.hxx> #include <svx/xtable.hxx> - #include <vector> class SvxChartColorTable @@ -51,29 +49,10 @@ public: // all options -class SvxChartOptions : public ::utl::ConfigItem +namespace SvxChartOptions { -private: - SvxChartColorTable maDefColors; - bool mbIsInitialized; - - css::uno::Sequence< OUString > - maPropertyNames; - - const css::uno::Sequence< OUString >& GetPropertyNames() const - { return maPropertyNames; } - bool RetrieveOptions(); - - virtual void ImplCommit() override; - -public: - SvxChartOptions(); - virtual ~SvxChartOptions() override; - - const SvxChartColorTable& GetDefaultColors(); - void SetDefaultColors( const SvxChartColorTable& aCol ); - - virtual void Notify( const css::uno::Sequence< OUString >& _rPropertyNames) override; + SvxChartColorTable GetDefaultColors(); + void SetDefaultColors( const SvxChartColorTable& aCol ); }; @@ -86,7 +65,7 @@ public: class SvxChartColorTableItem : public SfxPoolItem { public: - SvxChartColorTableItem( sal_uInt16 nWhich, const SvxChartColorTable& ); + SvxChartColorTableItem( sal_uInt16 nWhich, SvxChartColorTable ); virtual SvxChartColorTableItem* Clone( SfxItemPool *pPool = nullptr ) const override; virtual bool operator==( const SfxPoolItem& ) const override; diff --git a/cui/source/options/connpoolconfig.cxx b/cui/source/options/connpoolconfig.cxx index 8bf95ee0db5d..0d0f45be10b9 100644 --- a/cui/source/options/connpoolconfig.cxx +++ b/cui/source/options/connpoolconfig.cxx @@ -36,50 +36,21 @@ namespace offapp using namespace ::utl; using namespace ::com::sun::star::uno; - - static OUString getConnectionPoolNodeName() - { - return "org.openoffice.Office.DataAccess/ConnectionPool"; - } - - - static OUString getEnablePoolingNodeName() - { - return "EnablePooling"; - } - - - static OUString getDriverSettingsNodeName() - { - return "DriverSettings"; - } - - - static OUString getDriverNameNodeName() - { - return "DriverName"; - } - - - static OUString getEnableNodeName() - { - return "Enable"; - } - - - static OUString getTimeoutNodeName() - { - return "Timeout"; - } + constexpr OUString CONNECTIONPOOL_NODENAME = u"org.openoffice.Office.DataAccess/ConnectionPool"_ustr; + constexpr OUString ENABLE_POOLING = u"EnablePooling"_ustr; + constexpr OUString DRIVER_SETTINGS = u"DriverSettings"_ustr; + constexpr OUString DRIVER_NAME = u"DriverName"_ustr; + constexpr OUString ENABLE = u"Enable"_ustr; + constexpr OUString TIMEOUT = u"Timeout"_ustr; void ConnectionPoolConfig::GetOptions(SfxItemSet& _rFillItems) { // the config node where all pooling relevant info are stored under OConfigurationTreeRoot aConnectionPoolRoot = OConfigurationTreeRoot::createWithComponentContext( - ::comphelper::getProcessComponentContext(), getConnectionPoolNodeName(), -1, OConfigurationTreeRoot::CM_READONLY); + ::comphelper::getProcessComponentContext(), CONNECTIONPOOL_NODENAME, -1, OConfigurationTreeRoot::CM_READONLY); // the global "enabled" flag - Any aEnabled = aConnectionPoolRoot.getNodeValue(getEnablePoolingNodeName()); + Any aEnabled = aConnectionPoolRoot.getNodeValue(ENABLE_POOLING); bool bEnabled = true; aEnabled >>= bEnabled; _rFillItems.Put(SfxBoolItem(SID_SB_POOLING_ENABLED, bEnabled)); @@ -94,7 +65,7 @@ namespace offapp } // then look for which of them settings are stored in the configuration - OConfigurationNode aDriverSettings = aConnectionPoolRoot.openNode(getDriverSettingsNodeName()); + OConfigurationNode aDriverSettings = aConnectionPoolRoot.openNode(DRIVER_SETTINGS); Sequence< OUString > aDriverKeys = aDriverSettings.getNodeNames(); const OUString* pDriverKeys = aDriverKeys.getConstArray(); @@ -104,7 +75,7 @@ namespace offapp // the name of the driver in this round OConfigurationNode aThisDriverSettings = aDriverSettings.openNode(*pDriverKeys); OUString sThisDriverName; - aThisDriverSettings.getNodeValue(getDriverNameNodeName()) >>= sThisDriverName; + aThisDriverSettings.getNodeValue(DRIVER_NAME) >>= sThisDriverName; // look if we (resp. the driver manager) know this driver // doing O(n) search here, which is expensive, but this doesn't matter in this small case ... @@ -126,8 +97,8 @@ namespace offapp } // now fill this entry with the settings from the configuration - aThisDriverSettings.getNodeValue(getEnableNodeName()) >>= aLookup->bEnabled; - aThisDriverSettings.getNodeValue(getTimeoutNodeName()) >>= aLookup->nTimeoutSeconds; + aThisDriverSettings.getNodeValue(ENABLE) >>= aLookup->bEnabled; + aThisDriverSettings.getNodeValue(TIMEOUT) >>= aLookup->nTimeoutSeconds; } _rFillItems.Put(DriverPoolingSettingsItem(SID_SB_DRIVER_TIMEOUTS, aSettings)); @@ -138,7 +109,7 @@ namespace offapp { // the config node where all pooling relevant info are stored under OConfigurationTreeRoot aConnectionPoolRoot = OConfigurationTreeRoot::createWithComponentContext( - ::comphelper::getProcessComponentContext(), getConnectionPoolNodeName()); + ::comphelper::getProcessComponentContext(), CONNECTIONPOOL_NODENAME); if (!aConnectionPoolRoot.isValid()) // already asserted by the OConfigurationTreeRoot @@ -151,7 +122,7 @@ namespace offapp if (pEnabled) { bool bEnabled = pEnabled->GetValue(); - aConnectionPoolRoot.setNodeValue(getEnablePoolingNodeName(), Any(bEnabled)); + aConnectionPoolRoot.setNodeValue(ENABLE_POOLING, Any(bEnabled)); bNeedCommit = true; } @@ -159,7 +130,7 @@ namespace offapp const DriverPoolingSettingsItem* pDriverSettings = _rSourceItems.GetItem<DriverPoolingSettingsItem>(SID_SB_DRIVER_TIMEOUTS); if (pDriverSettings) { - OConfigurationNode aDriverSettings = aConnectionPoolRoot.openNode(getDriverSettingsNodeName()); + OConfigurationNode aDriverSettings = aConnectionPoolRoot.openNode(DRIVER_SETTINGS); if (!aDriverSettings.isValid()) return; @@ -179,9 +150,9 @@ namespace offapp aThisDriverSettings = aDriverSettings.createNode(newSetting.sName); // set the values - aThisDriverSettings.setNodeValue(getDriverNameNodeName(), Any(sThisDriverName)); - aThisDriverSettings.setNodeValue(getEnableNodeName(), Any(newSetting.bEnabled)); - aThisDriverSettings.setNodeValue(getTimeoutNodeName(), Any(newSetting.nTimeoutSeconds)); + aThisDriverSettings.setNodeValue(DRIVER_NAME, Any(sThisDriverName)); + aThisDriverSettings.setNodeValue(ENABLE, Any(newSetting.bEnabled)); + aThisDriverSettings.setNodeValue(TIMEOUT, Any(newSetting.nTimeoutSeconds)); } bNeedCommit = true; } diff --git a/cui/source/options/connpooloptions.cxx b/cui/source/options/connpooloptions.cxx index 1e1fa02a5529..f6321f2252b1 100644 --- a/cui/source/options/connpooloptions.cxx +++ b/cui/source/options/connpooloptions.cxx @@ -25,6 +25,8 @@ #include <svx/databaseregistrationui.hxx> #include <strings.hrc> #include <dialmgr.hxx> +#include <officecfg/Office/DataAccess.hxx> +#include <com/sun/star/beans/PropertyAttribute.hpp> namespace offapp { @@ -46,16 +48,19 @@ namespace offapp ConnectionPoolOptionsPage::ConnectionPoolOptionsPage(weld::Container* pPage, weld::DialogController* pController, const SfxItemSet& _rAttrSet) : SfxTabPage(pPage, pController, "cui/ui/connpooloptions.ui", "ConnPoolPage", &_rAttrSet) - , m_sYes(CuiResId(RID_SVXSTR_YES)) - , m_sNo(CuiResId(RID_SVXSTR_NO)) + , m_sYes(CuiResId(RID_CUISTR_YES)) + , m_sNo(CuiResId(RID_CUISTR_NO)) , m_xEnablePooling(m_xBuilder->weld_check_button("connectionpooling")) + , m_xEnablePoolingImg(m_xBuilder->weld_widget("lockconnectionpooling")) , m_xDriversLabel(m_xBuilder->weld_label("driverslabel")) , m_xDriverList(m_xBuilder->weld_tree_view("driverlist")) , m_xDriverLabel(m_xBuilder->weld_label("driverlabel")) , m_xDriver(m_xBuilder->weld_label("driver")) , m_xDriverPoolingEnabled(m_xBuilder->weld_check_button("enablepooling")) + , m_xDriverPoolingEnabledImg(m_xBuilder->weld_widget("lockenablepooling")) , m_xTimeoutLabel(m_xBuilder->weld_label("timeoutlabel")) , m_xTimeout(m_xBuilder->weld_spin_button("timeout")) + , m_xTimeoutImg(m_xBuilder->weld_widget("locktimeout")) { m_xDriverList->set_size_request(m_xDriverList->get_approximate_digit_width() * 60, m_xDriverList->get_height_rows(15)); @@ -68,6 +73,9 @@ namespace offapp }; m_xDriverList->set_column_fixed_widths(aWidths); + css::uno::Reference < css::uno::XComponentContext > xContext(::comphelper::getProcessComponentContext()); + m_xReadWriteAccess = css::configuration::ReadWriteAccess::create(xContext, "*"); + m_xEnablePooling->connect_toggled( LINK(this, ConnectionPoolOptionsPage, OnEnabledDisabled) ); m_xDriverPoolingEnabled->connect_toggled( LINK(this, ConnectionPoolOptionsPage, OnEnabledDisabled) ); @@ -136,6 +144,8 @@ namespace offapp const SfxBoolItem* pEnabled = _rSet.GetItem<SfxBoolItem>(SID_SB_POOLING_ENABLED); OSL_ENSURE(pEnabled, "ConnectionPoolOptionsPage::implInitControls: missing the Enabled item!"); m_xEnablePooling->set_active(pEnabled == nullptr || pEnabled->GetValue()); + m_xEnablePooling->set_sensitive(!officecfg::Office::DataAccess::ConnectionPool::EnablePooling::isReadOnly()); + m_xEnablePoolingImg->set_visible(officecfg::Office::DataAccess::ConnectionPool::EnablePooling::isReadOnly()); m_xEnablePooling->save_state(); @@ -145,7 +155,7 @@ namespace offapp UpdateDriverList(pDriverSettings->getSettings()); else { - OSL_FAIL("ConnectionPoolOptionsPage::implInitControls: missing the DriverTimeouts item!"); + SAL_WARN("cui.options", "ConnectionPoolOptionsPage::implInitControls: missing the DriverTimeouts item!"); UpdateDriverList(DriverPoolingSettings()); } saveDriverList(); @@ -159,6 +169,28 @@ namespace offapp commitTimeoutField(); } + OUString ConnectionPoolOptionsPage::GetAllStrings() + { + OUString sAllStrings; + OUString labels[] = { "label1", "driverslabel", "driverlabel", "timeoutlabel", "driver" }; + + for (const auto& label : labels) + { + if (const auto& pString = m_xBuilder->weld_label(label)) + sAllStrings += pString->get_label() + " "; + } + + OUString checkButton[] = { "connectionpooling", "enablepooling" }; + + for (const auto& check : checkButton) + { + if (const auto& pString = m_xBuilder->weld_check_button(check)) + sAllStrings += pString->get_label() + " "; + } + + return sAllStrings.replaceAll("_", ""); + } + bool ConnectionPoolOptionsPage::FillItemSet(SfxItemSet* _rSet) { commitTimeoutField(); @@ -211,6 +243,20 @@ namespace offapp m_xDriverPoolingEnabled->set_active(currentSetting.bEnabled); m_xTimeout->set_value(currentSetting.nTimeoutSeconds); + OUString aConfigPath = officecfg::Office::DataAccess::ConnectionPool::DriverSettings::path() + "/" + currentSetting.sName; + css::beans::Property aProperty = m_xReadWriteAccess->getPropertyByHierarchicalName(aConfigPath + "/Enable"); + bool bReadOnly = (aProperty.Attributes & css::beans::PropertyAttribute::READONLY) != 0; + + m_xDriverPoolingEnabled->set_sensitive(!bReadOnly); + m_xDriverPoolingEnabledImg->set_visible(bReadOnly); + + aProperty = m_xReadWriteAccess->getPropertyByHierarchicalName(aConfigPath + "/Timeout"); + bReadOnly = (aProperty.Attributes & css::beans::PropertyAttribute::READONLY) != 0; + + m_xTimeout->set_sensitive(!bReadOnly); + m_xTimeoutLabel->set_sensitive(!bReadOnly); + m_xTimeoutImg->set_visible(bReadOnly); + OnEnabledDisabled(*m_xDriverPoolingEnabled); } } @@ -237,13 +283,13 @@ namespace offapp m_xDriverList->select(-1); m_xDriverLabel->set_sensitive(bGloballyEnabled); m_xDriver->set_sensitive(bGloballyEnabled); - m_xDriverPoolingEnabled->set_sensitive(bGloballyEnabled); + m_xDriverPoolingEnabled->set_sensitive(bGloballyEnabled && !m_xDriverPoolingEnabledImg->get_visible()); } else OSL_ENSURE(bLocalDriverChanged, "ConnectionPoolOptionsPage::OnEnabledDisabled: where did this come from?"); - m_xTimeoutLabel->set_sensitive(bGloballyEnabled && m_xDriverPoolingEnabled->get_active()); - m_xTimeout->set_sensitive(bGloballyEnabled && m_xDriverPoolingEnabled->get_active()); + m_xTimeoutLabel->set_sensitive(bGloballyEnabled && m_xDriverPoolingEnabled->get_active() && !m_xTimeoutImg->get_visible()); + m_xTimeout->set_sensitive(bGloballyEnabled && m_xDriverPoolingEnabled->get_active() && !m_xTimeoutImg->get_visible()); if (bLocalDriverChanged) { diff --git a/cui/source/options/connpooloptions.hxx b/cui/source/options/connpooloptions.hxx index 549448e21ff6..2413f0d16de3 100644 --- a/cui/source/options/connpooloptions.hxx +++ b/cui/source/options/connpooloptions.hxx @@ -20,6 +20,7 @@ #pragma once #include <sfx2/tabdlg.hxx> +#include <com/sun/star/configuration/ReadWriteAccess.hpp> #include "connpoolsettings.hxx" @@ -32,19 +33,25 @@ namespace offapp DriverPoolingSettings m_aSettings; DriverPoolingSettings m_aSavedSettings; + css::uno::Reference< css::configuration::XReadWriteAccess> m_xReadWriteAccess; + std::unique_ptr<weld::CheckButton> m_xEnablePooling; + std::unique_ptr<weld::Widget> m_xEnablePoolingImg; std::unique_ptr<weld::Label> m_xDriversLabel; std::unique_ptr<weld::TreeView> m_xDriverList; std::unique_ptr<weld::Label> m_xDriverLabel; std::unique_ptr<weld::Label> m_xDriver; std::unique_ptr<weld::CheckButton> m_xDriverPoolingEnabled; + std::unique_ptr<weld::Widget> m_xDriverPoolingEnabledImg; std::unique_ptr<weld::Label> m_xTimeoutLabel; std::unique_ptr<weld::SpinButton> m_xTimeout; + std::unique_ptr<weld::Widget> m_xTimeoutImg; public: ConnectionPoolOptionsPage(weld::Container* pPage, weld::DialogController* pController, const SfxItemSet& _rAttrSet); virtual ~ConnectionPoolOptionsPage() override; static std::unique_ptr<SfxTabPage> Create(weld::Container* pPage, weld::DialogController* pController, const SfxItemSet* _rAttrSet); + virtual OUString GetAllStrings() override; private: virtual bool FillItemSet(SfxItemSet* _rSet) override; diff --git a/cui/source/options/connpoolsettings.cxx b/cui/source/options/connpoolsettings.cxx index 46742d826aa5..e92b26da555f 100644 --- a/cui/source/options/connpoolsettings.cxx +++ b/cui/source/options/connpoolsettings.cxx @@ -17,14 +17,16 @@ * the License at http://www.apache.org/licenses/LICENSE-2.0 . */ +#include <utility> + #include "connpoolsettings.hxx" namespace offapp { - DriverPooling::DriverPooling( const OUString& _rName ) - :sName(_rName) + DriverPooling::DriverPooling( OUString _aName ) + :sName(std::move(_aName)) ,bEnabled(false) ,nTimeoutSeconds(120) { @@ -43,9 +45,9 @@ namespace offapp } - DriverPoolingSettingsItem::DriverPoolingSettingsItem( sal_uInt16 _nId, const DriverPoolingSettings &_rSettings ) + DriverPoolingSettingsItem::DriverPoolingSettingsItem( sal_uInt16 _nId, DriverPoolingSettings _aSettings ) :SfxPoolItem(_nId) - ,m_aSettings(_rSettings) + ,m_aSettings(std::move(_aSettings)) { } diff --git a/cui/source/options/connpoolsettings.hxx b/cui/source/options/connpoolsettings.hxx index 8f8c6bc3b361..1e2404b88583 100644 --- a/cui/source/options/connpoolsettings.hxx +++ b/cui/source/options/connpoolsettings.hxx @@ -36,7 +36,7 @@ namespace offapp bool bEnabled; sal_Int32 nTimeoutSeconds; - explicit DriverPooling( const OUString& _rName ); + explicit DriverPooling( OUString _aName ); bool operator == (const DriverPooling& _rR) const; bool operator != (const DriverPooling& _rR) const { return !operator ==(_rR); } @@ -72,7 +72,7 @@ namespace offapp public: - DriverPoolingSettingsItem( sal_uInt16 _nId, const DriverPoolingSettings &_rSettings ); + DriverPoolingSettingsItem( sal_uInt16 _nId, DriverPoolingSettings _aSettings ); virtual bool operator==( const SfxPoolItem& ) const override; virtual DriverPoolingSettingsItem* Clone( SfxItemPool *pPool = nullptr ) const override; diff --git a/cui/source/options/dbregister.cxx b/cui/source/options/dbregister.cxx index 357a4af426c9..6aa9213efd92 100644 --- a/cui/source/options/dbregister.cxx +++ b/cui/source/options/dbregister.cxx @@ -29,6 +29,7 @@ #include <tools/debug.hxx> #include <strings.hrc> #include <bitmaps.hlst> +#include <utility> #include <vcl/svapp.hxx> #include <vcl/weld.hxx> #include <svl/itemset.hxx> @@ -36,6 +37,7 @@ #include <dialmgr.hxx> #include "dbregisterednamesconfig.hxx" #include <svx/databaseregistrationui.hxx> +#include <o3tl/string_view.hxx> #define COL_TYPE 0 @@ -43,15 +45,13 @@ namespace svx { -using namespace ::com::sun::star::lang; using namespace ::com::sun::star::ui::dialogs; -using namespace ::com::sun::star::uno; using namespace ::svt; // class RegistrationItemSetHolder ------------------------------------------------- -RegistrationItemSetHolder::RegistrationItemSetHolder( const SfxItemSet& _rMasterSet ) - :m_aRegistrationItems( _rMasterSet ) +RegistrationItemSetHolder::RegistrationItemSetHolder( SfxItemSet _aMasterSet ) + :m_aRegistrationItems(std::move( _aMasterSet )) { DbRegisteredNamesConfig::GetOptions( m_aRegistrationItems ); } @@ -67,7 +67,7 @@ DatabaseRegistrationDialog::DatabaseRegistrationDialog(weld::Window* pParent, co , SfxSingleTabDialogController(pParent, &getRegistrationItems()) { SetTabPage(DbRegistrationOptionsPage::Create(get_content_area(), this, &getRegistrationItems())); - m_xDialog->set_title(CuiResId(RID_SVXSTR_REGISTERED_DATABASES)); + m_xDialog->set_title(CuiResId(RID_CUISTR_REGISTERED_DATABASES)); } short DatabaseRegistrationDialog::run() @@ -120,7 +120,7 @@ DbRegistrationOptionsPage::DbRegistrationOptionsPage(weld::Container* pPage, wel DbRegistrationOptionsPage::~DbRegistrationOptionsPage() { for (int i = 0, nCount = m_xPathBox->n_children(); i < nCount; ++i ) - delete reinterpret_cast<DatabaseRegistration*>(m_xPathBox->get_id(i).toInt64()); + delete weld::fromId<DatabaseRegistration*>(m_xPathBox->get_id(i)); } std::unique_ptr<SfxTabPage> DbRegistrationOptionsPage::Create( weld::Container* pPage, weld::DialogController* pController, @@ -129,6 +129,16 @@ std::unique_ptr<SfxTabPage> DbRegistrationOptionsPage::Create( weld::Container* return std::make_unique<DbRegistrationOptionsPage>(pPage, pController, *rAttrSet); } +OUString DbRegistrationOptionsPage::GetAllStrings() +{ + OUString sAllStrings; + + if (const auto& pString = m_xBuilder->weld_label("label1")) + sAllStrings += pString->get_label() + " "; + + return sAllStrings.replaceAll("_", ""); +} + bool DbRegistrationOptionsPage::FillItemSet( SfxItemSet* rCoreSet ) { // the settings for the single drivers @@ -137,7 +147,7 @@ bool DbRegistrationOptionsPage::FillItemSet( SfxItemSet* rCoreSet ) int nCount = m_xPathBox->n_children(); for (int i = 0; i < nCount; ++i) { - DatabaseRegistration* pRegistration = reinterpret_cast<DatabaseRegistration*>(m_xPathBox->get_id(i).toInt64()); + DatabaseRegistration* pRegistration = weld::fromId<DatabaseRegistration*>(m_xPathBox->get_id(i)); if ( pRegistration && !pRegistration->sLocation.isEmpty() ) { OUString sName(m_xPathBox->get_text(i, 0)); @@ -179,11 +189,11 @@ void DbRegistrationOptionsPage::Reset( const SfxItemSet* rSet ) // restore column width std::vector<int> aWidths { - aUserData.getToken(0, ';', nIdx).toInt32() + o3tl::toInt32(o3tl::getToken(aUserData, 0, ';', nIdx)) }; m_xPathBox->set_column_fixed_widths(aWidths); // restore sort direction - bool bUp = aUserData.getToken(0, ';', nIdx).toInt32() != 0; + bool bUp = o3tl::toInt32(o3tl::getToken(aUserData, 0, ';', nIdx)) != 0; m_xPathBox->set_sort_order(bUp); m_xPathBox->set_sort_indicator(bUp ? TRISTATE_TRUE : TRISTATE_FALSE, COL_TYPE); } @@ -202,7 +212,7 @@ IMPL_LINK_NOARG(DbRegistrationOptionsPage, DeleteHdl, weld::Button&, void) if (nEntry != -1) { std::unique_ptr<weld::MessageDialog> xQuery(Application::CreateMessageDialog(GetFrameWeld(), - VclMessageType::Question, VclButtonsType::YesNo, CuiResId(RID_SVXSTR_QUERY_DELETE_CONFIRM))); + VclMessageType::Question, VclButtonsType::YesNo, CuiResId(RID_CUISTR_QUERY_DELETE_CONFIRM))); if (xQuery->run() == RET_YES) m_xPathBox->remove(nEntry); } @@ -225,7 +235,7 @@ IMPL_LINK_NOARG(DbRegistrationOptionsPage, EditHdl, weld::Button&, void) if (nEntry == -1) return; - DatabaseRegistration* pOldRegistration = reinterpret_cast<DatabaseRegistration*>(m_xPathBox->get_id(nEntry).toInt64()); + DatabaseRegistration* pOldRegistration = weld::fromId<DatabaseRegistration*>(m_xPathBox->get_id(nEntry)); if (!pOldRegistration || pOldRegistration->bReadOnly) return; @@ -250,7 +260,7 @@ IMPL_LINK( DbRegistrationOptionsPage, HeaderSelect_Impl, int, nCol, void ) IMPL_LINK_NOARG(DbRegistrationOptionsPage, PathSelect_Impl, weld::TreeView&, void) { - DatabaseRegistration* pRegistration = reinterpret_cast<DatabaseRegistration*>(m_xPathBox->get_selected_id().toInt64()); + DatabaseRegistration* pRegistration = weld::fromId<DatabaseRegistration*>(m_xPathBox->get_selected_id()); bool bReadOnly = true; if (pRegistration) @@ -264,7 +274,7 @@ IMPL_LINK_NOARG(DbRegistrationOptionsPage, PathSelect_Impl, weld::TreeView&, voi void DbRegistrationOptionsPage::insertNewEntry(const OUString& _sName,const OUString& _sLocation, const bool _bReadOnly) { - OUString sId(OUString::number(reinterpret_cast<sal_Int64>(new DatabaseRegistration(_sLocation, _bReadOnly)))); + OUString sId(weld::toId(new DatabaseRegistration(_sLocation, _bReadOnly))); m_xPathBox->insert(nullptr, -1, &_sName, &sId, nullptr, nullptr, false, m_xIter.get()); if (_bReadOnly) @@ -278,7 +288,10 @@ void DbRegistrationOptionsPage::openLinkDialog(const OUString& sOldName, const O ODocumentLinkDialog aDlg(GetFrameWeld(), nEntry == -1); aDlg.setLink(sOldName, sOldLocation); - aDlg.setNameValidator(LINK( this, DbRegistrationOptionsPage, NameValidator ) ); + + // tdf#149195: control the name (ie check duplicate) only if new entry case + if (nEntry == -1) + aDlg.setNameValidator(LINK( this, DbRegistrationOptionsPage, NameValidator ) ); if (aDlg.run() != RET_OK) return; @@ -289,7 +302,7 @@ void DbRegistrationOptionsPage::openLinkDialog(const OUString& sOldName, const O { if (nEntry != -1) { - delete reinterpret_cast<DatabaseRegistration*>(m_xPathBox->get_id(nEntry).toInt64()); + delete weld::fromId<DatabaseRegistration*>(m_xPathBox->get_id(nEntry)); m_xPathBox->remove(nEntry); } insertNewEntry( sNewName, sNewLocation, false ); diff --git a/cui/source/options/dbregisterednamesconfig.cxx b/cui/source/options/dbregisterednamesconfig.cxx index b33e9ded61c5..6539506e9614 100644 --- a/cui/source/options/dbregisterednamesconfig.cxx +++ b/cui/source/options/dbregisterednamesconfig.cxx @@ -23,7 +23,7 @@ #include <com/sun/star/sdb/DatabaseContext.hpp> #include <comphelper/processfactory.hxx> #include <svl/itemset.hxx> -#include <tools/diagnose_ex.h> +#include <comphelper/diagnose_ex.hxx> namespace svx @@ -32,7 +32,6 @@ namespace svx using namespace ::com::sun::star::uno; using namespace ::com::sun::star::sdb; - using namespace ::com::sun::star::container; void DbRegisteredNamesConfig::GetOptions( SfxItemSet& _rFillItems ) { diff --git a/cui/source/options/dbregistersettings.hxx b/cui/source/options/dbregistersettings.hxx index 2f86392bc9cf..b1db16542f02 100644 --- a/cui/source/options/dbregistersettings.hxx +++ b/cui/source/options/dbregistersettings.hxx @@ -24,6 +24,7 @@ #include <map> #include <svl/poolitem.hxx> +#include <utility> namespace svx @@ -41,8 +42,8 @@ namespace svx { } - DatabaseRegistration( const OUString& _rLocation, const bool _bReadOnly ) - :sLocation( _rLocation ) + DatabaseRegistration( OUString _aLocation, const bool _bReadOnly ) + :sLocation(std::move( _aLocation )) ,bReadOnly( _bReadOnly ) { } diff --git a/cui/source/options/doclinkdialog.cxx b/cui/source/options/doclinkdialog.cxx index 4218a18a1a04..f938399140ab 100644 --- a/cui/source/options/doclinkdialog.cxx +++ b/cui/source/options/doclinkdialog.cxx @@ -20,7 +20,11 @@ #include "doclinkdialog.hxx" #include <com/sun/star/ui/dialogs/TemplateDescription.hpp> +#include <com/sun/star/beans/PropertyAttribute.hpp> +#include <com/sun/star/container/XNameAccess.hpp> +#include <com/sun/star/beans/XPropertySet.hpp> #include <comphelper/processfactory.hxx> +#include <officecfg/Office/DataAccess.hxx> #include <strings.hrc> #include <svl/filenotation.hxx> #include <vcl/svapp.hxx> @@ -51,7 +55,10 @@ namespace svx m_xURL->SetSmartProtocol(INetProtocol::File); m_xURL->DisableHistory(); - m_xURL->SetFilter("*.odb"); + m_xURL->SetFilter(u"*.odb"); + + css::uno::Reference < css::uno::XComponentContext > xContext(::comphelper::getProcessComponentContext()); + m_xReadWriteAccess = css::configuration::ReadWriteAccess::create(xContext, "*"); m_xName->connect_changed( LINK(this, ODocumentLinkDialog, OnEntryModified) ); m_xURL->connect_changed( LINK(this, ODocumentLinkDialog, OnComboBoxModified) ); @@ -81,6 +88,44 @@ namespace svx void ODocumentLinkDialog::validate( ) { m_xOK->set_sensitive((!m_xName->get_text().isEmpty()) && (!m_xURL->get_active_text().isEmpty())); + + if (m_xOK->get_sensitive()) + { + Reference<container::XNameAccess> xItemList = officecfg::Office::DataAccess::RegisteredNames::get(); + Sequence< OUString > lNodeNames = xItemList->getElementNames(); + + for (const OUString& sNodeName : lNodeNames) + { + Reference<css::beans::XPropertySet> xSet; + xItemList->getByName(sNodeName) >>= xSet; + + OUString aDatabaseName; + if (xSet->getPropertySetInfo()->hasPropertyByName("Name")) + xSet->getPropertyValue("Name") >>= aDatabaseName; + + if (!aDatabaseName.isEmpty() && m_xName->get_text() == aDatabaseName) + { + const OUString aConfigPath = officecfg::Office::DataAccess::RegisteredNames::path() + "/" + sNodeName; + if (m_xReadWriteAccess->hasPropertyByHierarchicalName(aConfigPath + "/Name")) + { + css::beans::Property aProperty = m_xReadWriteAccess->getPropertyByHierarchicalName(aConfigPath + "/Name"); + bool bReadOnly = (aProperty.Attributes & css::beans::PropertyAttribute::READONLY) != 0; + + m_xURL->set_sensitive(!bReadOnly); + m_xBrowseFile->set_sensitive(!bReadOnly); + } + + if (m_xReadWriteAccess->hasPropertyByHierarchicalName(aConfigPath + "/Location")) + { + css::beans::Property aProperty = m_xReadWriteAccess->getPropertyByHierarchicalName(aConfigPath + "/Location"); + bool bReadOnly = (aProperty.Attributes & css::beans::PropertyAttribute::READONLY) != 0; + + m_xName->set_sensitive(!bReadOnly); + } + break; + } + } + } } IMPL_LINK_NOARG(ODocumentLinkDialog, OnOk, weld::Button&, void) diff --git a/cui/source/options/doclinkdialog.hxx b/cui/source/options/doclinkdialog.hxx index 371dc6504fe9..3ea0d5027d0f 100644 --- a/cui/source/options/doclinkdialog.hxx +++ b/cui/source/options/doclinkdialog.hxx @@ -21,6 +21,7 @@ #include <vcl/weld.hxx> #include <svtools/inettbc.hxx> +#include <com/sun/star/configuration/ReadWriteAccess.hpp> namespace svx { @@ -30,6 +31,8 @@ namespace svx { Link<const OUString&,bool> m_aNameValidator; + css::uno::Reference< css::configuration::XReadWriteAccess> m_xReadWriteAccess; + std::unique_ptr<weld::Button> m_xBrowseFile; std::unique_ptr<weld::Entry> m_xName; std::unique_ptr<weld::Button> m_xOK; diff --git a/cui/source/options/fontsubs.cxx b/cui/source/options/fontsubs.cxx index 67a34dec489e..4d61a873e264 100644 --- a/cui/source/options/fontsubs.cxx +++ b/cui/source/options/fontsubs.cxx @@ -35,14 +35,20 @@ SvxFontSubstTabPage::SvxFontSubstTabPage(weld::Container* pPage, weld::DialogController* pController, const SfxItemSet& rSet) : SfxTabPage(pPage, pController, "cui/ui/optfontspage.ui", "OptFontsPage", &rSet) , m_xUseTableCB(m_xBuilder->weld_check_button("usetable")) + , m_xUseTableImg(m_xBuilder->weld_widget("lockusetable")) , m_xFont1CB(m_xBuilder->weld_combo_box("font1")) , m_xFont2CB(m_xBuilder->weld_combo_box("font2")) , m_xApply(m_xBuilder->weld_button("apply")) , m_xDelete(m_xBuilder->weld_button("delete")) , m_xCheckLB(m_xBuilder->weld_tree_view("checklb")) , m_xFontNameLB(m_xBuilder->weld_combo_box("fontname")) + , m_xFontNameLabel(m_xBuilder->weld_label("label8")) + , m_xFontNameImg(m_xBuilder->weld_widget("lockfontname")) , m_xNonPropFontsOnlyCB(m_xBuilder->weld_check_button("nonpropfontonly")) + , m_xNonPropFontsOnlyImg(m_xBuilder->weld_widget("locknonpropfontonly")) , m_xFontHeightLB(m_xBuilder->weld_combo_box("fontheight")) + , m_xFontHeightLabel(m_xBuilder->weld_label("label9")) + , m_xFontHeightImg(m_xBuilder->weld_widget("lockfontheight")) { m_xFont1CB->make_sorted(); m_xFont1CB->set_size_request(1, -1); @@ -140,6 +146,28 @@ std::unique_ptr<SfxTabPage> SvxFontSubstTabPage::Create( weld::Container* pPage, return std::make_unique<SvxFontSubstTabPage>(pPage, pController, *rAttrSet); } +OUString SvxFontSubstTabPage::GetAllStrings() +{ + OUString sAllStrings; + OUString labels[] = { "label4", "label2", "label3", "label1", "label8", "label9" }; + + for (const auto& label : labels) + { + if (const auto& pString = m_xBuilder->weld_label(label)) + sAllStrings += pString->get_label() + " "; + } + + OUString checkButton[] = { "usetable", "nonpropfontonly" }; + + for (const auto& check : checkButton) + { + if (const auto& pString = m_xBuilder->weld_check_button(check)) + sAllStrings += pString->get_label() + " "; + } + + return sAllStrings.replaceAll("_", ""); +} + bool SvxFontSubstTabPage::FillItemSet( SfxItemSet* ) { std::vector<SubstitutionStruct> aNewFontSubs; @@ -200,18 +228,20 @@ void SvxFontSubstTabPage::Reset( const SfxItemSet* ) m_xFont2CB->thaw(); m_xFont1CB->thaw(); + bool bEnable = !officecfg::Office::Common::Font::Substitution::Replacement::isReadOnly(); m_xUseTableCB->set_active(svtools::IsFontSubstitutionsEnabled()); + m_xUseTableCB->set_sensitive(bEnable); + m_xUseTableImg->set_visible(!bEnable); std::vector<SubstitutionStruct> aFontSubs = svtools::GetFontSubstitutions(); std::unique_ptr<weld::TreeIter> xIter(m_xCheckLB->make_iterator()); - for (sal_Int32 i = 0; i < static_cast<sal_Int32>(aFontSubs.size()); ++i) + for (auto const & sub: aFontSubs) { m_xCheckLB->append(xIter.get()); - const SubstitutionStruct* pSubs = &aFontSubs[i]; - m_xCheckLB->set_toggle(*xIter, pSubs->bReplaceAlways ? TRISTATE_TRUE : TRISTATE_FALSE, 0); - m_xCheckLB->set_toggle(*xIter, pSubs->bReplaceOnScreenOnly ? TRISTATE_TRUE : TRISTATE_FALSE, 1); - m_xCheckLB->set_text(*xIter, pSubs->sFont, 2); - m_xCheckLB->set_text(*xIter, pSubs->sReplaceBy, 3); + m_xCheckLB->set_toggle(*xIter, sub.bReplaceAlways ? TRISTATE_TRUE : TRISTATE_FALSE, 0); + m_xCheckLB->set_toggle(*xIter, sub.bReplaceOnScreenOnly ? TRISTATE_TRUE : TRISTATE_FALSE, 1); + m_xCheckLB->set_text(*xIter, sub.sFont, 2); + m_xCheckLB->set_text(*xIter, sub.sReplaceBy, 3); } m_xCheckLB->thaw(); @@ -238,6 +268,19 @@ void SvxFontSubstTabPage::Reset( const SfxItemSet* ) OUString::number( officecfg::Office::Common::Font::SourceViewFont::FontHeight:: get())); + + bEnable = !officecfg::Office::Common::Font::SourceViewFont::FontName::isReadOnly(); + m_xFontNameLB->set_sensitive(bEnable); + m_xFontNameLabel->set_sensitive(bEnable); + m_xFontNameImg->set_visible(!bEnable); + + m_xNonPropFontsOnlyCB->set_sensitive(bEnable); + m_xNonPropFontsOnlyImg->set_visible(!bEnable); + + m_xFontHeightLB->set_sensitive(bEnable); + m_xFontHeightLabel->set_sensitive(bEnable); + m_xFontHeightImg->set_visible(!bEnable); + m_xNonPropFontsOnlyCB->save_state(); m_xFontHeightLB->save_value(); } @@ -374,7 +417,7 @@ IMPL_LINK(SvxFontSubstTabPage, NonPropFontsHdl, weld::Toggleable&, rBox, void) void SvxFontSubstTabPage::CheckEnable() { - bool bEnableAll = m_xUseTableCB->get_active(); + bool bEnableAll = m_xUseTableCB->get_active() && !officecfg::Office::Common::Font::SourceViewFont::FontName::isReadOnly(); m_xCheckLB->set_sensitive(bEnableAll); m_xFont1CB->set_sensitive(bEnableAll); m_xFont2CB->set_sensitive(bEnableAll); diff --git a/cui/source/options/fontsubs.hxx b/cui/source/options/fontsubs.hxx index dc55d9434ba9..e91a9818e56c 100644 --- a/cui/source/options/fontsubs.hxx +++ b/cui/source/options/fontsubs.hxx @@ -28,14 +28,20 @@ class SvxFontSubstTabPage : public SfxTabPage OUString m_sAutomatic; std::unique_ptr<weld::CheckButton> m_xUseTableCB; + std::unique_ptr<weld::Widget> m_xUseTableImg; std::unique_ptr<weld::ComboBox> m_xFont1CB; std::unique_ptr<weld::ComboBox> m_xFont2CB; std::unique_ptr<weld::Button> m_xApply; std::unique_ptr<weld::Button> m_xDelete; std::unique_ptr<weld::TreeView> m_xCheckLB; std::unique_ptr<weld::ComboBox> m_xFontNameLB; + std::unique_ptr<weld::Label> m_xFontNameLabel; + std::unique_ptr<weld::Widget> m_xFontNameImg; std::unique_ptr<weld::CheckButton> m_xNonPropFontsOnlyCB; + std::unique_ptr<weld::Widget> m_xNonPropFontsOnlyImg; std::unique_ptr<weld::ComboBox> m_xFontHeightLB; + std::unique_ptr<weld::Label> m_xFontHeightLabel; + std::unique_ptr<weld::Widget> m_xFontHeightImg; DECL_LINK(SelectComboBoxHdl, weld::ComboBox&, void); DECL_LINK(ToggleHdl, weld::Toggleable&, void); @@ -54,6 +60,9 @@ public: SvxFontSubstTabPage(weld::Container* pPage, weld::DialogController* pController, const SfxItemSet& rSet); static std::unique_ptr<SfxTabPage> Create( weld::Container* pPage, weld::DialogController* pController, const SfxItemSet* rAttrSet); virtual ~SvxFontSubstTabPage() override; + + virtual OUString GetAllStrings() override; + virtual bool FillItemSet( SfxItemSet* rSet ) override; virtual void Reset( const SfxItemSet* rSet ) override; }; diff --git a/cui/source/options/optaboutconfig.cxx b/cui/source/options/optaboutconfig.cxx index 55941f765dd9..de64f45b4260 100644 --- a/cui/source/options/optaboutconfig.cxx +++ b/cui/source/options/optaboutconfig.cxx @@ -7,25 +7,40 @@ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ -#include <o3tl/safeint.hxx> #include "optaboutconfig.hxx" +#include <o3tl/safeint.hxx> +#include <o3tl/string_view.hxx> -#include <comphelper/processfactory.hxx> -#include <comphelper/sequence.hxx> -#include <com/sun/star/configuration/theDefaultProvider.hpp> -#include <com/sun/star/lang/XMultiServiceFactory.hpp> #include <com/sun/star/beans/NamedValue.hpp> +#include <com/sun/star/beans/PropertyAttribute.hpp> +#include <com/sun/star/beans/UnknownPropertyException.hpp> +#include <com/sun/star/beans/XPropertySetInfo.hpp> +#include <com/sun/star/configuration/ReadWriteAccess.hpp> +#include <com/sun/star/configuration/XDocumentation.hpp> +#include <com/sun/star/configuration/theDefaultProvider.hpp> +#include <com/sun/star/container/XHierarchicalName.hpp> #include <com/sun/star/container/XNameAccess.hpp> #include <com/sun/star/container/XNameReplace.hpp> -#include <com/sun/star/container/XHierarchicalName.hpp> -#include <com/sun/star/util/XChangesBatch.hpp> -#include <com/sun/star/util/SearchFlags.hpp> +#include <com/sun/star/lang/XMultiServiceFactory.hpp> +#include <com/sun/star/uno/Reference.hxx> +#include <com/sun/star/uno/Type.hxx> +#include <com/sun/star/uno/TypeClass.hpp> +#include <com/sun/star/util/InvalidStateException.hpp> #include <com/sun/star/util/SearchAlgorithms2.hpp> +#include <com/sun/star/util/SearchFlags.hpp> +#include <com/sun/star/util/XChangesBatch.hpp> +#include <comphelper/diagnose_ex.hxx> +#include <comphelper/processfactory.hxx> +#include <comphelper/sequence.hxx> +#include <cppu/unotype.hxx> #include <rtl/ustrbuf.hxx> +#include <sal/log.hxx> #include <unotools/textsearch.hxx> +#include <utility> #include <vcl/event.hxx> -#include <sal/log.hxx> -#include <tools/diagnose_ex.h> + +#include <dialmgr.hxx> +#include <strings.hrc> #include <algorithm> #include <memory> @@ -35,106 +50,59 @@ using namespace ::com::sun::star; using namespace com::sun::star::uno; using namespace com::sun::star::container; -#define SHORT_LEN_LIMIT 7 -#define LONG_LEN_LIMIT 11 -#define HYPER_LEN_LIMIT 20 - struct Prop_Impl { - OUString Name; - OUString Property; - Any Value; - - Prop_Impl( const OUString& sName, const OUString& sProperty, const Any& aValue ) - : Name( sName ) - , Property( sProperty ) - , Value( aValue ) - {} + OUString Name; + OUString Property; + Any Value; + + Prop_Impl(OUString sName, OUString sProperty, Any aValue) + : Name(std::move(sName)) + , Property(std::move(sProperty)) + , Value(std::move(aValue)) + { + } }; struct UserData { bool bIsPropertyPath; + bool bIsReadOnly; + bool bWasModified; OUString sPropertyPath; + Any aPropertyValue; + OUString sTooltip; int aLineage; Reference<XNameAccess> aXNameAccess; - explicit UserData( OUString const & rPropertyPath ) - : bIsPropertyPath( true ) - , sPropertyPath(rPropertyPath) + explicit UserData(OUString aPropertyPath, Any aPropValue, OUString aTooltip, bool isReadOnly, + bool wasModified) + : bIsPropertyPath(true) + , bIsReadOnly(isReadOnly) + , bWasModified(wasModified) + , sPropertyPath(std::move(aPropertyPath)) + , aPropertyValue(aPropValue) + , sTooltip(std::move(aTooltip)) , aLineage(0) - {} + { + } - explicit UserData( Reference<XNameAccess> const & rXNameAccess, int rIndex ) - : bIsPropertyPath( false ) + explicit UserData(Reference<XNameAccess> const& rXNameAccess, int rIndex) + : bIsPropertyPath(false) + , bIsReadOnly(false) + , bWasModified(false) , aLineage(rIndex) - , aXNameAccess( rXNameAccess ) - {} -}; - -IMPL_LINK(CuiAboutConfigValueDialog, KeyInputHdl, const KeyEvent&, rKeyEvent, bool) -{ - bool bValid = false; - bool bNonSpace = rKeyEvent.GetKeyCode().GetCode() != KEY_SPACE; - if (m_bNumericOnly && bNonSpace ) + , aXNameAccess(rXNameAccess) { - const vcl::KeyCode& rKeyCode = rKeyEvent.GetKeyCode(); - sal_uInt16 nGroup = rKeyCode.GetGroup(); - sal_uInt16 nKey = rKeyCode.GetCode(); - - switch ( nGroup ) { - case KEYGROUP_NUM : - case KEYGROUP_CURSOR : - { - bValid = true; - break; - } - - case KEYGROUP_MISC : - { - switch ( nKey ) { - case KEY_SUBTRACT : - case KEY_COMMA : - case KEY_POINT : - { - bValid = true; - break; - } - - default : - { - if( nKey < KEY_ADD || nKey > KEY_EQUAL ) - bValid = true; - break; - } - } - break; - } - - default : - { - bValid = false; - break; - } - } - - //Select all, Copy, Paste, Cut, Undo Keys - if ( !bValid && ( rKeyCode.IsMod1() && ( - KEY_A == nKey || KEY_C == nKey || KEY_V == nKey || KEY_X == nKey || KEY_Z == nKey ) ) ) - bValid = true; } - else - bValid = true; - - //if value return true to claim that it has been handled - return !bValid; -} +}; CuiAboutConfigTabPage::CuiAboutConfigTabPage(weld::Window* pParent) : GenericDialogController(pParent, "cui/ui/aboutconfigdialog.ui", "AboutConfig") , m_xResetBtn(m_xBuilder->weld_button("reset")) , m_xEditBtn(m_xBuilder->weld_button("edit")) , m_xSearchBtn(m_xBuilder->weld_button("searchButton")) + , m_xModifiedCheckBtn(m_xBuilder->weld_check_button("modifiedButton")) , m_xSearchEdit(m_xBuilder->weld_entry("searchEntry")) , m_xPrefBox(m_xBuilder->weld_tree_view("preferences")) , m_xScratchIter(m_xPrefBox->make_iterator()) @@ -144,25 +112,42 @@ CuiAboutConfigTabPage::CuiAboutConfigTabPage(weld::Window* pParent) m_xPrefBox->get_height_rows(23)); m_xPrefBox->connect_column_clicked(LINK(this, CuiAboutConfigTabPage, HeaderBarClick)); - m_xEditBtn->connect_clicked(LINK( this, CuiAboutConfigTabPage, StandardHdl_Impl)); - m_xResetBtn->connect_clicked(LINK( this, CuiAboutConfigTabPage, ResetBtnHdl_Impl)); + m_xEditBtn->connect_clicked(LINK(this, CuiAboutConfigTabPage, StandardHdl_Impl)); + m_xResetBtn->connect_clicked(LINK(this, CuiAboutConfigTabPage, ResetBtnHdl_Impl)); m_xPrefBox->connect_row_activated(LINK(this, CuiAboutConfigTabPage, DoubleClickHdl_Impl)); m_xPrefBox->connect_expanding(LINK(this, CuiAboutConfigTabPage, ExpandingHdl_Impl)); m_xSearchBtn->connect_clicked(LINK(this, CuiAboutConfigTabPage, SearchHdl_Impl)); + m_xModifiedCheckBtn->connect_toggled(LINK(this, CuiAboutConfigTabPage, ModifiedHdl_Impl)); m_options.AlgorithmType2 = util::SearchAlgorithms2::ABSOLUTE; m_options.transliterateFlags |= TransliterationFlags::IGNORE_CASE; - m_options.searchFlag |= (util::SearchFlags::REG_NOT_BEGINOFLINE | - util::SearchFlags::REG_NOT_ENDOFLINE); + m_options.searchFlag + |= (util::SearchFlags::REG_NOT_BEGINOFLINE | util::SearchFlags::REG_NOT_ENDOFLINE); float fWidth = m_xPrefBox->get_approximate_digit_width(); - std::vector<int> aWidths - { - o3tl::narrowing<int>(fWidth * 65), - o3tl::narrowing<int>(fWidth * 20), - o3tl::narrowing<int>(fWidth * 8) - }; + std::vector<int> aWidths{ o3tl::narrowing<int>(fWidth * 65), o3tl::narrowing<int>(fWidth * 20), + o3tl::narrowing<int>(fWidth * 8) }; m_xPrefBox->set_column_fixed_widths(aWidths); + + m_xPrefBox->connect_query_tooltip(LINK(this, CuiAboutConfigTabPage, QueryTooltip)); +} + +IMPL_LINK(CuiAboutConfigTabPage, QueryTooltip, const weld::TreeIter&, rIter, OUString) +{ + UserData* pUserData = weld::fromId<UserData*>(m_xPrefBox->get_id(rIter)); + OUStringBuffer ret; + if (pUserData && pUserData->bIsReadOnly) + { + ret.append(CuiResId(RID_CUISTR_OPT_READONLY)); + } + if (pUserData && !pUserData->sTooltip.isEmpty()) + { + if (pUserData->bIsReadOnly) + ret.append("\n\n"); + ret.append(pUserData->sTooltip); + } + + return ret.makeStringAndClear(); } IMPL_LINK(CuiAboutConfigTabPage, HeaderBarClick, int, nColumn, void) @@ -196,29 +181,106 @@ IMPL_LINK(CuiAboutConfigTabPage, HeaderBarClick, int, nColumn, void) } } -CuiAboutConfigTabPage::~CuiAboutConfigTabPage() +IMPL_STATIC_LINK_NOARG(CuiAboutConfigTabPage, ValidNameHdl, SvxNameDialog&, bool) { + // Allow empty value + return true; } -void CuiAboutConfigTabPage::InsertEntry(const OUString& rPropertyPath, const OUString& rProp, const OUString& rStatus, - const OUString& rType, const OUString& rValue, const weld::TreeIter* pParentEntry, - bool bInsertToPrefBox) +CuiAboutConfigTabPage::~CuiAboutConfigTabPage() {} + +void CuiAboutConfigTabPage::InsertEntry(const OUString& rPropertyPath, Any aPropertyValue, + const OUString& rProp, const OUString& rStatus, + const OUString& rType, const OUString& rValue, + const OUString& rTooltip, + const weld::TreeIter* pParentEntry, bool bInsertToPrefBox, + bool bIsReadOnly, bool bWasModified) { - m_vectorUserData.push_back(std::make_unique<UserData>(rPropertyPath)); + bool bOnlyModified = m_xModifiedCheckBtn->get_active(); + if (bOnlyModified && !bWasModified) + return; + + m_vectorUserData.push_back(std::make_unique<UserData>(rPropertyPath, aPropertyValue, rTooltip, + bIsReadOnly, bWasModified)); if (bInsertToPrefBox) { - OUString sId(OUString::number(reinterpret_cast<sal_Int64>(m_vectorUserData.back().get()))); - m_xPrefBox->insert(pParentEntry, -1, &rProp, &sId, nullptr, nullptr, false, m_xScratchIter.get()); + OUString sId(weld::toId(m_vectorUserData.back().get())); + m_xPrefBox->insert(pParentEntry, -1, &rProp, &sId, nullptr, nullptr, false, + m_xScratchIter.get()); m_xPrefBox->set_text(*m_xScratchIter, rStatus, 1); m_xPrefBox->set_text(*m_xScratchIter, rType, 2); m_xPrefBox->set_text(*m_xScratchIter, rValue, 3); + m_xPrefBox->set_text_emphasis(*m_xScratchIter, bWasModified, -1); + m_xPrefBox->set_sensitive(*m_xScratchIter, !bIsReadOnly, -1); } else { - m_prefBoxEntries.push_back({rProp, rStatus, rType, rValue, m_vectorUserData.back().get()}); + m_prefBoxEntries.push_back( + { rProp, rStatus, rType, rValue, m_vectorUserData.back().get() }); } } +void CuiAboutConfigTabPage::InputChanged() +{ + weld::WaitObject aWait(m_xDialog.get()); + + m_xPrefBox->hide(); + m_xPrefBox->clear(); + m_xPrefBox->freeze(); + + if (m_bSorted) + m_xPrefBox->make_unsorted(); + + if (m_xSearchEdit->get_text().isEmpty()) + { + m_xPrefBox->clear(); + Reference<XNameAccess> xConfigAccess = getConfigAccess("/", false); + FillItems(xConfigAccess); + } + else + { + m_options.searchString = m_xSearchEdit->get_text(); + utl::TextSearch textSearch(m_options); + for (auto const& it : m_prefBoxEntries) + { + sal_Int32 endPos, startPos = 0; + + for (size_t i = 0; i < 5; ++i) + { + OUString scrTxt; + + if (i == 0) + scrTxt = it.pUserData->sPropertyPath; + else if (i == 1) + scrTxt = it.sProp; + else if (i == 2) + scrTxt = it.sStatus; + else if (i == 3) + scrTxt = it.sType; + else if (i == 4) + scrTxt = it.sValue; + + endPos = scrTxt.getLength(); + if (textSearch.SearchForward(scrTxt, &startPos, &endPos)) + { + InsertEntry(it); + break; + } + } + } + } + + m_xPrefBox->thaw(); + if (m_bSorted) + m_xPrefBox->make_sorted(); + + m_xPrefBox->all_foreach([this](weld::TreeIter& rEntry) { + m_xPrefBox->expand_row(rEntry); + return false; + }); + m_xPrefBox->show(); +} + void CuiAboutConfigTabPage::Reset() { weld::WaitObject aWait(m_xDialog.get()); @@ -235,42 +297,106 @@ void CuiAboutConfigTabPage::Reset() m_modifiedPrefBoxEntries.clear(); m_xPrefBox->freeze(); - Reference< XNameAccess > xConfigAccess = getConfigAccess( "/", false ); + Reference<XNameAccess> xConfigAccess = getConfigAccess("/", false); //Load all XNameAccess to m_prefBoxEntries - FillItems( xConfigAccess, nullptr, 0, true ); + FillItems(xConfigAccess, nullptr, 0, true); //Load xConfigAccess' children to m_prefBox - FillItems( xConfigAccess ); + FillItems(xConfigAccess); m_xPrefBox->thaw(); } void CuiAboutConfigTabPage::FillItemSet() { - std::vector< std::shared_ptr< Prop_Impl > >::iterator pIter; - for( pIter = m_vectorOfModified.begin() ; pIter != m_vectorOfModified.end(); ++pIter ) + std::vector<std::shared_ptr<Prop_Impl>>::iterator pIter; + for (pIter = m_vectorOfModified.begin(); pIter != m_vectorOfModified.end(); ++pIter) { - Reference< XNameAccess > xUpdateAccess = getConfigAccess( (*pIter)->Name , true ); - Reference< XNameReplace > xNameReplace( xUpdateAccess, UNO_QUERY_THROW ); + Reference<XNameAccess> xUpdateAccess = getConfigAccess((*pIter)->Name, true); + Reference<XNameReplace> xNameReplace(xUpdateAccess, UNO_QUERY_THROW); - xNameReplace->replaceByName( (*pIter)->Property, (*pIter)->Value ); + xNameReplace->replaceByName((*pIter)->Property, (*pIter)->Value); - Reference< util::XChangesBatch > xChangesBatch( xUpdateAccess, UNO_QUERY_THROW ); + Reference<util::XChangesBatch> xChangesBatch(xUpdateAccess, UNO_QUERY_THROW); xChangesBatch->commitChanges(); } } -void CuiAboutConfigTabPage::FillItems(const Reference< XNameAccess >& xNameAccess, const weld::TreeIter* pParentEntry, - int lineage, bool bLoadAll) +namespace { - OUString sPath = Reference< XHierarchicalName >( - xNameAccess, uno::UNO_QUERY_THROW )->getHierarchicalName(); - const uno::Sequence< OUString > seqItems = xNameAccess->getElementNames(); - for( const OUString& item : seqItems ) +OUString lcl_StringListToString(const uno::Sequence<OUString>& seq) +{ + OUStringBuffer sBuffer; + for (sal_Int32 i = 0; i != seq.getLength(); ++i) { - Any aNode = xNameAccess->getByName( item ); + if (i != 0) + sBuffer.append(","); + sBuffer.append(seq[i]); + } + return sBuffer.makeStringAndClear(); +} + +OUString lcl_IntListToString(const uno::Sequence<sal_Int16>& seq) +{ + OUStringBuffer sBuffer; + for (sal_Int32 i = 0; i != seq.getLength(); ++i) + { + if (i != 0) + sBuffer.append(","); + sBuffer.append(OUString::number(seq[i])); + } + return sBuffer.makeStringAndClear(); +} + +OUString lcl_IntListToString(const uno::Sequence<sal_Int32>& seq) +{ + OUStringBuffer sBuffer; + for (sal_Int32 i = 0; i != seq.getLength(); ++i) + { + if (i != 0) + sBuffer.append(","); + sBuffer.append(OUString::number(seq[i])); + } + return sBuffer.makeStringAndClear(); +} + +OUString lcl_IntListToString(const uno::Sequence<sal_Int64>& seq) +{ + OUStringBuffer sBuffer; + for (sal_Int32 i = 0; i != seq.getLength(); ++i) + { + if (i != 0) + sBuffer.append(","); + sBuffer.append(OUString::number(seq[i])); + } + return sBuffer.makeStringAndClear(); +} + +OUString lcl_DoubleListToString(const uno::Sequence<double>& seq) +{ + OUStringBuffer sBuffer; + for (sal_Int32 i = 0; i != seq.getLength(); ++i) + { + if (i != 0) + sBuffer.append(","); + sBuffer.append(OUString::number(seq[i])); + } + return sBuffer.makeStringAndClear(); +} +} + +void CuiAboutConfigTabPage::FillItems(const Reference<XNameAccess>& xNameAccess, + const weld::TreeIter* pParentEntry, int lineage, + bool bLoadAll) +{ + OUString sPath + = Reference<XHierarchicalName>(xNameAccess, uno::UNO_QUERY_THROW)->getHierarchicalName(); + const uno::Sequence<OUString> seqItems = xNameAccess->getElementNames(); + for (const OUString& item : seqItems) + { + Any aNode = xNameAccess->getByName(item); bool bNotLeaf = false; - Reference< XNameAccess > xNextNameAccess; + Reference<XNameAccess> xNextNameAccess; try { xNextNameAccess.set(aNode, uno::UNO_QUERY); @@ -278,24 +404,27 @@ void CuiAboutConfigTabPage::FillItems(const Reference< XNameAccess >& xNameAcces } catch (const RuntimeException&) { - TOOLS_WARN_EXCEPTION( "cui.options", "CuiAboutConfigTabPage"); + TOOLS_WARN_EXCEPTION("cui.options", "CuiAboutConfigTabPage"); } if (bNotLeaf) { - if(bLoadAll) + if (bLoadAll) FillItems(xNextNameAccess, nullptr, lineage + 1, true); else { // not leaf node - m_vectorUserData.push_back(std::make_unique<UserData>(xNextNameAccess, lineage + 1)); - OUString sId(OUString::number(reinterpret_cast<sal_Int64>(m_vectorUserData.back().get()))); + m_vectorUserData.push_back( + std::make_unique<UserData>(xNextNameAccess, lineage + 1)); + OUString sId(weld::toId(m_vectorUserData.back().get())); - m_xPrefBox->insert(pParentEntry, -1, &item, &sId, nullptr, nullptr, true, m_xScratchIter.get()); + m_xPrefBox->insert(pParentEntry, -1, &item, &sId, nullptr, nullptr, true, + m_xScratchIter.get()); // Necessary, without this the selection line will be truncated. m_xPrefBox->set_text(*m_xScratchIter, "", 1); m_xPrefBox->set_text(*m_xScratchIter, "", 2); m_xPrefBox->set_text(*m_xScratchIter, "", 3); + m_xPrefBox->set_sensitive(*m_xScratchIter, true); } } else @@ -303,214 +432,308 @@ void CuiAboutConfigTabPage::FillItems(const Reference< XNameAccess >& xNameAcces // leaf node OUString sPropertyName = item; auto it = std::find_if(m_modifiedPrefBoxEntries.begin(), m_modifiedPrefBoxEntries.end(), - [&sPath, &sPropertyName](const prefBoxEntry& rEntry) -> bool - { - return rEntry.pUserData->sPropertyPath == sPath - && rEntry.sStatus == sPropertyName; - } - ); - - OUString sType = aNode.getValueTypeName(); + [&sPath, &sPropertyName](const prefBoxEntry& rEntry) -> bool { + return rEntry.pUserData->sPropertyPath == sPath + && rEntry.sStatus == sPropertyName; + }); + + css::uno::Reference<css::configuration::XReadWriteAccess> m_xReadWriteAccess; + m_xReadWriteAccess = css::configuration::ReadWriteAccess::create( + ::comphelper::getProcessComponentContext(), "*"); + beans::Property aProperty; + bool bReadOnly = false; + OUString sFullPath(sPath + "/" + sPropertyName); + try + { + aProperty = m_xReadWriteAccess->getPropertyByHierarchicalName(sFullPath); + bReadOnly = (aProperty.Attributes & beans::PropertyAttribute::READONLY) != 0; + } + catch (css::beans::UnknownPropertyException) + { + SAL_WARN("cui.options", "unknown property: " << sFullPath); + } + + OUString sTooltip; + OUString sType; + bool bWasModified = false; + css::uno::Type aType = cppu::UnoType<void>::get(); + OUString sDynamicType = aNode.getValueTypeName(); + try + { + Reference<configuration::XDocumentation> xDocumentation(xNameAccess, + UNO_QUERY_THROW); + sTooltip + = xDocumentation->getDescriptionByHierarchicalName(sPath + "/" + sPropertyName); + aType = xDocumentation->getTypeByHierarchicalName(sFullPath); + bWasModified = xDocumentation->getModifiedByHierarchicalName(sFullPath); + } + catch (css::container::NoSuchElementException) + { + } + catch (css::util::InvalidStateException) + { + } + OUStringBuffer sValue; + // Fall back to dynamic type when this is empty + if (aType == cppu::UnoType<void>::get() && sDynamicType != "void") + { + if (sDynamicType == "boolean") + aType = cppu::UnoType<sal_Bool>::get(); + else if (sDynamicType == "short") + aType = cppu::UnoType<sal_Int16>::get(); + else if (sDynamicType == "long") + aType = cppu::UnoType<sal_Int32>::get(); + else if (sDynamicType == "hyper") + aType = cppu::UnoType<sal_Int64>::get(); + else if (sDynamicType == "double") + aType = cppu::UnoType<double>::get(); + else if (sDynamicType == "string") + aType = cppu::UnoType<OUString>::get(); + else if (sDynamicType == "[]byte") + aType = cppu::UnoType<css::uno::Sequence<sal_Int8>>::get(); + else if (sDynamicType == "[]boolean") + aType = cppu::UnoType<css::uno::Sequence<sal_Bool>>::get(); + else if (sDynamicType == "[]short") + aType = cppu::UnoType<css::uno::Sequence<sal_Int16>>::get(); + else if (sDynamicType == "[]long") + aType = cppu::UnoType<css::uno::Sequence<sal_Int32>>::get(); + else if (sDynamicType == "[]hyper") + aType = cppu::UnoType<css::uno::Sequence<sal_Int64>>::get(); + else if (sDynamicType == "[]double") + aType = cppu::UnoType<css::uno::Sequence<double>>::get(); + else if (sDynamicType == "[]string") + aType = cppu::UnoType<css::uno::Sequence<OUString>>::get(); + else if (sDynamicType == "[][]byte") + aType = cppu::UnoType<css::uno::Sequence<css::uno::Sequence<sal_Int8>>>::get(); + } + if (it != m_modifiedPrefBoxEntries.end()) sValue = it->sValue; else { - switch( aNode.getValueType().getTypeClass() ) + bool bHasValue = sDynamicType != "void"; + if (aType == cppu::UnoType<sal_Bool>::get()) { - case css::uno::TypeClass_VOID: - break; - - case css::uno::TypeClass_BOOLEAN: - sValue = OUString::boolean( aNode.get<bool>() ); - break; - - case css::uno::TypeClass_SHORT: - case css::uno::TypeClass_LONG: - case css::uno::TypeClass_HYPER: - sValue = OUString::number( aNode.get<sal_Int64>() ); - break; - - case css::uno::TypeClass_DOUBLE: - sValue = OUString::number( aNode.get<double>() ); - break; - - case css::uno::TypeClass_STRING: - sValue = aNode.get<OUString>(); - break; - - case css::uno::TypeClass_SEQUENCE: - if( sType == "[]boolean" ) - { - uno::Sequence<sal_Bool> seq = aNode.get< uno::Sequence<sal_Bool> >(); - for( sal_Int32 j = 0; j != seq.getLength(); ++j ) - { - if( j != 0 ) - { - sValue.append(","); - } - sValue.append(OUString::boolean( seq[j] )); - } - } - else if( sType == "[]byte" ) + if (bHasValue) + sValue = OUString::boolean(aNode.get<bool>()); + sType = "boolean"; + } + else if (aType == cppu::UnoType<sal_Int16>::get()) + { + if (bHasValue) + sValue = OUString::number(aNode.get<sal_Int16>()); + sType = "short"; + } + else if (aType == cppu::UnoType<sal_Int32>::get()) + { + if (bHasValue) + sValue = OUString::number(aNode.get<sal_Int32>()); + sType = "int"; + } + else if (aType == cppu::UnoType<sal_Int64>::get()) + { + if (bHasValue) + sValue = OUString::number(aNode.get<sal_Int64>()); + sType = "long"; + } + else if (aType == cppu::UnoType<double>::get()) + { + if (bHasValue) + sValue = OUString::number(aNode.get<double>()); + sType = "double"; + } + else if (aType == cppu::UnoType<OUString>::get()) + { + if (bHasValue) + sValue = aNode.get<OUString>(); + sType = "string"; + } + else if (aType == cppu::UnoType<css::uno::Sequence<sal_Int8>>::get()) + { + if (bHasValue) { - const uno::Sequence<sal_Int8> seq = aNode.get< uno::Sequence<sal_Int8> >(); - for( sal_Int8 j : seq ) + const uno::Sequence<sal_Int8> seq = aNode.get<uno::Sequence<sal_Int8>>(); + for (sal_Int8 j : seq) { - OUString s = OUString::number( - static_cast<sal_uInt8>(j), 16 ); - if( s.getLength() == 1 ) + OUString s = OUString::number(static_cast<sal_uInt8>(j), 16); + if (s.getLength() == 1) { sValue.append("0"); } sValue.append(s.toAsciiUpperCase()); } } - else if( sType == "[][]byte" ) + sType = "hexBinary"; + } + else if (aType == cppu::UnoType<css::uno::Sequence<sal_Bool>>::get()) + { + if (bHasValue) { - const uno::Sequence< uno::Sequence<sal_Int8> > seq = aNode.get< uno::Sequence< uno::Sequence<sal_Int8> > >(); - for( sal_Int32 j = 0; j != seq.getLength(); ++j ) + uno::Sequence<sal_Bool> seq = aNode.get<uno::Sequence<sal_Bool>>(); + for (sal_Int32 j = 0; j != seq.getLength(); ++j) { - if( j != 0 ) + if (j != 0) { sValue.append(","); } - for( sal_Int8 k : seq[j] ) - { - OUString s = OUString::number( - static_cast<sal_uInt8>(k), 16 ); - if( s.getLength() == 1 ) - { - sValue.append("0"); - } - sValue.append(s.toAsciiUpperCase()); - } + sValue.append(OUString::boolean(seq[j])); } } - else if( sType == "[]short" ) + sType = "boolean-list"; + } + else if (aType == cppu::UnoType<css::uno::Sequence<sal_Int16>>::get()) + { + if (bHasValue) { - uno::Sequence<sal_Int16> seq = aNode.get< uno::Sequence<sal_Int16> >(); - for( sal_Int32 j = 0; j != seq.getLength(); ++j ) + uno::Sequence<sal_Int16> seq = aNode.get<uno::Sequence<sal_Int16>>(); + for (sal_Int32 j = 0; j != seq.getLength(); ++j) { - if( j != 0 ) + if (j != 0) { sValue.append(","); } - sValue.append( static_cast<sal_Int32>(seq[j]) ); + sValue.append(static_cast<sal_Int32>(seq[j])); } } - else if( sType == "[]long" ) + sType = "short-list"; + } + else if (aType == cppu::UnoType<css::uno::Sequence<sal_Int32>>::get()) + { + if (bHasValue) { - uno::Sequence<sal_Int32> seq = aNode.get< uno::Sequence<sal_Int32> >(); - for( sal_Int32 j = 0; j != seq.getLength(); ++j ) + uno::Sequence<sal_Int32> seq = aNode.get<uno::Sequence<sal_Int32>>(); + for (sal_Int32 j = 0; j != seq.getLength(); ++j) { - if( j != 0 ) + if (j != 0) { sValue.append(","); } - sValue.append( seq[j] ); + sValue.append(seq[j]); } } - else if( sType == "[]hyper" ) + sType = "int-list"; + } + else if (aType == cppu::UnoType<css::uno::Sequence<sal_Int64>>::get()) + { + if (bHasValue) { - uno::Sequence<sal_Int64> seq = aNode.get< uno::Sequence<sal_Int64> >(); - for( sal_Int32 j = 0; j != seq.getLength(); ++j ) + uno::Sequence<sal_Int64> seq = aNode.get<uno::Sequence<sal_Int64>>(); + for (sal_Int32 j = 0; j != seq.getLength(); ++j) { - if( j != 0 ) + if (j != 0) { sValue.append(","); } - sValue.append( seq[j] ); + sValue.append(seq[j]); } } - else if( sType == "[]double" ) + sType = "long-list"; + } + else if (aType == cppu::UnoType<css::uno::Sequence<double>>::get()) + { + if (bHasValue) { - uno::Sequence<double> seq = aNode.get< uno::Sequence<double> >(); - for( sal_Int32 j = 0; j != seq.getLength(); ++j ) + uno::Sequence<double> seq = aNode.get<uno::Sequence<double>>(); + for (sal_Int32 j = 0; j != seq.getLength(); ++j) { - if( j != 0 ) + if (j != 0) { sValue.append(","); } - sValue.append( seq[j] ); + sValue.append(seq[j]); } } - else if( sType == "[]string" ) + sType = "double-list"; + } + else if (aType == cppu::UnoType<css::uno::Sequence<OUString>>::get()) + { + if (bHasValue) + sValue = lcl_StringListToString(aNode.get<uno::Sequence<OUString>>()); + sType = "string-list"; + } + else if (aType + == cppu::UnoType<css::uno::Sequence<css::uno::Sequence<sal_Int8>>>::get()) + { + if (bHasValue) { - uno::Sequence<OUString> seq = aNode.get< uno::Sequence<OUString> >(); - for( sal_Int32 j = 0; j != seq.getLength(); ++j ) + const uno::Sequence<uno::Sequence<sal_Int8>> seq + = aNode.get<uno::Sequence<uno::Sequence<sal_Int8>>>(); + for (sal_Int32 j = 0; j != seq.getLength(); ++j) { - if( j != 0 ) + if (j != 0) { sValue.append(","); } - sValue.append(seq[j]); + for (sal_Int8 k : seq[j]) + { + OUString s = OUString::number(static_cast<sal_uInt8>(k), 16); + if (s.getLength() == 1) + { + sValue.append("0"); + } + sValue.append(s.toAsciiUpperCase()); + } } } - else - { - SAL_WARN( - "cui.options", - "path \"" << sPath << "\" member " << item - << " of unsupported type " << sType); - } - break; - - default: - SAL_WARN( - "cui.options", - "path \"" << sPath << "\" member " << item - << " of unsupported type " << sType); - break; + sType = "hexBinary-list"; + } + else + { + SAL_INFO("cui.options", "path \"" << sPath << "\" member " << item + << " of unsupported type " << sType); + continue; } } //Short name int index = 0; - for(int j = 1; j < lineage; ++j) + for (int j = 1; j < lineage; ++j) index = sPath.indexOf("/", index + 1); - InsertEntry(sPath, sPath.copy(index+1), item, sType, sValue.makeStringAndClear(), pParentEntry, !bLoadAll); + InsertEntry(sPath, aNode, sPath.copy(index + 1), item, sType, + sValue.makeStringAndClear(), sTooltip, pParentEntry, !bLoadAll, bReadOnly, + bWasModified); } } } -Reference< XNameAccess > CuiAboutConfigTabPage::getConfigAccess( const OUString& sNodePath, bool bUpdate ) +Reference<XNameAccess> CuiAboutConfigTabPage::getConfigAccess(const OUString& sNodePath, + bool bUpdate) { - uno::Reference< uno::XComponentContext > xContext( ::comphelper::getProcessComponentContext() ); + uno::Reference<uno::XComponentContext> xContext(::comphelper::getProcessComponentContext()); - uno::Reference< lang::XMultiServiceFactory > xConfigProvider( - css::configuration::theDefaultProvider::get( xContext ) ); + uno::Reference<lang::XMultiServiceFactory> xConfigProvider( + css::configuration::theDefaultProvider::get(xContext)); beans::NamedValue aProperty; aProperty.Name = "nodepath"; aProperty.Value <<= sNodePath; - uno::Sequence< uno::Any > aArgumentList{ uno::Any(aProperty) }; + uno::Sequence<uno::Any> aArgumentList{ uno::Any(aProperty) }; OUString sAccessString; - if( bUpdate ) + if (bUpdate) sAccessString = "com.sun.star.configuration.ConfigurationUpdateAccess"; else sAccessString = "com.sun.star.configuration.ConfigurationAccess"; - uno::Reference< container::XNameAccess > xNameAccess( - xConfigProvider->createInstanceWithArguments( - sAccessString, aArgumentList ), - uno::UNO_QUERY_THROW ); + uno::Reference<container::XNameAccess> xNameAccess( + xConfigProvider->createInstanceWithArguments(sAccessString, aArgumentList), + uno::UNO_QUERY_THROW); return xNameAccess; } -void CuiAboutConfigTabPage::AddToModifiedVector( const std::shared_ptr< Prop_Impl >& rProp ) +void CuiAboutConfigTabPage::AddToModifiedVector(const std::shared_ptr<Prop_Impl>& rProp) { bool isModifiedBefore = false; //Check if value modified before - for(std::shared_ptr<Prop_Impl> & nInd : m_vectorOfModified) + for (std::shared_ptr<Prop_Impl>& nInd : m_vectorOfModified) { - if( rProp->Name == nInd->Name && rProp->Property == nInd->Property ) + if (rProp->Name == nInd->Name && rProp->Property == nInd->Property) { //property modified before. Assign reference to the modified value //do your changes on this object. They will be saved later. @@ -520,47 +743,28 @@ void CuiAboutConfigTabPage::AddToModifiedVector( const std::shared_ptr< Prop_Imp } } - if( !isModifiedBefore ) - m_vectorOfModified.push_back( rProp ); + if (!isModifiedBefore) + m_vectorOfModified.push_back(rProp); //property is not modified before } -std::vector< OUString > CuiAboutConfigTabPage::commaStringToSequence( const OUString& rCommaSepString ) +std::vector<OUString> +CuiAboutConfigTabPage::commaStringToSequence(std::u16string_view rCommaSepString) { std::vector<OUString> tempVector; sal_Int32 index = 0; do { - OUString word = rCommaSepString.getToken(0, u',', index); + OUString word(o3tl::getToken(rCommaSepString, 0, u',', index)); word = word.trim(); - if( !word.isEmpty()) + if (!word.isEmpty()) tempVector.push_back(word); - }while( index >= 0 ); + } while (index >= 0); return tempVector; } -CuiAboutConfigValueDialog::CuiAboutConfigValueDialog(weld::Window* pWindow, - const OUString& rValue, - int limit) - : GenericDialogController(pWindow, "cui/ui/aboutconfigvaluedialog.ui", "AboutConfigValueDialog") - , m_bNumericOnly(limit != 0) - , m_xEDValue(m_xBuilder->weld_entry("valuebox")) -{ - if (limit) - m_xEDValue->set_max_length(limit); - m_xEDValue->set_text(rValue); - m_xEDValue->connect_key_press(LINK(this, CuiAboutConfigValueDialog, KeyInputHdl)); -} - -CuiAboutConfigValueDialog::~CuiAboutConfigValueDialog() -{ -} - -IMPL_LINK_NOARG( CuiAboutConfigTabPage, ResetBtnHdl_Impl, weld::Button&, void ) -{ - Reset(); -} +IMPL_LINK_NOARG(CuiAboutConfigTabPage, ResetBtnHdl_Impl, weld::Button&, void) { Reset(); } IMPL_LINK_NOARG(CuiAboutConfigTabPage, DoubleClickHdl_Impl, weld::TreeView&, bool) { @@ -568,13 +772,13 @@ IMPL_LINK_NOARG(CuiAboutConfigTabPage, DoubleClickHdl_Impl, weld::TreeView&, boo return true; } -IMPL_LINK_NOARG( CuiAboutConfigTabPage, StandardHdl_Impl, weld::Button&, void ) +IMPL_LINK_NOARG(CuiAboutConfigTabPage, StandardHdl_Impl, weld::Button&, void) { if (!m_xPrefBox->get_selected(m_xScratchIter.get())) return; - UserData *pUserData = reinterpret_cast<UserData*>(m_xPrefBox->get_id(*m_xScratchIter).toInt64()); - if (!(pUserData && pUserData->bIsPropertyPath)) + UserData* pUserData = weld::fromId<UserData*>(m_xPrefBox->get_id(*m_xScratchIter)); + if (!pUserData || !pUserData->bIsPropertyPath || pUserData->bIsReadOnly) return; //if selection is a node @@ -582,16 +786,17 @@ IMPL_LINK_NOARG( CuiAboutConfigTabPage, StandardHdl_Impl, weld::Button&, void ) OUString sPropertyType = m_xPrefBox->get_text(*m_xScratchIter, 2); OUString sPropertyValue = m_xPrefBox->get_text(*m_xScratchIter, 3); - auto pProperty = std::make_shared<Prop_Impl>( pUserData->sPropertyPath, sPropertyName, Any( sPropertyValue ) ); + auto pProperty + = std::make_shared<Prop_Impl>(pUserData->sPropertyPath, sPropertyName, Any(sPropertyValue)); bool bSaveChanges = false; bool bOpenDialog = true; OUString sDialogValue; - if( sPropertyType == "boolean" ) + if (sPropertyType == "boolean") { bool bValue; - if( sPropertyValue == "true" ) + if (sPropertyValue == "true") { sDialogValue = "false"; bValue = false; @@ -606,10 +811,6 @@ IMPL_LINK_NOARG( CuiAboutConfigTabPage, StandardHdl_Impl, weld::Button&, void ) bOpenDialog = false; bSaveChanges = true; } - else if ( sPropertyType == "void" ) - { - bOpenDialog = false; - } else { sDialogValue = sPropertyValue; @@ -618,154 +819,180 @@ IMPL_LINK_NOARG( CuiAboutConfigTabPage, StandardHdl_Impl, weld::Button&, void ) try { - if( bOpenDialog ) + if (bOpenDialog) { - //Cosmetic length limit for integer values. - int limit=0; - if( sPropertyType == "short" ) - limit = SHORT_LEN_LIMIT; - else if( sPropertyType == "long" ) - limit = LONG_LEN_LIMIT; - else if( sPropertyType == "hyper" ) - limit = HYPER_LEN_LIMIT; - - CuiAboutConfigValueDialog aValueDialog(m_xDialog.get(), sDialogValue, limit); - - if (aValueDialog.run() == RET_OK ) + if (sPropertyType == "short" || sPropertyType == "int" || sPropertyType == "long") { - OUString sNewValue = aValueDialog.getValue(); - bSaveChanges = true; - if ( sPropertyType == "short") - { - sal_Int16 nShort; - sal_Int32 nNumb = sNewValue.toInt32(); - - //if the value is 0 and length is not 1, there is something wrong - if( ( nNumb==0 && sNewValue.getLength()!=1 ) || nNumb > SAL_MAX_INT16 || nNumb < SAL_MIN_INT16) - throw uno::Exception("out of range short", nullptr); - nShort = static_cast<sal_Int16>(nNumb); - pProperty->Value <<= nShort; - } - else if( sPropertyType == "long" ) + sal_Int64 nMin = sPropertyType == "short" + ? SAL_MIN_INT16 + : sPropertyType == "int" ? SAL_MIN_INT32 : SAL_MIN_INT64; + sal_Int64 nMax = sPropertyType == "short" + ? SAL_MAX_INT16 + : sPropertyType == "int" ? SAL_MAX_INT32 : SAL_MAX_INT64; + SvxNumberDialog aNumberDialog(m_xDialog.get(), sPropertyName, + sDialogValue.toInt64(), nMin, nMax); + if (aNumberDialog.run() == RET_OK) { - sal_Int32 nLong = sNewValue.toInt32(); - if( nLong==0 && sNewValue.getLength()!=1) - throw uno::Exception("out of range long", nullptr); - pProperty->Value <<= nLong; - } - else if( sPropertyType == "hyper") - { - sal_Int64 nHyper = sNewValue.toInt64(); - if( nHyper==0 && sNewValue.getLength()!=1) - throw uno::Exception("out of range hyper", nullptr); - pProperty->Value <<= nHyper; - } - else if( sPropertyType == "double") - { - double nDoub = sNewValue.toDouble(); - if( nDoub ==0 && sNewValue.getLength()!=1) - throw uno::Exception("out of range double", nullptr); - pProperty->Value <<= nDoub; + sal_Int64 nNewValue = aNumberDialog.GetNumber(); + if (sPropertyType == "short") + { + pProperty->Value <<= static_cast<sal_Int16>(nNewValue); + } + else if (sPropertyType == "int") + { + pProperty->Value <<= static_cast<sal_Int32>(nNewValue); + } + else if (sPropertyType == "long") + { + pProperty->Value <<= nNewValue; + } + bSaveChanges = true; + sDialogValue = OUString::number(nNewValue); } - else if( sPropertyType == "float") + } + else if (sPropertyType == "double") + { + SvxDecimalNumberDialog aNumberDialog(m_xDialog.get(), sPropertyName, + sDialogValue.toDouble()); + if (aNumberDialog.run() == RET_OK) { - float nFloat = sNewValue.toFloat(); - if( nFloat ==0 && sNewValue.getLength()!=1) - throw uno::Exception("out of range float", nullptr); - pProperty->Value <<= nFloat; + double fNewValue = aNumberDialog.GetNumber(); + pProperty->Value <<= fNewValue; + bSaveChanges = true; + sDialogValue = OUString::number(fNewValue); } - else if( sPropertyType == "string" ) + } + else if (sPropertyType == "string") + { + SvxNameDialog aNameDialog(m_xDialog.get(), sDialogValue, sPropertyName); + aNameDialog.SetCheckNameHdl(LINK(this, CuiAboutConfigTabPage, ValidNameHdl)); + if (aNameDialog.run() == RET_OK) { - pProperty->Value <<= sNewValue; + sDialogValue = aNameDialog.GetName(); + pProperty->Value <<= sDialogValue; + bSaveChanges = true; } - else if( sPropertyType == "[]short" ) + } + else if (sPropertyType == "short-list") + { + SvxListDialog aListDialog(m_xDialog.get()); + aListDialog.SetEntries(commaStringToSequence(sDialogValue)); + aListDialog.SetMode(ListMode::Int16); + if (aListDialog.run() == RET_OK) { - //create string sequence from comma separated string - //uno::Sequence< OUString > seqStr; - std::vector< OUString > seqStr = commaStringToSequence( sNewValue ); - - //create appropriate sequence with same size as string sequence - uno::Sequence< sal_Int16 > seqShort( seqStr.size() ); - //convert all strings to appropriate type - std::transform(seqStr.begin(), seqStr.end(), seqShort.getArray(), - [](const auto& str) - { return static_cast<sal_Int16>(str.toInt32()); }); + std::vector<OUString> seqStr = aListDialog.GetEntries(); + uno::Sequence<sal_Int16> seqShort(seqStr.size()); + std::transform( + seqStr.begin(), seqStr.end(), seqShort.getArray(), + [](const auto& str) { return static_cast<sal_Int16>(str.toInt32()); }); pProperty->Value <<= seqShort; + sDialogValue = lcl_IntListToString(seqShort); + bSaveChanges = true; } - else if( sPropertyType == "[]long" ) - { - std::vector< OUString > seqStrLong = commaStringToSequence( sNewValue ); - - uno::Sequence< sal_Int32 > seqLong( seqStrLong.size() ); - std::transform(seqStrLong.begin(), seqStrLong.end(), seqLong.getArray(), - [](const auto& str) { return str.toInt32(); }); - pProperty->Value <<= seqLong; - } - else if( sPropertyType == "[]hyper" ) + } + else if (sPropertyType == "int-list") + { + SvxListDialog aListDialog(m_xDialog.get()); + aListDialog.SetEntries(commaStringToSequence(sDialogValue)); + aListDialog.SetMode(ListMode::Int32); + if (aListDialog.run() == RET_OK) { - std::vector< OUString > seqStrHyper = commaStringToSequence( sNewValue ); - uno::Sequence< sal_Int64 > seqHyper( seqStrHyper.size() ); - std::transform(seqStrHyper.begin(), seqStrHyper.end(), seqHyper.getArray(), - [](const auto& str) { return str.toInt64(); }); - pProperty->Value <<= seqHyper; + std::vector<OUString> seqStr = aListDialog.GetEntries(); + uno::Sequence<sal_Int32> seq(seqStr.size()); + std::transform( + seqStr.begin(), seqStr.end(), seq.getArray(), + [](const auto& str) { return static_cast<sal_Int32>(str.toInt32()); }); + pProperty->Value <<= seq; + sDialogValue = lcl_IntListToString(seq); + bSaveChanges = true; } - else if( sPropertyType == "[]double" ) + } + else if (sPropertyType == "long-list") + { + SvxListDialog aListDialog(m_xDialog.get()); + aListDialog.SetEntries(commaStringToSequence(sDialogValue)); + aListDialog.SetMode(ListMode::Int64); + if (aListDialog.run() == RET_OK) { - std::vector< OUString > seqStrDoub = commaStringToSequence( sNewValue ); - uno::Sequence< double > seqDoub( seqStrDoub.size() ); - std::transform(seqStrDoub.begin(), seqStrDoub.end(), seqDoub.getArray(), - [](const auto& str) { return str.toDouble(); }); - pProperty->Value <<= seqDoub; + std::vector<OUString> seqStr = aListDialog.GetEntries(); + uno::Sequence<sal_Int64> seq(seqStr.size()); + std::transform( + seqStr.begin(), seqStr.end(), seq.getArray(), + [](const auto& str) { return static_cast<sal_Int64>(str.toInt32()); }); + pProperty->Value <<= seq; + sDialogValue = lcl_IntListToString(seq); + bSaveChanges = true; } - else if( sPropertyType == "[]float" ) + } + else if (sPropertyType == "double-list") + { + SvxListDialog aListDialog(m_xDialog.get()); + aListDialog.SetEntries(commaStringToSequence(sDialogValue)); + aListDialog.SetMode(ListMode::Double); + if (aListDialog.run() == RET_OK) { - std::vector< OUString > seqStrFloat = commaStringToSequence( sNewValue ); - uno::Sequence< sal_Int16 > seqFloat( seqStrFloat.size() ); - std::transform(seqStrFloat.begin(), seqStrFloat.end(), seqFloat.getArray(), - [](const auto& str) { return str.toFloat(); }); - pProperty->Value <<= seqFloat; + std::vector<OUString> seqStr = aListDialog.GetEntries(); + uno::Sequence<double> seq(seqStr.size()); + std::transform( + seqStr.begin(), seqStr.end(), seq.getArray(), + [](const auto& str) { return static_cast<double>(str.toDouble()); }); + pProperty->Value <<= seq; + sDialogValue = lcl_DoubleListToString(seq); + bSaveChanges = true; } - else if( sPropertyType == "[]string" ) + } + else if (sPropertyType == "string-list") + { + SvxListDialog aListDialog(m_xDialog.get()); + uno::Sequence<OUString> aList + = pUserData->aPropertyValue.get<uno::Sequence<OUString>>(); + aListDialog.SetEntries( + comphelper::sequenceToContainer<std::vector<OUString>>(aList)); + aListDialog.SetMode(ListMode::String); + if (aListDialog.run() == RET_OK) { - pProperty->Value <<= comphelper::containerToSequence( commaStringToSequence( sNewValue )); + auto seq = comphelper::containerToSequence(aListDialog.GetEntries()); + sDialogValue = lcl_StringListToString(seq); + pProperty->Value <<= seq; + bSaveChanges = true; } - else //unknown - throw uno::Exception("unknown property type " + sPropertyType, nullptr); - - sDialogValue = sNewValue; } + else //unknown + throw uno::Exception("unknown property type " + sPropertyType, nullptr); } - if(bSaveChanges) + if (bSaveChanges) { - AddToModifiedVector( pProperty ); + AddToModifiedVector(pProperty); + pUserData->aPropertyValue = pProperty->Value; //update listbox value. + m_xPrefBox->set_text(*m_xScratchIter, sPropertyType, 2); m_xPrefBox->set_text(*m_xScratchIter, sDialogValue, 3); + m_xPrefBox->set_text_emphasis(*m_xScratchIter, true, -1); //update m_prefBoxEntries - auto it = std::find_if(m_prefBoxEntries.begin(), m_prefBoxEntries.end(), - [&pUserData, &sPropertyName](const prefBoxEntry& rEntry) -> bool - { - return rEntry.pUserData->sPropertyPath == pUserData->sPropertyPath - && rEntry.sStatus == sPropertyName; - } - ); + auto it = std::find_if( + m_prefBoxEntries.begin(), m_prefBoxEntries.end(), + [&pUserData, &sPropertyName](const prefBoxEntry& rEntry) -> bool { + return rEntry.pUserData->sPropertyPath == pUserData->sPropertyPath + && rEntry.sStatus == sPropertyName; + }); if (it != m_prefBoxEntries.end()) { it->sValue = sDialogValue; + it->pUserData->bWasModified = true; auto modifiedIt = std::find_if( - m_modifiedPrefBoxEntries.begin(), m_modifiedPrefBoxEntries.end(), - [&pUserData, &sPropertyName](const prefBoxEntry& rEntry) -> bool - { - return rEntry.pUserData->sPropertyPath == pUserData->sPropertyPath - && rEntry.sStatus == sPropertyName; - } - ); + m_modifiedPrefBoxEntries.begin(), m_modifiedPrefBoxEntries.end(), + [&pUserData, &sPropertyName](const prefBoxEntry& rEntry) -> bool { + return rEntry.pUserData->sPropertyPath == pUserData->sPropertyPath + && rEntry.sStatus == sPropertyName; + }); if (modifiedIt != m_modifiedPrefBoxEntries.end()) { modifiedIt->sValue = sDialogValue; + modifiedIt->pUserData->bWasModified = true; } else { @@ -774,74 +1001,24 @@ IMPL_LINK_NOARG( CuiAboutConfigTabPage, StandardHdl_Impl, weld::Button&, void ) } } } - catch( uno::Exception& ) + catch (uno::Exception&) { } } -IMPL_LINK_NOARG( CuiAboutConfigTabPage, SearchHdl_Impl, weld::Button&, void) -{ - weld::WaitObject aWait(m_xDialog.get()); - - m_xPrefBox->hide(); - m_xPrefBox->clear(); - m_xPrefBox->freeze(); - - if (m_bSorted) - m_xPrefBox->make_unsorted(); +IMPL_LINK_NOARG(CuiAboutConfigTabPage, SearchHdl_Impl, weld::Button&, void) { InputChanged(); } - if (m_xSearchEdit->get_text().isEmpty()) - { - m_xPrefBox->clear(); - Reference< XNameAccess > xConfigAccess = getConfigAccess( "/", false ); - FillItems( xConfigAccess ); - } - else - { - m_options.searchString = m_xSearchEdit->get_text(); - utl::TextSearch textSearch( m_options ); - for (auto const& it : m_prefBoxEntries) - { - sal_Int32 endPos, startPos = 0; - - for(size_t i = 0; i < 5; ++i) - { - OUString scrTxt; - - if (i == 0) - scrTxt = it.pUserData->sPropertyPath; - else if (i == 1) - scrTxt = it.sProp; - else if (i == 2) - scrTxt = it.sStatus; - else if (i == 3) - scrTxt = it.sType; - else if (i == 4) - scrTxt = it.sValue; - - endPos = scrTxt.getLength(); - if (textSearch.SearchForward(scrTxt, &startPos, &endPos)) - { - InsertEntry(it); - break; - } - } - } - } - - m_xPrefBox->thaw(); - if (m_bSorted) - m_xPrefBox->make_sorted(); - - m_xPrefBox->all_foreach([this](weld::TreeIter& rEntry) { - m_xPrefBox->expand_row(rEntry); - return false; - }); - m_xPrefBox->show(); +IMPL_LINK_NOARG(CuiAboutConfigTabPage, ModifiedHdl_Impl, weld::Toggleable&, void) +{ + InputChanged(); } void CuiAboutConfigTabPage::InsertEntry(const prefBoxEntry& rEntry) { + bool bOnlyModified = m_xModifiedCheckBtn->get_active(); + if (bOnlyModified && !rEntry.pUserData->bWasModified) + return; + OUString sPathWithProperty = rEntry.pUserData->sPropertyPath; sal_Int32 index = sPathWithProperty.lastIndexOf(rEntry.sProp); OUString sPath = sPathWithProperty.copy(0, index); @@ -852,18 +1029,21 @@ void CuiAboutConfigTabPage::InsertEntry(const prefBoxEntry& rEntry) do { int prevIndex = index; - index = sPath.indexOf("/", index+1); + index = sPath.indexOf("/", index + 1); // deal with no parent case (tdf#107811) if (index < 0) { - OUString sId(OUString::number(reinterpret_cast<sal_Int64>(rEntry.pUserData))); - m_xPrefBox->insert(nullptr, -1, &rEntry.sProp, &sId, nullptr, nullptr, false, m_xScratchIter.get()); + OUString sId(weld::toId(rEntry.pUserData)); + m_xPrefBox->insert(nullptr, -1, &rEntry.sProp, &sId, nullptr, nullptr, false, + m_xScratchIter.get()); m_xPrefBox->set_text(*m_xScratchIter, rEntry.sStatus, 1); m_xPrefBox->set_text(*m_xScratchIter, rEntry.sType, 2); m_xPrefBox->set_text(*m_xScratchIter, rEntry.sValue, 3); + m_xPrefBox->set_text_emphasis(*m_xScratchIter, rEntry.pUserData->bWasModified, -1); + m_xPrefBox->set_sensitive(*m_xScratchIter, !rEntry.pUserData->bIsReadOnly); return; } - OUString sParentName = sPath.copy(prevIndex+1, index - prevIndex - 1); + OUString sParentName = sPath.copy(prevIndex + 1, index - prevIndex - 1); bool hasEntry = false; bool bStartOk; @@ -890,28 +1070,33 @@ void CuiAboutConfigTabPage::InsertEntry(const prefBoxEntry& rEntry) if (!hasEntry) { - m_xPrefBox->insert(xGrandParentEntry.get(), -1, &sParentName, nullptr, nullptr, nullptr, false, xParentEntry.get()); + m_xPrefBox->insert(xGrandParentEntry.get(), -1, &sParentName, nullptr, nullptr, nullptr, + false, xParentEntry.get()); //It is needed, without this the selection line will be truncated. m_xPrefBox->set_text(*xParentEntry, "", 1); m_xPrefBox->set_text(*xParentEntry, "", 2); m_xPrefBox->set_text(*xParentEntry, "", 3); + m_xPrefBox->set_sensitive(*xParentEntry, true); } xGrandParentEntry = m_xPrefBox->make_iterator(xParentEntry.get()); - } while(index < sPath.getLength() - 1); + } while (index < sPath.getLength() - 1); - OUString sId(OUString::number(reinterpret_cast<sal_Int64>(rEntry.pUserData))); - m_xPrefBox->insert(xParentEntry.get(), -1, &rEntry.sProp, &sId, nullptr, nullptr, false, m_xScratchIter.get()); + OUString sId(weld::toId(rEntry.pUserData)); + m_xPrefBox->insert(xParentEntry.get(), -1, &rEntry.sProp, &sId, nullptr, nullptr, false, + m_xScratchIter.get()); m_xPrefBox->set_text(*m_xScratchIter, rEntry.sStatus, 1); m_xPrefBox->set_text(*m_xScratchIter, rEntry.sType, 2); m_xPrefBox->set_text(*m_xScratchIter, rEntry.sValue, 3); + m_xPrefBox->set_text_emphasis(*m_xScratchIter, rEntry.pUserData->bWasModified, -1); + m_xPrefBox->set_sensitive(*m_xScratchIter, !rEntry.pUserData->bIsReadOnly); } IMPL_LINK(CuiAboutConfigTabPage, ExpandingHdl_Impl, const weld::TreeIter&, rEntry, bool) { if (m_xPrefBox->iter_has_child(rEntry)) return true; - UserData *pUserData = reinterpret_cast<UserData*>(m_xPrefBox->get_id(rEntry).toInt64()); + UserData* pUserData = weld::fromId<UserData*>(m_xPrefBox->get_id(rEntry)); if (pUserData && !pUserData->bIsPropertyPath) { assert(pUserData->aXNameAccess.is()); diff --git a/cui/source/options/optaboutconfig.hxx b/cui/source/options/optaboutconfig.hxx index 69a207da6712..2b9402369a26 100644 --- a/cui/source/options/optaboutconfig.hxx +++ b/cui/source/options/optaboutconfig.hxx @@ -11,6 +11,7 @@ #include <com/sun/star/container/XNameAccess.hpp> +#include <dlgname.hxx> #include <i18nutil/searchopt.hxx> #include <vcl/weld.hxx> @@ -36,60 +37,52 @@ private: std::unique_ptr<weld::Button> m_xResetBtn; std::unique_ptr<weld::Button> m_xEditBtn; std::unique_ptr<weld::Button> m_xSearchBtn; + std::unique_ptr<weld::CheckButton> m_xModifiedCheckBtn; std::unique_ptr<weld::Entry> m_xSearchEdit; std::unique_ptr<weld::TreeView> m_xPrefBox; std::unique_ptr<weld::TreeIter> m_xScratchIter; - std::vector < std::unique_ptr<UserData> > m_vectorUserData; + std::vector<std::unique_ptr<UserData>> m_vectorUserData; std::vector<prefBoxEntry> m_modifiedPrefBoxEntries; - std::vector< std::shared_ptr< Prop_Impl > > m_vectorOfModified; + std::vector<std::shared_ptr<Prop_Impl>> m_vectorOfModified; - //for search + //for search i18nutil::SearchOptions2 m_options; std::vector<prefBoxEntry> m_prefBoxEntries; bool m_bSorted; - void AddToModifiedVector( const std::shared_ptr< Prop_Impl >& rProp ); - static std::vector< OUString > commaStringToSequence( const OUString& rCommaSepString ); + void AddToModifiedVector(const std::shared_ptr<Prop_Impl>& rProp); + static std::vector<OUString> commaStringToSequence(std::u16string_view rCommaSepString); void InsertEntry(const prefBoxEntry& rEntry); + DECL_LINK(QueryTooltip, const weld::TreeIter& rIter, OUString); DECL_LINK(StandardHdl_Impl, weld::Button&, void); DECL_LINK(DoubleClickHdl_Impl, weld::TreeView&, bool); DECL_LINK(ResetBtnHdl_Impl, weld::Button&, void); DECL_LINK(SearchHdl_Impl, weld::Button&, void); + DECL_LINK(ModifiedHdl_Impl, weld::Toggleable&, void); DECL_LINK(ExpandingHdl_Impl, const weld::TreeIter&, bool); DECL_LINK(HeaderBarClick, int, void); + DECL_STATIC_LINK(CuiAboutConfigTabPage, ValidNameHdl, SvxNameDialog&, bool); public: - explicit CuiAboutConfigTabPage(weld::Window* pParent); - virtual ~CuiAboutConfigTabPage() override; - void InsertEntry(const OUString &rPropertyPath, const OUString& rProp, const OUString& rStatus, const OUString& rType, const OUString& rValue, - const weld::TreeIter* pParentEntry, bool bInsertToPrefBox); - void Reset(); - void FillItems(const css::uno::Reference<css::container::XNameAccess>& xNameAccess, - const weld::TreeIter* pParentEntry = nullptr, int lineage = 0, bool bLoadAll = false); - static css::uno::Reference< css::container::XNameAccess > getConfigAccess( const OUString& sNodePath, bool bUpdate ); - void FillItemSet(); -}; - -class CuiAboutConfigValueDialog : public weld::GenericDialogController -{ -private: - bool m_bNumericOnly; - std::unique_ptr<weld::Entry> m_xEDValue; - - DECL_LINK(KeyInputHdl, const KeyEvent&, bool); - -public: - CuiAboutConfigValueDialog(weld::Window* pWindow, const OUString& rValue , int limit); - virtual ~CuiAboutConfigValueDialog() override; - - OUString getValue() const - { - return m_xEDValue->get_text(); - } + explicit CuiAboutConfigTabPage(weld::Window* pParent); + virtual ~CuiAboutConfigTabPage() override; + void InsertEntry(const OUString& rPropertyPath, css::uno::Any aPropertyValue, + const OUString& rProp, const OUString& rStatus, const OUString& rType, + const OUString& rValue, const OUString& rTooltip, + const weld::TreeIter* pParentEntry, bool bInsertToPrefBox, bool bIsReadOnly, + bool bWasMOdified); + void Reset(); + void InputChanged(); + void FillItems(const css::uno::Reference<css::container::XNameAccess>& xNameAccess, + const weld::TreeIter* pParentEntry = nullptr, int lineage = 0, + bool bLoadAll = false); + static css::uno::Reference<css::container::XNameAccess> + getConfigAccess(const OUString& sNodePath, bool bUpdate); + void FillItemSet(); }; /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/cui/source/options/optaccessibility.cxx b/cui/source/options/optaccessibility.cxx index a394ff955a4a..008a4a273502 100644 --- a/cui/source/options/optaccessibility.cxx +++ b/cui/source/options/optaccessibility.cxx @@ -27,11 +27,18 @@ SvxAccessibilityOptionsTabPage::SvxAccessibilityOptionsTabPage(weld::Container* : SfxTabPage(pPage, pController, "cui/ui/optaccessibilitypage.ui", "OptAccessibilityPage", &rSet) , m_xAccessibilityTool(m_xBuilder->weld_check_button("acctool")) , m_xTextSelectionInReadonly(m_xBuilder->weld_check_button("textselinreadonly")) + , m_xTextSelectionInReadonlyImg(m_xBuilder->weld_widget("locktextselinreadonly")) , m_xAnimatedGraphics(m_xBuilder->weld_check_button("animatedgraphics")) + , m_xAnimatedGraphicsImg(m_xBuilder->weld_widget("lockanimatedgraphics")) , m_xAnimatedTexts(m_xBuilder->weld_check_button("animatedtext")) - , m_xAutoDetectHC(m_xBuilder->weld_check_button("autodetecthc")) + , m_xAnimatedTextsImg(m_xBuilder->weld_widget("lockanimatedtext")) + , m_xHighContrast(m_xBuilder->weld_combo_box("highcontrast")) + , m_xHighContrastImg(m_xBuilder->weld_widget("lockhighcontrast")) + , m_xHighContrastLabel(m_xBuilder->weld_label("label13")) , m_xAutomaticFontColor(m_xBuilder->weld_check_button("autofontcolor")) + , m_xAutomaticFontColorImg(m_xBuilder->weld_widget("lockautofontcolor")) , m_xPagePreviews(m_xBuilder->weld_check_button("systempagepreviewcolor")) + , m_xPagePreviewsImg(m_xBuilder->weld_widget("locksystempagepreviewcolor")) { #ifdef UNX // UNIX: read the gconf2 setting instead to use the checkbox @@ -48,6 +55,29 @@ std::unique_ptr<SfxTabPage> SvxAccessibilityOptionsTabPage::Create(weld::Contain return std::make_unique<SvxAccessibilityOptionsTabPage>(pPage, pController, *rAttrSet); } +OUString SvxAccessibilityOptionsTabPage::GetAllStrings() +{ + OUString sAllStrings; + OUString labels[] = { "label1", "label2", "label13" }; + + for (const auto& label : labels) + { + if (const auto& pString = m_xBuilder->weld_label(label)) + sAllStrings += pString->get_label() + " "; + } + + OUString checkButton[] = { "acctool", "textselinreadonly", "animatedgraphics", + "animatedtext", "autofontcolor", "systempagepreviewcolor" }; + + for (const auto& check : checkButton) + { + if (const auto& pString = m_xBuilder->weld_check_button(check)) + sAllStrings += pString->get_label() + " "; + } + + return sAllStrings.replaceAll("_", ""); +} + bool SvxAccessibilityOptionsTabPage::FillItemSet( SfxItemSet* ) { std::shared_ptr<comphelper::ConfigurationChanges> batch( comphelper::ConfigurationChanges::create() ); @@ -61,8 +91,8 @@ bool SvxAccessibilityOptionsTabPage::FillItemSet( SfxItemSet* ) officecfg::Office::Common::Accessibility::IsAutomaticFontColor::set(m_xAutomaticFontColor->get_active(), batch); if ( !officecfg::Office::Common::Accessibility::IsSelectionInReadonly::isReadOnly() ) officecfg::Office::Common::Accessibility::IsSelectionInReadonly::set(m_xTextSelectionInReadonly->get_active(), batch); - if ( !officecfg::Office::Common::Accessibility::AutoDetectSystemHC::isReadOnly() ) - officecfg::Office::Common::Accessibility::AutoDetectSystemHC::set(m_xAutoDetectHC->get_active(), batch); + if ( !officecfg::Office::Common::Accessibility::HighContrast::isReadOnly() ) + officecfg::Office::Common::Accessibility::HighContrast::set(m_xHighContrast->get_active(), batch); batch->commit(); AllSettings aAllSettings = Application::GetSettings(); @@ -80,28 +110,47 @@ bool SvxAccessibilityOptionsTabPage::FillItemSet( SfxItemSet* ) void SvxAccessibilityOptionsTabPage::Reset( const SfxItemSet* ) { m_xPagePreviews->set_active( officecfg::Office::Common::Accessibility::IsForPagePreviews::get() ); - if( officecfg::Office::Common::Accessibility::IsForPagePreviews::isReadOnly() ) + if (officecfg::Office::Common::Accessibility::IsForPagePreviews::isReadOnly()) + { m_xPagePreviews->set_sensitive(false); + m_xPagePreviewsImg->set_visible(true); + } m_xAnimatedGraphics->set_active( officecfg::Office::Common::Accessibility::IsAllowAnimatedGraphics::get() ); - if( officecfg::Office::Common::Accessibility::IsAllowAnimatedGraphics::isReadOnly() ) + if (officecfg::Office::Common::Accessibility::IsAllowAnimatedGraphics::isReadOnly()) + { m_xAnimatedGraphics->set_sensitive(false); + m_xAnimatedGraphicsImg->set_visible(true); + } m_xAnimatedTexts->set_active( officecfg::Office::Common::Accessibility::IsAllowAnimatedText::get() ); - if( officecfg::Office::Common::Accessibility::IsAllowAnimatedText::isReadOnly() ) + if (officecfg::Office::Common::Accessibility::IsAllowAnimatedText::isReadOnly()) + { m_xAnimatedTexts->set_sensitive(false); + m_xAnimatedTextsImg->set_visible(true); + } m_xAutomaticFontColor->set_active( officecfg::Office::Common::Accessibility::IsAutomaticFontColor::get() ); - if( officecfg::Office::Common::Accessibility::IsAutomaticFontColor::isReadOnly() ) + if (officecfg::Office::Common::Accessibility::IsAutomaticFontColor::isReadOnly()) + { m_xAutomaticFontColor->set_sensitive(false); + m_xAutomaticFontColorImg->set_visible(true); + } m_xTextSelectionInReadonly->set_active( officecfg::Office::Common::Accessibility::IsSelectionInReadonly::get() ); - if( officecfg::Office::Common::Accessibility::IsSelectionInReadonly::isReadOnly() ) + if (officecfg::Office::Common::Accessibility::IsSelectionInReadonly::isReadOnly()) + { m_xTextSelectionInReadonly->set_sensitive(false); + m_xTextSelectionInReadonlyImg->set_visible(true); + } - m_xAutoDetectHC->set_active( officecfg::Office::Common::Accessibility::AutoDetectSystemHC::get() ); - if( officecfg::Office::Common::Accessibility::AutoDetectSystemHC::isReadOnly() ) - m_xAutoDetectHC->set_sensitive(false); + m_xHighContrast->set_active( officecfg::Office::Common::Accessibility::HighContrast::get() ); + if (officecfg::Office::Common::Accessibility::HighContrast::isReadOnly()) + { + m_xHighContrast->set_sensitive(false); + m_xHighContrastLabel->set_sensitive(false); + m_xHighContrastImg->set_visible(true); + } AllSettings aAllSettings = Application::GetSettings(); const MiscSettings& aMiscSettings = aAllSettings.GetMiscSettings(); diff --git a/cui/source/options/optaccessibility.hxx b/cui/source/options/optaccessibility.hxx index 35d5fdefde03..73fe167c1679 100644 --- a/cui/source/options/optaccessibility.hxx +++ b/cui/source/options/optaccessibility.hxx @@ -24,17 +24,27 @@ class SvxAccessibilityOptionsTabPage : public SfxTabPage { std::unique_ptr<weld::CheckButton> m_xAccessibilityTool; std::unique_ptr<weld::CheckButton> m_xTextSelectionInReadonly; + std::unique_ptr<weld::Widget> m_xTextSelectionInReadonlyImg; std::unique_ptr<weld::CheckButton> m_xAnimatedGraphics; + std::unique_ptr<weld::Widget> m_xAnimatedGraphicsImg; std::unique_ptr<weld::CheckButton> m_xAnimatedTexts; - std::unique_ptr<weld::CheckButton> m_xAutoDetectHC; + std::unique_ptr<weld::Widget> m_xAnimatedTextsImg; + std::unique_ptr<weld::ComboBox> m_xHighContrast; + std::unique_ptr<weld::Widget> m_xHighContrastImg; + std::unique_ptr<weld::Label> m_xHighContrastLabel; std::unique_ptr<weld::CheckButton> m_xAutomaticFontColor; + std::unique_ptr<weld::Widget> m_xAutomaticFontColorImg; std::unique_ptr<weld::CheckButton> m_xPagePreviews; + std::unique_ptr<weld::Widget> m_xPagePreviewsImg; public: SvxAccessibilityOptionsTabPage(weld::Container* pPage, weld::DialogController* pController, const SfxItemSet& rSet); virtual ~SvxAccessibilityOptionsTabPage() override; static std::unique_ptr<SfxTabPage> Create( weld::Container* pPage, weld::DialogController* pController, const SfxItemSet* rAttrSet ); + + virtual OUString GetAllStrings() override; + virtual bool FillItemSet( SfxItemSet* rSet ) override; virtual void Reset( const SfxItemSet* rSet ) override; }; diff --git a/cui/source/options/optasian.cxx b/cui/source/options/optasian.cxx index 94a192cfddc7..390621a0cdd9 100644 --- a/cui/source/options/optasian.cxx +++ b/cui/source/options/optasian.cxx @@ -20,9 +20,8 @@ #include <memory> #include <map> #include <optasian.hxx> -#include <osl/diagnose.h> #include <tools/debug.hxx> -#include <tools/diagnose_ex.h> +#include <comphelper/diagnose_ex.hxx> #include <o3tl/any.hxx> #include <i18nlangtag/mslangid.hxx> #include <svl/asiancfg.hxx> @@ -43,15 +42,15 @@ using namespace com::sun::star::i18n; using namespace com::sun::star::frame; using namespace com::sun::star::beans; -constexpr OUStringLiteral cIsKernAsianPunctuation = u"IsKernAsianPunctuation"; -constexpr OUStringLiteral cCharacterCompressionType = u"CharacterCompressionType"; +constexpr OUString cIsKernAsianPunctuation = u"IsKernAsianPunctuation"_ustr; +constexpr OUString cCharacterCompressionType = u"CharacterCompressionType"_ustr; namespace { struct SvxForbiddenChars_Impl { bool bRemoved; - std::unique_ptr<ForbiddenCharacters> pCharacters; + std::optional<ForbiddenCharacters> oCharacters; }; } @@ -64,12 +63,12 @@ struct SvxAsianLayoutPage_Impl Reference< XForbiddenCharacters > xForbidden; Reference< XPropertySet > xPrSet; Reference< XPropertySetInfo > xPrSetInfo; - std::map< LanguageType, std::unique_ptr<SvxForbiddenChars_Impl> > + std::map< LanguageType, SvxForbiddenChars_Impl > aChangedLanguagesMap; bool hasForbiddenCharacters(LanguageType eLang); SvxForbiddenChars_Impl* getForbiddenCharacters(LanguageType eLang); - void addForbiddenCharacters(LanguageType eLang, std::unique_ptr<ForbiddenCharacters> pForbidden); + void addForbiddenCharacters(LanguageType eLang, std::optional<ForbiddenCharacters> oForbidden); }; bool SvxAsianLayoutPage_Impl::hasForbiddenCharacters(LanguageType eLang) @@ -82,25 +81,25 @@ SvxForbiddenChars_Impl* SvxAsianLayoutPage_Impl::getForbiddenCharacters(Language auto it = aChangedLanguagesMap.find( eLang ); DBG_ASSERT( ( it != aChangedLanguagesMap.end() ), "language not available"); if( it != aChangedLanguagesMap.end() ) - return it->second.get(); + return &it->second; return nullptr; } void SvxAsianLayoutPage_Impl::addForbiddenCharacters( - LanguageType eLang, std::unique_ptr<ForbiddenCharacters> pForbidden) + LanguageType eLang, std::optional<ForbiddenCharacters> oForbidden) { auto itOld = aChangedLanguagesMap.find( eLang ); if( itOld == aChangedLanguagesMap.end() ) { - std::unique_ptr<SvxForbiddenChars_Impl> pChar(new SvxForbiddenChars_Impl); - pChar->bRemoved = nullptr == pForbidden; - pChar->pCharacters = std::move(pForbidden); - aChangedLanguagesMap.emplace( eLang, std::move(pChar) ); + SvxForbiddenChars_Impl aChar; + aChar.bRemoved = !oForbidden.has_value(); + aChar.oCharacters = std::move(oForbidden); + aChangedLanguagesMap.emplace( eLang, std::move(aChar) ); } else { - itOld->second->bRemoved = nullptr == pForbidden; - itOld->second->pCharacters = std::move(pForbidden); + itOld->second.bRemoved = !oForbidden.has_value(); + itOld->second.oCharacters = std::move(oForbidden); } } @@ -142,6 +141,32 @@ std::unique_ptr<SfxTabPage> SvxAsianLayoutPage::Create(weld::Container* pPage, w return std::make_unique<SvxAsianLayoutPage>(pPage, pController, *rAttrSet); } +OUString SvxAsianLayoutPage::GetAllStrings() +{ + OUString sAllStrings; + OUString labels[] + = { "label1", "label2", "label3", "languageft", "startft", "endft", "hintft" }; + + for (const auto& label : labels) + { + if (const auto& pString = m_xBuilder->weld_label(label)) + sAllStrings += pString->get_label() + " "; + } + + OUString radioButton[] = { "charkerning", "charpunctkerning", "nocompression", + "punctcompression", "punctkanacompression" }; + + for (const auto& radio : radioButton) + { + if (const auto& pString = m_xBuilder->weld_radio_button(radio)) + sAllStrings += pString->get_label() + " "; + } + + sAllStrings += m_xStandardCB->get_label() + " "; + + return sAllStrings.replaceAll("_", ""); +} + bool SvxAsianLayoutPage::FillItemSet( SfxItemSet* ) { if(m_xCharKerningRB->get_state_changed_from_saved()) @@ -176,10 +201,10 @@ bool SvxAsianLayoutPage::FillItemSet( SfxItemSet* ) for (auto const& changedLanguage : pImpl->aChangedLanguagesMap) { Locale aLocale( LanguageTag::convertToLocale(changedLanguage.first)); - if(changedLanguage.second->bRemoved) + if(changedLanguage.second.bRemoved) pImpl->xForbidden->removeForbiddenCharacters( aLocale ); - else if(changedLanguage.second->pCharacters) - pImpl->xForbidden->setForbiddenCharacters( aLocale, *( changedLanguage.second->pCharacters ) ); + else if(changedLanguage.second.oCharacters) + pImpl->xForbidden->setForbiddenCharacters( aLocale, *( changedLanguage.second.oCharacters ) ); } } catch (const Exception&) @@ -206,8 +231,8 @@ void SvxAsianLayoutPage::Reset( const SfxItemSet* ) } if( pImpl->xPrSet.is() ) pImpl->xPrSetInfo = pImpl->xPrSet->getPropertySetInfo(); - bool bKernWesternText = pImpl->aConfig.IsKerningWesternTextOnly(); - CharCompressType nCompress = pImpl->aConfig.GetCharDistanceCompression(); + bool bKernWesternText = SvxAsianConfig::IsKerningWesternTextOnly(); + CharCompressType nCompress = SvxAsianConfig::GetCharDistanceCompression(); if(pImpl->xPrSetInfo.is()) { OUString sForbidden("ForbiddenCharacters"); @@ -287,14 +312,14 @@ IMPL_LINK_NOARG(SvxAsianLayoutPage, LanguageHdl, weld::ComboBox&, void) if(bAvail) { SvxForbiddenChars_Impl* pElement = pImpl->getForbiddenCharacters(eSelectLanguage); - if(pElement->bRemoved || !pElement->pCharacters) + if(pElement->bRemoved || !pElement->oCharacters) { bAvail = false; } else { - sStart = pElement->pCharacters->beginLine; - sEnd = pElement->pCharacters->endLine; + sStart = pElement->oCharacters->beginLine; + sEnd = pElement->oCharacters->endLine; } } else @@ -317,11 +342,11 @@ IMPL_LINK_NOARG(SvxAsianLayoutPage, LanguageHdl, weld::ComboBox&, void) } else { - bAvail = pImpl->aConfig.GetStartEndChars( aLocale, sStart, sEnd ); + bAvail = SvxAsianConfig::GetStartEndChars( aLocale, sStart, sEnd ); } if(!bAvail) { - LocaleDataWrapper aWrap( aLanguageTag ); + LocaleDataWrapper aWrap( std::move(aLanguageTag) ); ForbiddenCharacters aForbidden = aWrap.getForbiddenCharacters(); sStart = aForbidden.beginLine; sEnd = aForbidden.endLine; @@ -359,13 +384,13 @@ IMPL_LINK(SvxAsianLayoutPage, ModifyHdl, weld::Entry&, rEdit, void) { if(bEnable) { - std::unique_ptr<ForbiddenCharacters> pFCSet(new ForbiddenCharacters); - pFCSet->beginLine = sStart; - pFCSet->endLine = sEnd; - pImpl->addForbiddenCharacters(eSelectLanguage, std::move(pFCSet)); + ForbiddenCharacters aFCSet; + aFCSet.beginLine = sStart; + aFCSet.endLine = sEnd; + pImpl->addForbiddenCharacters(eSelectLanguage, std::move(aFCSet)); } else - pImpl->addForbiddenCharacters(eSelectLanguage, nullptr); + pImpl->addForbiddenCharacters(eSelectLanguage, std::nullopt); } catch (const Exception&) { diff --git a/cui/source/options/optbasic.cxx b/cui/source/options/optbasic.cxx index c550d9440edd..bbe20fd01eee 100644 --- a/cui/source/options/optbasic.cxx +++ b/cui/source/options/optbasic.cxx @@ -53,6 +53,29 @@ void SvxBasicIDEOptionsPage::LoadConfig() m_xUseExtendedTypesChk->set_sensitive( !officecfg::Office::BasicIDE::Autocomplete::UseExtended::isReadOnly() ); } +OUString SvxBasicIDEOptionsPage::GetAllStrings() +{ + OUString sAllStrings; + OUString labels[] = { "label1", "label2", "label3" }; + + for (const auto& label : labels) + { + if (const auto& pString = m_xBuilder->weld_label(label)) + sAllStrings += pString->get_label() + " "; + } + + OUString checkButton[] = { "codecomplete_enable", "autocorrect", "autoclose_quotes", + "autoclose_paren", "autoclose_proc", "extendedtypes_enable" }; + + for (const auto& check : checkButton) + { + if (const auto& pString = m_xBuilder->weld_check_button(check)) + sAllStrings += pString->get_label() + " "; + } + + return sAllStrings.replaceAll("_", ""); +} + bool SvxBasicIDEOptionsPage::FillItemSet( SfxItemSet* /*rCoreSet*/ ) { bool bModified = false; diff --git a/cui/source/options/optbasic.hxx b/cui/source/options/optbasic.hxx index 990b54d4e3bb..bc4274eaca1e 100644 --- a/cui/source/options/optbasic.hxx +++ b/cui/source/options/optbasic.hxx @@ -38,6 +38,9 @@ public: virtual ~SvxBasicIDEOptionsPage() override; static std::unique_ptr<SfxTabPage> Create( weld::Container* pPage, weld::DialogController* pController, const SfxItemSet* rSet ); + + virtual OUString GetAllStrings() override; + virtual bool FillItemSet( SfxItemSet* rSet ) override; virtual void Reset( const SfxItemSet* rSet ) override; virtual void FillUserData() override; diff --git a/cui/source/options/optchart.cxx b/cui/source/options/optchart.cxx index b8499c5ee886..eef87d2cd324 100644 --- a/cui/source/options/optchart.cxx +++ b/cui/source/options/optchart.cxx @@ -26,6 +26,7 @@ #include <svx/svxids.hrc> #include <osl/diagnose.h> #include <officecfg/Office/Common.hxx> +#include <officecfg/Office/Chart.hxx> void SvxDefaultColorOptPage::InsertColorEntry(const XColorEntry& rEntry, sal_Int32 nPos) { @@ -100,6 +101,14 @@ SvxDefaultColorOptPage::SvxDefaultColorOptPage(weld::Container* pPage, weld::Dia { m_xLbChartColors->set_size_request(-1, m_xLbChartColors->get_height_rows(16)); + if (officecfg::Office::Chart::DefaultColor::Series::isReadOnly()) + { + m_xPBDefault->set_sensitive(false); + m_xPBAdd->set_sensitive(false); + m_xPBRemove->set_sensitive(false); + m_xValSetColorBoxWin->set_sensitive(false); + } + m_xPBDefault->connect_clicked( LINK( this, SvxDefaultColorOptPage, ResetToDefaults ) ); m_xPBAdd->connect_clicked( LINK( this, SvxDefaultColorOptPage, AddChartColor ) ); m_xPBRemove->connect_clicked( LINK( this, SvxDefaultColorOptPage, RemoveChartColor ) ); @@ -109,19 +118,16 @@ SvxDefaultColorOptPage::SvxDefaultColorOptPage(weld::Container* pPage, weld::Dia m_xValSetColorBox->SetStyle( m_xValSetColorBox->GetStyle() | WB_ITEMBORDER | WB_NAMEFIELD | WB_VSCROLL ); - m_SvxChartOptionsUniquePtr.reset(new SvxChartOptions); - - const SfxPoolItem* pItem = nullptr; - if ( rInAttrs.GetItemState( SID_SCH_EDITOPTIONS, false, &pItem ) == SfxItemState::SET ) + if ( const SvxChartColorTableItem* pEditOptionsItem = rInAttrs.GetItemIfSet( SID_SCH_EDITOPTIONS, false ) ) { m_SvxChartColorTableUniquePtr = std::make_unique<SvxChartColorTable>( - static_cast<const SvxChartColorTableItem*>(pItem)->GetColorList()); + pEditOptionsItem->GetColorList()); } else { m_SvxChartColorTableUniquePtr = std::make_unique<SvxChartColorTable>(); m_SvxChartColorTableUniquePtr->useDefault(); - m_SvxChartOptionsUniquePtr->SetDefaultColors(*m_SvxChartColorTableUniquePtr); + SvxChartOptions::SetDefaultColors(*m_SvxChartColorTableUniquePtr); } Construct(); @@ -146,6 +152,28 @@ std::unique_ptr<SfxTabPage> SvxDefaultColorOptPage::Create( weld::Container* pPa return std::make_unique<SvxDefaultColorOptPage>( pPage, pController, *rAttrs ); } +OUString SvxDefaultColorOptPage::GetAllStrings() +{ + OUString sAllStrings; + OUString labels[] = { "label20", "label1" }; + + for (const auto& label : labels) + { + if (const auto& pString = m_xBuilder->weld_label(label)) + sAllStrings += pString->get_label() + " "; + } + + OUString buttons[] = { "add", "delete", "default" }; + + for (const auto& btn : buttons) + { + if (const auto& pString = m_xBuilder->weld_button(btn)) + sAllStrings += pString->get_label() + " "; + } + + return sAllStrings.replaceAll("_", ""); +} + bool SvxDefaultColorOptPage::FillItemSet( SfxItemSet* rOutAttrs ) { if( m_SvxChartColorTableUniquePtr ) @@ -176,11 +204,8 @@ void SvxDefaultColorOptPage::FillPaletteLB() void SvxDefaultColorOptPage::SaveChartOptions() { - if (m_SvxChartOptionsUniquePtr && m_SvxChartColorTableUniquePtr) - { - m_SvxChartOptionsUniquePtr->SetDefaultColors(*m_SvxChartColorTableUniquePtr); - m_SvxChartOptionsUniquePtr->Commit(); - } + if (m_SvxChartColorTableUniquePtr) + SvxChartOptions::SetDefaultColors(*m_SvxChartColorTableUniquePtr); } // event handlers diff --git a/cui/source/options/optchart.hxx b/cui/source/options/optchart.hxx index 11221617a9d1..22a01495b276 100644 --- a/cui/source/options/optchart.hxx +++ b/cui/source/options/optchart.hxx @@ -32,7 +32,6 @@ typedef std::vector<Color> ImpColorList; class SvxDefaultColorOptPage : public SfxTabPage { private: - std::unique_ptr<SvxChartOptions> m_SvxChartOptionsUniquePtr; // no reason to use a cloned SfxItem here (SvxChartColorTableItem) // that just leads to non-const SfxItem and potential trouble std::unique_ptr<SvxChartColorTable> m_SvxChartColorTableUniquePtr; @@ -70,6 +69,9 @@ public: void Construct(); static std::unique_ptr<SfxTabPage> Create( weld::Container* pPage, weld::DialogController* pController, const SfxItemSet* rInAttrs ); + + virtual OUString GetAllStrings() override; + virtual bool FillItemSet( SfxItemSet* rOutAttrs ) override; virtual void Reset( const SfxItemSet* rInAttrs ) override; diff --git a/cui/source/options/optcolor.cxx b/cui/source/options/optcolor.cxx index ebe066b1073e..d2c94669fa9f 100644 --- a/cui/source/options/optcolor.cxx +++ b/cui/source/options/optcolor.cxx @@ -21,6 +21,8 @@ #include <bitset> +#include <com/sun/star/configuration/ReadWriteAccess.hpp> +#include <com/sun/star/beans/PropertyAttribute.hpp> #include <tools/debug.hxx> #include <editeng/editids.hrc> #include <svtools/colorcfg.hxx> @@ -34,7 +36,10 @@ #include <dialmgr.hxx> #include "optcolor.hxx" #include <strings.hrc> - +#include <svtools/miscopt.hxx> +#include <officecfg/Office/Common.hxx> +#include <officecfg/Office/ExtendedColorScheme.hxx> +#include <officecfg/Office/UI.hxx> using namespace ::com::sun::star; using namespace ::svtools; @@ -61,7 +66,7 @@ struct // group Group eGroup; // .ui group name - const char *pGroup; + OUString pGroup; } const vGroupInfo[] = { @@ -81,11 +86,13 @@ struct // group Group eGroup; //checkbox (or simple text) - const char *pText; + OUString pText; //color listbox - const char *pColor; + OUString pColor; // has checkbox? bool bCheckBox; + //prop name + std::u16string_view sPropName; } const vEntryInfo[] = { @@ -97,66 +104,102 @@ const vEntryInfo[] = // The list of these entries (enum ColorConfigEntry) are in colorcfg.hxx. - { Group_General, IDS(doccolor) }, - { Group_General, IDS_CB(docboundaries) }, - { Group_General, IDS(appback) }, - { Group_General, IDS_CB(objboundaries) }, - { Group_General, IDS_CB(tblboundaries) }, - { Group_General, IDS(font) }, - { Group_General, IDS_CB(unvisitedlinks) }, - { Group_General, IDS_CB(visitedlinks) }, - { Group_General, IDS(autospellcheck) }, - { Group_General, IDS(smarttags) }, - { Group_General, IDS_CB(shadows) }, - - { Group_Writer, IDS(writergrid) }, - { Group_Writer, IDS_CB(field) }, - { Group_Writer, IDS_CB(index) }, - { Group_Writer, IDS(direct) }, - { Group_Writer, IDS(script) }, - { Group_Writer, IDS_CB(section) }, - { Group_Writer, IDS(hdft) }, - { Group_Writer, IDS(pagebreak) }, - - { Group_Html, IDS(sgml) }, - { Group_Html, IDS(htmlcomment) }, - { Group_Html, IDS(htmlkeyword) }, - { Group_Html, IDS(unknown) }, - - { Group_Calc, IDS(calcgrid) }, - { Group_Calc, IDS(brk) }, - { Group_Calc, IDS(brkmanual) }, - { Group_Calc, IDS(brkauto) }, - { Group_Calc, IDS(det) }, - { Group_Calc, IDS(deterror) }, - { Group_Calc, IDS(ref) }, - { Group_Calc, IDS(notes) }, - { Group_Calc, IDS(values) }, - { Group_Calc, IDS(formulas) }, - { Group_Calc, IDS(text) }, - { Group_Calc, IDS(protectedcells) }, - - { Group_Draw, IDS(drawgrid) }, - - { Group_Basic, IDS(basicid) }, - { Group_Basic, IDS(basiccomment) }, - { Group_Basic, IDS(basicnumber) }, - { Group_Basic, IDS(basicstring) }, - { Group_Basic, IDS(basicop) }, - { Group_Basic, IDS(basickeyword) }, - { Group_Basic, IDS(error) }, - - { Group_Sql, IDS(sqlid) }, - { Group_Sql, IDS(sqlnumber) }, - { Group_Sql, IDS(sqlstring) }, - { Group_Sql, IDS(sqlop) }, - { Group_Sql, IDS(sqlkeyword) }, - { Group_Sql, IDS(sqlparam) }, - { Group_Sql, IDS(sqlcomment) } + { Group_General, IDS(doccolor), std::u16string_view(u"/DocColor") }, + { Group_General, IDS_CB(docboundaries), std::u16string_view(u"/DocBoundaries") }, + { Group_General, IDS(appback), std::u16string_view(u"/AppBackground") }, + { Group_General, IDS_CB(objboundaries), std::u16string_view(u"/ObjectBoundaries") }, + { Group_General, IDS_CB(tblboundaries), std::u16string_view(u"/TableBoundaries") }, + { Group_General, IDS(font), std::u16string_view(u"/FontColor") }, + { Group_General, IDS_CB(unvisitedlinks), std::u16string_view(u"/Links") }, + { Group_General, IDS_CB(visitedlinks), std::u16string_view(u"/LinksVisited") }, + { Group_General, IDS(autospellcheck), std::u16string_view(u"/Spell") }, + { Group_General, IDS(grammarcheck), std::u16string_view(u"/Grammar") }, + { Group_General, IDS(smarttags), std::u16string_view(u"/SmartTags") }, + { Group_General, IDS_CB(shadows), std::u16string_view(u"/Shadow") }, + + { Group_Writer, IDS(writergrid), std::u16string_view(u"/WriterTextGrid") }, + { Group_Writer, IDS_CB(field), std::u16string_view(u"/WriterFieldShadings") }, + { Group_Writer, IDS_CB(index), std::u16string_view(u"/WriterIdxShadings") }, + { Group_Writer, IDS(direct), std::u16string_view(u"/WriterDirectCursor") }, + { Group_Writer, IDS(script), std::u16string_view(u"/WriterScriptIndicator") }, + { Group_Writer, IDS_CB(section), std::u16string_view(u"/WriterSectionBoundaries") }, + { Group_Writer, IDS(hdft), std::u16string_view(u"/WriterHeaderFooterMark") }, + { Group_Writer, IDS(pagebreak), std::u16string_view(u"/WriterPageBreaks") }, + + { Group_Html, IDS(sgml), std::u16string_view(u"/HTMLSGML") }, + { Group_Html, IDS(htmlcomment), std::u16string_view(u"/HTMLComment") }, + { Group_Html, IDS(htmlkeyword), std::u16string_view(u"/HTMLKeyword") }, + { Group_Html, IDS(unknown), std::u16string_view(u"/HTMLUnknown") }, + + { Group_Calc, IDS(calcgrid), std::u16string_view(u"/CalcGrid") }, + { Group_Calc, IDS(calccellfocus), std::u16string_view(u"/CalcCellFocus") }, + { Group_Calc, IDS(brk), std::u16string_view(u"/CalcPageBreak") }, + { Group_Calc, IDS(brkmanual), std::u16string_view(u"/CalcPageBreakManual") }, + { Group_Calc, IDS(brkauto), std::u16string_view(u"/CalcPageBreakAutomatic") }, + { Group_Calc, IDS_CB(hiddencolrow), std::u16string_view(u"/CalcHiddenColRow") }, + { Group_Calc, IDS_CB(textoverflow), std::u16string_view(u"/CalcTextOverflow") }, + { Group_Calc, IDS(comments), std::u16string_view(u"/CalcComments") }, + { Group_Calc, IDS(det), std::u16string_view(u"/CalcDetective") }, + { Group_Calc, IDS(deterror), std::u16string_view(u"/CalcDetectiveError") }, + { Group_Calc, IDS(ref), std::u16string_view(u"/CalcReference") }, + { Group_Calc, IDS(notes), std::u16string_view(u"/CalcNotesBackground") }, + { Group_Calc, IDS(values), std::u16string_view(u"/CalcValue") }, + { Group_Calc, IDS(formulas), std::u16string_view(u"/CalcFormula") }, + { Group_Calc, IDS(text), std::u16string_view(u"/CalcText") }, + { Group_Calc, IDS(protectedcells), std::u16string_view(u"/CalcProtectedBackground") }, + + { Group_Draw, IDS(drawgrid), std::u16string_view(u"/DrawGrid") }, + + { Group_Basic, IDS(basiceditor), std::u16string_view(u"/BASICEditor") }, + { Group_Basic, IDS(basicid), std::u16string_view(u"/BASICIdentifier") }, + { Group_Basic, IDS(basiccomment), std::u16string_view(u"/BASICComment") }, + { Group_Basic, IDS(basicnumber), std::u16string_view(u"/BASICNumber") }, + { Group_Basic, IDS(basicstring), std::u16string_view(u"/BASICString") }, + { Group_Basic, IDS(basicop), std::u16string_view(u"/BASICOperator") }, + { Group_Basic, IDS(basickeyword), std::u16string_view(u"/BASICKeyword") }, + { Group_Basic, IDS(error), std::u16string_view(u"/BASICError") }, + + { Group_Sql, IDS(sqlid), std::u16string_view(u"/SQLIdentifier") }, + { Group_Sql, IDS(sqlnumber), std::u16string_view(u"/SQLNumber") }, + { Group_Sql, IDS(sqlstring), std::u16string_view(u"/SQLString") }, + { Group_Sql, IDS(sqlop), std::u16string_view(u"/SQLOperator") }, + { Group_Sql, IDS(sqlkeyword), std::u16string_view(u"/SQLKeyword") }, + { Group_Sql, IDS(sqlparam), std::u16string_view(u"/SQLParameter") }, + { Group_Sql, IDS(sqlcomment), std::u16string_view(u"/SQLComment") } #undef IDS }; +// Maps the names of default color schemes to the corresponding TranslateId +const std::map<OUString, OUString> &getColorSchemes() +{ + static std::map<OUString, OUString> const vColorSchemes = { + {"COLOR_SCHEME_LIBREOFFICE_AUTOMATIC", CuiResId(RID_COLOR_SCHEME_LIBREOFFICE_AUTOMATIC)}, + }; + return vColorSchemes; +}; + +// If the color scheme name has a translated string, then return the translation +// Or else simply return the input string +// For non-translatable color schemes, the ID and the name are the same +OUString lcl_SchemeIdToTranslatedName(const OUString& sSchemeId) +{ + auto it = getColorSchemes().find(sSchemeId); + if (it != getColorSchemes().end()) + return it->second; + return sSchemeId; +} + +// Given a translated color scheme name, return the scheme ID used in the UI.xcu file +// For non-translatable color schemes, the ID and the name are the same +OUString lcl_TranslatedNameToSchemeId(const OUString& sName) +{ + for (auto it = getColorSchemes().begin(); it != getColorSchemes().end(); ++it) + if (it->second == sName) + return it->first; + return sName; +} + // ColorConfigWindow_Impl class ColorConfigWindow_Impl @@ -170,6 +213,7 @@ public: Link<weld::Widget&,void> const&, weld::ScrolledWindow& rScroll); void Update(EditableColorConfig const*, EditableExtendedColorConfig const*); + void UpdateEntries(); void ClickHdl(EditableColorConfig*, const weld::Toggleable&); void ColorHdl(EditableColorConfig*, EditableExtendedColorConfig*, const ColorListBox*); @@ -188,7 +232,10 @@ public: return *m_xBox; } - void AdjustExtraWidths(int nTextWidth); + int GetLabelIndent() const + { + return m_nCheckBoxLabelOffset; + } private: // Chapter -- horizontal group separator stripe with text @@ -197,38 +244,37 @@ private: // text std::unique_ptr<weld::Label> m_xText; public: - Chapter(weld::Builder& rBuilder, const char* pLabelWidget, bool bShow); + Chapter(weld::Builder& rBuilder, const OUString& pLabelWidget, bool bShow); void SetText(const OUString& rLabel) { m_xText->set_label(rLabel); } }; // Entry -- a color config entry: // text (checkbox) + color list box - class Entry + struct Entry { - public: - Entry(weld::Window* pTopLevel, weld::Builder& rBuilder, const char* pTextWidget, const char* pColorWidget, - const Color& rColor, tools::Long nCheckBoxLabelOffset, bool bCheckBox, bool bShow); - public: + Entry(weld::Window* pTopLevel, weld::Builder& rBuilder, const OUString& pTextWidget, const OUString& pColorWidget, + const Color& rColor, int nCheckBoxLabelOffset, const ColorListBox* pCache, bool bCheckBox, bool bShow); void SetText(const OUString& rLabel) { dynamic_cast<weld::Label&>(*m_xText).set_label(rLabel); } - void set_width_request(int nTextWidth) { m_xText->set_size_request(nTextWidth, -1); } int get_height_request() const { return std::max(m_xText->get_preferred_size().Height(), m_xColorList->get_widget().get_preferred_size().Height()); } - void Hide (); - public: + void Hide(); + void SetLinks(Link<weld::Toggleable&,void> const&, Link<ColorListBox&,void> const&, Link<weld::Widget&,void> const&); - void Update (ColorConfigValue const&); - void Update (ExtendedColorConfigValue const&); + void Update (ColorConfigValue const&, const std::u16string_view&, + css::uno::Reference<css::configuration::XReadWriteAccess> const&); + void Update (ExtendedColorConfigValue const&, const std::u16string_view&, + css::uno::Reference<css::configuration::XReadWriteAccess> const&); void ColorChanged (ColorConfigValue&); void ColorChanged (ExtendedColorConfigValue&); - public: + bool Is(const weld::Toggleable* pBox) const { return m_xText.get() == pBox; } bool Is(const ColorListBox* pBox) const { return m_xColorList.get() == pBox; } - private: + // checkbox (CheckBox) or simple text (FixedText) std::unique_ptr<weld::Widget> m_xText; // color list box @@ -237,8 +283,11 @@ private: Color m_aDefaultColor; }; + css::uno::Reference<css::configuration::XReadWriteAccess> m_xReadWriteAccess; + private: weld::Window* m_pTopLevel; + int m_nCheckBoxLabelOffset; std::unique_ptr<weld::Builder> m_xBuilder; std::unique_ptr<weld::Box> m_xBox; std::unique_ptr<weld::Widget> m_xWidget1; @@ -269,7 +318,7 @@ private: // ctor for default groups // rParent: parent window (ColorConfigWindow_Impl) // eGroup: which group is this? -ColorConfigWindow_Impl::Chapter::Chapter(weld::Builder& rBuilder, const char* pLabelWidget, bool bShow) +ColorConfigWindow_Impl::Chapter::Chapter(weld::Builder& rBuilder, const OUString& pLabelWidget, bool bShow) : m_xText(rBuilder.weld_label(pLabelWidget)) { if (!bShow) @@ -278,10 +327,11 @@ ColorConfigWindow_Impl::Chapter::Chapter(weld::Builder& rBuilder, const char* pL // ColorConfigWindow_Impl::Entry ColorConfigWindow_Impl::Entry::Entry(weld::Window* pTopLevel, weld::Builder& rBuilder, - const char* pTextWidget, const char* pColorWidget, - const Color& rColor, - tools::Long nCheckBoxLabelOffset, bool bCheckBox, bool bShow) - : m_xColorList(new ColorListBox(rBuilder.weld_menu_button(pColorWidget), [pTopLevel]{ return pTopLevel; })) + const OUString& pTextWidget, const OUString& pColorWidget, + const Color& rColor, int nCheckBoxLabelOffset, + const ColorListBox* pCache, bool bCheckBox, bool bShow) + : m_xColorList(new ColorListBox(rBuilder.weld_menu_button(pColorWidget), + [pTopLevel]{ return pTopLevel; }, pCache)) , m_aDefaultColor(rColor) { if (bCheckBox) @@ -324,22 +374,54 @@ void ColorConfigWindow_Impl::Entry::SetLinks(Link<weld::Toggleable&,void> const& } // updates a default color config entry -void ColorConfigWindow_Impl::Entry::Update(ColorConfigValue const& rValue) +void ColorConfigWindow_Impl::Entry::Update(ColorConfigValue const& rValue, const std::u16string_view& rConfigPath, + css::uno::Reference<css::configuration::XReadWriteAccess> const& xReadWriteAccess) { Color aColor(rValue.nColor); m_xColorList->SelectEntry(aColor); + + bool bReadOnly = false; + OUString aConfigPath = OUString::Concat(rConfigPath) + "/Color"; + if (xReadWriteAccess->hasPropertyByHierarchicalName(aConfigPath)) + { + css::beans::Property aProperty = xReadWriteAccess->getPropertyByHierarchicalName(aConfigPath); + bReadOnly = (aProperty.Attributes & css::beans::PropertyAttribute::READONLY) != 0; + } + m_xColorList->set_sensitive(!bReadOnly); + if (weld::Toggleable* pCheckBox = dynamic_cast<weld::Toggleable*>(m_xText.get())) + { + bReadOnly = false; pCheckBox->set_active(rValue.bIsVisible); + + aConfigPath = OUString::Concat(rConfigPath) + "/IsVisible"; + if (xReadWriteAccess->hasPropertyByHierarchicalName(aConfigPath)) + { + css::beans::Property aProperty = xReadWriteAccess->getPropertyByHierarchicalName(aConfigPath); + bReadOnly = (aProperty.Attributes & css::beans::PropertyAttribute::READONLY) != 0; + } + pCheckBox->set_sensitive(!bReadOnly); + } } // updates an extended color config entry -void ColorConfigWindow_Impl::Entry::Update(ExtendedColorConfigValue const& rValue) +void ColorConfigWindow_Impl::Entry::Update(ExtendedColorConfigValue const& rValue, const std::u16string_view& rConfigPath, + css::uno::Reference<css::configuration::XReadWriteAccess> const& xReadWriteAccess) { Color aColor(rValue.getColor()); if (rValue.getColor() == rValue.getDefaultColor()) m_xColorList->SelectEntry(COL_AUTO); else m_xColorList->SelectEntry(aColor); + + bool bReadOnly = false; + OUString aConfigPath = OUString::Concat(rConfigPath) + rValue.getName() + "/Color"; + if (xReadWriteAccess->hasPropertyByHierarchicalName(aConfigPath)) + { + css::beans::Property aProperty = xReadWriteAccess->getPropertyByHierarchicalName(aConfigPath); + bReadOnly = (aProperty.Attributes & css::beans::PropertyAttribute::READONLY) != 0; + } + m_xColorList->set_sensitive(!bReadOnly); } // color of a default entry has changed @@ -365,9 +447,12 @@ ColorConfigWindow_Impl::ColorConfigWindow_Impl(weld::Window* pTopLevel, weld::Co : m_pTopLevel(pTopLevel) , m_xBuilder(Application::CreateBuilder(pParent, "cui/ui/colorconfigwin.ui")) , m_xBox(m_xBuilder->weld_box("ColorConfigWindow")) - , m_xWidget1(m_xBuilder->weld_widget("doccolor")) - , m_xWidget2(m_xBuilder->weld_widget("doccolor_lb")) + , m_xWidget1(m_xBuilder->weld_widget("docboundaries")) + , m_xWidget2(m_xBuilder->weld_widget("docboundaries_lb")) { + css::uno::Reference < css::uno::XComponentContext > xContext(::comphelper::getProcessComponentContext()); + m_xReadWriteAccess = css::configuration::ReadWriteAccess::create(xContext, "*"); + CreateEntries(); } @@ -384,9 +469,8 @@ void ColorConfigWindow_Impl::CreateEntries() // Here we want to get the amount to add to the position of a FixedText to // get it to align its contents with that of a CheckBox - tools::Long nCheckBoxLabelOffset = 0; { - OUString sSampleText("X"); + OUString sSampleText("XXXXXX"); std::unique_ptr<weld::CheckButton> xCheckBox(m_xBuilder->weld_check_button("docboundaries")); std::unique_ptr<weld::Label> xFixedText(m_xBuilder->weld_label("doccolor")); OUString sOrigCheck(xCheckBox->get_label()); @@ -397,19 +481,23 @@ void ColorConfigWindow_Impl::CreateEntries() Size aFixedSize(xFixedText->get_preferred_size()); xCheckBox->set_label(sOrigCheck); xFixedText->set_label(sOrigFixed); - nCheckBoxLabelOffset = aCheckSize.Width() - aFixedSize.Width(); + m_nCheckBoxLabelOffset = aCheckSize.Width() - aFixedSize.Width(); } + const ColorListBox* pCache = nullptr; + // creating entries vEntries.reserve(ColorConfigEntryCount); - for (size_t i = 0; i < SAL_N_ELEMENTS(vEntryInfo); ++i) + for (size_t i = 0; i < std::size(vEntryInfo); ++i) { vEntries.push_back(std::make_shared<Entry>(m_pTopLevel, *m_xBuilder, vEntryInfo[i].pText, vEntryInfo[i].pColor, ColorConfig::GetDefaultColor(static_cast<ColorConfigEntry>(i)), - nCheckBoxLabelOffset, + m_nCheckBoxLabelOffset, pCache, vEntryInfo[i].bCheckBox, aModulesInstalled[vEntryInfo[i].eGroup])); + if (!pCache) + pCache = vEntries.back()->m_xColorList.get(); } // extended entries @@ -441,18 +529,12 @@ void ColorConfigWindow_Impl::CreateEntries() aExtConfig.GetComponentColorConfigValue(sComponentName, i); vEntries.push_back(std::make_shared<Entry>(m_pTopLevel, *vExtBuilders.back(), "label", "button", aColorEntry.getDefaultColor(), - nCheckBoxLabelOffset, false, true)); + m_nCheckBoxLabelOffset, pCache, false, true)); vEntries.back()->SetText(aColorEntry.getDisplayName()); } } } -void ColorConfigWindow_Impl::AdjustExtraWidths(int nTextWidth) -{ - for (size_t i = SAL_N_ELEMENTS(vEntryInfo); i < vEntries.size(); ++i) - vEntries[i]->set_width_request(nTextWidth); -} - // SetLinks() void ColorConfigWindow_Impl::SetLinks(Link<weld::Toggleable&,void> const& aCheckLink, Link<ColorListBox&,void> const& aColorLink, @@ -473,11 +555,17 @@ void ColorConfigWindow_Impl::Update ( EditableExtendedColorConfig const* pExtConfig) { // updating default entries + std::optional<OUString> aUIColorSchemeName = officecfg::Office::UI::ColorScheme::CurrentColorScheme::get(); + OUString aUIColorSchemePath = officecfg::Office::UI::ColorScheme::ColorSchemes::path() + u"/" + aUIColorSchemeName.value(); + for (unsigned i = 0; i != ColorConfigEntryCount; ++i) { + OUString sPath = aUIColorSchemePath + vEntryInfo[i].sPropName; ColorConfigEntry const aColorEntry = static_cast<ColorConfigEntry>(i); vEntries[i]->Update( - pConfig->GetColorValue(aColorEntry) + pConfig->GetColorValue(aColorEntry), + sPath, + m_xReadWriteAccess ); } @@ -487,14 +575,28 @@ void ColorConfigWindow_Impl::Update ( for (unsigned j = 0; j != nExtCount; ++j) { OUString sComponentName = pExtConfig->GetComponentName(j); + aUIColorSchemePath = officecfg::Office::ExtendedColorScheme::ExtendedColorScheme::ColorSchemes::path() + u"/" + + aUIColorSchemeName.value() + u"/" + sComponentName + u"/Entries/"; unsigned const nColorCount = pExtConfig->GetComponentColorCount(sComponentName); for (unsigned k = 0; i != vEntries.size() && k != nColorCount; ++i, ++k) vEntries[i]->Update( - pExtConfig->GetComponentColorConfigValue(sComponentName, k) + pExtConfig->GetComponentColorConfigValue(sComponentName, k), + aUIColorSchemePath, + m_xReadWriteAccess ); } } +void ColorConfigWindow_Impl::UpdateEntries() +{ + for (unsigned i = 0; i != ColorConfigEntryCount; ++i) + { + ColorConfigEntry const aEntry = static_cast<ColorConfigEntry>(i); + Color aColor = ColorConfig::GetDefaultColor(aEntry); + vEntries[i]->m_xColorList->SetAutoDisplayColor(aColor); + } +} + // ClickHdl() void ColorConfigWindow_Impl::ClickHdl(EditableColorConfig* pConfig, const weld::Toggleable& rBox) { @@ -591,10 +693,10 @@ class ColorConfigCtrl_Impl public: explicit ColorConfigCtrl_Impl(weld::Window* pTopLevel, weld::Builder& rbuilder); - void AdjustExtraWidths(int nTextWidth) { m_xScrollWindow->AdjustExtraWidths(nTextWidth); } void SetConfig (EditableColorConfig& rConfig) { pColorConfig = &rConfig; } void SetExtendedConfig (EditableExtendedColorConfig& rConfig) { pExtColorConfig = &rConfig; } void Update(); + void UpdateEntries(); tools::Long GetScrollPosition() const { return m_xVScroll->vadjustment_get_value(); @@ -611,6 +713,10 @@ public: { return m_xScrollWindow->GetWidget2(); } + int GetLabelIndent() const + { + return m_xScrollWindow->GetLabelIndent(); + } }; ColorConfigCtrl_Impl::ColorConfigCtrl_Impl(weld::Window* pTopLevel, weld::Builder& rBuilder) @@ -634,6 +740,11 @@ void ColorConfigCtrl_Impl::Update () m_xScrollWindow->Update(pColorConfig, pExtColorConfig); } +void ColorConfigCtrl_Impl::UpdateEntries() +{ + m_xScrollWindow->UpdateEntries(); +} + IMPL_LINK(ColorConfigCtrl_Impl, ClickHdl, weld::Toggleable&, rBox, void) { DBG_ASSERT(pColorConfig, "Configuration not set"); @@ -689,19 +800,23 @@ IMPL_LINK(ColorConfigCtrl_Impl, ControlFocusHdl, weld::Widget&, rCtrl, void) SvxColorOptionsTabPage::SvxColorOptionsTabPage(weld::Container* pPage, weld::DialogController* pController, const SfxItemSet& rCoreSet) : SfxTabPage(pPage, pController, "cui/ui/optappearancepage.ui", "OptAppearancePage", &rCoreSet) , bFillItemSetCalled(false) + , m_nSizeAllocEventId(nullptr) + , m_xAutoColorLB(m_xBuilder->weld_combo_box("autocolorlb")) + , m_xAutoColorImg(m_xBuilder->weld_widget("lockautocolorlb")) , m_xColorSchemeLB(m_xBuilder->weld_combo_box("colorschemelb")) + , m_xColorSchemeImg(m_xBuilder->weld_widget("lockcolorschemelb")) , m_xSaveSchemePB(m_xBuilder->weld_button("save")) , m_xDeleteSchemePB(m_xBuilder->weld_button("delete")) , m_xColorConfigCT(new ColorConfigCtrl_Impl(pController->getDialog(), *m_xBuilder)) , m_xTable(m_xBuilder->weld_widget("table")) , m_xOnFT(m_xBuilder->weld_label("on")) - , m_xElementFT(m_xBuilder->weld_label("uielements")) , m_xColorFT(m_xBuilder->weld_label("colorsetting")) , m_rWidget1(m_xColorConfigCT->GetWidget1()) , m_rWidget2(m_xColorConfigCT->GetWidget2()) { m_xColorSchemeLB->make_sorted(); m_xColorSchemeLB->connect_changed(LINK(this, SvxColorOptionsTabPage, SchemeChangedHdl_Impl)); + m_xAutoColorLB->connect_changed(LINK(this, SvxColorOptionsTabPage, onAutoColorChanged)); Link<weld::Button&,void> aLk = LINK(this, SvxColorOptionsTabPage, SaveDeleteHdl_Impl ); m_xSaveSchemePB->connect_clicked(aLk); m_xDeleteSchemePB->connect_clicked(aLk); @@ -734,6 +849,8 @@ SvxColorOptionsTabPage::~SvxColorOptionsTabPage() pExtColorConfig.reset(); } m_xColorConfigCT.reset(); + if (m_nSizeAllocEventId) + Application::RemoveUserEvent(m_nSizeAllocEventId); } std::unique_ptr<SfxTabPage> SvxColorOptionsTabPage::Create(weld::Container* pPage, weld::DialogController* pController, const SfxItemSet* rAttrSet) @@ -741,6 +858,21 @@ std::unique_ptr<SfxTabPage> SvxColorOptionsTabPage::Create(weld::Container* pPag return std::make_unique<SvxColorOptionsTabPage>(pPage, pController, *rAttrSet); } +OUString SvxColorOptionsTabPage::GetAllStrings() +{ + // buttons are excluded + OUString sAllStrings; + OUString labels[] = { "label2", "label3", "autocolor", "uielements", "colorsetting" }; + + for (const auto& label : labels) + { + if (const auto& pString = m_xBuilder->weld_label(label)) + sAllStrings += pString->get_label() + " "; + } + + return sAllStrings.replaceAll("_", ""); +} + bool SvxColorOptionsTabPage::FillItemSet( SfxItemSet* ) { bFillItemSetCalled = true; @@ -774,16 +906,30 @@ void SvxColorOptionsTabPage::Reset( const SfxItemSet* ) pExtColorConfig.reset(new EditableExtendedColorConfig); m_xColorConfigCT->SetExtendedConfig(*pExtColorConfig); + m_xAutoColorLB->set_active( MiscSettings::GetAppColorMode() ); + + bool bReadOnly = officecfg::Office::ExtendedColorScheme::ExtendedColorScheme::CurrentColorScheme::isReadOnly() || + officecfg::Office::UI::ColorScheme::CurrentColorScheme::isReadOnly(); + m_xAutoColorLB->set_sensitive(!bReadOnly); + m_xSaveSchemePB->set_sensitive(!bReadOnly); + m_xDeleteSchemePB->set_sensitive(!bReadOnly); + m_xAutoColorImg->set_visible(bReadOnly); + OUString sUser = GetUserData(); //has to be called always to speed up accessibility tools m_xColorConfigCT->SetScrollPosition(sUser.toInt32()); m_xColorSchemeLB->clear(); const uno::Sequence< OUString > aSchemes = pColorConfig->GetSchemeNames(); for(const OUString& s : aSchemes) - m_xColorSchemeLB->append_text(s); - m_xColorSchemeLB->set_active_text(pColorConfig->GetCurrentSchemeName()); + m_xColorSchemeLB->append_text(lcl_SchemeIdToTranslatedName(s)); + + m_xColorSchemeLB->set_active_text(lcl_SchemeIdToTranslatedName(pColorConfig->GetCurrentSchemeName())); + m_xColorSchemeLB->set_sensitive(!officecfg::Office::Common::Misc::ApplicationAppearance::isReadOnly()); + m_xColorSchemeImg->set_visible(officecfg::Office::Common::Misc::ApplicationAppearance::isReadOnly()); m_xColorSchemeLB->save_value(); - m_xDeleteSchemePB->set_sensitive( aSchemes.getLength() > 1 ); + + m_xDeleteSchemePB->set_sensitive( aSchemes.getLength() > 1 && + !officecfg::Office::ExtendedColorScheme::ExtendedColorScheme::CurrentColorScheme::isReadOnly() ); UpdateColorConfig(); } @@ -800,10 +946,21 @@ void SvxColorOptionsTabPage::UpdateColorConfig() m_xColorConfigCT->Update(); } +IMPL_LINK_NOARG(SvxColorOptionsTabPage, onAutoColorChanged, weld::ComboBox&, void) +{ + MiscSettings::SetAppColorMode( m_xAutoColorLB->get_active() ); + + m_xColorConfigCT->UpdateEntries(); + + pColorConfig->LoadScheme(lcl_TranslatedNameToSchemeId(m_xColorSchemeLB->get_active_text())); + pExtColorConfig->LoadScheme(lcl_TranslatedNameToSchemeId(m_xColorSchemeLB->get_active_text())); + UpdateColorConfig(); +} + IMPL_LINK(SvxColorOptionsTabPage, SchemeChangedHdl_Impl, weld::ComboBox&, rBox, void) { - pColorConfig->LoadScheme(rBox.get_active_text()); - pExtColorConfig->LoadScheme(rBox.get_active_text()); + pColorConfig->LoadScheme(lcl_TranslatedNameToSchemeId(rBox.get_active_text())); + pExtColorConfig->LoadScheme(lcl_TranslatedNameToSchemeId(rBox.get_active_text())); UpdateColorConfig(); } @@ -815,14 +972,14 @@ IMPL_LINK(SvxColorOptionsTabPage, SaveDeleteHdl_Impl, weld::Button&, rButton, vo SvxAbstractDialogFactory* pFact = SvxAbstractDialogFactory::Create(); ScopedVclPtr<AbstractSvxNameDialog> aNameDlg(pFact->CreateSvxNameDialog(GetFrameWeld(), - sName, CuiResId(RID_SVXSTR_COLOR_CONFIG_SAVE2) )); + sName, CuiResId(RID_CUISTR_COLOR_CONFIG_SAVE2) )); aNameDlg->SetCheckNameHdl( LINK(this, SvxColorOptionsTabPage, CheckNameHdl_Impl)); - aNameDlg->SetText(CuiResId(RID_SVXSTR_COLOR_CONFIG_SAVE1)); + aNameDlg->SetText(CuiResId(RID_CUISTR_COLOR_CONFIG_SAVE1)); aNameDlg->SetHelpId(HID_OPTIONS_COLORCONFIG_SAVE_SCHEME); aNameDlg->SetCheckNameHdl( LINK(this, SvxColorOptionsTabPage, CheckNameHdl_Impl)); if(RET_OK == aNameDlg->Execute()) { - aNameDlg->GetName(sName); + sName = aNameDlg->GetName(); pColorConfig->AddScheme(sName); pExtColorConfig->AddScheme(sName); m_xColorSchemeLB->append_text(sName); @@ -835,8 +992,8 @@ IMPL_LINK(SvxColorOptionsTabPage, SaveDeleteHdl_Impl, weld::Button&, rButton, vo DBG_ASSERT(m_xColorSchemeLB->get_count() > 1, "don't delete the last scheme"); std::unique_ptr<weld::MessageDialog> xQuery(Application::CreateMessageDialog(GetFrameWeld(), VclMessageType::Question, VclButtonsType::YesNo, - CuiResId(RID_SVXSTR_COLOR_CONFIG_DELETE))); - xQuery->set_title(CuiResId(RID_SVXSTR_COLOR_CONFIG_DELETE_TITLE)); + CuiResId(RID_CUISTR_COLOR_CONFIG_DELETE))); + xQuery->set_title(CuiResId(RID_CUISTR_COLOR_CONFIG_DELETE_TITLE)); if (RET_YES == xQuery->run()) { OUString sDeleteScheme(m_xColorSchemeLB->get_active_text()); @@ -853,8 +1010,7 @@ IMPL_LINK(SvxColorOptionsTabPage, SaveDeleteHdl_Impl, weld::Button&, rButton, vo IMPL_LINK(SvxColorOptionsTabPage, CheckNameHdl_Impl, AbstractSvxNameDialog&, rDialog, bool ) { - OUString sName; - rDialog.GetName(sName); + OUString sName = rDialog.GetName(); return !sName.isEmpty() && m_xColorSchemeLB->find_text(sName) == -1; } @@ -865,17 +1021,29 @@ void SvxColorOptionsTabPage::FillUserData() IMPL_LINK_NOARG(SvxColorOptionsTabPage, AdjustHeaderBar, const Size&, void) { + if (m_nSizeAllocEventId) + return; + m_nSizeAllocEventId = Application::PostUserEvent(LINK(this, SvxColorOptionsTabPage, PostAdjustHeaderBar)); +} + +IMPL_LINK_NOARG(SvxColorOptionsTabPage, PostAdjustHeaderBar, void*, void) +{ + m_nSizeAllocEventId = nullptr; + // horizontal positions - int nX0 = 0, nX1, nX2, y, width, height; + int nX1, nX2, nX3, y, width, height; if (!m_rWidget1.get_extents_relative_to(*m_xTable, nX1, y, width, height)) return; if (!m_rWidget2.get_extents_relative_to(*m_xTable, nX2, y, width, height)) return; - auto nTextWidth1 = nX1 - nX0; - auto nTextWidth2 = nX2 - nX1; + if (!m_xTable->get_extents_relative_to(*m_xTable, nX3, y, width, height)) + return; + + // 6 is the column-spacing of the parent grid of these labels + auto nTextWidth1 = nX1 + m_xColorConfigCT->GetLabelIndent() - 6; m_xOnFT->set_size_request(nTextWidth1, -1); - m_xElementFT->set_size_request(nTextWidth2, -1); - m_xColorConfigCT->AdjustExtraWidths(nTextWidth2 - 12); + auto nTextWidth3 = width - nX2; + m_xColorFT->set_size_request(nTextWidth3, -1); } /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/cui/source/options/optcolor.hxx b/cui/source/options/optcolor.hxx index de84e06b1405..7b5cdbca7451 100644 --- a/cui/source/options/optcolor.hxx +++ b/cui/source/options/optcolor.hxx @@ -23,18 +23,25 @@ namespace svtools {class EditableColorConfig;class EditableExtendedColorConfig;} class ColorConfigCtrl_Impl; class AbstractSvxNameDialog; +struct ImplSVEvent; + class SvxColorOptionsTabPage : public SfxTabPage { bool bFillItemSetCalled; + ImplSVEvent* m_nSizeAllocEventId; + + std::unique_ptr<weld::ComboBox> m_xAutoColorLB; + std::unique_ptr<weld::Widget> m_xAutoColorImg; std::unique_ptr<weld::ComboBox> m_xColorSchemeLB; + std::unique_ptr<weld::Widget> m_xColorSchemeImg; std::unique_ptr<weld::Button> m_xSaveSchemePB; std::unique_ptr<weld::Button> m_xDeleteSchemePB; std::unique_ptr<ColorConfigCtrl_Impl> m_xColorConfigCT; std::unique_ptr<weld::Widget> m_xTable; std::unique_ptr<weld::Label> m_xOnFT; - std::unique_ptr<weld::Label> m_xElementFT; std::unique_ptr<weld::Label> m_xColorFT; + weld::Widget& m_rWidget1; weld::Widget& m_rWidget2; @@ -42,9 +49,11 @@ class SvxColorOptionsTabPage : public SfxTabPage std::unique_ptr<svtools::EditableExtendedColorConfig> pExtColorConfig; DECL_LINK(SchemeChangedHdl_Impl, weld::ComboBox&, void); + DECL_LINK(onAutoColorChanged, weld::ComboBox&, void); DECL_LINK(SaveDeleteHdl_Impl, weld::Button&, void); DECL_LINK(CheckNameHdl_Impl, AbstractSvxNameDialog&, bool); DECL_LINK(AdjustHeaderBar, const Size&, void); + DECL_LINK(PostAdjustHeaderBar, void *, void); void UpdateColorConfig(); public: @@ -53,6 +62,8 @@ public: static std::unique_ptr<SfxTabPage> Create( weld::Container* pPage, weld::DialogController* pController, const SfxItemSet* rAttrSet ); + virtual OUString GetAllStrings() override; + virtual bool FillItemSet( SfxItemSet* rSet ) override; virtual void Reset( const SfxItemSet* rSet ) override; diff --git a/cui/source/options/optctl.cxx b/cui/source/options/optctl.cxx index 52bd18fc8788..10140c2eab50 100644 --- a/cui/source/options/optctl.cxx +++ b/cui/source/options/optctl.cxx @@ -58,6 +58,36 @@ std::unique_ptr<SfxTabPage> SvxCTLOptionsPage::Create( weld::Container* pPage, w return std::make_unique<SvxCTLOptionsPage>( pPage, pController, *rAttrSet ); } +OUString SvxCTLOptionsPage::GetAllStrings() +{ + OUString sAllStrings; + OUString labels[] = { "label1", "label2", "label3", "label4", "label5" }; + + for (const auto& label : labels) + { + if (const auto& pString = m_xBuilder->weld_label(label)) + sAllStrings += pString->get_label() + " "; + } + + OUString checkButton[] = { "sequencechecking", "restricted", "typeandreplace" }; + + for (const auto& check : checkButton) + { + if (const auto& pString = m_xBuilder->weld_check_button(check)) + sAllStrings += pString->get_label() + " "; + } + + OUString radioButton[] = { "movementlogical", "movementvisual" }; + + for (const auto& radio : radioButton) + { + if (const auto& pString = m_xBuilder->weld_radio_button(radio)) + sAllStrings += pString->get_label() + " "; + } + + return sAllStrings.replaceAll("_", ""); +} + bool SvxCTLOptionsPage::FillItemSet( SfxItemSet* ) { bool bModified = false; @@ -106,13 +136,11 @@ bool SvxCTLOptionsPage::FillItemSet( SfxItemSet* ) void SvxCTLOptionsPage::Reset( const SfxItemSet* ) { - SvtCTLOptions aCTLOptions; - - m_xSequenceCheckingCB->set_active( aCTLOptions.IsCTLSequenceChecking() ); - m_xRestrictedCB->set_active( aCTLOptions.IsCTLSequenceCheckingRestricted() ); - m_xTypeReplaceCB->set_active( aCTLOptions.IsCTLSequenceCheckingTypeAndReplace() ); + m_xSequenceCheckingCB->set_active( SvtCTLOptions::IsCTLSequenceChecking() ); + m_xRestrictedCB->set_active( SvtCTLOptions::IsCTLSequenceCheckingRestricted() ); + m_xTypeReplaceCB->set_active( SvtCTLOptions::IsCTLSequenceCheckingTypeAndReplace() ); - SvtCTLOptions::CursorMovement eMovement = aCTLOptions.GetCTLCursorMovement(); + SvtCTLOptions::CursorMovement eMovement = SvtCTLOptions::GetCTLCursorMovement(); switch ( eMovement ) { case SvtCTLOptions::MOVEMENT_LOGICAL : @@ -127,7 +155,7 @@ void SvxCTLOptionsPage::Reset( const SfxItemSet* ) SAL_WARN( "cui.options", "SvxCTLOptionsPage::Reset(): invalid movement enum" ); } - sal_uInt16 nPos = static_cast<sal_uInt16>(aCTLOptions.GetCTLTextNumerals()); + sal_uInt16 nPos = static_cast<sal_uInt16>(SvtCTLOptions::GetCTLTextNumerals()); DBG_ASSERT( nPos < m_xNumeralsLB->get_count(), "SvxCTLOptionsPage::Reset(): invalid numerals enum" ); m_xNumeralsLB->set_active(nPos); diff --git a/cui/source/options/optctl.hxx b/cui/source/options/optctl.hxx index 0cc24951b54b..35c07d3a81df 100644 --- a/cui/source/options/optctl.hxx +++ b/cui/source/options/optctl.hxx @@ -38,6 +38,9 @@ public: SvxCTLOptionsPage(weld::Container* pPage, weld::DialogController* pController, const SfxItemSet& rSet); virtual ~SvxCTLOptionsPage() override; static std::unique_ptr<SfxTabPage> Create( weld::Container* pPage, weld::DialogController* pController, const SfxItemSet* rAttrSet ); + + virtual OUString GetAllStrings() override; + virtual bool FillItemSet( SfxItemSet* rSet ) override; virtual void Reset( const SfxItemSet* rSet ) override; }; diff --git a/cui/source/options/optdeepl.cxx b/cui/source/options/optdeepl.cxx new file mode 100644 index 000000000000..ba068fe28af7 --- /dev/null +++ b/cui/source/options/optdeepl.cxx @@ -0,0 +1,78 @@ +/* -*- 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 "optdeepl.hxx" +#include <officecfg/Office/Linguistic.hxx> + +OptDeeplTabPage::OptDeeplTabPage(weld::Container* pPage, weld::DialogController* pController, + const SfxItemSet& rSet) + : SfxTabPage(pPage, pController, "cui/ui/optdeeplpage.ui", "OptDeeplPage", &rSet) + , m_xAPIUrl(m_xBuilder->weld_entry("apiurl")) + , m_xAuthKey(m_xBuilder->weld_entry("authkey")) +{ +} + +OptDeeplTabPage::~OptDeeplTabPage() {} + +void OptDeeplTabPage::Reset(const SfxItemSet*) +{ + std::optional<OUString> oDeeplAPIUrl + = officecfg::Office::Linguistic::Translation::Deepl::ApiURL::get(); + if (oDeeplAPIUrl && !oDeeplAPIUrl->isEmpty()) + m_xAPIUrl->set_text(*officecfg::Office::Linguistic::Translation::Deepl::ApiURL::get()); + + std::optional<OUString> oDeeplAuthKey + = officecfg::Office::Linguistic::Translation::Deepl::AuthKey::get(); + if (oDeeplAuthKey && !oDeeplAuthKey->isEmpty()) + m_xAuthKey->set_text(*officecfg::Office::Linguistic::Translation::Deepl::AuthKey::get()); +} + +OUString OptDeeplTabPage::GetAllStrings() +{ + OUString sAllStrings; + OUString labels[] = { "label1", "label2", "label3" }; + + for (const auto& label : labels) + { + if (const auto& pString = m_xBuilder->weld_label(label)) + sAllStrings += pString->get_label() + " "; + } + + if (const auto& pString = m_xBuilder->weld_link_button("privacy")) + sAllStrings += pString->get_label() + " "; + + return sAllStrings.replaceAll("_", ""); +} + +bool OptDeeplTabPage::FillItemSet(SfxItemSet*) +{ + std::shared_ptr<comphelper::ConfigurationChanges> batch( + comphelper::ConfigurationChanges::create()); + officecfg::Office::Linguistic::Translation::Deepl::ApiURL::set(m_xAPIUrl->get_text(), batch); + officecfg::Office::Linguistic::Translation::Deepl::AuthKey::set(m_xAuthKey->get_text(), batch); + batch->commit(); + return false; +} + +std::unique_ptr<SfxTabPage> OptDeeplTabPage::Create(weld::Container* pPage, + weld::DialogController* pController, + const SfxItemSet* rAttrSet) +{ + return std::make_unique<OptDeeplTabPage>(pPage, pController, *rAttrSet); +} diff --git a/cui/source/options/optdeepl.hxx b/cui/source/options/optdeepl.hxx new file mode 100644 index 000000000000..51714c685084 --- /dev/null +++ b/cui/source/options/optdeepl.hxx @@ -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 . + */ +#pragma once +#include <sfx2/tabdlg.hxx> + +class OptDeeplTabPage : public SfxTabPage +{ +public: + OptDeeplTabPage(weld::Container* pPage, weld::DialogController* pController, + const SfxItemSet& rSet); + virtual ~OptDeeplTabPage() override; + static std::unique_ptr<SfxTabPage> + Create(weld::Container* pPage, weld::DialogController* pController, const SfxItemSet* rAttrSet); + + virtual OUString GetAllStrings() override; + + virtual bool FillItemSet(SfxItemSet* rSet) override; + virtual void Reset(const SfxItemSet* rSet) override; + +private: + std::unique_ptr<weld::Entry> m_xAPIUrl; + std::unique_ptr<weld::Entry> m_xAuthKey; +}; diff --git a/cui/source/options/optdict.cxx b/cui/source/options/optdict.cxx index 7e3ebc7a9ced..dbe7f80e3d6b 100644 --- a/cui/source/options/optdict.cxx +++ b/cui/source/options/optdict.cxx @@ -67,6 +67,23 @@ static OUString getNormDicEntry_Impl(std::u16string_view rText) return aTmp.replaceAll("=", ""); } +// tdf#154499 separate words of a phrase only by a single space, +// i.e. trim terminating spaces and replace space sequences with single spaces +static OUString fixSpace(OUString sText) +{ + sText = sText.trim(); + + sal_Int32 nLen; + do + { + nLen = sText.getLength(); + sText = sText.replaceAll(" ", " "); + } + while ( sText.getLength() < nLen ); + + return sText; +} + namespace { // Compare Dictionary Entry result @@ -136,7 +153,7 @@ IMPL_LINK_NOARG(SvxNewDictionaryDialog, OKHdl_Impl, weld::Button&, void) // Detected an invalid character. std::unique_ptr<weld::MessageDialog> xInfoBox(Application::CreateMessageDialog(m_xDialog.get(), VclMessageType::Info, VclButtonsType::Ok, - CuiResId(RID_SVXSTR_OPT_INVALID_DICT_NAME))); + CuiResId(RID_CUISTR_OPT_INVALID_DICT_NAME))); xInfoBox->run(); m_xNameEdit->grab_focus(); return; @@ -147,7 +164,7 @@ IMPL_LINK_NOARG(SvxNewDictionaryDialog, OKHdl_Impl, weld::Button&, void) // duplicate names? std::unique_ptr<weld::MessageDialog> xInfoBox(Application::CreateMessageDialog(m_xDialog.get(), VclMessageType::Info, VclButtonsType::Ok, - CuiResId(RID_SVXSTR_OPT_DOUBLE_DICTS))); + CuiResId(RID_CUISTR_OPT_DOUBLE_DICTS))); xInfoBox->run(); m_xNameEdit->grab_focus(); return; @@ -175,7 +192,7 @@ IMPL_LINK_NOARG(SvxNewDictionaryDialog, OKHdl_Impl, weld::Button&, void) // error: couldn't create new dictionary SfxErrorContext aContext( ERRCTX_SVX_LINGU_DICTIONARY, OUString(), m_xDialog.get(), RID_SVXERRCTX, SvxResLocale() ); - ErrorHandler::HandleError( *new StringErrorInfo( + ErrorHandler::HandleError( ErrCodeMsg( ERRCODE_SVX_LINGU_DICT_NOTWRITEABLE, sDict ) ); m_xDialog->response(RET_CANCEL); } @@ -281,10 +298,6 @@ SvxEditDictionaryDialog::SvxEditDictionaryDialog(weld::Window* pParent, std::u16 m_xLangLB->SetLanguageList( SvxLanguageListFlags::ALL, true, true ); - Link<OUString&,bool> aLink = LINK(this, SvxEditDictionaryDialog, InsertTextHdl); - m_xReplaceED->connect_insert_text(aLink); - m_xWordED->connect_insert_text(aLink); - if ( nCount > 0 ) { m_xAllDictsLB->set_active_text(aLookUpEntry); @@ -425,7 +438,7 @@ IMPL_LINK_NOARG(SvxEditDictionaryDialog, SelectLangHdl_Impl, weld::ComboBox&, vo std::unique_ptr<weld::MessageDialog> xBox(Application::CreateMessageDialog(m_xDialog.get(), VclMessageType::Question, VclButtonsType::YesNo, - CuiResId(RID_SVXSTR_CONFIRM_SET_LANGUAGE))); + CuiResId(RID_CUISTR_CONFIRM_SET_LANGUAGE))); OUString sTxt(xBox->get_primary_text()); sTxt = sTxt.replaceFirst("%1", m_xAllDictsLB->get_active_text()); xBox->set_primary_text(sTxt); @@ -468,7 +481,7 @@ void SvxEditDictionaryDialog::ShowWords_Impl( sal_uInt16 nId ) { m_xReplaceFT->set_label(sReplaceFT_Text); } else if (!bLangNone) { - m_xReplaceFT->set_label(CuiResId(RID_SVXSTR_OPT_GRAMMAR_BY)); + m_xReplaceFT->set_label(CuiResId(RID_CUISTR_OPT_GRAMMAR_BY)); } if(bIsNegative || !bLangNone) @@ -598,9 +611,9 @@ bool SvxEditDictionaryDialog::NewDelHdl(const weld::Widget* pBtn) if (pBtn == m_xNewReplacePB.get() || m_xNewReplacePB->get_sensitive()) { int nEntry = m_pWordsLB->get_selected_index(); - OUString aNewWord(m_xWordED->get_text()); + OUString aNewWord(fixSpace(m_xWordED->get_text())); OUString sEntry(aNewWord); - OUString aReplaceStr(m_xReplaceED->get_text()); + OUString aReplaceStr(fixSpace(m_xReplaceED->get_text())); DictionaryError nAddRes = DictionaryError::UNKNOWN; int nPos = m_xAllDictsLB->get_active(); @@ -673,7 +686,7 @@ IMPL_LINK(SvxEditDictionaryDialog, ModifyHdl, weld::Entry&, rEdt, void) OUString rEntry = rEdt.get_text(); sal_Int32 nWordLen = rEntry.getLength(); - const OUString& rRepString = m_xReplaceED->get_text(); + const OUString& rRepString = fixSpace(m_xReplaceED->get_text()); bool bEnableNewReplace = false; bool bEnableDelete = false; @@ -754,9 +767,9 @@ IMPL_LINK(SvxEditDictionaryDialog, ModifyHdl, weld::Entry&, rEdt, void) bEnableDelete = true; } bool bIsChange = - CDE_EQUAL != cmpDicEntry_Impl(m_xWordED->get_text(), aWordText) - || CDE_EQUAL != cmpDicEntry_Impl(m_xReplaceED->get_text(), aReplaceText); - if (!m_xWordED->get_text().isEmpty() && bIsChange) + CDE_EQUAL != cmpDicEntry_Impl(fixSpace(m_xWordED->get_text()), aWordText) + || CDE_EQUAL != cmpDicEntry_Impl(fixSpace(m_xReplaceED->get_text()), aReplaceText); + if (!fixSpace(m_xWordED->get_text()).isEmpty() && bIsChange) bEnableNewReplace = true; } @@ -765,10 +778,4 @@ IMPL_LINK(SvxEditDictionaryDialog, ModifyHdl, weld::Entry&, rEdt, void) m_xDeletePB->set_sensitive(bEnableDelete && !IsDicReadonly_Impl()); } -IMPL_STATIC_LINK(SvxEditDictionaryDialog, InsertTextHdl, OUString&, rText, bool) -{ - rText = rText.replaceAll(" ", ""); - return true; -} - /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/cui/source/options/optfltr.cxx b/cui/source/options/optfltr.cxx index 607f7759b614..0ecd2215716d 100644 --- a/cui/source/options/optfltr.cxx +++ b/cui/source/options/optfltr.cxx @@ -18,8 +18,10 @@ */ #include <unotools/moduleoptions.hxx> -#include <unotools/fltrcfg.hxx> #include <officecfg/Office/Common.hxx> +#include <officecfg/Office/Calc.hxx> +#include <officecfg/Office/Writer.hxx> +#include <officecfg/Office/Impress.hxx> #include "optfltr.hxx" #include <strings.hrc> #include <dialmgr.hxx> @@ -39,13 +41,21 @@ enum class MSFltrPg2_CheckBoxEntries { OfaMSFilterTabPage::OfaMSFilterTabPage(weld::Container* pPage, weld::DialogController* pController, const SfxItemSet& rSet) : SfxTabPage(pPage, pController, "cui/ui/optfltrpage.ui", "OptFltrPage", &rSet) , m_xWBasicCodeCB(m_xBuilder->weld_check_button("wo_basic")) + , m_xWBasicCodeImg(m_xBuilder->weld_widget("lockwo_basic")) , m_xWBasicWbctblCB(m_xBuilder->weld_check_button("wo_exec")) + , m_xWBasicWbctblImg(m_xBuilder->weld_widget("lockwo_exec")) , m_xWBasicStgCB(m_xBuilder->weld_check_button("wo_saveorig")) + , m_xWBasicStgImg(m_xBuilder->weld_widget("lockwo_saveorig")) , m_xEBasicCodeCB(m_xBuilder->weld_check_button("ex_basic")) + , m_xEBasicCodeImg(m_xBuilder->weld_widget("lockex_basic")) , m_xEBasicExectblCB(m_xBuilder->weld_check_button("ex_exec")) + , m_xEBasicExectblImg(m_xBuilder->weld_widget("lockex_exec")) , m_xEBasicStgCB(m_xBuilder->weld_check_button("ex_saveorig")) + , m_xEBasicStgImg(m_xBuilder->weld_widget("lockex_saveorig")) , m_xPBasicCodeCB(m_xBuilder->weld_check_button("pp_basic")) + , m_xPBasicCodeImg(m_xBuilder->weld_widget("lockpp_basic")) , m_xPBasicStgCB(m_xBuilder->weld_check_button("pp_saveorig")) + , m_xPBasicStgImg(m_xBuilder->weld_widget("lockpp_saveorig")) { m_xWBasicCodeCB->connect_toggled( LINK( this, OfaMSFilterTabPage, LoadWordBasicCheckHdl_Impl ) ); m_xEBasicCodeCB->connect_toggled( LINK( this, OfaMSFilterTabPage, LoadExcelBasicCheckHdl_Impl ) ); @@ -57,12 +67,14 @@ OfaMSFilterTabPage::~OfaMSFilterTabPage() IMPL_LINK_NOARG(OfaMSFilterTabPage, LoadWordBasicCheckHdl_Impl, weld::Toggleable&, void) { - m_xWBasicWbctblCB->set_sensitive(m_xWBasicCodeCB->get_active()); + m_xWBasicWbctblCB->set_sensitive(m_xWBasicCodeCB->get_active() && !officecfg::Office::Writer::Filter::Import::VBA::Executable::isReadOnly()); + m_xWBasicWbctblImg->set_visible(officecfg::Office::Writer::Filter::Import::VBA::Executable::isReadOnly()); } IMPL_LINK_NOARG(OfaMSFilterTabPage, LoadExcelBasicCheckHdl_Impl, weld::Toggleable&, void) { - m_xEBasicExectblCB->set_sensitive(m_xEBasicCodeCB->get_active()); + m_xEBasicExectblCB->set_sensitive(m_xEBasicCodeCB->get_active() && !officecfg::Office::Calc::Filter::Import::VBA::Executable::isReadOnly()); + m_xEBasicExectblImg->set_visible(officecfg::Office::Calc::Filter::Import::VBA::Executable::isReadOnly()); } std::unique_ptr<SfxTabPage> OfaMSFilterTabPage::Create( weld::Container* pPage, weld::DialogController* pController, @@ -71,71 +83,113 @@ std::unique_ptr<SfxTabPage> OfaMSFilterTabPage::Create( weld::Container* pPage, return std::make_unique<OfaMSFilterTabPage>(pPage, pController, *rAttrSet); } +OUString OfaMSFilterTabPage::GetAllStrings() +{ + OUString sAllStrings; + OUString labels[] = { "label1", "label2", "label3" }; + + for (const auto& label : labels) + { + if (const auto& pString = m_xBuilder->weld_label(label)) + sAllStrings += pString->get_label() + " "; + } + + OUString checkButton[] = { "wo_basic", "wo_exec", "wo_saveorig", "ex_basic", + "ex_exec", "ex_saveorig", "pp_basic", "pp_saveorig" }; + + for (const auto& check : checkButton) + { + if (const auto& pString = m_xBuilder->weld_check_button(check)) + sAllStrings += pString->get_label() + " "; + } + + return sAllStrings.replaceAll("_", ""); +} + bool OfaMSFilterTabPage::FillItemSet( SfxItemSet* ) { - SvtFilterOptions& rOpt = SvtFilterOptions::Get(); + auto batch = comphelper::ConfigurationChanges::create(); if( m_xWBasicCodeCB->get_state_changed_from_saved() ) - rOpt.SetLoadWordBasicCode( m_xWBasicCodeCB->get_active() ); + officecfg::Office::Writer::Filter::Import::VBA::Load::set(m_xWBasicCodeCB->get_active(), batch); if( m_xWBasicWbctblCB->get_state_changed_from_saved() ) - rOpt.SetLoadWordBasicExecutable( m_xWBasicWbctblCB->get_active() ); + officecfg::Office::Writer::Filter::Import::VBA::Executable::set(m_xWBasicWbctblCB->get_active(), batch); if( m_xWBasicStgCB->get_state_changed_from_saved() ) - rOpt.SetLoadWordBasicStorage( m_xWBasicStgCB->get_active() ); + officecfg::Office::Writer::Filter::Import::VBA::Save::set(m_xWBasicStgCB->get_active(), batch); if( m_xEBasicCodeCB->get_state_changed_from_saved()) - rOpt.SetLoadExcelBasicCode( m_xEBasicCodeCB->get_active() ); + officecfg::Office::Calc::Filter::Import::VBA::Load::set(m_xEBasicCodeCB->get_active(), batch); if( m_xEBasicExectblCB->get_state_changed_from_saved()) - rOpt.SetLoadExcelBasicExecutable( m_xEBasicExectblCB->get_active() ); + officecfg::Office::Calc::Filter::Import::VBA::Executable::set(m_xEBasicExectblCB->get_active(), batch); if( m_xEBasicStgCB->get_state_changed_from_saved()) - rOpt.SetLoadExcelBasicStorage( m_xEBasicStgCB->get_active() ); + officecfg::Office::Calc::Filter::Import::VBA::Save::set(m_xEBasicStgCB->get_active(), batch); if( m_xPBasicCodeCB->get_state_changed_from_saved()) - rOpt.SetLoadPPointBasicCode( m_xPBasicCodeCB->get_active() ); + officecfg::Office::Impress::Filter::Import::VBA::Load::set(m_xPBasicCodeCB->get_active(), batch); if( m_xPBasicStgCB->get_state_changed_from_saved()) - rOpt.SetLoadPPointBasicStorage( m_xPBasicStgCB->get_active() ); + officecfg::Office::Impress::Filter::Import::VBA::Save::set(m_xPBasicStgCB->get_active(), batch); + + batch->commit(); return false; } void OfaMSFilterTabPage::Reset( const SfxItemSet* ) { - const SvtFilterOptions& rOpt = SvtFilterOptions::Get(); - - m_xWBasicCodeCB->set_active( rOpt.IsLoadWordBasicCode() ); + m_xWBasicCodeCB->set_active(officecfg::Office::Writer::Filter::Import::VBA::Load::get()); + m_xWBasicCodeCB->set_sensitive(!officecfg::Office::Writer::Filter::Import::VBA::Load::isReadOnly()); + m_xWBasicCodeImg->set_visible(officecfg::Office::Writer::Filter::Import::VBA::Load::isReadOnly()); m_xWBasicCodeCB->save_state(); - m_xWBasicWbctblCB->set_active( rOpt.IsLoadWordBasicExecutable() ); + m_xWBasicWbctblCB->set_active(officecfg::Office::Writer::Filter::Import::VBA::Executable::get()); + m_xWBasicWbctblCB->set_sensitive(!officecfg::Office::Writer::Filter::Import::VBA::Executable::isReadOnly()); + m_xWBasicWbctblImg->set_visible(officecfg::Office::Writer::Filter::Import::VBA::Executable::isReadOnly()); m_xWBasicWbctblCB->save_state(); - m_xWBasicStgCB->set_active( rOpt.IsLoadWordBasicStorage() ); + m_xWBasicStgCB->set_active(officecfg::Office::Writer::Filter::Import::VBA::Save::get()); + m_xWBasicStgCB->set_sensitive(!officecfg::Office::Writer::Filter::Import::VBA::Save::isReadOnly()); + m_xWBasicStgImg->set_visible(officecfg::Office::Writer::Filter::Import::VBA::Save::isReadOnly()); m_xWBasicStgCB->save_state(); LoadWordBasicCheckHdl_Impl( *m_xWBasicCodeCB ); - m_xEBasicCodeCB->set_active( rOpt.IsLoadExcelBasicCode() ); + m_xEBasicCodeCB->set_active(officecfg::Office::Calc::Filter::Import::VBA::Load::get()); + m_xEBasicCodeCB->set_sensitive(!officecfg::Office::Calc::Filter::Import::VBA::Load::isReadOnly()); + m_xEBasicCodeImg->set_visible(officecfg::Office::Calc::Filter::Import::VBA::Load::isReadOnly()); m_xEBasicCodeCB->save_state(); - m_xEBasicExectblCB->set_active( rOpt.IsLoadExcelBasicExecutable() ); + m_xEBasicExectblCB->set_active(officecfg::Office::Calc::Filter::Import::VBA::Executable::get()); + m_xEBasicExectblCB->set_sensitive(!officecfg::Office::Calc::Filter::Import::VBA::Executable::isReadOnly()); + m_xEBasicExectblImg->set_visible(officecfg::Office::Calc::Filter::Import::VBA::Executable::isReadOnly()); m_xEBasicExectblCB->save_state(); - m_xEBasicStgCB->set_active( rOpt.IsLoadExcelBasicStorage() ); + m_xEBasicStgCB->set_active(officecfg::Office::Calc::Filter::Import::VBA::Save::get()); + m_xEBasicStgCB->set_sensitive(!officecfg::Office::Calc::Filter::Import::VBA::Save::isReadOnly()); + m_xEBasicStgImg->set_visible(officecfg::Office::Calc::Filter::Import::VBA::Save::isReadOnly()); m_xEBasicStgCB->save_state(); LoadExcelBasicCheckHdl_Impl( *m_xEBasicCodeCB ); - m_xPBasicCodeCB->set_active( rOpt.IsLoadPPointBasicCode() ); + m_xPBasicCodeCB->set_active(officecfg::Office::Impress::Filter::Import::VBA::Load::get()); + m_xPBasicCodeCB->set_sensitive(!officecfg::Office::Impress::Filter::Import::VBA::Load::isReadOnly()); + m_xPBasicCodeImg->set_visible(officecfg::Office::Impress::Filter::Import::VBA::Load::isReadOnly()); m_xPBasicCodeCB->save_state(); - m_xPBasicStgCB->set_active( rOpt.IsLoadPPointBasicStorage() ); + m_xPBasicStgCB->set_active(officecfg::Office::Impress::Filter::Import::VBA::Save::get()); + m_xPBasicStgCB->set_sensitive(!officecfg::Office::Impress::Filter::Import::VBA::Save::isReadOnly()); + m_xPBasicStgImg->set_visible(officecfg::Office::Impress::Filter::Import::VBA::Save::isReadOnly()); m_xPBasicStgCB->save_state(); } OfaMSFilterTabPage2::OfaMSFilterTabPage2(weld::Container* pPage, weld::DialogController* pController, const SfxItemSet& rSet) : SfxTabPage(pPage, pController, "cui/ui/optfltrembedpage.ui", "OptFilterPage", &rSet) - , sChgToFromMath(CuiResId(RID_SVXSTR_CHG_MATH)) - , sChgToFromWriter(CuiResId(RID_SVXSTR_CHG_WRITER)) - , sChgToFromCalc(CuiResId(RID_SVXSTR_CHG_CALC)) - , sChgToFromImpress(CuiResId(RID_SVXSTR_CHG_IMPRESS)) - , sChgToFromSmartArt(CuiResId(RID_SVXSTR_CHG_SMARTART)) - , sChgToFromVisio(CuiResId(RID_SVXSTR_CHG_VISIO)) - , sChgToFromPDF(CuiResId(RID_SVXSTR_CHG_PDF)) + , sChgToFromMath(CuiResId(RID_CUISTR_CHG_MATH)) + , sChgToFromWriter(CuiResId(RID_CUISTR_CHG_WRITER)) + , sChgToFromCalc(CuiResId(RID_CUISTR_CHG_CALC)) + , sChgToFromImpress(CuiResId(RID_CUISTR_CHG_IMPRESS)) + , sChgToFromSmartArt(CuiResId(RID_CUISTR_CHG_SMARTART)) + , sChgToFromVisio(CuiResId(RID_CUISTR_CHG_VISIO)) + , sChgToFromPDF(CuiResId(RID_CUISTR_CHG_PDF)) , m_xCheckLB(m_xBuilder->weld_tree_view("checklbcontainer")) + , m_xHighlightingFT(m_xBuilder->weld_label("label5")) , m_xHighlightingRB(m_xBuilder->weld_radio_button("highlighting")) , m_xShadingRB(m_xBuilder->weld_radio_button("shading")) + , m_xShadingImg(m_xBuilder->weld_widget("lockbuttonbox1")) , m_xMSOLockFileCB(m_xBuilder->weld_check_button("mso_lockfile")) + , m_xMSOLockFileImg(m_xBuilder->weld_widget("lockmso_lockfile")) { std::vector<int> aWidths { @@ -155,87 +209,122 @@ std::unique_ptr<SfxTabPage> OfaMSFilterTabPage2::Create( weld::Container* pPage, return std::make_unique<OfaMSFilterTabPage2>( pPage, pController, *rAttrSet ); } +OUString OfaMSFilterTabPage2::GetAllStrings() +{ + OUString sAllStrings; + OUString labels[] = { "label1", "label2", "label3", "label4", "label5", "label6" }; + + for (const auto& label : labels) + { + if (const auto& pString = m_xBuilder->weld_label(label)) + sAllStrings += pString->get_label() + " "; + } + + OUString radioButton[] = { "highlighting", "shading" }; + + for (const auto& radio : radioButton) + { + if (const auto& pString = m_xBuilder->weld_radio_button(radio)) + sAllStrings += pString->get_label() + " "; + } + + sAllStrings += m_xMSOLockFileCB->get_label() + " "; + + return sAllStrings.replaceAll("_", ""); +} + +namespace +{ +struct Functions +{ + bool (*FnIs)(css::uno::Reference<css::uno::XComponentContext> const &); + bool (*FnIsReadOnly)(css::uno::Reference<css::uno::XComponentContext> const &); + void (*FnSet)(const bool& bFlag, const std::shared_ptr<comphelper::ConfigurationChanges>&); + template <class reg> static constexpr Functions fromReg() + { + return { reg::get, reg::isReadOnly, reg::set }; + } +}; +struct ChkCBoxPair +{ + MSFltrPg2_CheckBoxEntries eType; + Functions load; + Functions save; +}; +template <class regLoad, class regSave> constexpr ChkCBoxPair Pair(MSFltrPg2_CheckBoxEntries eType) +{ + return { eType, Functions::fromReg<regLoad>(), Functions::fromReg<regSave>() }; +} +template <class regLoad> constexpr ChkCBoxPair Load(MSFltrPg2_CheckBoxEntries eType) +{ + return { eType, Functions::fromReg<regLoad>(), {} }; +} +constexpr ChkCBoxPair aChkArr[] = { + Pair<officecfg::Office::Common::Filter::Microsoft::Import::MathTypeToMath, + officecfg::Office::Common::Filter::Microsoft::Export::MathToMathType>( + MSFltrPg2_CheckBoxEntries::Math), + Pair<officecfg::Office::Common::Filter::Microsoft::Import::WinWordToWriter, + officecfg::Office::Common::Filter::Microsoft::Export::WriterToWinWord>( + MSFltrPg2_CheckBoxEntries::Writer), + Pair<officecfg::Office::Common::Filter::Microsoft::Import::ExcelToCalc, + officecfg::Office::Common::Filter::Microsoft::Export::CalcToExcel>( + MSFltrPg2_CheckBoxEntries::Calc), + Pair<officecfg::Office::Common::Filter::Microsoft::Import::PowerPointToImpress, + officecfg::Office::Common::Filter::Microsoft::Export::ImpressToPowerPoint>( + MSFltrPg2_CheckBoxEntries::Impress), + Load<officecfg::Office::Common::Filter::Microsoft::Import::SmartArtToShapes>( + MSFltrPg2_CheckBoxEntries::SmartArt), + Load<officecfg::Office::Common::Filter::Microsoft::Import::VisioToDraw>( + MSFltrPg2_CheckBoxEntries::Visio), + Load<officecfg::Office::Common::Filter::Adobe::Import::PDFToDraw>( + MSFltrPg2_CheckBoxEntries::PDF), +}; +} + bool OfaMSFilterTabPage2::FillItemSet( SfxItemSet* ) { - SvtFilterOptions& rOpt = SvtFilterOptions::Get(); - - static struct ChkCBoxEntries{ - MSFltrPg2_CheckBoxEntries eType; - bool (SvtFilterOptions::*FnIs)() const; - void (SvtFilterOptions::*FnSet)( bool bFlag ); - } const aChkArr[] = { - { MSFltrPg2_CheckBoxEntries::Math, &SvtFilterOptions::IsMathType2Math, - &SvtFilterOptions::SetMathType2Math }, - { MSFltrPg2_CheckBoxEntries::Math, &SvtFilterOptions::IsMath2MathType, - &SvtFilterOptions::SetMath2MathType }, - { MSFltrPg2_CheckBoxEntries::Writer, &SvtFilterOptions::IsWinWord2Writer, - &SvtFilterOptions::SetWinWord2Writer }, - { MSFltrPg2_CheckBoxEntries::Writer, &SvtFilterOptions::IsWriter2WinWord, - &SvtFilterOptions::SetWriter2WinWord }, - { MSFltrPg2_CheckBoxEntries::Calc, &SvtFilterOptions::IsExcel2Calc, - &SvtFilterOptions::SetExcel2Calc }, - { MSFltrPg2_CheckBoxEntries::Calc, &SvtFilterOptions::IsCalc2Excel, - &SvtFilterOptions::SetCalc2Excel }, - { MSFltrPg2_CheckBoxEntries::Impress, &SvtFilterOptions::IsPowerPoint2Impress, - &SvtFilterOptions::SetPowerPoint2Impress }, - { MSFltrPg2_CheckBoxEntries::Impress, &SvtFilterOptions::IsImpress2PowerPoint, - &SvtFilterOptions::SetImpress2PowerPoint }, - { MSFltrPg2_CheckBoxEntries::SmartArt, &SvtFilterOptions::IsSmartArt2Shape, - &SvtFilterOptions::SetSmartArt2Shape }, - { MSFltrPg2_CheckBoxEntries::Visio, &SvtFilterOptions::IsVisio2Draw, - &SvtFilterOptions::SetVisio2Draw }, - }; - bool bFirstCol = true; - for( const ChkCBoxEntries & rEntry : aChkArr ) + auto pBatch = comphelper::ConfigurationChanges::create(); + for (const ChkCBoxPair& rEntry : aChkArr) { // we loop through the list, alternating reading the first/second column, // each row appears twice in the list (except for smartart and later entries, which are // import only) - sal_uInt16 nCol = bFirstCol ? 0 : 1; - bFirstCol = !bFirstCol; int nEntry = GetEntry4Type(rEntry.eType); if (nEntry != -1) { - bool bCheck = m_xCheckLB->get_toggle(nEntry, nCol); - if( bCheck != (rOpt.*rEntry.FnIs)() ) - (rOpt.*rEntry.FnSet)( bCheck ); - } - if (rEntry.eType == MSFltrPg2_CheckBoxEntries::SmartArt) - { - bFirstCol = !bFirstCol; + bool bCheck = m_xCheckLB->get_toggle(nEntry, 0); + if (bCheck != (rEntry.load.FnIs)(css::uno::Reference<css::uno::XComponentContext>())) + (rEntry.load.FnSet)(bCheck, pBatch); + + if (rEntry.save.FnIs) + { + bCheck = m_xCheckLB->get_toggle(nEntry, 1); + if (bCheck != (rEntry.save.FnIs)( + css::uno::Reference<css::uno::XComponentContext>())) + (rEntry.save.FnSet)(bCheck, pBatch); + } } } - int nPDFEntry = GetEntry4Type(MSFltrPg2_CheckBoxEntries::PDF); - bool bPDFCheck = m_xCheckLB->get_toggle(nPDFEntry, 0); - if (bPDFCheck != officecfg::Office::Common::Filter::Adobe::Import::PDFToDraw::get()) - { - std::shared_ptr<comphelper::ConfigurationChanges> pBatch( - comphelper::ConfigurationChanges::create()); - officecfg::Office::Common::Filter::Adobe::Import::PDFToDraw::set(bPDFCheck, pBatch); - pBatch->commit(); - } if( m_xHighlightingRB->get_state_changed_from_saved() ) { - if (m_xHighlightingRB->get_active()) - rOpt.SetCharBackground2Highlighting(); - else - rOpt.SetCharBackground2Shading(); + officecfg::Office::Common::Filter::Microsoft::Export::CharBackgroundToHighlighting::set( + m_xHighlightingRB->get_active(), pBatch); } if (m_xMSOLockFileCB->get_state_changed_from_saved()) { - rOpt.EnableMSOLockFileCreation(m_xMSOLockFileCB->get_active()); + officecfg::Office::Common::Filter::Microsoft::Import::CreateMSOLockFiles::set( + m_xMSOLockFileCB->get_active(), pBatch); } + pBatch->commit(); return true; } void OfaMSFilterTabPage2::Reset( const SfxItemSet* ) { - SvtFilterOptions& rOpt = SvtFilterOptions::Get(); - m_xCheckLB->freeze(); m_xCheckLB->clear(); @@ -257,63 +346,51 @@ void OfaMSFilterTabPage2::Reset( const SfxItemSet* ) InsertEntry(sChgToFromPDF, MSFltrPg2_CheckBoxEntries::PDF, false); } - static struct ChkCBoxEntries{ - MSFltrPg2_CheckBoxEntries eType; - bool (SvtFilterOptions::*FnIs)() const; - } const aChkArr[] = { - { MSFltrPg2_CheckBoxEntries::Math, &SvtFilterOptions::IsMathType2Math }, - { MSFltrPg2_CheckBoxEntries::Math, &SvtFilterOptions::IsMath2MathType }, - { MSFltrPg2_CheckBoxEntries::Writer, &SvtFilterOptions::IsWinWord2Writer }, - { MSFltrPg2_CheckBoxEntries::Writer, &SvtFilterOptions::IsWriter2WinWord }, - { MSFltrPg2_CheckBoxEntries::Calc, &SvtFilterOptions::IsExcel2Calc }, - { MSFltrPg2_CheckBoxEntries::Calc, &SvtFilterOptions::IsCalc2Excel }, - { MSFltrPg2_CheckBoxEntries::Impress, &SvtFilterOptions::IsPowerPoint2Impress }, - { MSFltrPg2_CheckBoxEntries::Impress, &SvtFilterOptions::IsImpress2PowerPoint }, - { MSFltrPg2_CheckBoxEntries::SmartArt, &SvtFilterOptions::IsSmartArt2Shape }, - { MSFltrPg2_CheckBoxEntries::Visio, &SvtFilterOptions::IsVisio2Draw }, - { MSFltrPg2_CheckBoxEntries::PDF, nullptr }, - }; - - bool bFirstCol = true; - for( const ChkCBoxEntries & rArr : aChkArr ) + for (const ChkCBoxPair& rArr : aChkArr) { // we loop through the list, alternating reading the first/second column, // each row appears twice in the list (except for smartart and later entries, which are // import only) - sal_uInt16 nCol = bFirstCol ? 0 : 1; - bFirstCol = !bFirstCol; int nEntry = GetEntry4Type( rArr.eType ); if (nEntry != -1) { - bool bCheck = false; - if (rArr.eType != MSFltrPg2_CheckBoxEntries::PDF) - { - bCheck = (rOpt.*rArr.FnIs)(); - } - else + bool bCheck = (rArr.load.FnIs)(css::uno::Reference<css::uno::XComponentContext>()); + bool bReadOnly = (rArr.load.FnIsReadOnly)( + css::uno::Reference<css::uno::XComponentContext>()); + m_xCheckLB->set_toggle(nEntry, bCheck ? TRISTATE_TRUE : TRISTATE_FALSE, 0); + m_xCheckLB->set_sensitive(nEntry, !bReadOnly, 0); + + if (rArr.save.FnIs) { - bCheck = officecfg::Office::Common::Filter::Adobe::Import::PDFToDraw::get(); - nCol = 0; + bCheck = (rArr.save.FnIs)(css::uno::Reference<css::uno::XComponentContext>()); + bReadOnly = (rArr.save.FnIsReadOnly)( + css::uno::Reference<css::uno::XComponentContext>()); + m_xCheckLB->set_toggle(nEntry, bCheck ? TRISTATE_TRUE : TRISTATE_FALSE, 1); + m_xCheckLB->set_sensitive(nEntry, !bReadOnly, 1); } - m_xCheckLB->set_toggle(nEntry, bCheck ? TRISTATE_TRUE : TRISTATE_FALSE, nCol); - } - if (rArr.eType == MSFltrPg2_CheckBoxEntries::SmartArt) - { - bFirstCol = !bFirstCol; } } m_xCheckLB->thaw(); - if (rOpt.IsCharBackground2Highlighting()) + if (officecfg::Office::Common::Filter::Microsoft::Export::CharBackgroundToHighlighting::get()) m_xHighlightingRB->set_active(true); else m_xShadingRB->set_active(true); + if (officecfg::Office::Common::Filter::Microsoft::Export::CharBackgroundToHighlighting::isReadOnly()) + { + m_xHighlightingRB->set_sensitive(false); + m_xShadingRB->set_sensitive(false); + m_xHighlightingFT->set_sensitive(false); + m_xShadingImg->set_visible(true); + } + m_xHighlightingRB->save_state(); - m_xMSOLockFileCB->set_active(rOpt.IsMSOLockFileCreationIsEnabled()); + m_xMSOLockFileCB->set_active(officecfg::Office::Common::Filter::Microsoft::Import::CreateMSOLockFiles::get()); m_xMSOLockFileCB->save_state(); m_xMSOLockFileCB->set_sensitive(!officecfg::Office::Common::Filter::Microsoft::Import::CreateMSOLockFiles::isReadOnly()); + m_xMSOLockFileImg->set_visible(officecfg::Office::Common::Filter::Microsoft::Import::CreateMSOLockFiles::isReadOnly()); } void OfaMSFilterTabPage2::InsertEntry( const OUString& _rTxt, MSFltrPg2_CheckBoxEntries _nType ) diff --git a/cui/source/options/optfltr.hxx b/cui/source/options/optfltr.hxx index f38a89366286..51a51ec04456 100644 --- a/cui/source/options/optfltr.hxx +++ b/cui/source/options/optfltr.hxx @@ -23,13 +23,21 @@ class OfaMSFilterTabPage : public SfxTabPage { std::unique_ptr<weld::CheckButton> m_xWBasicCodeCB; + std::unique_ptr<weld::Widget> m_xWBasicCodeImg; std::unique_ptr<weld::CheckButton> m_xWBasicWbctblCB; + std::unique_ptr<weld::Widget> m_xWBasicWbctblImg; std::unique_ptr<weld::CheckButton> m_xWBasicStgCB; + std::unique_ptr<weld::Widget> m_xWBasicStgImg; std::unique_ptr<weld::CheckButton> m_xEBasicCodeCB; + std::unique_ptr<weld::Widget> m_xEBasicCodeImg; std::unique_ptr<weld::CheckButton> m_xEBasicExectblCB; + std::unique_ptr<weld::Widget> m_xEBasicExectblImg; std::unique_ptr<weld::CheckButton> m_xEBasicStgCB; + std::unique_ptr<weld::Widget> m_xEBasicStgImg; std::unique_ptr<weld::CheckButton> m_xPBasicCodeCB; + std::unique_ptr<weld::Widget> m_xPBasicCodeImg; std::unique_ptr<weld::CheckButton> m_xPBasicStgCB; + std::unique_ptr<weld::Widget> m_xPBasicStgImg; DECL_LINK(LoadWordBasicCheckHdl_Impl, weld::Toggleable&, void); DECL_LINK(LoadExcelBasicCheckHdl_Impl, weld::Toggleable&, void); @@ -40,6 +48,8 @@ public: static std::unique_ptr<SfxTabPage> Create( weld::Container* pPage, weld::DialogController* pController, const SfxItemSet* rAttrSet ); + virtual OUString GetAllStrings() override; + virtual bool FillItemSet( SfxItemSet* rSet ) override; virtual void Reset( const SfxItemSet* rSet ) override; }; @@ -57,9 +67,12 @@ class OfaMSFilterTabPage2 : public SfxTabPage sChgToFromPDF; std::unique_ptr<weld::TreeView> m_xCheckLB; + std::unique_ptr<weld::Label> m_xHighlightingFT; std::unique_ptr<weld::RadioButton> m_xHighlightingRB; std::unique_ptr<weld::RadioButton> m_xShadingRB; + std::unique_ptr<weld::Widget> m_xShadingImg; std::unique_ptr<weld::CheckButton> m_xMSOLockFileCB; + std::unique_ptr<weld::Widget> m_xMSOLockFileImg; void InsertEntry( const OUString& _rTxt, MSFltrPg2_CheckBoxEntries _nType ); void InsertEntry( const OUString& _rTxt, MSFltrPg2_CheckBoxEntries _nType, @@ -71,6 +84,8 @@ public: static std::unique_ptr<SfxTabPage> Create( weld::Container* pPage, weld::DialogController* pController, const SfxItemSet* rAttrSet ); virtual ~OfaMSFilterTabPage2() override; + virtual OUString GetAllStrings() override; + virtual bool FillItemSet( SfxItemSet* rSet ) override; virtual void Reset( const SfxItemSet* rSet ) override; }; diff --git a/cui/source/options/optgdlg.cxx b/cui/source/options/optgdlg.cxx index 43b529a82718..1b8e6f58fde7 100644 --- a/cui/source/options/optgdlg.cxx +++ b/cui/source/options/optgdlg.cxx @@ -48,13 +48,14 @@ #include <editeng/editids.hrc> #include <svx/svxids.hrc> #include <svl/intitem.hxx> +#include <svl/voiditem.hxx> #include <GraphicsTestsDialog.hxx> #include <unotools/searchopt.hxx> #include <sal/log.hxx> #include <officecfg/Office/Common.hxx> #include <officecfg/Setup.hxx> #include <comphelper/configuration.hxx> -#include <tools/diagnose_ex.h> +#include <comphelper/diagnose_ex.hxx> #if HAVE_FEATURE_BREAKPAD #include <desktop/crashreport.hxx> #endif @@ -81,13 +82,18 @@ #include <vcl/window.hxx> #include <vcl/IconThemeInfo.hxx> #include <vcl/skia/SkiaHelper.hxx> +#include <bitmaps.hlst> + #include "optgdlg.hxx" #include <svtools/apearcfg.hxx> #include <svtools/optionsdrawinglayer.hxx> #include <svtools/restartdialog.hxx> #include <svtools/imgdef.hxx> +#include <com/sun/star/datatransfer/clipboard/SystemClipboard.hpp> +#include <vcl/unohelp2.hxx> #if defined(_WIN32) +#include <systools/win32/winstoreutil.hxx> #include <vcl/fileregistration.hxx> #endif using namespace ::com::sun::star::uno; @@ -154,48 +160,46 @@ bool lcl_HasSystemFilePicker() OfaMiscTabPage::OfaMiscTabPage(weld::Container* pPage, weld::DialogController* pController, const SfxItemSet& rSet) : SfxTabPage(pPage, pController, "cui/ui/optgeneralpage.ui", "OptGeneralPage", &rSet) , m_xExtHelpCB(m_xBuilder->weld_check_button("exthelp")) + , m_xExtHelpImg(m_xBuilder->weld_widget("lockexthelp")) , m_xPopUpNoHelpCB(m_xBuilder->weld_check_button("popupnohelp")) + , m_xPopUpNoHelpImg(m_xBuilder->weld_widget("lockpopupnohelp")) , m_xShowTipOfTheDay(m_xBuilder->weld_check_button("cbShowTipOfTheDay")) + , m_xShowTipOfTheDayImg(m_xBuilder->weld_widget("lockcbShowTipOfTheDay")) , m_xFileDlgFrame(m_xBuilder->weld_widget("filedlgframe")) , m_xFileDlgROImage(m_xBuilder->weld_widget("lockimage")) , m_xFileDlgCB(m_xBuilder->weld_check_button("filedlg")) - , m_xPrintDlgCB(m_xBuilder->weld_check_button("printdlg")) , m_xDocStatusCB(m_xBuilder->weld_check_button("docstatus")) + , m_xDocStatusImg(m_xBuilder->weld_widget("lockdocstatus")) , m_xYearFrame(m_xBuilder->weld_widget("yearframe")) + , m_xYearLabel(m_xBuilder->weld_label("yearslabel")) , m_xYearValueField(m_xBuilder->weld_spin_button("year")) , m_xToYearFT(m_xBuilder->weld_label("toyear")) + , m_xYearFrameImg(m_xBuilder->weld_widget("lockyears")) +#if HAVE_FEATURE_BREAKPAD + , m_xPrivacyFrame(m_xBuilder->weld_widget("privacyframe")) , m_xCrashReport(m_xBuilder->weld_check_button("crashreport")) - , m_xQuickStarterFrame(m_xBuilder->weld_widget("quickstarter")) - , m_xHelpImproveLabel(m_xBuilder->weld_label("label7")) //"Help Improve" -#if defined(UNX) - , m_xQuickLaunchCB(m_xBuilder->weld_check_button("systray")) -#else - , m_xQuickLaunchCB(m_xBuilder->weld_check_button("quicklaunch")) + , m_xCrashReportImg(m_xBuilder->weld_widget("lockcrashreport")) #endif #if defined(_WIN32) + , m_xQuickStarterFrame(m_xBuilder->weld_widget("quickstarter")) + , m_xQuickLaunchCB(m_xBuilder->weld_check_button("quicklaunch")) + , m_xQuickLaunchImg(m_xBuilder->weld_widget("lockquicklaunch")) , m_xFileAssocFrame(m_xBuilder->weld_widget("fileassoc")) , m_xFileAssocBtn(m_xBuilder->weld_button("assocfiles")) , m_xPerformFileExtCheck(m_xBuilder->weld_check_button("cbPerformFileExtCheck")) + , m_xPerformFileExtImg(m_xBuilder->weld_widget("lockcbPerformFileExtCheck")) #endif { - if (!lcl_HasSystemFilePicker()) - m_xFileDlgFrame->hide(); - else if (officecfg::Office::Common::Misc::UseSystemFileDialog::isReadOnly()) - { - m_xFileDlgROImage->show(); - m_xFileDlgCB->set_sensitive(false); - } - - m_xQuickLaunchCB->show(); - - //Only available in Win or if building the gtk systray -#if !defined(_WIN32) - m_xQuickStarterFrame->hide(); - //Hide frame label in case of no content - m_xHelpImproveLabel->hide(); +#if HAVE_FEATURE_BREAKPAD + m_xPrivacyFrame->show(); #endif #if defined(_WIN32) + // Store-packaged apps (located under the protected Program Files\WindowsApps) can't use normal + // shell shortcuts to their exe. TODO: show a button to open "Startup Apps" system applet? + if (!sal::systools::IsStorePackagedApp()) + m_xQuickStarterFrame->show(); + m_xFileAssocFrame->show(); m_xFileAssocBtn->connect_clicked(LINK(this, OfaMiscTabPage, FileAssocClick)); #endif @@ -215,6 +219,34 @@ std::unique_ptr<SfxTabPage> OfaMiscTabPage::Create( weld::Container* pPage, weld return std::make_unique<OfaMiscTabPage>( pPage, pController, *rAttrSet ); } +OUString OfaMiscTabPage::GetAllStrings() +{ + OUString sAllStrings; + OUString labels[] = { "label1", "label2", "label4", "label5", "yearslabel", + "toyear", "label7", "label8", "label9" }; + + for (const auto& label : labels) + { + if (const auto& pString = m_xBuilder->weld_label(label)) + sAllStrings += pString->get_label() + " "; + } + + OUString checkButton[] + = { "exthelp", "popupnohelp", "cbShowTipOfTheDay", "filedlg", + "docstatus", "crashreport", "quicklaunch", "cbPerformFileExtCheck" }; + + for (const auto& check : checkButton) + { + if (const auto& pString = m_xBuilder->weld_check_button(check)) + sAllStrings += pString->get_label() + " "; + } + + if (const auto& pString = m_xBuilder->weld_button("assocfiles")) + sAllStrings += pString->get_label() + " "; + + return sAllStrings.replaceAll("_", ""); +} + bool OfaMiscTabPage::FillItemSet( SfxItemSet* rSet ) { bool bModified = false; @@ -244,7 +276,7 @@ bool OfaMiscTabPage::FillItemSet( SfxItemSet* rSet ) bModified = true; } - const SfxUInt16Item* pUInt16Item = dynamic_cast< const SfxUInt16Item* >( GetOldItem( *rSet, SID_ATTR_YEAR2000 ) ); + const SfxUInt16Item* pUInt16Item = GetOldItem( *rSet, SID_ATTR_YEAR2000 ); sal_uInt16 nNum = static_cast<sal_uInt16>(m_xYearValueField->get_text().toInt32()); if ( pUInt16Item && pUInt16Item->GetValue() != nNum ) { @@ -267,38 +299,66 @@ bool OfaMiscTabPage::FillItemSet( SfxItemSet* rSet ) m_xPerformFileExtCheck->get_active(), batch); bModified = true; } -#endif - - batch->commit(); if( m_xQuickLaunchCB->get_state_changed_from_saved()) { rSet->Put(SfxBoolItem(SID_ATTR_QUICKLAUNCHER, m_xQuickLaunchCB->get_active())); bModified = true; } +#endif + + batch->commit(); return bModified; } void OfaMiscTabPage::Reset( const SfxItemSet* rSet ) { + bool bEnable = !officecfg::Office::Common::Help::ExtendedTip::isReadOnly(); m_xExtHelpCB->set_active( officecfg::Office::Common::Help::Tip::get() && officecfg::Office::Common::Help::ExtendedTip::get() ); + m_xExtHelpCB->set_sensitive(bEnable); + m_xExtHelpImg->set_visible(!bEnable); m_xExtHelpCB->save_state(); + + bEnable = !officecfg::Office::Common::Help::BuiltInHelpNotInstalledPopUp::isReadOnly(); m_xPopUpNoHelpCB->set_active( officecfg::Office::Common::Help::BuiltInHelpNotInstalledPopUp::get() ); + m_xPopUpNoHelpCB->set_sensitive(bEnable); + m_xPopUpNoHelpImg->set_visible(!bEnable); m_xPopUpNoHelpCB->save_state(); + + bEnable = !officecfg::Office::Common::Misc::ShowTipOfTheDay::isReadOnly(); m_xShowTipOfTheDay->set_active( officecfg::Office::Common::Misc::ShowTipOfTheDay::get() ); + m_xShowTipOfTheDay->set_sensitive(bEnable); + m_xShowTipOfTheDayImg->set_visible(!bEnable); m_xShowTipOfTheDay->save_state(); - m_xFileDlgCB->set_active( !officecfg::Office::Common::Misc::UseSystemFileDialog::get() ); + + if (!lcl_HasSystemFilePicker()) + m_xFileDlgFrame->hide(); + else + { + bEnable = !officecfg::Office::Common::Misc::UseSystemFileDialog::isReadOnly(); + m_xFileDlgCB->set_sensitive(bEnable); + m_xFileDlgROImage->set_visible(!bEnable); + } + m_xFileDlgCB->set_active(!officecfg::Office::Common::Misc::UseSystemFileDialog::get()); m_xFileDlgCB->save_state(); + bEnable = !officecfg::Office::Common::Print::PrintingModifiesDocument::isReadOnly(); m_xDocStatusCB->set_active(officecfg::Office::Common::Print::PrintingModifiesDocument::get()); + m_xDocStatusCB->set_sensitive(bEnable); + m_xDocStatusImg->set_visible(!bEnable); m_xDocStatusCB->save_state(); - const SfxPoolItem* pItem = nullptr; - if ( SfxItemState::SET == rSet->GetItemState( SID_ATTR_YEAR2000, false, &pItem ) ) + bEnable = !officecfg::Office::Common::DateFormat::TwoDigitYear::isReadOnly(); + m_xYearLabel->set_sensitive(bEnable); + m_xYearValueField->set_sensitive(bEnable); + m_xToYearFT->set_sensitive(bEnable); + m_xYearFrameImg->set_visible(!bEnable); + + if ( const SfxUInt16Item* pYearItem = rSet->GetItemIfSet( SID_ATTR_YEAR2000, false ) ) { - m_xYearValueField->set_value( static_cast<const SfxUInt16Item*>(pItem)->GetValue() ); + m_xYearValueField->set_value( pYearItem->GetValue() ); TwoFigureHdl(*m_xYearValueField); } else @@ -307,11 +367,12 @@ void OfaMiscTabPage::Reset( const SfxItemSet* rSet ) #if HAVE_FEATURE_BREAKPAD m_xCrashReport->set_active(officecfg::Office::Common::Misc::CrashReport::get() && CrashReporter::IsDumpEnable()); m_xCrashReport->set_sensitive(!officecfg::Office::Common::Misc::CrashReport::isReadOnly() && CrashReporter::IsDumpEnable()); + m_xCrashReportImg->set_visible(officecfg::Office::Common::Misc::CrashReport::isReadOnly() && CrashReporter::IsDumpEnable()); m_xCrashReport->save_state(); -#else - m_xCrashReport->hide(); #endif +#if defined(_WIN32) + const SfxPoolItem* pItem = nullptr; SfxItemState eState = rSet->GetItemState( SID_ATTR_QUICKLAUNCHER, false, &pItem ); if ( SfxItemState::SET == eState ) m_xQuickLaunchCB->set_active( static_cast<const SfxBoolItem*>(pItem)->GetValue() ); @@ -323,11 +384,11 @@ void OfaMiscTabPage::Reset( const SfxItemSet* rSet ) m_xQuickLaunchCB->save_state(); -#if defined(_WIN32) m_xPerformFileExtCheck->set_active( officecfg::Office::Common::Misc::PerformFileExtCheck::get()); m_xPerformFileExtCheck->save_state(); m_xPerformFileExtCheck->set_sensitive(!officecfg::Office::Common::Misc::PerformFileExtCheck::isReadOnly()); + m_xPerformFileExtImg->set_visible(officecfg::Office::Common::Misc::PerformFileExtCheck::isReadOnly()); #endif } @@ -524,39 +585,69 @@ OfaViewTabPage::OfaViewTabPage(weld::Container* pPage, weld::DialogController* p , nSidebarSizeLB_InitialSelection(0) , nNotebookbarSizeLB_InitialSelection(0) , nStyleLB_InitialSelection(0) - , pAppearanceCfg(new SvtTabAppearanceCfg) , pCanvasSettings(new CanvasSettings) + , m_xIconSizeLabel(m_xBuilder->weld_label("label14")) , m_xIconSizeLB(m_xBuilder->weld_combo_box("iconsize")) + , m_xIconSizeImg(m_xBuilder->weld_widget("lockiconsize")) + , m_xSidebarIconSizeLabel(m_xBuilder->weld_label("label9")) , m_xSidebarIconSizeLB(m_xBuilder->weld_combo_box("sidebariconsize")) + , m_xSidebarIconSizeImg(m_xBuilder->weld_widget("locksidebariconsize")) + , m_xNotebookbarIconSizeLabel(m_xBuilder->weld_label("label8")) , m_xNotebookbarIconSizeLB(m_xBuilder->weld_combo_box("notebookbariconsize")) + , m_xNotebookbarIconSizeImg(m_xBuilder->weld_widget("locknotebookbariconsize")) + , m_xDarkModeFrame(m_xBuilder->weld_widget("darkmode")) + , m_xAppearanceStyleLabel(m_xBuilder->weld_label("label7")) + , m_xAppearanceStyleLB(m_xBuilder->weld_combo_box("appearance")) + , m_xAppearanceStyleImg(m_xBuilder->weld_widget("lockappearance")) + , m_xIconStyleLabel(m_xBuilder->weld_label("label6")) , m_xIconStyleLB(m_xBuilder->weld_combo_box("iconstyle")) + , m_xIconStyleImg(m_xBuilder->weld_widget("lockiconstyle")) , m_xFontAntiAliasing(m_xBuilder->weld_check_button("aafont")) + , m_xFontAntiAliasingImg(m_xBuilder->weld_widget("lockaafont")) , m_xAAPointLimitLabel(m_xBuilder->weld_label("aafrom")) + , m_xAAPointLimitLabelImg(m_xBuilder->weld_widget("lockaafrom")) , m_xAAPointLimit(m_xBuilder->weld_metric_spin_button("aanf", FieldUnit::PIXEL)) - , m_xMenuIconBox(m_xBuilder->weld_widget("menuiconsbox")) - , m_xMenuIconsLB(m_xBuilder->weld_combo_box("menuicons")) - , m_xContextMenuShortcutsLB(m_xBuilder->weld_combo_box("contextmenushortcuts")) , m_xFontShowCB(m_xBuilder->weld_check_button("showfontpreview")) + , m_xFontShowImg(m_xBuilder->weld_widget("lockshowfontpreview")) , m_xUseHardwareAccell(m_xBuilder->weld_check_button("useaccel")) + , m_xUseHardwareAccellImg(m_xBuilder->weld_widget("lockuseaccel")) , m_xUseAntiAliase(m_xBuilder->weld_check_button("useaa")) + , m_xUseAntiAliaseImg(m_xBuilder->weld_widget("lockuseaa")) , m_xUseSkia(m_xBuilder->weld_check_button("useskia")) + , m_xUseSkiaImg(m_xBuilder->weld_widget("lockuseskia")) , m_xForceSkiaRaster(m_xBuilder->weld_check_button("forceskiaraster")) + , m_xForceSkiaRasterImg(m_xBuilder->weld_widget("lockforceskiaraster")) , m_xSkiaStatusEnabled(m_xBuilder->weld_label("skiaenabled")) , m_xSkiaStatusDisabled(m_xBuilder->weld_label("skiadisabled")) - , m_xMousePosLB(m_xBuilder->weld_combo_box("mousepos")) + , m_xSkiaLog(m_xBuilder->weld_button("btnSkialog")) + , m_xMouseMiddleLabel(m_xBuilder->weld_label("label12")) , m_xMouseMiddleLB(m_xBuilder->weld_combo_box("mousemiddle")) + , m_xMouseMiddleImg(m_xBuilder->weld_widget("lockmousemiddle")) , m_xMoreIcons(m_xBuilder->weld_button("btnMoreIcons")) , m_xRunGPTests(m_xBuilder->weld_button("btn_rungptest")) + , m_sAutoStr(m_xIconStyleLB->get_text(0)) { - if (Application::GetToolkitName().startsWith("gtk")) - m_xMenuIconBox->hide(); + OUString sToolKitName(Application::GetToolkitName()); + const bool bHasDarkMode = sToolKitName.startsWith("gtk") || sToolKitName == "osx" || sToolKitName == "win"; + if (!bHasDarkMode) + m_xDarkModeFrame->hide(); m_xFontAntiAliasing->connect_toggled( LINK( this, OfaViewTabPage, OnAntialiasingToggled ) ); m_xUseSkia->connect_toggled(LINK(this, OfaViewTabPage, OnUseSkiaToggled)); + m_xSkiaLog->connect_clicked(LINK(this, OfaViewTabPage, OnCopySkiaLog)); + + UpdateIconThemes(); + m_xIconStyleLB->set_active(0); + + m_xMoreIcons->connect_clicked(LINK(this, OfaViewTabPage, OnMoreIconsClick)); + m_xRunGPTests->connect_clicked( LINK( this, OfaViewTabPage, OnRunGPTestClick)); +} + +void OfaViewTabPage::UpdateIconThemes() +{ // Set known icon themes - OUString sAutoStr( m_xIconStyleLB->get_text( 0 ) ); m_xIconStyleLB->clear(); StyleSettings aStyleSettings = Application::GetSettings().GetStyleSettings(); mInstalledIconThemes = aStyleSettings.GetInstalledIconThemes(); @@ -566,9 +657,7 @@ OfaViewTabPage::OfaViewTabPage(weld::Container* pPage, weld::DialogController* p OUString autoThemeId = aStyleSettings.GetAutomaticallyChosenIconTheme(); const vcl::IconThemeInfo& autoIconTheme = vcl::IconThemeInfo::FindIconThemeById(mInstalledIconThemes, autoThemeId); - OUString entryForAuto = sAutoStr + " (" + - autoIconTheme.GetDisplayName() + - ")"; + OUString entryForAuto = m_sAutoStr + " (" + autoIconTheme.GetDisplayName() + ")"; m_xIconStyleLB->append("auto", entryForAuto); // index 0 means choose style automatically // separate auto and other icon themes @@ -576,12 +665,6 @@ OfaViewTabPage::OfaViewTabPage(weld::Container* pPage, weld::DialogController* p for (auto const& installIconTheme : mInstalledIconThemes) m_xIconStyleLB->append(installIconTheme.GetThemeId(), installIconTheme.GetDisplayName()); - - m_xIconStyleLB->set_active(0); - - m_xMoreIcons->set_from_icon_name("cmd/sc_additionsdialog.png"); - m_xMoreIcons->connect_clicked(LINK(this, OfaViewTabPage, OnMoreIconsClick)); - m_xRunGPTests->connect_clicked( LINK( this, OfaViewTabPage, OnRunGPTestClick)); } OfaViewTabPage::~OfaViewTabPage() @@ -603,7 +686,7 @@ IMPL_STATIC_LINK_NOARG(OfaViewTabPage, OnMoreIconsClick, weld::Button&, void) IMPL_LINK_NOARG( OfaViewTabPage, OnAntialiasingToggled, weld::Toggleable&, void ) { - bool bAAEnabled = m_xFontAntiAliasing->get_active(); + bool bAAEnabled = m_xFontAntiAliasing->get_active() && !officecfg::Office::Common::View::FontAntiAliasing::MinPixelHeight::isReadOnly(); m_xAAPointLimitLabel->set_sensitive(bAAEnabled); m_xAAPointLimit->set_sensitive(bAAEnabled); @@ -614,12 +697,25 @@ IMPL_LINK_NOARG(OfaViewTabPage, OnUseSkiaToggled, weld::Toggleable&, void) UpdateSkiaStatus(); } +IMPL_LINK_NOARG(OfaViewTabPage, OnCopySkiaLog, weld::Button&, void) +{ +#if HAVE_FEATURE_SKIA + css::uno::Reference<css::datatransfer::clipboard::XClipboard> xClipboard = + css::datatransfer::clipboard::SystemClipboard::create( + comphelper::getProcessComponentContext()); + OUString sInfo = SkiaHelper::readLog(); + vcl::unohelper::TextDataObject::CopyStringTo(sInfo, xClipboard); + m_xSkiaLog->set_from_icon_name(RID_SVXBMP_COPY); +#endif +} + void OfaViewTabPage::HideSkiaWidgets() { m_xUseSkia->hide(); m_xForceSkiaRaster->hide(); m_xSkiaStatusEnabled->hide(); m_xSkiaStatusDisabled->hide(); + m_xSkiaLog->hide(); } void OfaViewTabPage::UpdateSkiaStatus() @@ -648,9 +744,11 @@ void OfaViewTabPage::UpdateSkiaStatus() m_xSkiaStatusEnabled->set_visible(bEnabled); m_xSkiaStatusDisabled->set_visible(!bEnabled); - // FIXME: should really add code to show a 'lock' icon here. m_xUseSkia->set_sensitive(!officecfg::Office::Common::VCL::UseSkia::isReadOnly()); + m_xUseSkiaImg->set_visible(officecfg::Office::Common::VCL::UseSkia::isReadOnly()); m_xForceSkiaRaster->set_sensitive(m_xUseSkia->get_active() && !officecfg::Office::Common::VCL::ForceSkiaRaster::isReadOnly()); + m_xForceSkiaRasterImg->set_visible(officecfg::Office::Common::VCL::ForceSkiaRaster::isReadOnly()); + m_xSkiaLog->set_sensitive(bEnabled); // Technically the 'use hardware acceleration' option could be used to mean !forceSkiaRaster, but the implementation // of the option is so tied to the implementation of the canvas module that it's simpler to ignore it. @@ -665,10 +763,37 @@ std::unique_ptr<SfxTabPage> OfaViewTabPage::Create( weld::Container* pPage, weld return std::make_unique<OfaViewTabPage>(pPage, pController, *rAttrSet); } +OUString OfaViewTabPage::GetAllStrings() +{ + OUString sAllStrings; + OUString labels[] = { "label16", "label7", "label1", "label6", "label15", + "label14", "label8", "label9", "label4", "label12", + "label2", "skiaenabled", "skiadisabled", "label5", "aafrom" }; + + for (const auto& label : labels) + { + if (const auto& pString = m_xBuilder->weld_label(label)) + sAllStrings += pString->get_label() + " "; + } + + OUString checkButton[] + = { "useaccel", "useaa", "useskia", "forceskiaraster", "showfontpreview", "aafont" }; + + for (const auto& check : checkButton) + { + if (const auto& pString = m_xBuilder->weld_check_button(check)) + sAllStrings += pString->get_label() + " "; + } + + sAllStrings += m_xSkiaLog->get_label() + " " + m_xRunGPTests->get_label() + " "; + + return sAllStrings.replaceAll("_", ""); +} + bool OfaViewTabPage::FillItemSet( SfxItemSet* ) { bool bModified = false; - bool bMenuOptModified = false; + bool bDarkModeOptModified = false; bool bRepaintWindows(false); std::shared_ptr<comphelper::ConfigurationChanges> xChanges(comphelper::ConfigurationChanges::create()); @@ -685,7 +810,7 @@ bool OfaViewTabPage::FillItemSet( SfxItemSet* ) case 2: eSet = SFX_SYMBOLS_SIZE_LARGE; break; case 3: eSet = SFX_SYMBOLS_SIZE_32; break; default: - OSL_FAIL( "OfaViewTabPage::FillItemSet(): This state of m_xIconSizeLB should not be possible!" ); + SAL_WARN("cui.options", "OfaViewTabPage::FillItemSet(): This state of m_xIconSizeLB should not be possible!"); } aMiscOptions.SetSymbolsSize( eSet ); } @@ -701,7 +826,7 @@ bool OfaViewTabPage::FillItemSet( SfxItemSet* ) case 1: eSet = ToolBoxButtonSize::Small; break; case 2: eSet = ToolBoxButtonSize::Large; break; default: - OSL_FAIL( "OfaViewTabPage::FillItemSet(): This state of m_xSidebarIconSizeLB should not be possible!" ); + SAL_WARN("cui.options", "OfaViewTabPage::FillItemSet(): This state of m_xSidebarIconSizeLB should not be possible!"); } officecfg::Office::Common::Misc::SidebarIconSize::set(static_cast<sal_Int16>(eSet), xChanges); } @@ -717,7 +842,7 @@ bool OfaViewTabPage::FillItemSet( SfxItemSet* ) case 1: eSet = ToolBoxButtonSize::Small; break; case 2: eSet = ToolBoxButtonSize::Large; break; default: - OSL_FAIL( "OfaViewTabPage::FillItemSet(): This state of m_xNotebookbarIconSizeLB should not be possible!" ); + SAL_WARN("cui.options", "OfaViewTabPage::FillItemSet(): This state of m_xNotebookbarIconSizeLB should not be possible!"); } officecfg::Office::Common::Misc::NotebookbarIconSize::set(static_cast<sal_Int16>(eSet), xChanges); } @@ -730,40 +855,31 @@ bool OfaViewTabPage::FillItemSet( SfxItemSet* ) } bool bAppearanceChanged = false; - - // Mouse Snap Mode - SnapType eOldSnap = pAppearanceCfg->GetSnapMode(); - SnapType eNewSnap = static_cast<SnapType>(m_xMousePosLB->get_active()); - if(eNewSnap > SnapType::NONE) - eNewSnap = SnapType::NONE; - - if ( eNewSnap != eOldSnap ) - { - pAppearanceCfg->SetSnapMode(eNewSnap ); - bAppearanceChanged = true; - } + std::shared_ptr<comphelper::ConfigurationChanges> batch(comphelper::ConfigurationChanges::create()); // Middle Mouse Button - MouseMiddleButtonAction eOldMiddleMouse = pAppearanceCfg->GetMiddleMouseButton(); + MouseMiddleButtonAction eOldMiddleMouse = static_cast<MouseMiddleButtonAction>(officecfg::Office::Common::View::Dialog::MiddleMouseButton::get()); short eNewMiddleMouse = m_xMouseMiddleLB->get_active(); if(eNewMiddleMouse > 2) eNewMiddleMouse = 2; if ( eNewMiddleMouse != static_cast<short>(eOldMiddleMouse) ) { - pAppearanceCfg->SetMiddleMouseButton( static_cast<MouseMiddleButtonAction>(eNewMiddleMouse) ); + officecfg::Office::Common::View::Dialog::MiddleMouseButton::set(eNewMiddleMouse, batch); bAppearanceChanged = true; } if (m_xFontAntiAliasing->get_state_changed_from_saved()) { - pAppearanceCfg->SetFontAntiAliasing(m_xFontAntiAliasing->get_active()); + bool b = m_xFontAntiAliasing->get_active(); + officecfg::Office::Common::View::FontAntiAliasing::Enabled::set(b, batch); bAppearanceChanged = true; } if (m_xAAPointLimit->get_value_changed_from_saved()) { - pAppearanceCfg->SetFontAntialiasingMinPixelHeight(m_xAAPointLimit->get_value(FieldUnit::PIXEL)); + sal_Int64 i = m_xAAPointLimit->get_value(FieldUnit::PIXEL); + officecfg::Office::Common::View::FontAntiAliasing::MinPixelHeight::set(i, batch); bAppearanceChanged = true; } @@ -773,30 +889,10 @@ bool OfaViewTabPage::FillItemSet( SfxItemSet* ) bModified = true; } - if (m_xMenuIconsLB->get_value_changed_from_saved()) + if (m_xAppearanceStyleLB->get_value_changed_from_saved()) { - TriState eMenuIcons = m_xMenuIconsLB->get_active() == 0 ? - TRISTATE_INDET : - static_cast<TriState>(m_xMenuIconsLB->get_active() - 1); - // Output cache of current setting as possibly modified by System Theme for older version - bool bMenuIcons = Application::GetSettings().GetStyleSettings().GetUseImagesInMenus(); - officecfg::Office::Common::View::Menu::IsSystemIconsInMenus::set(eMenuIcons == TRISTATE_INDET, xChanges); - officecfg::Office::Common::View::Menu::ShowIconsInMenues::set(bMenuIcons, xChanges); + bDarkModeOptModified = true; bModified = true; - bMenuOptModified = true; - bAppearanceChanged = true; - } - - if (m_xContextMenuShortcutsLB->get_value_changed_from_saved()) - { - officecfg::Office::Common::View::Menu::ShortcutsInContextMenus::set( - m_xContextMenuShortcutsLB->get_active() == 0 ? - TRISTATE_INDET : - static_cast<TriState>(m_xContextMenuShortcutsLB->get_active() - 1), - xChanges); - bModified = true; - bMenuOptModified = true; - bAppearanceChanged = true; } // #i95644# if disabled, do not use value, see in ::Reset() @@ -830,20 +926,13 @@ bool OfaViewTabPage::FillItemSet( SfxItemSet* ) xChanges->commit(); - if( bMenuOptModified ) - { - // Set changed settings to the application instance - AllSettings aAllSettings = Application::GetSettings(); - StyleSettings aStyleSettings = aAllSettings.GetStyleSettings(); - aAllSettings.SetStyleSettings(aStyleSettings); - Application::MergeSystemSettings( aAllSettings ); - Application::SetSettings(aAllSettings); - } + if (bDarkModeOptModified) + MiscSettings::SetDarkMode(m_xAppearanceStyleLB->get_active()); if ( bAppearanceChanged ) { - pAppearanceCfg->Commit(); - pAppearanceCfg->SetApplicationDefaults ( GetpApp() ); + batch->commit(); + SvtTabAppearanceCfg::SetApplicationDefaults ( GetpApp() ); } if(bRepaintWindows) @@ -873,17 +962,23 @@ bool OfaViewTabPage::FillItemSet( SfxItemSet* ) void OfaViewTabPage::Reset( const SfxItemSet* ) { SvtMiscOptions aMiscOptions; + bool bEnable = true; - if (aMiscOptions.GetSymbolsSize() != SFX_SYMBOLS_SIZE_AUTO) + if (SvtMiscOptions::GetSymbolsSize() != SFX_SYMBOLS_SIZE_AUTO) { nSizeLB_InitialSelection = 1; - if (aMiscOptions.GetSymbolsSize() == SFX_SYMBOLS_SIZE_LARGE) + if (SvtMiscOptions::GetSymbolsSize() == SFX_SYMBOLS_SIZE_LARGE) nSizeLB_InitialSelection = 2; - else if (aMiscOptions.GetSymbolsSize() == SFX_SYMBOLS_SIZE_32) + else if (SvtMiscOptions::GetSymbolsSize() == SFX_SYMBOLS_SIZE_32) nSizeLB_InitialSelection = 3; } + bEnable = !officecfg::Office::Common::Misc::SymbolSet::isReadOnly(); m_xIconSizeLB->set_active( nSizeLB_InitialSelection ); + m_xIconSizeLabel->set_sensitive(bEnable); + m_xIconSizeLB->set_sensitive(bEnable); + m_xMoreIcons->set_sensitive(bEnable); + m_xIconSizeImg->set_visible(!bEnable); m_xIconSizeLB->save_value(); ToolBoxButtonSize eSidebarIconSize = static_cast<ToolBoxButtonSize>(officecfg::Office::Common::Misc::SidebarIconSize::get()); @@ -893,8 +988,14 @@ void OfaViewTabPage::Reset( const SfxItemSet* ) nSidebarSizeLB_InitialSelection = 1; else if( eSidebarIconSize == ToolBoxButtonSize::Large ) nSidebarSizeLB_InitialSelection = 2; + + bEnable = !officecfg::Office::Common::Misc::SidebarIconSize::isReadOnly(); m_xSidebarIconSizeLB->set_active( nSidebarSizeLB_InitialSelection ); + m_xSidebarIconSizeLabel->set_sensitive(bEnable); + m_xSidebarIconSizeLB->set_sensitive(bEnable); + m_xSidebarIconSizeImg->set_visible(!bEnable); m_xSidebarIconSizeLB->save_value(); + ToolBoxButtonSize eNotebookbarIconSize = static_cast<ToolBoxButtonSize>(officecfg::Office::Common::Misc::NotebookbarIconSize::get()); if( eNotebookbarIconSize == ToolBoxButtonSize::DontCare ) ; // do nothing @@ -902,45 +1003,67 @@ void OfaViewTabPage::Reset( const SfxItemSet* ) nNotebookbarSizeLB_InitialSelection = 1; else if( eNotebookbarIconSize == ToolBoxButtonSize::Large ) nNotebookbarSizeLB_InitialSelection = 2; + + bEnable = !officecfg::Office::Common::Misc::NotebookbarIconSize::isReadOnly(); m_xNotebookbarIconSizeLB->set_active(nNotebookbarSizeLB_InitialSelection); + m_xNotebookbarIconSizeLabel->set_sensitive(bEnable); + m_xNotebookbarIconSizeLB->set_sensitive(bEnable); + m_xNotebookbarIconSizeImg->set_visible(!bEnable); m_xNotebookbarIconSizeLB->save_value(); + // tdf#153497 set name of automatic icon theme, it may have changed due to "Apply" while this page is visible + UpdateIconThemes(); + if (aMiscOptions.IconThemeWasSetAutomatically()) { nStyleLB_InitialSelection = 0; } else { - const OUString& selected = aMiscOptions.GetIconTheme(); + const OUString& selected = SvtMiscOptions::GetIconTheme(); const vcl::IconThemeInfo& selectedInfo = vcl::IconThemeInfo::FindIconThemeById(mInstalledIconThemes, selected); nStyleLB_InitialSelection = m_xIconStyleLB->find_text(selectedInfo.GetDisplayName()); } + bEnable = !officecfg::Office::Common::Misc::SymbolStyle::isReadOnly(); m_xIconStyleLB->set_active(nStyleLB_InitialSelection); + m_xIconStyleLabel->set_sensitive(bEnable); + m_xIconStyleLB->set_sensitive(bEnable); + m_xIconStyleImg->set_visible(!bEnable); m_xIconStyleLB->save_value(); - // Mouse Snap - m_xMousePosLB->set_active(static_cast<sal_Int32>(pAppearanceCfg->GetSnapMode())); - m_xMousePosLB->save_value(); + bEnable = !officecfg::Office::Common::Misc::Appearance::isReadOnly(); + m_xAppearanceStyleLB->set_active(officecfg::Office::Common::Misc::Appearance::get()); + m_xAppearanceStyleLabel->set_sensitive(bEnable); + m_xAppearanceStyleLB->set_sensitive(bEnable); + m_xAppearanceStyleImg->set_visible(!bEnable); + m_xAppearanceStyleLB->save_value(); - // Mouse Snap - m_xMouseMiddleLB->set_active(static_cast<short>(pAppearanceCfg->GetMiddleMouseButton())); + // Middle Mouse Button + bEnable = !officecfg::Office::Common::View::Dialog::MiddleMouseButton::isReadOnly(); + sal_Int16 nMiddleMouseButton = officecfg::Office::Common::View::Dialog::MiddleMouseButton::get(); + m_xMouseMiddleLB->set_active(static_cast<short>(nMiddleMouseButton)); + m_xMouseMiddleLabel->set_sensitive(bEnable); + m_xMouseMiddleLB->set_sensitive(bEnable); + m_xMouseMiddleImg->set_visible(!bEnable); m_xMouseMiddleLB->save_value(); - m_xFontAntiAliasing->set_active( pAppearanceCfg->IsFontAntiAliasing() ); - m_xAAPointLimit->set_value(pAppearanceCfg->GetFontAntialiasingMinPixelHeight(), FieldUnit::PIXEL); + bEnable = !officecfg::Office::Common::View::FontAntiAliasing::Enabled::isReadOnly(); + bool bFontAntiAliasing = officecfg::Office::Common::View::FontAntiAliasing::Enabled::get(); + m_xFontAntiAliasing->set_active( bFontAntiAliasing ); + m_xFontAntiAliasing->set_sensitive(bEnable); + m_xFontAntiAliasingImg->set_visible(!bEnable); + + bEnable = !officecfg::Office::Common::View::FontAntiAliasing::MinPixelHeight::isReadOnly(); + sal_Int16 nFontAntiAliasingMinPixelHeight = officecfg::Office::Common::View::FontAntiAliasing::MinPixelHeight::get(); + m_xAAPointLimit->set_value(nFontAntiAliasingMinPixelHeight, FieldUnit::PIXEL); + m_xAAPointLimit->set_sensitive(bEnable); + m_xAAPointLimitLabelImg->set_visible(!bEnable); // WorkingSet + bEnable = !officecfg::Office::Common::Font::View::ShowFontBoxWYSIWYG::isReadOnly(); m_xFontShowCB->set_active(officecfg::Office::Common::Font::View::ShowFontBoxWYSIWYG::get()); - bool bMenuIcons = officecfg::Office::Common::View::Menu::ShowIconsInMenues::get(); - bool bSystemMenuIcons = officecfg::Office::Common::View::Menu::IsSystemIconsInMenus::get(); - TriState eMenuIcons = bSystemMenuIcons ? TRISTATE_INDET : static_cast<TriState>(bMenuIcons); - m_xMenuIconsLB->set_active(eMenuIcons == 2 ? 0 : eMenuIcons + 1); - m_xMenuIconsLB->save_value(); - - TriState eContextMenuShortcuts = static_cast<TriState>(officecfg::Office::Common::View::Menu::ShortcutsInContextMenus::get()); - bool bContextMenuShortcutsNonDefault = eContextMenuShortcuts == TRISTATE_FALSE || eContextMenuShortcuts == TRISTATE_TRUE; - m_xContextMenuShortcutsLB->set_active(bContextMenuShortcutsNonDefault ? eContextMenuShortcuts + 1 : 0); - m_xContextMenuShortcutsLB->save_value(); + m_xFontShowCB->set_sensitive(bEnable); + m_xFontShowImg->set_visible(!bEnable); UpdateHardwareAccelStatus(); m_xUseHardwareAccell->save_state(); @@ -954,8 +1077,12 @@ void OfaViewTabPage::Reset( const SfxItemSet* ) { m_xUseAntiAliase->set_active(false); m_xUseAntiAliase->set_sensitive(false); + m_xUseAntiAliaseImg->set_visible(true); } + bEnable = !officecfg::Office::Common::Drawinglayer::AntiAliasing::isReadOnly(); + m_xUseAntiAliase->set_sensitive(bEnable); + m_xUseAntiAliaseImg->set_visible(!bEnable); m_xUseAntiAliase->save_state(); } @@ -979,11 +1106,13 @@ void OfaViewTabPage::UpdateHardwareAccelStatus() { m_xUseHardwareAccell->set_active(pCanvasSettings->IsHardwareAccelerationEnabled()); m_xUseHardwareAccell->set_sensitive(!pCanvasSettings->IsHardwareAccelerationRO()); + m_xUseHardwareAccellImg->set_visible(pCanvasSettings->IsHardwareAccelerationRO()); } else { m_xUseHardwareAccell->set_active(false); m_xUseHardwareAccell->set_sensitive(false); + m_xUseHardwareAccellImg->set_visible(true); } #if HAVE_FEATURE_SKIA m_xUseHardwareAccell->set_sensitive(!m_xUseSkia->get_active()); @@ -1000,11 +1129,11 @@ struct LanguageConfig_Impl static bool bLanguageCurrentDoc_Impl = false; // some things we'll need... -constexpr OUStringLiteral sAccessSrvc = u"com.sun.star.configuration.ConfigurationAccess"; +constexpr OUString sAccessSrvc = u"com.sun.star.configuration.ConfigurationAccess"_ustr; constexpr OUStringLiteral sAccessUpdSrvc = u"com.sun.star.configuration.ConfigurationUpdateAccess"; -constexpr OUStringLiteral sInstalledLocalesPath = u"org.openoffice.Setup/Office/InstalledLocales"; -constexpr OUStringLiteral sUserLocalePath = u"org.openoffice.Office.Linguistic/General"; -constexpr OUStringLiteral sUserLocaleKey = u"UILocale"; +constexpr OUString sInstalledLocalesPath = u"org.openoffice.Setup/Office/InstalledLocales"_ustr; +constexpr OUString sUserLocalePath = u"org.openoffice.Office.Linguistic/General"_ustr; +constexpr OUString sUserLocaleKey = u"UILocale"_ustr; static Sequence< OUString > seqInstalledLanguages; static OUString lcl_getDatePatternsConfigString( const LocaleDataWrapper& rLocaleWrapper ) @@ -1018,7 +1147,7 @@ static OUString lcl_getDatePatternsConfigString( const LocaleDataWrapper& rLocal const OUString* pPatterns = aDateAcceptancePatterns.getConstArray(); aBuf.append( pPatterns[0]); for (sal_Int32 i=1; i < nPatterns; ++i) - aBuf.append(';').append( pPatterns[i]); + aBuf.append(";" + pPatterns[i]); } return aBuf.makeStringAndClear(); } @@ -1040,19 +1169,28 @@ OfaLanguagesTabPage::OfaLanguagesTabPage(weld::Container* pPage, weld::DialogCon , m_xUserInterfaceLB(m_xBuilder->weld_combo_box("userinterface")) , m_xLocaleSettingFT(m_xBuilder->weld_label("localesettingFT")) , m_xLocaleSettingLB(new SvxLanguageBox(m_xBuilder->weld_combo_box("localesetting"))) + , m_xLocaleSettingImg(m_xBuilder->weld_widget("locklocalesetting")) + , m_xDecimalSeparatorFT(m_xBuilder->weld_label("label6")) , m_xDecimalSeparatorCB(m_xBuilder->weld_check_button("decimalseparator")) + , m_xDecimalSeparatorImg(m_xBuilder->weld_widget("lockdecimalseparator")) , m_xCurrencyFT(m_xBuilder->weld_label("defaultcurrency")) , m_xCurrencyLB(m_xBuilder->weld_combo_box("currencylb")) + , m_xCurrencyImg(m_xBuilder->weld_widget("lockcurrencylb")) , m_xDatePatternsFT(m_xBuilder->weld_label("dataaccpatterns")) , m_xDatePatternsED(m_xBuilder->weld_entry("datepatterns")) + , m_xDatePatternsImg(m_xBuilder->weld_widget("lockdatepatterns")) , m_xWesternLanguageLB(new SvxLanguageBox(m_xBuilder->weld_combo_box("westernlanguage"))) , m_xWesternLanguageFT(m_xBuilder->weld_label("western")) + , m_xWesternLanguageImg(m_xBuilder->weld_widget("lockwesternlanguage")) , m_xAsianLanguageLB(new SvxLanguageBox(m_xBuilder->weld_combo_box("asianlanguage"))) , m_xComplexLanguageLB(new SvxLanguageBox(m_xBuilder->weld_combo_box("complexlanguage"))) , m_xCurrentDocCB(m_xBuilder->weld_check_button("currentdoc")) , m_xAsianSupportCB(m_xBuilder->weld_check_button("asiansupport")) + , m_xAsianSupportImg(m_xBuilder->weld_widget("lockasiansupport")) , m_xCTLSupportCB(m_xBuilder->weld_check_button("ctlsupport")) + , m_xCTLSupportImg(m_xBuilder->weld_widget("lockctlsupport")) , m_xIgnoreLanguageChangeCB(m_xBuilder->weld_check_button("ignorelanguagechange")) + , m_xIgnoreLanguageChangeImg(m_xBuilder->weld_widget("lockignorelanguagechange")) { // tdf#125483 save original default label m_sDecimalSeparatorLabel = m_xDecimalSeparatorCB->get_label(); @@ -1072,7 +1210,7 @@ OfaLanguagesTabPage::OfaLanguagesTabPage(weld::Container* pPage, weld::DialogCon css::configuration::theDefaultProvider::get( comphelper::getProcessComponentContext())); // find out which locales are currently installed and add them to the listbox - Sequence< Any > theArgs{ Any(NamedValue("nodepath", Any(OUString(sInstalledLocalesPath)))) }; + Sequence< Any > theArgs{ Any(NamedValue("nodepath", Any(sInstalledLocalesPath))) }; Reference< XNameAccess > theNameAccess( theConfigProvider->createInstanceWithArguments(sAccessSrvc, theArgs ), UNO_QUERY_THROW ); seqInstalledLanguages = theNameAccess->getElementNames(); @@ -1091,7 +1229,7 @@ OfaLanguagesTabPage::OfaLanguagesTabPage(weld::Container* pPage, weld::DialogCon std::sort(aUILanguages.begin(), aUILanguages.end(), [](const auto& l1, const auto& l2) { static const auto aSorter = comphelper::string::NaturalStringSorter( comphelper::getProcessComponentContext(), - Application::GetSettings().GetLanguageTag().getLocale()); + Application::GetSettings().GetUILanguageTag().getLocale()); return aSorter.compare(l1.second, l2.second) < 0; }); @@ -1104,7 +1242,7 @@ OfaLanguagesTabPage::OfaLanguagesTabPage(weld::Container* pPage, weld::DialogCon m_xUserInterfaceLB->set_active(0); // find out whether the user has a specific locale specified - Sequence< Any > theArgs2{ Any(NamedValue("nodepath", Any(OUString(sUserLocalePath)))) }; + Sequence< Any > theArgs2{ Any(NamedValue("nodepath", Any(sUserLocalePath))) }; theNameAccess.set( theConfigProvider->createInstanceWithArguments(sAccessSrvc, theArgs2 ), UNO_QUERY_THROW ); if (theNameAccess->hasByName(sUserLocaleKey)) @@ -1174,7 +1312,7 @@ OfaLanguagesTabPage::OfaLanguagesTabPage(weld::Container* pPage, weld::DialogCon aStr_ = ApplyLreOrRleEmbedding( aStr_ ) + aTwoSpace + ApplyLreOrRleEmbedding( SvtLanguageTable::GetLanguageString( v->GetLanguage() ) ); - m_xCurrencyLB->append(OUString::number(reinterpret_cast<sal_Int64>(v)), aStr_); + m_xCurrencyLB->append(weld::toId(v), aStr_); } m_xCurrencyLB->set_active(0); @@ -1189,15 +1327,17 @@ OfaLanguagesTabPage::OfaLanguagesTabPage(weld::Container* pPage, weld::DialogCon m_bOldAsian = SvtCJKOptions::IsAnyEnabled(); m_xAsianSupportCB->set_active(m_bOldAsian); m_xAsianSupportCB->save_state(); - bool bReadonly = SvtCJKOptions::IsReadOnly(SvtCJKOptions::E_ALL); + bool bReadonly = SvtCJKOptions::IsAnyReadOnly(); m_xAsianSupportCB->set_sensitive(!bReadonly); + m_xAsianSupportImg->set_visible(bReadonly); SupportHdl(*m_xAsianSupportCB); - m_bOldCtl = pLangConfig->aCTLLanguageOptions.IsCTLFontEnabled(); + m_bOldCtl = SvtCTLOptions::IsCTLFontEnabled(); m_xCTLSupportCB->set_active(m_bOldCtl); m_xCTLSupportCB->save_state(); bReadonly = pLangConfig->aCTLLanguageOptions.IsReadOnly(SvtCTLOptions::E_CTLFONT); m_xCTLSupportCB->set_sensitive(!bReadonly); + m_xCTLSupportImg->set_visible(bReadonly); SupportHdl(*m_xCTLSupportCB); m_xIgnoreLanguageChangeCB->set_active( pLangConfig->aSysLocaleOptions.IsIgnoreLanguageChange() ); @@ -1230,6 +1370,31 @@ static void lcl_Update(std::unique_ptr<SfxVoidItem> pInvalidItems[], std::unique } } +OUString OfaLanguagesTabPage::GetAllStrings() +{ + OUString sAllStrings; + OUString labels[] + = { "label1", "label4", "label7", "localesettingFT", "defaultcurrency", + "label6", "dataaccpatterns", "label2", "western", "label3" }; + + for (const auto& label : labels) + { + if (const auto& pString = m_xBuilder->weld_label(label)) + sAllStrings += pString->get_label() + " "; + } + + OUString checkButton[] = { "decimalseparator", "asiansupport", "ctlsupport", "currentdoc", + "ignorelanguagechange" }; + + for (const auto& check : checkButton) + { + if (const auto& pString = m_xBuilder->weld_check_button(check)) + sAllStrings += pString->get_label() + " "; + } + + return sAllStrings.replaceAll("_", ""); +} + bool OfaLanguagesTabPage::FillItemSet( SfxItemSet* rSet ) { // lock configuration broadcasters so that we can coordinate the notifications @@ -1273,7 +1438,7 @@ bool OfaLanguagesTabPage::FillItemSet( SfxItemSet* rSet ) Reference< XMultiServiceFactory > theConfigProvider( css::configuration::theDefaultProvider::get( comphelper::getProcessComponentContext())); - Sequence< Any > theArgs{ Any(NamedValue("nodepath", Any(OUString(sUserLocalePath)))) }; + Sequence< Any > theArgs{ Any(NamedValue("nodepath", Any(sUserLocalePath))) }; Reference< XPropertySet >xProp( theConfigProvider->createInstanceWithArguments(sAccessUpdSrvc, theArgs ), UNO_QUERY_THROW ); if ( m_sUserLocaleValue != aLangString) @@ -1329,8 +1494,10 @@ bool OfaLanguagesTabPage::FillItemSet( SfxItemSet* rSet ) SvtScriptType nNewType = SvtLanguageOptions::GetScriptTypeOfLanguage( eNewLocale ); bool bNewCJK = bool( nNewType & SvtScriptType::ASIAN ); - SvtCompatibilityOptions aCompatOpts; - aCompatOpts.SetDefault( SvtCompatibilityEntry::Index::ExpandWordSpace, !bNewCJK ); + auto batch = comphelper::ConfigurationChanges::create(); + SvtCompatibilityDefault aCompatOpts(batch); + aCompatOpts.set(u"ExpandWordSpace"_ustr, !bNewCJK); + batch->commit(); } if(m_xDecimalSeparatorCB->get_state_changed_from_saved()) @@ -1342,7 +1509,7 @@ bool OfaLanguagesTabPage::FillItemSet( SfxItemSet* rSet ) // Configured currency, for example, USD-en-US or EUR-de-DE, or empty for locale default. OUString sOldCurr = pLangConfig->aSysLocaleOptions.GetCurrencyConfigString(); OUString sId = m_xCurrencyLB->get_active_id(); - const NfCurrencyEntry* pCurr = sId == "default" ? nullptr : reinterpret_cast<const NfCurrencyEntry*>(sId.toInt64()); + const NfCurrencyEntry* pCurr = sId == "default" ? nullptr : weld::fromId<const NfCurrencyEntry*>(sId); OUString sNewCurr; if ( pCurr ) sNewCurr = SvtSysLocaleOptions::CreateCurrencyConfigString( @@ -1371,7 +1538,7 @@ bool OfaLanguagesTabPage::FillItemSet( SfxItemSet* rSet ) Any aValue; Locale aLocale = LanguageTag::convertToLocale( eSelectLang, false); aValue <<= aLocale; - pLangConfig->aLinguConfig.SetProperty( "DefaultLocale", aValue ); + pLangConfig->aLinguConfig.SetProperty( u"DefaultLocale", aValue ); if (xLinguProp.is()) xLinguProp->setDefaultLocale( aLocale ); } @@ -1390,7 +1557,7 @@ bool OfaLanguagesTabPage::FillItemSet( SfxItemSet* rSet ) Any aValue; Locale aLocale = LanguageTag::convertToLocale( eSelectLang, false); aValue <<= aLocale; - pLangConfig->aLinguConfig.SetProperty( "DefaultLocale_CJK", aValue ); + pLangConfig->aLinguConfig.SetProperty( u"DefaultLocale_CJK", aValue ); if (xLinguProp.is()) xLinguProp->setDefaultLocale_CJK( aLocale ); } @@ -1409,7 +1576,7 @@ bool OfaLanguagesTabPage::FillItemSet( SfxItemSet* rSet ) Any aValue; Locale aLocale = LanguageTag::convertToLocale( eSelectLang, false); aValue <<= aLocale; - pLangConfig->aLinguConfig.SetProperty( "DefaultLocale_CTL", aValue ); + pLangConfig->aLinguConfig.SetProperty( u"DefaultLocale_CTL", aValue ); if (xLinguProp.is()) xLinguProp->setDefaultLocale_CTL( aLocale ); } @@ -1478,12 +1645,20 @@ void OfaLanguagesTabPage::Reset( const SfxItemSet* rSet ) bool bReadonly = pLangConfig->aSysLocaleOptions.IsReadOnly(SvtSysLocaleOptions::EOption::Locale); m_xLocaleSettingLB->set_sensitive(!bReadonly); m_xLocaleSettingFT->set_sensitive(!bReadonly); + m_xLocaleSettingImg->set_visible(bReadonly); m_xDecimalSeparatorCB->set_active( pLangConfig->aSysLocaleOptions.IsDecimalSeparatorAsLocale()); + bReadonly = pLangConfig->aSysLocaleOptions.IsReadOnly(SvtSysLocaleOptions::EOption::DecimalSeparator); + m_xDecimalSeparatorCB->set_sensitive(!bReadonly); + m_xDecimalSeparatorFT->set_sensitive(!bReadonly); + m_xDecimalSeparatorImg->set_visible(bReadonly); m_xDecimalSeparatorCB->save_state(); m_xIgnoreLanguageChangeCB->set_active( pLangConfig->aSysLocaleOptions.IsIgnoreLanguageChange()); + bReadonly = pLangConfig->aSysLocaleOptions.IsReadOnly(SvtSysLocaleOptions::EOption::IgnoreLanguageChange); + m_xIgnoreLanguageChangeCB->set_sensitive(!bReadonly); + m_xIgnoreLanguageChangeImg->set_visible(bReadonly); m_xIgnoreLanguageChangeCB->save_state(); // let LocaleSettingHdl enable/disable checkboxes for CJK/CTL support @@ -1502,11 +1677,12 @@ void OfaLanguagesTabPage::Reset( const SfxItemSet* rSet ) pCurr = SvNumberFormatter::GetCurrencyEntry( aAbbrev, eLang ); } // if pCurr==nullptr the SYSTEM entry is selected - OUString sId = !pCurr ? OUString("default") : OUString::number(reinterpret_cast<sal_Int64>(pCurr)); + OUString sId = !pCurr ? OUString("default") : weld::toId(pCurr); m_xCurrencyLB->set_active_id(sId); bReadonly = pLangConfig->aSysLocaleOptions.IsReadOnly(SvtSysLocaleOptions::EOption::Currency); m_xCurrencyLB->set_sensitive(!bReadonly); m_xCurrencyFT->set_sensitive(!bReadonly); + m_xCurrencyImg->set_visible(bReadonly); // date acceptance patterns OUString aDatePatternsString = pLangConfig->aSysLocaleOptions.GetDatePatternsConfigString(); @@ -1514,13 +1690,21 @@ void OfaLanguagesTabPage::Reset( const SfxItemSet* rSet ) { const LocaleDataWrapper& rLocaleWrapper( Application::GetSettings().GetLocaleDataWrapper() ); aDatePatternsString = lcl_getDatePatternsConfigString( rLocaleWrapper); + // Let's assume patterns are valid at this point. + m_bDatePatternsValid = true; + } + else + { + bool bModified = false; + m_bDatePatternsValid = validateDatePatterns( bModified, aDatePatternsString); } - // Let's assume patterns are valid at this point. - m_bDatePatternsValid = true; m_xDatePatternsED->set_text(aDatePatternsString); + m_xDatePatternsED->set_message_type( m_bDatePatternsValid ? + weld::EntryMessageType::Normal : weld::EntryMessageType::Error); bReadonly = pLangConfig->aSysLocaleOptions.IsReadOnly(SvtSysLocaleOptions::EOption::DatePatterns); m_xDatePatternsED->set_sensitive(!bReadonly); m_xDatePatternsFT->set_sensitive(!bReadonly); + m_xDatePatternsImg->set_visible(bReadonly); m_xDatePatternsED->save_value(); //western/CJK/CLK language @@ -1536,18 +1720,18 @@ void OfaLanguagesTabPage::Reset( const SfxItemSet* rSet ) Any aCTLLang; try { - aWestLang = pLangConfig->aLinguConfig.GetProperty("DefaultLocale"); + aWestLang = pLangConfig->aLinguConfig.GetProperty(u"DefaultLocale"); Locale aLocale; aWestLang >>= aLocale; eCurLang = LanguageTag::convertToLanguageType( aLocale, false); - aCJKLang = pLangConfig->aLinguConfig.GetProperty("DefaultLocale_CJK"); + aCJKLang = pLangConfig->aLinguConfig.GetProperty(u"DefaultLocale_CJK"); aLocale = Locale(); aCJKLang >>= aLocale; eCurLangCJK = LanguageTag::convertToLanguageType( aLocale, false); - aCTLLang = pLangConfig->aLinguConfig.GetProperty("DefaultLocale_CTL"); + aCTLLang = pLangConfig->aLinguConfig.GetProperty(u"DefaultLocale_CTL"); aLocale = Locale(); aCTLLang >>= aLocale; eCurLangCTL = LanguageTag::convertToLanguageType( aLocale, false); @@ -1560,24 +1744,23 @@ void OfaLanguagesTabPage::Reset( const SfxItemSet* rSet ) { m_xCurrentDocCB->set_sensitive(true); m_xCurrentDocCB->set_active(bLanguageCurrentDoc_Impl); - const SfxPoolItem* pLang; - if( SfxItemState::SET == rSet->GetItemState(SID_ATTR_LANGUAGE, false, &pLang)) + if( const SvxLanguageItem* pLangItem = rSet->GetItemIfSet(SID_ATTR_LANGUAGE, false)) { - LanguageType eTempCurLang = static_cast<const SvxLanguageItem*>(pLang)->GetValue(); + LanguageType eTempCurLang = pLangItem->GetValue(); if (MsLangId::resolveSystemLanguageByScriptType(eCurLang, css::i18n::ScriptType::LATIN) != eTempCurLang) eCurLang = eTempCurLang; } - if( SfxItemState::SET == rSet->GetItemState(SID_ATTR_CHAR_CJK_LANGUAGE, false, &pLang)) + if( const SvxLanguageItem* pLang = rSet->GetItemIfSet(SID_ATTR_CHAR_CJK_LANGUAGE, false)) { - LanguageType eTempCurLang = static_cast<const SvxLanguageItem*>(pLang)->GetValue(); + LanguageType eTempCurLang = pLang->GetValue(); if (MsLangId::resolveSystemLanguageByScriptType(eCurLangCJK, css::i18n::ScriptType::ASIAN) != eTempCurLang) eCurLangCJK = eTempCurLang; } - if( SfxItemState::SET == rSet->GetItemState(SID_ATTR_CHAR_CTL_LANGUAGE, false, &pLang)) + if( const SvxLanguageItem* pLang = rSet->GetItemIfSet(SID_ATTR_CHAR_CTL_LANGUAGE, false)) { - LanguageType eTempCurLang = static_cast<const SvxLanguageItem*>(pLang)->GetValue(); + LanguageType eTempCurLang = pLang->GetValue(); if (MsLangId::resolveSystemLanguageByScriptType(eCurLangCTL, css::i18n::ScriptType::COMPLEX) != eTempCurLang) eCurLangCTL = eTempCurLang; } @@ -1603,14 +1786,15 @@ void OfaLanguagesTabPage::Reset( const SfxItemSet* rSet ) m_xIgnoreLanguageChangeCB->save_state(); m_xCurrentDocCB->save_state(); - bool bEnable = !pLangConfig->aLinguConfig.IsReadOnly( "DefaultLocale" ); + bool bEnable = !pLangConfig->aLinguConfig.IsReadOnly( u"DefaultLocale" ); m_xWesternLanguageFT->set_sensitive( bEnable ); m_xWesternLanguageLB->set_sensitive( bEnable ); + m_xWesternLanguageImg->set_visible( !bEnable ); // check the box "For the current document only" // set the focus to the Western Language box - const SfxPoolItem* pLang = nullptr; - if ( SfxItemState::SET == rSet->GetItemState(SID_SET_DOCUMENT_LANGUAGE, false, &pLang ) && static_cast<const SfxBoolItem*>(pLang)->GetValue() ) + const SfxBoolItem* pLang = rSet->GetItemIfSet(SID_SET_DOCUMENT_LANGUAGE, false ); + if ( pLang && pLang->GetValue() ) { m_xWesternLanguageLB->grab_focus(); m_xCurrentDocCB->set_sensitive(true); @@ -1623,7 +1807,7 @@ IMPL_LINK(OfaLanguagesTabPage, SupportHdl, weld::Toggleable&, rBox, void) bool bCheck = rBox.get_active(); if ( m_xAsianSupportCB.get() == &rBox ) { - bool bReadonly = pLangConfig->aLinguConfig.IsReadOnly("DefaultLocale_CJK"); + bool bReadonly = pLangConfig->aLinguConfig.IsReadOnly(u"DefaultLocale_CJK"); bCheck = ( bCheck && !bReadonly ); m_xAsianLanguageLB->set_sensitive( bCheck ); if (rBox.get_sensitive()) @@ -1631,7 +1815,7 @@ IMPL_LINK(OfaLanguagesTabPage, SupportHdl, weld::Toggleable&, rBox, void) } else if ( m_xCTLSupportCB.get() == &rBox ) { - bool bReadonly = pLangConfig->aLinguConfig.IsReadOnly("DefaultLocale_CTL"); + bool bReadonly = pLangConfig->aLinguConfig.IsReadOnly(u"DefaultLocale_CTL"); bCheck = ( bCheck && !bReadonly ); m_xComplexLanguageLB->set_sensitive( bCheck ); if (rBox.get_sensitive()) @@ -1669,7 +1853,7 @@ IMPL_LINK_NOARG(OfaLanguagesTabPage, LocaleSettingHdl, weld::ComboBox&, void) } // second check if CJK must be enabled // #103299# - if CJK support is not readonly - if(!SvtCJKOptions::IsReadOnly(SvtCJKOptions::E_ALL)) + if(!SvtCJKOptions::IsAnyReadOnly()) { bool bIsCJKFixed = bool(nType & SvtScriptType::ASIAN); lcl_checkLanguageCheckBox(*m_xAsianSupportCB, bIsCJKFixed, m_bOldAsian); @@ -1678,7 +1862,7 @@ IMPL_LINK_NOARG(OfaLanguagesTabPage, LocaleSettingHdl, weld::ComboBox&, void) const NfCurrencyEntry& rCurr = SvNumberFormatter::GetCurrencyEntry( (eLang == LANGUAGE_USER_SYSTEM_CONFIG) ? MsLangId::getConfiguredSystemLanguage() : eLang); - const OUString aDefaultID = "default"; + constexpr OUString aDefaultID = u"default"_ustr; // Update the "Default ..." currency. m_xCurrencyLB->remove_id(aDefaultID); OUString aDefaultCurr = m_sSystemDefaultString + " - " + rCurr.GetBankSymbol(); @@ -1687,8 +1871,7 @@ IMPL_LINK_NOARG(OfaLanguagesTabPage, LocaleSettingHdl, weld::ComboBox&, void) m_xCurrencyLB->set_active_text(aDefaultCurr); // obtain corresponding locale data - LanguageTag aLanguageTag( eLang); - LocaleDataWrapper aLocaleWrapper( aLanguageTag ); + LocaleDataWrapper aLocaleWrapper(( LanguageTag(eLang) )); // update the decimal separator key of the related CheckBox OUString sTempLabel(m_sDecimalSeparatorLabel); @@ -1699,20 +1882,39 @@ IMPL_LINK_NOARG(OfaLanguagesTabPage, LocaleSettingHdl, weld::ComboBox&, void) OUString aDatePatternsString = lcl_getDatePatternsConfigString( aLocaleWrapper); m_bDatePatternsValid = true; m_xDatePatternsED->set_text( aDatePatternsString); + m_xDatePatternsED->set_message_type(weld::EntryMessageType::Normal); } IMPL_LINK( OfaLanguagesTabPage, DatePatternsHdl, weld::Entry&, rEd, void ) { - const OUString aPatterns(rEd.get_text()); - OUStringBuffer aBuf( aPatterns); - sal_Int32 nChar = 0; - bool bValid = true; + OUString aPatterns(rEd.get_text()); bool bModified = false; - if (!aPatterns.isEmpty()) + const bool bValid = validateDatePatterns( bModified, aPatterns); + if (bModified) + { + // gtk3 keeps the cursor position on equal length set_text() but at + // least the 'gen' backend does not and resets to 0. + const int nCursorPos = rEd.get_position(); + rEd.set_text(aPatterns); + rEd.set_position(nCursorPos); + } + if (bValid) + rEd.set_message_type(weld::EntryMessageType::Normal); + else + rEd.set_message_type(weld::EntryMessageType::Error); + m_bDatePatternsValid = bValid; +} + +bool OfaLanguagesTabPage::validateDatePatterns( bool& rbModified, OUString& rPatterns ) +{ + bool bValid = true; + if (!rPatterns.isEmpty()) { + OUStringBuffer aBuf( rPatterns); + sal_Int32 nChar = 0; for (sal_Int32 nIndex=0; nIndex >= 0 && bValid; ++nChar) { - const OUString aPat( aPatterns.getToken( 0, ';', nIndex)); + const OUString aPat( rPatterns.getToken( 0, ';', nIndex)); if (aPat.isEmpty() && nIndex < 0) { // Indicating failure when about to append a pattern is too @@ -1727,6 +1929,18 @@ IMPL_LINK( OfaLanguagesTabPage, DatePatternsHdl, weld::Entry&, rEd, void ) bool bY, bM, bD; bY = bM = bD = false; bool bSep = true; + if (aPat.getLength() == 3) + { + // Disallow a pattern that would match a numeric input with + // decimal separator, like M.D + const LanguageType eLang = m_xLocaleSettingLB->get_active_id(); + const LocaleDataWrapper aLocaleWrapper(( LanguageTag(eLang))); + if ( aPat[1] == aLocaleWrapper.getNumDecimalSep().toChar() + || aPat[1] == aLocaleWrapper.getNumDecimalSepAlt().toChar()) + { + bValid = false; + } + } for (sal_Int32 i = 0; i < aPat.getLength() && bValid; /*nop*/) { const sal_Int32 j = i; @@ -1741,7 +1955,7 @@ IMPL_LINK( OfaLanguagesTabPage, DatePatternsHdl, weld::Entry&, rEd, void ) else if (c == 'y') { aBuf[nChar] = 'Y'; - bModified = true; + rbModified = true; } bY = true; bSep = false; @@ -1753,7 +1967,7 @@ IMPL_LINK( OfaLanguagesTabPage, DatePatternsHdl, weld::Entry&, rEd, void ) else if (c == 'm') { aBuf[nChar] = 'M'; - bModified = true; + rbModified = true; } bM = true; bSep = false; @@ -1765,7 +1979,7 @@ IMPL_LINK( OfaLanguagesTabPage, DatePatternsHdl, weld::Entry&, rEd, void ) else if (c == 'd') { aBuf[nChar] = 'D'; - bModified = true; + rbModified = true; } bD = true; bSep = false; @@ -1783,20 +1997,10 @@ IMPL_LINK( OfaLanguagesTabPage, DatePatternsHdl, weld::Entry&, rEd, void ) bValid &= (bY || bM || bD); } } + if (rbModified) + rPatterns = aBuf.makeStringAndClear(); } - if (bModified) - { - // gtk3 keeps the cursor position on equal length set_text() but at - // least the 'gen' backend does not and resets to 0. - const int nCursorPos = rEd.get_position(); - rEd.set_text(aBuf.makeStringAndClear()); - rEd.set_position(nCursorPos); - } - if (bValid) - rEd.set_message_type(weld::EntryMessageType::Normal); - else - rEd.set_message_type(weld::EntryMessageType::Error); - m_bDatePatternsValid = bValid; + return bValid; } /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/cui/source/options/optgdlg.hxx b/cui/source/options/optgdlg.hxx index 75f29c6c5a34..2c62e569ea75 100644 --- a/cui/source/options/optgdlg.hxx +++ b/cui/source/options/optgdlg.hxx @@ -18,6 +18,7 @@ */ #pragma once #include <memory> +#include <config_features.h> #include <sfx2/tabdlg.hxx> #include <svx/langbox.hxx> @@ -33,24 +34,34 @@ private: OUString m_aStrDateInfo; std::unique_ptr<weld::CheckButton> m_xExtHelpCB; + std::unique_ptr<weld::Widget> m_xExtHelpImg; std::unique_ptr<weld::CheckButton> m_xPopUpNoHelpCB; + std::unique_ptr<weld::Widget> m_xPopUpNoHelpImg; std::unique_ptr<weld::CheckButton> m_xShowTipOfTheDay; + std::unique_ptr<weld::Widget> m_xShowTipOfTheDayImg; std::unique_ptr<weld::Widget> m_xFileDlgFrame; std::unique_ptr<weld::Widget> m_xFileDlgROImage; std::unique_ptr<weld::CheckButton> m_xFileDlgCB; - std::unique_ptr<weld::CheckButton> m_xPrintDlgCB; std::unique_ptr<weld::CheckButton> m_xDocStatusCB; + std::unique_ptr<weld::Widget> m_xDocStatusImg; std::unique_ptr<weld::Widget> m_xYearFrame; + std::unique_ptr<weld::Label> m_xYearLabel; std::unique_ptr<weld::SpinButton> m_xYearValueField; std::unique_ptr<weld::Label> m_xToYearFT; + std::unique_ptr<weld::Widget> m_xYearFrameImg; +#if HAVE_FEATURE_BREAKPAD + std::unique_ptr<weld::Widget> m_xPrivacyFrame; std::unique_ptr<weld::CheckButton> m_xCrashReport; + std::unique_ptr<weld::Widget> m_xCrashReportImg; +#endif +#if defined(_WIN32) std::unique_ptr<weld::Widget> m_xQuickStarterFrame; - std::unique_ptr<weld::Label> m_xHelpImproveLabel; std::unique_ptr<weld::CheckButton> m_xQuickLaunchCB; -#if defined(_WIN32) + std::unique_ptr<weld::Widget> m_xQuickLaunchImg; std::unique_ptr<weld::Widget> m_xFileAssocFrame; std::unique_ptr<weld::Button> m_xFileAssocBtn; std::unique_ptr<weld::CheckButton> m_xPerformFileExtCheck; + std::unique_ptr<weld::Widget> m_xPerformFileExtImg; #endif DECL_LINK(TwoFigureHdl, weld::SpinButton&, void); @@ -66,12 +77,12 @@ public: static std::unique_ptr<SfxTabPage> Create( weld::Container* pPage, weld::DialogController* pController, const SfxItemSet* rAttrSet ); + virtual OUString GetAllStrings() override; + virtual bool FillItemSet( SfxItemSet* rSet ) override; virtual void Reset( const SfxItemSet* rSet ) override; }; -class SvtTabAppearanceCfg; - class OfaViewTabPage : public SfxTabPage { private: @@ -80,47 +91,66 @@ private: sal_Int32 nNotebookbarSizeLB_InitialSelection; sal_Int32 nStyleLB_InitialSelection; - std::unique_ptr<SvtTabAppearanceCfg> pAppearanceCfg; std::unique_ptr<CanvasSettings> pCanvasSettings; std::vector<vcl::IconThemeInfo> mInstalledIconThemes; + std::unique_ptr<weld::Label> m_xIconSizeLabel; std::unique_ptr<weld::ComboBox> m_xIconSizeLB; + std::unique_ptr<weld::Widget> m_xIconSizeImg; + std::unique_ptr<weld::Label> m_xSidebarIconSizeLabel; std::unique_ptr<weld::ComboBox> m_xSidebarIconSizeLB; + std::unique_ptr<weld::Widget> m_xSidebarIconSizeImg; + std::unique_ptr<weld::Label> m_xNotebookbarIconSizeLabel; std::unique_ptr<weld::ComboBox> m_xNotebookbarIconSizeLB; + std::unique_ptr<weld::Widget> m_xNotebookbarIconSizeImg; + std::unique_ptr<weld::Widget> m_xDarkModeFrame; + std::unique_ptr<weld::Label> m_xAppearanceStyleLabel; + std::unique_ptr<weld::ComboBox> m_xAppearanceStyleLB; + std::unique_ptr<weld::Widget> m_xAppearanceStyleImg; + std::unique_ptr<weld::Label> m_xIconStyleLabel; std::unique_ptr<weld::ComboBox> m_xIconStyleLB; + std::unique_ptr<weld::Widget> m_xIconStyleImg; std::unique_ptr<weld::CheckButton> m_xFontAntiAliasing; + std::unique_ptr<weld::Widget> m_xFontAntiAliasingImg; std::unique_ptr<weld::Label> m_xAAPointLimitLabel; + std::unique_ptr<weld::Widget> m_xAAPointLimitLabelImg; std::unique_ptr<weld::MetricSpinButton> m_xAAPointLimit; - std::unique_ptr<weld::Widget> m_xMenuIconBox; - std::unique_ptr<weld::ComboBox> m_xMenuIconsLB; - - std::unique_ptr<weld::ComboBox> m_xContextMenuShortcutsLB; - std::unique_ptr<weld::CheckButton> m_xFontShowCB; + std::unique_ptr<weld::Widget> m_xFontShowImg; std::unique_ptr<weld::CheckButton> m_xUseHardwareAccell; + std::unique_ptr<weld::Widget> m_xUseHardwareAccellImg; std::unique_ptr<weld::CheckButton> m_xUseAntiAliase; + std::unique_ptr<weld::Widget> m_xUseAntiAliaseImg; std::unique_ptr<weld::CheckButton> m_xUseSkia; + std::unique_ptr<weld::Widget> m_xUseSkiaImg; std::unique_ptr<weld::CheckButton> m_xForceSkiaRaster; + std::unique_ptr<weld::Widget> m_xForceSkiaRasterImg; std::unique_ptr<weld::Label> m_xSkiaStatusEnabled; std::unique_ptr<weld::Label> m_xSkiaStatusDisabled; + std::unique_ptr<weld::Button> m_xSkiaLog; - std::unique_ptr<weld::ComboBox> m_xMousePosLB; + std::unique_ptr<weld::Label> m_xMouseMiddleLabel; std::unique_ptr<weld::ComboBox> m_xMouseMiddleLB; + std::unique_ptr<weld::Widget> m_xMouseMiddleImg; std::unique_ptr<weld::Button> m_xMoreIcons; std::unique_ptr<weld::Button> m_xRunGPTests; + OUString m_sAutoStr; + DECL_LINK(OnAntialiasingToggled, weld::Toggleable&, void); DECL_LINK(OnUseSkiaToggled, weld::Toggleable&, void); + DECL_LINK(OnCopySkiaLog, weld::Button&, void); DECL_STATIC_LINK(OfaViewTabPage, OnMoreIconsClick, weld::Button&, void); DECL_LINK(OnRunGPTestClick, weld::Button&, void); void UpdateSkiaStatus(); void HideSkiaWidgets(); void UpdateHardwareAccelStatus(); + void UpdateIconThemes(); public: OfaViewTabPage(weld::Container* pPage, weld::DialogController* pController, const SfxItemSet& rSet); @@ -128,6 +158,8 @@ public: static std::unique_ptr<SfxTabPage> Create( weld::Container* pPage, weld::DialogController* pController, const SfxItemSet* rAttrSet ); + virtual OUString GetAllStrings() override; + virtual bool FillItemSet( SfxItemSet* rSet ) override; virtual void Reset( const SfxItemSet* rSet ) override; }; @@ -149,31 +181,44 @@ class OfaLanguagesTabPage : public SfxTabPage std::unique_ptr<weld::ComboBox> m_xUserInterfaceLB; std::unique_ptr<weld::Label> m_xLocaleSettingFT; std::unique_ptr<SvxLanguageBox> m_xLocaleSettingLB; + std::unique_ptr<weld::Widget> m_xLocaleSettingImg; + std::unique_ptr<weld::Label> m_xDecimalSeparatorFT; std::unique_ptr<weld::CheckButton> m_xDecimalSeparatorCB; + std::unique_ptr<weld::Widget> m_xDecimalSeparatorImg; std::unique_ptr<weld::Label> m_xCurrencyFT; std::unique_ptr<weld::ComboBox> m_xCurrencyLB; + std::unique_ptr<weld::Widget> m_xCurrencyImg; std::unique_ptr<weld::Label> m_xDatePatternsFT; std::unique_ptr<weld::Entry> m_xDatePatternsED; + std::unique_ptr<weld::Widget> m_xDatePatternsImg; std::unique_ptr<SvxLanguageBox> m_xWesternLanguageLB; std::unique_ptr<weld::Label> m_xWesternLanguageFT; + std::unique_ptr<weld::Widget> m_xWesternLanguageImg; std::unique_ptr<SvxLanguageBox> m_xAsianLanguageLB; std::unique_ptr<SvxLanguageBox> m_xComplexLanguageLB; std::unique_ptr<weld::CheckButton> m_xCurrentDocCB; std::unique_ptr<weld::CheckButton> m_xAsianSupportCB; + std::unique_ptr<weld::Widget> m_xAsianSupportImg; std::unique_ptr<weld::CheckButton> m_xCTLSupportCB; + std::unique_ptr<weld::Widget> m_xCTLSupportImg; std::unique_ptr<weld::CheckButton> m_xIgnoreLanguageChangeCB; + std::unique_ptr<weld::Widget> m_xIgnoreLanguageChangeImg; DECL_LINK(SupportHdl, weld::Toggleable&, void); DECL_LINK(LocaleSettingHdl, weld::ComboBox&, void); DECL_LINK(DatePatternsHdl, weld::Entry&, void); + bool validateDatePatterns( bool& rbModified, OUString& rPatterns ); + public: OfaLanguagesTabPage(weld::Container* pPage, weld::DialogController* pController, const SfxItemSet& rSet); virtual ~OfaLanguagesTabPage() override; static std::unique_ptr<SfxTabPage> Create( weld::Container* pPage, weld::DialogController* pController, const SfxItemSet* rAttrSet ); + virtual OUString GetAllStrings() override; + virtual bool FillItemSet( SfxItemSet* rSet ) override; virtual void Reset( const SfxItemSet* rSet ) override; }; diff --git a/cui/source/options/optgenrl.cxx b/cui/source/options/optgenrl.cxx index 9c657176527f..d2cf40244d85 100644 --- a/cui/source/options/optgenrl.cxx +++ b/cui/source/options/optgenrl.cxx @@ -30,7 +30,6 @@ #include <i18nlangtag/mslangid.hxx> #include <o3tl/safeint.hxx> #include <vcl/svapp.hxx> -#include <unotools/saveopt.hxx> #include <svl/intitem.hxx> #include <vcl/settings.hxx> @@ -80,26 +79,28 @@ namespace Lang struct { + // id of the lockimage + OUString pLockId; // id of the text - const char *pTextId; + OUString pTextId; // language flags (see Lang above): // which language is this row for? unsigned nLangFlags; } const vRowInfo[] = { - { "companyft", Lang::All }, - { "nameft", Lang::All & ~Lang::Russian & ~Lang::Eastern }, - { "rusnameft", Lang::Russian }, - { "eastnameft", Lang::Eastern }, - { "streetft", Lang::All & ~Lang::Russian }, - { "russtreetft", Lang::Russian }, - { "icityft", Lang::All & ~Lang::US }, - { "cityft", Lang::US }, - { "countryft", Lang::All }, - { "titleft", Lang::All }, - { "phoneft", Lang::All }, - { "faxft", Lang::All }, + { "lockcompanyft", "companyft", Lang::All }, + { "locknameft", "nameft", Lang::All & ~Lang::Russian & ~Lang::Eastern }, + { "lockrusnameft", "rusnameft", Lang::Russian }, + { "lockeastnameft", "eastnameft", Lang::Eastern }, + { "lockstreetft", "streetft", Lang::All & ~Lang::Russian }, + { "lockrusstreetft","russtreetft", Lang::Russian }, + { "lockicityft", "icityft", Lang::All & ~Lang::US }, + { "lockcityft", "cityft", Lang::US }, + { "lockcountryft", "countryft", Lang::All }, + { "locktitleft", "titleft", Lang::All }, + { "lockphoneft", "phoneft", Lang::All }, + { "lockfaxft", "faxft", Lang::All }, }; @@ -111,7 +112,7 @@ struct // in which row? RowType eRow; // id of the edit box - const char *pEditId; + OUString pEditId; // id for SvtUserOptions in unotools/useroptions.hxx UserOptToken nUserOptionsId; // id for settings the focus (defined in svx/optgenrl.hxx) @@ -167,14 +168,17 @@ const vFieldInfo[] = struct SvxGeneralTabPage::Row { + // row lockdown icon + std::unique_ptr<weld::Widget> xLockImg; // row label std::unique_ptr<weld::Label> xLabel; // first and last field in the row (last is exclusive) unsigned nFirstField, nLastField; public: - explicit Row (std::unique_ptr<weld::Label> xLabel_) - : xLabel(std::move(xLabel_)) + explicit Row (std::unique_ptr<weld::Widget> xLockImg_, std::unique_ptr<weld::Label> xLabel_) + : xLockImg(std::move(xLockImg_)) + , xLabel(std::move(xLabel_)) , nFirstField(0) , nLastField(0) { @@ -211,10 +215,16 @@ public: SvxGeneralTabPage::SvxGeneralTabPage(weld::Container* pPage, weld::DialogController* pController, const SfxItemSet& rCoreSet) : SfxTabPage(pPage, pController, "cui/ui/optuserpage.ui", "OptUserPage", &rCoreSet) , m_xUseDataCB(m_xBuilder->weld_check_button("usefordocprop")) + , m_xUseDataImg(m_xBuilder->weld_widget("lockusefordocprop")) , m_xCryptoFrame(m_xBuilder->weld_widget( "cryptography")) , m_xSigningKeyLB(m_xBuilder->weld_combo_box("signingkey")) + , m_xSigningKeyFT(m_xBuilder->weld_label("signingkeylabel")) + , m_xSigningKeyImg(m_xBuilder->weld_widget("locksigningkey")) , m_xEncryptionKeyLB(m_xBuilder->weld_combo_box("encryptionkey")) + , m_xEncryptionKeyFT(m_xBuilder->weld_label("encryptionkeylabel")) + , m_xEncryptionKeyImg(m_xBuilder->weld_widget("lockencryptionkey")) , m_xEncryptToSelfCB(m_xBuilder->weld_check_button("encrypttoself")) + , m_xEncryptToSelfImg(m_xBuilder->weld_widget("lockencrypttoself")) { InitControls(); #if HAVE_FEATURE_GPGME @@ -259,11 +269,11 @@ void SvxGeneralTabPage::InitControls () if (!(vRowInfo[iRow].nLangFlags & LangBit)) continue; // creating row - vRows.push_back(std::make_shared<Row>( + vRows.push_back(std::make_shared<Row>(m_xBuilder->weld_widget(vRowInfo[iRow].pLockId), m_xBuilder->weld_label(vRowInfo[iRow].pTextId))); Row& rRow = *vRows.back(); // fields in the row - static unsigned const nFieldCount = SAL_N_ELEMENTS(vFieldInfo); + static unsigned const nFieldCount = std::size(vFieldInfo); // skipping other (invisible) rows while (iField != nFieldCount && vFieldInfo[iField].eRow != eRow) ++iField; @@ -342,6 +352,26 @@ std::unique_ptr<SfxTabPage> SvxGeneralTabPage::Create( weld::Container* pPage, w return std::make_unique<SvxGeneralTabPage>( pPage, pController, *rAttrSet ); } +OUString SvxGeneralTabPage::GetAllStrings() +{ + OUString sAllStrings; + OUString labels[] + = { "label1", "companyft", "nameft", "rusnameft", + "eastnameft", "streetft", "russtreetft", "icityft", + "cityft", "countryft", "titleft", "phoneft", + "faxft", "cryptographylabel", "signingkeylabel", "encryptionkeylabel" }; + + for (const auto& label : labels) + { + if (const auto& pString = m_xBuilder->weld_label(label)) + sAllStrings += pString->get_label() + " "; + } + + sAllStrings += m_xUseDataCB->get_label() + " " + m_xEncryptToSelfCB->get_label() + " "; + + return sAllStrings.replaceAll("_", ""); +} + bool SvxGeneralTabPage::FillItemSet( SfxItemSet* ) { // remove leading and trailing whitespaces @@ -364,11 +394,9 @@ void SvxGeneralTabPage::Reset( const SfxItemSet* rSet ) { SetData_Impl(); - sal_uInt16 const nWhich = GetWhich(SID_FIELD_GRABFOCUS); - - if (rSet->GetItemState(nWhich) == SfxItemState::SET) + if (rSet->GetItemState(SID_FIELD_GRABFOCUS) == SfxItemState::SET) { - EditPosition nField = static_cast<EditPosition>(static_cast<const SfxUInt16Item&>(rSet->Get(nWhich)).GetValue()); + EditPosition nField = static_cast<EditPosition>(rSet->Get(SID_FIELD_GRABFOCUS).GetValue()); if (nField != EditPosition::UNKNOWN) { for (auto const & i: vFields) @@ -480,13 +508,33 @@ void SvxGeneralTabPage::SetData_Impl() bEnableLabel = bEnableLabel || bEnableEdit; } rRow.xLabel->set_sensitive(bEnableLabel); + rRow.xLockImg->set_visible(!bEnableLabel); } // saving for (auto const & i: vFields) i->xEdit->save_value(); + //enabling and disabling remaining fields + bool bEnable = !officecfg::Office::Common::Save::Document::UseUserData::isReadOnly(); + m_xUseDataCB->set_sensitive(bEnable); + m_xUseDataImg->set_visible(!bEnable); + #if HAVE_FEATURE_GPGME + bEnable = !aUserOpt.IsTokenReadonly(UserOptToken::SigningKey); + m_xSigningKeyLB->set_sensitive(bEnable); + m_xSigningKeyFT->set_sensitive(bEnable); + m_xSigningKeyImg->set_visible(!bEnable); + + bEnable = !aUserOpt.IsTokenReadonly(UserOptToken::EncryptionKey); + m_xEncryptionKeyLB->set_sensitive(bEnable); + m_xEncryptionKeyFT->set_sensitive(bEnable); + m_xEncryptionKeyImg->set_visible(!bEnable); + + bEnable = !aUserOpt.IsTokenReadonly(UserOptToken::EncryptToSelf); + m_xEncryptToSelfCB->set_sensitive(bEnable); + m_xEncryptToSelfImg->set_visible(!bEnable); + OUString aSK = aUserOpt.GetToken(UserOptToken::SigningKey); aSK.isEmpty() ? m_xSigningKeyLB->set_active( 0 ) //i.e. 'No Key' : m_xSigningKeyLB->set_active_text( aSK ); diff --git a/cui/source/options/opthtml.cxx b/cui/source/options/opthtml.cxx index 5fb93652b9a9..6880ec4b2e33 100644 --- a/cui/source/options/opthtml.cxx +++ b/cui/source/options/opthtml.cxx @@ -18,7 +18,6 @@ */ #include <svtools/langtab.hxx> -#include <svtools/htmlcfg.hxx> #include <comphelper/configuration.hxx> #include <officecfg/Office/Common.hxx> #include "opthtml.hxx" @@ -27,20 +26,33 @@ OfaHtmlTabPage::OfaHtmlTabPage(weld::Container* pPage, weld::DialogController* pController, const SfxItemSet& rSet) : SfxTabPage(pPage, pController, "cui/ui/opthtmlpage.ui", "OptHtmlPage", &rSet) , m_xSize1NF(m_xBuilder->weld_spin_button("size1")) + , m_xSize1Img(m_xBuilder->weld_widget("locksize1")) , m_xSize2NF(m_xBuilder->weld_spin_button("size2")) + , m_xSize2Img(m_xBuilder->weld_widget("locksize2")) , m_xSize3NF(m_xBuilder->weld_spin_button("size3")) + , m_xSize3Img(m_xBuilder->weld_widget("locksize3")) , m_xSize4NF(m_xBuilder->weld_spin_button("size4")) + , m_xSize4Img(m_xBuilder->weld_widget("locksize4")) , m_xSize5NF(m_xBuilder->weld_spin_button("size5")) + , m_xSize5Img(m_xBuilder->weld_widget("locksize5")) , m_xSize6NF(m_xBuilder->weld_spin_button("size6")) + , m_xSize6Img(m_xBuilder->weld_widget("locksize6")) , m_xSize7NF(m_xBuilder->weld_spin_button("size7")) + , m_xSize7Img(m_xBuilder->weld_widget("locksize7")) , m_xNumbersEnglishUSCB(m_xBuilder->weld_check_button("numbersenglishus")) + , m_xNumbersEnglishUSImg(m_xBuilder->weld_widget("locknumbersenglishus")) , m_xUnknownTagCB(m_xBuilder->weld_check_button("unknowntag")) + , m_xUnknownTagImg(m_xBuilder->weld_widget("lockunknowntag")) , m_xIgnoreFontNamesCB(m_xBuilder->weld_check_button("ignorefontnames")) + , m_xIgnoreFontNamesImg(m_xBuilder->weld_widget("lockignorefontnames")) , m_xStarBasicCB(m_xBuilder->weld_check_button("starbasic")) + , m_xStarBasicImg(m_xBuilder->weld_widget("lockstarbasic")) , m_xStarBasicWarningCB(m_xBuilder->weld_check_button("starbasicwarning")) + , m_xStarBasicWarningImg(m_xBuilder->weld_widget("lockstarbasicwarning")) , m_xPrintExtensionCB(m_xBuilder->weld_check_button("printextension")) + , m_xPrintExtensionImg(m_xBuilder->weld_widget("lockprintextension")) , m_xSaveGrfLocalCB(m_xBuilder->weld_check_button("savegrflocal")) - , m_xCharSetLB(new SvxTextEncodingBox(m_xBuilder->weld_combo_box("charset"))) + , m_xSaveGrfLocalImg(m_xBuilder->weld_widget("locksavegrflocal")) { // replace placeholder with UI string from language list OUString aText(m_xNumbersEnglishUSCB->get_label()); @@ -57,9 +69,6 @@ OfaHtmlTabPage::OfaHtmlTabPage(weld::Container* pPage, weld::DialogController* p } m_xStarBasicCB->connect_toggled(LINK(this, OfaHtmlTabPage, CheckBoxHdl_Impl)); - - // initialize the characterset listbox - m_xCharSetLB->FillWithMimeAndSelectBest(); } OfaHtmlTabPage::~OfaHtmlTabPage() @@ -72,6 +81,30 @@ std::unique_ptr<SfxTabPage> OfaHtmlTabPage::Create( weld::Container* pPage, weld return std::make_unique<OfaHtmlTabPage>(pPage, pController, *rAttrSet); } +OUString OfaHtmlTabPage::GetAllStrings() +{ + OUString sAllStrings; + OUString labels[] = { "label1", "label2", "label3", "size1FT", "size2FT", + "size3FT", "size4FT", "size5FT", "size6FT", "size7FT" }; + + for (const auto& label : labels) + { + if (const auto& pString = m_xBuilder->weld_label(label)) + sAllStrings += pString->get_label() + " "; + } + + OUString checkButton[] = { "numbersenglishus", "unknowntag", "ignorefontnames", "starbasic", + "starbasicwarning", "printextension", "savegrflocal" }; + + for (const auto& check : checkButton) + { + if (const auto& pString = m_xBuilder->weld_check_button(check)) + sAllStrings += pString->get_label() + " "; + } + + return sAllStrings.replaceAll("_", ""); +} + bool OfaHtmlTabPage::FillItemSet( SfxItemSet* ) { std::shared_ptr<comphelper::ConfigurationChanges> xChanges = comphelper::ConfigurationChanges::create(); @@ -125,10 +158,6 @@ bool OfaHtmlTabPage::FillItemSet( SfxItemSet* ) officecfg::Office::Common::Filter::HTML::Export::PrintLayout::set( m_xPrintExtensionCB->get_active(), xChanges); - if( m_xCharSetLB->GetSelectTextEncoding() != SvxHtmlOptions::GetTextEncoding() ) - officecfg::Office::Common::Filter::HTML::Export::Encoding::set( - m_xCharSetLB->GetSelectTextEncoding(), xChanges ); - xChanges->commit(); return false; } @@ -136,21 +165,99 @@ bool OfaHtmlTabPage::FillItemSet( SfxItemSet* ) void OfaHtmlTabPage::Reset( const SfxItemSet* ) { m_xSize1NF->set_value(officecfg::Office::Common::Filter::HTML::Import::FontSize::Size_1::get()); + if (officecfg::Office::Common::Filter::HTML::Import::FontSize::Size_1::isReadOnly()) + { + m_xSize1NF->set_sensitive(false); + m_xSize1Img->set_visible(true); + } + m_xSize2NF->set_value(officecfg::Office::Common::Filter::HTML::Import::FontSize::Size_2::get()); + if (officecfg::Office::Common::Filter::HTML::Import::FontSize::Size_2::isReadOnly()) + { + m_xSize2NF->set_sensitive(false); + m_xSize2Img->set_visible(true); + } + m_xSize3NF->set_value(officecfg::Office::Common::Filter::HTML::Import::FontSize::Size_3::get()); + if (officecfg::Office::Common::Filter::HTML::Import::FontSize::Size_3::isReadOnly()) + { + m_xSize3NF->set_sensitive(false); + m_xSize3Img->set_visible(true); + } + m_xSize4NF->set_value(officecfg::Office::Common::Filter::HTML::Import::FontSize::Size_4::get()); + if (officecfg::Office::Common::Filter::HTML::Import::FontSize::Size_4::isReadOnly()) + { + m_xSize4NF->set_sensitive(false); + m_xSize4Img->set_visible(true); + } + m_xSize5NF->set_value(officecfg::Office::Common::Filter::HTML::Import::FontSize::Size_5::get()); + if (officecfg::Office::Common::Filter::HTML::Import::FontSize::Size_5::isReadOnly()) + { + m_xSize5NF->set_sensitive(false); + m_xSize5Img->set_visible(true); + } + m_xSize6NF->set_value(officecfg::Office::Common::Filter::HTML::Import::FontSize::Size_6::get()); + if (officecfg::Office::Common::Filter::HTML::Import::FontSize::Size_6::isReadOnly()) + { + m_xSize6NF->set_sensitive(false); + m_xSize6Img->set_visible(true); + } + m_xSize7NF->set_value(officecfg::Office::Common::Filter::HTML::Import::FontSize::Size_7::get()); + if (officecfg::Office::Common::Filter::HTML::Import::FontSize::Size_7::isReadOnly()) + { + m_xSize7NF->set_sensitive(false); + m_xSize7Img->set_visible(true); + } + m_xNumbersEnglishUSCB->set_active(officecfg::Office::Common::Filter::HTML::Import::NumbersEnglishUS::get()); + if (officecfg::Office::Common::Filter::HTML::Import::NumbersEnglishUS::isReadOnly()) + { + m_xNumbersEnglishUSCB->set_sensitive(false); + m_xNumbersEnglishUSImg->set_visible(true); + } + m_xUnknownTagCB->set_active(officecfg::Office::Common::Filter::HTML::Import::UnknownTag::get()); + if (officecfg::Office::Common::Filter::HTML::Import::UnknownTag::isReadOnly()) + { + m_xUnknownTagCB->set_sensitive(false); + m_xUnknownTagImg->set_visible(true); + } + m_xIgnoreFontNamesCB->set_active(officecfg::Office::Common::Filter::HTML::Import::FontSetting::get()); + if (officecfg::Office::Common::Filter::HTML::Import::FontSetting::isReadOnly()) + { + m_xIgnoreFontNamesCB->set_sensitive(false); + m_xIgnoreFontNamesImg->set_visible(true); + } m_xStarBasicCB->set_active(officecfg::Office::Common::Filter::HTML::Export::Basic::get()); + if (officecfg::Office::Common::Filter::HTML::Export::Basic::isReadOnly()) + { + m_xStarBasicCB->set_sensitive(false); + m_xStarBasicImg->set_visible(true); + } + m_xStarBasicWarningCB->set_active(officecfg::Office::Common::Filter::HTML::Export::Warning::get()); - m_xStarBasicWarningCB->set_sensitive(!m_xStarBasicCB->get_active()); + m_xStarBasicWarningCB->set_sensitive(!m_xStarBasicCB->get_active() && !officecfg::Office::Common::Filter::HTML::Export::Warning::isReadOnly()); + m_xStarBasicWarningImg->set_visible(officecfg::Office::Common::Filter::HTML::Export::Warning::isReadOnly()); + m_xSaveGrfLocalCB->set_active(officecfg::Office::Common::Filter::HTML::Export::LocalGraphic::get()); - m_xPrintExtensionCB->set_active(SvxHtmlOptions::IsPrintLayoutExtension()); + if (officecfg::Office::Common::Filter::HTML::Export::LocalGraphic::isReadOnly()) + { + m_xSaveGrfLocalCB->set_sensitive(false); + m_xSaveGrfLocalImg->set_visible(true); + } + + m_xPrintExtensionCB->set_active(officecfg::Office::Common::Filter::HTML::Export::PrintLayout::get()); + if (officecfg::Office::Common::Filter::HTML::Export::PrintLayout::isReadOnly()) + { + m_xPrintExtensionCB->set_sensitive(false); + m_xPrintExtensionImg->set_visible(true); + } m_xPrintExtensionCB->save_state(); m_xStarBasicCB->save_state(); @@ -166,10 +273,6 @@ void OfaHtmlTabPage::Reset( const SfxItemSet* ) m_xNumbersEnglishUSCB->save_state(); m_xUnknownTagCB->save_state(); m_xIgnoreFontNamesCB->save_state(); - - if( !SvxHtmlOptions::IsDefaultTextEncoding() && - m_xCharSetLB->GetSelectTextEncoding() != SvxHtmlOptions::GetTextEncoding() ) - m_xCharSetLB->SelectTextEncoding( SvxHtmlOptions::GetTextEncoding() ); } IMPL_LINK(OfaHtmlTabPage, CheckBoxHdl_Impl, weld::Toggleable&, rBox, void) diff --git a/cui/source/options/opthtml.hxx b/cui/source/options/opthtml.hxx index 4fdb9d754451..2f389a7af571 100644 --- a/cui/source/options/opthtml.hxx +++ b/cui/source/options/opthtml.hxx @@ -25,22 +25,35 @@ class OfaHtmlTabPage : public SfxTabPage { std::unique_ptr<weld::SpinButton> m_xSize1NF; + std::unique_ptr<weld::Widget> m_xSize1Img; std::unique_ptr<weld::SpinButton> m_xSize2NF; + std::unique_ptr<weld::Widget> m_xSize2Img; std::unique_ptr<weld::SpinButton> m_xSize3NF; + std::unique_ptr<weld::Widget> m_xSize3Img; std::unique_ptr<weld::SpinButton> m_xSize4NF; + std::unique_ptr<weld::Widget> m_xSize4Img; std::unique_ptr<weld::SpinButton> m_xSize5NF; + std::unique_ptr<weld::Widget> m_xSize5Img; std::unique_ptr<weld::SpinButton> m_xSize6NF; + std::unique_ptr<weld::Widget> m_xSize6Img; std::unique_ptr<weld::SpinButton> m_xSize7NF; + std::unique_ptr<weld::Widget> m_xSize7Img; std::unique_ptr<weld::CheckButton> m_xNumbersEnglishUSCB; + std::unique_ptr<weld::Widget> m_xNumbersEnglishUSImg; std::unique_ptr<weld::CheckButton> m_xUnknownTagCB; + std::unique_ptr<weld::Widget> m_xUnknownTagImg; std::unique_ptr<weld::CheckButton> m_xIgnoreFontNamesCB; + std::unique_ptr<weld::Widget> m_xIgnoreFontNamesImg; std::unique_ptr<weld::CheckButton> m_xStarBasicCB; + std::unique_ptr<weld::Widget> m_xStarBasicImg; std::unique_ptr<weld::CheckButton> m_xStarBasicWarningCB; + std::unique_ptr<weld::Widget> m_xStarBasicWarningImg; std::unique_ptr<weld::CheckButton> m_xPrintExtensionCB; + std::unique_ptr<weld::Widget> m_xPrintExtensionImg; std::unique_ptr<weld::CheckButton> m_xSaveGrfLocalCB; - std::unique_ptr<SvxTextEncodingBox> m_xCharSetLB; + std::unique_ptr<weld::Widget> m_xSaveGrfLocalImg; DECL_LINK(CheckBoxHdl_Impl, weld::Toggleable&, void); @@ -50,6 +63,8 @@ public: static std::unique_ptr<SfxTabPage> Create( weld::Container* pPage, weld::DialogController* pController, const SfxItemSet* rAttrSet ); + virtual OUString GetAllStrings() override; + virtual bool FillItemSet( SfxItemSet* rSet ) override; virtual void Reset( const SfxItemSet* rSet ) override; diff --git a/cui/source/options/optinet2.cxx b/cui/source/options/optinet2.cxx index be01007e026c..eaf0e8616bfd 100644 --- a/cui/source/options/optinet2.cxx +++ b/cui/source/options/optinet2.cxx @@ -27,9 +27,8 @@ #include <vcl/weld.hxx> #include <sfx2/filedlghelper.hxx> #include <vcl/svapp.hxx> -#include <unotools/securityoptions.hxx> #include <com/sun/star/uno/Sequence.hxx> -#include <tools/diagnose_ex.h> +#include <comphelper/diagnose_ex.hxx> #include <dialmgr.hxx> #include "optinet2.hxx" @@ -52,7 +51,7 @@ #include <com/sun/star/ui/dialogs/TemplateDescription.hpp> #include <com/sun/star/task/PasswordContainer.hpp> #include <com/sun/star/task/XPasswordContainer2.hpp> -#include "securityoptions.hxx" +#include <securityoptions.hxx> #include "webconninfo.hxx" #include "certpath.hxx" #include "tsaurls.hxx" @@ -88,19 +87,17 @@ IMPL_LINK(SvxProxyTabPage, PortChangedHdl, weld::Entry&, rEdit, void) { std::unique_ptr<weld::MessageDialog> xErrorBox(Application::CreateMessageDialog(GetFrameWeld(), VclMessageType::Warning, VclButtonsType::Ok, - CuiResId( RID_SVXSTR_OPT_PROXYPORTS))); + CuiResId(RID_CUISTR_OPT_PROXYPORTS))); xErrorBox->run(); } } -constexpr OUStringLiteral g_aProxyModePN = u"ooInetProxyType"; -constexpr OUStringLiteral g_aHttpProxyPN = u"ooInetHTTPProxyName"; -constexpr OUStringLiteral g_aHttpPortPN = u"ooInetHTTPProxyPort"; -constexpr OUStringLiteral g_aHttpsProxyPN = u"ooInetHTTPSProxyName"; -constexpr OUStringLiteral g_aHttpsPortPN = u"ooInetHTTPSProxyPort"; -constexpr OUStringLiteral g_aFtpProxyPN = u"ooInetFTPProxyName"; -constexpr OUStringLiteral g_aFtpPortPN = u"ooInetFTPProxyPort"; -constexpr OUStringLiteral g_aNoProxyDescPN = u"ooInetNoProxy"; +constexpr OUString g_aProxyModePN = u"ooInetProxyType"_ustr; +constexpr OUString g_aHttpProxyPN = u"ooInetHTTPProxyName"_ustr; +constexpr OUString g_aHttpPortPN = u"ooInetHTTPProxyPort"_ustr; +constexpr OUString g_aHttpsProxyPN = u"ooInetHTTPSProxyName"_ustr; +constexpr OUString g_aHttpsPortPN = u"ooInetHTTPSProxyPort"_ustr; +constexpr OUString g_aNoProxyDescPN = u"ooInetNoProxy"_ustr; IMPL_STATIC_LINK(SvxProxyTabPage, NumberOnlyTextFilterHdl, OUString&, rTest, bool) { @@ -127,21 +124,24 @@ IMPL_STATIC_LINK(SvxProxyTabPage, NoSpaceTextFilterHdl, OUString&, rTest, bool) /********************************************************************/ SvxProxyTabPage::SvxProxyTabPage(weld::Container* pPage, weld::DialogController* pController, const SfxItemSet& rSet) : SfxTabPage(pPage, pController, "cui/ui/optproxypage.ui", "OptProxyPage", &rSet) + , m_xProxyModeFT(m_xBuilder->weld_label("label2")) , m_xProxyModeLB(m_xBuilder->weld_combo_box("proxymode")) + , m_xProxyModeImg(m_xBuilder->weld_widget("lockproxymode")) , m_xHttpProxyFT(m_xBuilder->weld_label("httpft")) , m_xHttpProxyED(m_xBuilder->weld_entry("http")) + , m_xHttpProxyImg(m_xBuilder->weld_widget("lockhttp")) , m_xHttpPortFT(m_xBuilder->weld_label("httpportft")) , m_xHttpPortED(m_xBuilder->weld_entry("httpport")) + , m_xHttpPortImg(m_xBuilder->weld_widget("lockhttpport")) , m_xHttpsProxyFT(m_xBuilder->weld_label("httpsft")) , m_xHttpsProxyED(m_xBuilder->weld_entry("https")) + , m_xHttpsProxyImg(m_xBuilder->weld_widget("lockhttps")) , m_xHttpsPortFT(m_xBuilder->weld_label("httpsportft")) , m_xHttpsPortED(m_xBuilder->weld_entry("httpsport")) - , m_xFtpProxyFT(m_xBuilder->weld_label("ftpft")) - , m_xFtpProxyED(m_xBuilder->weld_entry("ftp")) - , m_xFtpPortFT(m_xBuilder->weld_label("ftpportft")) - , m_xFtpPortED(m_xBuilder->weld_entry("ftpport")) + , m_xHttpsPortImg(m_xBuilder->weld_widget("lockhttpsport")) , m_xNoProxyForFT(m_xBuilder->weld_label("noproxyft")) , m_xNoProxyForED(m_xBuilder->weld_entry("noproxy")) + , m_xNoProxyForImg(m_xBuilder->weld_widget("locknoproxy")) , m_xNoProxyDescFT(m_xBuilder->weld_label("noproxydesc")) { m_xHttpProxyED->connect_insert_text(LINK(this, SvxProxyTabPage, NoSpaceTextFilterHdl)); @@ -150,14 +150,10 @@ SvxProxyTabPage::SvxProxyTabPage(weld::Container* pPage, weld::DialogController* m_xHttpsProxyED->connect_insert_text(LINK(this, SvxProxyTabPage, NoSpaceTextFilterHdl)); m_xHttpsPortED->connect_insert_text(LINK(this, SvxProxyTabPage, NumberOnlyTextFilterHdl)); m_xHttpsPortED->connect_changed(LINK(this, SvxProxyTabPage, PortChangedHdl)); - m_xFtpProxyED->connect_insert_text(LINK(this, SvxProxyTabPage, NoSpaceTextFilterHdl)); - m_xFtpPortED->connect_insert_text(LINK(this, SvxProxyTabPage, NumberOnlyTextFilterHdl)); - m_xFtpPortED->connect_changed(LINK(this, SvxProxyTabPage, PortChangedHdl)); Link<weld::Widget&,void> aLink = LINK( this, SvxProxyTabPage, LoseFocusHdl_Impl ); m_xHttpPortED->connect_focus_out( aLink ); m_xHttpsPortED->connect_focus_out( aLink ); - m_xFtpPortED->connect_focus_out( aLink ); m_xProxyModeLB->connect_changed(LINK( this, SvxProxyTabPage, ProxyHdl_Impl )); @@ -204,6 +200,8 @@ void SvxProxyTabPage::ReadConfigData_Impl() nIntValue = *x; m_xHttpPortED->set_text( OUString::number( nIntValue )); } + else + m_xHttpPortED->set_text( "" ); m_xHttpsProxyED->set_text( officecfg::Inet::Settings::ooInetHTTPSProxyName::get() ); x = officecfg::Inet::Settings::ooInetHTTPSProxyPort::get(); @@ -212,14 +210,8 @@ void SvxProxyTabPage::ReadConfigData_Impl() nIntValue = *x; m_xHttpsPortED->set_text( OUString::number( nIntValue )); } - - m_xFtpProxyED->set_text( officecfg::Inet::Settings::ooInetFTPProxyName::get() ); - x = officecfg::Inet::Settings::ooInetFTPProxyPort::get(); - if (x) - { - nIntValue = *x; - m_xFtpPortED->set_text( OUString::number( nIntValue )); - } + else + m_xHttpsPortED->set_text( "" ); m_xNoProxyForED->set_text( officecfg::Inet::Settings::ooInetNoProxy::get() ); } @@ -253,16 +245,6 @@ void SvxProxyTabPage::ReadConfigDefaults_Impl() m_xHttpsPortED->set_text( OUString::number( nIntValue )); } - if( xPropertyState->getPropertyDefault(g_aFtpProxyPN) >>= aStringValue ) - { - m_xFtpProxyED->set_text( aStringValue ); - } - - if( xPropertyState->getPropertyDefault(g_aFtpPortPN) >>= nIntValue ) - { - m_xFtpPortED->set_text( OUString::number( nIntValue )); - } - if( xPropertyState->getPropertyDefault(g_aNoProxyDescPN) >>= aStringValue ) { m_xNoProxyForED->set_text( aStringValue ); @@ -293,8 +275,6 @@ void SvxProxyTabPage::RestoreConfigDefaults_Impl() xPropertyState->setPropertyToDefault(g_aHttpPortPN); xPropertyState->setPropertyToDefault(g_aHttpsProxyPN); xPropertyState->setPropertyToDefault(g_aHttpsPortPN); - xPropertyState->setPropertyToDefault(g_aFtpProxyPN); - xPropertyState->setPropertyToDefault(g_aFtpPortPN); xPropertyState->setPropertyToDefault(g_aNoProxyDescPN); Reference< util::XChangesBatch > xChangesBatch(m_xConfigurationUpdateAccess, UNO_QUERY_THROW); @@ -323,13 +303,26 @@ void SvxProxyTabPage::Reset(const SfxItemSet*) m_xHttpPortED->save_value(); m_xHttpsProxyED->save_value(); m_xHttpsPortED->save_value(); - m_xFtpProxyED->save_value(); - m_xFtpPortED->save_value(); m_xNoProxyForED->save_value(); EnableControls_Impl(); } +OUString SvxProxyTabPage::GetAllStrings() +{ + OUString sAllStrings; + OUString labels[] = { "label1", "label2", "httpft", "httpsft", + "noproxyft", "httpportft", "httpsportft", "noproxydesc" }; + + for (const auto& label : labels) + { + if (const auto& pString = m_xBuilder->weld_label(label)) + sAllStrings += pString->get_label() + " "; + } + + return sAllStrings.replaceAll("_", ""); +} + bool SvxProxyTabPage::FillItemSet(SfxItemSet* ) { bool bModified = false; @@ -374,18 +367,6 @@ bool SvxProxyTabPage::FillItemSet(SfxItemSet* ) bModified = true; } - if( m_xFtpProxyED->get_value_changed_from_saved()) - { - xPropertySet->setPropertyValue( g_aFtpProxyPN, Any(m_xFtpProxyED->get_text()) ); - bModified = true; - } - - if ( m_xFtpPortED->get_value_changed_from_saved() ) - { - xPropertySet->setPropertyValue( g_aFtpPortPN, Any(m_xFtpPortED->get_text().toInt32())); - bModified = true; - } - if ( m_xNoProxyForED->get_value_changed_from_saved() ) { xPropertySet->setPropertyValue( g_aNoProxyDescPN, Any( m_xNoProxyForED->get_text())); @@ -416,34 +397,38 @@ bool SvxProxyTabPage::FillItemSet(SfxItemSet* ) void SvxProxyTabPage::EnableControls_Impl() { - m_xProxyModeLB->set_sensitive(!officecfg::Inet::Settings::ooInetNoProxy::isReadOnly()); + bool bEnable = !officecfg::Inet::Settings::ooInetNoProxy::isReadOnly(); + m_xProxyModeFT->set_sensitive(bEnable); + m_xProxyModeLB->set_sensitive(bEnable); + m_xProxyModeImg->set_visible(!bEnable); const bool bManualConfig = m_xProxyModeLB->get_active() == 2; - const bool bHTTPProxyNameEnabled = bManualConfig && !officecfg::Inet::Settings::ooInetHTTPProxyName::isReadOnly(); - const bool bHTTPProxyPortEnabled = bManualConfig && !officecfg::Inet::Settings::ooInetHTTPProxyPort::isReadOnly(); + bEnable = !officecfg::Inet::Settings::ooInetHTTPProxyName::isReadOnly(); + const bool bHTTPProxyNameEnabled = bManualConfig && bEnable; + const bool bHTTPProxyPortEnabled = bManualConfig && bEnable; m_xHttpProxyFT->set_sensitive(bHTTPProxyNameEnabled); m_xHttpProxyED->set_sensitive(bHTTPProxyNameEnabled); + m_xHttpProxyImg->set_visible(!bEnable); m_xHttpPortFT->set_sensitive(bHTTPProxyPortEnabled); m_xHttpPortED->set_sensitive(bHTTPProxyPortEnabled); + m_xHttpPortImg->set_visible(!bEnable); - const bool bHTTPSProxyNameEnabled = bManualConfig && !officecfg::Inet::Settings::ooInetHTTPSProxyName::isReadOnly(); - const bool bHTTPSProxyPortEnabled = bManualConfig && !officecfg::Inet::Settings::ooInetHTTPSProxyPort::isReadOnly(); + bEnable = !officecfg::Inet::Settings::ooInetHTTPSProxyName::isReadOnly(); + const bool bHTTPSProxyNameEnabled = bManualConfig && bEnable; + const bool bHTTPSProxyPortEnabled = bManualConfig && bEnable; m_xHttpsProxyFT->set_sensitive(bHTTPSProxyNameEnabled); m_xHttpsProxyED->set_sensitive(bHTTPSProxyNameEnabled); + m_xHttpsProxyImg->set_visible(!bEnable); m_xHttpsPortFT->set_sensitive(bHTTPSProxyPortEnabled); m_xHttpsPortED->set_sensitive(bHTTPSProxyPortEnabled); + m_xHttpsPortImg->set_visible(!bEnable); - const bool bFTPProxyNameEnabled = bManualConfig && !officecfg::Inet::Settings::ooInetFTPProxyName::isReadOnly(); - const bool bFTPProxyPortEnabled = bManualConfig && !officecfg::Inet::Settings::ooInetFTPProxyPort::isReadOnly(); - m_xFtpProxyFT->set_sensitive(bFTPProxyNameEnabled); - m_xFtpProxyED->set_sensitive(bFTPProxyNameEnabled); - m_xFtpPortFT->set_sensitive(bFTPProxyPortEnabled); - m_xFtpPortED->set_sensitive(bFTPProxyPortEnabled); - - const bool bInetNoProxyEnabled = bManualConfig && !officecfg::Inet::Settings::ooInetNoProxy::isReadOnly(); + bEnable = !officecfg::Inet::Settings::ooInetNoProxy::isReadOnly(); + const bool bInetNoProxyEnabled = bManualConfig && bEnable; m_xNoProxyForFT->set_sensitive(bInetNoProxyEnabled); m_xNoProxyForED->set_sensitive(bInetNoProxyEnabled); + m_xNoProxyForImg->set_visible(!bEnable); m_xNoProxyDescFT->set_sensitive(bInetNoProxyEnabled); } @@ -476,17 +461,27 @@ SvxSecurityTabPage::SvxSecurityTabPage(weld::Container* pPage, weld::DialogContr : SfxTabPage(pPage, pController, "cui/ui/optsecuritypage.ui", "OptSecurityPage", &rSet) , m_xSecurityOptionsPB(m_xBuilder->weld_button("options")) , m_xSavePasswordsCB(m_xBuilder->weld_check_button("savepassword")) + , m_xSavePasswordsImg(m_xBuilder->weld_widget("locksavepassword")) , m_xShowConnectionsPB(m_xBuilder->weld_button("connections")) , m_xMasterPasswordCB(m_xBuilder->weld_check_button("usemasterpassword")) + , m_xMasterPasswordImg(m_xBuilder->weld_widget("lockusemasterpassword")) , m_xMasterPasswordFT(m_xBuilder->weld_label("masterpasswordtext")) , m_xMasterPasswordPB(m_xBuilder->weld_button("masterpassword")) , m_xMacroSecFrame(m_xBuilder->weld_container("macrosecurity")) , m_xMacroSecPB(m_xBuilder->weld_button("macro")) , m_xCertFrame(m_xBuilder->weld_container("certificatepath")) , m_xCertPathPB(m_xBuilder->weld_button("cert")) + , m_xCertPathImg(m_xBuilder->weld_widget("lockcertipath")) + , m_xCertPathLabel(m_xBuilder->weld_label("label7")) , m_xTSAURLsFrame(m_xBuilder->weld_container("tsaurls")) , m_xTSAURLsPB(m_xBuilder->weld_button("tsas")) + , m_xTSAURLsImg(m_xBuilder->weld_widget("locktsas")) + , m_xTSAURLsLabel(m_xBuilder->weld_label("label9")) , m_xNoPasswordSaveFT(m_xBuilder->weld_label("nopasswordsave")) + , m_xCertMgrPathLB(m_xBuilder->weld_button("browse")) + , m_xParameterEdit(m_xBuilder->weld_entry("parameterfield")) + , m_xCertMgrPathImg(m_xBuilder->weld_widget("lockcertimanager")) + , m_xCertMgrPathLabel(m_xBuilder->weld_label("label11")) { //fdo#65595, we need height-for-width support here, but for now we can //bodge it @@ -510,10 +505,46 @@ SvxSecurityTabPage::SvxSecurityTabPage(weld::Container* pPage, weld::DialogContr m_xMacroSecPB->connect_clicked( LINK( this, SvxSecurityTabPage, MacroSecPBHdl ) ); m_xCertPathPB->connect_clicked( LINK( this, SvxSecurityTabPage, CertPathPBHdl ) ); m_xTSAURLsPB->connect_clicked( LINK( this, SvxSecurityTabPage, TSAURLsPBHdl ) ); + m_xCertMgrPathLB->connect_clicked( LINK( this, SvxSecurityTabPage, CertMgrPBHdl ) ); ActivatePage( rSet ); } +IMPL_LINK_NOARG(SvxSecurityTabPage, CertMgrPBHdl, weld::Button&, void) +{ + try + { + FileDialogHelper aHelper(css::ui::dialogs::TemplateDescription::FILEOPEN_SIMPLE, + FileDialogFlags::NONE, nullptr); + OUString sPath = m_xParameterEdit->get_text(); + if (sPath.isEmpty()) + sPath = "/usr/bin"; + + OUString sUrl; + osl::FileBase::getFileURLFromSystemPath(sPath, sUrl); + aHelper.SetDisplayDirectory(sUrl); + + if (ERRCODE_NONE == aHelper.Execute()) + { + sUrl = aHelper.GetPath(); + if (osl::FileBase::getSystemPathFromFileURL(sUrl, sPath) != osl::FileBase::E_None) + { + sPath.clear(); + } + m_xParameterEdit->set_text(sPath); + } + std::shared_ptr<comphelper::ConfigurationChanges> pBatch( + comphelper::ConfigurationChanges::create()); + OUString sCurCertMgr = m_xParameterEdit->get_text(); + officecfg::Office::Common::Security::Scripting::CertMgrPath::set(sCurCertMgr, pBatch); + pBatch->commit(); + } + catch (const uno::Exception&) + { + TOOLS_WARN_EXCEPTION("cui.options", "CertMgrPBHdl"); + } +} + SvxSecurityTabPage::~SvxSecurityTabPage() { } @@ -739,11 +770,51 @@ void SvxSecurityTabPage::InitControls() m_xMasterPasswordFT->set_sensitive(true); } } + + if (officecfg::Office::Common::Passwords::UseStorage::isReadOnly()) + { + m_xSavePasswordsCB->set_sensitive(false); + m_xShowConnectionsPB->set_sensitive(false); + m_xSavePasswordsImg->set_visible(true); + m_xMasterPasswordCB->set_sensitive(false); + m_xMasterPasswordPB->set_sensitive(false); + m_xMasterPasswordImg->set_visible(true); + } } catch (const Exception&) { m_xSavePasswordsCB->set_sensitive( false ); } + + try + { + OUString sCurCertMgr = officecfg::Office::Common::Security::Scripting::CertMgrPath::get(); + + if (!sCurCertMgr.isEmpty()) + m_xParameterEdit->set_text(sCurCertMgr); + + bool bEnable = !officecfg::Office::Common::Security::Scripting::CertMgrPath::isReadOnly(); + m_xCertMgrPathLB->set_sensitive(bEnable); + m_xParameterEdit->set_sensitive(bEnable); + m_xCertMgrPathLabel->set_sensitive(bEnable); + m_xCertMgrPathImg->set_visible(!bEnable); + + bEnable = !officecfg::Office::Common::Security::Scripting::TSAURLs::isReadOnly(); + m_xTSAURLsPB->set_sensitive(bEnable); + m_xTSAURLsLabel->set_sensitive(bEnable); + m_xTSAURLsImg->set_visible(!bEnable); + +#ifndef UNX + bEnable = !officecfg::Office::Common::Security::Scripting::CertDir::isReadOnly() || + !officecfg::Office::Common::Security::Scripting::ManualCertDir::isReadOnly(); + m_xCertPathPB->set_sensitive(bEnable); + m_xCertPathLabel->set_sensitive(bEnable); + m_xCertPathImg->set_visible(!bEnable); +#endif + } + catch (const uno::Exception&) + { + } } std::unique_ptr<SfxTabPage> SvxSecurityTabPage::Create(weld::Container* pPage, weld::DialogController* pController, const SfxItemSet* rAttrSet ) @@ -762,39 +833,56 @@ DeactivateRC SvxSecurityTabPage::DeactivatePage( SfxItemSet* _pSet ) return DeactivateRC::LeavePage; } -namespace +OUString SvxSecurityTabPage::GetAllStrings() { - bool CheckAndSave( SvtSecurityOptions::EOption _eOpt, const bool _bIsChecked, bool& _rModified ) + OUString sAllStrings; + OUString labels[] = { "label1", "label4", "label2", "masterpasswordtext", + "nopasswordsave", "label3", "label5", "label8", + "label7", "label10", "label9", "label12", + "label11" }; + + for (const auto& label : labels) { - bool bModified = false; - if ( !SvtSecurityOptions::IsReadOnly( _eOpt ) ) - { - bModified = SvtSecurityOptions::IsOptionSet( _eOpt ) != _bIsChecked; - if ( bModified ) - { - SvtSecurityOptions::SetOption( _eOpt, _bIsChecked ); - _rModified = true; - } - } + if (const auto& pString = m_xBuilder->weld_label(label)) + sAllStrings += pString->get_label() + " "; + } + + OUString checkButton[] = { "savepassword", "usemasterpassword" }; + + for (const auto& check : checkButton) + { + if (const auto& pString = m_xBuilder->weld_check_button(check)) + sAllStrings += pString->get_label() + " "; + } - return bModified; + // TODO: Should we exclude button strings from the search? + // button id: "browse" is excluded + OUString buttons[] = { "options", "connections", "masterpassword", "macro", "cert", "tsas" }; + + for (const auto& btn : buttons) + { + if (const auto& pString = m_xBuilder->weld_button(btn)) + sAllStrings += pString->get_label() + " "; } + + return sAllStrings.replaceAll("_", ""); } bool SvxSecurityTabPage::FillItemSet( SfxItemSet* ) { bool bModified = false; - if (m_xSecOptDlg) + if (m_xSecOptDlg) { + bModified = m_xSecOptDlg->SetSecurityOptions(); + } + + std::shared_ptr<comphelper::ConfigurationChanges> pBatch( + comphelper::ConfigurationChanges::create()); + if (m_xParameterEdit->get_value_changed_from_saved()) { - CheckAndSave( SvtSecurityOptions::EOption::DocWarnSaveOrSend, m_xSecOptDlg->IsSaveOrSendDocsChecked(), bModified ); - CheckAndSave( SvtSecurityOptions::EOption::DocWarnSigning, m_xSecOptDlg->IsSignDocsChecked(), bModified ); - CheckAndSave( SvtSecurityOptions::EOption::DocWarnPrint, m_xSecOptDlg->IsPrintDocsChecked(), bModified ); - CheckAndSave( SvtSecurityOptions::EOption::DocWarnCreatePdf, m_xSecOptDlg->IsCreatePdfChecked(), bModified ); - CheckAndSave( SvtSecurityOptions::EOption::DocWarnRemovePersonalInfo, m_xSecOptDlg->IsRemovePersInfoChecked(), bModified ); - CheckAndSave( SvtSecurityOptions::EOption::DocWarnRecommendPassword, m_xSecOptDlg->IsRecommPasswdChecked(), bModified ); - CheckAndSave( SvtSecurityOptions::EOption::CtrlClickHyperlink, m_xSecOptDlg->IsCtrlHyperlinkChecked(), bModified ); - CheckAndSave( SvtSecurityOptions::EOption::BlockUntrustedRefererLinks, m_xSecOptDlg->IsBlockUntrustedRefererLinksChecked(), bModified ); + OUString sCurCertMgr = m_xParameterEdit->get_text(); + officecfg::Office::Common::Security::Scripting::CertMgrPath::set(sCurCertMgr, pBatch); + pBatch->commit(); } return bModified; @@ -855,6 +943,22 @@ std::unique_ptr<SfxTabPage> SvxEMailTabPage::Create( weld::Container* pPage, wel /* -------------------------------------------------------------------------*/ +OUString SvxEMailTabPage::GetAllStrings() +{ + OUString sAllStrings; + OUString labels[] = { "label1", "label2", "browsetitle", "suppress" }; + + for (const auto& label : labels) + { + if (const auto& pString = m_xBuilder->weld_label(label)) + sAllStrings += pString->get_label() + " "; + } + + return sAllStrings.replaceAll("_", ""); +} + +/* -------------------------------------------------------------------------*/ + bool SvxEMailTabPage::FillItemSet( SfxItemSet* ) { std::shared_ptr<comphelper::ConfigurationChanges> batch( diff --git a/cui/source/options/optinet2.hxx b/cui/source/options/optinet2.hxx index 4d03d2d04337..e05a79be029b 100644 --- a/cui/source/options/optinet2.hxx +++ b/cui/source/options/optinet2.hxx @@ -30,25 +30,27 @@ class SvxProxyTabPage : public SfxTabPage { private: + std::unique_ptr<weld::Label> m_xProxyModeFT; std::unique_ptr<weld::ComboBox> m_xProxyModeLB; + std::unique_ptr<weld::Widget> m_xProxyModeImg; std::unique_ptr<weld::Label> m_xHttpProxyFT; std::unique_ptr<weld::Entry> m_xHttpProxyED; + std::unique_ptr<weld::Widget> m_xHttpProxyImg; std::unique_ptr<weld::Label> m_xHttpPortFT; std::unique_ptr<weld::Entry> m_xHttpPortED; + std::unique_ptr<weld::Widget> m_xHttpPortImg; std::unique_ptr<weld::Label> m_xHttpsProxyFT; std::unique_ptr<weld::Entry> m_xHttpsProxyED; + std::unique_ptr<weld::Widget> m_xHttpsProxyImg; std::unique_ptr<weld::Label> m_xHttpsPortFT; std::unique_ptr<weld::Entry> m_xHttpsPortED; - - std::unique_ptr<weld::Label> m_xFtpProxyFT; - std::unique_ptr<weld::Entry> m_xFtpProxyED; - std::unique_ptr<weld::Label> m_xFtpPortFT; - std::unique_ptr<weld::Entry> m_xFtpPortED; + std::unique_ptr<weld::Widget> m_xHttpsPortImg; std::unique_ptr<weld::Label> m_xNoProxyForFT; std::unique_ptr<weld::Entry> m_xNoProxyForED; + std::unique_ptr<weld::Widget> m_xNoProxyForImg; std::unique_ptr<weld::Label> m_xNoProxyDescFT; css::uno::Reference< css::uno::XInterface > m_xConfigurationUpdateAccess; @@ -68,6 +70,9 @@ public: SvxProxyTabPage(weld::Container* pPage, weld::DialogController* pController, const SfxItemSet& rSet); virtual ~SvxProxyTabPage() override; static std::unique_ptr<SfxTabPage> Create( weld::Container* pPage, weld::DialogController* pController, const SfxItemSet* rAttrSet ); + + virtual OUString GetAllStrings() override; + virtual bool FillItemSet( SfxItemSet* rSet ) override; virtual void Reset( const SfxItemSet* rSet ) override; }; @@ -87,9 +92,11 @@ private: std::unique_ptr<weld::Button> m_xSecurityOptionsPB; std::unique_ptr<weld::CheckButton> m_xSavePasswordsCB; + std::unique_ptr<weld::Widget> m_xSavePasswordsImg; std::unique_ptr<weld::Button> m_xShowConnectionsPB; std::unique_ptr<weld::CheckButton> m_xMasterPasswordCB; + std::unique_ptr<weld::Widget> m_xMasterPasswordImg; std::unique_ptr<weld::Label> m_xMasterPasswordFT; std::unique_ptr<weld::Button> m_xMasterPasswordPB; @@ -98,12 +105,21 @@ private: std::unique_ptr<weld::Container> m_xCertFrame; std::unique_ptr<weld::Button> m_xCertPathPB; + std::unique_ptr<weld::Widget> m_xCertPathImg; + std::unique_ptr<weld::Label> m_xCertPathLabel; std::unique_ptr<weld::Container> m_xTSAURLsFrame; std::unique_ptr<weld::Button> m_xTSAURLsPB; + std::unique_ptr<weld::Widget> m_xTSAURLsImg; + std::unique_ptr<weld::Label> m_xTSAURLsLabel; std::unique_ptr<weld::Label> m_xNoPasswordSaveFT; + std::unique_ptr<weld::Button> m_xCertMgrPathLB; + std::unique_ptr<weld::Entry> m_xParameterEdit; + std::unique_ptr<weld::Widget> m_xCertMgrPathImg; + std::unique_ptr<weld::Label> m_xCertMgrPathLabel; + DECL_LINK(SecurityOptionsHdl, weld::Button&, void); DECL_LINK(SavePasswordHdl, weld::Toggleable&, void); DECL_LINK(MasterPasswordHdl, weld::Button&, void); @@ -112,6 +128,7 @@ private: DECL_LINK(MacroSecPBHdl, weld::Button&, void ); DECL_LINK(CertPathPBHdl, weld::Button&, void ); DECL_LINK(TSAURLsPBHdl, weld::Button&, void ); + DECL_LINK(CertMgrPBHdl, weld::Button&, void ); void InitControls(); @@ -123,6 +140,9 @@ public: SvxSecurityTabPage(weld::Container* pPage, weld::DialogController* pController, const SfxItemSet& rSet); static std::unique_ptr<SfxTabPage> Create( weld::Container* pPage, weld::DialogController* pController, const SfxItemSet* rAttrSet ); virtual ~SvxSecurityTabPage() override; + + virtual OUString GetAllStrings() override; + virtual bool FillItemSet( SfxItemSet* rSet ) override; virtual void Reset( const SfxItemSet* rSet ) override; }; @@ -151,6 +171,8 @@ public: static std::unique_ptr<SfxTabPage> Create( weld::Container* pPage, weld::DialogController* pController, const SfxItemSet* rAttrSet ); + virtual OUString GetAllStrings() override; + virtual bool FillItemSet( SfxItemSet* rSet ) override; virtual void Reset( const SfxItemSet* rSet ) override; }; diff --git a/cui/source/options/optjava.cxx b/cui/source/options/optjava.cxx index ce535b9f6a6c..cc89865bdd28 100644 --- a/cui/source/options/optjava.cxx +++ b/cui/source/options/optjava.cxx @@ -33,6 +33,7 @@ #include <officecfg/Office/Common.hxx> #include <osl/file.hxx> +#include <rtl/bootstrap.hxx> #include <strings.hrc> #include <vcl/svapp.hxx> @@ -44,14 +45,12 @@ #include <svtools/restartdialog.hxx> #include <sfx2/filedlghelper.hxx> #include <sfx2/inputdlg.hxx> -#include <tools/diagnose_ex.h> +#include <comphelper/diagnose_ex.hxx> #include <comphelper/processfactory.hxx> #include <comphelper/string.hxx> #include <com/sun/star/ui/dialogs/ExecutableDialogResults.hpp> #include <com/sun/star/ui/dialogs/XAsynchronousExecutableDialog.hpp> #include <com/sun/star/ui/dialogs/TemplateDescription.hpp> -#include <com/sun/star/ui/dialogs/FolderPicker.hpp> -#include <com/sun/star/ucb/XContentProvider.hpp> #if HAVE_FEATURE_JAVA #include <jvmfwk/framework.hxx> #endif @@ -60,8 +59,6 @@ #define CLASSPATH_DELIMITER SAL_PATHSEPARATOR -using namespace ::com::sun::star::lang; -using namespace ::com::sun::star::ucb; using namespace ::com::sun::star::ui::dialogs; using namespace ::com::sun::star::uno; @@ -78,7 +75,9 @@ SvxJavaOptionsPage::SvxJavaOptionsPage(weld::Container* pPage, weld::DialogContr , m_xClassPathBtn(m_xBuilder->weld_button("classpath")) , m_xExpertConfigBtn(m_xBuilder->weld_button("expertconfig")) , m_xExperimentalCB(m_xBuilder->weld_check_button("experimental")) + , m_xExperimentalImg(m_xBuilder->weld_widget("lockexperimental")) , m_xMacroCB(m_xBuilder->weld_check_button("macrorecording")) + , m_xMacroImg(m_xBuilder->weld_widget("lockmacrorecording")) , m_xAddDialogText(m_xBuilder->weld_label("selectruntime")) , m_xJavaFrame(m_xBuilder->weld_widget("javaframe")) { @@ -110,10 +109,16 @@ SvxJavaOptionsPage::SvxJavaOptionsPage(weld::Container* pPage, weld::DialogContr m_xExpertConfigBtn->set_sensitive(false); if (officecfg::Office::Common::Misc::MacroRecorderMode::isReadOnly()) + { m_xMacroCB->set_sensitive(false); + m_xMacroImg->set_visible(true); + } if (officecfg::Office::Common::Misc::ExperimentalMode::isReadOnly()) + { m_xExperimentalCB->set_sensitive(false); + m_xExperimentalImg->set_visible(true); + } xDialogListener->SetDialogClosedLink( LINK( this, SvxJavaOptionsPage, DialogClosedHdl ) ); @@ -434,14 +439,14 @@ void SvxJavaOptionsPage::AddFolder( const OUString& _rFolder ) { std::unique_ptr<weld::MessageDialog> xBox(Application::CreateMessageDialog(GetFrameWeld(), VclMessageType::Warning, VclButtonsType::Ok, - CuiResId(RID_SVXSTR_JRE_NOT_RECOGNIZED))); + CuiResId(RID_CUISTR_JRE_NOT_RECOGNIZED))); xBox->run(); } else if ( JFW_E_FAILED_VERSION == eErr ) { std::unique_ptr<weld::MessageDialog> xBox(Application::CreateMessageDialog(GetFrameWeld(), VclMessageType::Warning, VclButtonsType::Ok, - CuiResId(RID_SVXSTR_JRE_FAILED_VERSION))); + CuiResId(RID_CUISTR_JRE_FAILED_VERSION))); xBox->run(); } @@ -468,6 +473,36 @@ std::unique_ptr<SfxTabPage> SvxJavaOptionsPage::Create(weld::Container* pPage, w return std::make_unique<SvxJavaOptionsPage>(pPage, pController, *rAttrSet); } +OUString SvxJavaOptionsPage::GetAllStrings() +{ + OUString sAllStrings; + OUString labels[] = { "label1", "label2", "javapath", "selectruntime", "label12" }; + + for (const auto& label : labels) + { + if (const auto& pString = m_xBuilder->weld_label(label)) + sAllStrings += pString->get_label() + " "; + } + + OUString checkButton[] = { "javaenabled", "experimental", "macrorecording" }; + + for (const auto& check : checkButton) + { + if (const auto& pString = m_xBuilder->weld_check_button(check)) + sAllStrings += pString->get_label() + " "; + } + + OUString buttons[] = { "add", "parameters", "classpath", "expertconfig" }; + + for (const auto& btn : buttons) + { + if (const auto& pString = m_xBuilder->weld_button(btn)) + sAllStrings += pString->get_label() + " "; + } + + return sAllStrings.replaceAll("_", ""); +} + bool SvxJavaOptionsPage::FillItemSet( SfxItemSet* /*rCoreSet*/ ) { bool bModified = false; @@ -712,7 +747,7 @@ void SvxJavaParameterDlg::EditParameter() if (nPos == -1) return; - InputDialog aParamEditDlg(m_xDialog.get(), CuiResId(RID_SVXSTR_JAVA_START_PARAM)); + InputDialog aParamEditDlg(m_xDialog.get(), CuiResId(RID_CUISTR_JAVA_START_PARAM)); OUString editableClassPath = m_xAssignedList->get_selected_text(); aParamEditDlg.SetEntryText(editableClassPath); aParamEditDlg.HideHelpBtn(); @@ -792,8 +827,8 @@ SvxJavaClassPathDlg::~SvxJavaClassPathDlg() IMPL_LINK_NOARG(SvxJavaClassPathDlg, AddArchiveHdl_Impl, weld::Button&, void) { sfx2::FileDialogHelper aDlg(TemplateDescription::FILEOPEN_SIMPLE, FileDialogFlags::NONE, m_xDialog.get()); - aDlg.SetTitle( CuiResId( RID_SVXSTR_ARCHIVE_TITLE ) ); - aDlg.AddFilter( CuiResId( RID_SVXSTR_ARCHIVE_HEADLINE ), "*.jar;*.zip" ); + aDlg.SetTitle( CuiResId( RID_CUISTR_ARCHIVE_TITLE ) ); + aDlg.AddFilter( CuiResId( RID_CUISTR_ARCHIVE_HEADLINE ), "*.jar;*.zip" ); aDlg.SetContext(sfx2::FileDialogHelper::JavaClassPath); OUString sFolder; if (m_xPathList->count_selected_rows() > 0) @@ -817,7 +852,7 @@ IMPL_LINK_NOARG(SvxJavaClassPathDlg, AddArchiveHdl_Impl, weld::Button&, void) } else { - OUString sMsg( CuiResId( RID_SVXSTR_MULTIFILE_DBL_ERR ) ); + OUString sMsg( CuiResId( RID_CUISTR_MULTIFILE_DBL_ERR ) ); sMsg = sMsg.replaceFirst( "%1", sFile ); std::unique_ptr<weld::MessageDialog> xBox(Application::CreateMessageDialog(m_xDialog.get(), VclMessageType::Warning, VclButtonsType::Ok, sMsg)); @@ -826,7 +861,7 @@ IMPL_LINK_NOARG(SvxJavaClassPathDlg, AddArchiveHdl_Impl, weld::Button&, void) } else { - OUString sMsg( CuiResId( RID_SVXSTR_CANNOTCONVERTURL_ERR ) ); + OUString sMsg( CuiResId( RID_CUISTR_CANNOTCONVERTURL_ERR ) ); sMsg = sMsg.replaceFirst( "%1", sURL ); std::unique_ptr<weld::MessageDialog> xBox(Application::CreateMessageDialog(m_xDialog.get(), VclMessageType::Warning, VclButtonsType::Ok, sMsg)); @@ -865,7 +900,7 @@ IMPL_LINK_NOARG(SvxJavaClassPathDlg, AddPathHdl_Impl, weld::Button&, void) } else { - OUString sMsg( CuiResId( RID_SVXSTR_MULTIFILE_DBL_ERR ) ); + OUString sMsg( CuiResId( RID_CUISTR_MULTIFILE_DBL_ERR ) ); sMsg = sMsg.replaceFirst( "%1", sNewFolder ); std::unique_ptr<weld::MessageDialog> xBox(Application::CreateMessageDialog(m_xDialog.get(), VclMessageType::Warning, VclButtonsType::Ok, sMsg)); @@ -874,7 +909,7 @@ IMPL_LINK_NOARG(SvxJavaClassPathDlg, AddPathHdl_Impl, weld::Button&, void) } else { - OUString sMsg( CuiResId( RID_SVXSTR_CANNOTCONVERTURL_ERR ) ); + OUString sMsg( CuiResId( RID_CUISTR_CANNOTCONVERTURL_ERR ) ); sMsg = sMsg.replaceFirst( "%1", sFolderURL ); std::unique_ptr<weld::MessageDialog> xBox(Application::CreateMessageDialog(m_xDialog.get(), VclMessageType::Warning, VclButtonsType::Ok, sMsg)); @@ -936,6 +971,7 @@ OUString SvxJavaClassPathDlg::GetClassPath() const return sPath.makeStringAndClear(); } +#if HAVE_FEATURE_JAVA void SvxJavaClassPathDlg::SetClassPath( const OUString& _rPath ) { if ( m_sOldPath.isEmpty() ) @@ -943,20 +979,27 @@ void SvxJavaClassPathDlg::SetClassPath( const OUString& _rPath ) m_xPathList->clear(); if (!_rPath.isEmpty()) { - sal_Int32 nIdx = 0; - do + std::vector paths = jfw_convertUserPathList(_rPath); + for (auto const& path : paths) { - OUString sToken = _rPath.getToken( 0, CLASSPATH_DELIMITER, nIdx ); OUString sURL; - osl::FileBase::getFileURLFromSystemPath(sToken, sURL); // best effort + if (path.startsWith("$")) + { + sURL = path; + rtl::Bootstrap::expandMacros(sURL); + } + else + { + osl::FileBase::getFileURLFromSystemPath(path, sURL); + } INetURLObject aURL( sURL ); - m_xPathList->append("", sToken, SvFileInformationManager::GetImageId(aURL)); + m_xPathList->append("", path, SvFileInformationManager::GetImageId(aURL)); } - while (nIdx>=0); // select first entry m_xPathList->select(0); } SelectHdl_Impl(*m_xPathList); } +#endif /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/cui/source/options/optjava.hxx b/cui/source/options/optjava.hxx index 097b7ffb5336..84422c903056 100644 --- a/cui/source/options/optjava.hxx +++ b/cui/source/options/optjava.hxx @@ -75,7 +75,9 @@ private: std::unique_ptr<SvxJavaClassPathDlg> m_xPathDlg; std::unique_ptr<weld::CheckButton> m_xExperimentalCB; + std::unique_ptr<weld::Widget> m_xExperimentalImg; std::unique_ptr<weld::CheckButton> m_xMacroCB; + std::unique_ptr<weld::Widget> m_xMacroImg; std::unique_ptr<weld::Label> m_xAddDialogText; @@ -108,6 +110,8 @@ public: static std::unique_ptr<SfxTabPage> Create( weld::Container* pPage, weld::DialogController* pController, const SfxItemSet* rSet ); + virtual OUString GetAllStrings() override; + virtual bool FillItemSet( SfxItemSet* rSet ) override; virtual void Reset( const SfxItemSet* rSet ) override; virtual void FillUserData() override; @@ -200,7 +204,9 @@ public: void SetFocus() { m_xPathList->grab_focus(); } OUString GetClassPath() const; +#if HAVE_FEATURE_JAVA void SetClassPath( const OUString& _rPath ); +#endif }; /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/cui/source/options/optjsearch.cxx b/cui/source/options/optjsearch.cxx index 4a2c31c49f76..3c313338a021 100644 --- a/cui/source/options/optjsearch.cxx +++ b/cui/source/options/optjsearch.cxx @@ -22,8 +22,6 @@ #include <i18nutil/transliteration.hxx> #include "optjsearch.hxx" -using namespace com::sun::star::i18n; - SvxJSearchOptionsPage::SvxJSearchOptionsPage(weld::Container* pPage, weld::DialogController* pController, const SfxItemSet& rSet) : SfxTabPage(pPage, pController, "cui/ui/optjsearchpage.ui", "OptJSearchPage", &rSet) @@ -201,6 +199,45 @@ void SvxJSearchOptionsPage::Reset( const SfxItemSet* ) m_xIgnoreMiddleDot ->save_state(); } +OUString SvxJSearchOptionsPage::GetAllStrings() +{ + OUString sAllStrings; + OUString labels[] = { "label1", "label2" }; + + for (const auto& label : labels) + { + if (const auto& pString = m_xBuilder->weld_label(label)) + sAllStrings += pString->get_label() + " "; + } + + OUString checkButton[] = { "matchcase", + "matchfullhalfwidth", + "matchhiraganakatakana", + "matchcontractions", + "matchminusdashchoon", + "matchrepeatcharmarks", + "matchvariantformkanji", + "matcholdkanaforms", + "ignorepunctuation", + "ignorewhitespace", + "matchdiziduzu", + "matchbavahafa", + "matchtsithichidhizi", + "matchhyuiyubyuvyu", + "matchseshezeje", + "matchiaiya", + "matchkiku", + "matchprolongedsoundmark", + "ignoremiddledot" }; + + for (const auto& check : checkButton) + { + if (const auto& pString = m_xBuilder->weld_check_button(check)) + sAllStrings += pString->get_label() + " "; + } + + return sAllStrings.replaceAll("_", ""); +} bool SvxJSearchOptionsPage::FillItemSet( SfxItemSet* ) { diff --git a/cui/source/options/optjsearch.hxx b/cui/source/options/optjsearch.hxx index f0da350ae651..96b7d73f1f11 100644 --- a/cui/source/options/optjsearch.hxx +++ b/cui/source/options/optjsearch.hxx @@ -59,6 +59,8 @@ public: virtual ~SvxJSearchOptionsPage() override; static std::unique_ptr<SfxTabPage> Create(weld::Container* pPage, weld::DialogController* pController, const SfxItemSet* rSet); + virtual OUString GetAllStrings() override; + virtual void Reset( const SfxItemSet* rSet ) override; virtual bool FillItemSet( SfxItemSet* rSet ) override; diff --git a/cui/source/options/optlanguagetool.cxx b/cui/source/options/optlanguagetool.cxx new file mode 100644 index 000000000000..3979b42c0521 --- /dev/null +++ b/cui/source/options/optlanguagetool.cxx @@ -0,0 +1,170 @@ +/* -*- 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 "optlanguagetool.hxx" +#include <officecfg/Office/Linguistic.hxx> +#include <sal/log.hxx> +#include <dialmgr.hxx> +#include <strings.hrc> + +using LanguageToolCfg = officecfg::Office::Linguistic::GrammarChecking::LanguageTool; +constexpr OUString LANGUAGETOOL_DEFAULT_URL = u"https://api.languagetool.org/v2"_ustr; +constexpr OUString LANGUAGETOOLPLUS_DEFAULT_URL = u"https://api.languagetoolplus.com/v2"_ustr; + +OptLanguageToolTabPage::OptLanguageToolTabPage(weld::Container* pPage, + weld::DialogController* pController, + const SfxItemSet& rSet) + : SfxTabPage(pPage, pController, "cui/ui/langtoolconfigpage.ui", "OptLangToolPage", &rSet) + , m_xBaseURLED(m_xBuilder->weld_entry("baseurl")) + , m_xBaseURLImg(m_xBuilder->weld_widget("lockbaseurl")) + , m_xUsernameED(m_xBuilder->weld_entry("username")) + , m_xUsernameImg(m_xBuilder->weld_widget("lockusername")) + , m_xApiKeyED(m_xBuilder->weld_entry("apikey")) + , m_xApiKeyImg(m_xBuilder->weld_widget("lockapikey")) + , m_xRestProtocol(m_xBuilder->weld_entry("restprotocol")) + , m_xRestProtocolImg(m_xBuilder->weld_widget("lockrestprotocol")) + , m_xActivateBox(m_xBuilder->weld_check_button("activate")) + , m_xActivateBoxImg(m_xBuilder->weld_widget("lockactivate")) + , m_xSSLDisableVerificationBox(m_xBuilder->weld_check_button("verifyssl")) + , m_xSSLDisableVerificationBoxImg(m_xBuilder->weld_widget("lockverifyssl")) + , m_xApiSettingsFrame(m_xBuilder->weld_frame("apisettings")) +{ + m_xActivateBox->connect_toggled(LINK(this, OptLanguageToolTabPage, CheckHdl)); + EnableControls(LanguageToolCfg::IsEnabled::get()); + + // tdf#150494 Set default values as placeholder text + m_xBaseURLED->set_placeholder_text(CuiResId(RID_LANGUAGETOOL_LEAVE_EMPTY)); + m_xUsernameED->set_placeholder_text(CuiResId(RID_LANGUAGETOOL_LEAVE_EMPTY)); + m_xApiKeyED->set_placeholder_text(CuiResId(RID_LANGUAGETOOL_LEAVE_EMPTY)); + m_xRestProtocol->set_placeholder_text(CuiResId(RID_LANGUAGETOOL_REST_LEAVE_EMPTY)); +} + +OptLanguageToolTabPage::~OptLanguageToolTabPage() {} + +void OptLanguageToolTabPage::EnableControls(bool bEnable) +{ + if (bEnable != LanguageToolCfg::IsEnabled::get()) + { + auto batch(comphelper::ConfigurationChanges::create()); + LanguageToolCfg::IsEnabled::set(bEnable, batch); + batch->commit(); + } + m_xApiSettingsFrame->set_visible(bEnable); + m_xActivateBox->set_active(bEnable); + m_xActivateBox->set_sensitive(!LanguageToolCfg::IsEnabled::isReadOnly()); + m_xActivateBoxImg->set_visible(LanguageToolCfg::IsEnabled::isReadOnly()); + m_xSSLDisableVerificationBox->set_active(!LanguageToolCfg::SSLCertVerify::get()); + m_xSSLDisableVerificationBox->set_sensitive(!LanguageToolCfg::SSLCertVerify::isReadOnly()); + m_xSSLDisableVerificationBoxImg->set_visible(LanguageToolCfg::SSLCertVerify::isReadOnly()); +} + +IMPL_LINK_NOARG(OptLanguageToolTabPage, CheckHdl, weld::Toggleable&, void) +{ + EnableControls(m_xActivateBox->get_active()); +} + +void OptLanguageToolTabPage::Reset(const SfxItemSet*) +{ + // tdf#150494 If no URL has been set, use the default URL + OUString aUsername = LanguageToolCfg::Username::get().value_or(""); + OUString aApiKey = LanguageToolCfg::ApiKey::get().value_or(""); + OUString aBaseURL = LanguageToolCfg::BaseURL::get().value_or( + (aUsername.isEmpty() && aApiKey.isEmpty()) ? LANGUAGETOOL_DEFAULT_URL + : LANGUAGETOOLPLUS_DEFAULT_URL); + + m_xBaseURLED->set_text(aBaseURL); + m_xBaseURLED->set_sensitive(!LanguageToolCfg::BaseURL::isReadOnly()); + m_xBaseURLImg->set_visible(LanguageToolCfg::BaseURL::isReadOnly()); + + m_xUsernameED->set_text(aUsername); + m_xUsernameED->set_sensitive(!LanguageToolCfg::Username::isReadOnly()); + m_xUsernameImg->set_visible(LanguageToolCfg::Username::isReadOnly()); + + m_xApiKeyED->set_text(aApiKey); + m_xApiKeyED->set_sensitive(!LanguageToolCfg::ApiKey::isReadOnly()); + m_xApiKeyImg->set_visible(LanguageToolCfg::ApiKey::isReadOnly()); + + m_xRestProtocol->set_text(LanguageToolCfg::RestProtocol::get().value_or("")); + m_xRestProtocol->set_sensitive(!LanguageToolCfg::RestProtocol::isReadOnly()); + m_xRestProtocolImg->set_visible(LanguageToolCfg::RestProtocol::isReadOnly()); + + m_xSSLDisableVerificationBox->set_active(!LanguageToolCfg::SSLCertVerify::get()); + m_xSSLDisableVerificationBox->set_sensitive(!LanguageToolCfg::SSLCertVerify::isReadOnly()); + m_xSSLDisableVerificationBoxImg->set_visible(LanguageToolCfg::SSLCertVerify::isReadOnly()); +} + +OUString OptLanguageToolTabPage::GetAllStrings() +{ + OUString sAllStrings; + OUString labels[] = { "langtoolsettings", "disclaimer", "apisettingsheader", "base", + "urldesc", "usernamelbl", "usernamedesc", "apikeylbl", + "apikeydesc", "restlbl", "restdesc" }; + + for (const auto& label : labels) + { + if (const auto& pString = m_xBuilder->weld_label(label)) + sAllStrings += pString->get_label() + " "; + } + + OUString checkButton[] = { "activate", "verifyssl" }; + + for (const auto& check : checkButton) + { + if (const auto& pString = m_xBuilder->weld_check_button(check)) + sAllStrings += pString->get_label() + " "; + } + + if (const auto& pString = m_xBuilder->weld_link_button("policy")) + sAllStrings += pString->get_label() + " "; + + return sAllStrings.replaceAll("_", ""); +} + +bool OptLanguageToolTabPage::FillItemSet(SfxItemSet*) +{ + auto batch(comphelper::ConfigurationChanges::create()); + + // tdf#150494 If no URL has been set, then save the default URL + // tdf#159395 If Username and ApiKey are set, then save the default URL for paid service + OUString aBaseURL = m_xBaseURLED->get_text(); + OUString aUsername = m_xUsernameED->get_text(); + OUString aApiKey = m_xApiKeyED->get_text(); + + if (aBaseURL.isEmpty() + || (aUsername.isEmpty() && aApiKey.isEmpty() && aBaseURL == LANGUAGETOOLPLUS_DEFAULT_URL)) + aBaseURL = LANGUAGETOOL_DEFAULT_URL; + + if (!aUsername.isEmpty() && !aApiKey.isEmpty() && aBaseURL == LANGUAGETOOL_DEFAULT_URL) + aBaseURL = LANGUAGETOOLPLUS_DEFAULT_URL; + + LanguageToolCfg::BaseURL::set(aBaseURL, batch); + LanguageToolCfg::Username::set(aUsername, batch); + LanguageToolCfg::ApiKey::set(aApiKey, batch); + LanguageToolCfg::RestProtocol::set(m_xRestProtocol->get_text(), batch); + LanguageToolCfg::SSLCertVerify::set(!m_xSSLDisableVerificationBox->get_active(), batch); + batch->commit(); + return false; +} + +std::unique_ptr<SfxTabPage> OptLanguageToolTabPage::Create(weld::Container* pPage, + weld::DialogController* pController, + const SfxItemSet* rAttrSet) +{ + return std::make_unique<OptLanguageToolTabPage>(pPage, pController, *rAttrSet); +} diff --git a/cui/source/options/optlanguagetool.hxx b/cui/source/options/optlanguagetool.hxx new file mode 100644 index 000000000000..3e3c3e8da0c7 --- /dev/null +++ b/cui/source/options/optlanguagetool.hxx @@ -0,0 +1,55 @@ +/* -*- 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 . + */ +#pragma once +#include <sfx2/tabdlg.hxx> +#include <rtl/ustring.hxx> + +class OptLanguageToolTabPage : public SfxTabPage +{ +public: + OptLanguageToolTabPage(weld::Container* pPage, weld::DialogController* pController, + const SfxItemSet& rSet); + virtual ~OptLanguageToolTabPage() override; + static std::unique_ptr<SfxTabPage> + Create(weld::Container* pPage, weld::DialogController* pController, const SfxItemSet* rAttrSet); + + virtual OUString GetAllStrings() override; + + virtual bool FillItemSet(SfxItemSet* rSet) override; + virtual void Reset(const SfxItemSet* rSet) override; + +private: + std::unique_ptr<weld::Entry> m_xBaseURLED; + std::unique_ptr<weld::Widget> m_xBaseURLImg; + std::unique_ptr<weld::Entry> m_xUsernameED; + std::unique_ptr<weld::Widget> m_xUsernameImg; + std::unique_ptr<weld::Entry> m_xApiKeyED; + std::unique_ptr<weld::Widget> m_xApiKeyImg; + std::unique_ptr<weld::Entry> m_xRestProtocol; + std::unique_ptr<weld::Widget> m_xRestProtocolImg; + std::unique_ptr<weld::CheckButton> m_xActivateBox; + std::unique_ptr<weld::Widget> m_xActivateBoxImg; + std::unique_ptr<weld::CheckButton> m_xSSLDisableVerificationBox; + std::unique_ptr<weld::Widget> m_xSSLDisableVerificationBoxImg; + std::unique_ptr<weld::Frame> m_xApiSettingsFrame; + + void EnableControls(bool bEnable); + + DECL_LINK(CheckHdl, weld::Toggleable&, void); +}; diff --git a/cui/source/options/optlingu.cxx b/cui/source/options/optlingu.cxx index 3e0acc1c05d7..4ec9bd987462 100644 --- a/cui/source/options/optlingu.cxx +++ b/cui/source/options/optlingu.cxx @@ -17,11 +17,14 @@ * the License at http://www.apache.org/licenses/LICENSE-2.0 . */ +#include <utility> #include <vcl/settings.hxx> #include <vcl/weld.hxx> #include <i18nlangtag/languagetag.hxx> #include <i18nlangtag/mslangid.hxx> +#include <o3tl/safeint.hxx> #include <officecfg/Office/Security.hxx> +#include <officecfg/Office/Linguistic.hxx> #include <unotools/lingucfg.hxx> #include <unotools/linguprops.hxx> #include <editeng/unolingu.hxx> @@ -29,8 +32,9 @@ #include <sfx2/sfxsids.hrc> #include <tools/debug.hxx> #include <tools/urlobj.hxx> -#include <tools/diagnose_ex.h> +#include <comphelper/diagnose_ex.hxx> #include <comphelper/dispatchcommand.hxx> +#include <comphelper/lok.hxx> #include <comphelper/processfactory.hxx> #include <com/sun/star/linguistic2/LinguServiceManager.hpp> #include <com/sun/star/linguistic2/XSearchableDictionaryList.hpp> @@ -43,6 +47,8 @@ #include <com/sun/star/linguistic2/XLinguProperties.hpp> #include <com/sun/star/lang/XServiceDisplayName.hpp> #include <com/sun/star/frame/XStorable.hpp> +#include <com/sun/star/container/XNameAccess.hpp> +#include <com/sun/star/beans/PropertyAttribute.hpp> #include <unotools/extendedsecurityoptions.hxx> #include <svl/eitem.hxx> #include <vcl/svapp.hxx> @@ -57,6 +63,7 @@ #include <ucbhelper/content.hxx> +#include <set> #include <vector> #include <map> @@ -67,10 +74,10 @@ using namespace css::uno; using namespace css::linguistic2; using namespace css::beans; -constexpr OUStringLiteral cSpell(SN_SPELLCHECKER); -constexpr OUStringLiteral cGrammar(SN_GRAMMARCHECKER); -constexpr OUStringLiteral cHyph(SN_HYPHENATOR); -constexpr OUStringLiteral cThes(SN_THESAURUS); +constexpr OUString cSpell(SN_SPELLCHECKER); +constexpr OUString cGrammar(SN_GRAMMARCHECKER); +constexpr OUString cHyph(SN_HYPHENATOR); +constexpr OUString cThes(SN_THESAURUS); // static ---------------------------------------------------------------- @@ -127,12 +134,12 @@ class ModuleUserData_Impl OUString sImplName; public: - ModuleUserData_Impl( const OUString& sImpName, bool bIsParent, bool bChecked, sal_uInt8 nSetType, sal_uInt8 nSetIndex ) : + ModuleUserData_Impl( OUString sImpName, bool bIsParent, bool bChecked, sal_uInt8 nSetType, sal_uInt8 nSetIndex ) : bParent(bIsParent), bIsChecked(bChecked), nType(nSetType), nIndex(nSetIndex), - sImplName(sImpName) + sImplName(std::move(sImpName)) { } bool IsParent() const {return bParent;} @@ -191,7 +198,9 @@ enum EID_OPTIONS EID_NUM_PRE_BREAK, EID_NUM_POST_BREAK, EID_HYPH_AUTO, - EID_HYPH_SPECIAL + EID_HYPH_SPECIAL, + EID_SPELL_CLOSED_COMPOUND, + EID_SPELL_HYPHENATED_COMPOUND }; } @@ -203,6 +212,8 @@ static OUString lcl_GetPropertyName( EID_OPTIONS eEntryId ) case EID_SPELL_AUTO: return UPN_IS_SPELL_AUTO; case EID_GRAMMAR_AUTO: return UPN_IS_GRAMMAR_AUTO; case EID_CAPITAL_WORDS: return UPN_IS_SPELL_UPPER_CASE; + case EID_SPELL_CLOSED_COMPOUND: return UPN_IS_SPELL_CLOSED_COMPOUND; + case EID_SPELL_HYPHENATED_COMPOUND: return UPN_IS_SPELL_HYPHENATED_COMPOUND; case EID_WORDS_WITH_DIGITS: return UPN_IS_SPELL_WITH_DIGITS; case EID_SPELL_SPECIAL: return UPN_IS_SPELL_SPECIAL; case EID_NUM_MIN_WORDLEN: return UPN_HYPH_MIN_WORD_LENGTH; @@ -322,6 +333,22 @@ struct ServiceInfo_Impl ServiceInfo_Impl() : bConfigured(false) {} }; +struct Locale_less +{ + bool operator()(const css::lang::Locale& lhs, const css::lang::Locale& rhs) const + { + if (lhs.Language < rhs.Language) + return true; + if (lhs.Language > rhs.Language) + return false; + if (lhs.Country < rhs.Country) + return true; + if (lhs.Country > rhs.Country) + return false; + return lhs.Variant < rhs.Variant; + } +}; + } typedef std::vector< ServiceInfo_Impl > ServiceInfoArr; @@ -336,7 +363,7 @@ class SvxLinguData_Impl ServiceInfoArr aDisplayServiceArr; sal_uInt32 nDisplayServices; - Sequence< Locale > aAllServiceLocales; + std::set<Locale, Locale_less> aAllServiceLocales; LangImplNameTable aCfgSpellTable; LangImplNameTable aCfgHyphTable; LangImplNameTable aCfgThesTable; @@ -355,7 +382,7 @@ public: void SetChecked( const Sequence< OUString > &rConfiguredServices ); void Reconfigure( std::u16string_view rDisplayName, bool bEnable ); - const Sequence<Locale> & GetAllSupportedLocales() const { return aAllServiceLocales; } + const auto& GetAllSupportedLocales() const { return aAllServiceLocales; } LangImplNameTable & GetSpellTable() { return aCfgSpellTable; } LangImplNameTable & GetHyphTable() { return aCfgHyphTable; } @@ -413,12 +440,12 @@ Sequence< OUString > SvxLinguData_Impl::GetSortedImplNames( LanguageType nLang, if (pTable->count( nLang )) aRes = (*pTable)[ nLang ]; // add configured services sal_Int32 nIdx = aRes.getLength(); - DBG_ASSERT( static_cast<sal_Int32>(nDisplayServices) >= nIdx, "size mismatch" ); + DBG_ASSERT( nDisplayServices >= o3tl::make_unsigned(nIdx), "size mismatch" ); aRes.realloc( nDisplayServices ); OUString *pRes = aRes.getArray(); // add not configured services - for (sal_Int32 i = 0; i < static_cast<sal_Int32>(nDisplayServices); ++i) + for (sal_uInt32 i = 0; i < nDisplayServices; ++i) { const ServiceInfo_Impl &rInfo = aDisplayServiceArr[ i ]; OUString aImplName; @@ -461,37 +488,6 @@ ServiceInfo_Impl * SvxLinguData_Impl::GetInfoByImplName( std::u16string_view rSv return nullptr; } - -static void lcl_MergeLocales(Sequence< Locale >& aAllLocales, const Sequence< Locale >& rAdd) -{ - Sequence<Locale> aLocToAdd(rAdd.getLength()); - Locale* pLocToAdd = aLocToAdd.getArray(); - sal_Int32 nFound = 0; - for(const Locale& i : rAdd) - { - bool bFound = false; - for(const Locale& j : std::as_const(aAllLocales)) - { - if (i.Language == j.Language && - i.Country == j.Country && - i.Variant == j.Variant) - { - bFound = true; - break; - } - } - if(!bFound) - { - pLocToAdd[nFound++] = i; - } - } - sal_Int32 nLength = aAllLocales.getLength(); - aAllLocales.realloc( nLength + nFound); - Locale* pAllLocales2 = aAllLocales.getArray(); - for(sal_Int32 i = 0; i < nFound; i++) - pAllLocales2[nLength++] = pLocToAdd[i]; -} - static void lcl_MergeDisplayArray( SvxLinguData_Impl &rData, const ServiceInfo_Impl &rToAdd ) @@ -552,9 +548,12 @@ SvxLinguData_Impl::SvxLinguData_Impl() : uno::Reference< XComponentContext > xContext = ::comphelper::getProcessComponentContext(); xLinguSrvcMgr = LinguServiceManager::create(xContext); - const Locale& rCurrentLocale = Application::GetSettings().GetLanguageTag().getLocale(); - Sequence<Any> aArgs(2);//second arguments has to be empty! - aArgs.getArray()[0] <<= LinguMgr::GetLinguPropertySet(); + const Locale& rCurrentLocale = Application::GetSettings().GetUILanguageTag().getLocale(); + Sequence<Any> aArgs + { + Any(LinguMgr::GetLinguPropertySet()), + Any() // second argument has to be empty! + }; //read spell checker const Sequence< OUString > aSpellNames = xLinguSrvcMgr->getAvailableServices( @@ -575,7 +574,7 @@ SvxLinguData_Impl::SvxLinguData_Impl() : //! suppress display of entries with no supported languages (see feature 110994) if (aLocales.hasElements()) { - lcl_MergeLocales( aAllServiceLocales, aLocales ); + aAllServiceLocales.insert(aLocales.begin(), aLocales.end()); lcl_MergeDisplayArray( *this, aInfo ); } } @@ -598,7 +597,7 @@ SvxLinguData_Impl::SvxLinguData_Impl() : //! suppress display of entries with no supported languages (see feature 110994) if (aLocales.hasElements()) { - lcl_MergeLocales( aAllServiceLocales, aLocales ); + aAllServiceLocales.insert(aLocales.begin(), aLocales.end()); lcl_MergeDisplayArray( *this, aInfo ); } } @@ -620,7 +619,7 @@ SvxLinguData_Impl::SvxLinguData_Impl() : //! suppress display of entries with no supported languages (see feature 110994) if (aLocales.hasElements()) { - lcl_MergeLocales( aAllServiceLocales, aLocales ); + aAllServiceLocales.insert(aLocales.begin(), aLocales.end()); lcl_MergeDisplayArray( *this, aInfo ); } } @@ -642,13 +641,13 @@ SvxLinguData_Impl::SvxLinguData_Impl() : //! suppress display of entries with no supported languages (see feature 110994) if (aLocales.hasElements()) { - lcl_MergeLocales( aAllServiceLocales, aLocales ); + aAllServiceLocales.insert(aLocales.begin(), aLocales.end()); lcl_MergeDisplayArray( *this, aInfo ); } } Sequence< OUString > aCfgSvcs; - for(auto const & locale : std::as_const(aAllServiceLocales)) + for (auto const& locale : aAllServiceLocales) { LanguageType nLang = LanguageTag::convertToLanguageType( locale ); @@ -821,16 +820,18 @@ void SvxLinguData_Impl::Reconfigure( std::u16string_view rDisplayName, bool bEna SvxLinguTabPage::SvxLinguTabPage(weld::Container* pPage, weld::DialogController* pController, const SfxItemSet& rSet) : SfxTabPage(pPage, pController, "cui/ui/optlingupage.ui", "OptLinguPage", &rSet) - , sCapitalWords (CuiResId(RID_SVXSTR_CAPITAL_WORDS)) - , sWordsWithDigits(CuiResId(RID_SVXSTR_WORDS_WITH_DIGITS)) - , sSpellSpecial (CuiResId(RID_SVXSTR_SPELL_SPECIAL)) - , sSpellAuto (CuiResId(RID_SVXSTR_SPELL_AUTO)) - , sGrammarAuto (CuiResId(RID_SVXSTR_GRAMMAR_AUTO)) - , sNumMinWordlen (CuiResId(RID_SVXSTR_NUM_MIN_WORDLEN)) - , sNumPreBreak (CuiResId(RID_SVXSTR_NUM_PRE_BREAK)) - , sNumPostBreak (CuiResId(RID_SVXSTR_NUM_POST_BREAK)) - , sHyphAuto (CuiResId(RID_SVXSTR_HYPH_AUTO)) - , sHyphSpecial (CuiResId(RID_SVXSTR_HYPH_SPECIAL)) + , sCapitalWords (CuiResId(RID_CUISTR_CAPITAL_WORDS)) + , sWordsWithDigits(CuiResId(RID_CUISTR_WORDS_WITH_DIGITS)) + , sSpellSpecial (CuiResId(RID_CUISTR_SPELL_SPECIAL)) + , sSpellAuto (CuiResId(RID_CUISTR_SPELL_AUTO)) + , sSpellClosedCompound (CuiResId(RID_CUISTR_SPELL_CLOSED_COMPOUND)) + , sSpellHyphenatedCompound (CuiResId(RID_CUISTR_SPELL_HYPHENATED_COMPOUND)) + , sGrammarAuto (CuiResId(RID_CUISTR_GRAMMAR_AUTO)) + , sNumMinWordlen (CuiResId(RID_CUISTR_NUM_MIN_WORDLEN)) + , sNumPreBreak (CuiResId(RID_CUISTR_NUM_PRE_BREAK)) + , sNumPostBreak (CuiResId(RID_CUISTR_NUM_POST_BREAK)) + , sHyphAuto (CuiResId(RID_CUISTR_HYPH_AUTO)) + , sHyphSpecial (CuiResId(RID_CUISTR_HYPH_SPECIAL)) , nUPN_HYPH_MIN_WORD_LENGTH(-1) , nUPN_HYPH_MIN_LEADING(-1) , nUPN_HYPH_MIN_TRAILING(-1) @@ -845,6 +846,7 @@ SvxLinguTabPage::SvxLinguTabPage(weld::Container* pPage, weld::DialogController* , m_xLinguDicsDelPB(m_xBuilder->weld_button("lingudictsdelete")) , m_xLinguOptionsCLB(m_xBuilder->weld_tree_view("linguoptions")) , m_xLinguOptionsEditPB(m_xBuilder->weld_button("linguoptionsedit")) + , m_xMoreDictsBox(m_xBuilder->weld_box("moredictsbox")) , m_xMoreDictsLink(m_xBuilder->weld_link_button("moredictslink")) { m_xLinguModulesCLB->enable_toggle_buttons(weld::ColumnToggleType::Check); @@ -870,7 +872,15 @@ SvxLinguTabPage::SvxLinguTabPage(weld::Container* pPage, weld::DialogController* m_xMoreDictsLink->connect_activate_link(LINK(this, SvxLinguTabPage, OnLinkClick)); if (officecfg::Office::Security::Hyperlinks::Open::get() == SvtExtendedSecurityOptions::OPEN_NEVER) - m_xMoreDictsLink->hide(); + m_xMoreDictsBox->hide(); + + if (comphelper::LibreOfficeKit::isActive()) + { + // hide User-defined Dictionaries part + m_xBuilder->weld_frame("dictsframe")->hide(); + // hide Get more dictionaries URL + icon + m_xMoreDictsBox->hide(); + } xProp = LinguMgr::GetLinguPropertySet(); xDicList.set( LinguMgr::GetDictionaryList() ); @@ -914,6 +924,22 @@ std::unique_ptr<SfxTabPage> SvxLinguTabPage::Create( weld::Container* pPage, wel return std::make_unique<SvxLinguTabPage>( pPage, pController, *rAttrSet ); } +OUString SvxLinguTabPage::GetAllStrings() +{ + OUString sAllStrings; + OUString labels[] = { "lingumodulesft", "lingudictsft", "label4" }; + + for (const auto& label : labels) + { + if (const auto& pString = m_xBuilder->weld_label(label)) + sAllStrings += pString->get_label() + " "; + } + + sAllStrings += m_xMoreDictsLink->get_label() + " "; + + return sAllStrings.replaceAll("_", ""); +} + bool SvxLinguTabPage::FillItemSet( SfxItemSet* rCoreSet ) { bool bModified = true; // !!!! @@ -997,12 +1023,8 @@ bool SvxLinguTabPage::FillItemSet( SfxItemSet* rCoreSet ) if (LinguMgr::GetIgnoreAllList() == xDic) bChecked = true; xDic->setActive( bChecked ); - if (bChecked) - { - OUString aDicName( xDic->getName() ); - pActiveDic[ nActiveDics++ ] = aDicName; - } + pActiveDic[nActiveDics++] = xDic->getName(); } } } @@ -1041,7 +1063,7 @@ bool SvxLinguTabPage::FillItemSet( SfxItemSet* rCoreSet ) OptionsUserData aPostBreakData(m_xLinguOptionsCLB->get_id(EID_NUM_POST_BREAK).toUInt32()); if ( aPreBreakData.IsModified() || aPostBreakData.IsModified() ) { - SfxHyphenRegionItem aHyp( GetWhich( SID_ATTR_HYPHENREGION ) ); + SfxHyphenRegionItem aHyp( SID_ATTR_HYPHENREGION ); aHyp.GetMinLead() = static_cast<sal_uInt8>(aPreBreakData.GetNumericValue()); aHyp.GetMinTrail() = static_cast<sal_uInt8>(aPostBreakData.GetNumericValue()); rCoreSet->Put( aHyp ); @@ -1052,8 +1074,7 @@ bool SvxLinguTabPage::FillItemSet( SfxItemSet* rCoreSet ) const SfxPoolItem* pOld = GetOldItem( *rCoreSet, SID_AUTOSPELL_CHECK ); if ( !pOld || static_cast<const SfxBoolItem*>(pOld)->GetValue() != bNewAutoCheck ) { - rCoreSet->Put( SfxBoolItem( GetWhich( SID_AUTOSPELL_CHECK ), - bNewAutoCheck ) ); + rCoreSet->Put( SfxBoolItem( SID_AUTOSPELL_CHECK, bNewAutoCheck ) ); bModified = true; } @@ -1134,7 +1155,7 @@ void SvxLinguTabPage::UpdateModulesBox_Impl() { const ServiceInfo_Impl &rInfo = rAllDispSrvcArr[i]; m_xLinguModulesCLB->append(); - m_xLinguModulesCLB->set_id(i, OUString::number(reinterpret_cast<sal_Int64>(&rInfo))); + m_xLinguModulesCLB->set_id(i, weld::toId(&rInfo)); m_xLinguModulesCLB->set_toggle(i, rInfo.bConfigured ? TRISTATE_TRUE : TRISTATE_FALSE); m_xLinguModulesCLB->set_text(i, rInfo.sDisplayName, 0); } @@ -1178,6 +1199,7 @@ void SvxLinguTabPage::Reset( const SfxItemSet* rSet ) m_xLinguOptionsCLB->set_toggle(nEntry, bVal ? TRISTATE_TRUE : TRISTATE_FALSE); m_xLinguOptionsCLB->set_text(nEntry, sSpellAuto, 0); m_xLinguOptionsCLB->set_id(nEntry, OUString::number(nUserData)); + m_xLinguOptionsCLB->set_sensitive(nEntry, !aLngCfg.IsReadOnly(UPN_IS_SPELL_AUTO)); m_xLinguOptionsCLB->append(); ++nEntry; @@ -1187,6 +1209,7 @@ void SvxLinguTabPage::Reset( const SfxItemSet* rSet ) m_xLinguOptionsCLB->set_toggle(nEntry, bVal ? TRISTATE_TRUE : TRISTATE_FALSE); m_xLinguOptionsCLB->set_text(nEntry, sGrammarAuto, 0); m_xLinguOptionsCLB->set_id(nEntry, OUString::number(nUserData)); + m_xLinguOptionsCLB->set_sensitive(nEntry, !aLngCfg.IsReadOnly(UPN_IS_GRAMMAR_AUTO)); m_xLinguOptionsCLB->append(); ++nEntry; @@ -1196,6 +1219,7 @@ void SvxLinguTabPage::Reset( const SfxItemSet* rSet ) m_xLinguOptionsCLB->set_toggle(nEntry, bVal ? TRISTATE_TRUE : TRISTATE_FALSE); m_xLinguOptionsCLB->set_text(nEntry, sCapitalWords, 0); m_xLinguOptionsCLB->set_id(nEntry, OUString::number(nUserData)); + m_xLinguOptionsCLB->set_sensitive(nEntry, !aLngCfg.IsReadOnly(UPN_IS_SPELL_UPPER_CASE)); m_xLinguOptionsCLB->append(); ++nEntry; @@ -1205,6 +1229,27 @@ void SvxLinguTabPage::Reset( const SfxItemSet* rSet ) m_xLinguOptionsCLB->set_toggle(nEntry, bVal ? TRISTATE_TRUE : TRISTATE_FALSE); m_xLinguOptionsCLB->set_text(nEntry, sWordsWithDigits, 0); m_xLinguOptionsCLB->set_id(nEntry, OUString::number(nUserData)); + m_xLinguOptionsCLB->set_sensitive(nEntry, !aLngCfg.IsReadOnly(UPN_IS_SPELL_WITH_DIGITS)); + + m_xLinguOptionsCLB->append(); + ++nEntry; + + aLngCfg.GetProperty( UPN_IS_SPELL_CLOSED_COMPOUND ) >>= bVal; + nUserData = OptionsUserData( EID_SPELL_CLOSED_COMPOUND, false, 0, true, bVal).GetUserData(); + m_xLinguOptionsCLB->set_toggle(nEntry, bVal ? TRISTATE_TRUE : TRISTATE_FALSE); + m_xLinguOptionsCLB->set_text(nEntry, sSpellClosedCompound, 0); + m_xLinguOptionsCLB->set_id(nEntry, OUString::number(nUserData)); + m_xLinguOptionsCLB->set_sensitive(nEntry, !aLngCfg.IsReadOnly(UPN_IS_SPELL_CLOSED_COMPOUND)); + + m_xLinguOptionsCLB->append(); + ++nEntry; + + aLngCfg.GetProperty( UPN_IS_SPELL_HYPHENATED_COMPOUND ) >>= bVal; + nUserData = OptionsUserData( EID_SPELL_HYPHENATED_COMPOUND, false, 0, true, bVal).GetUserData(); + m_xLinguOptionsCLB->set_toggle(nEntry, bVal ? TRISTATE_TRUE : TRISTATE_FALSE); + m_xLinguOptionsCLB->set_text(nEntry, sSpellHyphenatedCompound, 0); + m_xLinguOptionsCLB->set_id(nEntry, OUString::number(nUserData)); + m_xLinguOptionsCLB->set_sensitive(nEntry, !aLngCfg.IsReadOnly(UPN_IS_SPELL_HYPHENATED_COMPOUND)); m_xLinguOptionsCLB->append(); ++nEntry; @@ -1214,6 +1259,7 @@ void SvxLinguTabPage::Reset( const SfxItemSet* rSet ) m_xLinguOptionsCLB->set_toggle(nEntry, bVal ? TRISTATE_TRUE : TRISTATE_FALSE); m_xLinguOptionsCLB->set_text(nEntry, sSpellSpecial, 0); m_xLinguOptionsCLB->set_id(nEntry, OUString::number(nUserData)); + m_xLinguOptionsCLB->set_sensitive(nEntry, !aLngCfg.IsReadOnly(UPN_IS_SPELL_SPECIAL)); m_xLinguOptionsCLB->append(); ++nEntry; @@ -1222,12 +1268,12 @@ void SvxLinguTabPage::Reset( const SfxItemSet* rSet ) nUserData = OptionsUserData( EID_NUM_MIN_WORDLEN, true, static_cast<sal_uInt16>(nVal), false, false).GetUserData(); m_xLinguOptionsCLB->set_text(nEntry, sNumMinWordlen + " " + OUString::number(nVal), 0); m_xLinguOptionsCLB->set_id(nEntry, OUString::number(nUserData)); + m_xLinguOptionsCLB->set_sensitive(nEntry, !aLngCfg.IsReadOnly(UPN_HYPH_MIN_WORD_LENGTH)); nUPN_HYPH_MIN_WORD_LENGTH = nEntry; const SfxHyphenRegionItem *pHyp = nullptr; - sal_uInt16 nWhich = GetWhich( SID_ATTR_HYPHENREGION ); - if ( rSet->GetItemState( nWhich, false ) == SfxItemState::SET ) - pHyp = &static_cast<const SfxHyphenRegionItem &>( rSet->Get( nWhich ) ); + if ( rSet->GetItemState( SID_ATTR_HYPHENREGION, false ) == SfxItemState::SET ) + pHyp = & rSet->Get( SID_ATTR_HYPHENREGION ); m_xLinguOptionsCLB->append(); ++nEntry; @@ -1238,6 +1284,7 @@ void SvxLinguTabPage::Reset( const SfxItemSet* rSet ) nUserData = OptionsUserData( EID_NUM_PRE_BREAK, true, static_cast<sal_uInt16>(nVal), false, false).GetUserData(); m_xLinguOptionsCLB->set_text(nEntry, sNumPreBreak + " " + OUString::number(nVal), 0); m_xLinguOptionsCLB->set_id(nEntry, OUString::number(nUserData)); + m_xLinguOptionsCLB->set_sensitive(nEntry, !aLngCfg.IsReadOnly(UPN_HYPH_MIN_LEADING)); nUPN_HYPH_MIN_LEADING = nEntry; m_xLinguOptionsCLB->append(); @@ -1249,6 +1296,7 @@ void SvxLinguTabPage::Reset( const SfxItemSet* rSet ) nUserData = OptionsUserData( EID_NUM_POST_BREAK, true, static_cast<sal_uInt16>(nVal), false, false).GetUserData(); m_xLinguOptionsCLB->set_text(nEntry, sNumPostBreak + " " + OUString::number(nVal), 0); m_xLinguOptionsCLB->set_id(nEntry, OUString::number(nUserData)); + m_xLinguOptionsCLB->set_sensitive(nEntry, !aLngCfg.IsReadOnly(UPN_HYPH_MIN_TRAILING)); nUPN_HYPH_MIN_TRAILING = nEntry; m_xLinguOptionsCLB->append(); @@ -1259,6 +1307,7 @@ void SvxLinguTabPage::Reset( const SfxItemSet* rSet ) m_xLinguOptionsCLB->set_toggle(nEntry, bVal ? TRISTATE_TRUE : TRISTATE_FALSE); m_xLinguOptionsCLB->set_text(nEntry, sHyphAuto, 0); m_xLinguOptionsCLB->set_id(nEntry, OUString::number(nUserData)); + m_xLinguOptionsCLB->set_sensitive(nEntry, !aLngCfg.IsReadOnly(UPN_IS_HYPH_AUTO)); m_xLinguOptionsCLB->append(); ++nEntry; @@ -1268,6 +1317,7 @@ void SvxLinguTabPage::Reset( const SfxItemSet* rSet ) m_xLinguOptionsCLB->set_toggle(nEntry, bVal ? TRISTATE_TRUE : TRISTATE_FALSE); m_xLinguOptionsCLB->set_text(nEntry, sHyphSpecial, 0); m_xLinguOptionsCLB->set_id(nEntry, OUString::number(nUserData)); + m_xLinguOptionsCLB->set_sensitive(nEntry, !aLngCfg.IsReadOnly(UPN_IS_HYPH_SPECIAL)); m_xLinguOptionsCLB->thaw(); @@ -1280,6 +1330,15 @@ void SvxLinguTabPage::Reset( const SfxItemSet* rSet ) m_xLinguDicsCLB->get_height_rows(5)); m_xLinguOptionsCLB->set_size_request(m_xLinguOptionsCLB->get_preferred_size().Width(), m_xLinguOptionsCLB->get_height_rows(5)); + + if (officecfg::Office::Linguistic::General::DictionaryList::ActiveDictionaries::isReadOnly()) + { + m_xLinguDicsFT->set_sensitive(false); + m_xLinguDicsCLB->set_sensitive(false); + m_xLinguDicsNewPB->set_sensitive(false); + m_xLinguDicsEditPB->set_sensitive(false); + m_xLinguDicsDelPB->set_sensitive(false); + } } IMPL_LINK(SvxLinguTabPage, BoxDoubleClickHdl_Impl, weld::TreeView&, rBox, bool) @@ -1326,20 +1385,18 @@ IMPL_LINK(SvxLinguTabPage, ClickHdl_Impl, weld::Button&, rBtn, void) if (!pLinguData) pLinguData.reset( new SvxLinguData_Impl ); - SvxLinguData_Impl aOldLinguData( *pLinguData ); + SvxLinguData_Impl aOldLinguData(*pLinguData); SvxEditModulesDlg aDlg(GetFrameWeld(), *pLinguData); if (aDlg.run() != RET_OK) - *pLinguData = aOldLinguData; + *pLinguData = std::move(aOldLinguData); // evaluate new status of 'bConfigured' flag sal_uInt32 nLen = pLinguData->GetDisplayServiceCount(); for (sal_uInt32 i = 0; i < nLen; ++i) pLinguData->GetDisplayServiceArray()[i].bConfigured = false; - const Locale* pAllLocales = pLinguData->GetAllSupportedLocales().getConstArray(); - sal_Int32 nLocales = pLinguData->GetAllSupportedLocales().getLength(); - for (sal_Int32 k = 0; k < nLocales; ++k) + for (const auto& locale : pLinguData->GetAllSupportedLocales()) { - LanguageType nLang = LanguageTag::convertToLanguageType( pAllLocales[k] ); + LanguageType nLang = LanguageTag::convertToLanguageType(locale); if (pLinguData->GetSpellTable().count( nLang )) pLinguData->SetChecked( pLinguData->GetSpellTable()[ nLang ] ); if (pLinguData->GetGrammarTable().count( nLang )) @@ -1482,7 +1539,7 @@ IMPL_LINK(SvxLinguTabPage, ClickHdl_Impl, weld::Button&, rBtn, void) } else { - OSL_FAIL( "rBtn unexpected value" ); + SAL_WARN("cui.options", "rBtn unexpected value"); } } @@ -1514,7 +1571,7 @@ IMPL_LINK(SvxLinguTabPage, SelectHdl_Impl, weld::TreeView&, rBox, void) } else { - OSL_FAIL( "rBox unexpected value" ); + SAL_WARN("cui.options", "rBtn unexpected value"); } } @@ -1526,9 +1583,10 @@ void SvxLinguTabPage::HideGroups( sal_uInt16 nGrp ) m_xLinguModulesCLB->hide(); m_xLinguModulesEditPB->hide(); - if (officecfg::Office::Security::Hyperlinks::Open::get() != SvtExtendedSecurityOptions::OPEN_NEVER) + if (officecfg::Office::Security::Hyperlinks::Open::get() != SvtExtendedSecurityOptions::OPEN_NEVER && + !comphelper::LibreOfficeKit::isActive()) { - m_xMoreDictsLink->show(); + m_xMoreDictsBox->show(); } } } @@ -1541,10 +1599,10 @@ IMPL_STATIC_LINK_NOARG(SvxLinguTabPage, OnLinkClick, weld::LinkButton&, bool) SvxEditModulesDlg::SvxEditModulesDlg(weld::Window* pParent, SvxLinguData_Impl& rData) : GenericDialogController(pParent, "cui/ui/editmodulesdialog.ui", "EditModulesDialog") - , sSpell(CuiResId(RID_SVXSTR_SPELL)) - , sHyph(CuiResId(RID_SVXSTR_HYPH)) - , sThes(CuiResId(RID_SVXSTR_THES)) - , sGrammar(CuiResId(RID_SVXSTR_GRAMMAR)) + , sSpell(CuiResId(RID_CUISTR_SPELL)) + , sHyph(CuiResId(RID_CUISTR_HYPH)) + , sThes(CuiResId(RID_CUISTR_THES)) + , sGrammar(CuiResId(RID_CUISTR_GRAMMAR)) , rLinguData(rData) , m_xModulesCLB(m_xBuilder->weld_tree_view("lingudicts")) , m_xPrioUpPB(m_xBuilder->weld_button("up")) @@ -1580,17 +1638,20 @@ SvxEditModulesDlg::SvxEditModulesDlg(weld::Window* pParent, SvxLinguData_Impl& r m_xLanguageLB->SetLanguageList(SvxLanguageListFlags::EMPTY, false, false, true); //fill language box - const Sequence< Locale >& rLoc = rLinguData.GetAllSupportedLocales(); - for (Locale const & locale : rLoc) - { - LanguageType nLang = LanguageTag::convertToLanguageType( locale ); - m_xLanguageLB->InsertLanguage(nLang); - } + const auto& rLoc = rLinguData.GetAllSupportedLocales(); + std::vector<LanguageType> aLanguages; + aLanguages.reserve(rLoc.size()); + std::transform(rLoc.begin(), rLoc.end(), std::back_inserter(aLanguages), + [](Locale const& locale) { return LanguageTag::convertToLanguageType(locale); }); + m_xLanguageLB->InsertLanguages(aLanguages); LanguageType eSysLang = MsLangId::getConfiguredSystemLanguage(); m_xLanguageLB->set_active_id( eSysLang ); if (m_xLanguageLB->get_active_id() != eSysLang) m_xLanguageLB->set_active(0); + css::uno::Reference < css::uno::XComponentContext > xContext(::comphelper::getProcessComponentContext()); + m_xReadWriteAccess = css::configuration::ReadWriteAccess::create(xContext, "*"); + m_xLanguageLB->connect_changed( LINK( this, SvxEditModulesDlg, LangSelectListBoxHdl_Impl )); LangSelectHdl_Impl(m_xLanguageLB.get()); } @@ -1598,7 +1659,7 @@ SvxEditModulesDlg::SvxEditModulesDlg(weld::Window* pParent, SvxLinguData_Impl& r SvxEditModulesDlg::~SvxEditModulesDlg() { for (int i = 0, nEntryCount = m_xModulesCLB->n_children(); i < nEntryCount; ++i) - delete reinterpret_cast<ModuleUserData_Impl*>(m_xModulesCLB->get_id(i).toInt64()); + delete weld::fromId<ModuleUserData_Impl*>(m_xModulesCLB->get_id(i)); } IMPL_LINK( SvxEditModulesDlg, SelectHdl_Impl, weld::TreeView&, rBox, void ) @@ -1609,16 +1670,16 @@ IMPL_LINK( SvxEditModulesDlg, SelectHdl_Impl, weld::TreeView&, rBox, void ) bool bDisableUp = true; bool bDisableDown = true; - ModuleUserData_Impl* pData = reinterpret_cast<ModuleUserData_Impl*>(rBox.get_id(nCurPos).toInt64()); + ModuleUserData_Impl* pData = weld::fromId<ModuleUserData_Impl*>(rBox.get_id(nCurPos)); if (!pData->IsParent() && pData->GetType() != TYPE_HYPH) { if (nCurPos < rBox.n_children() - 1) { - bDisableDown = reinterpret_cast<ModuleUserData_Impl*>(rBox.get_id(nCurPos + 1).toInt64())->IsParent(); + bDisableDown = weld::fromId<ModuleUserData_Impl*>(rBox.get_id(nCurPos + 1))->IsParent(); } if (nCurPos > 1) { - bDisableUp = reinterpret_cast<ModuleUserData_Impl*>(rBox.get_id(nCurPos - 1).toInt64())->IsParent(); + bDisableUp = weld::fromId<ModuleUserData_Impl*>(rBox.get_id(nCurPos - 1))->IsParent(); } } m_xPrioUpPB->set_sensitive(!bDisableUp); @@ -1627,7 +1688,7 @@ IMPL_LINK( SvxEditModulesDlg, SelectHdl_Impl, weld::TreeView&, rBox, void ) IMPL_LINK( SvxEditModulesDlg, BoxCheckButtonHdl_Impl, const weld::TreeView::iter_col&, rRowCol, void ) { - ModuleUserData_Impl* pData = reinterpret_cast<ModuleUserData_Impl*>(m_xModulesCLB->get_id(rRowCol.first).toInt64()); + ModuleUserData_Impl* pData = weld::fromId<ModuleUserData_Impl*>(m_xModulesCLB->get_id(rRowCol.first)); if (pData->IsParent() || pData->GetType() != TYPE_HYPH) return; @@ -1636,7 +1697,7 @@ IMPL_LINK( SvxEditModulesDlg, BoxCheckButtonHdl_Impl, const weld::TreeView::iter auto nPos = m_xModulesCLB->get_iter_index_in_parent(rRowCol.first); for (int i = 0, nEntryCount = m_xModulesCLB->n_children(); i < nEntryCount; ++i) { - pData = reinterpret_cast<ModuleUserData_Impl*>(m_xModulesCLB->get_id(i).toInt64()); + pData = weld::fromId<ModuleUserData_Impl*>(m_xModulesCLB->get_id(i)); if (!pData->IsParent() && pData->GetType() == TYPE_HYPH && i != nPos) { m_xModulesCLB->set_toggle(i, TRISTATE_FALSE); @@ -1667,7 +1728,7 @@ void SvxEditModulesDlg::LangSelectHdl_Impl(const SvxLanguageBox* pBox) bool bChanged = false; for (int i = 0, nEntryCount = m_xModulesCLB->n_children(); i < nEntryCount; ++i) { - ModuleUserData_Impl* pData = reinterpret_cast<ModuleUserData_Impl*>(m_xModulesCLB->get_id(i).toInt64()); + ModuleUserData_Impl* pData = weld::fromId<ModuleUserData_Impl*>(m_xModulesCLB->get_id(i)); if (pData->IsParent()) { if (bChanged) @@ -1710,7 +1771,7 @@ void SvxEditModulesDlg::LangSelectHdl_Impl(const SvxLanguageBox* pBox) } for (int i = 0, nEntryCount = m_xModulesCLB->n_children(); i < nEntryCount; ++i) - delete reinterpret_cast<ModuleUserData_Impl*>(m_xModulesCLB->get_id(i).toInt64()); + delete weld::fromId<ModuleUserData_Impl*>(m_xModulesCLB->get_id(i)); m_xModulesCLB->clear(); // display entries for new selected language @@ -1719,19 +1780,28 @@ void SvxEditModulesDlg::LangSelectHdl_Impl(const SvxLanguageBox* pBox) { sal_Int32 n; ServiceInfo_Impl* pInfo; + bool bReadOnly = false; int nRow = 0; // spellchecker entries ModuleUserData_Impl* pUserData = new ModuleUserData_Impl( OUString(), true, false, TYPE_SPELL, 0 ); - OUString sId(OUString::number(reinterpret_cast<sal_Int64>(pUserData))); + OUString sId(weld::toId(pUserData)); m_xModulesCLB->append(nullptr); m_xModulesCLB->set_id(nRow, sId); m_xModulesCLB->set_text(nRow, sSpell, 0); m_xModulesCLB->set_text_emphasis(nRow, true, 0); ++nRow; + OUString aLangNodeName = LanguageTag::convertToBcp47(aCurLocale); + OUString aConfigPath = officecfg::Office::Linguistic::ServiceManager::path() + "/SpellCheckerList/" + aLangNodeName; + if (m_xReadWriteAccess->hasPropertyByHierarchicalName(aConfigPath)) + { + css::beans::Property aProperty = m_xReadWriteAccess->getPropertyByHierarchicalName(aConfigPath); + bReadOnly = (aProperty.Attributes & css::beans::PropertyAttribute::READONLY) != 0; + } + Sequence< OUString > aNames( rLinguData.GetSortedImplNames( eCurLanguage, TYPE_SPELL ) ); const OUString *pName = aNames.getConstArray(); sal_Int32 nNames = aNames.getLength(); @@ -1761,13 +1831,14 @@ void SvxEditModulesDlg::LangSelectHdl_Impl(const SvxLanguageBox* pBox) const bool bCheck = bHasLang && lcl_SeqGetEntryPos( rTable[ eCurLanguage ], aImplName ) >= 0; pUserData = new ModuleUserData_Impl( aImplName, false, bCheck, TYPE_SPELL, static_cast<sal_uInt8>(nLocalIndex++) ); - sId = OUString::number(reinterpret_cast<sal_Int64>(pUserData)); + sId = weld::toId(pUserData); m_xModulesCLB->append(nullptr); m_xModulesCLB->set_id(nRow, sId); m_xModulesCLB->set_toggle(nRow, bCheck ? TRISTATE_TRUE : TRISTATE_FALSE); m_xModulesCLB->set_text(nRow, aTxt, 0); m_xModulesCLB->set_text_emphasis(nRow, false, 0); + m_xModulesCLB->set_sensitive(nRow, !bReadOnly); ++nRow; } } @@ -1775,13 +1846,20 @@ void SvxEditModulesDlg::LangSelectHdl_Impl(const SvxLanguageBox* pBox) // grammar checker entries pUserData = new ModuleUserData_Impl( OUString(), true, false, TYPE_GRAMMAR, 0 ); - sId = OUString::number(reinterpret_cast<sal_Int64>(pUserData)); + sId = weld::toId(pUserData); m_xModulesCLB->append(nullptr); m_xModulesCLB->set_id(nRow, sId); m_xModulesCLB->set_text(nRow, sGrammar, 0); m_xModulesCLB->set_text_emphasis(nRow, true, 0); ++nRow; + aConfigPath = officecfg::Office::Linguistic::ServiceManager::path() + "/GrammarCheckerList/" + aLangNodeName; + if (m_xReadWriteAccess->hasPropertyByHierarchicalName(aConfigPath)) + { + css::beans::Property aProperty = m_xReadWriteAccess->getPropertyByHierarchicalName(aConfigPath); + bReadOnly = (aProperty.Attributes & css::beans::PropertyAttribute::READONLY) != 0; + } + aNames = rLinguData.GetSortedImplNames( eCurLanguage, TYPE_GRAMMAR ); pName = aNames.getConstArray(); nNames = aNames.getLength(); @@ -1812,13 +1890,14 @@ void SvxEditModulesDlg::LangSelectHdl_Impl(const SvxLanguageBox* pBox) pUserData = new ModuleUserData_Impl( aImplName, false, bCheck, TYPE_GRAMMAR, static_cast<sal_uInt8>(nLocalIndex++) ); - sId = OUString::number(reinterpret_cast<sal_Int64>(pUserData)); + sId = weld::toId(pUserData); m_xModulesCLB->append(nullptr); m_xModulesCLB->set_id(nRow, sId); m_xModulesCLB->set_toggle(nRow, bCheck ? TRISTATE_TRUE : TRISTATE_FALSE); m_xModulesCLB->set_text(nRow, aTxt, 0); m_xModulesCLB->set_text_emphasis(nRow, false, 0); + m_xModulesCLB->set_sensitive(nRow, !bReadOnly); ++nRow; } } @@ -1826,13 +1905,20 @@ void SvxEditModulesDlg::LangSelectHdl_Impl(const SvxLanguageBox* pBox) // hyphenator entries pUserData = new ModuleUserData_Impl( OUString(), true, false, TYPE_HYPH, 0 ); - sId = OUString::number(reinterpret_cast<sal_Int64>(pUserData)); + sId = weld::toId(pUserData); m_xModulesCLB->append(nullptr); m_xModulesCLB->set_id(nRow, sId); m_xModulesCLB->set_text(nRow, sHyph, 0); m_xModulesCLB->set_text_emphasis(nRow, true, 0); ++nRow; + aConfigPath = officecfg::Office::Linguistic::ServiceManager::path() + "/HyphenatorList/" + aLangNodeName; + if (m_xReadWriteAccess->hasPropertyByHierarchicalName(aConfigPath)) + { + css::beans::Property aProperty = m_xReadWriteAccess->getPropertyByHierarchicalName(aConfigPath); + bReadOnly = (aProperty.Attributes & css::beans::PropertyAttribute::READONLY) != 0; + } + aNames = rLinguData.GetSortedImplNames( eCurLanguage, TYPE_HYPH ); pName = aNames.getConstArray(); nNames = aNames.getLength(); @@ -1862,13 +1948,14 @@ void SvxEditModulesDlg::LangSelectHdl_Impl(const SvxLanguageBox* pBox) const bool bCheck = bHasLang && lcl_SeqGetEntryPos( rTable[ eCurLanguage ], aImplName ) >= 0; pUserData = new ModuleUserData_Impl( aImplName, false, bCheck, TYPE_HYPH, static_cast<sal_uInt8>(nLocalIndex++) ); - sId = OUString::number(reinterpret_cast<sal_Int64>(pUserData)); + sId = weld::toId(pUserData); m_xModulesCLB->append(nullptr); m_xModulesCLB->set_id(nRow, sId); m_xModulesCLB->set_toggle(nRow, bCheck ? TRISTATE_TRUE : TRISTATE_FALSE); m_xModulesCLB->set_text(nRow, aTxt, 0); m_xModulesCLB->set_text_emphasis(nRow, false, 0); + m_xModulesCLB->set_sensitive(nRow, !bReadOnly); ++nRow; } } @@ -1876,13 +1963,20 @@ void SvxEditModulesDlg::LangSelectHdl_Impl(const SvxLanguageBox* pBox) // thesaurus entries pUserData = new ModuleUserData_Impl( OUString(), true, false, TYPE_THES, 0 ); - sId = OUString::number(reinterpret_cast<sal_Int64>(pUserData)); + sId = weld::toId(pUserData); m_xModulesCLB->append(nullptr); m_xModulesCLB->set_id(nRow, sId); m_xModulesCLB->set_text(nRow, sThes, 0); m_xModulesCLB->set_text_emphasis(nRow, true, 0); ++nRow; + aConfigPath = officecfg::Office::Linguistic::ServiceManager::path() + "/ThesaurusList/" + aLangNodeName; + if (m_xReadWriteAccess->hasPropertyByHierarchicalName(aConfigPath)) + { + css::beans::Property aProperty = m_xReadWriteAccess->getPropertyByHierarchicalName(aConfigPath); + bReadOnly = (aProperty.Attributes & css::beans::PropertyAttribute::READONLY) != 0; + } + aNames = rLinguData.GetSortedImplNames( eCurLanguage, TYPE_THES ); pName = aNames.getConstArray(); nNames = aNames.getLength(); @@ -1912,13 +2006,14 @@ void SvxEditModulesDlg::LangSelectHdl_Impl(const SvxLanguageBox* pBox) const bool bCheck = bHasLang && lcl_SeqGetEntryPos( rTable[ eCurLanguage ], aImplName ) >= 0; pUserData = new ModuleUserData_Impl( aImplName, false, bCheck, TYPE_THES, static_cast<sal_uInt8>(nLocalIndex++) ); - sId = OUString::number(reinterpret_cast<sal_Int64>(pUserData)); + sId = weld::toId(pUserData); m_xModulesCLB->append(nullptr); m_xModulesCLB->set_id(nRow, sId); m_xModulesCLB->set_toggle(nRow, bCheck ? TRISTATE_TRUE : TRISTATE_FALSE); m_xModulesCLB->set_text(nRow, aTxt, 0); m_xModulesCLB->set_text_emphasis(nRow, false, 0); + m_xModulesCLB->set_sensitive(nRow, !bReadOnly); ++nRow; } } diff --git a/cui/source/options/optopencl.cxx b/cui/source/options/optopencl.cxx index e85ef1d7e23a..129cbc1b01b7 100644 --- a/cui/source/options/optopencl.cxx +++ b/cui/source/options/optopencl.cxx @@ -30,11 +30,13 @@ SvxOpenCLTabPage::SvxOpenCLTabPage(weld::Container* pPage, weld::DialogControlle : SfxTabPage(pPage, pController, "cui/ui/optopenclpage.ui", "OptOpenCLPage", &rSet) , maConfig(OpenCLConfig::get()) , mxUseOpenCL(m_xBuilder->weld_check_button("useopencl")) + , mxUseOpenImg(m_xBuilder->weld_widget("lockuseopencl")) , mxOclUsed(m_xBuilder->weld_label("openclused")) , mxOclNotUsed(m_xBuilder->weld_label("openclnotused")) { mxUseOpenCL->set_active(maConfig.mbUseOpenCL); mxUseOpenCL->set_sensitive(!officecfg::Office::Common::Misc::UseOpenCL::isReadOnly()); + mxUseOpenImg->set_visible(officecfg::Office::Common::Misc::UseOpenCL::isReadOnly()); bool bCLUsed = openclwrapper::GPUEnv::isOpenCLEnabled(); mxOclUsed->set_visible(bCLUsed); @@ -50,6 +52,22 @@ std::unique_ptr<SfxTabPage> SvxOpenCLTabPage::Create(weld::Container* pPage, wel return std::make_unique<SvxOpenCLTabPage>(pPage, pController, *rAttrSet); } +OUString SvxOpenCLTabPage::GetAllStrings() +{ + OUString sAllStrings; + OUString labels[] = { "label1", "openclnotused", "openclused" }; + + for (const auto& label : labels) + { + if (const auto& pString = m_xBuilder->weld_label(label)) + sAllStrings += pString->get_label() + " "; + } + + sAllStrings += mxUseOpenCL->get_label() + " "; + + return sAllStrings.replaceAll("_", ""); +} + bool SvxOpenCLTabPage::FillItemSet( SfxItemSet* ) { bool bModified = false; @@ -81,6 +99,7 @@ void SvxOpenCLTabPage::Reset( const SfxItemSet* ) maConfig = OpenCLConfig::get(); mxUseOpenCL->set_active(maConfig.mbUseOpenCL); + mxUseOpenImg->set_visible(officecfg::Office::Common::Misc::UseOpenCL::isReadOnly()); mxUseOpenCL->save_state(); } diff --git a/cui/source/options/optopencl.hxx b/cui/source/options/optopencl.hxx index f7097d3fdba6..e6414245da8f 100644 --- a/cui/source/options/optopencl.hxx +++ b/cui/source/options/optopencl.hxx @@ -27,6 +27,7 @@ private: OpenCLConfig maConfig; std::unique_ptr<weld::CheckButton> mxUseOpenCL; + std::unique_ptr<weld::Widget> mxUseOpenImg; std::unique_ptr<weld::Label> mxOclUsed; std::unique_ptr<weld::Label> mxOclNotUsed; @@ -34,6 +35,7 @@ public: SvxOpenCLTabPage(weld::Container* pPage, weld::DialogController* pController, const SfxItemSet& rSet); static std::unique_ptr<SfxTabPage> Create( weld::Container* pPage, weld::DialogController* pController, const SfxItemSet* rSet ); virtual ~SvxOpenCLTabPage() override; + virtual OUString GetAllStrings() override; virtual bool FillItemSet( SfxItemSet* rSet ) override; virtual void Reset( const SfxItemSet* rSet ) override; diff --git a/cui/source/options/optpath.cxx b/cui/source/options/optpath.cxx index bdd7db2ca89e..4a410af07c4b 100644 --- a/cui/source/options/optpath.cxx +++ b/cui/source/options/optpath.cxx @@ -36,16 +36,16 @@ #include <com/sun/star/beans/PropertyAttribute.hpp> #include <com/sun/star/ui/dialogs/ExecutableDialogResults.hpp> #include <com/sun/star/ui/dialogs/XAsynchronousExecutableDialog.hpp> -#include <com/sun/star/ui/dialogs/FolderPicker.hpp> -#include <com/sun/star/ui/dialogs/FilePicker.hpp> +#include <com/sun/star/ui/dialogs/XFolderPicker2.hpp> +#include <com/sun/star/ui/dialogs/XFilePicker3.hpp> #include <com/sun/star/ui/dialogs/TemplateDescription.hpp> #include <com/sun/star/util/thePathSettings.hpp> -#include <tools/diagnose_ex.h> +#include <comphelper/diagnose_ex.hxx> #include <sal/log.hxx> +#include <o3tl/string_view.hxx> using namespace css; using namespace css::beans; -using namespace css::lang; using namespace css::ui::dialogs; using namespace css::uno; using namespace svx; @@ -53,8 +53,8 @@ using namespace svx; // define ---------------------------------------------------------------- constexpr OUStringLiteral POSTFIX_INTERNAL = u"_internal"; -constexpr OUStringLiteral POSTFIX_USER = u"_user"; -constexpr OUStringLiteral POSTFIX_WRITABLE = u"_writable"; +constexpr OUString POSTFIX_USER = u"_user"_ustr; +constexpr OUString POSTFIX_WRITABLE = u"_writable"_ustr; constexpr OUStringLiteral VAR_ONE = u"%1"; constexpr OUStringLiteral IODLG_CONFIGNAME = u"FilePicker_Save"; @@ -66,7 +66,7 @@ struct OptPath_Impl Reference< css::util::XPathSettings > m_xPathSettings; OptPath_Impl() - : m_sMultiPathDlg(CuiResId(RID_SVXSTR_EDIT_PATHS)) + : m_sMultiPathDlg(CuiResId(RID_CUISTR_EDIT_PATHS)) { } }; @@ -135,16 +135,16 @@ static OUString getCfgName_Impl( SvtPathOptions::Paths _nHandle ) #define MULTIPATH_DELIMITER ';' -static OUString Convert_Impl( const OUString& rValue ) +static OUString Convert_Impl( std::u16string_view rValue ) { - if (rValue.isEmpty()) + if (rValue.empty()) return OUString(); sal_Int32 nPos = 0; OUStringBuffer aReturn; for (;;) { - OUString aValue = rValue.getToken( 0, MULTIPATH_DELIMITER, nPos ); + OUString aValue( o3tl::getToken(rValue, 0, MULTIPATH_DELIMITER, nPos ) ); INetURLObject aObj( aValue ); if ( aObj.GetProtocol() == INetProtocol::File ) aReturn.append(aObj.PathToFileName()); @@ -211,7 +211,7 @@ IMPL_LINK(SvxPathTabPage, HeaderBarClick, int, nColumn, void) SvxPathTabPage::~SvxPathTabPage() { for (int i = 0, nEntryCount = m_xPathBox->n_children(); i < nEntryCount; ++i) - delete reinterpret_cast<PathUserData_Impl*>(m_xPathBox->get_id(i).toInt64()); + delete weld::fromId<PathUserData_Impl*>(m_xPathBox->get_id(i)); } std::unique_ptr<SfxTabPage> SvxPathTabPage::Create( weld::Container* pPage, weld::DialogController* pController, @@ -220,11 +220,19 @@ std::unique_ptr<SfxTabPage> SvxPathTabPage::Create( weld::Container* pPage, weld return std::make_unique<SvxPathTabPage>( pPage, pController, *rAttrSet ); } +OUString SvxPathTabPage::GetAllStrings() +{ + OUString sAllStrings; + if (const auto& pString = m_xBuilder->weld_label("label1")) + sAllStrings += pString->get_label() + " "; + return sAllStrings.replaceAll("_", ""); +} + bool SvxPathTabPage::FillItemSet( SfxItemSet* ) { for (int i = 0, nEntryCount = m_xPathBox->n_children(); i < nEntryCount; ++i) { - PathUserData_Impl* pPathImpl = reinterpret_cast<PathUserData_Impl*>(m_xPathBox->get_id(i).toInt64()); + PathUserData_Impl* pPathImpl = weld::fromId<PathUserData_Impl*>(m_xPathBox->get_id(i)); SvtPathOptions::Paths nRealId = pPathImpl->nRealId; if (pPathImpl->bItemStateSet ) SetPathList( nRealId, pPathImpl->sUserPath, pPathImpl->sWritablePath ); @@ -250,39 +258,39 @@ void SvxPathTabPage::Reset( const SfxItemSet* ) switch (static_cast<SvtPathOptions::Paths>(i)) { case SvtPathOptions::Paths::AutoCorrect: - pId = RID_SVXSTR_KEY_AUTOCORRECT_DIR; + pId = RID_CUISTR_KEY_AUTOCORRECT_DIR; break; case SvtPathOptions::Paths::AutoText: - pId = RID_SVXSTR_KEY_GLOSSARY_PATH; + pId = RID_CUISTR_KEY_GLOSSARY_PATH; break; case SvtPathOptions::Paths::Backup: - pId = RID_SVXSTR_KEY_BACKUP_PATH; + pId = RID_CUISTR_KEY_BACKUP_PATH; break; case SvtPathOptions::Paths::Gallery: - pId = RID_SVXSTR_KEY_GALLERY_DIR; + pId = RID_CUISTR_KEY_GALLERY_DIR; break; case SvtPathOptions::Paths::Graphic: - pId = RID_SVXSTR_KEY_GRAPHICS_PATH; + pId = RID_CUISTR_KEY_GRAPHICS_PATH; break; case SvtPathOptions::Paths::Temp: - pId = RID_SVXSTR_KEY_TEMP_PATH; + pId = RID_CUISTR_KEY_TEMP_PATH; break; case SvtPathOptions::Paths::Template: - pId = RID_SVXSTR_KEY_TEMPLATE_PATH; + pId = RID_CUISTR_KEY_TEMPLATE_PATH; break; case SvtPathOptions::Paths::Dictionary: - pId = RID_SVXSTR_KEY_DICTIONARY_PATH; + pId = RID_CUISTR_KEY_DICTIONARY_PATH; break; case SvtPathOptions::Paths::Classification: - pId = RID_SVXSTR_KEY_CLASSIFICATION_PATH; + pId = RID_CUISTR_KEY_CLASSIFICATION_PATH; break; #if OSL_DEBUG_LEVEL > 1 case SvtPathOptions::Paths::Linguistic: - pId = RID_SVXSTR_KEY_LINGUISTIC_DIR; + pId = RID_CUISTR_KEY_LINGUISTIC_DIR; break; #endif case SvtPathOptions::Paths::Work: - pId = RID_SVXSTR_KEY_WORK_PATH; + pId = RID_CUISTR_KEY_WORK_PATH; break; default: break; } @@ -322,7 +330,7 @@ void SvxPathTabPage::Reset( const SfxItemSet* ) pPathImpl->sWritablePath = sWritable; pPathImpl->bReadOnly = bReadOnly; - OUString sId = OUString::number(reinterpret_cast<sal_Int64>(pPathImpl)); + OUString sId = weld::toId(pPathImpl); m_xPathBox->set_id(*xIter, sId); } } @@ -338,7 +346,7 @@ IMPL_LINK_NOARG(SvxPathTabPage, PathSelect_Impl, weld::TreeView&, void) int nEntry = m_xPathBox->get_selected_index(); if (nEntry != -1) { - PathUserData_Impl* pPathImpl = reinterpret_cast<PathUserData_Impl*>(m_xPathBox->get_id(nEntry).toInt64()); + PathUserData_Impl* pPathImpl = weld::fromId<PathUserData_Impl*>(m_xPathBox->get_id(nEntry)); bEnable = !pPathImpl->bReadOnly; } sal_uInt16 nSelCount = m_xPathBox->count_selected_rows(); @@ -349,7 +357,7 @@ IMPL_LINK_NOARG(SvxPathTabPage, PathSelect_Impl, weld::TreeView&, void) IMPL_LINK_NOARG(SvxPathTabPage, StandardHdl_Impl, weld::Button&, void) { m_xPathBox->selected_foreach([this](weld::TreeIter& rEntry){ - PathUserData_Impl* pPathImpl = reinterpret_cast<PathUserData_Impl*>(m_xPathBox->get_id(rEntry).toInt64()); + PathUserData_Impl* pPathImpl = weld::fromId<PathUserData_Impl*>(m_xPathBox->get_id(rEntry)); OUString aOldPath = SvtDefaultOptions::GetDefaultPath( pPathImpl->nRealId ); if ( !aOldPath.isEmpty() ) @@ -362,13 +370,13 @@ IMPL_LINK_NOARG(SvxPathTabPage, StandardHdl_Impl, weld::Button&, void) do { bool bFound = false; - const OUString sOnePath = aOldPath.getToken( 0, MULTIPATH_DELIMITER, nOldPos ); + const std::u16string_view sOnePath = o3tl::getToken(aOldPath, 0, MULTIPATH_DELIMITER, nOldPos ); if ( !sInternal.isEmpty() ) { sal_Int32 nInternalPos = 0; do { - if ( sInternal.getToken( 0, MULTIPATH_DELIMITER, nInternalPos ) == sOnePath ) + if ( o3tl::getToken(sInternal, 0, MULTIPATH_DELIMITER, nInternalPos ) == sOnePath ) bFound = true; } while ( !bFound && nInternalPos >= 0 ); @@ -420,7 +428,7 @@ void SvxPathTabPage::ChangeCurrentEntry( const OUString& _rFolder ) } OUString sInternal, sUser, sWritable; - PathUserData_Impl* pPathImpl = reinterpret_cast<PathUserData_Impl*>(m_xPathBox->get_id(nEntry).toInt64()); + PathUserData_Impl* pPathImpl = weld::fromId<PathUserData_Impl*>(m_xPathBox->get_id(nEntry)); bool bReadOnly = false; GetPathList( pPathImpl->nRealId, sInternal, sUser, sWritable, bReadOnly ); sUser = pPathImpl->sUserPath; @@ -470,7 +478,7 @@ IMPL_LINK_NOARG(SvxPathTabPage, DoubleClickPathHdl_Impl, weld::TreeView&, bool) IMPL_LINK_NOARG(SvxPathTabPage, PathHdl_Impl, weld::Button&, void) { int nEntry = m_xPathBox->get_cursor_index(); - PathUserData_Impl* pPathImpl = nEntry != -1 ? reinterpret_cast<PathUserData_Impl*>(m_xPathBox->get_id(nEntry).toInt64()) : nullptr; + PathUserData_Impl* pPathImpl = nEntry != -1 ? weld::fromId<PathUserData_Impl*>(m_xPathBox->get_id(nEntry)) : nullptr; if (!pPathImpl || pPathImpl->bReadOnly) return; @@ -658,7 +666,7 @@ void SvxPathTabPage::GetPathList( void SvxPathTabPage::SetPathList( - SvtPathOptions::Paths _nPathHandle, const OUString& _rUserPath, const OUString& _rWritablePath ) + SvtPathOptions::Paths _nPathHandle, std::u16string_view _rUserPath, const OUString& _rWritablePath ) { OUString sCfgName = getCfgName_Impl( _nPathHandle ); @@ -677,7 +685,7 @@ void SvxPathTabPage::SetPathList( OUString* pArray = aPathSeq.getArray(); sal_Int32 nPos = 0; for ( sal_Int32 i = 0; i < nCount; ++i ) - pArray[i] = _rUserPath.getToken( 0, MULTIPATH_DELIMITER, nPos ); + pArray[i] = o3tl::getToken(_rUserPath, 0, MULTIPATH_DELIMITER, nPos ); Any aValue( aPathSeq ); pImpl->m_xPathSettings->setPropertyValue( sCfgName + POSTFIX_USER, aValue); diff --git a/cui/source/options/optsave.cxx b/cui/source/options/optsave.cxx index 08e4ce219197..ecf23f377ec3 100644 --- a/cui/source/options/optsave.cxx +++ b/cui/source/options/optsave.cxx @@ -21,9 +21,13 @@ #include <string_view> +#include <o3tl/string_view.hxx> #include <svl/eitem.hxx> #include <svl/intitem.hxx> +#include <dialmgr.hxx> #include "optsave.hxx" +#include <strings.hrc> +#include <treeopt.hxx> #include <officecfg/Office/Common.hxx> #include <comphelper/processfactory.hxx> #include <unotools/moduleoptions.hxx> @@ -36,22 +40,19 @@ #include <com/sun/star/beans/PropertyValue.hpp> #include <sfx2/sfxsids.hrc> #include <sfx2/docfilt.hxx> -#include <unotools/optionsdlg.hxx> #include <osl/diagnose.h> -#include <tools/diagnose_ex.h> +#include <comphelper/diagnose_ex.hxx> #include <officecfg/Office/Recovery.hxx> +#include <unotools/confignode.hxx> #include <sfx2/fcontnr.hxx> using namespace com::sun::star::uno; -using namespace com::sun::star::util; using namespace com::sun::star::lang; using namespace com::sun::star::beans; using namespace com::sun::star::container; using namespace comphelper; -#define CFG_PAGE_AND_GROUP u"General", u"LoadSave" - struct SvxSaveTabPage_Impl { @@ -75,18 +76,33 @@ SvxSaveTabPage_Impl::SvxSaveTabPage_Impl() : bInitialized( false ) SvxSaveTabPage::SvxSaveTabPage(weld::Container* pPage, weld::DialogController* pController, const SfxItemSet& rCoreSet) : SfxTabPage( pPage, pController, "cui/ui/optsavepage.ui", "OptSavePage", &rCoreSet ) , pImpl(new SvxSaveTabPage_Impl) + , m_xLoadViewPosAnyUserCB(m_xBuilder->weld_check_button("load_anyuser")) + , m_xLoadViewPosAnyUserImg(m_xBuilder->weld_widget("lockload_anyuser")) , m_xLoadUserSettingsCB(m_xBuilder->weld_check_button("load_settings")) + , m_xLoadUserSettingsImg(m_xBuilder->weld_widget("lockload_settings")) , m_xLoadDocPrinterCB(m_xBuilder->weld_check_button("load_docprinter")) + , m_xLoadDocPrinterImg(m_xBuilder->weld_widget("lockload_docprinter")) , m_xDocInfoCB(m_xBuilder->weld_check_button("docinfo")) + , m_xDocInfoImg(m_xBuilder->weld_widget("lockdocinfo")) , m_xBackupCB(m_xBuilder->weld_check_button("backup")) + , m_xBackupImg(m_xBuilder->weld_widget("lockbackup")) + , m_xBackupIntoDocumentFolderCB(m_xBuilder->weld_check_button("backupintodocumentfolder")) + , m_xBackupIntoDocumentFolderImg(m_xBuilder->weld_widget("lockbackupintodoc")) , m_xAutoSaveCB(m_xBuilder->weld_check_button("autosave")) + , m_xAutoSaveImg(m_xBuilder->weld_widget("lockautosave")) , m_xAutoSaveEdit(m_xBuilder->weld_spin_button("autosave_spin")) , m_xMinuteFT(m_xBuilder->weld_label("autosave_mins")) , m_xUserAutoSaveCB(m_xBuilder->weld_check_button("userautosave")) + , m_xUserAutoSaveImg(m_xBuilder->weld_widget("lockuserautosave")) , m_xRelativeFsysCB(m_xBuilder->weld_check_button("relative_fsys")) + , m_xRelativeFsysImg(m_xBuilder->weld_widget("lockrelative_fsys")) , m_xRelativeInetCB(m_xBuilder->weld_check_button("relative_inet")) + , m_xRelativeInetImg(m_xBuilder->weld_widget("lockrelative_inet")) , m_xODFVersionLB(m_xBuilder->weld_combo_box("odfversion")) + , m_xODFVersionFT(m_xBuilder->weld_label("label5")) + , m_xODFVersionImg(m_xBuilder->weld_widget("lockodfversion")) , m_xWarnAlienFormatCB(m_xBuilder->weld_check_button("warnalienformat")) + , m_xWarnAlienFormatImg(m_xBuilder->weld_widget("lockwarnalienformat")) , m_xDocTypeLB(m_xBuilder->weld_combo_box("doctype")) , m_xSaveAsFT(m_xBuilder->weld_label("saveas_label")) , m_xSaveAsLB(m_xBuilder->weld_combo_box("saveas")) @@ -94,6 +110,7 @@ SvxSaveTabPage::SvxSaveTabPage(weld::Container* pPage, weld::DialogController* p , m_xODFWarningFT(m_xBuilder->weld_label("odfwarning_label")) { m_xAutoSaveEdit->set_max_length(2); + m_xBackupIntoDocumentFolderCB->set_accessible_description(CuiResId(RID_CUISTR_A11Y_DESC_BACKUP)); m_xODFVersionLB->set_id(0, OUString::number(SvtSaveOptions::ODFVER_011)); // 1.0/1.1 m_xODFVersionLB->set_id(1, OUString::number(SvtSaveOptions::ODFVER_012)); // 1.2 @@ -102,15 +119,23 @@ SvxSaveTabPage::SvxSaveTabPage(weld::Container* pPage, weld::DialogController* p m_xODFVersionLB->set_id(4, OUString::number(SvtSaveOptions::ODFVER_013)); // 1.3 m_xODFVersionLB->set_id(5, OUString::number(SvtSaveOptions::ODFVER_LATEST)); // 1.3 Extended (recommended) - m_xDocTypeLB->set_id(0, OUString::number(APP_WRITER) ); - m_xDocTypeLB->set_id(1, OUString::number(APP_WRITER_WEB) ); - m_xDocTypeLB->set_id(2, OUString::number(APP_WRITER_GLOBAL)); - m_xDocTypeLB->set_id(3, OUString::number(APP_CALC) ); - m_xDocTypeLB->set_id(4, OUString::number(APP_IMPRESS) ); - m_xDocTypeLB->set_id(5, OUString::number(APP_DRAW) ); - m_xDocTypeLB->set_id(6, OUString::number(APP_MATH) ); + auto aFilterClassesNode = utl::OConfigurationTreeRoot::createWithComponentContext( + comphelper::getProcessComponentContext(), + "org.openoffice.Office.UI/FilterClassification/GlobalFilters/Classes", + -1, + utl::OConfigurationTreeRoot::CM_READONLY + ); + + m_xDocTypeLB->append(OUString::number(APP_WRITER), aFilterClassesNode.getNodeValue("com.sun.star.text.TextDocument/DisplayName").get<OUString>()); + m_xDocTypeLB->append(OUString::number(APP_WRITER_WEB), aFilterClassesNode.getNodeValue("com.sun.star.text.WebDocument/DisplayName").get<OUString>()); + m_xDocTypeLB->append(OUString::number(APP_WRITER_GLOBAL), aFilterClassesNode.getNodeValue("com.sun.star.text.GlobalDocument/DisplayName").get<OUString>()); + m_xDocTypeLB->append(OUString::number(APP_CALC), aFilterClassesNode.getNodeValue("com.sun.star.sheet.SpreadsheetDocument/DisplayName").get<OUString>()); + m_xDocTypeLB->append(OUString::number(APP_IMPRESS), aFilterClassesNode.getNodeValue("com.sun.star.presentation.PresentationDocument/DisplayName").get<OUString>()); + m_xDocTypeLB->append(OUString::number(APP_DRAW), aFilterClassesNode.getNodeValue("com.sun.star.drawing.DrawingDocument/DisplayName").get<OUString>()); + m_xDocTypeLB->append(OUString::number(APP_MATH), aFilterClassesNode.getNodeValue("com.sun.star.formula.FormulaProperties/DisplayName").get<OUString>()); m_xAutoSaveCB->connect_toggled( LINK( this, SvxSaveTabPage, AutoClickHdl_Impl ) ); + m_xBackupCB->connect_toggled(LINK(this, SvxSaveTabPage, BackupClickHdl_Impl)); SvtModuleOptions aModuleOpt; if ( !aModuleOpt.IsModuleInstalled( SvtModuleOptions::EModule::MATH ) ) @@ -181,8 +206,6 @@ SvxSaveTabPage::SvxSaveTabPage(weld::Container* pPage, weld::DialogController* p aLink = LINK( this, SvxSaveTabPage, FilterHdl_Impl ); m_xDocTypeLB->connect_changed( aLink ); m_xSaveAsLB->connect_changed( aLink ); - - DetectHiddenControls(); } SvxSaveTabPage::~SvxSaveTabPage() @@ -195,36 +218,40 @@ std::unique_ptr<SfxTabPage> SvxSaveTabPage::Create(weld::Container* pPage, weld: return std::make_unique<SvxSaveTabPage>(pPage, pController, *rAttrSet); } -void SvxSaveTabPage::DetectHiddenControls() +OUString SvxSaveTabPage::GetAllStrings() { - SvtOptionsDialogOptions aOptionsDlgOpt; + OUString sAllStrings; + OUString labels[] = { "label1", "label2", "autosave_mins", "label3", + "label5", "label6", "saveas_label", "odfwarning_label" }; - if ( aOptionsDlgOpt.IsOptionHidden( u"Backup", CFG_PAGE_AND_GROUP ) ) + for (const auto& label : labels) { - // hide controls of "Backup" - m_xBackupCB->hide(); + if (const auto& pString = m_xBuilder->weld_label(label)) + sAllStrings += pString->get_label() + " "; } - if ( aOptionsDlgOpt.IsOptionHidden( u"AutoSave", CFG_PAGE_AND_GROUP ) ) - { - // hide controls of "AutoSave" - m_xAutoSaveCB->hide(); - m_xAutoSaveEdit->hide(); - m_xMinuteFT->hide(); - } + OUString checkButton[] + = { "load_settings", "load_docprinter", "load_anyuser", "autosave", + "userautosave", "docinfo", "backup", "backupintodocumentfolder", + "relative_fsys", "relative_inet", "warnalienformat" }; - if ( aOptionsDlgOpt.IsOptionHidden( u"UserAutoSave", CFG_PAGE_AND_GROUP ) ) + for (const auto& check : checkButton) { - // hide controls of "UserAutoSave" - m_xUserAutoSaveCB->hide(); + if (const auto& pString = m_xBuilder->weld_check_button(check)) + sAllStrings += pString->get_label() + " "; } + return sAllStrings.replaceAll("_", ""); } bool SvxSaveTabPage::FillItemSet( SfxItemSet* rSet ) { auto xChanges = comphelper::ConfigurationChanges::create(); bool bModified = false; + if (m_xLoadViewPosAnyUserCB->get_state_changed_from_saved()) + { + officecfg::Office::Common::Load::ViewPositionForAnyUser::set(m_xLoadViewPosAnyUserCB->get_active(), xChanges); + } if(m_xLoadUserSettingsCB->get_state_changed_from_saved()) officecfg::Office::Common::Load::UserDefinedSettings::set(m_xLoadUserSettingsCB->get_active(), xChanges); @@ -239,55 +266,62 @@ bool SvxSaveTabPage::FillItemSet( SfxItemSet* rSet ) if ( m_xDocInfoCB->get_state_changed_from_saved() ) { - rSet->Put( SfxBoolItem( GetWhich( SID_ATTR_DOCINFO ), + rSet->Put( SfxBoolItem( SID_ATTR_DOCINFO, m_xDocInfoCB->get_active() ) ); bModified = true; } if ( m_xBackupCB->get_sensitive() && m_xBackupCB->get_state_changed_from_saved() ) { - rSet->Put( SfxBoolItem( GetWhich( SID_ATTR_BACKUP ), - m_xBackupCB->get_active() ) ); + rSet->Put( SfxBoolItem( SID_ATTR_BACKUP, m_xBackupCB->get_active() ) ); + bModified = true; + } + + if (m_xBackupIntoDocumentFolderCB->get_sensitive() + && m_xBackupIntoDocumentFolderCB->get_state_changed_from_saved()) + { + rSet->Put( + SfxBoolItem(SID_ATTR_BACKUP_BESIDE_ORIGINAL, m_xBackupIntoDocumentFolderCB->get_active())); bModified = true; } if ( m_xAutoSaveCB->get_state_changed_from_saved() ) { - rSet->Put( SfxBoolItem( GetWhich( SID_ATTR_AUTOSAVE ), + rSet->Put( SfxBoolItem( SID_ATTR_AUTOSAVE, m_xAutoSaveCB->get_active() ) ); bModified = true; } if ( m_xWarnAlienFormatCB->get_state_changed_from_saved() ) { - rSet->Put( SfxBoolItem( GetWhich( SID_ATTR_WARNALIENFORMAT ), + rSet->Put( SfxBoolItem( SID_ATTR_WARNALIENFORMAT, m_xWarnAlienFormatCB->get_active() ) ); bModified = true; } if ( m_xAutoSaveEdit->get_value_changed_from_saved() ) { - rSet->Put( SfxUInt16Item( GetWhich( SID_ATTR_AUTOSAVEMINUTE ), + rSet->Put( SfxUInt16Item( SID_ATTR_AUTOSAVEMINUTE, static_cast<sal_uInt16>(m_xAutoSaveEdit->get_value()) ) ); bModified = true; } if ( m_xUserAutoSaveCB->get_state_changed_from_saved() ) { - rSet->Put( SfxBoolItem( GetWhich( SID_ATTR_USERAUTOSAVE ), + rSet->Put( SfxBoolItem( SID_ATTR_USERAUTOSAVE, m_xUserAutoSaveCB->get_active() ) ); bModified = true; } // save relatively if ( m_xRelativeFsysCB->get_state_changed_from_saved() ) { - rSet->Put( SfxBoolItem( GetWhich( SID_SAVEREL_FSYS ), + rSet->Put( SfxBoolItem( SID_SAVEREL_FSYS, m_xRelativeFsysCB->get_active() ) ); bModified = true; } if ( m_xRelativeInetCB->get_state_changed_from_saved() ) { - rSet->Put( SfxBoolItem( GetWhich( SID_SAVEREL_INET ), + rSet->Put( SfxBoolItem( SID_SAVEREL_INET, m_xRelativeInetCB->get_active() ) ); bModified = true; } @@ -325,7 +359,7 @@ bool SvxSaveTabPage::FillItemSet( SfxItemSet* rSet ) return bModified; } -static bool isODFFormat( const OUString& sFilter ) +static bool isODFFormat( std::u16string_view sFilter ) { static const char* aODFFormats[] = { @@ -349,7 +383,7 @@ static bool isODFFormat( const OUString& sFilter ) int i = 0; while ( aODFFormats[i] != nullptr ) { - if ( sFilter.equalsAscii( aODFFormats[i++] ) ) + if ( o3tl::equalsAscii( sFilter, aODFFormats[i++] ) ) { bRet = true; break; @@ -361,12 +395,20 @@ static bool isODFFormat( const OUString& sFilter ) void SvxSaveTabPage::Reset( const SfxItemSet* ) { + m_xLoadViewPosAnyUserCB->set_active(officecfg::Office::Common::Load::ViewPositionForAnyUser::get()); + m_xLoadViewPosAnyUserCB->save_state(); + m_xLoadViewPosAnyUserCB->set_sensitive(!officecfg::Office::Common::Load::ViewPositionForAnyUser::isReadOnly()); + m_xLoadViewPosAnyUserImg->set_visible(officecfg::Office::Common::Load::ViewPositionForAnyUser::isReadOnly()); + m_xLoadUserSettingsCB->set_active(officecfg::Office::Common::Load::UserDefinedSettings::get()); m_xLoadUserSettingsCB->save_state(); m_xLoadUserSettingsCB->set_sensitive(!officecfg::Office::Common::Load::UserDefinedSettings::isReadOnly()); + m_xLoadUserSettingsImg->set_visible(officecfg::Office::Common::Load::UserDefinedSettings::isReadOnly()); + m_xLoadDocPrinterCB->set_active( officecfg::Office::Common::Save::Document::LoadPrinter::get() ); m_xLoadDocPrinterCB->save_state(); m_xLoadDocPrinterCB->set_sensitive(!officecfg::Office::Common::Save::Document::LoadPrinter::isReadOnly()); + m_xLoadDocPrinterImg->set_visible(officecfg::Office::Common::Save::Document::LoadPrinter::isReadOnly()); if ( !pImpl->bInitialized ) { @@ -396,7 +438,7 @@ void SvxSaveTabPage::Reset( const SfxItemSet* ) case APP_IMPRESS : sReplace = "com.sun.star.presentation.PresentationDocument";break; case APP_DRAW : sReplace = "com.sun.star.drawing.DrawingDocument";break; case APP_MATH : sReplace = "com.sun.star.formula.FormulaProperties";break; - default: OSL_FAIL("illegal user data"); + default: SAL_WARN("cui.options", "illegal user data"); } sCommand = sCommand.replaceFirst("%1", sReplace); Reference< XEnumeration > xList = xQuery->createSubSetEnumerationByQuery(sCommand); @@ -416,7 +458,23 @@ void SvxSaveTabPage::Reset( const SfxItemSet* ) pImpl->aODFArr[nData] = lODFList; } } - m_xDocTypeLB->set_active(0); + OUString sModule = OfaTreeOptionsDialog::getCurrentFactory_Impl(GetFrame()); + sal_Int32 docId = 0; + if (sModule == "com.sun.star.text.TextDocument") + docId = APP_WRITER; + else if (sModule == "com.sun.star.text.WebDocument") + docId = APP_WRITER_WEB; + else if (sModule == "com.sun.star.text.GlobalDocument") + docId = APP_WRITER_GLOBAL; + else if (sModule == "com.sun.star.sheet.SpreadsheetDocument") + docId = APP_CALC; + else if (sModule == "com.sun.star.presentation.PresentationDocument") + docId = APP_IMPRESS; + else if (sModule == "com.sun.star.drawing.DrawingDocument") + docId = APP_DRAW; + else if (sModule == "com.sun.star.formula.FormulaProperties") + docId = APP_MATH; + m_xDocTypeLB->set_active_id(OUString::number(docId)); FilterHdl_Impl(*m_xDocTypeLB); } catch(Exception const &) @@ -429,38 +487,56 @@ void SvxSaveTabPage::Reset( const SfxItemSet* ) m_xDocInfoCB->set_active(officecfg::Office::Common::Save::Document::EditProperty::get()); m_xDocInfoCB->set_sensitive(!officecfg::Office::Common::Save::Document::EditProperty::isReadOnly()); + m_xDocInfoImg->set_visible(officecfg::Office::Common::Save::Document::EditProperty::isReadOnly()); m_xBackupCB->set_active(officecfg::Office::Common::Save::Document::CreateBackup::get()); m_xBackupCB->set_sensitive(!officecfg::Office::Common::Save::Document::CreateBackup::isReadOnly()); + m_xBackupImg->set_visible(officecfg::Office::Common::Save::Document::CreateBackup::isReadOnly()); - m_xAutoSaveCB->set_active(officecfg::Office::Common::Save::Document::AutoSave::get()); - m_xAutoSaveCB->set_sensitive(!officecfg::Office::Common::Save::Document::AutoSave::isReadOnly()); + m_xBackupIntoDocumentFolderCB->set_active( + officecfg::Office::Common::Save::Document::BackupIntoDocumentFolder::get()); + m_xBackupIntoDocumentFolderCB->set_sensitive( + !officecfg::Office::Common::Save::Document::BackupIntoDocumentFolder::isReadOnly() + && m_xBackupCB->get_active()); + m_xBackupIntoDocumentFolderImg->set_visible( + officecfg::Office::Common::Save::Document::BackupIntoDocumentFolder::isReadOnly()); + + m_xAutoSaveCB->set_active(officecfg::Office::Recovery::AutoSave::Enabled::get()); + m_xAutoSaveCB->set_sensitive(!officecfg::Office::Recovery::AutoSave::Enabled::isReadOnly()); + m_xAutoSaveImg->set_visible(officecfg::Office::Recovery::AutoSave::Enabled::isReadOnly()); m_xUserAutoSaveCB->set_active(officecfg::Office::Recovery::AutoSave::UserAutoSaveEnabled::get()); m_xUserAutoSaveCB->set_sensitive(!officecfg::Office::Recovery::AutoSave::UserAutoSaveEnabled::isReadOnly()); + m_xUserAutoSaveImg->set_visible(officecfg::Office::Recovery::AutoSave::UserAutoSaveEnabled::isReadOnly()); m_xWarnAlienFormatCB->set_active(officecfg::Office::Common::Save::Document::WarnAlienFormat::get()); m_xWarnAlienFormatCB->set_sensitive(!officecfg::Office::Common::Save::Document::WarnAlienFormat::isReadOnly()); + m_xWarnAlienFormatImg->set_visible(officecfg::Office::Common::Save::Document::WarnAlienFormat::isReadOnly()); - m_xAutoSaveEdit->set_value(officecfg::Office::Common::Save::Document::AutoSaveTimeIntervall::get()); - m_xAutoSaveEdit->set_sensitive(!officecfg::Office::Common::Save::Document::AutoSaveTimeIntervall::isReadOnly()); + m_xAutoSaveEdit->set_value(officecfg::Office::Recovery::AutoSave::TimeIntervall::get()); + m_xAutoSaveEdit->set_sensitive(!officecfg::Office::Recovery::AutoSave::TimeIntervall::isReadOnly()); // save relatively m_xRelativeFsysCB->set_active(officecfg::Office::Common::Save::URL::FileSystem::get()); m_xRelativeFsysCB->set_sensitive(!officecfg::Office::Common::Save::URL::FileSystem::isReadOnly()); + m_xRelativeFsysImg->set_visible(officecfg::Office::Common::Save::URL::FileSystem::isReadOnly()); m_xRelativeInetCB->set_active(officecfg::Office::Common::Save::URL::Internet::get()); m_xRelativeInetCB->set_sensitive(!officecfg::Office::Common::Save::URL::Internet::isReadOnly()); + m_xRelativeInetImg->set_visible(officecfg::Office::Common::Save::URL::Internet::isReadOnly()); sal_Int32 nDefaultVersion = GetODFDefaultVersion(); m_xODFVersionLB->set_active_id(OUString::number(nDefaultVersion)); m_xODFVersionLB->set_sensitive(!officecfg::Office::Common::Save::ODF::DefaultVersion::isReadOnly()); + m_xODFVersionFT->set_sensitive(!officecfg::Office::Common::Save::ODF::DefaultVersion::isReadOnly()); + m_xODFVersionImg->set_visible(officecfg::Office::Common::Save::ODF::DefaultVersion::isReadOnly()); AutoClickHdl_Impl(*m_xAutoSaveCB); ODFVersionHdl_Impl(*m_xODFVersionLB); m_xDocInfoCB->save_state(); m_xBackupCB->save_state(); + m_xBackupIntoDocumentFolderCB->save_state(); m_xWarnAlienFormatCB->save_state(); m_xAutoSaveCB->save_state(); m_xAutoSaveEdit->save_value(); @@ -479,9 +555,9 @@ IMPL_LINK(SvxSaveTabPage, AutoClickHdl_Impl, weld::Toggleable&, rBox, void) if (m_xAutoSaveCB->get_active()) { - m_xAutoSaveEdit->set_sensitive(true); - m_xMinuteFT->set_sensitive(true); - m_xUserAutoSaveCB->set_sensitive(true); + m_xAutoSaveEdit->set_sensitive(!officecfg::Office::Recovery::AutoSave::Enabled::isReadOnly()); + m_xMinuteFT->set_sensitive(!officecfg::Office::Recovery::AutoSave::Enabled::isReadOnly()); + m_xUserAutoSaveCB->set_sensitive(!officecfg::Office::Recovery::AutoSave::UserAutoSaveEnabled::isReadOnly()); } else { @@ -491,6 +567,12 @@ IMPL_LINK(SvxSaveTabPage, AutoClickHdl_Impl, weld::Toggleable&, rBox, void) } } +IMPL_LINK_NOARG(SvxSaveTabPage, BackupClickHdl_Impl, weld::Toggleable&, void) +{ + m_xBackupIntoDocumentFolderCB->set_sensitive(m_xBackupCB->get_active() && + !officecfg::Office::Common::Save::Document::BackupIntoDocumentFolder::isReadOnly()); +} + static OUString lcl_ExtracUIName(const Sequence<PropertyValue> &rProperties, std::u16string_view rExtension) { OUString sName; @@ -565,7 +647,7 @@ IMPL_LINK( SvxSaveTabPage, FilterHdl_Impl, weld::ComboBox&, rBox, void ) { OUString sId; if (pImpl->aODFArr[nData][i]) - sId = OUString::number(reinterpret_cast<sal_Int64>(pImpl.get())); + sId = weld::toId(pImpl.get()); m_xSaveAsLB->append(sId, rUIFilters[i]); if (rFilters[i] == pImpl->aDefaultArr[nData]) sSelect = rUIFilters[i]; diff --git a/cui/source/options/optsave.hxx b/cui/source/options/optsave.hxx index 4ec3b1ddada5..255719184d63 100644 --- a/cui/source/options/optsave.hxx +++ b/cui/source/options/optsave.hxx @@ -41,18 +41,33 @@ class SvxSaveTabPage : public SfxTabPage private: std::unique_ptr<SvxSaveTabPage_Impl> pImpl; + std::unique_ptr<weld::CheckButton> m_xLoadViewPosAnyUserCB; + std::unique_ptr<weld::Widget> m_xLoadViewPosAnyUserImg; std::unique_ptr<weld::CheckButton> m_xLoadUserSettingsCB; + std::unique_ptr<weld::Widget> m_xLoadUserSettingsImg; std::unique_ptr<weld::CheckButton> m_xLoadDocPrinterCB; + std::unique_ptr<weld::Widget> m_xLoadDocPrinterImg; std::unique_ptr<weld::CheckButton> m_xDocInfoCB; + std::unique_ptr<weld::Widget> m_xDocInfoImg; std::unique_ptr<weld::CheckButton> m_xBackupCB; + std::unique_ptr<weld::Widget> m_xBackupImg; + std::unique_ptr<weld::CheckButton> m_xBackupIntoDocumentFolderCB; + std::unique_ptr<weld::Widget> m_xBackupIntoDocumentFolderImg; std::unique_ptr<weld::CheckButton> m_xAutoSaveCB; + std::unique_ptr<weld::Widget> m_xAutoSaveImg; std::unique_ptr<weld::SpinButton> m_xAutoSaveEdit; std::unique_ptr<weld::Label> m_xMinuteFT; std::unique_ptr<weld::CheckButton> m_xUserAutoSaveCB; + std::unique_ptr<weld::Widget> m_xUserAutoSaveImg; std::unique_ptr<weld::CheckButton> m_xRelativeFsysCB; + std::unique_ptr<weld::Widget> m_xRelativeFsysImg; std::unique_ptr<weld::CheckButton> m_xRelativeInetCB; + std::unique_ptr<weld::Widget> m_xRelativeInetImg; std::unique_ptr<weld::ComboBox> m_xODFVersionLB; + std::unique_ptr<weld::Label> m_xODFVersionFT; + std::unique_ptr<weld::Widget> m_xODFVersionImg; std::unique_ptr<weld::CheckButton> m_xWarnAlienFormatCB; + std::unique_ptr<weld::Widget> m_xWarnAlienFormatImg; std::unique_ptr<weld::ComboBox> m_xDocTypeLB; std::unique_ptr<weld::Label> m_xSaveAsFT; std::unique_ptr<weld::ComboBox> m_xSaveAsLB; @@ -60,17 +75,18 @@ private: std::unique_ptr<weld::Label> m_xODFWarningFT; DECL_LINK( AutoClickHdl_Impl, weld::Toggleable&, void ); + DECL_LINK(BackupClickHdl_Impl, weld::Toggleable&, void); DECL_LINK( FilterHdl_Impl, weld::ComboBox&, void ); DECL_LINK(ODFVersionHdl_Impl, weld::ComboBox&, void ); - void DetectHiddenControls(); - public: SvxSaveTabPage(weld::Container* pPage, weld::DialogController* pController, const SfxItemSet& rSet); virtual ~SvxSaveTabPage() override; static std::unique_ptr<SfxTabPage> Create( weld::Container* pPage, weld::DialogController* pController, const SfxItemSet* rAttrSet ); + virtual OUString GetAllStrings() override; + virtual bool FillItemSet( SfxItemSet* rSet ) override; virtual void Reset( const SfxItemSet* rSet ) override; }; diff --git a/cui/source/options/optupdt.cxx b/cui/source/options/optupdt.cxx index 6b0dbe2cd2cd..2686f8dfb277 100644 --- a/cui/source/options/optupdt.cxx +++ b/cui/source/options/optupdt.cxx @@ -17,6 +17,7 @@ * the License at http://www.apache.org/licenses/LICENSE-2.0 . */ +#include <config_features.h> #include <vcl/svapp.hxx> #include <vcl/settings.hxx> #include <svl/numformat.hxx> @@ -25,7 +26,7 @@ #include <comphelper/processfactory.hxx> #include <com/sun/star/configuration/theDefaultProvider.hpp> #include <com/sun/star/lang/XMultiServiceFactory.hpp> -#include <com/sun/star/ui/dialogs/FolderPicker.hpp> +#include <com/sun/star/ui/dialogs/XFolderPicker2.hpp> #include <com/sun/star/ui/dialogs/ExecutableDialogResults.hpp> #include <com/sun/star/deployment/UpdateInformationProvider.hpp> #include <com/sun/star/ucb/XWebDAVCommandEnvironment.hpp> @@ -34,65 +35,99 @@ #include <com/sun/star/util/XChangesBatch.hpp> #include <com/sun/star/util/URLTransformer.hpp> #include <com/sun/star/util/XURLTransformer.hpp> +#include <com/sun/star/setup/UpdateCheck.hpp> #include <com/sun/star/setup/UpdateCheckConfig.hpp> #include <com/sun/star/configuration/ReadWriteAccess.hpp> #include <com/sun/star/beans/PropertyAttribute.hpp> #include <com/sun/star/beans/NamedValue.hpp> #include <sfx2/filedlghelper.hxx> #include <officecfg/Office/Common.hxx> +#include <officecfg/Office/Update.hxx> #include <osl/file.hxx> #include <osl/security.hxx> -#include <tools/diagnose_ex.h> +#include <comphelper/diagnose_ex.hxx> #include <unotools/configmgr.hxx> using namespace ::css; SvxOnlineUpdateTabPage::SvxOnlineUpdateTabPage(weld::Container* pPage, weld::DialogController* pController, const SfxItemSet& rSet) : SfxTabPage(pPage, pController, "cui/ui/optonlineupdatepage.ui", "OptOnlineUpdatePage", &rSet) + , m_showTraditionalOnlineUpdate(isTraditionalOnlineUpdateAvailable()) + , m_showMarOnlineUpdate(isMarOnlineUpdateAvailable()) , m_xNeverChecked(m_xBuilder->weld_label("neverchecked")) , m_xAutoCheckCheckBox(m_xBuilder->weld_check_button("autocheck")) + , m_xAutoCheckImg(m_xBuilder->weld_widget("lockautocheck")) , m_xEveryDayButton(m_xBuilder->weld_radio_button("everyday")) , m_xEveryWeekButton(m_xBuilder->weld_radio_button("everyweek")) , m_xEveryMonthButton(m_xBuilder->weld_radio_button("everymonth")) + , m_xCheckIntervalImg(m_xBuilder->weld_widget("lockcheckinterval")) , m_xCheckNowButton(m_xBuilder->weld_button("checknow")) , m_xAutoDownloadCheckBox(m_xBuilder->weld_check_button("autodownload")) + , m_xAutoDownloadImg(m_xBuilder->weld_widget("lockautodownload")) , m_xDestPathLabel(m_xBuilder->weld_label("destpathlabel")) , m_xDestPath(m_xBuilder->weld_label("destpath")) , m_xChangePathButton(m_xBuilder->weld_button("changepath")) , m_xLastChecked(m_xBuilder->weld_label("lastchecked")) , m_xExtrasCheckBox(m_xBuilder->weld_check_button("extrabits")) + , m_xExtrasImg(m_xBuilder->weld_widget("lockextrabits")) , m_xUserAgentLabel(m_xBuilder->weld_label("useragent")) , m_xPrivacyPolicyButton(m_xBuilder->weld_link_button("btnPrivacyPolicy")) + , m_xBox2(m_xBuilder->weld_box("box2")) + , m_xFrameDest(m_xBuilder->weld_frame("frameDest")) + , m_xFrameAgent(m_xBuilder->weld_frame("frameAgent")) + , m_xMar(m_xBuilder->weld_frame("frameMar")) + , m_xEnableMar(m_xBuilder->weld_check_button("enableMar")) { - m_aNeverChecked = m_xNeverChecked->get_label(); + if (m_showTraditionalOnlineUpdate) { + m_aNeverChecked = m_xNeverChecked->get_label(); - m_xAutoCheckCheckBox->connect_toggled( LINK( this, SvxOnlineUpdateTabPage, AutoCheckHdl_Impl ) ); - m_xExtrasCheckBox->connect_toggled( LINK( this, SvxOnlineUpdateTabPage, ExtrasCheckHdl_Impl ) ); - m_xCheckNowButton->connect_clicked( LINK( this, SvxOnlineUpdateTabPage, CheckNowHdl_Impl ) ); - m_xChangePathButton->connect_clicked( LINK( this, SvxOnlineUpdateTabPage, FileDialogHdl_Impl ) ); - m_xPrivacyPolicyButton->set_uri( - officecfg::Office::Common::Menus::PrivacyPolicyURL::get() - + "?type=updatecheck&LOvers=" + utl::ConfigManager::getProductVersion() - + "&LOlocale=" + LanguageTag(utl::ConfigManager::getUILocale()).getBcp47()); + m_xAutoCheckCheckBox->connect_toggled( LINK( this, SvxOnlineUpdateTabPage, AutoCheckHdl_Impl ) ); + m_xExtrasCheckBox->connect_toggled( LINK( this, SvxOnlineUpdateTabPage, ExtrasCheckHdl_Impl ) ); + m_xCheckNowButton->connect_clicked( LINK( this, SvxOnlineUpdateTabPage, CheckNowHdl_Impl ) ); + m_xChangePathButton->connect_clicked( LINK( this, SvxOnlineUpdateTabPage, FileDialogHdl_Impl ) ); + m_xPrivacyPolicyButton->set_uri( + officecfg::Office::Common::Menus::PrivacyPolicyURL::get() + + "?type=updatecheck&LOvers=" + utl::ConfigManager::getProductVersion() + + "&LOlocale=" + LanguageTag(utl::ConfigManager::getUILocale()).getBcp47()); - uno::Reference < uno::XComponentContext > xContext( ::comphelper::getProcessComponentContext() ); + uno::Reference < uno::XComponentContext > xContext( ::comphelper::getProcessComponentContext() ); - m_xUpdateAccess = setup::UpdateCheckConfig::create( xContext ); - m_xReadWriteAccess = css::configuration::ReadWriteAccess::create(xContext, "*"); + m_xUpdateAccess = setup::UpdateCheckConfig::create( xContext ); + m_xReadWriteAccess = css::configuration::ReadWriteAccess::create(xContext, "*"); - bool bDownloadSupported = false; - m_xUpdateAccess->getByName( "DownloadSupported" ) >>= bDownloadSupported; + bool bDownloadSupported = false; + m_xUpdateAccess->getByName( "DownloadSupported" ) >>= bDownloadSupported; - m_xAutoDownloadCheckBox->set_visible(bDownloadSupported); - m_xDestPathLabel->set_visible(bDownloadSupported); - m_xDestPath->set_visible(bDownloadSupported); - m_xChangePathButton->set_visible(bDownloadSupported); + m_xAutoDownloadCheckBox->set_visible(bDownloadSupported); + m_xDestPathLabel->set_visible(bDownloadSupported); + m_xDestPath->set_visible(bDownloadSupported); + m_xChangePathButton->set_visible(bDownloadSupported); - m_aLastCheckedTemplate = m_xLastChecked->get_label(); + m_aLastCheckedTemplate = m_xLastChecked->get_label(); - UpdateLastCheckedText(); - UpdateUserAgent(); + UpdateLastCheckedText(); + UpdateUserAgent(); + } else { + m_xAutoCheckCheckBox->hide(); + m_xEveryDayButton->hide(); + m_xEveryWeekButton->hide(); + m_xEveryMonthButton->hide(); + m_xCheckNowButton->hide(); + m_xBox2->hide(); + m_xAutoCheckImg->hide(); + m_xCheckIntervalImg->hide(); + m_xFrameDest->hide(); + m_xFrameAgent->hide(); + m_xPrivacyPolicyButton->hide(); + } + + if (m_showMarOnlineUpdate) { + m_xMar->show(); + m_xEnableMar->set_sensitive(!officecfg::Office::Update::Update::Enabled::isReadOnly()); + } else { + m_xMar->hide(); + } } SvxOnlineUpdateTabPage::~SvxOnlineUpdateTabPage() @@ -190,130 +225,184 @@ std::unique_ptr<SfxTabPage> SvxOnlineUpdateTabPage::Create( weld::Container* pPa return std::make_unique<SvxOnlineUpdateTabPage>( pPage, pController, *rAttrSet ); } -bool SvxOnlineUpdateTabPage::FillItemSet( SfxItemSet* ) +OUString SvxOnlineUpdateTabPage::GetAllStrings() { - bool bModified = false; - - bool bValue; - sal_Int64 nValue; + OUString sAllStrings; + OUString labels[] = { "label1", "lastchecked", "neverchecked", "labeldest", + "destpathlabel", "labelagent", "useragent_label", "useragent_changed" }; - if( m_xAutoCheckCheckBox->get_state_changed_from_saved() ) + for (const auto& label : labels) { - bValue = m_xAutoCheckCheckBox->get_active(); - m_xUpdateAccess->replaceByName( "AutoCheckEnabled", uno::Any( bValue ) ); - bModified = true; + if (const auto& pString = m_xBuilder->weld_label(label)) + sAllStrings += pString->get_label() + " "; } - nValue = 0; - if( m_xEveryDayButton->get_active() ) - { - if( !m_xEveryDayButton->get_saved_state() ) - nValue = 86400; - } - else if( m_xEveryWeekButton->get_active() ) - { - if( !m_xEveryWeekButton->get_saved_state() ) - nValue = 604800; - } - else if( m_xEveryMonthButton->get_active() ) - { - if( !m_xEveryMonthButton->get_saved_state() ) - nValue = 2592000; - } + OUString checkButton[] = { "autocheck", "autodownload", "extrabits" }; - if( nValue > 0 ) + for (const auto& check : checkButton) { - m_xUpdateAccess->replaceByName( "CheckInterval", uno::Any( nValue ) ); - bModified = true; + if (const auto& pString = m_xBuilder->weld_check_button(check)) + sAllStrings += pString->get_label() + " "; } - if( m_xAutoDownloadCheckBox->get_state_changed_from_saved() ) + OUString radioButton[] = { "everyday", "everyweek", "everymonth" }; + + for (const auto& radio : radioButton) { - bValue = m_xAutoDownloadCheckBox->get_active(); - m_xUpdateAccess->replaceByName( "AutoDownloadEnabled", uno::Any( bValue ) ); - bModified = true; + if (const auto& pString = m_xBuilder->weld_radio_button(radio)) + sAllStrings += pString->get_label() + " "; } - OUString sValue, aURL; - m_xUpdateAccess->getByName( "DownloadDestination" ) >>= sValue; + // some buttons are not included + sAllStrings += m_xPrivacyPolicyButton->get_label() + " "; - if( ( osl::FileBase::E_None == osl::FileBase::getFileURLFromSystemPath(m_xDestPath->get_label(), aURL) ) && - ( aURL != sValue ) ) - { - m_xUpdateAccess->replaceByName( "DownloadDestination", uno::Any( aURL ) ); - bModified = true; + return sAllStrings.replaceAll("_", ""); +} + +bool SvxOnlineUpdateTabPage::FillItemSet( SfxItemSet* ) +{ + bool bModified = false; + + if (m_showTraditionalOnlineUpdate) { + bool bValue; + sal_Int64 nValue; + + if( m_xAutoCheckCheckBox->get_state_changed_from_saved() ) + { + bValue = m_xAutoCheckCheckBox->get_active(); + m_xUpdateAccess->replaceByName( "AutoCheckEnabled", uno::Any( bValue ) ); + bModified = true; + } + + nValue = 0; + if( m_xEveryDayButton->get_active() ) + { + if( !m_xEveryDayButton->get_saved_state() ) + nValue = 86400; + } + else if( m_xEveryWeekButton->get_active() ) + { + if( !m_xEveryWeekButton->get_saved_state() ) + nValue = 604800; + } + else if( m_xEveryMonthButton->get_active() ) + { + if( !m_xEveryMonthButton->get_saved_state() ) + nValue = 2592000; + } + + if( nValue > 0 ) + { + m_xUpdateAccess->replaceByName( "CheckInterval", uno::Any( nValue ) ); + bModified = true; + } + + if( m_xAutoDownloadCheckBox->get_state_changed_from_saved() ) + { + bValue = m_xAutoDownloadCheckBox->get_active(); + m_xUpdateAccess->replaceByName( "AutoDownloadEnabled", uno::Any( bValue ) ); + bModified = true; + } + + OUString sValue, aURL; + m_xUpdateAccess->getByName( "DownloadDestination" ) >>= sValue; + + if( ( osl::FileBase::E_None == osl::FileBase::getFileURLFromSystemPath(m_xDestPath->get_label(), aURL) ) && + ( aURL != sValue ) ) + { + m_xUpdateAccess->replaceByName( "DownloadDestination", uno::Any( aURL ) ); + bModified = true; + } + + if( m_xExtrasCheckBox->get_state_changed_from_saved() ) + { + bValue = m_xExtrasCheckBox->get_active(); + m_xUpdateAccess->replaceByName( "ExtendedUserAgent", uno::Any( bValue ) ); + bModified = true; + } + + uno::Reference< util::XChangesBatch > xChangesBatch(m_xUpdateAccess, uno::UNO_QUERY); + if( xChangesBatch.is() && xChangesBatch->hasPendingChanges() ) + xChangesBatch->commitChanges(); } - if( m_xExtrasCheckBox->get_state_changed_from_saved() ) - { - bValue = m_xExtrasCheckBox->get_active(); - m_xUpdateAccess->replaceByName( "ExtendedUserAgent", uno::Any( bValue ) ); + if (m_showMarOnlineUpdate && m_xEnableMar->get_state_changed_from_saved()) { + auto batch(comphelper::ConfigurationChanges::create()); + officecfg::Office::Update::Update::Enabled::set(m_xEnableMar->get_active(), batch); + batch->commit(); bModified = true; } - uno::Reference< util::XChangesBatch > xChangesBatch(m_xUpdateAccess, uno::UNO_QUERY); - if( xChangesBatch.is() && xChangesBatch->hasPendingChanges() ) - xChangesBatch->commitChanges(); - return bModified; } void SvxOnlineUpdateTabPage::Reset( const SfxItemSet* ) { - bool bValue = false; - m_xUpdateAccess->getByName( "AutoCheckEnabled" ) >>= bValue; - beans::Property aProperty = m_xReadWriteAccess->getPropertyByHierarchicalName("/org.openoffice.Office.Jobs/Jobs/org.openoffice.Office.Jobs:Job['UpdateCheck']/Arguments/AutoCheckEnabled"); - bool bReadOnly = (aProperty.Attributes & beans::PropertyAttribute::READONLY) != 0; - - m_xAutoCheckCheckBox->set_active(bValue); - m_xAutoCheckCheckBox->set_sensitive(!bReadOnly); - - sal_Int64 nValue = 0; - m_xUpdateAccess->getByName( "CheckInterval" ) >>= nValue; - aProperty = m_xReadWriteAccess->getPropertyByHierarchicalName("/org.openoffice.Office.Jobs/Jobs/org.openoffice.Office.Jobs:Job['UpdateCheck']/Arguments/CheckInterval"); - bool bReadOnly2 = (aProperty.Attributes & beans::PropertyAttribute::READONLY) != 0; - m_xEveryDayButton->set_sensitive(bValue && !(bReadOnly || bReadOnly2)); - m_xEveryWeekButton->set_sensitive(bValue && !(bReadOnly || bReadOnly2)); - m_xEveryMonthButton->set_sensitive(bValue && !(bReadOnly || bReadOnly2)); - - if( nValue == 86400 ) - m_xEveryDayButton->set_active(true); - else if( nValue == 604800 ) - m_xEveryWeekButton->set_active(true); - else - m_xEveryMonthButton->set_active(true); - - m_xAutoCheckCheckBox->save_state(); - m_xEveryDayButton->save_state(); - m_xEveryWeekButton->save_state(); - m_xEveryMonthButton->save_state(); - - m_xUpdateAccess->getByName( "AutoDownloadEnabled" ) >>= bValue; - aProperty = m_xReadWriteAccess->getPropertyByHierarchicalName("/org.openoffice.Office.Jobs/Jobs/org.openoffice.Office.Jobs:Job['UpdateCheck']/Arguments/AutoDownloadEnabled"); - bReadOnly = (aProperty.Attributes & beans::PropertyAttribute::READONLY) != 0; - m_xAutoDownloadCheckBox->set_active(bValue); - m_xAutoDownloadCheckBox->set_sensitive(!bReadOnly); - m_xDestPathLabel->set_sensitive(true); - m_xDestPath->set_sensitive(true); - - OUString sValue, aPath; - m_xUpdateAccess->getByName( "DownloadDestination" ) >>= sValue; - aProperty = m_xReadWriteAccess->getPropertyByHierarchicalName("/org.openoffice.Office.Jobs/Jobs/org.openoffice.Office.Jobs:Job['UpdateCheck']/Arguments/DownloadDestination"); - bReadOnly = (aProperty.Attributes & beans::PropertyAttribute::READONLY) != 0; - m_xChangePathButton->set_sensitive(!bReadOnly); - - if( osl::FileBase::E_None == osl::FileBase::getSystemPathFromFileURL(sValue, aPath) ) - m_xDestPath->set_label(aPath); - - m_xUpdateAccess->getByName( "ExtendedUserAgent" ) >>= bValue; - aProperty = m_xReadWriteAccess->getPropertyByHierarchicalName("/org.openoffice.Office.Jobs/Jobs/org.openoffice.Office.Jobs:Job['UpdateCheck']/Arguments/ExtendedUserAgent"); - bReadOnly = (aProperty.Attributes & beans::PropertyAttribute::READONLY) != 0; - m_xExtrasCheckBox->set_active(bValue); - m_xExtrasCheckBox->set_sensitive(!bReadOnly); - m_xExtrasCheckBox->save_state(); - UpdateUserAgent(); + if (m_showTraditionalOnlineUpdate) { + bool bValue = false; + m_xUpdateAccess->getByName( "AutoCheckEnabled" ) >>= bValue; + beans::Property aProperty = m_xReadWriteAccess->getPropertyByHierarchicalName("/org.openoffice.Office.Jobs/Jobs/org.openoffice.Office.Jobs:Job['UpdateCheck']/Arguments/AutoCheckEnabled"); + bool bReadOnly = (aProperty.Attributes & beans::PropertyAttribute::READONLY) != 0; + + m_xAutoCheckCheckBox->set_active(bValue); + m_xAutoCheckCheckBox->set_sensitive(!bReadOnly); + m_xAutoCheckImg->set_visible(bReadOnly); + + sal_Int64 nValue = 0; + m_xUpdateAccess->getByName( "CheckInterval" ) >>= nValue; + aProperty = m_xReadWriteAccess->getPropertyByHierarchicalName("/org.openoffice.Office.Jobs/Jobs/org.openoffice.Office.Jobs:Job['UpdateCheck']/Arguments/CheckInterval"); + bool bReadOnly2 = (aProperty.Attributes & beans::PropertyAttribute::READONLY) != 0; + m_xEveryDayButton->set_sensitive(bValue && !(bReadOnly || bReadOnly2)); + m_xEveryWeekButton->set_sensitive(bValue && !(bReadOnly || bReadOnly2)); + m_xEveryMonthButton->set_sensitive(bValue && !(bReadOnly || bReadOnly2)); + m_xCheckIntervalImg->set_visible(bReadOnly2); + + if( nValue == 86400 ) + m_xEveryDayButton->set_active(true); + else if( nValue == 604800 ) + m_xEveryWeekButton->set_active(true); + else + m_xEveryMonthButton->set_active(true); + + m_xAutoCheckCheckBox->save_state(); + m_xEveryDayButton->save_state(); + m_xEveryWeekButton->save_state(); + m_xEveryMonthButton->save_state(); + + m_xUpdateAccess->getByName( "AutoDownloadEnabled" ) >>= bValue; + aProperty = m_xReadWriteAccess->getPropertyByHierarchicalName("/org.openoffice.Office.Jobs/Jobs/org.openoffice.Office.Jobs:Job['UpdateCheck']/Arguments/AutoDownloadEnabled"); + bReadOnly = (aProperty.Attributes & beans::PropertyAttribute::READONLY) != 0; + m_xAutoDownloadCheckBox->set_active(bValue); + m_xAutoDownloadCheckBox->set_sensitive(!bReadOnly); + m_xAutoDownloadImg->set_visible(bReadOnly); + m_xDestPathLabel->set_sensitive(true); + m_xDestPath->set_sensitive(true); + + OUString sValue, aPath; + m_xUpdateAccess->getByName( "DownloadDestination" ) >>= sValue; + aProperty = m_xReadWriteAccess->getPropertyByHierarchicalName("/org.openoffice.Office.Jobs/Jobs/org.openoffice.Office.Jobs:Job['UpdateCheck']/Arguments/DownloadDestination"); + bReadOnly = (aProperty.Attributes & beans::PropertyAttribute::READONLY) != 0; + m_xChangePathButton->set_sensitive(!bReadOnly); + + if( osl::FileBase::E_None == osl::FileBase::getSystemPathFromFileURL(sValue, aPath) ) + m_xDestPath->set_label(aPath); + + m_xUpdateAccess->getByName( "ExtendedUserAgent" ) >>= bValue; + aProperty = m_xReadWriteAccess->getPropertyByHierarchicalName("/org.openoffice.Office.Jobs/Jobs/org.openoffice.Office.Jobs:Job['UpdateCheck']/Arguments/ExtendedUserAgent"); + bReadOnly = (aProperty.Attributes & beans::PropertyAttribute::READONLY) != 0; + m_xExtrasCheckBox->set_active(bValue); + m_xExtrasCheckBox->set_sensitive(!bReadOnly); + m_xExtrasImg->set_visible(bReadOnly); + m_xExtrasCheckBox->save_state(); + UpdateUserAgent(); + + m_xAutoDownloadCheckBox->save_state(); + } - m_xAutoDownloadCheckBox->save_state(); + if (m_showMarOnlineUpdate) { + m_xEnableMar->set_active(officecfg::Office::Update::Update::Enabled::get()); + m_xEnableMar->save_state(); + } } void SvxOnlineUpdateTabPage::FillUserData() @@ -328,6 +417,7 @@ IMPL_LINK(SvxOnlineUpdateTabPage, AutoCheckHdl_Impl, weld::Toggleable&, rBox, vo m_xEveryDayButton->set_sensitive(bEnabled && !bReadOnly); m_xEveryWeekButton->set_sensitive(bEnabled && !bReadOnly); m_xEveryMonthButton->set_sensitive(bEnabled && !bReadOnly); + m_xCheckIntervalImg->set_visible(bReadOnly); } IMPL_LINK_NOARG(SvxOnlineUpdateTabPage, ExtrasCheckHdl_Impl, weld::Toggleable&, void) @@ -402,4 +492,25 @@ IMPL_LINK_NOARG(SvxOnlineUpdateTabPage, CheckNowHdl_Impl, weld::Button&, void) } } +bool SvxOnlineUpdateTabPage::isTraditionalOnlineUpdateAvailable() { + try + { + css::uno::Reference < css::uno::XInterface > xService( setup::UpdateCheck::create( ::comphelper::getProcessComponentContext() ) ); + if( xService.is() ) + return true; + } + catch ( css::uno::DeploymentException& ) + { + } + return false; +} + +bool SvxOnlineUpdateTabPage::isMarOnlineUpdateAvailable() { +#if HAVE_FEATURE_UPDATE_MAR + return true; +#else + return false; +#endif +} + /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/cui/source/options/optupdt.hxx b/cui/source/options/optupdt.hxx index 7143bf333f65..48113c8079d6 100644 --- a/cui/source/options/optupdt.hxx +++ b/cui/source/options/optupdt.hxx @@ -28,6 +28,9 @@ class SvxOnlineUpdateTabPage : public SfxTabPage { private: + bool m_showTraditionalOnlineUpdate; + bool m_showMarOnlineUpdate; + OUString m_aNeverChecked; OUString m_aLastCheckedTemplate; @@ -36,18 +39,27 @@ private: std::unique_ptr<weld::Label> m_xNeverChecked; std::unique_ptr<weld::CheckButton> m_xAutoCheckCheckBox; + std::unique_ptr<weld::Widget> m_xAutoCheckImg; std::unique_ptr<weld::RadioButton> m_xEveryDayButton; std::unique_ptr<weld::RadioButton> m_xEveryWeekButton; std::unique_ptr<weld::RadioButton> m_xEveryMonthButton; + std::unique_ptr<weld::Widget> m_xCheckIntervalImg; std::unique_ptr<weld::Button> m_xCheckNowButton; std::unique_ptr<weld::CheckButton> m_xAutoDownloadCheckBox; + std::unique_ptr<weld::Widget> m_xAutoDownloadImg; std::unique_ptr<weld::Label> m_xDestPathLabel; std::unique_ptr<weld::Label> m_xDestPath; std::unique_ptr<weld::Button> m_xChangePathButton; std::unique_ptr<weld::Label> m_xLastChecked; std::unique_ptr<weld::CheckButton> m_xExtrasCheckBox; + std::unique_ptr<weld::Widget> m_xExtrasImg; std::unique_ptr<weld::Label> m_xUserAgentLabel; std::unique_ptr<weld::LinkButton> m_xPrivacyPolicyButton; + std::unique_ptr<weld::Box> m_xBox2; + std::unique_ptr<weld::Frame> m_xFrameDest; + std::unique_ptr<weld::Frame> m_xFrameAgent; + std::unique_ptr<weld::Frame> m_xMar; + std::unique_ptr<weld::CheckButton> m_xEnableMar; DECL_LINK(FileDialogHdl_Impl, weld::Button&, void); DECL_LINK(CheckNowHdl_Impl, weld::Button&, void); @@ -62,9 +74,14 @@ public: static std::unique_ptr<SfxTabPage> Create( weld::Container* pPage, weld::DialogController* pController, const SfxItemSet* rSet ); virtual ~SvxOnlineUpdateTabPage() override; + virtual OUString GetAllStrings() override; + virtual bool FillItemSet( SfxItemSet* rSet ) override; virtual void Reset( const SfxItemSet* rSet ) override; virtual void FillUserData() override; + + static bool isTraditionalOnlineUpdateAvailable(); + static bool isMarOnlineUpdateAvailable(); }; /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/cui/source/options/personalization.cxx b/cui/source/options/personalization.cxx index 02c064d1b2e7..3328760a9855 100644 --- a/cui/source/options/personalization.cxx +++ b/cui/source/options/personalization.cxx @@ -11,6 +11,8 @@ #include "personalization.hxx" +#include <dialmgr.hxx> + #include <comphelper/processfactory.hxx> #include <officecfg/Office/Common.hxx> #include <rtl/bootstrap.hxx> @@ -21,9 +23,9 @@ #include <vcl/settings.hxx> #include <vcl/graphicfilter.hxx> #include <vcl/virdev.hxx> +#include <personas.hrc> using namespace com::sun::star; -using namespace ::com::sun::star::uno; using namespace ::com::sun::star::beans; // persona @@ -33,11 +35,13 @@ SvxPersonalizationTabPage::SvxPersonalizationTabPage(weld::Container* pPage, : SfxTabPage(pPage, pController, "cui/ui/personalization_tab.ui", "PersonalizationTabPage", &rSet) , m_xNoPersona(m_xBuilder->weld_radio_button("no_persona")) + , m_xPersonaImg(m_xBuilder->weld_widget("lockpersona")) , m_xDefaultPersona(m_xBuilder->weld_radio_button("default_persona")) + , m_xContentGrid(m_xBuilder->weld_container("gridpersonasetting")) { for (sal_uInt32 i = 0; i < MAX_DEFAULT_PERSONAS; ++i) { - OString sDefaultId("default" + OString::number(i)); + OUString sDefaultId("default" + OUString::number(i)); m_vDefaultPersonaImages[i] = m_xBuilder->weld_toggle_button(sDefaultId); m_vDefaultPersonaImages[i]->connect_clicked( LINK(this, SvxPersonalizationTabPage, DefaultPersona)); @@ -55,6 +59,23 @@ std::unique_ptr<SfxTabPage> SvxPersonalizationTabPage::Create(weld::Container* p return std::make_unique<SvxPersonalizationTabPage>(pPage, pController, *rSet); } +OUString SvxPersonalizationTabPage::GetAllStrings() +{ + OUString sAllStrings; + OUString radioButton[] = { "no_persona", "default_persona" }; + + for (const auto& radio : radioButton) + { + if (const auto& pString = m_xBuilder->weld_radio_button(radio)) + sAllStrings += pString->get_label() + " "; + } + + if (const auto& pString = m_xBuilder->weld_label("personas_label")) + sAllStrings += pString->get_label() + " "; + + return sAllStrings.replaceAll("_", ""); +} + bool SvxPersonalizationTabPage::FillItemSet(SfxItemSet*) { // persona @@ -63,11 +84,8 @@ bool SvxPersonalizationTabPage::FillItemSet(SfxItemSet*) aPersona = "no"; bool bModified = false; - uno::Reference<uno::XComponentContext> xContext(comphelper::getProcessComponentContext()); - if (xContext.is() - && (aPersona != officecfg::Office::Common::Misc::Persona::get(xContext) - || m_aPersonaSettings - != officecfg::Office::Common::Misc::PersonaSettings::get(xContext))) + if (aPersona != officecfg::Office::Common::Misc::Persona::get() + || m_aPersonaSettings != officecfg::Office::Common::Misc::PersonaSettings::get()) { bModified = true; } @@ -94,20 +112,24 @@ bool SvxPersonalizationTabPage::FillItemSet(SfxItemSet*) void SvxPersonalizationTabPage::Reset(const SfxItemSet*) { - uno::Reference<uno::XComponentContext> xContext(comphelper::getProcessComponentContext()); - // persona - OUString aPersona("default"); - if (xContext.is()) - { - aPersona = officecfg::Office::Common::Misc::Persona::get(xContext); - m_aPersonaSettings = officecfg::Office::Common::Misc::PersonaSettings::get(xContext); - } + OUString aPersona = officecfg::Office::Common::Misc::Persona::get(); + m_aPersonaSettings = officecfg::Office::Common::Misc::PersonaSettings::get(); if (aPersona == "no") m_xNoPersona->set_active(true); else m_xDefaultPersona->set_active(true); + + if (officecfg::Office::Common::Misc::Persona::isReadOnly()) + { + m_xNoPersona->set_sensitive(false); + m_xDefaultPersona->set_sensitive(false); + m_xPersonaImg->set_visible(true); + } + + if (officecfg::Office::Common::Misc::PersonaSettings::isReadOnly()) + m_xContentGrid->set_sensitive(false); } void SvxPersonalizationTabPage::LoadDefaultImages() @@ -123,23 +145,24 @@ void SvxPersonalizationTabPage::LoadDefaultImages() sal_Int32 nIndex = 0; bool foundOne = false; + OStringBuffer aLine; + int nLineNumberFilePersona = 0; while (aStream.IsOpen() && !aStream.eof() && nIndex < MAX_DEFAULT_PERSONAS) { - OString aLine; OUString aPersonaSetting, aPreviewFile, aName; sal_Int32 nParseIndex = 0; aStream.ReadLine(aLine); aPersonaSetting = OStringToOUString(aLine, RTL_TEXTENCODING_UTF8); - aName = aPersonaSetting.getToken(1, ';', nParseIndex); - aPreviewFile = aPersonaSetting.getToken(0, ';', nParseIndex); + aName = CuiResId(RID_PERSONAS_COLOR[nLineNumberFilePersona].first); + aPreviewFile = aPersonaSetting.getToken(2, ';', nParseIndex); if (aPreviewFile.isEmpty()) break; m_vDefaultPersonaSettings.push_back(aPersonaSetting); - INetURLObject aURLObj(gallery + aPreviewFile); + INetURLObject aURLObj(rtl::Concat2View(gallery + aPreviewFile)); aFilter.ImportGraphic(aGraphic, aURLObj); Size aSize(aGraphic.GetSizePixel()); @@ -155,6 +178,7 @@ void SvxPersonalizationTabPage::LoadDefaultImages() m_vDefaultPersonaImages[nIndex]->set_tooltip_text(aName); m_vDefaultPersonaImages[nIndex++]->show(); foundOne = true; + ++nLineNumberFilePersona; } m_xDefaultPersona->set_sensitive(foundOne); diff --git a/cui/source/options/personalization.hxx b/cui/source/options/personalization.hxx index 671f194c244b..786b22c7d7b3 100644 --- a/cui/source/options/personalization.hxx +++ b/cui/source/options/personalization.hxx @@ -18,7 +18,9 @@ class SvxPersonalizationTabPage : public SfxTabPage { private: std::unique_ptr<weld::RadioButton> m_xNoPersona; ///< Just the default look, without any bitmap + std::unique_ptr<weld::Widget> m_xPersonaImg; std::unique_ptr<weld::RadioButton> m_xDefaultPersona; ///< Use the built-in bitmap + std::unique_ptr<weld::Container> m_xContentGrid; std::unique_ptr<weld::ToggleButton> m_vDefaultPersonaImages [MAX_DEFAULT_PERSONAS]; ///< Buttons to show the default persona images OUString m_aPersonaSettings; ///< Header and footer images + color to be set in the settings. @@ -33,6 +35,8 @@ public: static std::unique_ptr<SfxTabPage> Create(weld::Container* pPage, weld::DialogController* pController, const SfxItemSet* rSet); + virtual OUString GetAllStrings() override; + /// Apply the settings ([OK] button). virtual bool FillItemSet(SfxItemSet* rSet) override; diff --git a/cui/source/options/sdbcdriverenum.cxx b/cui/source/options/sdbcdriverenum.cxx index 629fb7056c1e..0ddd7f8f9f08 100644 --- a/cui/source/options/sdbcdriverenum.cxx +++ b/cui/source/options/sdbcdriverenum.cxx @@ -20,7 +20,7 @@ #include "sdbcdriverenum.hxx" #include <comphelper/processfactory.hxx> #include <osl/diagnose.h> -#include <tools/diagnose_ex.h> +#include <comphelper/diagnose_ex.hxx> #include <com/sun/star/lang/XServiceInfo.hpp> #include <com/sun/star/sdbc/DriverManager.hpp> diff --git a/cui/source/options/securityoptions.cxx b/cui/source/options/securityoptions.cxx index f5c94edf1029..d99ad64e545e 100644 --- a/cui/source/options/securityoptions.cxx +++ b/cui/source/options/securityoptions.cxx @@ -17,9 +17,8 @@ * the License at http://www.apache.org/licenses/LICENSE-2.0 . */ -#include <tools/debug.hxx> +#include <securityoptions.hxx> #include <unotools/securityoptions.hxx> -#include "securityoptions.hxx" namespace { @@ -32,6 +31,15 @@ namespace rCheckBox.set_active(SvtSecurityOptions::IsOptionSet(eOption)); return bEnable; } + + void CheckAndSave(SvtSecurityOptions::EOption _eOpt, const bool _bIsChecked, bool& _rModified) + { + if (!SvtSecurityOptions::IsReadOnly(_eOpt) && SvtSecurityOptions::IsOptionSet(_eOpt) != _bIsChecked) + { + SvtSecurityOptions::SetOption(_eOpt, _bIsChecked); + _rModified = true; + } + } } namespace svx @@ -55,6 +63,29 @@ SecurityOptionsDialog::SecurityOptionsDialog(weld::Window* pParent) , m_xCtrlHyperlinkImg(m_xBuilder->weld_widget("lockctrlclick")) , m_xBlockUntrustedRefererLinksCB(m_xBuilder->weld_check_button("blockuntrusted")) , m_xBlockUntrustedRefererLinksImg(m_xBuilder->weld_widget("lockblockuntrusted")) + , m_xDisableActiveContentCB(m_xBuilder->weld_check_button("disableactivecontent")) + , m_xDisableActiveContentImg(m_xBuilder->weld_widget("lockdisableactivecontent")) + , m_xRedlineinfoCB(m_xBuilder->weld_check_button("redlineinfo")) + , m_xRedlineinfoImg(m_xBuilder->weld_widget("lockredlineinfo")) + , m_xDocPropertiesCB(m_xBuilder->weld_check_button("docproperties")) + , m_xDocPropertiesImg(m_xBuilder->weld_widget("lockdocproperties")) + , m_xNoteAuthorCB(m_xBuilder->weld_check_button("noteauthor")) + , m_xNoteAuthorImg(m_xBuilder->weld_widget("locknoteauthor")) + , m_xDocumentVersionCB(m_xBuilder->weld_check_button("documentversion")) + , m_xDocumentVersionImg(m_xBuilder->weld_widget("lockdocumentversion")) + , m_xPrinterSettingsCB(m_xBuilder->weld_check_button("printersettings")) + , m_xPrinterSettingsImg(m_xBuilder->weld_widget("lockprintersettings")) +{ + m_xRemovePersInfoCB->connect_toggled(LINK(this, SecurityOptionsDialog, ShowPersonalInfosToggle)); + init(); +} + +IMPL_LINK_NOARG(SecurityOptionsDialog, ShowPersonalInfosToggle, weld::Toggleable&, void) +{ + changeKeepSecurityInfosEnabled(); +} + +void SecurityOptionsDialog::init() { enableAndSet(SvtSecurityOptions::EOption::DocWarnSaveOrSend, *m_xSaveOrSendDocsCB, *m_xSaveOrSendDocsImg); @@ -66,12 +97,58 @@ SecurityOptionsDialog::SecurityOptionsDialog(weld::Window* pParent) *m_xCreatePdfImg); enableAndSet(SvtSecurityOptions::EOption::DocWarnRemovePersonalInfo, *m_xRemovePersInfoCB, *m_xRemovePersInfoImg); + enableAndSet(SvtSecurityOptions::EOption::DocWarnKeepRedlineInfo, *m_xRedlineinfoCB, + *m_xRedlineinfoImg); + enableAndSet(SvtSecurityOptions::EOption::DocWarnKeepDocUserInfo, *m_xDocPropertiesCB, + *m_xDocPropertiesImg); + enableAndSet(SvtSecurityOptions::EOption::DocWarnKeepNoteAuthorDateInfo, *m_xNoteAuthorCB, + *m_xNoteAuthorImg); + enableAndSet(SvtSecurityOptions::EOption::DocWarnKeepDocVersionInfo, *m_xDocumentVersionCB, + *m_xDocumentVersionImg); + enableAndSet(SvtSecurityOptions::EOption::DocKeepPrinterSettings, *m_xPrinterSettingsCB, + *m_xPrinterSettingsImg); enableAndSet(SvtSecurityOptions::EOption::DocWarnRecommendPassword, *m_xRecommPasswdCB, *m_xRecommPasswdImg); enableAndSet(SvtSecurityOptions::EOption::CtrlClickHyperlink, *m_xCtrlHyperlinkCB, *m_xCtrlHyperlinkImg); enableAndSet(SvtSecurityOptions::EOption::BlockUntrustedRefererLinks, *m_xBlockUntrustedRefererLinksCB, *m_xBlockUntrustedRefererLinksImg); + enableAndSet(SvtSecurityOptions::EOption::DisableActiveContent, + *m_xDisableActiveContentCB, *m_xDisableActiveContentImg); + + if (!SvtSecurityOptions::IsReadOnly(SvtSecurityOptions::EOption::DocWarnRemovePersonalInfo)) + changeKeepSecurityInfosEnabled(); +} + +bool SecurityOptionsDialog::SetSecurityOptions() +{ + bool bModified = false; + CheckAndSave(SvtSecurityOptions::EOption::DocWarnSaveOrSend, IsSaveOrSendDocsChecked(), bModified); + CheckAndSave(SvtSecurityOptions::EOption::DocWarnSigning, IsSignDocsChecked(), bModified); + CheckAndSave(SvtSecurityOptions::EOption::DocWarnPrint, IsPrintDocsChecked(), bModified); + CheckAndSave(SvtSecurityOptions::EOption::DocWarnCreatePdf, IsCreatePdfChecked(), bModified); + CheckAndSave(SvtSecurityOptions::EOption::DocWarnRemovePersonalInfo, IsRemovePersInfoChecked(), bModified); + CheckAndSave(SvtSecurityOptions::EOption::DocWarnKeepRedlineInfo, IsRemoveRedlineInfoChecked(), bModified); + CheckAndSave(SvtSecurityOptions::EOption::DocWarnKeepDocUserInfo, IsRemoveDocUserInfoChecked(), bModified); + CheckAndSave(SvtSecurityOptions::EOption::DocWarnKeepNoteAuthorDateInfo, IsRemoveNoteAuthorInfoChecked(), bModified); + CheckAndSave(SvtSecurityOptions::EOption::DocWarnKeepDocVersionInfo, IsRemoveDocVersionInfoChecked(), bModified); + CheckAndSave(SvtSecurityOptions::EOption::DocKeepPrinterSettings, IsKeepPrinterSettingsChecked(), bModified); + CheckAndSave(SvtSecurityOptions::EOption::DocWarnRecommendPassword, IsRecommPasswdChecked(), bModified); + CheckAndSave(SvtSecurityOptions::EOption::CtrlClickHyperlink, IsCtrlHyperlinkChecked(), bModified); + CheckAndSave(SvtSecurityOptions::EOption::BlockUntrustedRefererLinks, IsBlockUntrustedRefererLinksChecked(), bModified); + CheckAndSave(SvtSecurityOptions::EOption::DisableActiveContent, IsDisableActiveContentChecked(), bModified); + + return bModified; +} + +void SecurityOptionsDialog::changeKeepSecurityInfosEnabled() +{ + bool bEnable = m_xRemovePersInfoCB->get_active(); + m_xRedlineinfoCB->set_sensitive(bEnable); + m_xDocPropertiesCB->set_sensitive(bEnable); + m_xNoteAuthorCB->set_sensitive(bEnable); + m_xDocumentVersionCB->set_sensitive(bEnable); + m_xPrinterSettingsCB->set_sensitive(bEnable); } } diff --git a/cui/source/options/treeopt.cxx b/cui/source/options/treeopt.cxx index a3d2fc54819d..6ab767bb8044 100644 --- a/cui/source/options/treeopt.cxx +++ b/cui/source/options/treeopt.cxx @@ -26,10 +26,10 @@ #include <config_gpgme.h> #include <officecfg/Office/Common.hxx> +#include <officecfg/Office/Writer.hxx> #include <svx/dialogs.hrc> #include <svx/svxids.hrc> -#include <unotools/resmgr.hxx> #include <treeopt.hrc> #include <helpids.h> @@ -63,6 +63,13 @@ #include "personalization.hxx" #include <treeopt.hxx> #include "optbasic.hxx" +#include "optlanguagetool.hxx" +#include "optdeepl.hxx" + +// include search util +#include <com/sun/star/util/SearchFlags.hpp> +#include <com/sun/star/util/SearchAlgorithms2.hpp> +#include <unotools/textsearch.hxx> #include <com/sun/star/awt/XContainerWindowEventHandler.hpp> #include <com/sun/star/awt/ContainerWindowProvider.hpp> @@ -73,13 +80,13 @@ #include <com/sun/star/frame/UnknownModuleException.hpp> #include <com/sun/star/lang/XMultiServiceFactory.hpp> #include <com/sun/star/linguistic2/LinguProperties.hpp> -#include <com/sun/star/setup/UpdateCheck.hpp> #include <comphelper/getexpandeduri.hxx> #include <comphelper/processfactory.hxx> #include <editeng/langitem.hxx> #include <editeng/optitems.hxx> #include <editeng/unolingu.hxx> #include <linguistic/misc.hxx> +#include <o3tl/deleter.hxx> #include <officecfg/Office/OptionsDialog.hxx> #include <sfx2/app.hxx> #include <sfx2/dispatch.hxx> @@ -90,17 +97,17 @@ #include <sfx2/viewfrm.hxx> #include <svl/flagitem.hxx> #include <svl/intitem.hxx> -#include <svl/languageoptions.hxx> #include <svl/cjkoptions.hxx> #include <svl/ctloptions.hxx> #include <svx/databaseregistrationui.hxx> #include <toolkit/helper/vclunohelper.hxx> #include <tools/urlobj.hxx> -#include <tools/diagnose_ex.h> +#include <comphelper/diagnose_ex.hxx> #include <unotools/configmgr.hxx> #include <unotools/moduleoptions.hxx> #include <unotools/optionsdlg.hxx> #include <unotools/viewoptions.hxx> +#include <utility> #include <vcl/help.hxx> #include <vcl/svapp.hxx> #include <vcl/weldutils.hxx> @@ -108,7 +115,6 @@ #include <sal/log.hxx> using namespace ::com::sun::star; -using namespace ::com::sun::star::beans; using namespace ::com::sun::star::container; using namespace ::com::sun::star::frame; using namespace ::com::sun::star::lang; @@ -119,7 +125,7 @@ using namespace ::com::sun::star::util; LastPageSaver* OfaTreeOptionsDialog::pLastPageSaver = nullptr; // some stuff for easier changes for SvtViewOptions -constexpr OUStringLiteral VIEWOPT_DATANAME = u"page data"; +constexpr OUString VIEWOPT_DATANAME = u"page data"_ustr; static void SetViewOptUserItem( SvtViewOptions& rOpt, const OUString& rData ) { @@ -228,42 +234,12 @@ static sal_uInt16 getGroupNodeId( std::u16string_view rModule ) namespace { -class MailMergeCfg_Impl : public utl::ConfigItem +bool MailMergeCfgIsEmailSupported() { -private: - // variables - bool bIsEmailSupported; - - virtual void ImplCommit() override; - -public: - MailMergeCfg_Impl(); - - virtual void Notify( const css::uno::Sequence< OUString >& _rPropertyNames) override; - - bool IsEmailSupported() const {return bIsEmailSupported;} - -}; - -} - -MailMergeCfg_Impl::MailMergeCfg_Impl() : - utl::ConfigItem("Office.Writer/MailMergeWizard"), - bIsEmailSupported(false) -{ - Sequence<OUString> aNames { "EMailSupported" }; - const Sequence< Any > aValues = GetProperties(aNames); - const Any* pValues = aValues.getConstArray(); - if(aValues.hasElements() && pValues[0].hasValue()) - pValues[0] >>= bIsEmailSupported; + std::optional<bool> b = officecfg::Office::Writer::MailMergeWizard::EMailSupported::get(); + return b.has_value() && *b; } -void MailMergeCfg_Impl::ImplCommit() -{ -} - -void MailMergeCfg_Impl::Notify( const css::uno::Sequence< OUString >& ) -{ } //typedef SfxTabPage* (*FNCreateTabPage)(weld::Container* pPage, weld::DialogController* pController, const SfxItemSet &rAttrSet); @@ -297,6 +273,8 @@ static std::unique_ptr<SfxTabPage> CreateGeneralTabPage(sal_uInt16 nId, weld::Co case SID_SB_DBREGISTEROPTIONS: fnCreate = &svx::DbRegistrationOptionsPage::Create; break; case RID_SVXPAGE_ACCESSIBILITYCONFIG: fnCreate = &SvxAccessibilityOptionsTabPage::Create; break; case RID_SVXPAGE_OPTIONS_CTL: fnCreate = &SvxCTLOptionsPage::Create ; break; + case RID_SVXPAGE_LANGTOOL_OPTIONS: fnCreate = &OptLanguageToolTabPage::Create ; break; + case RID_SVXPAGE_DEEPL_OPTIONS: fnCreate = &OptDeeplTabPage::Create ; break; case RID_SVXPAGE_OPTIONS_JAVA: fnCreate = &SvxJavaOptionsPage::Create ; break; #if HAVE_FEATURE_OPENCL case RID_SVXPAGE_OPENCL: fnCreate = &SvxOpenCLTabPage::Create ; break; @@ -464,22 +442,42 @@ struct OptionsGroupInfo m_pModule( pMod ), m_nDialogId( nId ) {} }; -#define INI_LIST() \ - , m_pParent ( pParent )\ - , sTitle ( m_xDialog->get_title() )\ - , bForgetSelection ( false )\ - , bIsFromExtensionManager( false ) \ - , bIsForSetDocumentLanguage( false ) \ - , bNeedsRestart ( false ) \ - , eRestartReason( svtools::RESTART_REASON_NONE ) - -void OfaTreeOptionsDialog::InitWidgets() -{ - xOkPB = m_xBuilder->weld_button("ok"); - xApplyPB = m_xBuilder->weld_button("apply"); - xBackPB = m_xBuilder->weld_button("revert"); - xTreeLB = m_xBuilder->weld_tree_view("pages"); - xTabBox = m_xBuilder->weld_container("box"); +struct OptionsPageIdInfo +{ + OUString m_sParentName; + OUString m_sPageName; + sal_uInt16 m_nParentId; + sal_uInt16 m_nPageId; + + OptionsPageIdInfo(OUString sParentName, OUString sPageName, sal_uInt16 nParentId, + sal_uInt16 nPageId) + : m_sParentName(std::move(sParentName)) + , m_sPageName(std::move(sPageName)) + , m_nParentId(nParentId) + , m_nPageId(nPageId) + { + } +}; + +// Basic ctor with common initialization +OfaTreeOptionsDialog::OfaTreeOptionsDialog(weld::Window* pParent, bool fromExtensionManager) + : SfxOkDialogController(pParent, "cui/ui/optionsdialog.ui", "OptionsDialog") + , xOkPB(m_xBuilder->weld_button("ok")) + , xApplyPB(m_xBuilder->weld_button("apply")) + , xBackPB(m_xBuilder->weld_button("revert")) + , xTreeLB(m_xBuilder->weld_tree_view("pages")) + , xTabBox(m_xBuilder->weld_container("box")) + , m_xSearchEdit(m_xBuilder->weld_entry("searchEntry")) + , m_pParent(pParent) + , m_aUpdateDataTimer("OfaTreeOptionsDialog UpdateDataTimer") + , bIsFirtsInitialize(true) + , sTitle(m_xDialog->get_title()) + , bForgetSelection(false) + , bIsFromExtensionManager(fromExtensionManager) + , bIsForSetDocumentLanguage(false) + , bNeedsRestart(false) + , eRestartReason(svtools::RESTART_REASON_NONE) +{ Size aSize(xTreeLB->get_approximate_digit_width() * 82, xTreeLB->get_height_rows(30)); #if HAVE_FEATURE_GPGME // tdf#115015: make enough space for crypto settings (approx. 14 text edits + padding) @@ -487,38 +485,48 @@ void OfaTreeOptionsDialog::InitWidgets() #endif xTabBox->set_size_request(aSize.Width(), aSize.Height()); xTreeLB->set_size_request(xTreeLB->get_approximate_digit_width() * 35, aSize.Height()); + + // Init tree and handler + xTreeLB->set_help_id(HID_OFADLG_TREELISTBOX); + xTreeLB->connect_changed(LINK(this, OfaTreeOptionsDialog, ShowPageHdl_Impl)); + xBackPB->connect_clicked(LINK(this, OfaTreeOptionsDialog, BackHdl_Impl)); + xApplyPB->connect_clicked(LINK(this, OfaTreeOptionsDialog, ApplyHdl_Impl)); + xOkPB->connect_clicked(LINK(this, OfaTreeOptionsDialog, ApplyHdl_Impl)); + m_xSearchEdit->connect_changed(LINK(this, OfaTreeOptionsDialog, SearchUpdateHdl)); + m_xSearchEdit->connect_focus_out(LINK(this, OfaTreeOptionsDialog, FocusOut_Impl)); + m_xDialog->connect_help(LINK(this, OfaTreeOptionsDialog, HelpHdl_Impl)); + + m_aUpdateDataTimer.SetInvokeHandler(LINK(this, OfaTreeOptionsDialog, ImplUpdateDataHdl)); + m_aUpdateDataTimer.SetTimeout(EDIT_UPDATEDATA_TIMEOUT); + + // Initialize search util + m_options.AlgorithmType2 = util::SearchAlgorithms2::ABSOLUTE; + m_options.transliterateFlags |= TransliterationFlags::IGNORE_CASE; + m_options.searchFlag + |= (util::SearchFlags::REG_NOT_BEGINOFLINE | util::SearchFlags::REG_NOT_ENDOFLINE); + + xTreeLB->set_accessible_name(sTitle); } // Ctor() with Frame ----------------------------------------------------- OfaTreeOptionsDialog::OfaTreeOptionsDialog(weld::Window* pParent, const Reference< XFrame >& _xFrame, bool bActivateLastSelection) - : SfxOkDialogController(pParent, "cui/ui/optionsdialog.ui", "OptionsDialog") - INI_LIST() + : OfaTreeOptionsDialog(pParent, false) { - InitWidgets(); - - InitTreeAndHandler(); Initialize( _xFrame ); LoadExtensionOptions( u"" ); if (bActivateLastSelection) ActivateLastSelection(); - - xTreeLB->set_accessible_name(m_xDialog->get_title()); } // Ctor() with ExtensionId ----------------------------------------------- OfaTreeOptionsDialog::OfaTreeOptionsDialog(weld::Window* pParent, std::u16string_view rExtensionId) - : SfxOkDialogController(pParent, "cui/ui/optionsdialog.ui", "OptionsDialog") - INI_LIST() + : OfaTreeOptionsDialog(pParent, !rExtensionId.empty()) { - InitWidgets(); - - bIsFromExtensionManager = ( !rExtensionId.empty() ); - InitTreeAndHandler(); LoadExtensionOptions( rExtensionId ); ActivateLastSelection(); } -OfaTreeOptionsDialog::~OfaTreeOptionsDialog() +void OfaTreeOptionsDialog::ImplDestroy() { xCurrentPageEntry.reset(); @@ -530,7 +538,7 @@ OfaTreeOptionsDialog::~OfaTreeOptionsDialog() // if Child (has parent), then OptionsPageInfo if (xTreeLB->get_iter_depth(*xEntry)) { - OptionsPageInfo *pPageInfo = reinterpret_cast<OptionsPageInfo*>(xTreeLB->get_id(*xEntry).toInt64()); + OptionsPageInfo *pPageInfo = weld::fromId<OptionsPageInfo*>(xTreeLB->get_id(*xEntry)); if(pPageInfo->m_xPage) { pPageInfo->m_xPage->FillUserData(); @@ -566,7 +574,7 @@ OfaTreeOptionsDialog::~OfaTreeOptionsDialog() { if (!xTreeLB->get_iter_depth(*xEntry)) { - OptionsGroupInfo* pGroupInfo = reinterpret_cast<OptionsGroupInfo*>(xTreeLB->get_id(*xEntry).toInt64()); + OptionsGroupInfo* pGroupInfo = weld::fromId<OptionsGroupInfo*>(xTreeLB->get_id(*xEntry)); delete pGroupInfo; } bEntry = xTreeLB->iter_next(*xEntry); @@ -574,6 +582,11 @@ OfaTreeOptionsDialog::~OfaTreeOptionsDialog() deleteGroupNames(); } +OfaTreeOptionsDialog::~OfaTreeOptionsDialog() +{ + suppress_fun_call_w_exception(ImplDestroy()); +} + OptionsPageInfo* OfaTreeOptionsDialog::AddTabPage( sal_uInt16 nId, const OUString& rPageName, sal_uInt16 nGroup ) { @@ -583,7 +596,7 @@ OptionsPageInfo* OfaTreeOptionsDialog::AddTabPage( xTreeLB->iter_nth_sibling(*xParent, nGroup); OptionsPageInfo* pPageInfo = new OptionsPageInfo( nId ); - OUString sId(OUString::number(reinterpret_cast<sal_Int64>(pPageInfo))); + OUString sId(weld::toId(pPageInfo)); xTreeLB->insert(xParent.get(), -1, &rPageName, &sId, nullptr, nullptr, false, nullptr); return pPageInfo; } @@ -596,7 +609,7 @@ sal_uInt16 OfaTreeOptionsDialog::AddGroup(const OUString& rGroupName, { OptionsGroupInfo* pInfo = new OptionsGroupInfo( pCreateShell, pCreateModule, nDialogId ); - OUString sId(OUString::number(reinterpret_cast<sal_Int64>(pInfo))); + OUString sId(weld::toId(pInfo)); xTreeLB->append(sId, rGroupName); sal_uInt16 nRet = 0; @@ -621,13 +634,13 @@ void OfaTreeOptionsDialog::ResetCurrentPageFromConfig() if (!(xCurrentPageEntry && xTreeLB->get_iter_depth(*xCurrentPageEntry))) return; - OptionsPageInfo* pPageInfo = reinterpret_cast<OptionsPageInfo*>(xTreeLB->get_id(*xCurrentPageEntry).toInt64()); + OptionsPageInfo* pPageInfo = weld::fromId<OptionsPageInfo*>(xTreeLB->get_id(*xCurrentPageEntry)); if (pPageInfo->m_xPage) { std::unique_ptr<weld::TreeIter> xParent = xTreeLB->make_iterator(xCurrentPageEntry.get()); xTreeLB->iter_parent(*xParent); OptionsGroupInfo* pGroupInfo = - reinterpret_cast<OptionsGroupInfo*>(xTreeLB->get_id(*xParent).toInt64()); + weld::fromId<OptionsGroupInfo*>(xTreeLB->get_id(*xParent)); pPageInfo->m_xPage->Reset( &*pGroupInfo->m_pInItemSet ); } else if ( pPageInfo->m_xExtPage ) @@ -647,13 +660,13 @@ void OfaTreeOptionsDialog::ApplyOptions() { if (xTreeLB->get_iter_depth(*xEntry)) { - OptionsPageInfo* pPageInfo = reinterpret_cast<OptionsPageInfo*>(xTreeLB->get_id(*xEntry).toInt64()); + OptionsPageInfo* pPageInfo = weld::fromId<OptionsPageInfo*>(xTreeLB->get_id(*xEntry)); if ( pPageInfo->m_xPage && !pPageInfo->m_xPage->HasExchangeSupport() ) { std::unique_ptr<weld::TreeIter> xParent = xTreeLB->make_iterator(xEntry.get()); xTreeLB->iter_parent(*xParent); OptionsGroupInfo* pGroupInfo = - reinterpret_cast<OptionsGroupInfo*>(xTreeLB->get_id(*xParent).toInt64()); + weld::fromId<OptionsGroupInfo*>(xTreeLB->get_id(*xParent)); pPageInfo->m_xPage->FillItemSet(pGroupInfo->m_pOutItemSet.get()); } @@ -677,11 +690,11 @@ IMPL_LINK_NOARG(OfaTreeOptionsDialog, HelpHdl_Impl, weld::Widget&, bool) Help* pHelp = Application::GetHelp(); if (pHelp && xCurrentPageEntry && xTreeLB->get_iter_depth(*xCurrentPageEntry)) { - OptionsPageInfo* pPageInfo = reinterpret_cast<OptionsPageInfo*>(xTreeLB->get_id(*xCurrentPageEntry).toInt64()); + OptionsPageInfo* pPageInfo = weld::fromId<OptionsPageInfo*>(xTreeLB->get_id(*xCurrentPageEntry)); if (pPageInfo->m_xPage) { - OString sHelpId(pPageInfo->m_xPage->GetHelpId()); - pHelp->Start(OStringToOUString(sHelpId, RTL_TEXTENCODING_UTF8), m_xDialog.get()); + OUString sHelpId(pPageInfo->m_xPage->GetHelpId()); + pHelp->Start(sHelpId, m_xDialog.get()); return false; } } @@ -696,13 +709,13 @@ IMPL_LINK(OfaTreeOptionsDialog, ApplyHdl_Impl, weld::Button&, rButton, void) if (xCurrentPageEntry && xTreeLB->get_iter_depth(*xCurrentPageEntry)) { - OptionsPageInfo* pPageInfo = reinterpret_cast<OptionsPageInfo*>(xTreeLB->get_id(*xCurrentPageEntry).toInt64()); + OptionsPageInfo* pPageInfo = weld::fromId<OptionsPageInfo*>(xTreeLB->get_id(*xCurrentPageEntry)); if ( pPageInfo->m_xPage ) { std::unique_ptr<weld::TreeIter> xParent = xTreeLB->make_iterator(xCurrentPageEntry.get()); xTreeLB->iter_parent(*xParent); - pGroupInfo = reinterpret_cast<OptionsGroupInfo*>(xTreeLB->get_id(*xParent).toInt64()); + pGroupInfo = weld::fromId<OptionsGroupInfo*>(xTreeLB->get_id(*xParent)); if ( RID_SVXPAGE_COLOR != pPageInfo->m_nPageId && pPageInfo->m_xPage->HasExchangeSupport() ) { @@ -766,6 +779,306 @@ IMPL_LINK(OfaTreeOptionsDialog, ApplyHdl_Impl, weld::Button&, rButton, void) m_xDialog->response(RET_OK); } +IMPL_LINK_NOARG(OfaTreeOptionsDialog, FocusOut_Impl, weld::Widget&, void) +{ + if (m_aUpdateDataTimer.IsActive()) + { + m_aUpdateDataTimer.Stop(); + m_aUpdateDataTimer.Invoke(); + } +} + +IMPL_LINK_NOARG(OfaTreeOptionsDialog, SearchUpdateHdl, weld::Entry&, void) +{ + m_aUpdateDataTimer.Start(); +} + +IMPL_LINK_NOARG(OfaTreeOptionsDialog, ImplUpdateDataHdl, Timer*, void) +{ + // initializeFirstNDialog() can take a long time, show wait cursor and disable input + std::unique_ptr<weld::WaitObject> xWait(m_pParent ? new weld::WaitObject(m_pParent) : nullptr); + + // Pause redraw + xTreeLB->freeze(); + + if (bIsFirtsInitialize) + { + m_xSearchEdit->freeze(); + xTreeLB->hide(); + + initializeFirstNDialog(); + + m_xSearchEdit->thaw(); + xTreeLB->show(); + bIsFirtsInitialize = false; + } + + // Apply the search filter + OUString aSearchTerm(m_xSearchEdit->get_text()); + int nMatchFound = applySearchFilter(aSearchTerm); + + // Resume redraw + xTreeLB->thaw(); + + // select first child of first node after the search done + if (nMatchFound != -1) + selectFirstEntry(); +} + +void OfaTreeOptionsDialog::selectFirstEntry() +{ + std::unique_ptr<weld::TreeIter> xTemp = xTreeLB->make_iterator(); + bool bTemp = xTreeLB->get_iter_first(*xTemp); + + while (bTemp) + { + // select only the first child + if (xTreeLB->get_iter_depth(*xTemp) && xTreeLB->get_id(*xTemp).toInt64()) + { + std::unique_ptr<weld::TreeIter> xEntry(xTreeLB->make_iterator(xTemp.get())); + + std::unique_ptr<weld::TreeIter> xParent(xTreeLB->make_iterator(xEntry.get())); + xTreeLB->iter_parent(*xParent); + xTreeLB->expand_row(*xParent); + xTreeLB->scroll_to_row(*xParent); + xTreeLB->scroll_to_row(*xEntry); + xTreeLB->set_cursor(*xEntry); + xTreeLB->select(*xEntry); + SelectHdl_Impl(); + + break; + } + bTemp = xTreeLB->iter_next(*xTemp); + } +} + +void OfaTreeOptionsDialog::initializeFirstNDialog(sal_Int16 nNumberOfNode) +{ + std::unique_ptr<weld::TreeIter> xEntry; + sal_Int16 nCount = 0; + + std::unique_ptr<weld::TreeIter> xTemp = xTreeLB->make_iterator(); + bool bTemp = xTreeLB->get_iter_first(*xTemp); + + while (bTemp) + { + if (xTreeLB->get_iter_depth(*xTemp) && xTreeLB->get_id(*xTemp).toInt64()) + { + if (!(xEntry = xTreeLB->make_iterator(xTemp.get()))) + { + xEntry = xTreeLB->make_iterator(); + if (!xTreeLB->get_iter_first(*xEntry) || !xTreeLB->iter_next(*xEntry)) + xEntry.reset(); + } + + if (!xEntry) + return; + + OptionsPageInfo* pPageInfo = weld::fromId<OptionsPageInfo*>(xTreeLB->get_id(*xEntry)); + if (TreeOptHelper::getStringsFromDialog(pPageInfo->m_nPageId).isEmpty()) + { + SolarMutexGuard aGuard; + initializeCurrentDialog(pPageInfo, xEntry); + } + } + + /* if nNumberOfNode is -1 (which is the default value if no parameter provided), + this function will initialize all dialogs since nCount always greater than -1 */ + if (nCount == nNumberOfNode) + break; + + ++nCount; + bTemp = xTreeLB->iter_next(*xTemp); + } +} + +void OfaTreeOptionsDialog::clearOptionsDialog() +{ + // clear and reset + std::unique_ptr<weld::TreeIter> xEntry = xTreeLB->make_iterator(); + bool bEntry = xTreeLB->get_iter_first(*xEntry); + + while (bEntry) + { + if (xTreeLB->get_iter_depth(*xEntry)) + { + OptionsPageInfo* pPageInfo = weld::fromId<OptionsPageInfo*>(xTreeLB->get_id(*xEntry)); + if (pPageInfo->m_xPage) + pPageInfo->m_xPage.reset(); + } + bEntry = xTreeLB->iter_next(*xEntry); + } + xCurrentPageEntry.reset(); +} + +// store Options tree with their page names +void OfaTreeOptionsDialog::storeOptionsTree() +{ + m_aTreePageIds.clear(); + + sal_uInt16 aParentId = 0; + OUString sParentName; + + std::unique_ptr<weld::TreeIter> xEntry = xTreeLB->make_iterator(); + bool bEntry = xTreeLB->get_iter_first(*xEntry); + + while (bEntry) + { + OptionsGroupInfo* pGroupInfo = weld::fromId<OptionsGroupInfo*>(xTreeLB->get_id(*xEntry)); + bool bIsParentNode = !xTreeLB->get_iter_depth(*xEntry); + + if (bIsParentNode) + { + // Parent node + sParentName = xTreeLB->get_text(*xEntry); + aParentId = pGroupInfo->m_nDialogId; + m_aTreePageIds.push_back(new OptionsPageIdInfo(sParentName, sParentName, aParentId, 0)); + } + else + { + // Child node + OUString sChildName = xTreeLB->get_text(*xEntry); + OptionsPageInfo* pPageInfo = weld::fromId<OptionsPageInfo*>(xTreeLB->get_id(*xEntry)); + m_aTreePageIds.push_back( + new OptionsPageIdInfo(sParentName, sChildName, aParentId, pPageInfo->m_nPageId)); + } + bEntry = xTreeLB->iter_next(*xEntry); + } +} + +int OfaTreeOptionsDialog::applySearchFilter(const OUString& rSearchTerm) +{ + if (rSearchTerm.isEmpty()) + { + clearOptionsDialog(); + xTreeLB->clear(); + Initialize(m_xFrame); + + return 0; + } + + m_options.searchString = rSearchTerm; + utl::TextSearch textSearch(m_options); + + clearOptionsDialog(); + + if (xTreeLB->n_children() > 0) + xTreeLB->clear(); + + std::vector<std::pair<sal_uInt16, std::vector<sal_uInt16>>> aFoundIdsVector; + + for (std::size_t i = 0; i < m_aTreePageIds.size(); ++i) + { + const OUString sParentName = m_aTreePageIds[i]->m_sParentName; + const OUString sPageName = m_aTreePageIds[i]->m_sPageName; + const sal_uInt16 nParentId = m_aTreePageIds[i]->m_nParentId; + const sal_uInt16 nPageId = m_aTreePageIds[i]->m_nPageId; + + const OUString sPageStrings = TreeOptHelper::getStringsFromDialog(nPageId); + const OUString sPageNameAndStrings = sParentName + " " + sPageName + " " + sPageStrings; + + sal_Int32 aStartPos = 0; + sal_Int32 aEndPos = sPageNameAndStrings.getLength(); + + // check if rSearchTerm matches with sPageNameAndStrings + if (textSearch.SearchForward(sPageNameAndStrings, &aStartPos, &aEndPos)) + { + bool isFound = false; + for (auto& aEntryId : aFoundIdsVector) + { + if (aEntryId.first == nParentId) + { + isFound = true; + aEntryId.second.push_back(nPageId); + } + } + + if (!isFound) + aFoundIdsVector.push_back({ nParentId, { nPageId } }); + } + } + + showDialog(aFoundIdsVector); + + // if treeview is empty, return -1 + return xTreeLB->n_children() ? 0 : -1; +} + +void OfaTreeOptionsDialog::showDialog(VectorOfMatchedIds& pSearchIds) +{ + // + // void generalOptions(); // SID_GENERAL_OPTIONS + // void loadAndSaveOptions(); // SID_FILTER_DLG + // void languageOptions(); // SID_LANGUAGE_OPTIONS + // void writerOptions(); // SID_SW_EDITOPTIONS + // void writerWebOptions(); // SID_SW_ONLINEOPTIONS + // void calcOptions(); // SID_SC_EDITOPTIONS + // void impressOptions(); // SID_SD_EDITOPTIONS + // void drawOptions(); // SID_SD_GRAPHIC_OPTIONS + // void mathOptions(); // SID_SM_EDITOPTIONS + // void databaseOptions(); // SID_SB_STARBASEOPTIONS + // void chartOptions(); // SID_SCH_EDITOPTIONS + // void internetOptions(); // SID_INET_DLG + // + + for (auto& aEntryId : pSearchIds) + { + switch (aEntryId.first) + { + case SID_GENERAL_OPTIONS: + generalOptions(aEntryId.second); + break; + + case SID_FILTER_DLG: + loadAndSaveOptions(aEntryId.second); + break; + + case SID_LANGUAGE_OPTIONS: + languageOptions(aEntryId.second); + break; + + case SID_SW_EDITOPTIONS: + writerOptions(aEntryId.second); + break; + + case SID_SW_ONLINEOPTIONS: + writerWebOptions(aEntryId.second); + break; + + case SID_SC_EDITOPTIONS: + calcOptions(aEntryId.second); + break; + + case SID_SD_EDITOPTIONS: + impressOptions(aEntryId.second); + break; + + case SID_SD_GRAPHIC_OPTIONS: + drawOptions(aEntryId.second); + break; + + case SID_SM_EDITOPTIONS: + mathOptions(aEntryId.second); + break; + + case SID_SB_STARBASEOPTIONS: + databaseOptions(aEntryId.second); + break; + + case SID_SCH_EDITOPTIONS: + chartOptions(aEntryId.second); + break; + + case SID_INET_DLG: + internetOptions(aEntryId.second); + break; + + default: + break; + } + } +} + void OfaTreeOptionsDialog::ApplyItemSets() { std::unique_ptr<weld::TreeIter> xEntry = xTreeLB->make_iterator(); @@ -774,7 +1087,7 @@ void OfaTreeOptionsDialog::ApplyItemSets() { if (!xTreeLB->get_iter_depth(*xEntry)) { - OptionsGroupInfo* pGroupInfo = reinterpret_cast<OptionsGroupInfo*>(xTreeLB->get_id(*xEntry).toInt64()); + OptionsGroupInfo* pGroupInfo = weld::fromId<OptionsGroupInfo*>(xTreeLB->get_id(*xEntry)); if(pGroupInfo->m_pOutItemSet) { if(pGroupInfo->m_pShell) @@ -787,16 +1100,6 @@ void OfaTreeOptionsDialog::ApplyItemSets() } } -void OfaTreeOptionsDialog::InitTreeAndHandler() -{ - xTreeLB->set_help_id(HID_OFADLG_TREELISTBOX); - xTreeLB->connect_changed( LINK( this, OfaTreeOptionsDialog, ShowPageHdl_Impl ) ); - xBackPB->connect_clicked( LINK( this, OfaTreeOptionsDialog, BackHdl_Impl ) ); - xApplyPB->connect_clicked( LINK( this, OfaTreeOptionsDialog, ApplyHdl_Impl ) ); - xOkPB->connect_clicked( LINK( this, OfaTreeOptionsDialog, ApplyHdl_Impl ) ); - m_xDialog->connect_help( LINK( this, OfaTreeOptionsDialog, HelpHdl_Impl ) ); -} - void OfaTreeOptionsDialog::ActivatePage( sal_uInt16 nResId ) { bIsForSetDocumentLanguage = false; @@ -850,7 +1153,7 @@ void OfaTreeOptionsDialog::ActivateLastSelection() // restore only selection of a leaf if (xTreeLB->get_iter_depth(*xTemp) && xTreeLB->get_id(*xTemp).toInt64()) { - OptionsPageInfo* pPageInfo = reinterpret_cast<OptionsPageInfo*>(xTreeLB->get_id(*xTemp).toInt64()); + OptionsPageInfo* pPageInfo = weld::fromId<OptionsPageInfo*>(xTreeLB->get_id(*xTemp)); OUString sPageURL = pPageInfo->m_sPageURL; if ( bMustExpand ) { @@ -887,7 +1190,16 @@ void OfaTreeOptionsDialog::ActivateLastSelection() xTreeLB->scroll_to_row(*xEntry); xTreeLB->set_cursor(*xEntry); xTreeLB->select(*xEntry); - xTreeLB->grab_focus(); + m_xSearchEdit->grab_focus(); + SelectHdl_Impl(); + + // initializeFirstNDialog() can take a long time, show wait cursor + std::unique_ptr<weld::WaitObject> xWait(m_pParent ? new weld::WaitObject(m_pParent) : nullptr); + + /* initialize first 25 dialogs which are almost half of the dialogs + in a row while Options dialog opens. then clear&reselect to avoid UI test failures. */ + initializeFirstNDialog(25); + clearOptionsDialog(); SelectHdl_Impl(); } @@ -903,6 +1215,70 @@ void OfaTreeOptionsDialog::InitItemSets(OptionsGroupInfo& rGroupInfo) rGroupInfo.m_pInItemSet->GetRanges()); } +void OfaTreeOptionsDialog::initializeCurrentDialog(OptionsPageInfo*& pPageInfo, + std::unique_ptr<weld::TreeIter>& xEntry) +{ + std::unique_ptr<weld::TreeIter> xParent(xTreeLB->make_iterator(xEntry.get())); + bool bParent = xTreeLB->iter_parent(*xParent); + + if (!bParent) + return; + + if (pPageInfo->m_xPage) + { + TreeOptHelper::storeStringsOfDialog(pPageInfo->m_nPageId, + pPageInfo->m_xPage->GetAllStrings()); + return; + } + + OptionsGroupInfo* pGroupInfo = weld::fromId<OptionsGroupInfo*>(xTreeLB->get_id(*xParent)); + + if (!pPageInfo->m_xPage && pPageInfo->m_nPageId > 0) + { + InitItemSets(*pGroupInfo); + + pPageInfo->m_xPage = ::CreateGeneralTabPage(pPageInfo->m_nPageId, xTabBox.get(), this, + *pGroupInfo->m_pInItemSet); + + if (!pPageInfo->m_xPage && pGroupInfo->m_pModule) + pPageInfo->m_xPage = pGroupInfo->m_pModule->CreateTabPage( + pPageInfo->m_nPageId, xTabBox.get(), this, *pGroupInfo->m_pInItemSet); + + DBG_ASSERT(pPageInfo->m_xPage, "tabpage could not created"); + if (pPageInfo->m_xPage) + { + SvtViewOptions aTabPageOpt(EViewType::TabPage, OUString::number(pPageInfo->m_nPageId)); + pPageInfo->m_xPage->SetUserData(GetViewOptUserItem(aTabPageOpt)); + pPageInfo->m_xPage->SetFrame(m_xFrame); + pPageInfo->m_xPage->Reset(&*pGroupInfo->m_pInItemSet); + } + + TreeOptHelper::storeStringsOfDialog(pPageInfo->m_nPageId, + pPageInfo->m_xPage->GetAllStrings()); + + pPageInfo->m_xPage->set_visible(false); + } + else if (0 == pPageInfo->m_nPageId && !pPageInfo->m_xExtPage) + { + if (!m_xContainerWinProvider.is()) + m_xContainerWinProvider + = awt::ContainerWindowProvider::create(::comphelper::getProcessComponentContext()); + + pPageInfo->m_xExtPage = std::make_unique<ExtensionsTabPage>( + xTabBox.get(), pPageInfo->m_sPageURL, pPageInfo->m_sEventHdl, m_xContainerWinProvider); + + pPageInfo->m_xExtPage->Hide(); + } + + BuilderPage* pNewPage = pPageInfo->m_xPage.get(); + + // fdo#58170 use current page's layout child HelpId, unless there isn't a current page + OUString sHelpId(pNewPage ? pNewPage->GetHelpId() : OUString()); + if (sHelpId.isEmpty()) + sHelpId = HID_OFADLG_TREELISTBOX; + xTreeLB->set_help_id(sHelpId); +} + void OfaTreeOptionsDialog::SelectHdl_Impl() { std::unique_ptr<weld::TreeIter> xEntry(xTreeLB->make_iterator()); @@ -923,14 +1299,14 @@ void OfaTreeOptionsDialog::SelectHdl_Impl() BuilderPage* pNewPage = nullptr; OptionsPageInfo* pOptPageInfo = (xCurrentPageEntry && xTreeLB->get_iter_depth(*xCurrentPageEntry)) - ? reinterpret_cast<OptionsPageInfo*>(xTreeLB->get_id(*xCurrentPageEntry).toInt64()) : nullptr; + ? weld::fromId<OptionsPageInfo*>(xTreeLB->get_id(*xCurrentPageEntry)) : nullptr; if (pOptPageInfo && pOptPageInfo->m_xPage && pOptPageInfo->m_xPage->IsVisible()) { std::unique_ptr<weld::TreeIter> xCurParent(xTreeLB->make_iterator(xCurrentPageEntry.get())); xTreeLB->iter_parent(*xCurParent); - OptionsGroupInfo* pGroupInfo = reinterpret_cast<OptionsGroupInfo*>(xTreeLB->get_id(*xCurParent).toInt64()); + OptionsGroupInfo* pGroupInfo = weld::fromId<OptionsGroupInfo*>(xTreeLB->get_id(*xCurParent)); DeactivateRC nLeave = DeactivateRC::LeavePage; if ( RID_SVXPAGE_COLOR != pOptPageInfo->m_nPageId && pOptPageInfo->m_xPage->HasExchangeSupport() ) nLeave = pOptPageInfo->m_xPage->DeactivatePage( pGroupInfo->m_pOutItemSet.get() ); @@ -951,8 +1327,8 @@ void OfaTreeOptionsDialog::SelectHdl_Impl() pOptPageInfo->m_xExtPage->DeactivatePage(); } - OptionsPageInfo *pPageInfo = reinterpret_cast<OptionsPageInfo*>(xTreeLB->get_id(*xEntry).toInt64()); - OptionsGroupInfo* pGroupInfo = reinterpret_cast<OptionsGroupInfo*>(xTreeLB->get_id(*xParent).toInt64()); + OptionsPageInfo *pPageInfo = weld::fromId<OptionsPageInfo*>(xTreeLB->get_id(*xEntry)); + OptionsGroupInfo* pGroupInfo = weld::fromId<OptionsGroupInfo*>(xTreeLB->get_id(*xParent)); if(!pPageInfo->m_xPage && pPageInfo->m_nPageId > 0) { InitItemSets(*pGroupInfo); @@ -967,6 +1343,7 @@ void OfaTreeOptionsDialog::SelectHdl_Impl() { SvtViewOptions aTabPageOpt( EViewType::TabPage, OUString::number( pPageInfo->m_nPageId) ); pPageInfo->m_xPage->SetUserData( GetViewOptUserItem( aTabPageOpt ) ); + pPageInfo->m_xPage->SetFrame( m_xFrame ); pPageInfo->m_xPage->Reset( &*pGroupInfo->m_pInItemSet ); } } @@ -1022,7 +1399,7 @@ void OfaTreeOptionsDialog::SelectHdl_Impl() pNewPage = pPageInfo->m_xPage.get(); // fdo#58170 use current page's layout child HelpId, unless there isn't a current page - OString sHelpId(pNewPage ? pNewPage->GetHelpId() : OString()); + OUString sHelpId(pNewPage ? pNewPage->GetHelpId() : OUString()); if (sHelpId.isEmpty()) sHelpId = HID_OFADLG_TREELISTBOX; xTreeLB->set_help_id(sHelpId); @@ -1046,18 +1423,19 @@ std::optional<SfxItemSet> OfaTreeOptionsDialog::CreateItemSet( sal_uInt16 nId ) SID_ATTR_YEAR2000, SID_ATTR_YEAR2000> ); SfxItemSetFixed<SID_ATTR_QUICKLAUNCHER, SID_ATTR_QUICKLAUNCHER> aOptSet( SfxGetpApp()->GetPool() ); - SfxGetpApp()->GetOptions(aOptSet); + SfxApplication::GetOptions(aOptSet); pRet->Put(aOptSet); SfxViewFrame* pViewFrame = SfxViewFrame::Current(); if ( pViewFrame ) { - const SfxPoolItem* pItem = nullptr; - SfxDispatcher* pDispatch = pViewFrame->GetDispatcher(); + SfxPoolItemHolder aResult; + const SfxItemState aState(pViewFrame->GetDispatcher()->QueryState(SID_ATTR_YEAR2000, aResult)); + const SfxUInt16Item* pItem(static_cast<const SfxUInt16Item*>(aResult.getItem())); // miscellaneous - Year2000 - if( SfxItemState::DEFAULT <= pDispatch->QueryState( SID_ATTR_YEAR2000, pItem ) ) - pRet->Put( SfxUInt16Item( SID_ATTR_YEAR2000, static_cast<const SfxUInt16Item*>(pItem)->GetValue() ) ); + if(SfxItemState::DEFAULT <= aState && nullptr != pItem) + pRet->Put( SfxUInt16Item( SID_ATTR_YEAR2000, pItem->GetValue() ) ); else pRet->Put( SfxUInt16Item( SID_ATTR_YEAR2000, officecfg::Office::Common::DateFormat::TwoDigitYear::get() ) ); } @@ -1102,31 +1480,28 @@ std::optional<SfxItemSet> OfaTreeOptionsDialog::CreateItemSet( sal_uInt16 nId ) SfxViewFrame* pViewFrame = SfxViewFrame::Current(); if ( pViewFrame ) { - const SfxPoolItem* pItem = nullptr; - SfxDispatcher* pDispatch = pViewFrame->GetDispatcher(); - if(SfxItemState::DEFAULT <= pDispatch->QueryState(SID_ATTR_LANGUAGE, pItem)) - pRet->Put( - SvxLanguageItem( - (static_cast<const SvxLanguageItem*>(pItem) - ->GetLanguage()), - SID_ATTR_LANGUAGE)); - if(SfxItemState::DEFAULT <= pDispatch->QueryState(SID_ATTR_CHAR_CJK_LANGUAGE, pItem)) - pRet->Put( - SvxLanguageItem( - (static_cast<const SvxLanguageItem*>(pItem) - ->GetLanguage()), - SID_ATTR_CHAR_CJK_LANGUAGE)); - if(SfxItemState::DEFAULT <= pDispatch->QueryState(SID_ATTR_CHAR_CTL_LANGUAGE, pItem)) - pRet->Put( - SvxLanguageItem( - (static_cast<const SvxLanguageItem*>(pItem) - ->GetLanguage()), - SID_ATTR_CHAR_CTL_LANGUAGE)); + SfxPoolItemHolder aResult; + SfxDispatcher* pDispatch(pViewFrame->GetDispatcher()); + + SfxItemState aState(pDispatch->QueryState(SID_ATTR_LANGUAGE, aResult)); + if(SfxItemState::DEFAULT <= aState) + pRet->Put(*aResult.getItem()); + + aState = pDispatch->QueryState(SID_ATTR_CHAR_CJK_LANGUAGE, aResult); + if(SfxItemState::DEFAULT <= aState) + pRet->Put(*aResult.getItem()); + + aState = pDispatch->QueryState(SID_ATTR_CHAR_CTL_LANGUAGE, aResult); + if(SfxItemState::DEFAULT <= aState) + pRet->Put(*aResult.getItem()); pRet->Put(aHyphen); - if(SfxItemState::DEFAULT <= pDispatch->QueryState(SID_AUTOSPELL_CHECK, pItem)) + + aState = pDispatch->QueryState(SID_AUTOSPELL_CHECK, aResult); + if(SfxItemState::DEFAULT <= aState) { - pRet->Put(std::unique_ptr<SfxPoolItem>(pItem->Clone())); + pRet->Put(*aResult.getItem()); // allow share/refcounting + // pRet->Put(std::unique_ptr<SfxPoolItem>(aResult.getItem()->Clone())); } else { @@ -1147,9 +1522,9 @@ std::optional<SfxItemSet> OfaTreeOptionsDialog::CreateItemSet( sal_uInt16 nId ) svl::Items< //SID_OPTIONS_START - ..END SID_SAVEREL_INET, SID_SAVEREL_FSYS, - SID_INET_NOPROXY, SID_INET_FTP_PROXY_PORT, + SID_INET_NOPROXY, SID_INET_HTTP_PROXY_PORT, SID_SECURE_URL, SID_SECURE_URL> ); - SfxGetpApp()->GetOptions(*pRet); + SfxApplication::GetOptions(*pRet); break; case SID_FILTER_DLG: pRet.emplace( @@ -1159,7 +1534,7 @@ std::optional<SfxItemSet> OfaTreeOptionsDialog::CreateItemSet( sal_uInt16 nId ) SID_ATTR_DOCINFO, SID_ATTR_AUTOSAVEMINUTE, SID_SAVEREL_INET, SID_SAVEREL_FSYS, SID_ATTR_PRETTYPRINTING, SID_ATTR_PRETTYPRINTING> ); - SfxGetpApp()->GetOptions(*pRet); + SfxApplication::GetOptions(*pRet); break; case SID_SB_STARBASEOPTIONS: @@ -1171,9 +1546,8 @@ std::optional<SfxItemSet> OfaTreeOptionsDialog::CreateItemSet( sal_uInt16 nId ) case SID_SCH_EDITOPTIONS: { - SvxChartOptions aChartOpt; pRet.emplace( SfxGetpApp()->GetPool(), svl::Items<SID_SCH_EDITOPTIONS, SID_SCH_EDITOPTIONS> ); - pRet->Put( SvxChartColorTableItem( SID_SCH_EDITOPTIONS, aChartOpt.GetDefaultColors() ) ); + pRet->Put( SvxChartColorTableItem( SID_SCH_EDITOPTIONS, SvxChartOptions::GetDefaultColors() ) ); break; } } @@ -1188,36 +1562,35 @@ void OfaTreeOptionsDialog::ApplyItemSet( sal_uInt16 nId, const SfxItemSet& rSet { std::shared_ptr<comphelper::ConfigurationChanges> batch(comphelper::ConfigurationChanges::create()); - const SfxPoolItem* pItem = nullptr; SfxItemSetFixed<SID_ATTR_QUICKLAUNCHER, SID_ATTR_QUICKLAUNCHER> aOptSet(SfxGetpApp()->GetPool()); aOptSet.Put(rSet); if(aOptSet.Count()) - SfxGetpApp()->SetOptions( aOptSet ); + SfxApplication::SetOptions( aOptSet ); // get dispatcher anew, because SetOptions() might have destroyed the dispatcher SfxViewFrame *pViewFrame = SfxViewFrame::Current(); // evaluate Year2000 sal_uInt16 nY2K = USHRT_MAX; - if( SfxItemState::SET == rSet.GetItemState( SID_ATTR_YEAR2000, false, &pItem ) ) - nY2K = static_cast<const SfxUInt16Item*>(pItem)->GetValue(); + const SfxUInt16Item* pYearItem = rSet.GetItemIfSet( SID_ATTR_YEAR2000, false ); + if( pYearItem ) + nY2K = pYearItem->GetValue(); if( USHRT_MAX != nY2K ) { if ( pViewFrame ) { SfxDispatcher* pDispatch = pViewFrame->GetDispatcher(); pDispatch->ExecuteList(SID_ATTR_YEAR2000, - SfxCallMode::ASYNCHRON, { pItem }); + SfxCallMode::ASYNCHRON, { pYearItem }); } officecfg::Office::Common::DateFormat::TwoDigitYear::set(nY2K, batch); } // evaluate print - if(SfxItemState::SET == rSet.GetItemState(SID_PRINTER_NOTFOUND_WARN, false, &pItem)) - officecfg::Office::Common::Print::Warning::NotFound::set(static_cast<const SfxBoolItem*>(pItem)->GetValue(), batch); + if(const SfxBoolItem* pWarnItem = rSet.GetItemIfSet(SID_PRINTER_NOTFOUND_WARN, false)) + officecfg::Office::Common::Print::Warning::NotFound::set(pWarnItem->GetValue(), batch); - if(SfxItemState::SET == rSet.GetItemState(SID_PRINTER_CHANGESTODOC, false, &pItem)) + if(const SfxFlagItem* pFlag = rSet.GetItemIfSet(SID_PRINTER_CHANGESTODOC, false)) { - const SfxFlagItem* pFlag = static_cast<const SfxFlagItem*>(pItem); bool bPaperSizeWarning = bool(static_cast<SfxPrinterChangeFlags>(pFlag->GetValue()) & SfxPrinterChangeFlags::CHG_SIZE); officecfg::Office::Common::Print::Warning::PaperSize::set(bPaperSizeWarning, batch); bool bPaperOrientationWarning = bool(static_cast<SfxPrinterChangeFlags>(pFlag->GetValue()) & SfxPrinterChangeFlags::CHG_ORIENTATION); @@ -1242,7 +1615,7 @@ void OfaTreeOptionsDialog::ApplyItemSet( sal_uInt16 nId, const SfxItemSet& rSet break; case SID_INET_DLG : case SID_FILTER_DLG: - SfxGetpApp()->SetOptions( rSet ); + SfxApplication::SetOptions( rSet ); break; case SID_SB_STARBASEOPTIONS: @@ -1256,7 +1629,7 @@ void OfaTreeOptionsDialog::ApplyItemSet( sal_uInt16 nId, const SfxItemSet& rSet default: { - OSL_FAIL( "Unhandled option in ApplyItemSet" ); + SAL_WARN("cui.options", "Unhandled option in ApplyItemSet"); } break; } @@ -1269,10 +1642,8 @@ void OfaTreeOptionsDialog::ApplyLanguageOptions(const SfxItemSet& rSet) Reference< XComponentContext > xContext( ::comphelper::getProcessComponentContext() ); Reference< XLinguProperties > xProp = LinguProperties::create( xContext ); - if ( SfxItemState::SET == rSet.GetItemState(SID_ATTR_HYPHENREGION, false, &pItem ) ) + if ( const SfxHyphenRegionItem* pHyphenItem = rSet.GetItemIfSet(SID_ATTR_HYPHENREGION, false ) ) { - const SfxHyphenRegionItem* pHyphenItem = static_cast<const SfxHyphenRegionItem*>(pItem); - xProp->setHyphMinLeading( static_cast<sal_Int16>(pHyphenItem->GetMinLead()) ); xProp->setHyphMinTrailing( static_cast<sal_Int16>(pHyphenItem->GetMinTrail()) ); bSaveSpellCheck = true; @@ -1328,7 +1699,7 @@ void OfaTreeOptionsDialog::ApplyLanguageOptions(const SfxItemSet& rSet) } } -static OUString getCurrentFactory_Impl( const Reference< XFrame >& _xFrame ) +OUString OfaTreeOptionsDialog::getCurrentFactory_Impl( const Reference< XFrame >& _xFrame ) { OUString sIdentifier; Reference < XFrame > xCurrentFrame( _xFrame ); @@ -1358,19 +1729,17 @@ static OUString getCurrentFactory_Impl( const Reference< XFrame >& _xFrame ) return sIdentifier; } -void OfaTreeOptionsDialog::Initialize( const Reference< XFrame >& _xFrame ) +void OfaTreeOptionsDialog::generalOptions(const std::vector<sal_uInt16>& vPageId) { sal_uInt16 nGroup = 0; - SvtOptionsDialogOptions aOptionsDlgOpt; - sal_uInt16 nPageId; + sal_uInt16 nPageId = 0; - // %PRODUCTNAME options if ( !lcl_isOptionHidden( SID_GENERAL_OPTIONS, aOptionsDlgOpt ) ) { setGroupName(u"ProductName", CuiResId(SID_GENERAL_OPTIONS_RES[0].first)); nGroup = AddGroup(CuiResId(SID_GENERAL_OPTIONS_RES[0].first), nullptr, nullptr, SID_GENERAL_OPTIONS ); - const sal_uInt16 nEnd = static_cast<sal_uInt16>(SAL_N_ELEMENTS(SID_GENERAL_OPTIONS_RES)); + const sal_uInt16 nEnd = static_cast<sal_uInt16>(std::size(SID_GENERAL_OPTIONS_RES)); for (sal_uInt16 i = 1; i < nEnd; ++i) { @@ -1379,67 +1748,101 @@ void OfaTreeOptionsDialog::Initialize( const Reference< XFrame >& _xFrame ) if ( lcl_isOptionHidden( nPageId, aOptionsDlgOpt ) ) continue; - // Disable Online Update page if service not installed - if( RID_SVXPAGE_ONLINEUPDATE == nPageId ) + // Disable Online Update page if neither mode is available + if( RID_SVXPAGE_ONLINEUPDATE == nPageId + && !(SvxOnlineUpdateTabPage::isTraditionalOnlineUpdateAvailable() + || SvxOnlineUpdateTabPage::isMarOnlineUpdateAvailable()) ) { - try - { - Reference < XInterface > xService( setup::UpdateCheck::create( ::comphelper::getProcessComponentContext() ) ); - if( ! xService.is() ) - continue; - } - catch ( css::uno::DeploymentException& ) - { - continue; - } + continue; } - // Disable Basic IDE options, if experimental features are not enabled - if( RID_SVXPAGE_BASICIDE_OPTIONS == nPageId ) + if (!vPageId.empty()) { - if( ! officecfg::Office::Common::Misc::ExperimentalMode::get() ) - continue; + if (std::find(vPageId.begin(), vPageId.end(), nPageId) != vPageId.end()) + AddTabPage(nPageId, sNewTitle, nGroup); } - - AddTabPage( nPageId, sNewTitle, nGroup ); + else + AddTabPage(nPageId, sNewTitle, nGroup); } } +} + +void OfaTreeOptionsDialog::loadAndSaveOptions(const std::vector<sal_uInt16>& vPageId) +{ + sal_uInt16 nGroup = 0; + SvtOptionsDialogOptions aOptionsDlgOpt; + sal_uInt16 nPageId = 0; - // Load and Save options if ( !lcl_isOptionHidden( SID_FILTER_DLG, aOptionsDlgOpt ) ) { setGroupName( u"LoadSave", CuiResId(SID_FILTER_DLG_RES[0].first) ); nGroup = AddGroup( CuiResId(SID_FILTER_DLG_RES[0].first), nullptr, nullptr, SID_FILTER_DLG ); - for ( size_t i = 1; i < SAL_N_ELEMENTS(SID_FILTER_DLG_RES); ++i ) + for ( size_t i = 1; i < std::size(SID_FILTER_DLG_RES); ++i ) { nPageId = static_cast<sal_uInt16>(SID_FILTER_DLG_RES[i].second); if ( !lcl_isOptionHidden( nPageId, aOptionsDlgOpt ) ) - AddTabPage( nPageId, CuiResId(SID_FILTER_DLG_RES[i].first), nGroup ); + { + if (!vPageId.empty()) + { + if (std::find(vPageId.begin(), vPageId.end(), nPageId) != vPageId.end()) + AddTabPage(nPageId, CuiResId(SID_FILTER_DLG_RES[i].first), nGroup); + } + else + AddTabPage(nPageId, CuiResId(SID_FILTER_DLG_RES[i].first), nGroup); + } } } +} + +void OfaTreeOptionsDialog::languageOptions(const std::vector<sal_uInt16>& vPageId) +{ + sal_uInt16 nGroup = 0; + SvtOptionsDialogOptions aOptionsDlgOpt; + sal_uInt16 nPageId = 0; - // Language options SvtCTLOptions aCTLLanguageOptions; if ( !lcl_isOptionHidden( SID_LANGUAGE_OPTIONS, aOptionsDlgOpt ) ) { setGroupName(u"LanguageSettings", CuiResId(SID_LANGUAGE_OPTIONS_RES[0].first)); nGroup = AddGroup(CuiResId(SID_LANGUAGE_OPTIONS_RES[0].first), nullptr, nullptr, SID_LANGUAGE_OPTIONS ); - for (size_t i = 1; i < SAL_N_ELEMENTS(SID_LANGUAGE_OPTIONS_RES); ++i) + for (size_t i = 1; i < std::size(SID_LANGUAGE_OPTIONS_RES); ++i) { nPageId = static_cast<sal_uInt16>(SID_LANGUAGE_OPTIONS_RES[i].second); if ( lcl_isOptionHidden( nPageId, aOptionsDlgOpt ) ) continue; + + // Disable DeepL translation settings, if experimental mode is not enabled + if( RID_SVXPAGE_DEEPL_OPTIONS == nPageId ) + { + if( ! officecfg::Office::Common::Misc::ExperimentalMode::get() ) + continue; + } + if ( ( RID_SVXPAGE_JSEARCH_OPTIONS != nPageId || SvtCJKOptions::IsJapaneseFindEnabled() ) && ( RID_SVXPAGE_ASIAN_LAYOUT != nPageId || SvtCJKOptions::IsAsianTypographyEnabled() ) && - ( RID_SVXPAGE_OPTIONS_CTL != nPageId || aCTLLanguageOptions.IsCTLFontEnabled() ) ) - AddTabPage(nPageId, CuiResId(SID_LANGUAGE_OPTIONS_RES[i].first), nGroup); + ( RID_SVXPAGE_OPTIONS_CTL != nPageId || SvtCTLOptions::IsCTLFontEnabled() ) ) + { + if (!vPageId.empty()) + { + if (std::find(vPageId.begin(), vPageId.end(), nPageId) != vPageId.end()) + AddTabPage(nPageId, CuiResId(SID_LANGUAGE_OPTIONS_RES[i].first), nGroup); + } + else + AddTabPage(nPageId, CuiResId(SID_LANGUAGE_OPTIONS_RES[i].first), nGroup); + } } } +} + +void OfaTreeOptionsDialog::writerOptions(const std::vector<sal_uInt16>& vPageId) +{ + sal_uInt16 nGroup = 0; + SvtOptionsDialogOptions aOptionsDlgOpt; + sal_uInt16 nPageId = 0; - OUString aFactory = getCurrentFactory_Impl( _xFrame ); - DBG_ASSERT( GetModuleIdentifier( _xFrame ) == aFactory, "S H I T!!!" ); + OUString aFactory = getCurrentFactory_Impl( m_xFrame ); + DBG_ASSERT( GetModuleIdentifier( m_xFrame ) == aFactory, "This should not happen" ); - // Writer and Writer/Web options SvtModuleOptions aModuleOpt; if ( aModuleOpt.IsModuleInstalled( SvtModuleOptions::EModule::WRITER ) ) { @@ -1456,38 +1859,105 @@ void OfaTreeOptionsDialog::Initialize( const Reference< XFrame >& _xFrame ) else setGroupName( u"Writer", CuiResId(SID_SW_EDITOPTIONS_RES[0].first) ); nGroup = AddGroup(CuiResId(SID_SW_EDITOPTIONS_RES[0].first), pSwMod, pSwMod, SID_SW_EDITOPTIONS ); - for ( size_t i = 1; i < SAL_N_ELEMENTS(SID_SW_EDITOPTIONS_RES); ++i ) + SvtCTLOptions aCTLLanguageOptions; + for ( size_t i = 1; i < std::size(SID_SW_EDITOPTIONS_RES); ++i ) { nPageId = static_cast<sal_uInt16>(SID_SW_EDITOPTIONS_RES[i].second); if ( lcl_isOptionHidden( nPageId, aOptionsDlgOpt ) ) continue; if ( ( RID_SW_TP_STD_FONT_CJK != nPageId || SvtCJKOptions::IsCJKFontEnabled() ) && - ( RID_SW_TP_STD_FONT_CTL != nPageId || aCTLLanguageOptions.IsCTLFontEnabled() ) && - ( RID_SW_TP_MAILCONFIG != nPageId || MailMergeCfg_Impl().IsEmailSupported() ) ) - AddTabPage( nPageId, CuiResId(SID_SW_EDITOPTIONS_RES[i].first), nGroup ); + ( RID_SW_TP_STD_FONT_CTL != nPageId || SvtCTLOptions::IsCTLFontEnabled() ) && + ( RID_SW_TP_MAILCONFIG != nPageId || MailMergeCfgIsEmailSupported() ) ) + { + if (!vPageId.empty()) + { + if (std::find(vPageId.begin(), vPageId.end(), nPageId) != vPageId.end()) + AddTabPage(nPageId, CuiResId(SID_SW_EDITOPTIONS_RES[i].first), + nGroup); + } + else + AddTabPage(nPageId, CuiResId(SID_SW_EDITOPTIONS_RES[i].first), nGroup); + } } #ifdef DBG_UTIL - AddTabPage( RID_SW_TP_OPTTEST_PAGE, "Internal Test", nGroup ); + if (!vPageId.empty()) + { + if (std::find(vPageId.begin(), vPageId.end(), RID_SW_TP_OPTTEST_PAGE) + != vPageId.end()) + AddTabPage(RID_SW_TP_OPTTEST_PAGE, "Internal Test", nGroup); + } + else + AddTabPage(RID_SW_TP_OPTTEST_PAGE, "Internal Test", nGroup); #endif } + } + } +} + +void OfaTreeOptionsDialog::writerWebOptions(const std::vector<sal_uInt16>& vPageId) +{ + sal_uInt16 nGroup = 0; + SvtOptionsDialogOptions aOptionsDlgOpt; + sal_uInt16 nPageId = 0; + + OUString aFactory = getCurrentFactory_Impl( m_xFrame ); + DBG_ASSERT( GetModuleIdentifier( m_xFrame ) == aFactory, "This should not happen" ); + + SvtModuleOptions aModuleOpt; + if ( aModuleOpt.IsModuleInstalled( SvtModuleOptions::EModule::WRITER ) ) + { + // text document + if ( aFactory == "com.sun.star.text.TextDocument" + || aFactory == "com.sun.star.text.WebDocument" + || aFactory == "com.sun.star.text.GlobalDocument" ) + { + SfxModule* pSwMod = SfxApplication::GetModule(SfxToolsModule::Writer); // HTML documents if ( !lcl_isOptionHidden( SID_SW_ONLINEOPTIONS, aOptionsDlgOpt ) ) { nGroup = AddGroup(CuiResId(SID_SW_ONLINEOPTIONS_RES[0].first), pSwMod, pSwMod, SID_SW_ONLINEOPTIONS ); - for( size_t i = 1; i < SAL_N_ELEMENTS(SID_SW_ONLINEOPTIONS_RES); ++i ) + for( size_t i = 1; i < std::size(SID_SW_ONLINEOPTIONS_RES); ++i ) { nPageId = static_cast<sal_uInt16>(SID_SW_ONLINEOPTIONS_RES[i].second); if ( !lcl_isOptionHidden( nPageId, aOptionsDlgOpt ) ) - AddTabPage(nPageId, CuiResId(SID_SW_ONLINEOPTIONS_RES[i].first), nGroup); + { + if (!vPageId.empty()) + { + if (std::find(vPageId.begin(), vPageId.end(), nPageId) != vPageId.end()) + AddTabPage(nPageId, CuiResId(SID_SW_ONLINEOPTIONS_RES[i].first), + nGroup); + } + else + AddTabPage(nPageId, CuiResId(SID_SW_ONLINEOPTIONS_RES[i].first), + nGroup); + } } #ifdef DBG_UTIL - AddTabPage( RID_SW_TP_OPTTEST_PAGE, "Internal Test", nGroup ); + if (!vPageId.empty()) + { + if (std::find(vPageId.begin(), vPageId.end(), RID_SW_TP_OPTTEST_PAGE) + != vPageId.end()) + AddTabPage(RID_SW_TP_OPTTEST_PAGE, "Internal Test", nGroup); + } + else + AddTabPage(RID_SW_TP_OPTTEST_PAGE, "Internal Test", nGroup); #endif } } } +} + +void OfaTreeOptionsDialog::calcOptions(const std::vector<sal_uInt16>& vPageId) +{ + sal_uInt16 nGroup = 0; + SvtOptionsDialogOptions aOptionsDlgOpt; + sal_uInt16 nPageId = 0; + + OUString aFactory = getCurrentFactory_Impl( m_xFrame ); + DBG_ASSERT( GetModuleIdentifier( m_xFrame ) == aFactory, "This should not happen" ); + SvtModuleOptions aModuleOpt; // Calc options if ( aModuleOpt.IsModuleInstalled( SvtModuleOptions::EModule::CALC ) ) { @@ -1498,18 +1968,35 @@ void OfaTreeOptionsDialog::Initialize( const Reference< XFrame >& _xFrame ) SfxModule* pScMod = SfxApplication::GetModule( SfxToolsModule::Calc ); setGroupName( u"Calc", CuiResId(SID_SC_EDITOPTIONS_RES[0].first) ); nGroup = AddGroup( CuiResId(SID_SC_EDITOPTIONS_RES[0].first), pScMod, pScMod, SID_SC_EDITOPTIONS ); - const sal_uInt16 nCount = static_cast<sal_uInt16>(SAL_N_ELEMENTS(SID_SC_EDITOPTIONS_RES)); + const sal_uInt16 nCount = static_cast<sal_uInt16>(std::size(SID_SC_EDITOPTIONS_RES)); for ( sal_uInt16 i = 1; i < nCount; ++i ) { nPageId = static_cast<sal_uInt16>(SID_SC_EDITOPTIONS_RES[i].second); if ( lcl_isOptionHidden( nPageId, aOptionsDlgOpt ) ) continue; - AddTabPage( nPageId, CuiResId(SID_SC_EDITOPTIONS_RES[i].first), nGroup ); + if (!vPageId.empty()) + { + if (std::find(vPageId.begin(), vPageId.end(), nPageId) != vPageId.end()) + AddTabPage(nPageId, CuiResId(SID_SC_EDITOPTIONS_RES[i].first), nGroup); + } + else + AddTabPage(nPageId, CuiResId(SID_SC_EDITOPTIONS_RES[i].first), nGroup); } } } } +} + +void OfaTreeOptionsDialog::impressOptions(const std::vector<sal_uInt16>& vPageId) +{ + sal_uInt16 nGroup = 0; + SvtOptionsDialogOptions aOptionsDlgOpt; + sal_uInt16 nPageId = 0; + + OUString aFactory = getCurrentFactory_Impl( m_xFrame ); + DBG_ASSERT( GetModuleIdentifier( m_xFrame ) == aFactory, "This should not happen" ); + SvtModuleOptions aModuleOpt; // Impress options SfxModule* pSdMod = SfxApplication::GetModule( SfxToolsModule::Draw ); @@ -1521,20 +2008,38 @@ void OfaTreeOptionsDialog::Initialize( const Reference< XFrame >& _xFrame ) { setGroupName( u"Impress", CuiResId(SID_SD_EDITOPTIONS_RES[0].first) ); nGroup = AddGroup( CuiResId(SID_SD_EDITOPTIONS_RES[0].first), pSdMod, pSdMod, SID_SD_EDITOPTIONS ); - const sal_uInt16 nCount = static_cast<sal_uInt16>(SAL_N_ELEMENTS(SID_SD_EDITOPTIONS_RES)); + const sal_uInt16 nCount = static_cast<sal_uInt16>(std::size(SID_SD_EDITOPTIONS_RES)); for ( sal_uInt16 i = 1; i < nCount; ++i ) { nPageId = static_cast<sal_uInt16>(SID_SD_EDITOPTIONS_RES[i].second); if ( lcl_isOptionHidden( nPageId, aOptionsDlgOpt ) ) continue; - AddTabPage( nPageId, CuiResId(SID_SD_EDITOPTIONS_RES[i].first), nGroup ); + if (!vPageId.empty()) + { + if (std::find(vPageId.begin(), vPageId.end(), nPageId) != vPageId.end()) + AddTabPage(nPageId, CuiResId(SID_SD_EDITOPTIONS_RES[i].first), nGroup); + } + else + AddTabPage(nPageId, CuiResId(SID_SD_EDITOPTIONS_RES[i].first), nGroup); } } } } +} + +void OfaTreeOptionsDialog::drawOptions(const std::vector<sal_uInt16>& vPageId) +{ + sal_uInt16 nGroup = 0; + SvtOptionsDialogOptions aOptionsDlgOpt; + sal_uInt16 nPageId = 0; + + OUString aFactory = getCurrentFactory_Impl( m_xFrame ); + DBG_ASSERT( GetModuleIdentifier( m_xFrame ) == aFactory, "This should not happen" ); + SvtModuleOptions aModuleOpt; // Draw options + SfxModule* pSdMod = SfxApplication::GetModule(SfxToolsModule::Draw); if ( aModuleOpt.IsModuleInstalled( SvtModuleOptions::EModule::DRAW ) ) { if ( aFactory == "com.sun.star.drawing.DrawingDocument" ) @@ -1543,18 +2048,36 @@ void OfaTreeOptionsDialog::Initialize( const Reference< XFrame >& _xFrame ) { setGroupName( u"Draw", CuiResId(SID_SD_GRAPHIC_OPTIONS_RES[0].first) ); nGroup = AddGroup( CuiResId(SID_SD_GRAPHIC_OPTIONS_RES[0].first), pSdMod, pSdMod, SID_SD_GRAPHIC_OPTIONS ); - const sal_uInt16 nCount = static_cast<sal_uInt16>(SAL_N_ELEMENTS(SID_SD_GRAPHIC_OPTIONS_RES)); + const sal_uInt16 nCount = static_cast<sal_uInt16>(std::size(SID_SD_GRAPHIC_OPTIONS_RES)); for ( sal_uInt16 i = 1; i < nCount; ++i ) { nPageId = static_cast<sal_uInt16>(SID_SD_GRAPHIC_OPTIONS_RES[i].second); if ( lcl_isOptionHidden( nPageId, aOptionsDlgOpt ) ) continue; - AddTabPage( nPageId, CuiResId(SID_SD_GRAPHIC_OPTIONS_RES[i].first), nGroup ); + if (!vPageId.empty()) + { + if (std::find(vPageId.begin(), vPageId.end(), nPageId) != vPageId.end()) + AddTabPage(nPageId, CuiResId(SID_SD_GRAPHIC_OPTIONS_RES[i].first), + nGroup); + } + else + AddTabPage(nPageId, CuiResId(SID_SD_GRAPHIC_OPTIONS_RES[i].first), nGroup); } } } } +} + +void OfaTreeOptionsDialog::mathOptions(const std::vector<sal_uInt16>& vPageId) +{ + sal_uInt16 nGroup = 0; + SvtOptionsDialogOptions aOptionsDlgOpt; + sal_uInt16 nPageId = 0; + + OUString aFactory = getCurrentFactory_Impl( m_xFrame ); + DBG_ASSERT( GetModuleIdentifier( m_xFrame ) == aFactory, "This should not happen" ); + SvtModuleOptions aModuleOpt; // Math options if ( aModuleOpt.IsModuleInstalled( SvtModuleOptions::EModule::MATH ) ) @@ -1566,15 +2089,33 @@ void OfaTreeOptionsDialog::Initialize( const Reference< XFrame >& _xFrame ) SfxModule* pSmMod = SfxApplication::GetModule(SfxToolsModule::Math); setGroupName( u"Math", CuiResId(SID_SM_EDITOPTIONS_RES[0].first) ); nGroup = AddGroup(CuiResId(SID_SM_EDITOPTIONS_RES[0].first), pSmMod, pSmMod, SID_SM_EDITOPTIONS ); - for ( size_t i = 1; i < SAL_N_ELEMENTS(SID_SM_EDITOPTIONS_RES); ++i ) + for ( size_t i = 1; i < std::size(SID_SM_EDITOPTIONS_RES); ++i ) { nPageId = static_cast<sal_uInt16>(SID_SM_EDITOPTIONS_RES[i].second); if ( !lcl_isOptionHidden( nPageId, aOptionsDlgOpt ) ) - AddTabPage( nPageId, CuiResId(SID_SM_EDITOPTIONS_RES[i].first), nGroup ); + { + if (!vPageId.empty()) + { + if (std::find(vPageId.begin(), vPageId.end(), nPageId) != vPageId.end()) + AddTabPage(nPageId, CuiResId(SID_SM_EDITOPTIONS_RES[i].first), + nGroup); + } + else + AddTabPage(nPageId, CuiResId(SID_SM_EDITOPTIONS_RES[i].first), nGroup); + } } } } } +} + +void OfaTreeOptionsDialog::databaseOptions(const std::vector<sal_uInt16>& vPageId) +{ + sal_uInt16 nGroup = 0; + SvtOptionsDialogOptions aOptionsDlgOpt; + sal_uInt16 nPageId = 0; + + SvtModuleOptions aModuleOpt; // Database - needed only if there is an application which integrates with databases if ( !lcl_isOptionHidden( SID_SB_STARBASEOPTIONS, aOptionsDlgOpt ) && @@ -1585,35 +2126,63 @@ void OfaTreeOptionsDialog::Initialize( const Reference< XFrame >& _xFrame ) { setGroupName( u"Base", CuiResId(SID_SB_STARBASEOPTIONS_RES[0].first) ); nGroup = AddGroup( CuiResId(SID_SB_STARBASEOPTIONS_RES[0].first), nullptr, nullptr, SID_SB_STARBASEOPTIONS ); - for ( size_t i = 1; i < SAL_N_ELEMENTS(SID_SB_STARBASEOPTIONS_RES); ++i ) + for ( size_t i = 1; i < std::size(SID_SB_STARBASEOPTIONS_RES); ++i ) { nPageId = static_cast<sal_uInt16>(SID_SB_STARBASEOPTIONS_RES[i].second); if ( !lcl_isOptionHidden( nPageId, aOptionsDlgOpt ) ) - AddTabPage( nPageId, CuiResId(SID_SB_STARBASEOPTIONS_RES[i].first), nGroup ); + { + if (!vPageId.empty()) + { + if (std::find(vPageId.begin(), vPageId.end(), nPageId) != vPageId.end()) + AddTabPage(nPageId, CuiResId(SID_SB_STARBASEOPTIONS_RES[i].first), nGroup); + } + else + AddTabPage(nPageId, CuiResId(SID_SB_STARBASEOPTIONS_RES[i].first), nGroup); + } } } +} + +void OfaTreeOptionsDialog::chartOptions(const std::vector<sal_uInt16>& vPageId) +{ + sal_uInt16 nGroup = 0; + SvtOptionsDialogOptions aOptionsDlgOpt; + sal_uInt16 nPageId = 0; - // Chart options (always installed and active) if ( !lcl_isOptionHidden( SID_SCH_EDITOPTIONS, aOptionsDlgOpt ) ) { setGroupName( u"Charts", CuiResId(SID_SCH_EDITOPTIONS_RES[0].first) ); nGroup = AddGroup( CuiResId(SID_SCH_EDITOPTIONS_RES[0].first), nullptr, nullptr, SID_SCH_EDITOPTIONS ); - for ( size_t i = 1; i < SAL_N_ELEMENTS(SID_SCH_EDITOPTIONS_RES); ++i ) + for ( size_t i = 1; i < std::size(SID_SCH_EDITOPTIONS_RES); ++i ) { nPageId = static_cast<sal_uInt16>(SID_SCH_EDITOPTIONS_RES[i].second); if ( !lcl_isOptionHidden( nPageId, aOptionsDlgOpt ) ) - AddTabPage( nPageId, CuiResId(SID_SCH_EDITOPTIONS_RES[i].first), nGroup ); + { + if (!vPageId.empty()) + { + if (std::find(vPageId.begin(), vPageId.end(), nPageId) != vPageId.end()) + AddTabPage(nPageId, CuiResId(SID_SCH_EDITOPTIONS_RES[i].first), nGroup); + } + else + AddTabPage(nPageId, CuiResId(SID_SCH_EDITOPTIONS_RES[i].first), nGroup); + } } } +} + +void OfaTreeOptionsDialog::internetOptions(const std::vector<sal_uInt16>& vPageId) +{ + sal_uInt16 nGroup = 0; + SvtOptionsDialogOptions aOptionsDlgOpt; + sal_uInt16 nPageId = 0; - // Internet options if ( lcl_isOptionHidden( SID_INET_DLG, aOptionsDlgOpt ) ) return; setGroupName(u"Internet", CuiResId(SID_INET_DLG_RES[0].first)); nGroup = AddGroup(CuiResId(SID_INET_DLG_RES[0].first), nullptr, nullptr, SID_INET_DLG ); - for ( size_t i = 1; i < SAL_N_ELEMENTS(SID_INET_DLG_RES); ++i ) + for ( size_t i = 1; i < std::size(SID_INET_DLG_RES); ++i ) { nPageId = static_cast<sal_uInt16>(SID_INET_DLG_RES[i].second); if ( lcl_isOptionHidden( nPageId, aOptionsDlgOpt ) ) @@ -1623,33 +2192,82 @@ void OfaTreeOptionsDialog::Initialize( const Reference< XFrame >& _xFrame ) if ( nPageId == RID_SVXPAGE_INET_MAIL ) continue; #endif - AddTabPage( nPageId, CuiResId(SID_INET_DLG_RES[i].first), nGroup ); + if (!vPageId.empty()) + { + if (std::find(vPageId.begin(), vPageId.end(), nPageId) != vPageId.end()) + AddTabPage(nPageId, CuiResId(SID_INET_DLG_RES[i].first), nGroup); + } + else + AddTabPage(nPageId, CuiResId(SID_INET_DLG_RES[i].first), nGroup); } } +void OfaTreeOptionsDialog::Initialize(const Reference<XFrame>& _xFrame) +{ + m_xFrame = _xFrame; + + // %PRODUCTNAME options + generalOptions(); + + // Load and Save options + loadAndSaveOptions(); + + // Language options + languageOptions(); + + // Writer and Writer/Web options + writerOptions(); + writerWebOptions(); + + // Calc options + calcOptions(); + + // Impress options + impressOptions(); + + // Draw options + drawOptions(); + + // Math options + mathOptions(); + + // Database - needed only if there is an application which integrates with databases + databaseOptions(); + + // Chart options (always installed and active) + chartOptions(); + + // Internet options + internetOptions(); + + // store Options Dialogs with their page names and strings + // in order to use them when searching + storeOptionsTree(); +} + static bool isNodeActive( OptionsNode const * pNode, Module* pModule ) { - if ( pNode ) - { - // Node for all modules active? - if ( pNode->m_bAllModules ) - return true; + if ( !pNode ) + return false; - // OOo-Nodes (Writer, Calc, Impress...) are active if node is already inserted - if ( !getGroupName( pNode->m_sId, false ).isEmpty() ) - return true; + // Node for all modules active? + if ( pNode->m_bAllModules ) + return true; - // no module -> not active - if ( !pModule ) - return false; + // OOo-Nodes (Writer, Calc, Impress...) are active if node is already inserted + if ( !getGroupName( pNode->m_sId, false ).isEmpty() ) + return true; - // search node in active module - if ( pModule->m_bActive ) - { - for (auto const& j : pModule->m_aNodeList) - if ( j->m_sId == pNode->m_sId ) - return true; - } + // no module -> not active + if ( !pModule ) + return false; + + // search node in active module + if ( pModule->m_bActive ) + { + for (auto const& j : pModule->m_aNodeList) + if ( j->m_sId == pNode->m_sId ) + return true; } return false; } @@ -1961,8 +2579,7 @@ short OfaTreeOptionsDialog::run() if ( !bIsFromExtensionManager ) { // collect all DictionaryList Events while the dialog is executed - Reference<css::linguistic2::XSearchableDictionaryList> xDictionaryList(LinguMgr::GetDictionaryList()); - pClamp.reset( new SvxDicListChgClamp( xDictionaryList ) ); + pClamp.reset(new SvxDicListChgClamp(LinguMgr::GetDictionaryList())); } return SfxOkDialogController::run(); @@ -1970,11 +2587,11 @@ short OfaTreeOptionsDialog::run() // class ExtensionsTabPage ----------------------------------------------- ExtensionsTabPage::ExtensionsTabPage( - weld::Container* pParent, const OUString& rPageURL, - const OUString& rEvtHdl, const Reference< awt::XContainerWindowProvider >& rProvider ) + weld::Container* pParent, OUString aPageURL, + OUString aEvtHdl, const Reference< awt::XContainerWindowProvider >& rProvider ) : m_pContainer(pParent) - , m_sPageURL(rPageURL) - , m_sEventHdl(rEvtHdl) + , m_sPageURL(std::move(aPageURL)) + , m_sEventHdl(std::move(aEvtHdl)) , m_xWinProvider(rProvider) { } diff --git a/cui/source/options/treeopthelper.cxx b/cui/source/options/treeopthelper.cxx new file mode 100644 index 000000000000..e486dbb5ea30 --- /dev/null +++ b/cui/source/options/treeopthelper.cxx @@ -0,0 +1,184 @@ +/* -*- 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 <fstream> +#include <treeopt.hxx> + +#include <treeopt.hrc> +#include <helpids.h> +#include <svx/dialogs.hrc> +#include <svx/svxids.hrc> + +namespace +{ +struct PageIdToFileNameMap_Impl +{ + sal_uInt16 m_nPageId; + OUString m_sContent; +}; +} + +static PageIdToFileNameMap_Impl FileMap_Impl[] = { + + // { PAGE-ID, CONTENT }, + + // ProductName, SID_GENERAL_OPTIONS + { RID_SFXPAGE_GENERAL, "" }, // UserData + + { OFA_TP_MISC, "" }, // General + + { OFA_TP_VIEW, "" }, // View + + { RID_SFXPAGE_PRINTOPTIONS, "" }, // Print + + { RID_SFXPAGE_PATH, "" }, // Paths + + { RID_SVX_FONT_SUBSTITUTION, "" }, // Fonts + + { RID_SVXPAGE_INET_SECURITY, "" }, // Security + + { RID_SVXPAGE_PERSONALIZATION, "" }, // Personalization + { RID_SVXPAGE_COLORCONFIG, "" }, // ApplicationColors + { RID_SVXPAGE_ACCESSIBILITYCONFIG, "" }, // Accessibility + { RID_SVXPAGE_OPTIONS_JAVA, "" }, // Java + { RID_SVXPAGE_BASICIDE_OPTIONS, "" }, // BasicIDEOptions + { RID_SVXPAGE_ONLINEUPDATE, "" }, // OnlineUpdate + { RID_SVXPAGE_OPENCL, "" }, // OpenCL + + // LanguageSettings, SID_LANGUAGE_OPTIONS + { OFA_TP_LANGUAGES, "" }, // Languages + { RID_SFXPAGE_LINGU, "" }, // WritingAids + { RID_SVXPAGE_JSEARCH_OPTIONS, "" }, // SearchingInJapanese + { RID_SVXPAGE_ASIAN_LAYOUT, "" }, // AsianLayout + { RID_SVXPAGE_OPTIONS_CTL, "" }, // ComplexTextLayout + { RID_SVXPAGE_LANGTOOL_OPTIONS, "" }, // LanguageTool Server + { RID_SVXPAGE_DEEPL_OPTIONS, "" }, // DeepL Server + + // Internet, SID_INET_DLG + { RID_SVXPAGE_INET_PROXY, "" }, // Proxy + { RID_SVXPAGE_INET_MAIL, "" }, // Email + + // Load/Save, SID_FILTER_DLG + { RID_SFXPAGE_SAVE, "" }, // General + { SID_OPTFILTER_MSOFFICE, "" }, // VBA Properties + { RID_OFAPAGE_MSFILTEROPT2, "" }, // Microsoft Office + { RID_OFAPAGE_HTMLOPT, "" }, // HTML Compatibility + + // Writer, SID_SW_EDITOPTIONS + { RID_SW_TP_OPTLOAD_PAGE, "" }, // General + { RID_SW_TP_CONTENT_OPT, "" }, // View + { RID_SW_TP_OPTSHDWCRSR, "" }, // FormattingAids + { RID_SVXPAGE_GRID, "" }, // Grid + { RID_SW_TP_STD_FONT, "" }, // BasicFontsWestern + { RID_SW_TP_STD_FONT_CJK, "" }, // BasicFontsAsian + { RID_SW_TP_STD_FONT_CTL, "" }, // BasicFontsCTL + { RID_SW_TP_OPTPRINT_PAGE, "" }, // Print + { RID_SW_TP_OPTTABLE_PAGE, "" }, // Table + { RID_SW_TP_REDLINE_OPT, "" }, // Changes + { RID_SW_TP_COMPARISON_OPT, "" }, // Comparison + { RID_SW_TP_OPTCOMPATIBILITY_PAGE, "" }, // Compatibility + { RID_SW_TP_OPTCAPTION_PAGE, "" }, // AutoCaption + { RID_SW_TP_MAILCONFIG, "" }, // MailMerge + { RID_SW_TP_OPTTEST_PAGE, "" }, // Internal Test (only in dev build) + + // WriterWeb, SID_SW_ONLINEOPTIONS + { RID_SW_TP_HTML_CONTENT_OPT, "" }, // View + { RID_SW_TP_HTML_OPTSHDWCRSR, "" }, // FormattingAids + { RID_SW_TP_HTML_OPTGRID_PAGE, "" }, // Grid + { RID_SW_TP_HTML_OPTPRINT_PAGE, "" }, // Print + { RID_SW_TP_HTML_OPTTABLE_PAGE, "" }, // Table + { RID_SW_TP_BACKGROUND, "" }, // Background + { RID_SW_TP_OPTTEST_PAGE, "" }, // Internal Test (only in dev build) + + // Math, SID_SM_EDITOPTIONS + { SID_SM_TP_PRINTOPTIONS, "" }, // Settings + + // Calc, SID_SC_EDITOPTIONS + { SID_SC_TP_LAYOUT, "" }, // General + { RID_SC_TP_DEFAULTS, "" }, // Defaults + { SID_SC_TP_CONTENT, "" }, // View + { SID_SC_TP_CALC, "" }, // Calculate + { SID_SC_TP_FORMULA, "" }, // Formula + { SID_SC_TP_USERLISTS, "" }, // SortLists + { SID_SC_TP_CHANGES, "" }, // Changes + { SID_SC_TP_COMPATIBILITY, "" }, // Compatibility + { SID_SC_TP_GRID, "" }, // Grid + { RID_SC_TP_PRINT, "" }, // Print + + // Impress, SID_SD_EDITOPTIONS + { SID_SI_TP_MISC, "" }, // General + { SID_SI_TP_CONTENTS, "" }, // View + { SID_SI_TP_SNAP, "" }, // Grid + { SID_SI_TP_PRINT, "" }, // Print + + // Draw, SID_SD_GRAPHIC_OPTIONS + { SID_SD_TP_MISC, "" }, // General + { SID_SD_TP_CONTENTS, "" }, // View + { SID_SD_TP_SNAP, "" }, // Grid + { SID_SD_TP_PRINT, "" }, // Print + + // Charts, SID_SCH_EDITOPTIONS + { RID_OPTPAGE_CHART_DEFCOLORS, "" }, // DefaultColor + + // Base, SID_SB_STARBASEOPTIONS + { SID_SB_CONNECTIONPOOLING, "" }, // Connections + { SID_SB_DBREGISTEROPTIONS, "" } // Databases +}; + +void TreeOptHelper::storeStringsOfDialog(sal_uInt16 nPageId, const OUString& sPageStrings) +{ + for (PageIdToFileNameMap_Impl& rEntry : FileMap_Impl) + { + if (rEntry.m_nPageId == nPageId) + { + rEntry.m_sContent = sPageStrings.replaceAll("~", ""); + break; + } + } +} + +/* +return the strings of: +- labels, +- check buttons, +- radio buttons, +- toggle buttons, +- link buttons, +- buttons + +TODO: +- accessible-names +- accessible-descriptions +- tooltip-texts +*/ +OUString TreeOptHelper::getStringsFromDialog(sal_uInt16 nPageId) +{ + if (nPageId == 0) + return OUString(); + + for (PageIdToFileNameMap_Impl& rEntry : FileMap_Impl) + { + if (rEntry.m_nPageId == nPageId) + return rEntry.m_sContent; + } + + return OUString(); +} + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/cui/source/options/tsaurls.cxx b/cui/source/options/tsaurls.cxx index 5c01e1c5b425..d0d9ef1c1c6c 100644 --- a/cui/source/options/tsaurls.cxx +++ b/cui/source/options/tsaurls.cxx @@ -10,7 +10,7 @@ #include <officecfg/Office/Common.hxx> #include <svx/svxdlg.hxx> #include <comphelper/sequence.hxx> -#include <tools/diagnose_ex.h> +#include <comphelper/diagnose_ex.hxx> #include "tsaurls.hxx" @@ -88,17 +88,15 @@ void TSAURLsDialog::AddTSAURL(const OUString& rURL) IMPL_LINK_NOARG(TSAURLsDialog, AddHdl_Impl, weld::Button&, void) { - OUString aURL; OUString aDesc(m_xEnterAUrl->get_label()); SvxAbstractDialogFactory* pFact = SvxAbstractDialogFactory::Create(); ScopedVclPtr<AbstractSvxNameDialog> pDlg( - pFact->CreateSvxNameDialog(m_xDialog.get(), aURL, aDesc)); + pFact->CreateSvxNameDialog(m_xDialog.get(), OUString(), aDesc)); if (pDlg->Execute() == RET_OK) { - pDlg->GetName(aURL); - AddTSAURL(aURL); + AddTSAURL(pDlg->GetName()); m_xOKBtn->set_sensitive(true); } m_xURLListBox->unselect_all(); diff --git a/cui/source/options/webconninfo.cxx b/cui/source/options/webconninfo.cxx index d9acbd18f537..4ab84e4320ed 100644 --- a/cui/source/options/webconninfo.cxx +++ b/cui/source/options/webconninfo.cxx @@ -190,8 +190,7 @@ IMPL_LINK_NOARG(WebConnectionInfoDialog, ChangePasswordHdl, weld::Button&, void) if ( pPasswordRequest->isPassword() ) { - OUString aNewPass = pPasswordRequest->getPassword(); - uno::Sequence<OUString> aPasswd { aNewPass }; + uno::Sequence<OUString> aPasswd { pPasswordRequest->getPassword() }; uno::Reference< task::XPasswordContainer2 > xPasswdContainer( task::PasswordContainer::create(comphelper::getProcessComponentContext())); diff --git a/cui/source/tabpages/TextColumnsPage.cxx b/cui/source/tabpages/TextColumnsPage.cxx index 5bfd3b47a69e..2e39995083f3 100644 --- a/cui/source/tabpages/TextColumnsPage.cxx +++ b/cui/source/tabpages/TextColumnsPage.cxx @@ -39,7 +39,7 @@ void SvxTextColumnsPage::Reset(const SfxItemSet* rAttrs) { auto pItem = GetItem(*rAttrs, SDRATTR_TEXTCOLUMNS_NUMBER); if (!pItem) - pItem = &pPool->GetDefaultItem(SDRATTR_TEXTCOLUMNS_NUMBER); + pItem = &pPool->GetUserOrPoolDefaultItem(SDRATTR_TEXTCOLUMNS_NUMBER); m_xColumnsNumber->set_value(pItem->GetValue()); m_xColumnsNumber->save_value(); } @@ -48,7 +48,7 @@ void SvxTextColumnsPage::Reset(const SfxItemSet* rAttrs) MapUnit eUnit = pPool->GetMetric(SDRATTR_TEXTCOLUMNS_SPACING); auto pItem = GetItem(*rAttrs, SDRATTR_TEXTCOLUMNS_SPACING); if (!pItem) - pItem = &pPool->GetDefaultItem(SDRATTR_TEXTCOLUMNS_SPACING); + pItem = &pPool->GetUserOrPoolDefaultItem(SDRATTR_TEXTCOLUMNS_SPACING); SetMetricValue(*m_xColumnsSpacing, pItem->GetValue(), eUnit); m_xColumnsSpacing->save_value(); } diff --git a/cui/source/tabpages/align.cxx b/cui/source/tabpages/align.cxx index 3db4e5c20ca5..d5816158d70b 100644 --- a/cui/source/tabpages/align.cxx +++ b/cui/source/tabpages/align.cxx @@ -56,24 +56,23 @@ namespace { template<typename JustContainerType, typename JustEnumType> void lcl_MaybeResetAlignToDistro( - weld::ComboBox& rLB, sal_uInt16 nListId, const SfxItemSet& rCoreAttrs, sal_uInt16 nWhichAlign, sal_uInt16 nWhichJM, JustEnumType eBlock) + weld::ComboBox& rLB, sal_uInt16 nListId, const SfxItemSet& rCoreAttrs, TypedWhichId<SfxEnumItemInterface> nWhichAlign, TypedWhichId<SfxEnumItemInterface> nWhichJM, JustEnumType eBlock) { - const SfxPoolItem* pItem; - if (rCoreAttrs.GetItemState(nWhichAlign, true, &pItem) != SfxItemState::SET) + const SfxEnumItemInterface* p = rCoreAttrs.GetItemIfSet(nWhichAlign); + if (!p) // alignment not set. return; - const SfxEnumItemInterface* p = static_cast<const SfxEnumItemInterface*>(pItem); JustContainerType eVal = static_cast<JustContainerType>(p->GetEnumValue()); if (eVal != eBlock) // alignment is not 'justify'. No need to go further. return; - if (rCoreAttrs.GetItemState(nWhichJM, true, &pItem) != SfxItemState::SET) + p = rCoreAttrs.GetItemIfSet(nWhichJM); + if (!p) // justification method is not set. return; - p = static_cast<const SfxEnumItemInterface*>(pItem); SvxCellJustifyMethod eMethod = static_cast<SvxCellJustifyMethod>(p->GetEnumValue()); if (eMethod == SvxCellJustifyMethod::Distribute) { @@ -124,7 +123,6 @@ AlignmentTabPage::AlignmentTabPage(weld::Container* pPage, weld::DialogControlle , m_xCbStacked(m_xBuilder->weld_check_button("checkVertStack")) , m_xCbAsianMode(m_xBuilder->weld_check_button("checkAsianMode")) // Properties - , m_xBoxDirection(m_xBuilder->weld_widget("boxDirection")) , m_xBtnWrap(m_xBuilder->weld_check_button("checkWrapTextAuto")) , m_xBtnHyphen(m_xBuilder->weld_check_button("checkHyphActive")) , m_xBtnShrink(m_xBuilder->weld_check_button("checkShrinkFitCellSize")) @@ -224,7 +222,7 @@ bool AlignmentTabPage::FillItemSet( SfxItemSet* rSet ) assert(pIndentItem); std::unique_ptr<SfxUInt16Item> pNewIndentItem(pIndentItem->Clone()); pNewIndentItem->SetValue(m_xEdIndent->get_value(FieldUnit::TWIP)); - rSet->Put(*pNewIndentItem); + rSet->Put(std::move(pNewIndentItem)); bChanged = true; } else if (SfxItemState::DEFAULT == rOldSet.GetItemState(nWhich, false)) @@ -267,25 +265,25 @@ bool AlignmentTabPage::FillItemSet( SfxItemSet* rSet ) assert(pAngleItem); std::unique_ptr<SdrAngleItem> pNewAngleItem(pAngleItem->Clone()); pNewAngleItem->SetValue(m_xCtrlDial->GetRotation()); - rSet->Put(*pNewAngleItem); + rSet->Put(std::move(pNewAngleItem)); bChanged = true; } else if (SfxItemState::DEFAULT == rOldSet.GetItemState(nWhich, false)) rSet->InvalidateItem(nWhich); - nWhich = GetWhich(SID_ATTR_ALIGN_LOCKPOS); + TypedWhichId<SvxRotateModeItem> nWhichLockPos(GetWhich(SID_ATTR_ALIGN_LOCKPOS)); if (m_aVsRefEdge.IsValueChangedFromSaved()) { switch (m_aVsRefEdge.GetSelectedItemId()) { case IID_CELLLOCK: - rSet->Put(SvxRotateModeItem(SvxRotateMode::SVX_ROTATE_MODE_STANDARD, nWhich)); + rSet->Put(SvxRotateModeItem(SvxRotateMode::SVX_ROTATE_MODE_STANDARD, nWhichLockPos)); break; case IID_TOPLOCK: - rSet->Put(SvxRotateModeItem(SvxRotateMode::SVX_ROTATE_MODE_TOP, nWhich)); + rSet->Put(SvxRotateModeItem(SvxRotateMode::SVX_ROTATE_MODE_TOP, nWhichLockPos)); break; case IID_BOTTOMLOCK: - rSet->Put(SvxRotateModeItem(SvxRotateMode::SVX_ROTATE_MODE_BOTTOM, nWhich)); + rSet->Put(SvxRotateModeItem(SvxRotateMode::SVX_ROTATE_MODE_BOTTOM, nWhichLockPos)); break; default: m_aVsRefEdge.SetNoSelection(); @@ -293,8 +291,8 @@ bool AlignmentTabPage::FillItemSet( SfxItemSet* rSet ) } bChanged = true; } - else if (SfxItemState::DEFAULT == rOldSet.GetItemState(nWhich, false)) - rSet->InvalidateItem(nWhich); + else if (SfxItemState::DEFAULT == rOldSet.GetItemState(nWhichLockPos, false)) + rSet->InvalidateItem(nWhichLockPos); nWhich = GetWhich(SID_ATTR_ALIGN_STACKED); if (m_xCbStacked->get_state_changed_from_saved()) @@ -304,7 +302,7 @@ bool AlignmentTabPage::FillItemSet( SfxItemSet* rSet ) assert(pStackItem); std::unique_ptr<SfxBoolItem> pNewStackItem(pStackItem->Clone()); pNewStackItem->SetValue(m_xCbStacked->get_active()); - rSet->Put(*pNewStackItem); + rSet->Put(std::move(pNewStackItem)); bChanged = true; } else if (SfxItemState::DEFAULT == rOldSet.GetItemState(nWhich, false)) @@ -327,7 +325,7 @@ bool AlignmentTabPage::FillItemSet( SfxItemSet* rSet ) assert(pWrapItem); std::unique_ptr<SfxBoolItem> pNewWrapItem(pWrapItem->Clone()); pNewWrapItem->SetValue(m_xBtnWrap->get_active()); - rSet->Put(*pNewWrapItem); + rSet->Put(std::move(pNewWrapItem)); bChanged = true; } else if (SfxItemState::DEFAULT == rOldSet.GetItemState(nWhich, false)) @@ -341,7 +339,7 @@ bool AlignmentTabPage::FillItemSet( SfxItemSet* rSet ) assert(pHyphItem); std::unique_ptr<SfxBoolItem> pNewHyphItem(pHyphItem->Clone()); pNewHyphItem->SetValue(m_xBtnHyphen->get_active()); - rSet->Put(*pNewHyphItem); + rSet->Put(std::move(pNewHyphItem)); bChanged = true; } else if (SfxItemState::DEFAULT == rOldSet.GetItemState(nWhich, false)) @@ -355,7 +353,7 @@ bool AlignmentTabPage::FillItemSet( SfxItemSet* rSet ) assert(pShrinkItem); std::unique_ptr<SfxBoolItem> pNewShrinkItem(pShrinkItem->Clone()); pNewShrinkItem->SetValue(m_xBtnShrink->get_active()); - rSet->Put(*pNewShrinkItem); + rSet->Put(std::move(pNewShrinkItem)); bChanged = true; } else if (SfxItemState::DEFAULT == rOldSet.GetItemState(nWhich, false)) @@ -376,12 +374,12 @@ bool AlignmentTabPage::FillItemSet( SfxItemSet* rSet ) // Special treatment for distributed alignment; we need to set the justify // method to 'distribute' to distinguish from the normal justification. - sal_uInt16 nWhichHorJM = GetWhich(SID_ATTR_ALIGN_HOR_JUSTIFY_METHOD); + TypedWhichId<SfxEnumItemInterface> nWhichHorJM(GetWhich(SID_ATTR_ALIGN_HOR_JUSTIFY_METHOD)); lcl_SetJustifyMethodToItemSet(*rSet, rOldSet, nWhichHorJM, *m_xLbHorAlign, ALIGNDLG_HORALIGN_DISTRIBUTED); if (!bChanged) bChanged = HasAlignmentChanged(*rSet, nWhichHorJM); - sal_uInt16 nWhichVerJM = GetWhich(SID_ATTR_ALIGN_VER_JUSTIFY_METHOD); + TypedWhichId<SfxEnumItemInterface> nWhichVerJM(GetWhich(SID_ATTR_ALIGN_VER_JUSTIFY_METHOD)); lcl_SetJustifyMethodToItemSet(*rSet, rOldSet, nWhichVerJM, *m_xLbVerAlign, ALIGNDLG_VERALIGN_DISTRIBUTED); if (!bChanged) bChanged = HasAlignmentChanged(*rSet, nWhichVerJM); @@ -404,7 +402,7 @@ namespace rBtn.set_sensitive(false); rTriState.bTriStateEnabled = false; break; - case SfxItemState::DONTCARE: + case SfxItemState::INVALID: rBtn.set_state(TRISTATE_INDET); rTriState.bTriStateEnabled = true; break; @@ -441,7 +439,7 @@ void AlignmentTabPage::Reset(const SfxItemSet* pCoreAttrs) case SfxItemState::DISABLED: m_xLbHorAlign->set_sensitive(false); break; - case SfxItemState::DONTCARE: + case SfxItemState::INVALID: m_xLbHorAlign->set_active(-1); break; case SfxItemState::DEFAULT: @@ -484,7 +482,7 @@ void AlignmentTabPage::Reset(const SfxItemSet* pCoreAttrs) case SfxItemState::DISABLED: m_xEdIndent->set_sensitive(false); break; - case SfxItemState::DONTCARE: + case SfxItemState::INVALID: m_xEdIndent->set_text(""); break; case SfxItemState::DEFAULT: @@ -507,7 +505,7 @@ void AlignmentTabPage::Reset(const SfxItemSet* pCoreAttrs) case SfxItemState::DISABLED: m_xLbVerAlign->set_sensitive(false); break; - case SfxItemState::DONTCARE: + case SfxItemState::INVALID: m_xLbVerAlign->set_active(-1); break; case SfxItemState::DEFAULT: @@ -548,7 +546,7 @@ void AlignmentTabPage::Reset(const SfxItemSet* pCoreAttrs) m_xNfRotate->set_sensitive(false); m_xCtrlDialWin->set_sensitive(false); break; - case SfxItemState::DONTCARE: + case SfxItemState::INVALID: m_xCtrlDial->SetNoRotation(); break; case SfxItemState::DEFAULT: @@ -570,7 +568,7 @@ void AlignmentTabPage::Reset(const SfxItemSet* pCoreAttrs) case SfxItemState::DISABLED: m_xVsRefEdge->set_sensitive(false); break; - case SfxItemState::DONTCARE: + case SfxItemState::INVALID: m_aVsRefEdge.SetNoSelection(); break; case SfxItemState::DEFAULT: @@ -608,7 +606,7 @@ void AlignmentTabPage::Reset(const SfxItemSet* pCoreAttrs) case SfxItemState::DISABLED: m_xLbFrameDir->set_sensitive(false); break; - case SfxItemState::DONTCARE: + case SfxItemState::INVALID: m_xLbFrameDir->set_active(-1); break; case SfxItemState::DEFAULT: @@ -622,7 +620,7 @@ void AlignmentTabPage::Reset(const SfxItemSet* pCoreAttrs) // Special treatment for distributed alignment; we need to set the justify // method to 'distribute' to distinguish from the normal justification. - sal_uInt16 nHorJustifyMethodWhich = GetWhich(SID_ATTR_ALIGN_HOR_JUSTIFY_METHOD); + TypedWhichId<SfxEnumItemInterface> nHorJustifyMethodWhich(GetWhich(SID_ATTR_ALIGN_HOR_JUSTIFY_METHOD)); SfxItemState eHorJustifyMethodState = pCoreAttrs->GetItemState(nHorJustifyMethodWhich); if (eHorJustifyMethodState == SfxItemState::UNKNOWN) { @@ -636,11 +634,11 @@ void AlignmentTabPage::Reset(const SfxItemSet* pCoreAttrs) // feature known, e.g. calc lcl_MaybeResetAlignToDistro<SvxCellHorJustify, SvxCellHorJustify>( *m_xLbHorAlign, ALIGNDLG_HORALIGN_DISTRIBUTED, *pCoreAttrs, - GetWhich(SID_ATTR_ALIGN_HOR_JUSTIFY), nHorJustifyMethodWhich, + TypedWhichId<SfxEnumItemInterface>(GetWhich(SID_ATTR_ALIGN_HOR_JUSTIFY)), nHorJustifyMethodWhich, SvxCellHorJustify::Block); } - sal_uInt16 nVerJustifyMethodWhich = GetWhich(SID_ATTR_ALIGN_VER_JUSTIFY_METHOD); + TypedWhichId<SfxEnumItemInterface> nVerJustifyMethodWhich( GetWhich(SID_ATTR_ALIGN_VER_JUSTIFY_METHOD) ); SfxItemState eVerJustifyMethodState = pCoreAttrs->GetItemState(nVerJustifyMethodWhich); if (eVerJustifyMethodState == SfxItemState::UNKNOWN) { @@ -654,7 +652,7 @@ void AlignmentTabPage::Reset(const SfxItemSet* pCoreAttrs) // feature known, e.g. calc lcl_MaybeResetAlignToDistro<SvxCellVerJustify, SvxCellVerJustify>( *m_xLbVerAlign, ALIGNDLG_VERALIGN_DISTRIBUTED, *pCoreAttrs, - GetWhich(SID_ATTR_ALIGN_VER_JUSTIFY), nVerJustifyMethodWhich, + TypedWhichId<SfxEnumItemInterface>(GetWhich(SID_ATTR_ALIGN_VER_JUSTIFY)), nVerJustifyMethodWhich, SvxCellVerJustify::Block); } @@ -736,21 +734,18 @@ void AlignmentTabPage::UpdateEnableControls() m_xNfRotate->set_sensitive(!bHorFill && !bStackedText); } -bool AlignmentTabPage::HasAlignmentChanged( const SfxItemSet& rNew, sal_uInt16 nWhich ) const +bool AlignmentTabPage::HasAlignmentChanged( const SfxItemSet& rNew, TypedWhichId<SfxEnumItemInterface> nWhich ) const { const SfxItemSet& rOld = GetItemSet(); - const SfxPoolItem* pItem; SvxCellJustifyMethod eMethodOld = SvxCellJustifyMethod::Auto; SvxCellJustifyMethod eMethodNew = SvxCellJustifyMethod::Auto; - if (rOld.GetItemState(nWhich, true, &pItem) == SfxItemState::SET) + if (const SfxEnumItemInterface* p = rOld.GetItemIfSet(nWhich)) { - const SfxEnumItemInterface* p = static_cast<const SfxEnumItemInterface*>(pItem); eMethodOld = static_cast<SvxCellJustifyMethod>(p->GetEnumValue()); } - if (rNew.GetItemState(nWhich, true, &pItem) == SfxItemState::SET) + if (const SfxEnumItemInterface* p = rNew.GetItemIfSet(nWhich)) { - const SfxEnumItemInterface* p = static_cast<const SfxEnumItemInterface*>(pItem); eMethodNew = static_cast<SvxCellJustifyMethod>(p->GetEnumValue()); } diff --git a/cui/source/tabpages/autocdlg.cxx b/cui/source/tabpages/autocdlg.cxx index 28bcbcf9f951..b7abdbcce907 100644 --- a/cui/source/tabpages/autocdlg.cxx +++ b/cui/source/tabpages/autocdlg.cxx @@ -17,8 +17,11 @@ * the License at http://www.apache.org/licenses/LICENSE-2.0 . */ +#include <sal/config.h> + #include <i18nutil/unicode.hxx> #include <o3tl/safeint.hxx> +#include <utility> #include <vcl/event.hxx> #include <vcl/keycodes.hxx> #include <vcl/settings.hxx> @@ -29,11 +32,9 @@ #include <unotools/charclass.hxx> #include <unotools/collatorwrapper.hxx> #include <comphelper/processfactory.hxx> -#include <comphelper/string.hxx> #include <vcl/svapp.hxx> #include <sfx2/module.hxx> #include <svl/eitem.hxx> -#include <svl/languageoptions.hxx> #include <svl/cjkoptions.hxx> #include <svl/ctloptions.hxx> #include <svx/SmartTagMgr.hxx> @@ -46,14 +47,13 @@ #include <autocdlg.hxx> #include <editeng/acorrcfg.hxx> #include <editeng/svxacorr.hxx> -#include <cui/cuicharmap.hxx> +#include <svx/cuicharmap.hxx> #include <strings.hrc> #include <dialmgr.hxx> #include <svx/svxids.hrc> static LanguageType eLastDialogLanguage = LANGUAGE_SYSTEM; -using namespace ::com::sun::star::util; using namespace ::com::sun::star; OfaAutoCorrDlg::OfaAutoCorrDlg(weld::Window* pParent, const SfxItemSet* _pSet ) @@ -106,7 +106,7 @@ OfaAutoCorrDlg::OfaAutoCorrDlg(weld::Window* pParent, const SfxItemSet* _pSet ) //! will be set to LANGUAGE_UNDETERMINED SvxLanguageListFlags nLangList = SvxLanguageListFlags::WESTERN; - if( SvtCTLOptions().IsCTLFontEnabled() ) + if( SvtCTLOptions::IsCTLFontEnabled() ) nLangList |= SvxLanguageListFlags::CTL; if( SvtCJKOptions::IsCJKFontEnabled() ) nLangList |= SvxLanguageListFlags::CJK; @@ -166,7 +166,7 @@ IMPL_LINK_NOARG(OfaAutoCorrDlg, SelectLanguageHdl, weld::ComboBox&, void) if(eNewLang == eLastDialogLanguage) return; - OString sPageId = GetCurPageId(); + OUString sPageId = GetCurPageId(); if (sPageId == "replace") { OfaAutocorrReplacePage* pPage = static_cast<OfaAutocorrReplacePage*>(GetTabPage(sPageId)); @@ -183,14 +183,15 @@ IMPL_LINK_NOARG(OfaAutoCorrDlg, SelectLanguageHdl, weld::ComboBox&, void) OfaAutocorrOptionsPage::OfaAutocorrOptionsPage(weld::Container* pPage, weld::DialogController* pController, const SfxItemSet& rSet) : SfxTabPage(pPage, pController, "cui/ui/acoroptionspage.ui", "AutocorrectOptionsPage", &rSet) - , m_sInput(CuiResId(RID_SVXSTR_USE_REPLACE)) - , m_sDoubleCaps(CuiResId(RID_SVXSTR_CPTL_STT_WORD)) - , m_sStartCap(CuiResId(RID_SVXSTR_CPTL_STT_SENT)) - , m_sBoldUnderline(CuiResId(RID_SVXSTR_BOLD_UNDER)) - , m_sURL(CuiResId(RID_SVXSTR_DETECT_URL)) - , m_sNoDblSpaces(CuiResId(RID_SVXSTR_NO_DBL_SPACES)) - , m_sDash(CuiResId(RID_SVXSTR_DASH)) - , m_sAccidentalCaps(CuiResId(RID_SVXSTR_CORRECT_ACCIDENTAL_CAPS_LOCK)) + , m_sInput(CuiResId(RID_CUISTR_USE_REPLACE)) + , m_sDoubleCaps(CuiResId(RID_CUISTR_CPTL_STT_WORD)) + , m_sStartCap(CuiResId(RID_CUISTR_CPTL_STT_SENT)) + , m_sBoldUnderline(CuiResId(RID_CUISTR_BOLD_UNDER)) + , m_sURL(CuiResId(RID_CUISTR_DETECT_URL)) + , m_sDOI(CuiResId(RID_CUISTR_DETECT_DOI)) + , m_sNoDblSpaces(CuiResId(RID_CUISTR_NO_DBL_SPACES)) + , m_sDash(CuiResId(RID_CUISTR_DASH)) + , m_sAccidentalCaps(CuiResId(RID_CUISTR_CORRECT_ACCIDENTAL_CAPS_LOCK)) , m_xCheckLB(m_xBuilder->weld_tree_view("checklist")) { m_xCheckLB->enable_toggle_buttons(weld::ColumnToggleType::Check); @@ -222,6 +223,7 @@ bool OfaAutocorrOptionsPage::FillItemSet( SfxItemSet* ) pAutoCorrect->SetAutoCorrFlag(ACFlags::CapitalStartSentence, m_xCheckLB->get_toggle(nPos++) == TRISTATE_TRUE); pAutoCorrect->SetAutoCorrFlag(ACFlags::ChgWeightUnderl, m_xCheckLB->get_toggle(nPos++) == TRISTATE_TRUE); pAutoCorrect->SetAutoCorrFlag(ACFlags::SetINetAttr, m_xCheckLB->get_toggle(nPos++) == TRISTATE_TRUE); + pAutoCorrect->SetAutoCorrFlag(ACFlags::SetDOIAttr, m_xCheckLB->get_toggle(nPos++) == TRISTATE_TRUE); pAutoCorrect->SetAutoCorrFlag(ACFlags::ChgToEnEmDash, m_xCheckLB->get_toggle(nPos++) == TRISTATE_TRUE); pAutoCorrect->SetAutoCorrFlag(ACFlags::IgnoreDoubleSpace, m_xCheckLB->get_toggle(nPos++) == TRISTATE_TRUE); pAutoCorrect->SetAutoCorrFlag(ACFlags::CorrectCapsLock, m_xCheckLB->get_toggle(nPos++) == TRISTATE_TRUE); @@ -262,6 +264,7 @@ void OfaAutocorrOptionsPage::Reset( const SfxItemSet* ) InsertEntry(m_sStartCap); InsertEntry(m_sBoldUnderline); InsertEntry(m_sURL); + InsertEntry(m_sDOI); InsertEntry(m_sDash); InsertEntry(m_sNoDblSpaces); InsertEntry(m_sAccidentalCaps); @@ -272,6 +275,7 @@ void OfaAutocorrOptionsPage::Reset( const SfxItemSet* ) m_xCheckLB->set_toggle( nPos++, bool(nFlags & ACFlags::CapitalStartSentence) ? TRISTATE_TRUE : TRISTATE_FALSE ); m_xCheckLB->set_toggle( nPos++, bool(nFlags & ACFlags::ChgWeightUnderl) ? TRISTATE_TRUE : TRISTATE_FALSE ); m_xCheckLB->set_toggle( nPos++, bool(nFlags & ACFlags::SetINetAttr) ? TRISTATE_TRUE : TRISTATE_FALSE ); + m_xCheckLB->set_toggle( nPos++, bool(nFlags & ACFlags::SetDOIAttr) ? TRISTATE_TRUE : TRISTATE_FALSE ); m_xCheckLB->set_toggle( nPos++, bool(nFlags & ACFlags::ChgToEnEmDash) ? TRISTATE_TRUE : TRISTATE_FALSE ); m_xCheckLB->set_toggle( nPos++, bool(nFlags & ACFlags::IgnoreDoubleSpace) ? TRISTATE_TRUE : TRISTATE_FALSE ); m_xCheckLB->set_toggle( nPos++, bool(nFlags & ACFlags::CorrectCapsLock) ? TRISTATE_TRUE : TRISTATE_FALSE ); @@ -332,12 +336,14 @@ enum OfaAutoFmtOptions BEGIN_UPPER, BOLD_UNDERLINE, DETECT_URL, + DETECT_DOI, REPLACE_DASHES, DEL_SPACES_AT_STT_END, DEL_SPACES_BETWEEN_LINES, IGNORE_DBLSPACE, CORRECT_CAPS_LOCK, APPLY_NUMBERING, + APPLY_NUMBERING_AFTER_SPACE, INSERT_BORDER, CREATE_TABLE, REPLACE_STYLES, @@ -352,31 +358,32 @@ enum OfaAutoFmtOptions OfaSwAutoFmtOptionsPage::OfaSwAutoFmtOptionsPage(weld::Container* pPage, weld::DialogController* pController, const SfxItemSet& rSet ) : SfxTabPage(pPage, pController, "cui/ui/applyautofmtpage.ui", "ApplyAutoFmtPage", &rSet) - , sDeleteEmptyPara(CuiResId(RID_SVXSTR_DEL_EMPTY_PARA)) - , sUseReplaceTbl(CuiResId(RID_SVXSTR_USE_REPLACE)) - , sCapitalStartWord(CuiResId(RID_SVXSTR_CPTL_STT_WORD)) - , sCapitalStartSentence(CuiResId(RID_SVXSTR_CPTL_STT_SENT)) - , sUserStyle(CuiResId(RID_SVXSTR_USER_STYLE)) - , sBullet(CuiResId(RID_SVXSTR_BULLET)) - , sBoldUnder(CuiResId(RID_SVXSTR_BOLD_UNDER)) - , sNoDblSpaces(CuiResId(RID_SVXSTR_NO_DBL_SPACES)) - , sCorrectCapsLock(CuiResId(RID_SVXSTR_CORRECT_ACCIDENTAL_CAPS_LOCK)) - , sDetectURL(CuiResId(RID_SVXSTR_DETECT_URL)) - , sDash(CuiResId(RID_SVXSTR_DASH)) - , sRightMargin(CuiResId(RID_SVXSTR_RIGHT_MARGIN)) - , sNum(CuiResId(RID_SVXSTR_NUM)) - , sBorder(CuiResId(RID_SVXSTR_BORDER)) - , sTable(CuiResId(RID_SVXSTR_CREATE_TABLE)) - , sReplaceTemplates(CuiResId(RID_SVXSTR_REPLACE_TEMPLATES)) - , sDelSpaceAtSttEnd(CuiResId(RID_SVXSTR_DEL_SPACES_AT_STT_END)) - , sDelSpaceBetweenLines(CuiResId(RID_SVXSTR_DEL_SPACES_BETWEEN_LINES)) + , sDeleteEmptyPara(CuiResId(RID_CUISTR_DEL_EMPTY_PARA)) + , sUseReplaceTbl(CuiResId(RID_CUISTR_USE_REPLACE)) + , sCapitalStartWord(CuiResId(RID_CUISTR_CPTL_STT_WORD)) + , sCapitalStartSentence(CuiResId(RID_CUISTR_CPTL_STT_SENT)) + , sUserStyle(CuiResId(RID_CUISTR_USER_STYLE)) + , sBullet(CuiResId(RID_CUISTR_BULLET)) + , sBoldUnder(CuiResId(RID_CUISTR_BOLD_UNDER)) + , sNoDblSpaces(CuiResId(RID_CUISTR_NO_DBL_SPACES)) + , sCorrectCapsLock(CuiResId(RID_CUISTR_CORRECT_ACCIDENTAL_CAPS_LOCK)) + , sDetectURL(CuiResId(RID_CUISTR_DETECT_URL)) + , sDetectDOI(CuiResId(RID_CUISTR_DETECT_DOI)) + , sDash(CuiResId(RID_CUISTR_DASH)) + , sRightMargin(CuiResId(RID_CUISTR_RIGHT_MARGIN)) + , sNum(CuiResId(RID_CUISTR_NUM)) + , sBulletsAfterSpace(CuiResId(RID_SVXSTR_NUM_FORMAT_AFTER_SPACE)) + , sBorder(CuiResId(RID_CUISTR_BORDER)) + , sTable(CuiResId(RID_CUISTR_CREATE_TABLE)) + , sReplaceTemplates(CuiResId(RID_CUISTR_REPLACE_TEMPLATES)) + , sDelSpaceAtSttEnd(CuiResId(RID_CUISTR_DEL_SPACES_AT_STT_END)) + , sDelSpaceBetweenLines(CuiResId(RID_CUISTR_DEL_SPACES_BETWEEN_LINES)) , nPercent(50) , m_xCheckLB(m_xBuilder->weld_tree_view("list")) , m_xEditPB(m_xBuilder->weld_button("edit")) { m_xCheckLB->connect_changed(LINK(this, OfaSwAutoFmtOptionsPage, SelectHdl)); m_xCheckLB->connect_row_activated(LINK(this, OfaSwAutoFmtOptionsPage, DoubleClickEditHdl)); - m_xCheckLB->enable_toggle_buttons(weld::ColumnToggleType::Check); std::vector<int> aWidths { @@ -401,9 +408,9 @@ void OfaSwAutoFmtOptionsPage::CreateEntry(const OUString& rTxt, sal_uInt16 nCol) OfaSwAutoFmtOptionsPage::~OfaSwAutoFmtOptionsPage() { - delete reinterpret_cast<ImpUserData*>(m_xCheckLB->get_id(REPLACE_BULLETS).toInt64()); - delete reinterpret_cast<ImpUserData*>(m_xCheckLB->get_id(APPLY_NUMBERING).toInt64()); - delete reinterpret_cast<ImpUserData*>(m_xCheckLB->get_id(MERGE_SINGLE_LINE_PARA).toInt64()); + delete weld::fromId<ImpUserData*>(m_xCheckLB->get_id(REPLACE_BULLETS)); + delete weld::fromId<ImpUserData*>(m_xCheckLB->get_id(APPLY_NUMBERING)); + delete weld::fromId<ImpUserData*>(m_xCheckLB->get_id(MERGE_SINGLE_LINE_PARA)); } std::unique_ptr<SfxTabPage> OfaSwAutoFmtOptionsPage::Create(weld::Container* pPage, weld::DialogController* pController, @@ -455,6 +462,12 @@ bool OfaSwAutoFmtOptionsPage::FillItemSet( SfxItemSet* ) pAutoCorrect->SetAutoCorrFlag(ACFlags::SetINetAttr, m_xCheckLB->get_toggle(DETECT_URL, CBCOL_SECOND) == TRISTATE_TRUE); + bCheck = m_xCheckLB->get_toggle(DETECT_DOI, CBCOL_FIRST) == TRISTATE_TRUE; + bModified |= pOpt->bSetDOIAttr != bCheck; + pOpt->bSetDOIAttr = bCheck; + pAutoCorrect->SetAutoCorrFlag(ACFlags::SetDOIAttr, + m_xCheckLB->get_toggle(DETECT_DOI, CBCOL_SECOND) == TRISTATE_TRUE); + bCheck = m_xCheckLB->get_toggle(DEL_EMPTY_NODE, CBCOL_FIRST) == TRISTATE_TRUE; bModified |= pOpt->bDelEmptyNode != bCheck; pOpt->bDelEmptyNode = bCheck; @@ -486,6 +499,10 @@ bool OfaSwAutoFmtOptionsPage::FillItemSet( SfxItemSet* ) bModified |= pOpt->bSetNumRule != bCheck; pOpt->bSetNumRule = bCheck; + bCheck = m_xCheckLB->get_toggle(APPLY_NUMBERING_AFTER_SPACE, CBCOL_SECOND) == TRISTATE_TRUE; + bModified |= pOpt->bSetNumRuleAfterSpace != bCheck; + pOpt->bSetNumRuleAfterSpace = bCheck; + bCheck = m_xCheckLB->get_toggle(INSERT_BORDER, CBCOL_SECOND) == TRISTATE_TRUE; bModified |= pOpt->bSetBorder != bCheck; pOpt->bSetBorder = bCheck; @@ -558,6 +575,7 @@ void OfaSwAutoFmtOptionsPage::Reset( const SfxItemSet* ) CreateEntry(sCapitalStartSentence, CBCOL_BOTH ); CreateEntry(sBoldUnder, CBCOL_BOTH ); CreateEntry(sDetectURL, CBCOL_BOTH ); + CreateEntry(sDetectDOI, CBCOL_BOTH ); CreateEntry(sDash, CBCOL_BOTH ); CreateEntry(sDelSpaceAtSttEnd, CBCOL_BOTH ); CreateEntry(sDelSpaceBetweenLines, CBCOL_BOTH ); @@ -565,6 +583,7 @@ void OfaSwAutoFmtOptionsPage::Reset( const SfxItemSet* ) CreateEntry(sNoDblSpaces, CBCOL_SECOND); CreateEntry(sCorrectCapsLock, CBCOL_SECOND); CreateEntry(sNum.replaceFirst("%1", sBulletChar), CBCOL_SECOND); + CreateEntry(sBulletsAfterSpace, CBCOL_SECOND); CreateEntry(sBorder, CBCOL_SECOND); CreateEntry(sTable, CBCOL_SECOND); CreateEntry(sReplaceTemplates, CBCOL_SECOND); @@ -583,6 +602,8 @@ void OfaSwAutoFmtOptionsPage::Reset( const SfxItemSet* ) m_xCheckLB->set_toggle(BOLD_UNDERLINE, bool(nFlags & ACFlags::ChgWeightUnderl) ? TRISTATE_TRUE : TRISTATE_FALSE, CBCOL_SECOND); m_xCheckLB->set_toggle(DETECT_URL, pOpt->bSetINetAttr ? TRISTATE_TRUE : TRISTATE_FALSE, CBCOL_FIRST); m_xCheckLB->set_toggle(DETECT_URL, bool(nFlags & ACFlags::SetINetAttr) ? TRISTATE_TRUE : TRISTATE_FALSE, CBCOL_SECOND); + m_xCheckLB->set_toggle(DETECT_DOI, pOpt->bSetDOIAttr ? TRISTATE_TRUE : TRISTATE_FALSE, CBCOL_FIRST); + m_xCheckLB->set_toggle(DETECT_DOI, bool(nFlags & ACFlags::SetDOIAttr) ? TRISTATE_TRUE : TRISTATE_FALSE, CBCOL_SECOND); m_xCheckLB->set_toggle(REPLACE_DASHES, pOpt->bChgToEnEmDash ? TRISTATE_TRUE : TRISTATE_FALSE, CBCOL_FIRST); m_xCheckLB->set_toggle(REPLACE_DASHES, bool(nFlags & ACFlags::ChgToEnEmDash) ? TRISTATE_TRUE : TRISTATE_FALSE, CBCOL_SECOND); m_xCheckLB->set_toggle(DEL_SPACES_AT_STT_END, pOpt->bAFormatDelSpacesAtSttEnd ? TRISTATE_TRUE : TRISTATE_FALSE, CBCOL_FIRST); @@ -592,6 +613,7 @@ void OfaSwAutoFmtOptionsPage::Reset( const SfxItemSet* ) m_xCheckLB->set_toggle(IGNORE_DBLSPACE, bool(nFlags & ACFlags::IgnoreDoubleSpace) ? TRISTATE_TRUE : TRISTATE_FALSE, CBCOL_SECOND); m_xCheckLB->set_toggle(CORRECT_CAPS_LOCK, bool(nFlags & ACFlags::CorrectCapsLock) ? TRISTATE_TRUE : TRISTATE_FALSE, CBCOL_SECOND); m_xCheckLB->set_toggle(APPLY_NUMBERING, pOpt->bSetNumRule ? TRISTATE_TRUE : TRISTATE_FALSE, CBCOL_SECOND); + m_xCheckLB->set_toggle(APPLY_NUMBERING_AFTER_SPACE, pOpt->bSetNumRuleAfterSpace ? TRISTATE_TRUE : TRISTATE_FALSE, CBCOL_SECOND); m_xCheckLB->set_toggle(INSERT_BORDER, pOpt->bSetBorder ? TRISTATE_TRUE : TRISTATE_FALSE, CBCOL_SECOND); m_xCheckLB->set_toggle(CREATE_TABLE, pOpt->bCreateTable ? TRISTATE_TRUE : TRISTATE_FALSE, CBCOL_SECOND); m_xCheckLB->set_toggle(REPLACE_STYLES, pOpt->bReplaceStyles ? TRISTATE_TRUE : TRISTATE_FALSE, CBCOL_SECOND); @@ -601,15 +623,15 @@ void OfaSwAutoFmtOptionsPage::Reset( const SfxItemSet* ) m_xCheckLB->set_toggle(MERGE_SINGLE_LINE_PARA, pOpt->bRightMargin ? TRISTATE_TRUE : TRISTATE_FALSE, CBCOL_FIRST); ImpUserData* pUserData = new ImpUserData(&sBulletChar, &aBulletFont); - OUString sId(OUString::number(reinterpret_cast<sal_Int64>(pUserData))); + OUString sId(weld::toId(pUserData)); m_xCheckLB->set_id(REPLACE_BULLETS, sId); pUserData = new ImpUserData(&sMargin, nullptr); - sId = OUString::number(reinterpret_cast<sal_Int64>(pUserData)); + sId = weld::toId(pUserData); m_xCheckLB->set_id(MERGE_SINGLE_LINE_PARA, sId); ImpUserData* pUserData2 = new ImpUserData(&sByInputBulletChar, &aByInputBulletFont); - sId = OUString::number(reinterpret_cast<sal_Int64>(pUserData2)); + sId = weld::toId(pUserData2); m_xCheckLB->set_id(APPLY_NUMBERING, sId); m_xCheckLB->thaw(); @@ -632,7 +654,7 @@ IMPL_LINK_NOARG(OfaSwAutoFmtOptionsPage, EditHdl, weld::Button&, void) if (nSelEntryPos == REPLACE_BULLETS || nSelEntryPos == APPLY_NUMBERING) { SvxCharacterMap aMapDlg(GetFrameWeld(), nullptr, nullptr); - ImpUserData* pUserData = reinterpret_cast<ImpUserData*>(m_xCheckLB->get_id(nSelEntryPos).toInt64()); + ImpUserData* pUserData = weld::fromId<ImpUserData*>(m_xCheckLB->get_id(nSelEntryPos)); aMapDlg.SetCharFont(*pUserData->pFont); aMapDlg.SetChar( (*pUserData->pString)[0] ); if (RET_OK == aMapDlg.run()) @@ -667,6 +689,7 @@ IMPL_LINK_NOARG(OfaSwAutoFmtOptionsPage, EditHdl, weld::Button&, void) OfaAutocorrReplacePage::OfaAutocorrReplacePage(weld::Container* pPage, weld::DialogController* pController, const SfxItemSet& rSet) : SfxTabPage(pPage, pController, "cui/ui/acorreplacepage.ui", "AcorReplacePage", &rSet) + , maCompareClass(comphelper::getProcessComponentContext()) , eLang(eLastDialogLanguage) , bHasSelectionText(false) , bFirstSelect(true) @@ -698,9 +721,8 @@ OfaAutocorrReplacePage::OfaAutocorrReplacePage(weld::Container* pPage, weld::Dia bSWriter = pMod == SfxModule::GetActiveModule(); LanguageTag aLanguageTag( eLastDialogLanguage ); - pCompareClass.reset( new CollatorWrapper( comphelper::getProcessComponentContext() ) ); - pCompareClass->loadDefaultCollator( aLanguageTag.getLocale(), 0 ); - pCharClass.reset( new CharClass( aLanguageTag ) ); + maCompareClass.loadDefaultCollator( aLanguageTag.getLocale(), 0 ); + pCharClass.reset( new CharClass( std::move(aLanguageTag) ) ); auto nColWidth = m_xReplaceTLB->get_approximate_digit_width() * 32; m_aReplaceFixedWidths.push_back(nColWidth); @@ -722,7 +744,6 @@ OfaAutocorrReplacePage::~OfaAutocorrReplacePage() aDoubleStringTable.clear(); aChangesTable.clear(); - pCompareClass.reset(); pCharClass.reset(); } @@ -770,7 +791,8 @@ bool OfaAutocorrReplacePage::FillItemSet( SfxItemSet* ) bool bKeepSourceFormatting = newEntry.pUserData == &bHasSelectionText; if (bKeepSourceFormatting) { - pAutoCorrect->PutText(newEntry.sShort, *SfxObjectShell::Current(), eCurrentLang); + if (SfxObjectShell* pSh = SfxObjectShell::Current()) + pAutoCorrect->PutText(newEntry.sShort, *pSh, eCurrentLang); continue; } @@ -810,7 +832,7 @@ void OfaAutocorrReplacePage::RefillReplaceBox(bool bFromReset, pArray->push_back(DoubleString(m_xReplaceTLB->get_text(rIter, 0), m_xReplaceTLB->get_text(rIter, 1))); DoubleString& rDouble = pArray->back(); - rDouble.pUserData = reinterpret_cast<void*>(m_xReplaceTLB->get_id(rIter).toInt64()); + rDouble.pUserData = weld::fromId<void*>(m_xReplaceTLB->get_id(rIter)); return false; }); } @@ -831,7 +853,7 @@ void OfaAutocorrReplacePage::RefillReplaceBox(bool bFromReset, if (!bTextOnly) { // that means: with format info or even with selection text - OUString sId = OUString::number(reinterpret_cast<sal_Int64>(rDouble.pUserData)); + OUString sId = weld::toId(rDouble.pUserData); m_xReplaceTLB->set_id(rIter, sId); } m_xReplaceTLB->set_text(rIter, rDouble.sShort, 0); @@ -857,7 +879,7 @@ void OfaAutocorrReplacePage::RefillReplaceBox(bool bFromReset, if (!bTextOnly) { // that means: with format info or even with selection text - OUString sId = OUString::number(reinterpret_cast<sal_Int64>(m_xTextOnlyCB.get())); + OUString sId = weld::toId(m_xTextOnlyCB.get()); m_xReplaceTLB->set_id(rIter, sId); } m_xReplaceTLB->set_text(rIter, elem.GetShort(), 0); @@ -903,9 +925,9 @@ void OfaAutocorrReplacePage::SetLanguage(LanguageType eSet) eLastDialogLanguage = eSet; LanguageTag aLanguageTag( eLastDialogLanguage ); - pCompareClass.reset( new CollatorWrapper( comphelper::getProcessComponentContext() ) ); - pCompareClass->loadDefaultCollator( aLanguageTag.getLocale(), 0 ); - pCharClass.reset( new CharClass( aLanguageTag ) ); + maCompareClass = CollatorWrapper( comphelper::getProcessComponentContext() ); + maCompareClass.loadDefaultCollator( aLanguageTag.getLocale(), 0 ); + pCharClass.reset( new CharClass( std::move(aLanguageTag) ) ); ModifyHdl(*m_xShortED); } } @@ -918,7 +940,7 @@ IMPL_LINK(OfaAutocorrReplacePage, SelectHdl, weld::TreeView&, rBox, void) OUString sTmpShort(rBox.get_text(nEntry, 0)); // if the text is set via ModifyHdl, the cursor is always at the beginning // of a word, although you're editing here - bool bSameContent = 0 == pCompareClass->compareString(sTmpShort, m_xShortED->get_text()); + bool bSameContent = 0 == maCompareClass.compareString(sTmpShort, m_xShortED->get_text()); int nStartPos, nEndPos; m_xShortED->get_selection_bounds(nStartPos, nEndPos); if (m_xShortED->get_text() != sTmpShort) @@ -1056,7 +1078,7 @@ bool OfaAutocorrReplacePage::NewDelHdl(const weld::Widget* pBtn) int nCount = m_xReplaceTLB->n_children(); for (j = 0; j < nCount; ++j) { - if (0 >= pCompareClass->compareString(sEntry, m_xReplaceTLB->get_text(j, 0))) + if (0 >= maCompareClass.compareString(sEntry, m_xReplaceTLB->get_text(j, 0))) break; } nPos = j; @@ -1065,7 +1087,7 @@ bool OfaAutocorrReplacePage::NewDelHdl(const weld::Widget* pBtn) OUString sId; if (bKeepSourceFormatting) { - sId = OUString::number(reinterpret_cast<sal_Int64>(&bHasSelectionText)); // new formatted text + sId = weld::toId(&bHasSelectionText); // new formatted text } m_xReplaceTLB->insert(nPos, sEntry, &sId, nullptr, nullptr); @@ -1109,7 +1131,7 @@ IMPL_LINK(OfaAutocorrReplacePage, ModifyHdl, weld::Entry&, rEdt, void) &bTmpSelEntry, &bFirstSelIterSet, &xFirstSel, &aWordStr](weld::TreeIter& rIter){ OUString aTestStr = m_xReplaceTLB->get_text(rIter, 0); - if( pCompareClass->compareString(rEntry, aTestStr ) == 0 ) + if( maCompareClass.compareString(rEntry, aTestStr ) == 0 ) { if (!rRepString.isEmpty()) bFirstSelect = true; @@ -1190,6 +1212,7 @@ static bool lcl_FindInArray(std::vector<OUString>& rStrings, std::u16string_view OfaAutocorrExceptPage::OfaAutocorrExceptPage(weld::Container* pPage, weld::DialogController* pController, const SfxItemSet& rSet) : SfxTabPage(pPage, pController, "cui/ui/acorexceptpage.ui", "AcorExceptPage", &rSet) + , maCompareClass(comphelper::getProcessComponentContext()) , eLang(eLastDialogLanguage) , m_xAbbrevED(m_xBuilder->weld_entry("abbrev")) , m_xAbbrevLB(m_xBuilder->weld_tree_view("abbrevlist")) @@ -1209,8 +1232,7 @@ OfaAutocorrExceptPage::OfaAutocorrExceptPage(weld::Container* pPage, weld::Dialo m_xDoubleCapsLB->set_size_request(-1, m_xDoubleCapsLB->get_height_rows(6)); css::lang::Locale aLcl( LanguageTag::convertToLocale(eLastDialogLanguage )); - pCompareClass.reset( new CollatorWrapper( comphelper::getProcessComponentContext() ) ); - pCompareClass->loadDefaultCollator( aLcl, 0 ); + maCompareClass.loadDefaultCollator( aLcl, 0 ); m_xNewAbbrevPB->connect_clicked(LINK(this, OfaAutocorrExceptPage, NewDelButtonHdl)); m_xDelAbbrevPB->connect_clicked(LINK(this, OfaAutocorrExceptPage, NewDelButtonHdl)); @@ -1229,7 +1251,6 @@ OfaAutocorrExceptPage::OfaAutocorrExceptPage(weld::Container* pPage, weld::Dialo OfaAutocorrExceptPage::~OfaAutocorrExceptPage() { aStringsTable.clear(); - pCompareClass.reset(); } std::unique_ptr<SfxTabPage> OfaAutocorrExceptPage::Create(weld::Container* pPage, weld::DialogController* pController, @@ -1364,8 +1385,8 @@ void OfaAutocorrExceptPage::SetLanguage(LanguageType eSet) // save old settings and fill anew RefillReplaceBoxes(false, eLang, eSet); eLastDialogLanguage = eSet; - pCompareClass.reset( new CollatorWrapper( comphelper::getProcessComponentContext() ) ); - pCompareClass->loadDefaultCollator( LanguageTag::convertToLocale( eLastDialogLanguage ), 0 ); + maCompareClass = CollatorWrapper( comphelper::getProcessComponentContext() ); + maCompareClass.loadDefaultCollator( LanguageTag::convertToLocale( eLastDialogLanguage ), 0 ); ModifyHdl(*m_xAbbrevED); ModifyHdl(*m_xDoubleCapsED); } @@ -1510,7 +1531,7 @@ IMPL_LINK(OfaAutocorrExceptPage, ModifyHdl, weld::Entry&, rEdt, void) bool bEntryLen = !sEntry.isEmpty(); if (&rEdt == m_xAbbrevED.get()) { - bool bSame = lcl_FindEntry(*m_xAbbrevLB, sEntry, *pCompareClass); + bool bSame = lcl_FindEntry(*m_xAbbrevLB, sEntry, maCompareClass); if(bSame && sEntry != m_xAbbrevLB->get_selected_text()) rEdt.set_text(m_xAbbrevLB->get_selected_text()); m_xNewAbbrevPB->set_sensitive(!bSame && bEntryLen); @@ -1518,7 +1539,7 @@ IMPL_LINK(OfaAutocorrExceptPage, ModifyHdl, weld::Entry&, rEdt, void) } else { - bool bSame = lcl_FindEntry(*m_xDoubleCapsLB, sEntry, *pCompareClass); + bool bSame = lcl_FindEntry(*m_xDoubleCapsLB, sEntry, maCompareClass); if(bSame && sEntry != m_xDoubleCapsLB->get_selected_text()) rEdt.set_text(m_xDoubleCapsLB->get_selected_text()); m_xNewDoublePB->set_sensitive(!bSame && bEntryLen); @@ -1551,10 +1572,10 @@ void OfaQuoteTabPage::CreateEntry(weld::TreeView& rCheckLB, const OUString& rTxt OfaQuoteTabPage::OfaQuoteTabPage(weld::Container* pPage, weld::DialogController* pController, const SfxItemSet& rSet) : SfxTabPage(pPage, pController, "cui/ui/applylocalizedpage.ui", "ApplyLocalizedPage", &rSet) - , sNonBrkSpace(CuiResId(RID_SVXSTR_NON_BREAK_SPACE)) - , sOrdinal(CuiResId(RID_SVXSTR_ORDINAL)) - , sTransliterateRTL(CuiResId(RID_SVXSTR_OLD_HUNGARIAN)) - , sAngleQuotes(CuiResId(RID_SVXSTR_ANGLE_QUOTES)) + , sNonBrkSpace(CuiResId(RID_CUISTR_NON_BREAK_SPACE)) + , sOrdinal(CuiResId(RID_CUISTR_ORDINAL)) + , sTransliterateRTL(CuiResId(RID_CUISTR_OLD_HUNGARIAN)) + , sAngleQuotes(CuiResId(RID_CUISTR_ANGLE_QUOTES)) , cSglStartQuote(0) , cSglEndQuote(0) , cStartQuote(0) @@ -1586,7 +1607,6 @@ OfaQuoteTabPage::OfaQuoteTabPage(weld::Container* pPage, weld::DialogController* if ( bShowSWOptions ) { - m_xSwCheckLB->enable_toggle_buttons(weld::ColumnToggleType::Check); std::vector<int> aWidths { o3tl::narrowing<int>(m_xSwCheckLB->get_pixel_size(m_xSwCheckLB->get_column_title(0)).Width() * 2), @@ -1795,7 +1815,7 @@ IMPL_LINK(OfaQuoteTabPage, QuoteHdl, weld::Button&, rBtn, void) SvxCharacterMap aMap(GetFrameWeld(), nullptr, nullptr); aMap.SetCharFont( OutputDevice::GetDefaultFont(DefaultFontType::LATIN_TEXT, LANGUAGE_ENGLISH_US, GetDefaultFontFlags::OnlyOne )); - aMap.set_title(nMode < SGL_END ? CuiResId(RID_SVXSTR_STARTQUOTE) : CuiResId(RID_SVXSTR_ENDQUOTE)); + aMap.set_title(nMode < SGL_END ? CuiResId(RID_CUISTR_STARTQUOTE) : CuiResId(RID_CUISTR_ENDQUOTE)); sal_UCS4 cDlg; SvxAutoCorrect* pAutoCorrect = SvxAutoCorrCfg::Get().GetAutoCorrect(); LanguageType eLang = Application::GetSettings().GetLanguageTag().getLanguageType(); @@ -1968,7 +1988,6 @@ bool OfaAutoCompleteTabPage::FillItemSet( SfxItemSet* ) bool bModified = false, bCheck; SvxAutoCorrect* pAutoCorrect = SvxAutoCorrCfg::Get().GetAutoCorrect(); SvxSwAutoFormatFlags *pOpt = &pAutoCorrect->GetSwFlags(); - sal_uInt16 nVal; bCheck = m_xCBActiv->get_active(); bModified |= pOpt->bAutoCompleteWords != bCheck; @@ -1986,13 +2005,13 @@ bool OfaAutoCompleteTabPage::FillItemSet( SfxItemSet* ) bModified |= pOpt->bAutoCmpltShowAsTip != bCheck; pOpt->bAutoCmpltShowAsTip = bCheck; - nVal = static_cast<sal_uInt16>(m_xNFMinWordlen->get_value()); + sal_uInt16 nVal = static_cast<sal_uInt16>(m_xNFMinWordlen->get_value()); bModified |= nVal != pOpt->nAutoCmpltWordLen; pOpt->nAutoCmpltWordLen = nVal; - nVal = static_cast<sal_uInt16>(m_xNFMaxEntries->get_value()); - bModified |= nVal != pOpt->nAutoCmpltListLen; - pOpt->nAutoCmpltListLen = nVal; + sal_uInt32 nList = static_cast<sal_uInt32>(m_xNFMaxEntries->get_value()); + bModified |= nList != pOpt->nAutoCmpltListLen; + pOpt->nAutoCmpltListLen = nList; const int nPos = m_xDCBExpandKey->get_active(); if (nPos != -1) @@ -2053,7 +2072,7 @@ void OfaAutoCompleteTabPage::Reset( const SfxItemSet* ) { const OUString* pStr = &(*m_pAutoCompleteList)[n]->GetAutoCompleteString(); - OUString sId(OUString::number(reinterpret_cast<sal_Int64>(pStr))); + OUString sId(weld::toId(pStr)); m_xLBEntries->append(sId, *pStr); } } @@ -2079,7 +2098,7 @@ IMPL_LINK_NOARG(OfaAutoCompleteTabPage, DeleteHdl, weld::Button&, void) while (!rows.empty()) { sal_Int32 nPos = rows.back(); - OUString* pStr = reinterpret_cast<OUString*>(m_xLBEntries->get_id(nPos).toInt64()); + OUString* pStr = weld::fromId<OUString*>(m_xLBEntries->get_id(nPos)); m_xLBEntries->remove(nPos); editeng::IAutoCompleteString hack(*pStr); // UGLY m_pAutoCompleteList->erase(&hack); @@ -2115,12 +2134,7 @@ void OfaAutoCompleteTabPage::CopyToClipboard() const for (auto a : rows) { - sData.append(OUStringToOString(m_xLBEntries->get_text(a), nEncode)); -#if defined(_WIN32) - sData.append("\015\012"); -#else - sData.append("\012"); -#endif + sData.append(OUStringToOString(m_xLBEntries->get_text(a), nEncode) + SAL_NEWLINE_STRING); } pCntnr->CopyByteString( SotClipboardFormatId::STRING, sData.makeStringAndClear() ); pCntnr->CopyToClipboard(m_xLBEntries->get_clipboard()); @@ -2186,11 +2200,11 @@ struct ImplSmartTagLBUserData uno::Reference< smarttags::XSmartTagRecognizer > mxRec; sal_Int32 mnSmartTagIdx; - ImplSmartTagLBUserData( const OUString& rSmartTagType, - uno::Reference< smarttags::XSmartTagRecognizer > const & xRec, + ImplSmartTagLBUserData( OUString aSmartTagType, + uno::Reference< smarttags::XSmartTagRecognizer > xRec, sal_Int32 nSmartTagIdx ) : - maSmartTagType( rSmartTagType ), - mxRec( xRec ), + maSmartTagType(std::move( aSmartTagType )), + mxRec(std::move( xRec )), mnSmartTagIdx( nSmartTagIdx ) {} }; @@ -2203,7 +2217,7 @@ void OfaSmartTagOptionsTabPage::ClearListBox() const int nCount = m_xSmartTagTypesLB->n_children(); for (int i = 0; i < nCount; ++i) { - const ImplSmartTagLBUserData* pUserData = reinterpret_cast<ImplSmartTagLBUserData*>(m_xSmartTagTypesLB->get_id(i).toInt64()); + const ImplSmartTagLBUserData* pUserData = weld::fromId<ImplSmartTagLBUserData*>(m_xSmartTagTypesLB->get_id(i)); delete pUserData; } @@ -2243,7 +2257,7 @@ void OfaSmartTagOptionsTabPage::FillListBox( const SmartTagMgr& rSmartTagMgr ) const bool bCheck = rSmartTagMgr.IsSmartTagTypeEnabled( aSmartTagType ); m_xSmartTagTypesLB->set_toggle(nRow, bCheck ? TRISTATE_TRUE : TRISTATE_FALSE); m_xSmartTagTypesLB->set_text(nRow, aLBEntry, 0); - m_xSmartTagTypesLB->set_id(nRow, OUString::number(reinterpret_cast<sal_Int64>(new ImplSmartTagLBUserData(aSmartTagType, xRec, j)))); + m_xSmartTagTypesLB->set_id(nRow, weld::toId(new ImplSmartTagLBUserData(aSmartTagType, xRec, j))); } } } @@ -2253,7 +2267,7 @@ void OfaSmartTagOptionsTabPage::FillListBox( const SmartTagMgr& rSmartTagMgr ) IMPL_LINK_NOARG(OfaSmartTagOptionsTabPage, ClickHdl, weld::Button&, void) { const int nPos = m_xSmartTagTypesLB->get_selected_index(); - const ImplSmartTagLBUserData* pUserData = reinterpret_cast<ImplSmartTagLBUserData*>(m_xSmartTagTypesLB->get_id(nPos).toInt64()); + const ImplSmartTagLBUserData* pUserData = weld::fromId<ImplSmartTagLBUserData*>(m_xSmartTagTypesLB->get_id(nPos)); uno::Reference< smarttags::XSmartTagRecognizer > xRec = pUserData->mxRec; const sal_Int32 nSmartTagIdx = pUserData->mnSmartTagIdx; @@ -2285,7 +2299,7 @@ IMPL_LINK_NOARG(OfaSmartTagOptionsTabPage, SelectHdl, weld::TreeView&, void) const int nPos = m_xSmartTagTypesLB->get_selected_index(); if (nPos == -1) return; - const ImplSmartTagLBUserData* pUserData = reinterpret_cast<ImplSmartTagLBUserData*>(m_xSmartTagTypesLB->get_id(nPos).toInt64()); + const ImplSmartTagLBUserData* pUserData = weld::fromId<ImplSmartTagLBUserData*>(m_xSmartTagTypesLB->get_id(nPos)); uno::Reference< smarttags::XSmartTagRecognizer > xRec = pUserData->mxRec; const sal_Int32 nSmartTagIdx = pUserData->mnSmartTagIdx; @@ -2315,7 +2329,7 @@ bool OfaSmartTagOptionsTabPage::FillItemSet( SfxItemSet* ) for (int i = 0; i < nCount; ++i) { - const ImplSmartTagLBUserData* pUserData = reinterpret_cast<ImplSmartTagLBUserData*>(m_xSmartTagTypesLB->get_id(i).toInt64()); + const ImplSmartTagLBUserData* pUserData = weld::fromId<ImplSmartTagLBUserData*>(m_xSmartTagTypesLB->get_id(i)); const bool bChecked = m_xSmartTagTypesLB->get_toggle(i) == TRISTATE_TRUE; const bool bIsCurrentlyEnabled = pSmartTagMgr->IsSmartTagTypeEnabled( pUserData->maSmartTagType ); diff --git a/cui/source/tabpages/backgrnd.cxx b/cui/source/tabpages/backgrnd.cxx index 7b06e9a86092..b10c6f79c304 100644 --- a/cui/source/tabpages/backgrnd.cxx +++ b/cui/source/tabpages/backgrnd.cxx @@ -36,7 +36,7 @@ using namespace css; #define TBL_DEST_ROW 1 #define TBL_DEST_TBL 2 -const WhichRangesContainer SvxBkgTabPage::pPageRanges(svl::Items< +const WhichRangesContainer SvxBkgTabPage::pBkgRanges(svl::Items< SID_ATTR_BRUSH, SID_ATTR_BRUSH, SID_ATTR_BRUSH_CHAR, SID_ATTR_BRUSH_CHAR >); @@ -63,32 +63,13 @@ static sal_uInt16 lcl_GetTableDestSlot(sal_Int32 nTblDest) SvxBkgTabPage::SvxBkgTabPage(weld::Container* pPage, weld::DialogController* pController, const SfxItemSet& rInAttrs) : SvxAreaTabPage(pPage, pController, rInAttrs), - bHighlighting(false), - bCharBackColor(false), - maSet(rInAttrs) + m_aAttrSet(*rInAttrs.GetPool(), + rInAttrs.GetRanges().MergeRange(XATTR_FILL_FIRST, XATTR_FILL_LAST)) { m_xBtnGradient->hide(); m_xBtnHatch->hide(); m_xBtnBitmap->hide(); m_xBtnPattern->hide(); - - SfxObjectShell* pDocSh = SfxObjectShell::Current(); - - XColorListRef pColorTable; - if ( pDocSh ) - if (auto pItem = pDocSh->GetItem( SID_COLOR_TABLE )) - pColorTable = pItem->GetColorList(); - - if ( !pColorTable.is() ) - pColorTable = XColorList::CreateStdColorList(); - - XBitmapListRef pBitmapList; - if ( pDocSh ) - if (auto pItem = pDocSh->GetItem( SID_BITMAP_LIST ) ) - pBitmapList = pItem->GetBitmapList(); - - SetColorList(pColorTable); - SetBitmapList(pBitmapList); } SvxBkgTabPage::~SvxBkgTabPage() @@ -98,12 +79,12 @@ SvxBkgTabPage::~SvxBkgTabPage() void SvxBkgTabPage::ActivatePage( const SfxItemSet& ) { - SvxAreaTabPage::ActivatePage( maSet ); + SvxAreaTabPage::ActivatePage(m_aAttrSet); } DeactivateRC SvxBkgTabPage::DeactivatePage( SfxItemSet* _pSet ) { - if ( DeactivateRC::KeepPage == SvxAreaTabPage::DeactivatePage( &maSet ) ) + if (DeactivateRC::KeepPage == SvxAreaTabPage::DeactivatePage(&m_aAttrSet)) return DeactivateRC::KeepPage; if ( _pSet ) @@ -112,37 +93,49 @@ DeactivateRC SvxBkgTabPage::DeactivatePage( SfxItemSet* _pSet ) return DeactivateRC::LeavePage; } -void SvxBkgTabPage::Reset( const SfxItemSet* ) +void SvxBkgTabPage::Reset(const SfxItemSet* pItemSet) { - maSet.Set( *m_pResetSet ); - if ( m_xTblLBox && m_xTblLBox->get_visible() ) + if (m_xTblLBox && m_xTblLBox->get_visible()) { - m_nActPos = -1; - const SfxPoolItem* pItem; - if ( SfxItemState::SET == m_pResetSet->GetItemState( SID_BACKGRND_DESTINATION, false, &pItem ) ) + if (m_nActPos == -1) // initial reset { - sal_uInt16 nDestValue = static_cast<const SfxUInt16Item*>(pItem)->GetValue(); - m_xTblLBox->set_active( nDestValue ); - TblDestinationHdl_Impl( *m_xTblLBox ); + m_nActPos = 0; + if (const SfxUInt16Item* pDestItem = pItemSet->GetItemIfSet(SID_BACKGRND_DESTINATION, false)) + m_nActPos = pDestItem->GetValue(); + m_xTblLBox->set_active(m_nActPos); } - m_xTblLBox->save_value(); + SetActiveTableDestinationBrushItem(); + return; + } + else if (m_bCharBackColor) + { + sal_uInt16 nWhich(pItemSet->GetPool()->GetWhichIDFromSlotID(SID_ATTR_CHAR_BACK_COLOR)); + Color aBackColor(static_cast<const SvxColorItem&>(pItemSet->Get(nWhich)).GetValue()); + SvxBrushItem aBrushItem(SvxBrushItem(aBackColor, SID_ATTR_BRUSH_CHAR)); + setSvxBrushItemAsFillAttributesToTargetSet(aBrushItem, m_aAttrSet); + } + else + { + sal_uInt16 nWhich(pItemSet->GetPool()->GetWhichIDFromSlotID(m_bHighlighting ? SID_ATTR_BRUSH_CHAR : SID_ATTR_BRUSH)); + SvxBrushItem aBrushItem(static_cast<const SvxBrushItem&>(pItemSet->Get(nWhich))); + setSvxBrushItemAsFillAttributesToTargetSet(aBrushItem, m_aAttrSet); } - SvxAreaTabPage::Reset( &maSet ); + SvxAreaTabPage::Reset(&m_aAttrSet); } -bool SvxBkgTabPage::FillItemSet( SfxItemSet* rCoreSet ) +bool SvxBkgTabPage::FillItemSet(SfxItemSet* pCoreSet) { sal_uInt16 nSlot = SID_ATTR_BRUSH; if (m_xTblLBox && m_xTblLBox->get_visible()) nSlot = lcl_GetTableDestSlot(m_xTblLBox->get_active()); - else if ( bHighlighting ) + else if (m_bHighlighting) nSlot = SID_ATTR_BRUSH_CHAR; - else if( bCharBackColor ) + else if (m_bCharBackColor) nSlot = SID_ATTR_CHAR_BACK_COLOR; sal_uInt16 nWhich = GetWhich(nSlot); - drawing::FillStyle eFillType = maSet.Get( XATTR_FILLSTYLE ).GetValue(); + drawing::FillStyle eFillType = m_aAttrSet.Get(XATTR_FILLSTYLE).GetValue(); switch( eFillType ) { case drawing::FillStyle_NONE: @@ -151,76 +144,77 @@ bool SvxBkgTabPage::FillItemSet( SfxItemSet* rCoreSet ) { if ( SID_ATTR_CHAR_BACK_COLOR == nSlot ) { - maSet.Put( SvxColorItem( COL_TRANSPARENT, nWhich ) ); - rCoreSet->Put( SvxColorItem( COL_TRANSPARENT, nWhich ) ); + pCoreSet->Put(SvxColorItem(COL_TRANSPARENT, nWhich)); } else { - maSet.Put( SvxBrushItem( COL_TRANSPARENT, nWhich ) ); - rCoreSet->Put( SvxBrushItem( COL_TRANSPARENT, nWhich ) ); + pCoreSet->Put(SvxBrushItem(COL_TRANSPARENT, nWhich)); } } break; } case drawing::FillStyle_SOLID: { - XFillColorItem aColorItem( maSet.Get( XATTR_FILLCOLOR ) ); + XFillColorItem aColorItem(m_aAttrSet.Get(XATTR_FILLCOLOR)); + + // tdf#157801 - don't change direct formatting when color is unchanged + if (const SfxPoolItem* pOldItem = GetOldItem(*pCoreSet, nSlot)) + { + const SvxBrushItem* pOldBrushItem = static_cast<const SvxBrushItem*>(pOldItem); + if (pOldBrushItem->GetColor() == aColorItem.GetColorValue()) + break; + } + if ( SID_ATTR_CHAR_BACK_COLOR == nSlot ) { - maSet.Put( SvxColorItem( aColorItem.GetColorValue(), nWhich ) ); - rCoreSet->Put( SvxColorItem( aColorItem.GetColorValue(), nWhich ) ); + pCoreSet->Put(SvxColorItem(aColorItem.GetColorValue(), aColorItem.getComplexColor(), nWhich)); } else { - maSet.Put( SvxBrushItem( aColorItem.GetColorValue(), nWhich ) ); - rCoreSet->Put( SvxBrushItem( aColorItem.GetColorValue(), nWhich ) ); + pCoreSet->Put(SvxBrushItem(aColorItem.GetColorValue(), aColorItem.getComplexColor(), nWhich)); } break; } case drawing::FillStyle_BITMAP: { - std::unique_ptr<SvxBrushItem> aBrushItem( getSvxBrushItemFromSourceSet( maSet, nWhich ) ); + std::unique_ptr<SvxBrushItem> aBrushItem(getSvxBrushItemFromSourceSet(m_aAttrSet, nWhich)); if ( GraphicType::NONE != aBrushItem->GetGraphicObject()->GetType() ) - rCoreSet->Put( *aBrushItem ); + pCoreSet->Put(std::move(aBrushItem)); break; } default: break; } - if (m_xTblLBox && m_xTblLBox->get_visible()) + if (!m_xTblLBox || !m_xTblLBox->get_visible()) + return true; + + pCoreSet->Put(SfxUInt16Item(SID_BACKGRND_DESTINATION, m_xTblLBox->get_active())); + + // *Put* in the core set all table brushes that are *SET* in the m_aAttrSet + if (nSlot != SID_ATTR_BRUSH) { - if (nSlot != SID_ATTR_BRUSH) + nWhich = m_aAttrSet.GetPool()->GetWhichIDFromSlotID(SID_ATTR_BRUSH); + if (SfxItemState::SET == m_aAttrSet.GetItemState(nWhich)) { - nWhich = maSet.GetPool()->GetWhich(SID_ATTR_BRUSH); - if (SfxItemState::SET == maSet.GetItemState(nWhich)) - { - SvxBrushItem aBrushItem(static_cast<const SvxBrushItem&>(maSet.Get(nWhich))); - rCoreSet->Put(aBrushItem); - } + SvxBrushItem aBrushItem(static_cast<const SvxBrushItem&>(m_aAttrSet.Get(nWhich))); + pCoreSet->Put(aBrushItem); } - if (nSlot != SID_ATTR_BRUSH_ROW) - { - nWhich = maSet.GetPool()->GetWhich(SID_ATTR_BRUSH_ROW); - if (SfxItemState::SET == maSet.GetItemState(nWhich)) - { - SvxBrushItem aBrushItem(static_cast<const SvxBrushItem&>(maSet.Get(nWhich))); - rCoreSet->Put(aBrushItem); - } - } - if (nSlot != SID_ATTR_BRUSH_TABLE) + } + if (nSlot != SID_ATTR_BRUSH_ROW) + { + if (SfxItemState::SET == m_aAttrSet.GetItemState(SID_ATTR_BRUSH_ROW)) { - nWhich = maSet.GetPool()->GetWhich(SID_ATTR_BRUSH_TABLE); - if (SfxItemState::SET == maSet.GetItemState(nWhich)) - { - SvxBrushItem aBrushItem(static_cast<const SvxBrushItem&>(maSet.Get(nWhich))); - rCoreSet->Put(aBrushItem); - } + SvxBrushItem aBrushItem(m_aAttrSet.Get(SID_ATTR_BRUSH_ROW)); + pCoreSet->Put(aBrushItem); } - - if (m_xTblLBox->get_value_changed_from_saved()) + } + if (nSlot != SID_ATTR_BRUSH_TABLE) + { + if (SfxItemState::SET == m_aAttrSet.GetItemState(SID_ATTR_BRUSH_TABLE)) { - rCoreSet->Put(SfxUInt16Item(SID_BACKGRND_DESTINATION, m_xTblLBox->get_active())); + SvxBrushItem aBrushItem(m_aAttrSet.Get(SID_ATTR_BRUSH_TABLE)); + pCoreSet->Put(aBrushItem); } } @@ -250,89 +244,90 @@ void SvxBkgTabPage::PageCreated(const SfxAllItemSet& aSet) if ((nFlags & SvxBackgroundTabFlags::SHOW_HIGHLIGHTING) || (nFlags & SvxBackgroundTabFlags::SHOW_CHAR_BKGCOLOR)) { - bHighlighting = bool(nFlags & SvxBackgroundTabFlags::SHOW_HIGHLIGHTING); - bCharBackColor = bool(nFlags & SvxBackgroundTabFlags::SHOW_CHAR_BKGCOLOR); + m_bHighlighting = bool(nFlags & SvxBackgroundTabFlags::SHOW_HIGHLIGHTING); + m_bCharBackColor = bool(nFlags & SvxBackgroundTabFlags::SHOW_CHAR_BKGCOLOR); } if (nFlags & SvxBackgroundTabFlags::SHOW_SELECTOR) m_xBtnBitmap->show(); SetOptimalSize(GetDialogController()); } - if ( bCharBackColor ) + SfxObjectShell* pObjSh = SfxObjectShell::Current(); + + // we always have the color page + XColorListRef xColorTable; + if (pObjSh) { - sal_uInt16 nWhich(maSet.GetPool()->GetWhich(SID_ATTR_CHAR_BACK_COLOR)); - Color aBackColor(static_cast<const SvxColorItem&>(maSet.Get(nWhich)).GetValue()); - SvxBrushItem aBrushItem(SvxBrushItem(aBackColor, SID_ATTR_BRUSH_CHAR)); - setSvxBrushItemAsFillAttributesToTargetSet(aBrushItem, maSet); + const SvxColorListItem* pItem = pObjSh->GetItem(SID_COLOR_TABLE); + if (pItem) + xColorTable = pItem->GetColorList(); } - else + if (!xColorTable.is()) + xColorTable = XColorList::CreateStdColorList(); + SetColorList(xColorTable); + + // sometimes we have the bitmap page + if (m_xBtnBitmap->get_visible()) { - sal_uInt16 nWhich(maSet.GetPool()->GetWhich(bHighlighting ? SID_ATTR_BRUSH_CHAR : SID_ATTR_BRUSH)); - SvxBrushItem aBrushItem(static_cast<const SvxBrushItem&>(maSet.Get(nWhich))); - setSvxBrushItemAsFillAttributesToTargetSet(aBrushItem, maSet); + XBitmapListRef xBitmapList; + if (pObjSh) + if (const SvxBitmapListItem* pItem = pObjSh->GetItem(SID_BITMAP_LIST)) + xBitmapList = pItem->GetBitmapList(); + SetBitmapList(xBitmapList); } - - m_pResetSet = maSet.Clone(); - - SvxAreaTabPage::PageCreated(aSet); } IMPL_LINK(SvxBkgTabPage, TblDestinationHdl_Impl, weld::ComboBox&, rBox, void) { - if (m_nActPos > -1) - { - // fill local item set with XATTR_FILL settings gathered from tab page - // and convert to SvxBrushItem and store in table destination slot Which - SvxAreaTabPage::FillItemSet(&maSet); - maSet.Put(*getSvxBrushItemFromSourceSet(maSet, maSet.GetPool()->GetWhich(lcl_GetTableDestSlot(m_nActPos)))); - } - sal_Int32 nSelPos = rBox.get_active(); + if (m_nActPos == nSelPos) return; + // Fill the local item set with XATTR_FILL settings gathered from the tab page, convert to + // SvxBrushItem and store in table destination slot Which. Do this so cell, row, and table + // brush items can be set together. + SvxAreaTabPage::FillItemSet(&m_aAttrSet); + m_aAttrSet.Put(getSvxBrushItemFromSourceSet(m_aAttrSet, GetWhich(lcl_GetTableDestSlot(m_nActPos)))); + m_nActPos = nSelPos; - // fill local item set with XATTR_FILL created from SvxBushItem for table destination slot Which - sal_uInt16 nWhich = maSet.GetPool()->GetWhich(lcl_GetTableDestSlot(nSelPos)); - if (SfxItemState::SET == maSet.GetItemState(nWhich)) + SetActiveTableDestinationBrushItem(); +} + +void SvxBkgTabPage::SetActiveTableDestinationBrushItem() +{ + // set the table destination (cell, row, table) brush item as a fill item in the local item set + sal_uInt16 nWhich = GetWhich(lcl_GetTableDestSlot(m_nActPos)); + if (SfxItemState::SET == GetItemSet().GetItemState(nWhich)) { - SvxBrushItem aBrushItem(static_cast<const SvxBrushItem&>(maSet.Get(nWhich))); - setSvxBrushItemAsFillAttributesToTargetSet(aBrushItem, maSet); + SvxBrushItem aBrushItem(static_cast<const SvxBrushItem&>(GetItemSet().Get(nWhich))); + setSvxBrushItemAsFillAttributesToTargetSet(aBrushItem, m_aAttrSet); } else { - SelectFillType(*m_xBtnNone, &maSet); + SelectFillType(*m_xBtnNone, &m_aAttrSet); return; } - // show tab page - drawing::FillStyle eXFS = drawing::FillStyle_NONE; - if (maSet.GetItemState(XATTR_FILLSTYLE) != SfxItemState::DONTCARE) - { - XFillStyleItem aFillStyleItem(static_cast<const XFillStyleItem&>(maSet.Get(GetWhich( XATTR_FILLSTYLE)))); - eXFS = aFillStyleItem.GetValue(); - } + XFillStyleItem aFillStyleItem(m_aAttrSet.Get(m_aAttrSet.GetPool()->GetWhichIDFromSlotID(XATTR_FILLSTYLE))); + drawing::FillStyle eXFS = aFillStyleItem.GetValue(); switch(eXFS) { default: case drawing::FillStyle_NONE: { - SelectFillType(*m_xBtnNone, &maSet); + SelectFillType(*m_xBtnNone, &m_aAttrSet); break; } case drawing::FillStyle_SOLID: { - SelectFillType(*m_xBtnColor, &maSet); - // color tab page Active and New preview controls are same after SelectFillType - // hack to restore color tab page Active preview - setSvxBrushItemAsFillAttributesToTargetSet(static_cast<const SvxBrushItem&>(m_pResetSet->Get(nWhich)), *m_pResetSet); - static_cast<SvxColorTabPage*>(GetFillTabPage())->SetCtlPreviewOld(*m_pResetSet); + SelectFillType(*m_xBtnColor, &m_aAttrSet); break; } case drawing::FillStyle_BITMAP: { - SelectFillType(*m_xBtnBitmap, &maSet); + SelectFillType(*m_xBtnBitmap, &m_aAttrSet); break; } } diff --git a/cui/source/tabpages/bbdlg.cxx b/cui/source/tabpages/bbdlg.cxx index 488fc5283a6b..9fc59604476e 100644 --- a/cui/source/tabpages/bbdlg.cxx +++ b/cui/source/tabpages/bbdlg.cxx @@ -33,8 +33,8 @@ SvxBorderBackgroundDlg::SvxBorderBackgroundDlg(weld::Window *pParent, ? OUString("cui/ui/borderareatransparencydialog.ui") : OUString("cui/ui/borderbackgrounddialog.ui"), bEnableDrawingLayerFillStyles - ? OString("BorderAreaTransparencyDialog") - : OString("BorderBackgroundDialog"), + ? OUString("BorderAreaTransparencyDialog") + : OUString("BorderBackgroundDialog"), &rCoreSet) , mbEnableBackgroundSelector(bEnableSelector) { @@ -51,7 +51,7 @@ SvxBorderBackgroundDlg::SvxBorderBackgroundDlg(weld::Window *pParent, } } -void SvxBorderBackgroundDlg::PageCreated(const OString& rPageId, SfxTabPage& rTabPage) +void SvxBorderBackgroundDlg::PageCreated(const OUString& rPageId, SfxTabPage& rTabPage) { if (rPageId == "background") { diff --git a/cui/source/tabpages/border.cxx b/cui/source/tabpages/border.cxx index 64558279be60..ccb94fe46854 100644 --- a/cui/source/tabpages/border.cxx +++ b/cui/source/tabpages/border.cxx @@ -19,8 +19,6 @@ #include <sal/config.h> -#include <string_view> - #include <sfx2/objsh.hxx> #include <svx/strings.hrc> #include <svx/svxids.hrc> @@ -37,6 +35,7 @@ #include <vcl/fieldvalues.hxx> #include <vcl/settings.hxx> #include <vcl/svapp.hxx> +#include <svx/dialmgr.hxx> #include <svx/flagsdef.hxx> #include <svl/grabbagitem.hxx> #include <svl/intitem.hxx> @@ -79,22 +78,19 @@ const WhichRangesContainer SvxBorderTabPage::pRanges( namespace { -int lcl_twipsToPt(sal_Int64 nTwips) +constexpr int twipsToPt100(sal_Int64 nTwips) { - return vcl::ConvertDoubleValue(nTwips, 0, FieldUnit::TWIP, MapUnit::MapPoint) * 100; + return o3tl::convert(nTwips * 100, o3tl::Length::twip, o3tl::Length::pt); } +constexpr int s_LineWidths[] = { twipsToPt100(SvxBorderLineWidth::Hairline), + twipsToPt100(SvxBorderLineWidth::VeryThin), + twipsToPt100(SvxBorderLineWidth::Thin), + twipsToPt100(SvxBorderLineWidth::Medium), + twipsToPt100(SvxBorderLineWidth::Thick), + twipsToPt100(SvxBorderLineWidth::ExtraThick), + -1 }; } -const std::vector<int> SvxBorderTabPage::m_aLineWidths = { - lcl_twipsToPt(SvxBorderLineWidth::Hairline), - lcl_twipsToPt(SvxBorderLineWidth::VeryThin), - lcl_twipsToPt(SvxBorderLineWidth::Thin), - lcl_twipsToPt(SvxBorderLineWidth::Medium), - lcl_twipsToPt(SvxBorderLineWidth::Thick), - lcl_twipsToPt(SvxBorderLineWidth::ExtraThick), - -1 -}; - static void lcl_SetDecimalDigitsTo1(weld::MetricSpinButton& rField) { auto nMin = rField.denormalize(rField.get_min(FieldUnit::TWIP)); @@ -140,10 +136,10 @@ static sal_Int64 lcl_GetMinLineWidth(SvxBorderLineStyle aStyle) } // number of preset images to show -const sal_uInt16 SVX_BORDER_PRESET_COUNT = 5; +const sal_uInt16 BORDER_PRESET_COUNT = 5; // number of shadow images to show -const sal_uInt16 SVX_BORDER_SHADOW_COUNT = 5; +const sal_uInt16 BORDER_SHADOW_COUNT = 5; ShadowControlsWrapper::ShadowControlsWrapper(ValueSet& rVsPos, weld::MetricSpinButton& rMfSize, ColorListBox& rLbColor) : mrVsPos(rVsPos) @@ -412,7 +408,7 @@ SvxBorderTabPage::SvxBorderTabPage(weld::Container* pPage, weld::DialogControlle for (auto const & rImageId : aShadowImageIds) m_aShadowImgVec.emplace_back(StockImage::Yes, rImageId); - assert(m_aShadowImgVec.size() == SVX_BORDER_SHADOW_COUNT); + assert(m_aShadowImgVec.size() == BORDER_SHADOW_COUNT); // this page needs ExchangeSupport SetExchangeSupport(); @@ -422,19 +418,16 @@ SvxBorderTabPage::SvxBorderTabPage(weld::Container* pPage, weld::DialogControlle is needed across various functions... */ mbUseMarginItem = rCoreAttrs.GetItemState(GetWhich(SID_ATTR_ALIGN_MARGIN)) != SfxItemState::UNKNOWN; - const SfxPoolItem* pItem = nullptr; - if (rCoreAttrs.HasItem(SID_ATTR_BORDER_STYLES, &pItem)) + if (const SfxIntegerListItem* p = rCoreAttrs.GetItemIfSet(SID_ATTR_BORDER_STYLES)) { - const SfxIntegerListItem* p = static_cast<const SfxIntegerListItem*>(pItem); std::vector<sal_Int32> aUsedStyles = p->GetList(); for (int aUsedStyle : aUsedStyles) maUsedBorderStyles.insert(static_cast<SvxBorderLineStyle>(aUsedStyle)); } - if (rCoreAttrs.HasItem(SID_ATTR_BORDER_DEFAULT_WIDTH, &pItem)) + if (const SfxInt64Item* p = rCoreAttrs.GetItemIfSet(SID_ATTR_BORDER_DEFAULT_WIDTH)) { // The caller specifies default line width. Honor it. - const SfxInt64Item* p = static_cast<const SfxInt64Item*>(pItem); SetLineWidth(p->GetValue()); } @@ -547,6 +540,7 @@ SvxBorderTabPage::SvxBorderTabPage(weld::Container* pPage, weld::DialogControlle SetLineWidth(m_xLineWidthMF->get_value(FieldUnit::NONE)); // connections + const SfxPoolItem* pItem = nullptr; if (rCoreAttrs.HasItem(GetWhich(SID_ATTR_PARA_GRABBAG), &pItem)) { const SfxGrabBagItem* pGrabBag = static_cast<const SfxGrabBagItem*>(pItem); @@ -577,8 +571,7 @@ SvxBorderTabPage::SvxBorderTabPage(weld::Container* pPage, weld::DialogControlle // checkbox "Merge adjacent line styles" only visible for Writer dialog format.table m_xMergeAdjacentBordersCB->hide(); - SfxObjectShell* pDocSh = SfxObjectShell::Current(); - if (pDocSh) + if (SfxObjectShell* pDocSh = SfxObjectShell::Current()) { Reference< XServiceInfo > xSI( pDocSh->GetModel(), UNO_QUERY ); if ( xSI.is() ) @@ -641,7 +634,7 @@ void SvxBorderTabPage::Reset( const SfxItemSet* rSet ) if (m_aFrameSel.IsBorderEnabled(svx::FrameBorderType::TLBR)) { - sal_uInt16 nBorderDiagId = pPool->GetWhich(SID_ATTR_BORDER_DIAG_TLBR); + sal_uInt16 nBorderDiagId = pPool->GetWhichIDFromSlotID(SID_ATTR_BORDER_DIAG_TLBR); if (const SvxLineItem* pLineItem = static_cast<const SvxLineItem*>(rSet->GetItem(nBorderDiagId))) m_aFrameSel.ShowBorder(svx::FrameBorderType::TLBR, pLineItem->GetLine()); else @@ -650,7 +643,7 @@ void SvxBorderTabPage::Reset( const SfxItemSet* rSet ) if (m_aFrameSel.IsBorderEnabled(svx::FrameBorderType::BLTR)) { - sal_uInt16 nBorderDiagId = pPool->GetWhich(SID_ATTR_BORDER_DIAG_BLTR); + sal_uInt16 nBorderDiagId = pPool->GetWhichIDFromSlotID(SID_ATTR_BORDER_DIAG_BLTR); if (const SvxLineItem* pLineItem = static_cast<const SvxLineItem*>(rSet->GetItem(nBorderDiagId))) m_aFrameSel.ShowBorder(svx::FrameBorderType::BLTR, pLineItem->GetLine()); else @@ -659,7 +652,7 @@ void SvxBorderTabPage::Reset( const SfxItemSet* rSet ) if (m_xShadowControls) { - sal_uInt16 nShadowId = pPool->GetWhich(mnShadowSlot); + sal_uInt16 nShadowId = pPool->GetWhichIDFromSlotID(mnShadowSlot); const SfxPoolItem* pItem = rSet->GetItem(nShadowId); if (pItem) m_xShadowControls->SetControlValue(*static_cast<const SvxShadowItem*>(pItem)); @@ -669,7 +662,7 @@ void SvxBorderTabPage::Reset( const SfxItemSet* rSet ) if (m_xMarginControls) { - sal_uInt16 nAlignMarginId = pPool->GetWhich(SID_ATTR_ALIGN_MARGIN); + sal_uInt16 nAlignMarginId = pPool->GetWhichIDFromSlotID(SID_ATTR_ALIGN_MARGIN); const SfxPoolItem* pItem = rSet->GetItem(nAlignMarginId); if (pItem) m_xMarginControls->SetControlValue(*static_cast<const SvxMarginItem*>(pItem)); @@ -677,7 +670,7 @@ void SvxBorderTabPage::Reset( const SfxItemSet* rSet ) m_xMarginControls->SetControlDontKnow(); } - sal_uInt16 nMergeAdjacentBordersId = pPool->GetWhich(SID_SW_COLLAPSING_BORDERS); + sal_uInt16 nMergeAdjacentBordersId = pPool->GetWhichIDFromSlotID(SID_SW_COLLAPSING_BORDERS); const SfxBoolItem *pMergeAdjacentBorders = static_cast<const SfxBoolItem*>(rSet->GetItem(nMergeAdjacentBordersId)); if (!pMergeAdjacentBorders) m_xMergeAdjacentBordersCB->set_state(TRISTATE_INDET); @@ -685,7 +678,7 @@ void SvxBorderTabPage::Reset( const SfxItemSet* rSet ) m_xMergeAdjacentBordersCB->set_active(pMergeAdjacentBorders->GetValue()); m_xMergeAdjacentBordersCB->save_state(); - sal_uInt16 nMergeWithNextId = pPool->GetWhich(SID_ATTR_BORDER_CONNECT); + sal_uInt16 nMergeWithNextId = pPool->GetWhichIDFromSlotID(SID_ATTR_BORDER_CONNECT); const SfxBoolItem *pMergeWithNext = static_cast<const SfxBoolItem*>(rSet->GetItem(nMergeWithNextId)); if (!pMergeWithNext) m_xMergeWithNextCB->set_state(TRISTATE_INDET); @@ -846,13 +839,15 @@ void SvxBorderTabPage::Reset( const SfxItemSet* rSet ) SelStyleHdl_Impl(*m_xLbLineStyle); } - const SfxPoolItem* pItem; - SfxObjectShell* pShell; - if(SfxItemState::SET == rSet->GetItemState(SID_HTML_MODE, false, &pItem) || - ( nullptr != (pShell = SfxObjectShell::Current()) && - nullptr != (pItem = pShell->GetItem(SID_HTML_MODE)))) + const SfxUInt16Item* pHtmlModeItem = rSet->GetItemIfSet(SID_HTML_MODE, false); + if(!pHtmlModeItem) + { + if (SfxObjectShell* pShell = SfxObjectShell::Current()) + pHtmlModeItem = pShell->GetItem(SID_HTML_MODE); + } + if(pHtmlModeItem) { - sal_uInt16 nHtmlMode = static_cast<const SfxUInt16Item*>(pItem)->GetValue(); + sal_uInt16 nHtmlMode = pHtmlModeItem->GetValue(); if(nHtmlMode & HTMLMODE_ON) { // there are no shadows in Html-mode and only complete borders @@ -958,7 +953,7 @@ bool SvxBorderTabPage::FillItemSet( SfxItemSet* rCoreAttrs ) auto nState = m_xMergeAdjacentBordersCB->get_state(); if (nState == TRISTATE_INDET) { - sal_uInt16 nMergeAdjacentBordersId = pPool->GetWhich(SID_SW_COLLAPSING_BORDERS); + sal_uInt16 nMergeAdjacentBordersId = pPool->GetWhichIDFromSlotID(SID_SW_COLLAPSING_BORDERS); rCoreAttrs->ClearItem(nMergeAdjacentBordersId); } else @@ -978,7 +973,7 @@ bool SvxBorderTabPage::FillItemSet( SfxItemSet* rCoreAttrs ) auto nState = m_xMergeWithNextCB->get_state(); if (nState == TRISTATE_INDET) { - sal_uInt16 nMergeWithNextId = pPool->GetWhich(SID_ATTR_BORDER_CONNECT); + sal_uInt16 nMergeWithNextId = pPool->GetWhichIDFromSlotID(SID_ATTR_BORDER_CONNECT); rCoreAttrs->ClearItem(nMergeWithNextId); } else @@ -995,7 +990,7 @@ bool SvxBorderTabPage::FillItemSet( SfxItemSet* rCoreAttrs ) bool bPut = true; sal_uInt16 nBoxWhich = GetWhich( mnBoxSlot ); - sal_uInt16 nBoxInfoWhich = pPool->GetWhich( SID_ATTR_BORDER_INNER, false ); + sal_uInt16 nBoxInfoWhich = pPool->GetWhichIDFromSlotID( SID_ATTR_BORDER_INNER, false ); const SfxItemSet& rOldSet = GetItemSet(); SvxBoxItem aBoxItem ( nBoxWhich ); SvxBoxInfoItem aBoxInfoItem ( nBoxInfoWhich ); @@ -1236,15 +1231,19 @@ IMPL_LINK_NOARG(SvxBorderTabPage, SelSdwHdl_Impl, ValueSet*, void) IMPL_LINK(SvxBorderTabPage, SelColHdl_Impl, ColorListBox&, rColorBox, void) { - Color aColor = rColorBox.GetSelectEntryColor(); - m_aFrameSel.SetColorToSelection(aColor); + NamedColor aNamedColor = rColorBox.GetSelectedEntry(); + m_aFrameSel.SetColorToSelection(aNamedColor.m_aColor, aNamedColor.getComplexColor()); } IMPL_LINK_NOARG(SvxBorderTabPage, ModifyWidthLBHdl_Impl, weld::ComboBox&, void) { sal_Int32 nPos = m_xLineWidthLB->get_active(); + sal_Int32 nRemovedType = 0; + if (m_xLineWidthLB->get_values_changed_from_saved()) { + nRemovedType = std::size(s_LineWidths) - m_xLineWidthLB->get_count(); + } - SetLineWidth(m_aLineWidths[nPos]); + SetLineWidth(s_LineWidths[nPos + nRemovedType], nRemovedType); // Call the spinner handler to trigger all related modifications ModifyWidthMFHdl_Impl(*m_xLineWidthMF); @@ -1253,6 +1252,13 @@ IMPL_LINK_NOARG(SvxBorderTabPage, ModifyWidthLBHdl_Impl, weld::ComboBox&, void) IMPL_LINK_NOARG(SvxBorderTabPage, ModifyWidthMFHdl_Impl, weld::MetricSpinButton&, void) { sal_Int64 nVal = m_xLineWidthMF->get_value(FieldUnit::NONE); + + // for DOUBLE_THIN line style we cannot allow thinner line width then 1.10pt + if (m_xLbLineStyle->GetSelectEntryStyle() == SvxBorderLineStyle::DOUBLE_THIN) + m_xLineWidthMF->set_min(110, FieldUnit::NONE); + else + m_xLineWidthMF->set_min(5, FieldUnit::NONE); + nVal = static_cast<sal_Int64>(vcl::ConvertDoubleValue( nVal, m_xLineWidthMF->get_digits(), @@ -1266,6 +1272,13 @@ IMPL_LINK_NOARG(SvxBorderTabPage, ModifyWidthMFHdl_Impl, weld::MetricSpinButton& IMPL_LINK_NOARG(SvxBorderTabPage, SelStyleHdl_Impl, SvtLineListBox&, void) { sal_Int64 nOldWidth = m_xLineWidthMF->get_value(FieldUnit::NONE); + + // for DOUBLE_THIN line style we cannot allow thinner line width then 1.10pt + if (m_xLbLineStyle->GetSelectEntryStyle() == SvxBorderLineStyle::DOUBLE_THIN) + m_xLineWidthMF->set_min(110, FieldUnit::NONE); + else + m_xLineWidthMF->set_min(5, FieldUnit::NONE); + nOldWidth = static_cast<sal_Int64>(vcl::ConvertDoubleValue( nOldWidth, m_xLineWidthMF->get_digits(), @@ -1277,7 +1290,14 @@ IMPL_LINK_NOARG(SvxBorderTabPage, SelStyleHdl_Impl, SvtLineListBox&, void) // auto change line-width if it doesn't correspond to minimal value // let's change only in case when user has not changed the line-width into some custom value - const sal_Int64 nNewWidth = (nOldMinWidth == nOldWidth)? nNewMinWidth : nOldWidth; + sal_Int64 nNewWidth = (nOldMinWidth == nOldWidth) ? nNewMinWidth : nOldWidth; + + // if we had selected a predefined border width under SvxBorderLineWidth::Medium set the Medium as default + // otherwise if we had a custom border width under 1.10pt then set the spinner to the maximum allowed value for double border styles + bool bNewDoubleHairline = m_xLbLineStyle->GetSelectEntryStyle() == SvxBorderLineStyle::DOUBLE_THIN && !m_xLineWidthMF->get_visible() && + (nOldWidth == SvxBorderLineWidth::Hairline || nOldWidth == SvxBorderLineWidth::VeryThin || nOldWidth == SvxBorderLineWidth::Thin); + if (bNewDoubleHairline && nNewWidth < SvxBorderLineWidth::Medium) + nNewWidth = SvxBorderLineWidth::Medium; // set value inside edit box if (nOldWidth != nNewWidth) @@ -1290,6 +1310,26 @@ IMPL_LINK_NOARG(SvxBorderTabPage, SelStyleHdl_Impl, SvtLineListBox&, void) SetLineWidth(nNewWidthPt); } + if (m_xLbLineStyle->GetSelectEntryStyle() == SvxBorderLineStyle::DOUBLE_THIN) + { + for (size_t i = 0; i < 3; i++) + { + m_xLineWidthLB->save_values_by_id(OUString::number(i)); + m_xLineWidthLB->remove_id(OUString::number(i)); + } + if (m_xLineWidthLB->get_active_id().isEmpty()) + m_xLineWidthLB->set_active_id("3"); + } + else + { + if (m_xLineWidthLB->get_values_changed_from_saved()) + { + for (size_t i = 0; i < 3; i++) + m_xLineWidthLB->append(i, OUString::number(i), m_xLineWidthLB->get_saved_values(i)); + m_xLineWidthLB->removeSavedValues(); + } + } + // set value inside style box m_aFrameSel.SetStyleToSelection( nNewWidth, m_xLbLineStyle->GetSelectEntryStyle() ); @@ -1300,7 +1340,7 @@ IMPL_LINK_NOARG(SvxBorderTabPage, SelStyleHdl_Impl, SvtLineListBox&, void) sal_uInt16 SvxBorderTabPage::GetPresetImageId( sal_uInt16 nValueSetIdx ) const { // table with all sets of predefined border styles - static const sal_uInt16 ppnImgIds[][ SVX_BORDER_PRESET_COUNT ] = + static const sal_uInt16 ppnImgIds[][ BORDER_PRESET_COUNT ] = { // simple cell without diagonal frame borders { IID_PRE_CELL_NONE, IID_PRE_CELL_ALL, IID_PRE_CELL_LR, IID_PRE_CELL_TB, IID_PRE_CELL_L }, @@ -1325,7 +1365,7 @@ sal_uInt16 SvxBorderTabPage::GetPresetImageId( sal_uInt16 nValueSetIdx ) const else nLine = 4; - DBG_ASSERT( (1 <= nValueSetIdx) && (nValueSetIdx <= SVX_BORDER_PRESET_COUNT), + DBG_ASSERT( (1 <= nValueSetIdx) && (nValueSetIdx <= BORDER_PRESET_COUNT), "SvxBorderTabPage::GetPresetImageId - wrong index" ); return ppnImgIds[ nLine ][ nValueSetIdx - 1 ]; } @@ -1367,14 +1407,14 @@ void SvxBorderTabPage::FillPresetVS() { // basic initialization of the ValueSet m_xWndPresets->SetStyle( m_xWndPresets->GetStyle() | WB_ITEMBORDER | WB_DOUBLEBORDER ); - m_xWndPresets->SetColCount( SVX_BORDER_PRESET_COUNT ); + m_xWndPresets->SetColCount( BORDER_PRESET_COUNT ); // insert images and help texts - for( sal_uInt16 nVSIdx = 1; nVSIdx <= SVX_BORDER_PRESET_COUNT; ++nVSIdx ) + for( sal_uInt16 nVSIdx = 1; nVSIdx <= BORDER_PRESET_COUNT; ++nVSIdx ) { m_xWndPresets->InsertItem( nVSIdx ); m_xWndPresets->SetItemImage(nVSIdx, m_aBorderImgVec[GetPresetImageId(nVSIdx) - 1]); - m_xWndPresets->SetItemText( nVSIdx, CuiResId( GetPresetStringId( nVSIdx ) ) ); + m_xWndPresets->SetItemText( nVSIdx, SvxResId( GetPresetStringId( nVSIdx ) ) ); } // show the control @@ -1387,14 +1427,14 @@ void SvxBorderTabPage::FillShadowVS() { // basic initialization of the ValueSet m_xWndShadows->SetStyle( m_xWndShadows->GetStyle() | WB_ITEMBORDER | WB_DOUBLEBORDER ); - m_xWndShadows->SetColCount( SVX_BORDER_SHADOW_COUNT ); + m_xWndShadows->SetColCount( BORDER_SHADOW_COUNT ); // string resource IDs for each image - static const TranslateId pnStrIds[ SVX_BORDER_SHADOW_COUNT ] = - { RID_SVXSTR_SHADOW_STYLE_NONE, RID_SVXSTR_SHADOW_STYLE_BOTTOMRIGHT, RID_SVXSTR_SHADOW_STYLE_TOPRIGHT, RID_SVXSTR_SHADOW_STYLE_BOTTOMLEFT, RID_SVXSTR_SHADOW_STYLE_TOPLEFT }; + static const TranslateId pnStrIds[ BORDER_SHADOW_COUNT ] = + { RID_CUISTR_SHADOW_STYLE_NONE, RID_CUISTR_SHADOW_STYLE_BOTTOMRIGHT, RID_CUISTR_SHADOW_STYLE_TOPRIGHT, RID_CUISTR_SHADOW_STYLE_BOTTOMLEFT, RID_CUISTR_SHADOW_STYLE_TOPLEFT }; // insert images and help texts - for( sal_uInt16 nVSIdx = 1; nVSIdx <= SVX_BORDER_SHADOW_COUNT; ++nVSIdx ) + for( sal_uInt16 nVSIdx = 1; nVSIdx <= BORDER_SHADOW_COUNT; ++nVSIdx ) { m_xWndShadows->InsertItem( nVSIdx ); m_xWndShadows->SetItemImage(nVSIdx, m_aShadowImgVec[nVSIdx-1]); @@ -1414,24 +1454,23 @@ void SvxBorderTabPage::FillValueSets() FillShadowVS(); } -void SvxBorderTabPage::SetLineWidth( sal_Int64 nWidth ) +void SvxBorderTabPage::SetLineWidth( sal_Int64 nWidth, sal_Int32 nRemovedType ) { if ( nWidth >= 0 ) m_xLineWidthMF->set_value( nWidth, FieldUnit::POINT ); - auto it = std::find_if( m_aLineWidths.begin(), m_aLineWidths.end(), - [nWidth](const int val) -> bool { return val == nWidth; } ); + auto it = std::find( std::begin(s_LineWidths), std::end(s_LineWidths), nWidth ); - if ( it != m_aLineWidths.end() && *it >= 0 ) + if ( it != std::end(s_LineWidths) && *it >= 0 ) { // Select predefined value in combobox m_xLineWidthMF->hide(); - m_xLineWidthLB->set_active(std::distance(m_aLineWidths.begin(), it)); + m_xLineWidthLB->set_active(std::distance(std::begin(s_LineWidths), it) - nRemovedType); } else { // This is not one of predefined values. Show spinner - m_xLineWidthLB->set_active(m_aLineWidths.size()-1); + m_xLineWidthLB->set_active(std::size(s_LineWidths) - nRemovedType -1); m_xLineWidthMF->show(); } } @@ -1478,7 +1517,7 @@ void SvxBorderTabPage::FillLineListBox_Impl() m_xLbLineStyle->SetSourceUnit( FieldUnit::TWIP ); - for (size_t i = 0; i < SAL_N_ELEMENTS(aLines); ++i) + for (size_t i = 0; i < std::size(aLines); ++i) { if (!IsBorderLineStyleAllowed(aLines[i].mnStyle)) continue; @@ -1603,7 +1642,7 @@ void SvxBorderTabPage::UpdateRemoveAdjCellBorderCB( sal_uInt16 nPreset ) // Check if current selection involves deletion of at least one border bool bBorderDeletionReq = false; - for ( size_t i=0; i < SAL_N_ELEMENTS( eTypes1 ); ++i ) + for ( size_t i=0; i < std::size( eTypes1 ); ++i ) { if( pOldBoxItem->GetLine( eTypes2[i] ) || !( pOldBoxInfoItem->IsValid( eTypes1[i].second ) ) ) { diff --git a/cui/source/tabpages/chardlg.cxx b/cui/source/tabpages/chardlg.cxx index fef7b46fb537..cd6965375003 100644 --- a/cui/source/tabpages/chardlg.cxx +++ b/cui/source/tabpages/chardlg.cxx @@ -23,7 +23,6 @@ #include <sfx2/objsh.hxx> #include <svx/svxids.hrc> #include <svtools/unitconv.hxx> -#include <svl/languageoptions.hxx> #include <svl/cjkoptions.hxx> #include <svl/ctloptions.hxx> #include <chardlg.hxx> @@ -42,10 +41,11 @@ #include <editeng/kernitem.hxx> #include <editeng/flstitem.hxx> #include <editeng/autokernitem.hxx> +#include <editeng/nhypitem.hxx> #include <editeng/colritem.hxx> #include <dialmgr.hxx> #include <sfx2/htmlmode.hxx> -#include <cui/cuicharmap.hxx> +#include <svx/cuicharmap.hxx> #include "chardlg.h" #include <editeng/emphasismarkitem.hxx> #include <editeng/charreliefitem.hxx> @@ -63,6 +63,7 @@ #include <sal/log.hxx> #include <osl/diagnose.h> #include <o3tl/unit_conversion.hxx> +#include <o3tl/string_view.hxx> using namespace ::com::sun::star; @@ -132,7 +133,7 @@ inline SvxFont& SvxCharBasePage::GetPreviewCTLFont() return m_aPreviewWin.GetCTLFont(); } -SvxCharBasePage::SvxCharBasePage(weld::Container* pPage, weld::DialogController* pController, const OUString& rUIXMLDescription, const OString& rID, const SfxItemSet& rItemset) +SvxCharBasePage::SvxCharBasePage(weld::Container* pPage, weld::DialogController* pController, const OUString& rUIXMLDescription, const OUString& rID, const SfxItemSet& rItemset) : SfxTabPage(pPage, pController, rUIXMLDescription, rID, &rItemset) , m_bPreviewBackgroundToCharacter( false ) { @@ -190,84 +191,72 @@ struct SvxCharNamePage_Impl SvxCharNamePage::SvxCharNamePage(weld::Container* pPage, weld::DialogController* pController, const SfxItemSet& rInSet) : SvxCharBasePage(pPage, pController, "cui/ui/charnamepage.ui", "CharNamePage", rInSet) , m_pImpl(new SvxCharNamePage_Impl) - , m_xEastFrame(m_xBuilder->weld_widget("asian")) - , m_xEastFontNameFT(m_xBuilder->weld_label("eastfontnameft")) - , m_xEastFontNameLB(m_xBuilder->weld_combo_box("eastfontnamelb")) - , m_xEastFontStyleFT(m_xBuilder->weld_label("eaststyleft")) - , m_xEastFontStyleLB(new FontStyleBox(m_xBuilder->weld_combo_box("eaststylelb"))) - , m_xEastFontSizeFT(m_xBuilder->weld_label("eastsizeft")) - , m_xEastFontSizeLB(new FontSizeBox(m_xBuilder->weld_combo_box("eastsizelb"))) - , m_xEastFontLanguageFT(m_xBuilder->weld_label("eastlangft")) - , m_xEastFontLanguageLB(new SvxLanguageBox(m_xBuilder->weld_combo_box("eastlanglb"))) - , m_xEastFontTypeFT(m_xBuilder->weld_label("eastfontinfo")) - , m_xEastFontFeaturesButton(m_xBuilder->weld_button("east_features_button")) - , m_xCTLFrame(m_xBuilder->weld_widget("ctl")) - , m_xCTLFontNameFT(m_xBuilder->weld_label("ctlfontnameft")) - , m_xCTLFontNameLB(m_xBuilder->weld_combo_box("ctlfontnamelb")) - , m_xCTLFontStyleFT(m_xBuilder->weld_label("ctlstyleft")) - , m_xCTLFontStyleLB(new FontStyleBox(m_xBuilder->weld_combo_box("ctlstylelb"))) - , m_xCTLFontSizeFT(m_xBuilder->weld_label("ctlsizeft")) - , m_xCTLFontSizeLB(new FontSizeBox(m_xBuilder->weld_combo_box("ctlsizelb"))) - , m_xCTLFontLanguageFT(m_xBuilder->weld_label("ctllangft")) - , m_xCTLFontLanguageLB(new SvxLanguageBox(m_xBuilder->weld_combo_box("ctllanglb"))) - , m_xCTLFontTypeFT(m_xBuilder->weld_label("ctlfontinfo")) - , m_xCTLFontFeaturesButton(m_xBuilder->weld_button("ctl_features_button")) - , m_xVDev(*Application::GetDefaultDevice(), DeviceFormat::DEFAULT, DeviceFormat::DEFAULT) + // Western + , m_xWestern(m_xBuilder->weld_notebook("nbWestern")) + , m_xWestFontNameFT(m_xBuilder->weld_label("lbWestFontname")) + , m_xWestFontStyleFT(m_xBuilder->weld_label("lbWestStyle")) + , m_xWestFontStyleLB(new FontStyleBox(m_xBuilder->weld_combo_box("cbWestStyle"))) + , m_xWestFontSizeFT(m_xBuilder->weld_label("lbWestSize")) + , m_xWestFontSizeLB(new FontSizeBox(m_xBuilder->weld_combo_box("cbWestSize"))) + , m_xWestFontLanguageFT(m_xBuilder->weld_label("lbWestLanguage")) + , m_xWestFontLanguageLB(new SvxLanguageBox(m_xBuilder->weld_combo_box("cbWestLanguage"))) + , m_xWestFontFeaturesButton(m_xBuilder->weld_button("btnWestFeatures")) + , m_xWestFontTypeFT(m_xBuilder->weld_label("lbWestFontinfo")) + , m_xCJK_CTL(m_xBuilder->weld_notebook("nbCJKCTL")) + // CJK + , m_xEastFontNameFT(m_xBuilder->weld_label("lbCJKFontname")) + , m_xEastFontStyleFT(m_xBuilder->weld_label("lbCJKStyle")) + , m_xEastFontStyleLB(new FontStyleBox(m_xBuilder->weld_combo_box("cbCJKStyle"))) + , m_xEastFontSizeFT(m_xBuilder->weld_label("lbCJKSize")) + , m_xEastFontSizeLB(new FontSizeBox(m_xBuilder->weld_combo_box("cbCJKSize"))) + , m_xEastFontLanguageFT(m_xBuilder->weld_label("lbCJKLanguage")) + , m_xEastFontLanguageLB(new SvxLanguageBox(m_xBuilder->weld_combo_box("cbCJKLanguage"))) + , m_xEastFontFeaturesButton(m_xBuilder->weld_button("btnCJKFeatures")) + , m_xEastFontTypeFT(m_xBuilder->weld_label("lbCJKFontinfo")) + // CTL + , m_xCTLFontNameFT(m_xBuilder->weld_label("lbCTLFontname")) + // tree + , m_xCTLFontStyleFT(m_xBuilder->weld_label("lbCTLStyle")) + , m_xCTLFontStyleLB(new FontStyleBox(m_xBuilder->weld_combo_box("cbCTLStyle"))) + , m_xCTLFontSizeFT(m_xBuilder->weld_label("lbCTLSize")) + , m_xCTLFontSizeLB(new FontSizeBox(m_xBuilder->weld_combo_box("cbCTLSize"))) + , m_xCTLFontLanguageFT(m_xBuilder->weld_label("lbCTLLanguage")) + , m_xCTLFontLanguageLB(new SvxLanguageBox(m_xBuilder->weld_combo_box("cbCTLLanguage"))) + , m_xCTLFontFeaturesButton(m_xBuilder->weld_button("btnCTLFeatures")) + , m_xCTLFontTypeFT(m_xBuilder->weld_label("lbCTLFontinfo")) + + , m_xVDev(*Application::GetDefaultDevice(), DeviceFormat::WITH_ALPHA) { m_xPreviewWin.reset(new weld::CustomWeld(*m_xBuilder, "preview", m_aPreviewWin)); #ifdef IOS m_xPreviewWin->hide(); #endif - m_pImpl->m_aNoStyleText = CuiResId( RID_SVXSTR_CHARNAME_NOSTYLE ); + m_pImpl->m_aNoStyleText = CuiResId( RID_CUISTR_CHARNAME_NOSTYLE ); - SvtCTLOptions aCTLLanguageOptions; - bool bShowCJK = SvtCJKOptions::IsCJKFontEnabled(); - bool bShowCTL = aCTLLanguageOptions.IsCTLFontEnabled(); - bool bShowNonWestern = bShowCJK || bShowCTL; - - if (bShowNonWestern) - { - m_xWestFrame = m_xBuilder->weld_widget("western"); - m_xWestFontNameFT = m_xBuilder->weld_label("westfontnameft-cjk"); - m_xWestFontNameLB = m_xBuilder->weld_combo_box("westfontnamelb-cjk"); - m_xWestFontStyleFT = m_xBuilder->weld_label("weststyleft-cjk"); - m_xWestFontSizeFT = m_xBuilder->weld_label("westsizeft-cjk"); + std::unique_ptr<weld::EntryTreeView> xWestFontName = m_xBuilder->weld_entry_tree_view("gdWestern", "edWestFontName", "trWestFontName"); + std::unique_ptr<weld::EntryTreeView> xCJKFontName = m_xBuilder->weld_entry_tree_view("gdCJK", "edCJKFontName", "trCJKFontName"); + std::unique_ptr<weld::EntryTreeView> xCTLFontName = m_xBuilder->weld_entry_tree_view("gdCTL", "edCTLFontName", "trCTLFontName"); - m_xWestFontStyleLB.reset(new FontStyleBox(m_xBuilder->weld_combo_box("weststylelb-cjk"))); - m_xWestFontSizeLB.reset(new FontSizeBox(m_xBuilder->weld_combo_box("westsizelb-cjk"))); + // 7 lines in the treeview + xWestFontName->set_height_request_by_rows(7); + xCJKFontName->set_height_request_by_rows(7); + xCTLFontName->set_height_request_by_rows(7); - m_xWestFontLanguageFT = m_xBuilder->weld_label("westlangft-cjk"); - m_xWestFontLanguageLB.reset(new SvxLanguageBox(m_xBuilder->weld_combo_box("westlanglb-cjk"))); - m_xWestFontTypeFT = m_xBuilder->weld_label("westfontinfo-cjk"); + m_xWestFontNameLB = std::move(xWestFontName); + m_xEastFontNameLB = std::move(xCJKFontName); + m_xCTLFontNameLB = std::move(xCTLFontName); - m_xWestFontFeaturesButton = m_xBuilder->weld_button("west_features_button-cjk"); - } - else + bool bShowCJK = SvtCJKOptions::IsCJKFontEnabled(); + bool bShowCTL = SvtCTLOptions::IsCTLFontEnabled(); + bool bShowNonWestern = bShowCJK || bShowCTL; + if (!bShowNonWestern) { - m_xWestFrame = m_xBuilder->weld_widget("simple"); - m_xWestFontNameFT = m_xBuilder->weld_label("westfontnameft-nocjk"); - m_xWestFontStyleFT = m_xBuilder->weld_label("weststyleft-nocjk"); - m_xWestFontSizeFT = m_xBuilder->weld_label("westsizeft-nocjk"); - - m_xWestFontLanguageFT = m_xBuilder->weld_label("westlangft-nocjk"); - m_xWestFontLanguageLB.reset(new SvxLanguageBox(m_xBuilder->weld_combo_box("westlanglb-nocjk"))); - m_xWestFontTypeFT = m_xBuilder->weld_label("westfontinfo-nocjk"); - - m_xWestFontFeaturesButton = m_xBuilder->weld_button("west_features_button-nocjk"); - - std::unique_ptr<weld::EntryTreeView> xWestFontNameLB = m_xBuilder->weld_entry_tree_view("namegrid", "westfontname-nocjk", "westfontnamelb-nocjk"); - std::unique_ptr<weld::EntryTreeView> xWestFontStyleLB = m_xBuilder->weld_entry_tree_view("stylegrid", "weststyle-nocjk", "weststylelb-nocjk"); - std::unique_ptr<weld::EntryTreeView> xWestFontSizeLB = m_xBuilder->weld_entry_tree_view("sizegrid", "westsize-nocjk", "westsizelb-nocjk"); - - // 7 lines in the treeview - xWestFontNameLB->set_height_request_by_rows(7); - xWestFontStyleLB->set_height_request_by_rows(7); - xWestFontSizeLB->set_height_request_by_rows(7); - - m_xWestFontNameLB = std::move(xWestFontNameLB); - m_xWestFontStyleLB.reset(new FontStyleBox(std::move(xWestFontStyleLB))); - m_xWestFontSizeLB.reset(new FontSizeBox(std::move(xWestFontSizeLB))); + m_xCJK_CTL->hide(); + m_xWestern->set_show_tabs(false); //hide single tab in case of Western only } + else if (!bShowCJK) m_xCJK_CTL->remove_page("nbCJK"); + else if (!bShowCTL) m_xCJK_CTL->remove_page("nbCTL"); + //In MacOSX the standard dialogs name font-name, font-style as //Family, Typeface @@ -276,33 +265,34 @@ SvxCharNamePage::SvxCharNamePage(weld::Container* pPage, weld::DialogController* //In Windows the standard dialogs name font-name, font-style as //Font, Style #ifdef _WIN32 - OUString sFontFamilyString(CuiResId(RID_SVXSTR_CHARNAME_FONT)); + OUString sFontFamilyString(CuiResId(RID_CUISTR_CHARNAME_FONT)); #else - OUString sFontFamilyString(CuiResId(RID_SVXSTR_CHARNAME_FAMILY)); + OUString sFontFamilyString(CuiResId(RID_CUISTR_CHARNAME_FAMILY)); #endif m_xWestFontNameFT->set_label(sFontFamilyString); - m_xEastFontNameFT->set_label(sFontFamilyString); m_xCTLFontNameFT->set_label(sFontFamilyString); + m_xEastFontNameFT->set_label(sFontFamilyString); #ifdef MACOSX - OUString sFontStyleString(CuiResId(RID_SVXSTR_CHARNAME_TYPEFACE)); + OUString sFontStyleString(CuiResId(RID_CUISTR_CHARNAME_TYPEFACE)); #else - OUString sFontStyleString(CuiResId(RID_SVXSTR_CHARNAME_STYLE)); + OUString sFontStyleString(CuiResId(RID_CUISTR_CHARNAME_STYLE)); #endif m_xWestFontStyleFT->set_label(sFontStyleString); m_xEastFontStyleFT->set_label(sFontStyleString); m_xCTLFontStyleFT->set_label(sFontStyleString); - m_xWestFrame->show(); - m_xEastFrame->set_visible(bShowCJK); - m_xCTLFrame->set_visible(bShowCTL); - m_xWestFontLanguageLB->SetLanguageList(SvxLanguageListFlags::WESTERN, true, false, true, true, - LANGUAGE_SYSTEM, css::i18n::ScriptType::LATIN); + LANGUAGE_SYSTEM, css::i18n::ScriptType::LATIN); m_xEastFontLanguageLB->SetLanguageList(SvxLanguageListFlags::CJK, true, false, true, true, - LANGUAGE_SYSTEM, css::i18n::ScriptType::ASIAN); + LANGUAGE_SYSTEM, css::i18n::ScriptType::ASIAN); m_xCTLFontLanguageLB->SetLanguageList(SvxLanguageListFlags::CTL, true, false, true, true, - LANGUAGE_SYSTEM, css::i18n::ScriptType::COMPLEX); + LANGUAGE_SYSTEM, css::i18n::ScriptType::COMPLEX); + int nVisibleChars = 15; + // read-only combobox / HasEntry asserts on set_width_char() + m_xWestFontLanguageLB->set_width_chars(nVisibleChars); + m_xEastFontLanguageLB->set_width_chars(nVisibleChars); + m_xCTLFontLanguageLB->set_width_chars(nVisibleChars); Initialize(); } @@ -354,10 +344,8 @@ const FontList* SvxCharNamePage::GetFontList() const { if ( !m_pImpl->m_pFontList ) { - SfxObjectShell* pDocSh = SfxObjectShell::Current(); - /* #110771# SvxFontListItem::GetFontList can return NULL */ - if ( pDocSh ) + if (SfxObjectShell* pDocSh = SfxObjectShell::Current()) { const SfxPoolItem* pItem = pDocSh->GetItem( SID_ATTR_CHAR_FONTLIST ); if ( pItem != nullptr ) @@ -691,7 +679,7 @@ void SvxCharNamePage::Reset_Impl( const SfxItemSet& rSet, LanguageGroup eLangGrp eItalic = rItem.GetValue(); bStyle = true; } - bStyleAvailable = bStyleAvailable && (eState >= SfxItemState::DONTCARE); + bStyleAvailable = bStyleAvailable && (eState >= SfxItemState::INVALID); switch ( eLangGrp ) { @@ -708,7 +696,7 @@ void SvxCharNamePage::Reset_Impl( const SfxItemSet& rSet, LanguageGroup eLangGrp } else bStyle = false; - bStyleAvailable = bStyleAvailable && (eState >= SfxItemState::DONTCARE); + bStyleAvailable = bStyleAvailable && (eState >= SfxItemState::INVALID); // currently chosen font if ( bStyle && pFontItem ) @@ -804,7 +792,7 @@ void SvxCharNamePage::Reset_Impl( const SfxItemSet& rSet, LanguageGroup eLangGrp pLangBox->set_active_id(eLangType); break; } - case SfxItemState::DONTCARE: + case SfxItemState::INVALID: break; } @@ -1072,31 +1060,40 @@ bool SvxCharNamePage::FillItemSet_Impl( SfxItemSet& rSet, LanguageGroup eLangGrp case Asian : nSlot = SID_ATTR_CHAR_CJK_LANGUAGE; break; case Ctl : nSlot = SID_ATTR_CHAR_CTL_LANGUAGE; break; } - nWhich = GetWhich( nSlot ); - pOld = GetOldItem( rSet, nSlot ); // For language list boxes acting as ComboBox, check for, add and select an // edited entry. - if (pLangBox == m_xWestFontLanguageLB.get()) + switch (pLangBox->GetEditedAndValid()) { - switch (pLangBox->GetEditedAndValid()) - { - case SvxLanguageBox::EditedAndValid::No: - ; // nothing to do - break; - case SvxLanguageBox::EditedAndValid::Valid: + case SvxLanguageBox::EditedAndValid::No: + ; // nothing to do + break; + case SvxLanguageBox::EditedAndValid::Valid: + { + SvxLanguageBox* ppBoxes[3] + = {m_xWestFontLanguageLB.get(), m_xEastFontLanguageLB.get(), m_xCTLFontLanguageLB.get()}; + SvxLanguageBox* pBox = pLangBox->SaveEditedAsEntry(ppBoxes); + if (pBox != pLangBox) { - const int nPos = pLangBox->SaveEditedAsEntry(); - if (nPos != -1) - pLangBox->set_active(nPos); + // Get item from corresponding slot. + if (pBox == m_xWestFontLanguageLB.get()) + nSlot = SID_ATTR_CHAR_LANGUAGE; + else if (pBox == m_xEastFontLanguageLB.get()) + nSlot = SID_ATTR_CHAR_CJK_LANGUAGE; + else if (pBox == m_xCTLFontLanguageLB.get()) + nSlot = SID_ATTR_CHAR_CTL_LANGUAGE; + pLangBox = pBox; } - break; - case SvxLanguageBox::EditedAndValid::Invalid: - pLangBox->set_active_id(pLangBox->get_saved_active_id()); - break; - } + } + break; + case SvxLanguageBox::EditedAndValid::Invalid: + pLangBox->set_active_id(pLangBox->get_saved_active_id()); + break; } + nWhich = GetWhich( nSlot ); + pOld = GetOldItem( rSet, nSlot ); + int nLangPos = pLangBox->get_active(); LanguageType eLangType = pLangBox->get_active_id(); @@ -1364,14 +1361,16 @@ void SvxCharEffectsPage::Initialize() SetExchangeSupport(); // HTML-Mode - const SfxPoolItem* pItem; - SfxObjectShell* pShell; - if ( SfxItemState::SET == GetItemSet().GetItemState( SID_HTML_MODE, false, &pItem ) || - ( nullptr != ( pShell = SfxObjectShell::Current() ) && - nullptr != ( pItem = pShell->GetItem( SID_HTML_MODE ) ) ) ) + const SfxUInt16Item* pHtmlModeItem = GetItemSet().GetItemIfSet( SID_HTML_MODE, false ); + if ( !pHtmlModeItem) + { + if (SfxObjectShell* pShell = SfxObjectShell::Current()) + pHtmlModeItem = pShell->GetItem( SID_HTML_MODE ); + } + if (pHtmlModeItem) { - m_nHtmlMode = static_cast<const SfxUInt16Item*>(pItem)->GetValue(); - if ( ( m_nHtmlMode & HTMLMODE_ON ) == HTMLMODE_ON ) + sal_uInt16 nHtmlMode = pHtmlModeItem->GetValue(); + if ( ( nHtmlMode & HTMLMODE_ON ) == HTMLMODE_ON ) { //!!! hide some controls please } @@ -1523,7 +1522,7 @@ void SvxCharEffectsPage::ResetColor_Impl( const SfxItemSet& rSet ) m_xFontColorLB->set_sensitive(false); break; - case SfxItemState::DONTCARE: + case SfxItemState::INVALID: //Related: tdf#106080 if there is no font color, then allow "none" //as a color so the listbox can display that state. EnableNoneFontColor(); @@ -1573,28 +1572,31 @@ bool SvxCharEffectsPage::FillItemSetColor_Impl( SfxItemSet& rSet ) sal_uInt16 nWhich = GetWhich( SID_ATTR_CHAR_COLOR ); const SfxItemSet& rOldSet = GetItemSet(); - Color aSelectedColor; + NamedColor aSelectedColor; bool bChanged = m_bNewFontColor; if (bChanged) { - aSelectedColor = m_xFontColorLB->GetSelectEntryColor(); + aSelectedColor = m_xFontColorLB->GetSelectedEntryThemedColor(); if (m_xFontTransparencyMtr->get_value_changed_from_saved()) { double fTransparency = m_xFontTransparencyMtr->get_value(FieldUnit::PERCENT) * 255.0 / 100; - aSelectedColor.SetAlpha(255 - static_cast<sal_uInt8>(basegfx::fround(fTransparency))); + aSelectedColor.m_aColor.SetAlpha(255 - static_cast<sal_uInt8>(basegfx::fround(fTransparency))); } if (m_bOrigFontColor) - bChanged = aSelectedColor != m_aOrigFontColor; - if (m_bEnableNoneFontColor && bChanged && aSelectedColor == COL_NONE_COLOR) + bChanged = aSelectedColor.m_aColor != m_aOrigFontColor; + if (m_bEnableNoneFontColor && bChanged && aSelectedColor.m_aColor == COL_NONE_COLOR) bChanged = false; } if (bChanged) - rSet.Put( SvxColorItem( aSelectedColor, nWhich ) ); + { + SvxColorItem aItem(aSelectedColor.m_aColor, aSelectedColor.getComplexColor(), nWhich); + rSet.Put(aItem); + } else if ( SfxItemState::DEFAULT == rOldSet.GetItemState( nWhich, false ) ) rSet.InvalidateItem(nWhich); @@ -1687,9 +1689,9 @@ void SvxCharEffectsPage::Reset( const SfxItemSet* rSet ) m_xUnderlineLB->set_active( 0 ); SfxItemState eState = rSet->GetItemState( nWhich ); - if ( eState >= SfxItemState::DONTCARE ) + if ( eState >= SfxItemState::INVALID ) { - if ( eState == SfxItemState::DONTCARE ) + if ( eState == SfxItemState::INVALID ) m_xUnderlineLB->set_active(-1); else { @@ -1727,9 +1729,9 @@ void SvxCharEffectsPage::Reset( const SfxItemSet* rSet ) m_xOverlineLB->set_active( 0 ); eState = rSet->GetItemState( nWhich ); - if ( eState >= SfxItemState::DONTCARE ) + if ( eState >= SfxItemState::INVALID ) { - if ( eState == SfxItemState::DONTCARE ) + if ( eState == SfxItemState::INVALID ) m_xOverlineLB->set_active(-1); else { @@ -1767,9 +1769,9 @@ void SvxCharEffectsPage::Reset( const SfxItemSet* rSet ) m_xStrikeoutLB->set_active( 0 ); eState = rSet->GetItemState( nWhich ); - if ( eState >= SfxItemState::DONTCARE ) + if ( eState >= SfxItemState::INVALID ) { - if ( eState == SfxItemState::DONTCARE ) + if ( eState == SfxItemState::INVALID ) m_xStrikeoutLB->set_active(-1); else { @@ -1807,7 +1809,7 @@ void SvxCharEffectsPage::Reset( const SfxItemSet* rSet ) m_xIndividualWordsBtn->set_sensitive(false); break; - case SfxItemState::DONTCARE: + case SfxItemState::INVALID: m_aIndividualWordsState.bTriStateEnabled = true; m_xIndividualWordsBtn->set_state( TRISTATE_INDET ); break; @@ -1849,7 +1851,7 @@ void SvxCharEffectsPage::Reset( const SfxItemSet* rSet ) if (nPos != -1) m_xPositionLB->set_active(nPos); } - else if ( eState == SfxItemState::DONTCARE ) + else if ( eState == SfxItemState::INVALID ) m_xEmphasisLB->set_active(-1); else if ( eState == SfxItemState::UNKNOWN ) { @@ -1884,7 +1886,7 @@ void SvxCharEffectsPage::Reset( const SfxItemSet* rSet ) m_xEffectsLB->set_sensitive(false); break; - case SfxItemState::DONTCARE: + case SfxItemState::INVALID: m_xEffectsLB->set_active(-1); break; @@ -1913,7 +1915,7 @@ void SvxCharEffectsPage::Reset( const SfxItemSet* rSet ) m_xReliefLB->set_sensitive(false); break; - case SfxItemState::DONTCARE: + case SfxItemState::INVALID: m_xReliefLB->set_active(-1); break; @@ -1942,7 +1944,7 @@ void SvxCharEffectsPage::Reset( const SfxItemSet* rSet ) m_xOutlineBtn->set_sensitive(false); break; - case SfxItemState::DONTCARE: + case SfxItemState::INVALID: m_aOutlineState.bTriStateEnabled = true; m_xOutlineBtn->set_state(TRISTATE_INDET); break; @@ -1973,7 +1975,7 @@ void SvxCharEffectsPage::Reset( const SfxItemSet* rSet ) m_xShadowBtn->set_sensitive(false); break; - case SfxItemState::DONTCARE: + case SfxItemState::INVALID: m_aShadowState.bTriStateEnabled = true; m_xShadowBtn->set_state( TRISTATE_INDET ); break; @@ -2004,7 +2006,7 @@ void SvxCharEffectsPage::Reset( const SfxItemSet* rSet ) m_xHiddenBtn->set_sensitive(false); break; - case SfxItemState::DONTCARE: + case SfxItemState::INVALID: m_aHiddenState.bTriStateEnabled = true; m_xHiddenBtn->set_state(TRISTATE_INDET); break; @@ -2081,21 +2083,26 @@ bool SvxCharEffectsPage::FillItemSet( SfxItemSet* rSet ) //! item-state in the 'rOldSet' will be invalid. In this case //! changing the underline style will be allowed if a style is //! selected in the listbox. - bool bAllowChg = nPos != -1 && + bool bAllowChange = nPos != -1 && SfxItemState::DEFAULT > rOldSet.GetItemState( nWhich ); const SvxUnderlineItem& rItem = *static_cast<const SvxUnderlineItem*>(pOld); - if ( rItem.GetValue() == eUnder && - ( LINESTYLE_NONE == eUnder || rItem.GetColor() == m_xUnderlineColorLB->GetSelectEntryColor() ) && - ! bAllowChg ) + if (rItem.GetValue() == eUnder && + (LINESTYLE_NONE == eUnder || (rItem.GetColor() == m_xUnderlineColorLB->GetSelectEntryColor() && + rItem.getComplexColor() == m_xUnderlineColorLB->GetSelectedEntry().getComplexColor())) && + !bAllowChange) + { bChanged = false; + } } if ( bChanged ) { SvxUnderlineItem aNewItem( eUnder, nWhich ); - aNewItem.SetColor( m_xUnderlineColorLB->GetSelectEntryColor() ); - rSet->Put( aNewItem ); + auto aNamedColor = m_xUnderlineColorLB->GetSelectedEntry(); + aNewItem.SetColor(aNamedColor.m_aColor); + aNewItem.setComplexColor(aNamedColor.getComplexColor()); + rSet->Put(aNewItem); bModified = true; } else if ( SfxItemState::DEFAULT == rOldSet.GetItemState( nWhich, false ) ) @@ -2115,21 +2122,26 @@ bool SvxCharEffectsPage::FillItemSet( SfxItemSet* rSet ) //! item-state in the 'rOldSet' will be invalid. In this case //! changing the underline style will be allowed if a style is //! selected in the listbox. - bool bAllowChg = nPos != -1 && + bool bAllowChange = nPos != -1 && SfxItemState::DEFAULT > rOldSet.GetItemState( nWhich ); const SvxOverlineItem& rItem = *static_cast<const SvxOverlineItem*>(pOld); - if ( rItem.GetValue() == eOver && - ( LINESTYLE_NONE == eOver || rItem.GetColor() == m_xOverlineColorLB->GetSelectEntryColor() ) && - ! bAllowChg ) + if (rItem.GetValue() == eOver && + (LINESTYLE_NONE == eOver || (rItem.GetColor() == m_xOverlineColorLB->GetSelectEntryColor() && + rItem.getComplexColor() == m_xOverlineColorLB->GetSelectedEntry().getComplexColor())) && + !bAllowChange) + { bChanged = false; + } } if ( bChanged ) { SvxOverlineItem aNewItem( eOver, nWhich ); - aNewItem.SetColor( m_xOverlineColorLB->GetSelectEntryColor() ); - rSet->Put( aNewItem ); + auto aNamedColor = m_xOverlineColorLB->GetSelectedEntry(); + aNewItem.SetColor(aNamedColor.m_aColor); + aNewItem.setComplexColor(aNamedColor.getComplexColor()); + rSet->Put(aNewItem); bModified = true; } else if ( SfxItemState::DEFAULT == rOldSet.GetItemState( nWhich, false ) ) @@ -2211,7 +2223,7 @@ bool SvxCharEffectsPage::FillItemSet( SfxItemSet* rSet ) if ( pOld ) { - if( rOldSet.GetItemState( nWhich ) != SfxItemState::DONTCARE ) + if( rOldSet.GetItemState( nWhich ) != SfxItemState::INVALID ) { const SvxEmphasisMarkItem& rItem = *static_cast<const SvxEmphasisMarkItem*>(pOld); if ( rItem.GetEmphasisMark() == eMark ) @@ -2219,7 +2231,7 @@ bool SvxCharEffectsPage::FillItemSet( SfxItemSet* rSet ) } } - if (rOldSet.GetItemState( nWhich ) == SfxItemState::DONTCARE && + if (rOldSet.GetItemState( nWhich ) == SfxItemState::INVALID && m_xEmphasisLB->get_saved_value() == sMarkPos && m_xPositionLB->get_saved_value() == sPosPos) { bChanged = false; @@ -2227,7 +2239,7 @@ bool SvxCharEffectsPage::FillItemSet( SfxItemSet* rSet ) if (bChanged) { - rSet->Put( SvxEmphasisMarkItem( eMark, nWhich ) ); + rSet->Put( SvxEmphasisMarkItem( eMark, TypedWhichId<SvxEmphasisMarkItem>(nWhich) ) ); bModified = true; } else if ( SfxItemState::DEFAULT == rOldSet.GetItemState( nWhich, false ) ) @@ -2378,10 +2390,7 @@ void SvxCharEffectsPage::PageCreated(const SfxAllItemSet& aSet) if (pDisableCtlItem) DisableControls(pDisableCtlItem->GetValue()); - if (!pFlagItem) - return; - - sal_uInt32 nFlags=pFlagItem->GetValue(); + sal_uInt32 nFlags = pFlagItem ? pFlagItem->GetValue() : 0; if ( ( nFlags & SVX_PREVIEW_CHARACTER ) == SVX_PREVIEW_CHARACTER ) // the writer uses SID_ATTR_BRUSH as font background m_bPreviewBackgroundToCharacter = true; @@ -2421,6 +2430,7 @@ SvxCharPositionPage::SvxCharPositionPage(weld::Container* pPage, weld::DialogCon , m_xScaleWidthMF(m_xBuilder->weld_metric_spin_button("scalewidthsb", FieldUnit::PERCENT)) , m_xKerningMF(m_xBuilder->weld_metric_spin_button("kerningsb", FieldUnit::POINT)) , m_xPairKerningBtn(m_xBuilder->weld_check_button("pairkerning")) + , m_xNoHyphenationBtn(m_xBuilder->weld_check_button("nohyphenation")) { m_xPreviewWin.reset(new weld::CustomWeld(*m_xBuilder, "preview", m_aPreviewWin)); #ifdef IOS @@ -2636,10 +2646,10 @@ void SvxCharPositionPage::Reset( const SfxItemSet* rSet ) if ( !sUser.isEmpty() ) { sal_Int32 nIdx {0}; - m_nSuperEsc = static_cast<short>(sUser.getToken( 0, ';', nIdx ).toInt32()); - m_nSubEsc = static_cast<short>(sUser.getToken( 0, ';', nIdx ).toInt32()); - m_nSuperProp = static_cast<sal_uInt8>(sUser.getToken( 0, ';', nIdx ).toInt32()); - m_nSubProp = static_cast<sal_uInt8>(sUser.getToken( 0, ';', nIdx ).toInt32()); + m_nSuperEsc = static_cast<short>(o3tl::toInt32(o3tl::getToken(sUser, 0, ';', nIdx ))); + m_nSubEsc = static_cast<short>(o3tl::toInt32(o3tl::getToken(sUser, 0, ';', nIdx ))); + m_nSuperProp = static_cast<sal_uInt8>(o3tl::toInt32(o3tl::getToken(sUser, 0, ';', nIdx ))); + m_nSubProp = static_cast<sal_uInt8>(o3tl::toInt32(o3tl::getToken(sUser, 0, ';', nIdx ))); m_xHighLowMF->set_max(MAX_ESC_POS, FieldUnit::PERCENT); @@ -2740,6 +2750,8 @@ void SvxCharPositionPage::Reset( const SfxItemSet* rSet ) m_xHighPosBtn->set_active(false); m_xNormalPosBtn->set_active(false); m_xLowPosBtn->set_active(false); + + m_xHighLowRB->set_active(true); } // set BspFont @@ -2761,10 +2773,13 @@ void SvxCharPositionPage::Reset( const SfxItemSet* rSet ) rCJKFont.SetFixKerning( static_cast<short>(nKern) ); rCTLFont.SetFixKerning( static_cast<short>(nKern) ); - //the attribute value must be displayed also if it's above the maximum allowed value + //the attribute value must be displayed also if it's above/below the maximum allowed value tools::Long nVal = static_cast<tools::Long>(m_xKerningMF->get_max(FieldUnit::POINT)); if(nVal < nKerning) m_xKerningMF->set_max(nKerning, FieldUnit::POINT); + nVal = static_cast<tools::Long>(m_xKerningMF->get_min(FieldUnit::POINT)); + if (nVal > nKerning) + m_xKerningMF->set_min(nKerning, FieldUnit::POINT); m_xKerningMF->set_value(nKerning, FieldUnit::POINT); } else @@ -2781,6 +2796,16 @@ void SvxCharPositionPage::Reset( const SfxItemSet* rSet ) else m_xPairKerningBtn->set_active(false); + // No hyphenation + nWhich = GetWhich( sal_uInt16(19) ); // number borrowed from RES_CHRATR_NOHYPHEN + if ( rSet->GetItemState( nWhich ) >= SfxItemState::DEFAULT ) + { + const SvxNoHyphenItem& rItem = static_cast<const SvxNoHyphenItem&>(rSet->Get( nWhich )); + m_xNoHyphenationBtn->set_active(rItem.GetValue()); + } + else + m_xNoHyphenationBtn->set_active(false); + // Scale Width nWhich = GetWhich( SID_ATTR_CHAR_SCALEWIDTH ); if ( rSet->GetItemState( nWhich ) >= SfxItemState::DEFAULT ) @@ -2792,9 +2817,8 @@ void SvxCharPositionPage::Reset( const SfxItemSet* rSet ) else m_xScaleWidthMF->set_value(100, FieldUnit::PERCENT); - nWhich = GetWhich( SID_ATTR_CHAR_WIDTH_FIT_TO_LINE ); - if ( rSet->GetItemState( nWhich ) >= SfxItemState::DEFAULT ) - m_nScaleWidthItemSetVal = static_cast<const SfxUInt16Item&>( rSet->Get( nWhich )).GetValue(); + if ( rSet->GetItemState( SID_ATTR_CHAR_WIDTH_FIT_TO_LINE ) >= SfxItemState::DEFAULT ) + m_nScaleWidthItemSetVal = rSet->Get( SID_ATTR_CHAR_WIDTH_FIT_TO_LINE ).GetValue(); // Rotation nWhich = GetWhich( SID_ATTR_CHAR_ROTATED ); @@ -2828,7 +2852,7 @@ void SvxCharPositionPage::Reset( const SfxItemSet* rSet ) } else { - if( eState == SfxItemState::DONTCARE ) + if( eState == SfxItemState::INVALID ) { m_x0degRB->set_active(false); m_x90degRB->set_active(false); @@ -2842,8 +2866,8 @@ void SvxCharPositionPage::Reset( const SfxItemSet* rSet ) m_xFitToLineCB->set_sensitive(!m_x0degRB->get_active()); // is this value set? - if( SfxItemState::UNKNOWN == rSet->GetItemState( GetWhich( - SID_ATTR_CHAR_WIDTH_FIT_TO_LINE ) )) + if( SfxItemState::UNKNOWN == rSet->GetItemState( + SID_ATTR_CHAR_WIDTH_FIT_TO_LINE )) m_xFitToLineCB->hide(); } ChangesApplied(); @@ -2862,6 +2886,7 @@ void SvxCharPositionPage::ChangesApplied() m_xScaleWidthMF->save_value(); m_xKerningMF->save_value(); m_xPairKerningBtn->save_state(); + m_xNoHyphenationBtn->save_state(); } bool SvxCharPositionPage::FillItemSet( SfxItemSet* rSet ) @@ -2951,11 +2976,23 @@ bool SvxCharPositionPage::FillItemSet( SfxItemSet* rSet ) else if ( SfxItemState::DEFAULT == rOldSet.GetItemState( nWhich, false ) ) rSet->InvalidateItem(nWhich); + // No hyphenation + + nWhich = GetWhich( sal_uInt16(19) ); // number borrowed from RES_CHRATR_NOHYPHEN + + if (m_xNoHyphenationBtn->get_state_changed_from_saved()) + { + rSet->Put( SvxNoHyphenItem( m_xNoHyphenationBtn->get_active(), nWhich ) ); + bModified = true; + } + else if ( SfxItemState::DEFAULT == rOldSet.GetItemState( nWhich, false ) ) + rSet->InvalidateItem(nWhich); + // Scale Width nWhich = GetWhich( SID_ATTR_CHAR_SCALEWIDTH ); if (m_xScaleWidthMF->get_value_changed_from_saved()) { - rSet->Put(SvxCharScaleWidthItem(static_cast<sal_uInt16>(m_xScaleWidthMF->get_value(FieldUnit::PERCENT)), nWhich)); + rSet->Put(SvxCharScaleWidthItem(static_cast<sal_uInt16>(m_xScaleWidthMF->get_value(FieldUnit::PERCENT)), TypedWhichId<SvxCharScaleWidthItem>(nWhich))); bModified = true; } else if ( SfxItemState::DEFAULT == rOldSet.GetItemState( nWhich, false ) ) @@ -2968,7 +3005,7 @@ bool SvxCharPositionPage::FillItemSet( SfxItemSet* rSet ) m_x270degRB->get_state_changed_from_saved() || m_xFitToLineCB->get_state_changed_from_saved() ) { - SvxCharRotateItem aItem( 0_deg10, m_xFitToLineCB->get_active(), nWhich ); + SvxCharRotateItem aItem( 0_deg10, m_xFitToLineCB->get_active(), TypedWhichId<SvxCharRotateItem>(nWhich) ); if (m_x90degRB->get_active()) aItem.SetBottomToTop(); else if (m_x270degRB->get_active()) @@ -2985,7 +3022,7 @@ bool SvxCharPositionPage::FillItemSet( SfxItemSet* rSet ) void SvxCharPositionPage::FillUserData() { - static const OUStringLiteral cTok( u";" ); + static constexpr OUString cTok( u";"_ustr ); OUString sUser = OUString::number( m_nSuperEsc ) + cTok + OUString::number( m_nSubEsc ) + cTok + @@ -3017,9 +3054,9 @@ SvxCharTwoLinesPage::SvxCharTwoLinesPage(weld::Container* pPage, weld::DialogCon , m_xStartBracketLB(m_xBuilder->weld_tree_view("startbracket")) , m_xEndBracketLB(m_xBuilder->weld_tree_view("endbracket")) { - for (size_t i = 0; i < SAL_N_ELEMENTS(TWOLINE_OPEN); ++i) + for (size_t i = 0; i < std::size(TWOLINE_OPEN); ++i) m_xStartBracketLB->append(OUString::number(TWOLINE_OPEN[i].second), CuiResId(TWOLINE_OPEN[i].first)); - for (size_t i = 0; i < SAL_N_ELEMENTS(TWOLINE_CLOSE); ++i) + for (size_t i = 0; i < std::size(TWOLINE_CLOSE); ++i) m_xEndBracketLB->append(OUString::number(TWOLINE_CLOSE[i].second), CuiResId(TWOLINE_CLOSE[i].first)); m_xPreviewWin.reset(new weld::CustomWeld(*m_xBuilder, "preview", m_aPreviewWin)); @@ -3153,7 +3190,7 @@ void SvxCharTwoLinesPage::Reset( const SfxItemSet* rSet ) sal_uInt16 nWhich = GetWhich( SID_ATTR_CHAR_TWO_LINES ); SfxItemState eState = rSet->GetItemState( nWhich ); - if ( eState >= SfxItemState::DONTCARE ) + if ( eState >= SfxItemState::INVALID ) { const SvxTwoLinesItem& rItem = static_cast<const SvxTwoLinesItem&>(rSet->Get( nWhich )); m_xTwoLinesBtn->set_active(rItem.GetValue()); diff --git a/cui/source/tabpages/connect.cxx b/cui/source/tabpages/connect.cxx index 677613191130..b3d036d991f9 100644 --- a/cui/source/tabpages/connect.cxx +++ b/cui/source/tabpages/connect.cxx @@ -50,7 +50,7 @@ SvxConnectionDialog::SvxConnectionDialog(weld::Window* pParent, const SfxItemSet xPage->Construct(); SetTabPage(std::move(xPage)); - m_xDialog->set_title(CuiResId(RID_SVXSTR_CONNECTOR)); + m_xDialog->set_title(CuiResId(RID_CUISTR_CONNECTOR)); } /************************************************************************* @@ -118,6 +118,17 @@ SvxConnectionPage::~SvxConnectionPage() m_xCtlPreview.reset(); } +template<class T> +void SvxConnectionPage::SetMetricValueAndSave(const SfxItemSet* rAttrs, weld::MetricSpinButton& rField, TypedWhichId<T> nWhich) +{ + const SfxPoolItem* pItem = GetItem( *rAttrs, nWhich); + const SfxItemPool* pPool = rAttrs->GetPool(); + if( !pItem ) + pItem = &pPool->GetUserOrPoolDefaultItem( nWhich ); + SetMetricValue(rField, pItem->StaticWhichCast(nWhich).GetValue(), eUnit); + rField.save_value(); +} + /************************************************************************* |* |* reads passed Item-Set @@ -126,66 +137,35 @@ SvxConnectionPage::~SvxConnectionPage() void SvxConnectionPage::Reset( const SfxItemSet* rAttrs ) { - const SfxPoolItem* pItem = GetItem( *rAttrs, SDRATTR_EDGENODE1HORZDIST ); + const SfxPoolItem* pItem; const SfxItemPool* pPool = rAttrs->GetPool(); // SdrEdgeNode1HorzDistItem - if( !pItem ) - pItem = &pPool->GetDefaultItem( SDRATTR_EDGENODE1HORZDIST ); - SetMetricValue(*m_xMtrFldHorz1, static_cast<const SdrEdgeNode1HorzDistItem*>(pItem)->GetValue(), - eUnit); - m_xMtrFldHorz1->save_value(); + SetMetricValueAndSave(rAttrs, *m_xMtrFldHorz1, SDRATTR_EDGENODE1HORZDIST); // SdrEdgeNode2HorzDistItem - pItem = GetItem( *rAttrs, SDRATTR_EDGENODE2HORZDIST ); - if( !pItem ) - pItem = &pPool->GetDefaultItem( SDRATTR_EDGENODE2HORZDIST ); - SetMetricValue(*m_xMtrFldHorz2, static_cast<const SdrEdgeNode2HorzDistItem*>(pItem)->GetValue(), - eUnit); - m_xMtrFldHorz2->save_value(); + SetMetricValueAndSave(rAttrs, *m_xMtrFldHorz2, SDRATTR_EDGENODE2HORZDIST); // SdrEdgeNode1VertDistItem - pItem = GetItem( *rAttrs, SDRATTR_EDGENODE1VERTDIST ); - if( !pItem ) - pItem = &pPool->GetDefaultItem( SDRATTR_EDGENODE1VERTDIST ); - SetMetricValue(*m_xMtrFldVert1, static_cast<const SdrEdgeNode1VertDistItem*>(pItem)->GetValue(), - eUnit); - m_xMtrFldVert1->save_value(); + SetMetricValueAndSave(rAttrs, *m_xMtrFldVert1, SDRATTR_EDGENODE1VERTDIST); // SdrEdgeNode2VertDistItem - pItem = GetItem( *rAttrs, SDRATTR_EDGENODE2VERTDIST ); - if( !pItem ) - pItem = &pPool->GetDefaultItem( SDRATTR_EDGENODE2VERTDIST ); - SetMetricValue(*m_xMtrFldVert2, static_cast<const SdrEdgeNode2VertDistItem*>(pItem)->GetValue(), - eUnit); - m_xMtrFldVert2->save_value(); + SetMetricValueAndSave(rAttrs, *m_xMtrFldVert2, SDRATTR_EDGENODE2VERTDIST); // SdrEdgeLine1DeltaItem - pItem = GetItem( *rAttrs, SDRATTR_EDGELINE1DELTA ); - if( !pItem ) - pItem = &pPool->GetDefaultItem( SDRATTR_EDGELINE1DELTA ); - SetMetricValue(*m_xMtrFldLine1, static_cast<const SdrMetricItem*>(pItem)->GetValue(), eUnit); - m_xMtrFldLine1->save_value(); + SetMetricValueAndSave(rAttrs, *m_xMtrFldLine1, SDRATTR_EDGELINE1DELTA); // SdrEdgeLine2DeltaItem - pItem = GetItem( *rAttrs, SDRATTR_EDGELINE2DELTA ); - if( !pItem ) - pItem = &pPool->GetDefaultItem( SDRATTR_EDGELINE2DELTA ); - SetMetricValue(*m_xMtrFldLine2, static_cast<const SdrMetricItem*>(pItem)->GetValue(), eUnit); - m_xMtrFldLine2->save_value(); + SetMetricValueAndSave(rAttrs, *m_xMtrFldLine2, SDRATTR_EDGELINE2DELTA); // SdrEdgeLine3DeltaItem - pItem = GetItem( *rAttrs, SDRATTR_EDGELINE3DELTA ); - if( !pItem ) - pItem = &pPool->GetDefaultItem( SDRATTR_EDGELINE3DELTA ); - SetMetricValue(*m_xMtrFldLine3, static_cast<const SdrMetricItem*>(pItem)->GetValue(), eUnit); - m_xMtrFldLine3->save_value(); + SetMetricValueAndSave(rAttrs, *m_xMtrFldLine3, SDRATTR_EDGELINE3DELTA); // SdrEdgeLineDeltaAnzItem pItem = GetItem( *rAttrs, SDRATTR_EDGELINEDELTACOUNT ); if( !pItem ) - pItem = &pPool->GetDefaultItem( SDRATTR_EDGELINEDELTACOUNT ); - switch (static_cast<const SdrEdgeLineDeltaCountItem*>(pItem)->GetValue()) + pItem = &pPool->GetUserOrPoolDefaultItem( SDRATTR_EDGELINEDELTACOUNT ); + switch (pItem->StaticWhichCast(SDRATTR_EDGELINEDELTACOUNT).GetValue()) { case 0: m_xFtLine1->set_sensitive(false); @@ -207,9 +187,9 @@ void SvxConnectionPage::Reset( const SfxItemSet* rAttrs ) // SdrEdgeKindItem pItem = GetItem( *rAttrs, SDRATTR_EDGEKIND ); if( !pItem ) - pItem = &pPool->GetDefaultItem( SDRATTR_EDGEKIND ); + pItem = &pPool->GetUserOrPoolDefaultItem( SDRATTR_EDGEKIND ); m_xLbType->set_active( - sal::static_int_cast<sal_uInt16>(static_cast<const SdrEdgeKindItem*>(pItem)->GetValue())); + sal::static_int_cast<sal_uInt16>(pItem->StaticWhichCast(SDRATTR_EDGEKIND).GetValue())); m_xLbType->save_value(); } @@ -394,8 +374,8 @@ void SvxConnectionPage::FillTypeLB() const SfxItemPool* pPool = rOutAttrs.GetPool(); if( !pItem ) - pItem = &pPool->GetDefaultItem( SDRATTR_EDGEKIND ); - const SdrEdgeKindItem* pEdgeKindItem = static_cast<const SdrEdgeKindItem*>(pItem); + pItem = &pPool->GetUserOrPoolDefaultItem( SDRATTR_EDGEKIND ); + const SdrEdgeKindItem* pEdgeKindItem = &pItem->StaticWhichCast(SDRATTR_EDGEKIND); const sal_uInt16 nCount = pEdgeKindItem->GetValueCount(); for (sal_uInt16 i = 0; i < nCount; i++) { diff --git a/cui/source/tabpages/grfpage.cxx b/cui/source/tabpages/grfpage.cxx index 726b09647bc1..9e96fdbb603c 100644 --- a/cui/source/tabpages/grfpage.cxx +++ b/cui/source/tabpages/grfpage.cxx @@ -32,6 +32,7 @@ #include <svx/svxids.hrc> #include <strings.hrc> #include <vcl/fieldvalues.hxx> +#include <vcl/outdev.hxx> #include <vcl/settings.hxx> #include <vcl/svapp.hxx> #include <svtools/unitconv.hxx> @@ -39,6 +40,7 @@ #include <basegfx/matrix/b2dhommatrix.hxx> #include <basegfx/polygon/b2dpolygontools.hxx> #include <o3tl/unit_conversion.hxx> +#include <officecfg/Office/Common.hxx> constexpr auto CM_1_TO_TWIP = o3tl::convert(1, o3tl::Length::cm, o3tl::Length::twip); // 567 @@ -54,9 +56,10 @@ static int lcl_GetValue(const weld::MetricSpinButton& rMetric, FieldUnit eUnit) SvxGrfCropPage::SvxGrfCropPage(weld::Container* pPage, weld::DialogController* pController, const SfxItemSet &rSet) : SfxTabPage(pPage, pController, "cui/ui/croppage.ui", "CropPage", &rSet) - , nOldWidth(0) - , nOldHeight(0) - , bSetOrigSize(false) + , m_nOldWidth(0) + , m_nOldHeight(0) + , m_bSetOrigSize(false) + , m_aPreferredDPI(0) , m_xCropFrame(m_xBuilder->weld_widget("cropframe")) , m_xZoomConstRB(m_xBuilder->weld_radio_button("keepscale")) , m_xSizeConstRB(m_xBuilder->weld_radio_button("keepsize")) @@ -73,6 +76,7 @@ SvxGrfCropPage::SvxGrfCropPage(weld::Container* pPage, weld::DialogController* p , m_xOrigSizeGrid(m_xBuilder->weld_widget("origsizegrid")) , m_xOrigSizeFT(m_xBuilder->weld_label("origsizeft")) , m_xOrigSizePB(m_xBuilder->weld_button("origsize")) + , m_xUncropPB(m_xBuilder->weld_button("uncrop")) , m_xExampleWN(new weld::CustomWeld(*m_xBuilder, "preview", m_aExampleWN)) { SetExchangeSupport(); @@ -102,6 +106,7 @@ SvxGrfCropPage::SvxGrfCropPage(weld::Container* pPage, weld::DialogController* p m_xBottomMF->connect_value_changed( aLk ); m_xOrigSizePB->connect_clicked(LINK(this, SvxGrfCropPage, OrigSizeHdl)); + m_xUncropPB->connect_clicked(LINK(this, SvxGrfCropPage, UncropHdl)); } SvxGrfCropPage::~SvxGrfCropPage() @@ -119,7 +124,7 @@ void SvxGrfCropPage::Reset( const SfxItemSet *rSet ) const SfxPoolItem* pItem; const SfxItemPool& rPool = *rSet->GetPool(); - if(SfxItemState::SET == rSet->GetItemState( rPool.GetWhich( + if(SfxItemState::SET == rSet->GetItemState( rPool.GetWhichIDFromSlotID( SID_ATTR_GRAF_KEEP_ZOOM ), true, &pItem )) { if( static_cast<const SfxBoolItem*>(pItem)->GetValue() ) @@ -129,7 +134,7 @@ void SvxGrfCropPage::Reset( const SfxItemSet *rSet ) m_xZoomConstRB->save_state(); } - sal_uInt16 nW = rPool.GetWhich( SID_ATTR_GRAF_CROP ); + sal_uInt16 nW = rPool.GetWhichIDFromSlotID( SID_ATTR_GRAF_CROP ); if( SfxItemState::SET == rSet->GetItemState( nW, true, &pItem)) { FieldUnit eUnit = MapToFieldUnit( rSet->GetPool()->GetMetric( nW )); @@ -159,55 +164,54 @@ void SvxGrfCropPage::Reset( const SfxItemSet *rSet ) m_xTopMF->save_value(); m_xBottomMF->save_value(); - nW = rPool.GetWhich( SID_ATTR_PAGE_SIZE ); + nW = rPool.GetWhichIDFromSlotID( SID_ATTR_PAGE_SIZE ); if ( SfxItemState::SET == rSet->GetItemState( nW, false, &pItem ) ) { // orientation and size from the PageItem FieldUnit eUnit = MapToFieldUnit( rSet->GetPool()->GetMetric( nW )); - aPageSize = static_cast<const SvxSizeItem*>(pItem)->GetSize(); + m_aPageSize = static_cast<const SvxSizeItem*>(pItem)->GetSize(); auto nMin = m_xWidthMF->normalize( 23 ); - auto nMax = m_xHeightMF->normalize(aPageSize.Height()); + auto nMax = m_xHeightMF->normalize(m_aPageSize.Height()); m_xHeightMF->set_range(nMin, nMax, eUnit); - nMax = m_xWidthMF->normalize(aPageSize.Width()); + nMax = m_xWidthMF->normalize(m_aPageSize.Width()); m_xWidthMF->set_range(nMin, nMax, eUnit); } else { - aPageSize = OutputDevice::LogicToLogic( + m_aPageSize = OutputDevice::LogicToLogic( Size( CM_1_TO_TWIP, CM_1_TO_TWIP ), MapMode( MapUnit::MapTwip ), MapMode( rSet->GetPool()->GetMetric( nW ) ) ); } bool bFound = false; - if( SfxItemState::SET == rSet->GetItemState( SID_ATTR_GRAF_GRAPHIC, false, &pItem ) ) + if( const SvxBrushItem* pGraphicItem = rSet->GetItemIfSet( SID_ATTR_GRAF_GRAPHIC, false ) ) { OUString referer; - SfxStringItem const * it = static_cast<SfxStringItem const *>( - rSet->GetItem(SID_REFERER)); + SfxStringItem const * it = rSet->GetItem(SID_REFERER); if (it != nullptr) { referer = it->GetValue(); } - const Graphic* pGrf = static_cast<const SvxBrushItem*>(pItem)->GetGraphic(referer); + const Graphic* pGrf = pGraphicItem->GetGraphic(referer); if( pGrf ) { - aOrigSize = GetGrfOrigSize( *pGrf ); - if (pGrf->GetType() == GraphicType::Bitmap && aOrigSize.Width() && aOrigSize.Height()) + m_aOrigSize = GetGrfOrigSize( *pGrf ); + if (pGrf->GetType() == GraphicType::Bitmap && m_aOrigSize.Width() && m_aOrigSize.Height()) { - aOrigPixelSize = pGrf->GetSizePixel(); + m_aOrigPixelSize = pGrf->GetSizePixel(); } - if( aOrigSize.Width() && aOrigSize.Height() ) + if( m_aOrigSize.Width() && m_aOrigSize.Height() ) { CalcMinMaxBorder(); m_aExampleWN.SetGraphic( *pGrf ); - m_aExampleWN.SetFrameSize( aOrigSize ); + m_aExampleWN.SetFrameSize( m_aOrigSize ); bFound = true; - if( !static_cast<const SvxBrushItem*>(pItem)->GetGraphicLink().isEmpty() ) - aGraphicName = static_cast<const SvxBrushItem*>(pItem)->GetGraphicLink(); + if( !pGraphicItem->GetGraphicLink().isEmpty() ) + m_aGraphicName = pGraphicItem->GetGraphicLink(); } } } @@ -223,21 +227,21 @@ bool SvxGrfCropPage::FillItemSet(SfxItemSet *rSet) if( m_xWidthMF->get_value_changed_from_saved() || m_xHeightMF->get_value_changed_from_saved() ) { - sal_uInt16 nW = rPool.GetWhich( SID_ATTR_GRAF_FRMSIZE ); + constexpr TypedWhichId<SvxSizeItem> nW = SID_ATTR_GRAF_FRMSIZE; FieldUnit eUnit = MapToFieldUnit( rSet->GetPool()->GetMetric( nW )); std::shared_ptr<SvxSizeItem> aSz(std::make_shared<SvxSizeItem>(nW)); // size could already have been set from another page const SfxItemSet* pExSet = GetDialogExampleSet(); - const SfxPoolItem* pItem = nullptr; - if( pExSet && SfxItemState::SET ==pExSet->GetItemState( nW, false, &pItem ) ) + const SvxSizeItem* pSizeItem = nullptr; + if( pExSet && (pSizeItem = pExSet->GetItemIfSet( nW, false )) ) { - aSz.reset(static_cast< SvxSizeItem*>(pItem->Clone())); + aSz.reset(pSizeItem->Clone()); } else { - aSz.reset(static_cast< SvxSizeItem*>(GetItemSet().Get(nW).Clone())); + aSz.reset(GetItemSet().Get(nW).Clone()); } Size aTmpSz( aSz->GetSize() ); @@ -251,16 +255,16 @@ bool SvxGrfCropPage::FillItemSet(SfxItemSet *rSet) bModified |= nullptr != rSet->Put( *aSz ); - if( bSetOrigSize ) + if (m_bSetOrigSize) { - bModified |= nullptr != rSet->Put( SvxSizeItem( rPool.GetWhich( + bModified |= nullptr != rSet->Put( SvxSizeItem( rPool.GetWhichIDFromSlotID( SID_ATTR_GRAF_FRMSIZE_PERCENT ), Size( 0, 0 )) ); } } if( m_xLeftMF->get_value_changed_from_saved() || m_xRightMF->get_value_changed_from_saved() || m_xTopMF->get_value_changed_from_saved() || m_xBottomMF->get_value_changed_from_saved() ) { - sal_uInt16 nW = rPool.GetWhich( SID_ATTR_GRAF_CROP ); + sal_uInt16 nW = rPool.GetWhichIDFromSlotID( SID_ATTR_GRAF_CROP ); FieldUnit eUnit = MapToFieldUnit( rSet->GetPool()->GetMetric( nW )); std::unique_ptr<SvxGrfCrop> pNew(static_cast<SvxGrfCrop*>(rSet->Get( nW ).Clone())); @@ -268,12 +272,12 @@ bool SvxGrfCropPage::FillItemSet(SfxItemSet *rSet) pNew->SetRight( lcl_GetValue( *m_xRightMF, eUnit ) ); pNew->SetTop( lcl_GetValue( *m_xTopMF, eUnit ) ); pNew->SetBottom( lcl_GetValue( *m_xBottomMF, eUnit ) ); - bModified |= nullptr != rSet->Put( *pNew ); + bModified |= nullptr != rSet->Put( std::move(pNew) ); } if( m_xZoomConstRB->get_state_changed_from_saved() ) { - bModified |= nullptr != rSet->Put( SfxBoolItem( rPool.GetWhich( + bModified |= nullptr != rSet->Put( SfxBoolItem( rPool.GetWhichIDFromSlotID( SID_ATTR_GRAF_KEEP_ZOOM), m_xZoomConstRB->get_active() ) ); } @@ -287,19 +291,23 @@ void SvxGrfCropPage::ActivatePage(const SfxItemSet& rSet) DBG_ASSERT( pPool, "Where is the pool?" ); #endif - bSetOrigSize = false; + auto& aProperties = getAdditionalProperties(); + auto aIterator = aProperties.find("PreferredDPI"); + if (aIterator != aProperties.end()) + m_aPreferredDPI = aIterator->second.get<sal_Int32>(); + + m_bSetOrigSize = false; // Size Size aSize; - const SfxPoolItem* pItem; - if( SfxItemState::SET == rSet.GetItemState( SID_ATTR_GRAF_FRMSIZE, false, &pItem ) ) - aSize = static_cast<const SvxSizeItem*>(pItem)->GetSize(); + if( const SvxSizeItem* pFrmSizeItem = rSet.GetItemIfSet( SID_ATTR_GRAF_FRMSIZE, false ) ) + aSize = pFrmSizeItem->GetSize(); - nOldWidth = aSize.Width(); - nOldHeight = aSize.Height(); + m_nOldWidth = aSize.Width(); + m_nOldHeight = aSize.Height(); - auto nWidth = m_xWidthMF->normalize(nOldWidth); - auto nHeight = m_xHeightMF->normalize(nOldHeight); + auto nWidth = m_xWidthMF->normalize(m_nOldWidth); + auto nHeight = m_xHeightMF->normalize(m_nOldHeight); if (nWidth != m_xWidthMF->get_value(FieldUnit::TWIP)) m_xWidthMF->set_value(nWidth, FieldUnit::TWIP); @@ -309,29 +317,27 @@ void SvxGrfCropPage::ActivatePage(const SfxItemSet& rSet) m_xHeightMF->set_value(nHeight, FieldUnit::TWIP); m_xHeightMF->save_value(); - if( SfxItemState::SET == rSet.GetItemState( SID_ATTR_GRAF_GRAPHIC, false, &pItem ) ) + if( const SvxBrushItem* pBrushItem = rSet.GetItemIfSet( SID_ATTR_GRAF_GRAPHIC, false ) ) { - const SvxBrushItem& rBrush = *static_cast<const SvxBrushItem*>(pItem); - if( !rBrush.GetGraphicLink().isEmpty() && - aGraphicName != rBrush.GetGraphicLink() ) - aGraphicName = rBrush.GetGraphicLink(); + if( !pBrushItem->GetGraphicLink().isEmpty() && + m_aGraphicName != pBrushItem->GetGraphicLink() ) + m_aGraphicName = pBrushItem->GetGraphicLink(); OUString referer; - SfxStringItem const * it = static_cast<SfxStringItem const *>( - rSet.GetItem(SID_REFERER)); + SfxStringItem const * it = rSet.GetItem(SID_REFERER); if (it != nullptr) { referer = it->GetValue(); } - const Graphic* pGrf = rBrush.GetGraphic(referer); + const Graphic* pGrf = pBrushItem->GetGraphic(referer); if( pGrf ) { m_aExampleWN.SetGraphic( *pGrf ); - aOrigSize = GetGrfOrigSize( *pGrf ); - if (pGrf->GetType() == GraphicType::Bitmap && aOrigSize.Width() > 1 && aOrigSize.Height() > 1) { - aOrigPixelSize = pGrf->GetSizePixel(); + m_aOrigSize = GetGrfOrigSize( *pGrf ); + if (pGrf->GetType() == GraphicType::Bitmap && m_aOrigSize.Width() > 1 && m_aOrigSize.Height() > 1) { + m_aOrigPixelSize = pGrf->GetSizePixel(); } - m_aExampleWN.SetFrameSize(aOrigSize); - GraphicHasChanged( aOrigSize.Width() && aOrigSize.Height() ); + m_aExampleWN.SetFrameSize(m_aOrigSize); + GraphicHasChanged( m_aOrigSize.Width() && m_aOrigSize.Height() ); CalcMinMaxBorder(); } else @@ -356,7 +362,7 @@ IMPL_LINK( SvxGrfCropPage, ZoomHdl, weld::MetricSpinButton&, rField, void ) { SfxItemPool* pPool = GetItemSet().GetPool(); DBG_ASSERT( pPool, "Where is the pool?" ); - FieldUnit eUnit = MapToFieldUnit( pPool->GetMetric( pPool->GetWhich( + FieldUnit eUnit = MapToFieldUnit( pPool->GetMetric( pPool->GetWhichIDFromSlotID( SID_ATTR_GRAF_CROP ) ) ); if (&rField == m_xWidthZoomMF.get()) @@ -364,7 +370,7 @@ IMPL_LINK( SvxGrfCropPage, ZoomHdl, weld::MetricSpinButton&, rField, void ) tools::Long nLRBorders = lcl_GetValue(*m_xLeftMF, eUnit) +lcl_GetValue(*m_xRightMF, eUnit); m_xWidthMF->set_value( m_xWidthMF->normalize( - ((aOrigSize.Width() - nLRBorders) * rField.get_value(FieldUnit::NONE))/100), + ((m_aOrigSize.Width() - nLRBorders) * rField.get_value(FieldUnit::NONE))/100), eUnit); } else @@ -372,7 +378,7 @@ IMPL_LINK( SvxGrfCropPage, ZoomHdl, weld::MetricSpinButton&, rField, void ) tools::Long nULBorders = lcl_GetValue(*m_xTopMF, eUnit) +lcl_GetValue(*m_xBottomMF, eUnit); m_xHeightMF->set_value( m_xHeightMF->normalize( - ((aOrigSize.Height() - nULBorders ) * rField.get_value(FieldUnit::NONE))/100) , + ((m_aOrigSize.Height() - nULBorders ) * rField.get_value(FieldUnit::NONE))/100) , eUnit ); } } @@ -385,7 +391,7 @@ IMPL_LINK( SvxGrfCropPage, SizeHdl, weld::MetricSpinButton&, rField, void ) { SfxItemPool* pPool = GetItemSet().GetPool(); DBG_ASSERT( pPool, "Where is the pool?" ); - FieldUnit eUnit = MapToFieldUnit( pPool->GetMetric( pPool->GetWhich( + FieldUnit eUnit = MapToFieldUnit( pPool->GetMetric( pPool->GetWhichIDFromSlotID( SID_ATTR_GRAF_CROP ) ) ); Size aSize( lcl_GetValue(*m_xWidthMF, eUnit), @@ -393,7 +399,7 @@ IMPL_LINK( SvxGrfCropPage, SizeHdl, weld::MetricSpinButton&, rField, void ) if(&rField == m_xWidthMF.get()) { - tools::Long nWidth = aOrigSize.Width() - + tools::Long nWidth = m_aOrigSize.Width() - ( lcl_GetValue(*m_xLeftMF, eUnit) + lcl_GetValue(*m_xRightMF, eUnit) ); if(!nWidth) @@ -403,7 +409,7 @@ IMPL_LINK( SvxGrfCropPage, SizeHdl, weld::MetricSpinButton&, rField, void ) } else { - tools::Long nHeight = aOrigSize.Height() - + tools::Long nHeight = m_aOrigSize.Height() - ( lcl_GetValue(*m_xTopMF, eUnit) + lcl_GetValue(*m_xBottomMF, eUnit)); if(!nHeight) @@ -421,7 +427,7 @@ IMPL_LINK( SvxGrfCropPage, CropModifyHdl, weld::MetricSpinButton&, rField, void { SfxItemPool* pPool = GetItemSet().GetPool(); DBG_ASSERT( pPool, "Where is the pool?" ); - FieldUnit eUnit = MapToFieldUnit( pPool->GetMetric( pPool->GetWhich( + FieldUnit eUnit = MapToFieldUnit( pPool->GetMetric( pPool->GetWhichIDFromSlotID( SID_ATTR_GRAF_CROP ) ) ); bool bZoom = m_xZoomConstRB->get_active(); @@ -430,19 +436,19 @@ IMPL_LINK( SvxGrfCropPage, CropModifyHdl, weld::MetricSpinButton&, rField, void tools::Long nLeft = lcl_GetValue( *m_xLeftMF, eUnit ); tools::Long nRight = lcl_GetValue( *m_xRightMF, eUnit ); tools::Long nWidthZoom = static_cast<tools::Long>(m_xWidthZoomMF->get_value(FieldUnit::NONE)); - if (bZoom && nWidthZoom != 0 && ( ( ( aOrigSize.Width() - (nLeft + nRight )) * nWidthZoom ) - / 100 >= aPageSize.Width() ) ) + if (bZoom && nWidthZoom != 0 && ( ( ( m_aOrigSize.Width() - (nLeft + nRight )) * nWidthZoom ) + / 100 >= m_aPageSize.Width() ) ) { if (&rField == m_xLeftMF.get()) { - nLeft = aOrigSize.Width() - - ( aPageSize.Width() * 100 / nWidthZoom + nRight ); + nLeft = m_aOrigSize.Width() - + ( m_aPageSize.Width() * 100 / nWidthZoom + nRight ); m_xLeftMF->set_value( m_xLeftMF->normalize( nLeft ), eUnit ); } else { - nRight = aOrigSize.Width() - - ( aPageSize.Width() * 100 / nWidthZoom + nLeft ); + nRight = m_aOrigSize.Width() - + ( m_aPageSize.Width() * 100 / nWidthZoom + nLeft ); m_xRightMF->set_value( m_xRightMF->normalize( nRight ), eUnit ); } } @@ -467,20 +473,20 @@ IMPL_LINK( SvxGrfCropPage, CropModifyHdl, weld::MetricSpinButton&, rField, void tools::Long nTop = lcl_GetValue( *m_xTopMF, eUnit ); tools::Long nBottom = lcl_GetValue( *m_xBottomMF, eUnit ); tools::Long nHeightZoom = static_cast<tools::Long>(m_xHeightZoomMF->get_value(FieldUnit::NONE)); - if(bZoom && ( ( ( aOrigSize.Height() - (nTop + nBottom )) * nHeightZoom) - / 100 >= aPageSize.Height())) + if(bZoom && ( ( ( m_aOrigSize.Height() - (nTop + nBottom )) * nHeightZoom) + / 100 >= m_aPageSize.Height())) { assert(nHeightZoom && "div-by-zero"); if(&rField == m_xTopMF.get()) { - nTop = aOrigSize.Height() - - ( aPageSize.Height() * 100 / nHeightZoom + nBottom); + nTop = m_aOrigSize.Height() - + ( m_aPageSize.Height() * 100 / nHeightZoom + nBottom); m_xTopMF->set_value( m_xWidthMF->normalize( nTop ), eUnit ); } else { - nBottom = aOrigSize.Height() - - ( aPageSize.Height() * 100 / nHeightZoom + nTop); + nBottom = m_aOrigSize.Height() - + ( m_aPageSize.Height() * 100 / nHeightZoom + nTop); m_xBottomMF->set_value( m_xWidthMF->normalize( nBottom ), eUnit ); } } @@ -506,21 +512,47 @@ IMPL_LINK_NOARG(SvxGrfCropPage, OrigSizeHdl, weld::Button&, void) { SfxItemPool* pPool = GetItemSet().GetPool(); DBG_ASSERT( pPool, "Where is the pool?" ); - FieldUnit eUnit = MapToFieldUnit( pPool->GetMetric( pPool->GetWhich( + FieldUnit eUnit = MapToFieldUnit( pPool->GetMetric( pPool->GetWhichIDFromSlotID( SID_ATTR_GRAF_CROP ) ) ); - tools::Long nWidth = aOrigSize.Width() - + tools::Long nWidth = m_aOrigSize.Width() - lcl_GetValue( *m_xLeftMF, eUnit ) - lcl_GetValue( *m_xRightMF, eUnit ); m_xWidthMF->set_value( m_xWidthMF->normalize( nWidth ), eUnit ); - tools::Long nHeight = aOrigSize.Height() - + tools::Long nHeight = m_aOrigSize.Height() - lcl_GetValue( *m_xTopMF, eUnit ) - lcl_GetValue( *m_xBottomMF, eUnit ); m_xHeightMF->set_value( m_xHeightMF->normalize( nHeight ), eUnit ); m_xWidthZoomMF->set_value(100, FieldUnit::NONE); m_xHeightZoomMF->set_value(100, FieldUnit::NONE); - bSetOrigSize = true; + m_bSetOrigSize = true; } + +/*-------------------------------------------------------------------- + description: reset crop + --------------------------------------------------------------------*/ + +IMPL_LINK_NOARG(SvxGrfCropPage, UncropHdl, weld::Button&, void) +{ + SfxItemPool* pPool = GetItemSet().GetPool(); + DBG_ASSERT( pPool, "Where is the pool?" ); + + m_xLeftMF->set_value(0, FieldUnit::NONE); + m_xRightMF->set_value(0, FieldUnit::NONE); + m_xTopMF->set_value(0, FieldUnit::NONE); + m_xBottomMF->set_value(0, FieldUnit::NONE); + + m_aExampleWN.SetLeft(0); + m_aExampleWN.SetRight(0); + m_aExampleWN.SetTop(0); + m_aExampleWN.SetBottom(0); + + m_aExampleWN.Invalidate(); + CalcMinMaxBorder(); + +} + + /*-------------------------------------------------------------------- description: compute scale --------------------------------------------------------------------*/ @@ -529,7 +561,7 @@ void SvxGrfCropPage::CalcZoom() { SfxItemPool* pPool = GetItemSet().GetPool(); DBG_ASSERT( pPool, "Where is the pool?" ); - FieldUnit eUnit = MapToFieldUnit( pPool->GetMetric( pPool->GetWhich( + FieldUnit eUnit = MapToFieldUnit( pPool->GetMetric( pPool->GetWhichIDFromSlotID( SID_ATTR_GRAF_CROP ) ) ); tools::Long nWidth = lcl_GetValue( *m_xWidthMF, eUnit ); @@ -540,10 +572,10 @@ void SvxGrfCropPage::CalcZoom() lcl_GetValue( *m_xBottomMF, eUnit ); sal_uInt16 nZoom = 0; tools::Long nDen; - if( (nDen = aOrigSize.Width() - nLRBorders) > 0) + if( (nDen = m_aOrigSize.Width() - nLRBorders) > 0) nZoom = static_cast<sal_uInt16>((( nWidth * 1000 / nDen )+5)/10); m_xWidthZoomMF->set_value(nZoom, FieldUnit::NONE); - if( (nDen = aOrigSize.Height() - nULBorders) > 0) + if( (nDen = m_aOrigSize.Height() - nULBorders) > 0) nZoom = static_cast<sal_uInt16>((( nHeight * 1000 / nDen )+5)/10); else nZoom = 0; @@ -558,10 +590,10 @@ void SvxGrfCropPage::CalcMinMaxBorder() { SfxItemPool* pPool = GetItemSet().GetPool(); DBG_ASSERT( pPool, "Where is the pool?" ); - FieldUnit eUnit = MapToFieldUnit( pPool->GetMetric( pPool->GetWhich( + FieldUnit eUnit = MapToFieldUnit( pPool->GetMetric( pPool->GetWhichIDFromSlotID( SID_ATTR_GRAF_CROP ) ) ); tools::Long nR = lcl_GetValue(*m_xRightMF, eUnit ); - tools::Long nMinWidth = (aOrigSize.Width() * 10) /11; + tools::Long nMinWidth = (m_aOrigSize.Width() * 10) /11; tools::Long nMin = nMinWidth - (nR >= 0 ? nR : 0); m_xLeftMF->set_max( m_xLeftMF->normalize(nMin), eUnit ); @@ -570,7 +602,7 @@ void SvxGrfCropPage::CalcMinMaxBorder() m_xRightMF->set_max( m_xRightMF->normalize(nMin), eUnit ); tools::Long nUp = lcl_GetValue( *m_xTopMF, eUnit ); - tools::Long nMinHeight = (aOrigSize.Height() * 10) /11; + tools::Long nMinHeight = (m_aOrigSize.Height() * 10) /11; nMin = nMinHeight - (nUp >= 0 ? nUp : 0); m_xBottomMF->set_max( m_xBottomMF->normalize(nMin), eUnit ); @@ -589,19 +621,19 @@ void SvxGrfCropPage::GraphicHasChanged( bool bFound ) { SfxItemPool* pPool = GetItemSet().GetPool(); DBG_ASSERT( pPool, "Where is the pool?" ); - FieldUnit eUnit = MapToFieldUnit( pPool->GetMetric( pPool->GetWhich( + FieldUnit eUnit = MapToFieldUnit( pPool->GetMetric( pPool->GetWhichIDFromSlotID( SID_ATTR_GRAF_CROP ) )); - sal_Int64 nSpin = m_xLeftMF->normalize(aOrigSize.Width()) / 20; - nSpin = vcl::ConvertValue( nSpin, aOrigSize.Width(), 0, + sal_Int64 nSpin = m_xLeftMF->normalize(m_aOrigSize.Width()) / 20; + nSpin = vcl::ConvertValue( nSpin, m_aOrigSize.Width(), 0, eUnit, m_xLeftMF->get_unit()); // if the margin is too big, it is set to 1/3 on both pages tools::Long nR = lcl_GetValue( *m_xRightMF, eUnit ); tools::Long nL = lcl_GetValue( *m_xLeftMF, eUnit ); - if((nL + nR) < - aOrigSize.Width()) + if((nL + nR) < - m_aOrigSize.Width()) { - tools::Long nVal = aOrigSize.Width() / -3; + tools::Long nVal = m_aOrigSize.Width() / -3; m_xRightMF->set_value( m_xRightMF->normalize( nVal ), eUnit ); m_xLeftMF->set_value( m_xLeftMF->normalize( nVal ), eUnit ); m_aExampleWN.SetLeft(nVal); @@ -609,9 +641,9 @@ void SvxGrfCropPage::GraphicHasChanged( bool bFound ) } tools::Long nUp = lcl_GetValue(*m_xTopMF, eUnit ); tools::Long nLow = lcl_GetValue(*m_xBottomMF, eUnit ); - if((nUp + nLow) < - aOrigSize.Height()) + if((nUp + nLow) < - m_aOrigSize.Height()) { - tools::Long nVal = aOrigSize.Height() / -3; + tools::Long nVal = m_aOrigSize.Height() / -3; m_xTopMF->set_value( m_xTopMF->normalize( nVal ), eUnit ); m_xBottomMF->set_value( m_xBottomMF->normalize( nVal ), eUnit ); m_aExampleWN.SetTop(nVal); @@ -620,8 +652,8 @@ void SvxGrfCropPage::GraphicHasChanged( bool bFound ) m_xLeftMF->set_increments(nSpin, nSpin * 10, FieldUnit::NONE); m_xRightMF->set_increments(nSpin, nSpin * 10, FieldUnit::NONE); - nSpin = m_xTopMF->normalize(aOrigSize.Height()) / 20; - nSpin = vcl::ConvertValue( nSpin, aOrigSize.Width(), 0, + nSpin = m_xTopMF->normalize(m_aOrigSize.Height()) / 20; + nSpin = vcl::ConvertValue( nSpin, m_aOrigSize.Width(), 0, eUnit, m_xLeftMF->get_unit() ); m_xTopMF->set_increments(nSpin, nSpin * 10, FieldUnit::NONE); m_xBottomMF->set_increments(nSpin, nSpin * 10, FieldUnit::NONE); @@ -638,26 +670,27 @@ void SvxGrfCropPage::GraphicHasChanged( bool bFound ) xFld->set_digits(m_xWidthMF->get_digits()); xFld->set_max(INT_MAX - 1, FieldUnit::NONE); - xFld->set_value(xFld->normalize(aOrigSize.Width()), eUnit); + xFld->set_value(xFld->normalize(m_aOrigSize.Width()), eUnit); sTemp = xFld->get_text(); - xFld->set_value(xFld->normalize(aOrigSize.Height()), eUnit); + xFld->set_value(xFld->normalize(m_aOrigSize.Height()), eUnit); // multiplication sign (U+00D7) sTemp += u"\u00D7" + xFld->get_text(); } - if ( aOrigPixelSize.Width() && aOrigPixelSize.Height() ) { - sal_Int32 ax = 0.5 + aOrigPixelSize.Width() / - o3tl::convert<double>(aOrigSize.Width(), o3tl::Length::twip, + if ( m_aOrigPixelSize.Width() && m_aOrigPixelSize.Height() ) { + sal_Int32 ax = 0.5 + m_aOrigPixelSize.Width() / + o3tl::convert<double>(m_aOrigSize.Width(), o3tl::Length::twip, o3tl::Length::in); - sal_Int32 ay = 0.5 + aOrigPixelSize.Height() / - o3tl::convert<double>(aOrigSize.Height(), o3tl::Length::twip, + sal_Int32 ay = 0.5 + m_aOrigPixelSize.Height() / + o3tl::convert<double>(m_aOrigSize.Height(), o3tl::Length::twip, o3tl::Length::in); OUString sPPI = OUString::number(ax); if (abs(ax - ay) > 1) { sPPI += u"\u00D7" + OUString::number(ay); } - sTemp += " " + CuiResId(RID_SVXSTR_PPI).replaceAll("%1", sPPI); + sTemp += " " + CuiResId(RID_CUISTR_PPI).replaceAll("%1", sPPI); } + sTemp += "\n" + OUString::number(m_aOrigPixelSize.Width()) + u"\u00D7" + OUString::number(m_aOrigPixelSize.Height()) + " px"; m_xOrigSizeFT->set_label(sTemp); } @@ -670,13 +703,27 @@ void SvxGrfCropPage::GraphicHasChanged( bool bFound ) Size SvxGrfCropPage::GetGrfOrigSize(const Graphic& rGrf) { - const MapMode aMapTwip( MapUnit::MapTwip ); - Size aSize( rGrf.GetPrefSize() ); - if( MapUnit::MapPixel == rGrf.GetPrefMapMode().GetMapUnit() ) - aSize = Application::GetDefaultDevice()->PixelToLogic(aSize, aMapTwip); + Size aSize; + + if (m_aPreferredDPI > 0) + { + Size aPixelSize = rGrf.GetSizePixel(); + double fWidth = aPixelSize.Width() / double(m_aPreferredDPI); + double fHeight = aPixelSize.Height() / double(m_aPreferredDPI); + fWidth = o3tl::convert(fWidth, o3tl::Length::in, o3tl::Length::twip); + fHeight = o3tl::convert(fHeight, o3tl::Length::in, o3tl::Length::twip); + aSize = Size(fWidth, fHeight); + } else - aSize = OutputDevice::LogicToLogic( aSize, - rGrf.GetPrefMapMode(), aMapTwip ); + { + const MapMode aMapTwip( MapUnit::MapTwip ); + aSize = rGrf.GetPrefSize(); + if( MapUnit::MapPixel == rGrf.GetPrefMapMode().GetMapUnit() ) + aSize = Application::GetDefaultDevice()->PixelToLogic(aSize, aMapTwip); + else + aSize = OutputDevice::LogicToLogic( aSize, + rGrf.GetPrefMapMode(), aMapTwip ); + } return aSize; } @@ -728,7 +775,7 @@ void SvxCropExample::Paint(vcl::RenderContext& rRenderContext, const ::tools::Re // the former used XOR paint. const Color aColA(SvtOptionsDrawinglayer::GetStripeColorA().getBColor()); const Color aColB(SvtOptionsDrawinglayer::GetStripeColorB().getBColor()); - const double fStripeLength(SvtOptionsDrawinglayer::GetStripeLength()); + const double fStripeLength(officecfg::Office::Common::Drawinglayer::StripeLength::get()); const basegfx::B2DVector aDashVector(rRenderContext.GetInverseViewTransformation() * basegfx::B2DVector(fStripeLength, 0.0)); const double fLogicDashLength(aDashVector.getX()); diff --git a/cui/source/tabpages/labdlg.cxx b/cui/source/tabpages/labdlg.cxx index 867a31885af7..c5661586472c 100644 --- a/cui/source/tabpages/labdlg.cxx +++ b/cui/source/tabpages/labdlg.cxx @@ -255,9 +255,9 @@ void SvxCaptionTabPage::Reset( const SfxItemSet* ) SetMetricValue( *m_xMF_SPACING, nGap, eUnit ); nGap = m_xMF_SPACING->get_value(FieldUnit::NONE); - nCaptionType = static_cast<const SdrCaptionTypeItem&>( rOutAttrs.Get( GetWhich( SDRATTR_CAPTIONTYPE ) ) ).GetValue(); + nCaptionType = rOutAttrs.Get( GetWhich( SDRATTR_CAPTIONTYPE ) ).GetValue(); bFitLineLen = static_cast<const SfxBoolItem&>( rOutAttrs.Get( GetWhich( SDRATTR_CAPTIONFITLINELEN ) ) ).GetValue(); - nEscDir = static_cast<const SdrCaptionEscDirItem&>( rOutAttrs.Get( GetWhich( SDRATTR_CAPTIONESCDIR ) ) ).GetValue(); + nEscDir = rOutAttrs.Get( GetWhich( SDRATTR_CAPTIONESCDIR ) ).GetValue(); bEscRel = static_cast<const SfxBoolItem&>( rOutAttrs.Get( GetWhich( SDRATTR_CAPTIONESCISREL ) ) ).GetValue(); // special treatment!!! XXX @@ -474,7 +474,7 @@ SvxCaptionTabDialog::SvxCaptionTabDialog(weld::Window* pParent, const SdrView* p SvxCaptionTabPage::GetRanges ); } -void SvxCaptionTabDialog::PageCreated(const OString& rId, SfxTabPage &rPage) +void SvxCaptionTabDialog::PageCreated(const OUString& rId, SfxTabPage &rPage) { if (rId == "RID_SVXPAGE_POSITION_SIZE") { diff --git a/cui/source/tabpages/macroass.cxx b/cui/source/tabpages/macroass.cxx index 94143e310ebd..baff7c87b0ae 100644 --- a/cui/source/tabpages/macroass.cxx +++ b/cui/source/tabpages/macroass.cxx @@ -19,6 +19,7 @@ #include <macroass.hxx> #include <o3tl/safeint.hxx> +#include <o3tl/string_view.hxx> #include <osl/diagnose.h> #include <comphelper/string.hxx> #include <comphelper/processfactory.hxx> @@ -70,7 +71,7 @@ static OUString ConvertToUIName_Impl( SvxMacro const *pMacro ) OUString aEntry = aName.getToken( nCount-1, '.' ); if ( nCount > 2 ) { - aEntry += "(" + aName.getToken( 0, '.' ) + "." + aName.getToken( nCount-2, '.' ) + ")"; + aEntry += OUString::Concat("(") + o3tl::getToken(aName, 0, '.' ) + "." + o3tl::getToken(aName, nCount-2, '.' ) + ")"; } return aEntry; } @@ -155,9 +156,14 @@ bool SfxMacroTabPage::FillItemSet( SfxItemSet* rSet ) SvxMacroItem aItem( GetWhich( aPageRg[0] ) ); const_cast<SvxMacroTableDtor&>(aItem.GetMacroTable()) = aTbl; - const SfxPoolItem* pItem; - if( SfxItemState::SET != GetItemSet().GetItemState( aItem.Which(), true, &pItem ) - || aItem != *static_cast<const SvxMacroItem*>(pItem) ) + const SfxPoolItem* pItem = nullptr; + SfxItemState eState = GetItemSet().GetItemState(aItem.Which(), true, &pItem); + if (eState == SfxItemState::DEFAULT && aTbl.empty()) + { + // Don't touch the item set if there was no input and our table is empty. + return false; + } + if (SfxItemState::SET != eState || aItem != *static_cast<const SvxMacroItem*>(pItem)) { rSet->Put( aItem ); return true; @@ -178,11 +184,12 @@ void SfxMacroTabPage::ActivatePage( const SfxItemSet& ) void SfxMacroTabPage::PageCreated(const SfxAllItemSet& aSet) { - const SfxPoolItem* pEventsItem; - if( !mpImpl->m_bGotEvents && SfxItemState::SET == aSet.GetItemState( SID_EVENTCONFIG, true, &pEventsItem ) ) + if( mpImpl->m_bGotEvents ) + return; + if( const SfxEventNamesItem* pEventsItem = aSet.GetItemIfSet( SID_EVENTCONFIG ) ) { mpImpl->m_bGotEvents = true; - const SfxEventNamesList& rList = static_cast<const SfxEventNamesItem*>(pEventsItem)->GetEvents(); + const SfxEventNamesList& rList = pEventsItem->GetEvents(); for ( size_t nNo = 0, nCnt = rList.size(); nNo < nCnt; ++nNo ) { const SfxEventName &rOwn = rList.at(nNo); @@ -197,11 +204,11 @@ void SfxMacroTabPage::Reset( const SfxItemSet* rSet ) if( SfxItemState::SET == rSet->GetItemState( GetWhich( aPageRg[0] ), true, &pItem )) aTbl = static_cast<const SvxMacroItem*>(pItem)->GetMacroTable(); - const SfxPoolItem* pEventsItem; - if( !mpImpl->m_bGotEvents && SfxItemState::SET == rSet->GetItemState( SID_EVENTCONFIG, true, &pEventsItem ) ) + const SfxEventNamesItem* pEventsItem; + if( !mpImpl->m_bGotEvents && (pEventsItem = rSet->GetItemIfSet( SID_EVENTCONFIG ) ) ) { mpImpl->m_bGotEvents = true; - const SfxEventNamesList& rList = static_cast<const SfxEventNamesItem*>(pEventsItem)->GetEvents(); + const SfxEventNamesList& rList = pEventsItem->GetEvents(); for ( size_t nNo = 0, nCnt = rList.size(); nNo < nCnt; ++nNo ) { const SfxEventName &rOwn = rList.at(nNo); @@ -214,7 +221,10 @@ void SfxMacroTabPage::Reset( const SfxItemSet* rSet ) weld::TreeView& rListBox = mpImpl->m_xEventLB->GetListBox(); std::unique_ptr<weld::TreeIter> xIter(rListBox.make_iterator()); if (rListBox.get_iter_first(*xIter)) + { rListBox.set_cursor(*xIter); + EnableButtons(); + } } bool SfxMacroTabPage::IsReadOnly() const diff --git a/cui/source/tabpages/measure.cxx b/cui/source/tabpages/measure.cxx index 027f52a77d18..8c7b4dcd8351 100644 --- a/cui/source/tabpages/measure.cxx +++ b/cui/source/tabpages/measure.cxx @@ -54,7 +54,7 @@ SvxMeasureDialog::SvxMeasureDialog(weld::Window* pParent, const SfxItemSet& rInA xPage->Construct(); SetTabPage(std::move(xPage)); - m_xDialog->set_title(CuiResId(RID_SVXSTR_DIMENSION_LINE)); + m_xDialog->set_title(CuiResId(RID_CUISTR_DIMENSION_LINE)); } /************************************************************************* @@ -110,11 +110,16 @@ SvxMeasurePage::SvxMeasurePage(weld::Container* pPage, weld::DialogController* p m_xTsbAutoPosH->connect_toggled(LINK(this, SvxMeasurePage, ClickAutoPosHdl_Impl)); Link<weld::MetricSpinButton&,void> aLink(LINK(this, SvxMeasurePage, ChangeAttrEditHdl_Impl)); + m_xMtrFldLineDist->set_range(-10000, 10000, FieldUnit::MM); m_xMtrFldLineDist->connect_value_changed(aLink); m_xMtrFldHelplineOverhang->connect_value_changed(aLink); + m_xMtrFldHelplineOverhang->set_range(-10000, 10000, FieldUnit::MM); m_xMtrFldHelplineDist->connect_value_changed(aLink); + m_xMtrFldHelplineDist->set_range(-10000, 10000, FieldUnit::MM); m_xMtrFldHelpline1Len->connect_value_changed(aLink); + m_xMtrFldHelpline1Len->set_range(-10000, 10000, FieldUnit::MM); m_xMtrFldHelpline2Len->connect_value_changed(aLink); + m_xMtrFldHelpline2Len->set_range(-10000, 10000, FieldUnit::MM); m_xMtrFldDecimalPlaces->connect_value_changed(LINK(this, SvxMeasurePage, ChangeAttrSpinHdl_Impl)); m_xTsbBelowRefEdge->connect_toggled(LINK(this, SvxMeasurePage, ChangeAttrClickHdl_Impl)); m_xTsbParallel->connect_toggled( LINK( this, SvxMeasurePage, ChangeAttrClickHdl_Impl)); @@ -144,14 +149,14 @@ void SvxMeasurePage::Reset( const SfxItemSet* rAttrs ) // SdrMeasureLineDistItem if( pItem == nullptr ) - pItem = &pPool->GetDefaultItem( SDRATTR_MEASURELINEDIST ); + pItem = &pPool->GetUserOrPoolDefaultItem( SDRATTR_MEASURELINEDIST ); SetMetricValue(*m_xMtrFldLineDist, static_cast<const SdrMetricItem*>(pItem)->GetValue(), eUnit); m_xMtrFldLineDist->save_value(); // SdrMeasureHelplineOverhangItem pItem = GetItem( *rAttrs, SDRATTR_MEASUREHELPLINEOVERHANG ); if( pItem == nullptr ) - pItem = &pPool->GetDefaultItem( SDRATTR_MEASUREHELPLINEOVERHANG ); + pItem = &pPool->GetUserOrPoolDefaultItem( SDRATTR_MEASUREHELPLINEOVERHANG ); SetMetricValue(*m_xMtrFldHelplineOverhang, static_cast<const SdrMetricItem*>(pItem)->GetValue(), eUnit); m_xMtrFldHelplineOverhang->save_value(); @@ -159,7 +164,7 @@ void SvxMeasurePage::Reset( const SfxItemSet* rAttrs ) // SdrMeasureHelplineDistItem pItem = GetItem( *rAttrs, SDRATTR_MEASUREHELPLINEDIST ); if( pItem == nullptr ) - pItem = &pPool->GetDefaultItem( SDRATTR_MEASUREHELPLINEDIST ); + pItem = &pPool->GetUserOrPoolDefaultItem( SDRATTR_MEASUREHELPLINEDIST ); SetMetricValue(*m_xMtrFldHelplineDist, static_cast<const SdrMetricItem*>(pItem)->GetValue(), eUnit); m_xMtrFldHelplineDist->save_value(); @@ -167,7 +172,7 @@ void SvxMeasurePage::Reset( const SfxItemSet* rAttrs ) // SdrMeasureHelpline1LenItem pItem = GetItem( *rAttrs, SDRATTR_MEASUREHELPLINE1LEN ); if( pItem == nullptr ) - pItem = &pPool->GetDefaultItem( SDRATTR_MEASUREHELPLINE1LEN ); + pItem = &pPool->GetUserOrPoolDefaultItem( SDRATTR_MEASUREHELPLINE1LEN ); SetMetricValue(*m_xMtrFldHelpline1Len, static_cast<const SdrMetricItem*>(pItem)->GetValue(), eUnit); m_xMtrFldHelpline1Len->save_value(); @@ -175,13 +180,13 @@ void SvxMeasurePage::Reset( const SfxItemSet* rAttrs ) // SdrMeasureHelpline2LenItem pItem = GetItem( *rAttrs, SDRATTR_MEASUREHELPLINE2LEN ); if( pItem == nullptr ) - pItem = &pPool->GetDefaultItem( SDRATTR_MEASUREHELPLINE2LEN ); + pItem = &pPool->GetUserOrPoolDefaultItem( SDRATTR_MEASUREHELPLINE2LEN ); SetMetricValue(*m_xMtrFldHelpline2Len, static_cast<const SdrMetricItem*>(pItem)->GetValue(), eUnit); m_xMtrFldHelpline2Len->save_value(); // SdrMeasureBelowRefEdgeItem - if( rAttrs->GetItemState( SDRATTR_MEASUREBELOWREFEDGE ) != SfxItemState::DONTCARE ) + if( rAttrs->GetItemState( SDRATTR_MEASUREBELOWREFEDGE ) != SfxItemState::INVALID ) { m_xTsbBelowRefEdge->set_state( rAttrs->Get( SDRATTR_MEASUREBELOWREFEDGE ). GetValue() ? TRISTATE_TRUE : TRISTATE_FALSE ); @@ -195,14 +200,14 @@ void SvxMeasurePage::Reset( const SfxItemSet* rAttrs ) // SdrMeasureDecimalPlacesItem pItem = GetItem( *rAttrs, SDRATTR_MEASUREDECIMALPLACES ); if( pItem == nullptr ) - pItem = &pPool->GetDefaultItem( SDRATTR_MEASUREDECIMALPLACES ); + pItem = &pPool->GetUserOrPoolDefaultItem( SDRATTR_MEASUREDECIMALPLACES ); m_xMtrFldDecimalPlaces->set_value( static_cast<const SdrMeasureDecimalPlacesItem*>(pItem)->GetValue()); m_xMtrFldDecimalPlaces->save_value(); // SdrMeasureTextRota90Item // Attention: negate ! - if( rAttrs->GetItemState( SDRATTR_MEASURETEXTROTA90 ) != SfxItemState::DONTCARE ) + if( rAttrs->GetItemState( SDRATTR_MEASURETEXTROTA90 ) != SfxItemState::INVALID ) { m_xTsbParallel->set_state( rAttrs->Get( SDRATTR_MEASURETEXTROTA90 ). GetValue() ? TRISTATE_FALSE : TRISTATE_TRUE ); @@ -214,7 +219,7 @@ void SvxMeasurePage::Reset( const SfxItemSet* rAttrs ) m_xTsbParallel->save_state(); // SdrMeasureShowUnitItem - if( rAttrs->GetItemState( SDRATTR_MEASURESHOWUNIT ) != SfxItemState::DONTCARE ) + if( rAttrs->GetItemState( SDRATTR_MEASURESHOWUNIT ) != SfxItemState::INVALID ) { m_xTsbShowUnit->set_state( rAttrs->Get( SDRATTR_MEASURESHOWUNIT ). GetValue() ? TRISTATE_TRUE : TRISTATE_FALSE ); @@ -226,7 +231,7 @@ void SvxMeasurePage::Reset( const SfxItemSet* rAttrs ) m_xTsbShowUnit->save_state(); // SdrMeasureUnitItem - if( rAttrs->GetItemState( SDRATTR_MEASUREUNIT ) != SfxItemState::DONTCARE ) + if( rAttrs->GetItemState( SDRATTR_MEASUREUNIT ) != SfxItemState::INVALID ) { tools::Long nFieldUnit = static_cast<tools::Long>(rAttrs->Get( SDRATTR_MEASUREUNIT ).GetValue()); @@ -246,12 +251,12 @@ void SvxMeasurePage::Reset( const SfxItemSet* rAttrs ) m_xLbUnit->save_value(); // Position - if ( rAttrs->GetItemState( SDRATTR_MEASURETEXTVPOS ) != SfxItemState::DONTCARE ) + if ( rAttrs->GetItemState( SDRATTR_MEASURETEXTVPOS ) != SfxItemState::INVALID ) { css::drawing::MeasureTextVertPos eVPos = rAttrs->Get( SDRATTR_MEASURETEXTVPOS ).GetValue(); { - if ( rAttrs->GetItemState( SDRATTR_MEASURETEXTHPOS ) != SfxItemState::DONTCARE ) + if ( rAttrs->GetItemState( SDRATTR_MEASURETEXTHPOS ) != SfxItemState::INVALID ) { css::drawing::MeasureTextHorzPos eHPos = rAttrs->Get( SDRATTR_MEASURETEXTHPOS ).GetValue(); @@ -460,7 +465,7 @@ bool SvxMeasurePage::FillItemSet( SfxItemSet* rAttrs) if (m_xTsbAutoPosV->get_state() == TRISTATE_TRUE) eVPos = css::drawing::MeasureTextVertPos_AUTO; - if ( rAttrs->GetItemState( SDRATTR_MEASURETEXTVPOS ) != SfxItemState::DONTCARE ) + if ( rAttrs->GetItemState( SDRATTR_MEASURETEXTVPOS ) != SfxItemState::INVALID ) { css::drawing::MeasureTextVertPos eOldVPos = rOutAttrs.Get(SDRATTR_MEASURETEXTVPOS).GetValue(); if( eOldVPos != eVPos ) @@ -475,7 +480,7 @@ bool SvxMeasurePage::FillItemSet( SfxItemSet* rAttrs) bModified = true; } - if ( rAttrs->GetItemState( SDRATTR_MEASURETEXTHPOS ) != SfxItemState::DONTCARE ) + if ( rAttrs->GetItemState( SDRATTR_MEASURETEXTHPOS ) != SfxItemState::INVALID ) { css::drawing::MeasureTextHorzPos eOldHPos = rOutAttrs.Get( SDRATTR_MEASURETEXTHPOS ).GetValue(); if( eOldHPos != eHPos ) diff --git a/cui/source/tabpages/numfmt.cxx b/cui/source/tabpages/numfmt.cxx index 219972d75edc..afaa43f0dc1c 100644 --- a/cui/source/tabpages/numfmt.cxx +++ b/cui/source/tabpages/numfmt.cxx @@ -24,8 +24,6 @@ #include <svl/intitem.hxx> #include <sfx2/objsh.hxx> #include <vcl/outdev.hxx> -#include <vcl/svapp.hxx> -#include <vcl/settings.hxx> #include <i18nlangtag/lang.h> #include <svx/svxids.hrc> #include <svtools/colorcfg.hxx> @@ -113,9 +111,19 @@ void SvxNumberPreview::NotifyChange( const OUString& rPrevStr, mnPos = -1; } } - svtools::ColorConfig aColorConfig; - Color aWindowTextColor( aColorConfig.GetColorValue( svtools::FONTCOLOR ).nColor ); - aPrevCol = pColor ? *pColor : aWindowTextColor; + if (pColor) + aPrevCol = *pColor; + else + { + svtools::ColorConfig aColorConfig; + Color aFgColor = aColorConfig.GetColorValue(svtools::FONTCOLOR, false).nColor; + if (aFgColor == COL_AUTO) + { + Color aBgColor = aColorConfig.GetColorValue(svtools::DOCCOLOR).nColor; + aFgColor = aBgColor.IsDark() ? COL_WHITE : COL_BLACK; + } + aPrevCol = aFgColor; + } Invalidate(); } @@ -135,8 +143,13 @@ void SvxNumberPreview::Paint(vcl::RenderContext& rRenderContext, const ::tools:: rRenderContext.Push(vcl::PushFlags::ALL); svtools::ColorConfig aColorConfig; - rRenderContext.SetTextColor(aColorConfig.GetColorValue(svtools::FONTCOLOR).nColor); - rRenderContext.SetBackground(aColorConfig.GetColorValue(svtools::DOCCOLOR).nColor); + Color aBgColor = aColorConfig.GetColorValue(svtools::DOCCOLOR).nColor; + Color aFgColor = aColorConfig.GetColorValue(svtools::FONTCOLOR, false).nColor; + if (aFgColor == COL_AUTO) + aFgColor = aBgColor.IsDark() ? COL_WHITE : COL_BLACK; + rRenderContext.SetBackground(aBgColor); + rRenderContext.SetTextColor(aFgColor); + rRenderContext.Erase(); vcl::Font aDrawFont = rRenderContext.GetFont(); Size aSzWnd(GetOutputSizePixel()); @@ -189,7 +202,7 @@ SvxNumberFormatTabPage::SvxNumberFormatTabPage(weld::Container* pPage, weld::Dia , nInitFormat(std::numeric_limits<sal_uInt32>::max()) , m_nLbFormatSelPosEdComment(SELPOS_NONE) , bLegacyAutomaticCurrency(false) - , sAutomaticLangEntry(CuiResId(RID_SVXSTR_AUTO_ENTRY)) + , sAutomaticLangEntry(CuiResId(RID_CUISTR_AUTO_ENTRY)) , m_xFtCategory(m_xBuilder->weld_label("categoryft")) , m_xLbCategory(m_xBuilder->weld_tree_view("categorylb")) , m_xFtFormat(m_xBuilder->weld_label("formatft")) @@ -217,7 +230,7 @@ SvxNumberFormatTabPage::SvxNumberFormatTabPage(weld::Container* pPage, weld::Dia , m_xLbLanguage(new SvxLanguageBox(m_xBuilder->weld_combo_box("languagelb"))) , m_xWndPreview(new weld::CustomWeld(*m_xBuilder, "preview", m_aWndPreview)) { - for (size_t i = 0; i < SAL_N_ELEMENTS(NUM_CATEGORIES); ++i) + for (size_t i = 0; i < std::size(NUM_CATEGORIES); ++i) m_xLbCategory->append_text(CuiResId(NUM_CATEGORIES[i])); auto nWidth = m_xLbCategory->get_approximate_digit_width() * 22; @@ -362,14 +375,9 @@ void SvxNumberFormatTabPage::Reset( const SfxItemSet* rSet ) double nValDouble = 0; OUString aValString; - SfxItemState eState = rSet->GetItemState( GetWhich( SID_ATTR_NUMBERFORMAT_NOLANGUAGE ),true,&pItem); - - if(eState==SfxItemState::SET) + if(const SfxBoolItem* pBoolLangItem = rSet->GetItemIfSet( SID_ATTR_NUMBERFORMAT_NOLANGUAGE )) { - const SfxBoolItem* pBoolLangItem = static_cast<const SfxBoolItem*>( - GetItem( *rSet, SID_ATTR_NUMBERFORMAT_NOLANGUAGE)); - - if(pBoolLangItem!=nullptr && pBoolLangItem->GetValue()) + if(pBoolLangItem->GetValue()) { HideLanguage(); } @@ -380,7 +388,7 @@ void SvxNumberFormatTabPage::Reset( const SfxItemSet* rSet ) } - eState = rSet->GetItemState( GetWhich( SID_ATTR_NUMBERFORMAT_INFO ),true,&pItem); + SfxItemState eState = rSet->GetItemState( GetWhich( SID_ATTR_NUMBERFORMAT_INFO ),true,&pItem); if(eState==SfxItemState::SET) { @@ -404,8 +412,7 @@ void SvxNumberFormatTabPage::Reset( const SfxItemSet* rSet ) if(eState==SfxItemState::SET) { - const SfxBoolItem* pBoolItem = static_cast<const SfxBoolItem*>( - GetItem( *rSet, SID_ATTR_NUMBERFORMAT_ONE_AREA)); + const SfxBoolItem* pBoolItem = GetItem( *rSet, SID_ATTR_NUMBERFORMAT_ONE_AREA); if(pBoolItem!=nullptr) { @@ -413,12 +420,12 @@ void SvxNumberFormatTabPage::Reset( const SfxItemSet* rSet ) } } - eState = rSet->GetItemState( GetWhich( SID_ATTR_NUMBERFORMAT_SOURCE ) ); + eState = rSet->GetItemState( SID_ATTR_NUMBERFORMAT_SOURCE ); if ( eState == SfxItemState::SET ) { - const SfxBoolItem* pBoolItem = static_cast<const SfxBoolItem*>( - GetItem( *rSet, SID_ATTR_NUMBERFORMAT_SOURCE )); + const SfxBoolItem* pBoolItem = + GetItem( *rSet, SID_ATTR_NUMBERFORMAT_SOURCE ); if ( pBoolItem ) m_xCbSourceFormat->set_active(pBoolItem->GetValue()); else @@ -439,7 +446,7 @@ void SvxNumberFormatTabPage::Reset( const SfxItemSet* rSet ) eState = rSet->GetItemState( GetWhich( SID_ATTR_NUMBERFORMAT_VALUE ) ); - if ( SfxItemState::DONTCARE != eState ) + if ( SfxItemState::INVALID != eState ) pValFmtAttr = GetItem( *rSet, SID_ATTR_NUMBERFORMAT_VALUE ); eValType = pNumItem->GetValueType(); @@ -482,8 +489,7 @@ void SvxNumberFormatTabPage::Reset( const SfxItemSet* rSet ) bool bUseStarFormat = false; - SfxObjectShell* pDocSh = SfxObjectShell::Current(); - if ( pDocSh ) + if (SfxObjectShell* pDocSh = SfxObjectShell::Current()) { // is this a calc document Reference< XServiceInfo > xSI( pDocSh->GetModel(), UNO_QUERY ); @@ -514,10 +520,9 @@ void SvxNumberFormatTabPage::Reset( const SfxItemSet* rSet ) { SetCategory(nCatLbSelPos ); } - eState = rSet->GetItemState( GetWhich( SID_ATTR_NUMBERFORMAT_ADD_AUTO ) ); + eState = rSet->GetItemState( SID_ATTR_NUMBERFORMAT_ADD_AUTO ); if(SfxItemState::SET == eState) - pAutoEntryAttr = static_cast<const SfxBoolItem*>( - GetItem( *rSet, SID_ATTR_NUMBERFORMAT_ADD_AUTO )); + pAutoEntryAttr = GetItem( *rSet, SID_ATTR_NUMBERFORMAT_ADD_AUTO ); // no_NO is an alias for nb_NO and normally isn't listed, we need it for // backwards compatibility, but only if the format passed is of // LanguageType no_NO. @@ -636,7 +641,7 @@ void SvxNumberFormatTabPage::EnableBySourceFormat_Impl() #*------------------------------------------------------------------------ #* #* Class: SvxNumberFormatTabPage -#* Function: Hides the language settings: +#* Function: Hides the Languages and Locales: #* Input: sal_Bool nFlag #* Output: --- #* @@ -667,7 +672,7 @@ bool SvxNumberFormatTabPage::FillItemSet( SfxItemSet* rCoreAttrs ) if ( bDataChanged ) { const SfxItemSet& rMyItemSet = GetItemSet(); - sal_uInt16 nWhich = GetWhich( SID_ATTR_NUMBERFORMAT_VALUE ); + TypedWhichId<SfxUInt32Item> nWhich = GetWhich( SID_ATTR_NUMBERFORMAT_VALUE ); SfxItemState eItemState = rMyItemSet.GetItemState( nWhich, false ); // OK chosen - Is format code input entered already taken over? @@ -722,11 +727,8 @@ bool SvxNumberFormatTabPage::FillItemSet( SfxItemSet* rCoreAttrs ) else { SfxObjectShell* pDocSh = SfxObjectShell::Current(); - DBG_ASSERT( pDocSh, "DocShell not found!" ); - - - if ( pDocSh ) + if (pDocSh) pDocSh->PutItem( *pNumItem ); } } @@ -736,12 +738,11 @@ bool SvxNumberFormatTabPage::FillItemSet( SfxItemSet* rCoreAttrs ) if ( m_xCbSourceFormat->get_sensitive() ) { - sal_uInt16 _nWhich = GetWhich( SID_ATTR_NUMBERFORMAT_SOURCE ); - SfxItemState _eItemState = rMyItemSet.GetItemState( _nWhich, false ); - const SfxBoolItem* pBoolItem = static_cast<const SfxBoolItem*>( - GetItem( rMyItemSet, SID_ATTR_NUMBERFORMAT_SOURCE )); + SfxItemState _eItemState = rMyItemSet.GetItemState( SID_ATTR_NUMBERFORMAT_SOURCE, false ); + const SfxBoolItem* pBoolItem = + GetItem( rMyItemSet, SID_ATTR_NUMBERFORMAT_SOURCE ); bool bOld = pBoolItem && pBoolItem->GetValue(); - rCoreAttrs->Put( SfxBoolItem( _nWhich, m_xCbSourceFormat->get_active() ) ); + rCoreAttrs->Put( SfxBoolItem( SID_ATTR_NUMBERFORMAT_SOURCE, m_xCbSourceFormat->get_active() ) ); if ( !bDataChanged ) bDataChanged = (bOld != m_xCbSourceFormat->get_active() || _eItemState != SfxItemState::SET); @@ -940,7 +941,8 @@ void SvxNumberFormatTabPage::UpdateOptions_Impl( bool bCheckCatChange /*= sal_Fa m_xBtnNegRed->set_active( bNegRed ); if ( nCategory != CAT_SCIENTIFIC ) { - m_xBtnThousand->set_sensitive( nCategory != CAT_TIME ); + m_xBtnThousand->set_sensitive( nCategory != CAT_TIME + && !pNumFmtShell->IsNatNum12( theFormat ) ); m_xBtnThousand->set_active( bThousand && nCategory != CAT_TIME ); } break; @@ -1290,10 +1292,10 @@ IMPL_LINK( SvxNumberFormatTabPage, ClickHdl_Impl, weld::Button&, rIB, void) bool SvxNumberFormatTabPage::Click_Impl(const weld::Button& rIB) { - sal_uLong nReturn = 0; - constexpr sal_uLong nReturnChanged = 0x1; // THE boolean return value - constexpr sal_uLong nReturnAdded = 0x2; // temp: format added - constexpr sal_uLong nReturnOneArea = 0x4; // temp: one area but category changed => ignored + sal_uInt8 nReturn = 0; + constexpr sal_uInt8 nReturnChanged = 0x1; // THE boolean return value + constexpr sal_uInt8 nReturnAdded = 0x2; // temp: format added + constexpr sal_uInt8 nReturnOneArea = 0x4; // temp: one area but category changed => ignored if (&rIB == m_xIbAdd.get()) { // Also called from FillItemSet() if a temporary currency format has @@ -1674,6 +1676,16 @@ OUString SvxNumberFormatTabPage::GetExpColorString( } double fVal = fSvxNumValConst[i]; + // use lower number for long NatNum12 transliteration + if ( ( CAT_CURRENCY == nTmpCatPos || CAT_NUMBER == nTmpCatPos ) && + rFormatStr.indexOf("NatNum12") >= 0 ) + { + if ( CAT_CURRENCY == nTmpCatPos ) + fVal = 1.2; + else + fVal = 100; // show also title case for English: One Hundred + } + OUString aPreviewString; pNumFmtShell->MakePrevStringFromVal( rFormatStr, aPreviewString, rpPreviewColor, fVal ); return aPreviewString; diff --git a/cui/source/tabpages/numpages.cxx b/cui/source/tabpages/numpages.cxx index ade080a1436a..2d084a1cd9af 100644 --- a/cui/source/tabpages/numpages.cxx +++ b/cui/source/tabpages/numpages.cxx @@ -17,7 +17,6 @@ * the License at http://www.apache.org/licenses/LICENSE-2.0 . */ -#include <com/sun/star/text/HoriOrientation.hpp> #include <com/sun/star/text/VertOrientation.hpp> #include <numpages.hxx> @@ -29,6 +28,7 @@ #include <svl/eitem.hxx> #include <vcl/svapp.hxx> #include <svx/colorbox.hxx> +#include <svx/dlgutil.hxx> #include <svx/strarray.hxx> #include <svx/gallery.hxx> #include <editeng/brushitem.hxx> @@ -36,13 +36,14 @@ #include <sfx2/objsh.hxx> #include <vcl/graph.hxx> #include <vcl/settings.hxx> -#include <cui/cuicharmap.hxx> +#include <svx/cuicharmap.hxx> #include <editeng/flstitem.hxx> #include <svx/numvset.hxx> #include <sfx2/htmlmode.hxx> #include <unotools/pathoptions.hxx> #include <svtools/ctrltool.hxx> #include <svtools/unitconv.hxx> +#include <svtools/colorcfg.hxx> #include <com/sun/star/style/NumberingType.hpp> #include <com/sun/star/lang/XMultiServiceFactory.hpp> #include <com/sun/star/container/XIndexAccess.hpp> @@ -51,7 +52,10 @@ #include <com/sun/star/beans/PropertyValue.hpp> #include <comphelper/processfactory.hxx> #include <comphelper/propertyvalue.hxx> +#include <comphelper/lok.hxx> #include <svx/svxids.hrc> +#include <o3tl/string_view.hxx> +#include <officecfg/Office/Common.hxx> #include <algorithm> #include <memory> @@ -72,13 +76,14 @@ #include <o3tl/temporary.hxx> #include <osl/diagnose.h> +#include <bitmaps.hlst> + using namespace css; using namespace css::uno; using namespace css::beans; using namespace css::lang; using namespace css::text; using namespace css::container; -using namespace css::style; #define SHOW_NUMBERING 0 #define SHOW_BULLET 1 @@ -117,19 +122,6 @@ static SvxNumSettings_Impl* lcl_CreateNumSettingsPtr(const Sequence<PropertyValu return pNew; } -// the selection of bullets from the OpenSymbol -const sal_Unicode aBulletTypes[] = -{ - 0x2022, - 0x25cf, - 0xe00c, - 0xe00a, - 0x2794, - 0x27a2, - 0x2717, - 0x2714 -}; - // Is one of the masked formats set? static bool lcl_IsNumFmtSet(SvxNumRule const * pNum, sal_uInt16 nLevelMask) { @@ -144,7 +136,7 @@ static bool lcl_IsNumFmtSet(SvxNumRule const * pNum, sal_uInt16 nLevelMask) return bRet; } -static const vcl::Font& lcl_GetDefaultBulletFont() +static vcl::Font& lcl_GetDefaultBulletFont() { static vcl::Font aDefBulletFont = []() { @@ -227,20 +219,19 @@ bool SvxSingleNumPickTabPage::FillItemSet( SfxItemSet* rSet ) void SvxSingleNumPickTabPage::ActivatePage(const SfxItemSet& rSet) { - const SfxPoolItem* pItem; bPreset = false; bool bIsPreset = false; const SfxItemSet* pExampleSet = GetDialogExampleSet(); if(pExampleSet) { - if(SfxItemState::SET == pExampleSet->GetItemState(SID_PARAM_NUM_PRESET, false, &pItem)) - bIsPreset = static_cast<const SfxBoolItem*>(pItem)->GetValue(); - if(SfxItemState::SET == pExampleSet->GetItemState(SID_PARAM_CUR_NUM_LEVEL, false, &pItem)) - nActNumLvl = static_cast<const SfxUInt16Item*>(pItem)->GetValue(); + if(const SfxBoolItem* pPresetItem = pExampleSet->GetItemIfSet(SID_PARAM_NUM_PRESET, false)) + bIsPreset = pPresetItem->GetValue(); + if(const SfxUInt16Item* pLevelItem = pExampleSet->GetItemIfSet(SID_PARAM_CUR_NUM_LEVEL, false)) + nActNumLvl = pLevelItem->GetValue(); } - if(SfxItemState::SET == rSet.GetItemState(nNumItemId, false, &pItem)) + if(const SvxNumBulletItem* pNumItem = rSet.GetItemIfSet(nNumItemId, false)) { - pSaveNum.reset( new SvxNumRule(static_cast<const SvxNumBulletItem*>(pItem)->GetNumRule()) ); + pSaveNum.reset( new SvxNumRule(pNumItem->GetNumRule()) ); } if(pActNum && *pSaveNum != *pActNum) { @@ -274,12 +265,12 @@ void SvxSingleNumPickTabPage::Reset( const SfxItemSet* rSet ) SfxItemState eState = rSet->GetItemState(SID_ATTR_NUMBERING_RULE, false, &pItem); if(eState != SfxItemState::SET) { - nNumItemId = rSet->GetPool()->GetWhich(SID_ATTR_NUMBERING_RULE); + nNumItemId = rSet->GetPool()->GetWhichIDFromSlotID(SID_ATTR_NUMBERING_RULE); eState = rSet->GetItemState(nNumItemId, false, &pItem); if( eState != SfxItemState::SET ) { - pItem = &static_cast< const SvxNumBulletItem& >( rSet->Get( nNumItemId ) ); + pItem = & rSet->Get( nNumItemId ); eState = SfxItemState::SET; } } @@ -372,20 +363,19 @@ bool SvxBulletPickTabPage::FillItemSet( SfxItemSet* rSet ) void SvxBulletPickTabPage::ActivatePage(const SfxItemSet& rSet) { - const SfxPoolItem* pItem; bPreset = false; bool bIsPreset = false; const SfxItemSet* pExampleSet = GetDialogExampleSet(); if(pExampleSet) { - if(SfxItemState::SET == pExampleSet->GetItemState(SID_PARAM_NUM_PRESET, false, &pItem)) - bIsPreset = static_cast<const SfxBoolItem*>(pItem)->GetValue(); - if(SfxItemState::SET == pExampleSet->GetItemState(SID_PARAM_CUR_NUM_LEVEL, false, &pItem)) - nActNumLvl = static_cast<const SfxUInt16Item*>(pItem)->GetValue(); + if(const SfxBoolItem* pPresetItem = pExampleSet->GetItemIfSet(SID_PARAM_NUM_PRESET, false)) + bIsPreset = pPresetItem->GetValue(); + if(const SfxUInt16Item* pLevelItem = pExampleSet->GetItemIfSet(SID_PARAM_CUR_NUM_LEVEL, false)) + nActNumLvl = pLevelItem->GetValue(); } - if(SfxItemState::SET == rSet.GetItemState(nNumItemId, false, &pItem)) + if(const SvxNumBulletItem* pBulletItem = rSet.GetItemIfSet(nNumItemId, false)) { - pSaveNum.reset( new SvxNumRule(static_cast<const SvxNumBulletItem*>(pItem)->GetNumRule()) ); + pSaveNum.reset( new SvxNumRule(pBulletItem->GetNumRule()) ); } if(pActNum && *pSaveNum != *pActNum) { @@ -412,23 +402,20 @@ DeactivateRC SvxBulletPickTabPage::DeactivatePage(SfxItemSet *_pSet) void SvxBulletPickTabPage::Reset( const SfxItemSet* rSet ) { - const SfxPoolItem* pItem; // in Draw the item exists as WhichId, in Writer only as SlotId - SfxItemState eState = rSet->GetItemState(SID_ATTR_NUMBERING_RULE, false, &pItem); - if(eState != SfxItemState::SET) + const SvxNumBulletItem* pItem = rSet->GetItemIfSet(SID_ATTR_NUMBERING_RULE, false); + if(!pItem) { - nNumItemId = rSet->GetPool()->GetWhich(SID_ATTR_NUMBERING_RULE); - eState = rSet->GetItemState(nNumItemId, false, &pItem); + nNumItemId = rSet->GetPool()->GetWhichIDFromSlotID(SID_ATTR_NUMBERING_RULE); + pItem = rSet->GetItemIfSet(nNumItemId, false); - if( eState != SfxItemState::SET ) + if( !pItem ) { - pItem = &static_cast< const SvxNumBulletItem& >( rSet->Get( nNumItemId ) ); - eState = SfxItemState::SET; + pItem = & rSet->Get( nNumItemId ); } } - DBG_ASSERT(eState == SfxItemState::SET, "no item found!"); - pSaveNum.reset( new SvxNumRule(static_cast<const SvxNumBulletItem*>(pItem)->GetNumRule()) ); + pSaveNum.reset( new SvxNumRule(pItem->GetNumRule()) ); if(!pActNum) pActNum.reset( new SvxNumRule(*pSaveNum) ); @@ -443,8 +430,11 @@ IMPL_LINK_NOARG(SvxBulletPickTabPage, NumSelectHdl_Impl, ValueSet*, void) bPreset = false; bModified = true; - sal_Unicode cChar = aBulletTypes[m_xExamplesVS->GetSelectedItemId() - 1]; - const vcl::Font& rActBulletFont = lcl_GetDefaultBulletFont(); + sal_uInt16 nIndex = m_xExamplesVS->GetSelectedItemId() - 1; + sal_Unicode cChar = officecfg::Office::Common::BulletsNumbering::DefaultBullets::get()[nIndex].toChar(); + vcl::Font& rActBulletFont = lcl_GetDefaultBulletFont(); + rActBulletFont.SetFamilyName( + officecfg::Office::Common::BulletsNumbering::DefaultBulletsFonts::get()[nIndex]); sal_uInt16 nMask = 1; for(sal_uInt16 i = 0; i < pActNum->GetLevelCount(); i++) @@ -512,11 +502,14 @@ SvxNumPickTabPage::SvxNumPickTabPage(weld::Container* pPage, weld::DialogControl SvxNumSettingsArr_Impl& rItemArr = aNumSettingsArrays[ nItem ]; Reference<XIndexAccess> xLevel = aOutlineAccess.getConstArray()[nItem]; - for(sal_Int32 nLevel = 0; nLevel < xLevel->getCount() && nLevel < 5; nLevel++) + for(sal_Int32 nLevel = 0; nLevel < SVX_MAX_NUM; nLevel++) { - Any aValueAny = xLevel->getByIndex(nLevel); + // use the last locale-defined level for all remaining levels. + sal_Int32 nLocaleLevel = std::min(nLevel, xLevel->getCount() - 1); Sequence<PropertyValue> aLevelProps; - aValueAny >>= aLevelProps; + if (nLocaleLevel >= 0) + xLevel->getByIndex(nLocaleLevel) >>= aLevelProps; + SvxNumSettings_Impl* pNew = lcl_CreateNumSettingsPtr(aLevelProps); rItemArr.push_back( std::unique_ptr<SvxNumSettings_Impl>(pNew) ); } @@ -554,20 +547,19 @@ bool SvxNumPickTabPage::FillItemSet( SfxItemSet* rSet ) void SvxNumPickTabPage::ActivatePage(const SfxItemSet& rSet) { - const SfxPoolItem* pItem; bPreset = false; bool bIsPreset = false; const SfxItemSet* pExampleSet = GetDialogExampleSet(); if(pExampleSet) { - if(SfxItemState::SET == pExampleSet->GetItemState(SID_PARAM_NUM_PRESET, false, &pItem)) - bIsPreset = static_cast<const SfxBoolItem*>(pItem)->GetValue(); - if(SfxItemState::SET == pExampleSet->GetItemState(SID_PARAM_CUR_NUM_LEVEL, false, &pItem)) - nActNumLvl = static_cast<const SfxUInt16Item*>(pItem)->GetValue(); + if(const SfxBoolItem* pPresetItem = pExampleSet->GetItemIfSet(SID_PARAM_NUM_PRESET, false)) + bIsPreset = pPresetItem->GetValue(); + if(const SfxUInt16Item* pLevelItem = pExampleSet->GetItemIfSet(SID_PARAM_CUR_NUM_LEVEL, false)) + nActNumLvl = pLevelItem->GetValue(); } - if(SfxItemState::SET == rSet.GetItemState(nNumItemId, false, &pItem)) + if(const SvxNumBulletItem* pBulletItem = rSet.GetItemIfSet(nNumItemId, false)) { - pSaveNum.reset( new SvxNumRule(static_cast<const SvxNumBulletItem*>(pItem)->GetNumRule()) ); + pSaveNum.reset( new SvxNumRule(pBulletItem->GetNumRule()) ); } if(pActNum && *pSaveNum != *pActNum) { @@ -594,23 +586,19 @@ DeactivateRC SvxNumPickTabPage::DeactivatePage(SfxItemSet *_pSet) void SvxNumPickTabPage::Reset( const SfxItemSet* rSet ) { - const SfxPoolItem* pItem; // in Draw the item exists as WhichId, in Writer only as SlotId - SfxItemState eState = rSet->GetItemState(SID_ATTR_NUMBERING_RULE, false, &pItem); - if(eState != SfxItemState::SET) + const SvxNumBulletItem* pItem = rSet->GetItemIfSet(SID_ATTR_NUMBERING_RULE, false); + if(!pItem) { - nNumItemId = rSet->GetPool()->GetWhich(SID_ATTR_NUMBERING_RULE); - eState = rSet->GetItemState(nNumItemId, false, &pItem); + nNumItemId = rSet->GetPool()->GetWhichIDFromSlotID(SID_ATTR_NUMBERING_RULE); + pItem = rSet->GetItemIfSet(nNumItemId, false); - if( eState != SfxItemState::SET ) + if( !pItem ) { - pItem = &static_cast< const SvxNumBulletItem& >( rSet->Get( nNumItemId ) ); - eState = SfxItemState::SET; + pItem = & rSet->Get( nNumItemId ); } - } - DBG_ASSERT(eState == SfxItemState::SET, "no item found!"); - pSaveNum.reset( new SvxNumRule(static_cast<const SvxNumBulletItem*>(pItem)->GetNumRule()) ); + pSaveNum.reset( new SvxNumRule(pItem->GetNumRule()) ); if(!pActNum) pActNum.reset( new SvxNumRule(*pSaveNum) ); @@ -653,17 +641,18 @@ IMPL_LINK_NOARG(SvxNumPickTabPage, NumSelectHdl_Impl, ValueSet*, void) //search for the font if(!pList) { - SfxObjectShell* pCurDocShell = SfxObjectShell::Current(); - const SvxFontListItem* pFontListItem = - static_cast<const SvxFontListItem*>( pCurDocShell - ->GetItem( SID_ATTR_CHAR_FONTLIST )); - pList = pFontListItem ? pFontListItem->GetFontList() : nullptr; + if (SfxObjectShell* pCurDocShell = SfxObjectShell::Current()) + { + const SvxFontListItem* pFontListItem = + static_cast<const SvxFontListItem*>( pCurDocShell + ->GetItem( SID_ATTR_CHAR_FONTLIST )); + pList = pFontListItem ? pFontListItem->GetFontList() : nullptr; + } } if(pList && pList->IsAvailable( pLevelSettings->sBulletFont ) ) { - FontMetric aFontMetric = pList->Get( - pLevelSettings->sBulletFont,WEIGHT_NORMAL, ITALIC_NONE); - vcl::Font aFont(aFontMetric); + vcl::Font aFont(pList->Get( + pLevelSettings->sBulletFont,WEIGHT_NORMAL, ITALIC_NONE)); aFmt.SetBulletFont(&aFont); } else @@ -694,6 +683,11 @@ IMPL_LINK_NOARG(SvxNumPickTabPage, NumSelectHdl_Impl, ValueSet*, void) aFmt.SetIncludeUpperLevels(sal::static_int_cast< sal_uInt8 >(0 != nUpperLevelOrChar ? pActNum->GetLevelCount() : 1)); aFmt.SetCharFormatName(sNumCharFmtName); aFmt.SetBulletRelSize(100); + + // Completely ignore the Left/Right value provided by the locale outline definition, + // because this function doesn't actually modify the indents at all, + // and right-adjusted numbering definitely needs a different FirstLineIndent. + // #i93908# aFmt.SetListFormat(pLevelSettings->sPrefix, pLevelSettings->sSuffix, i); } @@ -736,7 +730,10 @@ SvxBitmapPickTabPage::SvxBitmapPickTabPage(weld::Container* pPage, weld::DialogC m_xExamplesVS->SetDoubleClickHdl(LINK(this, SvxBitmapPickTabPage, DoubleClickHdl_Impl)); m_xBtBrowseFile->connect_clicked(LINK(this, SvxBitmapPickTabPage, ClickAddBrowseHdl_Impl)); - eCoreUnit = rSet.GetPool()->GetMetric(rSet.GetPool()->GetWhich(SID_ATTR_NUMBERING_RULE)); + if(comphelper::LibreOfficeKit::isActive()) + m_xBtBrowseFile->hide(); + + eCoreUnit = rSet.GetPool()->GetMetric(rSet.GetPool()->GetWhichIDFromSlotID(SID_ATTR_NUMBERING_RULE)); // determine graphic name GalleryExplorer::FillObjList(GALLERY_THEME_BULLETS, aGrfNames); @@ -784,20 +781,19 @@ std::unique_ptr<SfxTabPage> SvxBitmapPickTabPage::Create(weld::Container* pPage, void SvxBitmapPickTabPage::ActivatePage(const SfxItemSet& rSet) { - const SfxPoolItem* pItem; bPreset = false; bool bIsPreset = false; const SfxItemSet* pExampleSet = GetDialogExampleSet(); if(pExampleSet) { - if(SfxItemState::SET == pExampleSet->GetItemState(SID_PARAM_NUM_PRESET, false, &pItem)) - bIsPreset = static_cast<const SfxBoolItem*>(pItem)->GetValue(); - if(SfxItemState::SET == pExampleSet->GetItemState(SID_PARAM_CUR_NUM_LEVEL, false, &pItem)) - nActNumLvl = static_cast<const SfxUInt16Item*>(pItem)->GetValue(); + if(const SfxBoolItem* pPresetItem = pExampleSet->GetItemIfSet(SID_PARAM_NUM_PRESET, false)) + bIsPreset = pPresetItem->GetValue(); + if(const SfxUInt16Item* pLevelItem = pExampleSet->GetItemIfSet(SID_PARAM_CUR_NUM_LEVEL, false)) + nActNumLvl = pLevelItem->GetValue(); } - if(SfxItemState::SET == rSet.GetItemState(nNumItemId, false, &pItem)) + if(const SvxNumBulletItem* pBulletItem = rSet.GetItemIfSet(nNumItemId, false)) { - pSaveNum.reset( new SvxNumRule(static_cast<const SvxNumBulletItem*>(pItem)->GetNumRule()) ); + pSaveNum.reset( new SvxNumRule(pBulletItem->GetNumRule()) ); } if(pActNum && *pSaveNum != *pActNum) { @@ -841,23 +837,21 @@ bool SvxBitmapPickTabPage::FillItemSet( SfxItemSet* rSet ) void SvxBitmapPickTabPage::Reset( const SfxItemSet* rSet ) { - const SfxPoolItem* pItem; // in Draw the item exists as WhichId, in Writer only as SlotId - SfxItemState eState = rSet->GetItemState(SID_ATTR_NUMBERING_RULE, false, &pItem); - if(eState != SfxItemState::SET) + const SvxNumBulletItem* pItem = rSet->GetItemIfSet(SID_ATTR_NUMBERING_RULE, false); + if(!pItem) { - nNumItemId = rSet->GetPool()->GetWhich(SID_ATTR_NUMBERING_RULE); - eState = rSet->GetItemState(nNumItemId, false, &pItem); + nNumItemId = rSet->GetPool()->GetWhichIDFromSlotID(SID_ATTR_NUMBERING_RULE); + pItem = rSet->GetItemIfSet(nNumItemId, false); - if( eState != SfxItemState::SET ) + if( !pItem ) { - pItem = &static_cast< const SvxNumBulletItem& >( rSet->Get( nNumItemId ) ); - eState = SfxItemState::SET; + pItem = & rSet->Get( nNumItemId ); } } - DBG_ASSERT(eState == SfxItemState::SET, "no item found!"); - pSaveNum.reset( new SvxNumRule(static_cast<const SvxNumBulletItem*>(pItem)->GetNumRule()) ); + DBG_ASSERT(pItem, "no item found!"); + pSaveNum.reset( new SvxNumRule(pItem->GetNumRule()) ); if(!pActNum) pActNum.reset( new SvxNumRule(*pSaveNum) ); @@ -912,12 +906,12 @@ IMPL_LINK_NOARG(SvxBitmapPickTabPage, ClickAddBrowseHdl_Impl, weld::Button&, voi { sfx2::FileDialogHelper aFileDialog(0, FileDialogFlags::NONE, GetFrameWeld()); aFileDialog.SetContext(sfx2::FileDialogHelper::BulletsAddImage); - aFileDialog.SetTitle(CuiResId(RID_SVXSTR_ADD_IMAGE)); + aFileDialog.SetTitle(CuiResId(RID_CUISTR_ADD_IMAGE)); if ( aFileDialog.Execute() != ERRCODE_NONE ) return; OUString aPath = SvtPathOptions().GetGalleryPath(); - OUString aPathToken = aPath.getToken( 1 , SEARCHPATH_DELIMITER ); + std::u16string_view aPathToken = o3tl::getToken(aPath, 1 , SEARCHPATH_DELIMITER ); OUString aUserImageURL = aFileDialog.GetPath(); @@ -928,7 +922,7 @@ IMPL_LINK_NOARG(SvxBitmapPickTabPage, ClickAddBrowseHdl_Impl, weld::Button&, voi else if (nPos<aUserImageURL.getLength()) aFileName = aUserImageURL.copy(nPos); - OUString aUserGalleryURL = aPathToken + "/" + aFileName; + OUString aUserGalleryURL = OUString::Concat(aPathToken) + "/" + aFileName; INetURLObject aURL( aUserImageURL ); DBG_ASSERT( aURL.GetProtocol() != INetProtocol::NotValid, "invalid URL" ); @@ -1021,6 +1015,8 @@ SvxNumOptionsTabPage::SvxNumOptionsTabPage(weld::Container* pPage, weld::DialogC , nBullet(0xff) , nActNumLvl(1) , nNumItemId(SID_ATTR_NUMBERING_RULE) + , m_aRatioTop(ConnectorType::Top) + , m_aRatioBottom(ConnectorType::Bottom) , m_xGrid(m_xBuilder->weld_widget("grid2")) , m_xLevelLB(m_xBuilder->weld_tree_view("levellb")) , m_xFmtLB(m_xBuilder->weld_combo_box("numfmtlb")) @@ -1038,6 +1034,7 @@ SvxNumOptionsTabPage::SvxNumOptionsTabPage(weld::Container* pPage, weld::DialogC , m_xBulRelSizeMF(m_xBuilder->weld_metric_spin_button("relsize", FieldUnit::PERCENT)) , m_xAllLevelFT(m_xBuilder->weld_label("sublevelsft")) , m_xAllLevelNF(m_xBuilder->weld_spin_button("sublevels")) + , m_xIsLegalCB(m_xBuilder->weld_check_button("islegal")) , m_xStartFT(m_xBuilder->weld_label("startatft")) , m_xStartED(m_xBuilder->weld_spin_button("startat")) , m_xBulletFT(m_xBuilder->weld_label("bulletft")) @@ -1049,6 +1046,9 @@ SvxNumOptionsTabPage::SvxNumOptionsTabPage(weld::Container* pPage, weld::DialogC , m_xHeightFT(m_xBuilder->weld_label("heightft")) , m_xHeightMF(m_xBuilder->weld_metric_spin_button("heightmf", FieldUnit::CM)) , m_xRatioCB(m_xBuilder->weld_check_button("keepratio")) + , m_xCbxScaleImg(m_xBuilder->weld_image("imRatio")) + , m_xImgRatioTop(new weld::CustomWeld(*m_xBuilder, "daRatioTop", m_aRatioTop)) + , m_xImgRatioBottom(new weld::CustomWeld(*m_xBuilder, "daRatioBottom", m_aRatioBottom)) , m_xOrientFT(m_xBuilder->weld_label("orientft")) , m_xOrientLB(m_xBuilder->weld_combo_box("orientlb")) , m_xAllLevelsFrame(m_xBuilder->weld_widget("levelsframe")) @@ -1060,6 +1060,18 @@ SvxNumOptionsTabPage::SvxNumOptionsTabPage(weld::Container* pPage, weld::DialogC m_xBulRelSizeMF->set_increments(5, 50, FieldUnit::PERCENT); SetExchangeSupport(); aActBulletFont = lcl_GetDefaultBulletFont(); + // vertical alignment = fill makes the drawingarea expand the associated spinedits so we have to size it here + const sal_Int16 aHeight + = static_cast<sal_Int16>(std::max(int(m_xRatioCB->get_preferred_size().getHeight() / 2 + - m_xWidthMF->get_preferred_size().getHeight() / 2), + 12)); + const sal_Int16 aWidth + = static_cast<sal_Int16>(m_xRatioCB->get_preferred_size().getWidth() / 2); + m_xImgRatioTop->set_size_request(aWidth, aHeight); + m_xImgRatioBottom->set_size_request(aWidth, aHeight); + //init needed for gtk3 + m_xCbxScaleImg->set_from_icon_name(m_xRatioCB->get_active() ? RID_SVXBMP_LOCKED + : RID_SVXBMP_UNLOCKED); m_xBulletPB->connect_clicked(LINK(this, SvxNumOptionsTabPage, BulletHdl_Impl)); m_xFmtLB->connect_changed(LINK(this, SvxNumOptionsTabPage, NumberTypeSelectHdl_Impl)); @@ -1075,6 +1087,7 @@ SvxNumOptionsTabPage::SvxNumOptionsTabPage(weld::Container* pPage, weld::DialogC m_xPrefixED->connect_changed(LINK(this, SvxNumOptionsTabPage, EditModifyHdl_Impl)); m_xSuffixED->connect_changed(LINK(this, SvxNumOptionsTabPage, EditModifyHdl_Impl)); m_xAllLevelNF->connect_value_changed(LINK(this,SvxNumOptionsTabPage, AllLevelHdl_Impl)); + m_xIsLegalCB->connect_toggled(LINK(this, SvxNumOptionsTabPage, IsLegalHdl_Impl)); m_xOrientLB->connect_changed(LINK(this, SvxNumOptionsTabPage, OrientHdl_Impl)); m_xSameLevelCB->connect_toggled(LINK(this, SvxNumOptionsTabPage, SameLevelHdl_Impl)); m_xBulRelSizeMF->connect_value_changed(LINK(this,SvxNumOptionsTabPage, BulRelSizeHdl_Impl)); @@ -1082,13 +1095,15 @@ SvxNumOptionsTabPage::SvxNumOptionsTabPage(weld::Container* pPage, weld::DialogC aInvalidateTimer.SetInvokeHandler(LINK(this, SvxNumOptionsTabPage, PreviewInvalidateHdl_Impl)); aInvalidateTimer.SetTimeout(50); - eCoreUnit = rSet.GetPool()->GetMetric(rSet.GetPool()->GetWhich(SID_ATTR_NUMBERING_RULE)); + eCoreUnit = rSet.GetPool()->GetMetric(rSet.GetPool()->GetWhichIDFromSlotID(SID_ATTR_NUMBERING_RULE)); // Fill ListBox with predefined / translated numbering types. sal_uInt32 nCount = SvxNumberingTypeTable::Count(); for (sal_uInt32 i = 0; i < nCount; ++i) { - m_xFmtLB->append(OUString::number(SvxNumberingTypeTable::GetValue(i)), SvxNumberingTypeTable::GetString(i)); + int nValue = SvxNumberingTypeTable::GetValue(i); + if (comphelper::LibreOfficeKit::isActive() && (nValue & SVX_NUM_BITMAP)) continue; + m_xFmtLB->append(OUString::number(nValue), SvxNumberingTypeTable::GetString(i)); } // Get advanced numbering types from the component. @@ -1136,19 +1151,18 @@ std::unique_ptr<SfxTabPage> SvxNumOptionsTabPage::Create(weld::Container* pPage, void SvxNumOptionsTabPage::ActivatePage(const SfxItemSet& rSet) { - const SfxPoolItem* pItem; const SfxItemSet* pExampleSet = GetDialogExampleSet(); sal_uInt16 nTmpNumLvl = 1; if(pExampleSet) { - if(SfxItemState::SET == pExampleSet->GetItemState(SID_PARAM_NUM_PRESET, false, &pItem)) - bPreset = static_cast<const SfxBoolItem*>(pItem)->GetValue(); - if(SfxItemState::SET == pExampleSet->GetItemState(SID_PARAM_CUR_NUM_LEVEL, false, &pItem)) - nTmpNumLvl = static_cast<const SfxUInt16Item*>(pItem)->GetValue(); + if(const SfxBoolItem* pPresetItem = pExampleSet->GetItemIfSet(SID_PARAM_NUM_PRESET, false)) + bPreset = pPresetItem->GetValue(); + if(const SfxUInt16Item* pLevelItem = pExampleSet->GetItemIfSet(SID_PARAM_CUR_NUM_LEVEL, false)) + nTmpNumLvl = pLevelItem->GetValue(); } - if(SfxItemState::SET == rSet.GetItemState(nNumItemId, false, &pItem)) + if(const SvxNumBulletItem* pBulletItem = rSet.GetItemIfSet(nNumItemId, false)) { - pSaveNum.reset( new SvxNumRule(static_cast<const SvxNumBulletItem*>(pItem)->GetNumRule()) ); + pSaveNum.reset( new SvxNumRule(pBulletItem->GetNumRule()) ); } bModified = (!pActNum->Get( 0 ) || bPreset); @@ -1195,23 +1209,21 @@ bool SvxNumOptionsTabPage::FillItemSet( SfxItemSet* rSet ) void SvxNumOptionsTabPage::Reset( const SfxItemSet* rSet ) { - const SfxPoolItem* pItem; // in Draw the item exists as WhichId, in Writer only as SlotId - SfxItemState eState = rSet->GetItemState(SID_ATTR_NUMBERING_RULE, false, &pItem); - if(eState != SfxItemState::SET) + const SvxNumBulletItem* pBulletItem = + rSet->GetItemIfSet(SID_ATTR_NUMBERING_RULE, false); + if(!pBulletItem) { - nNumItemId = rSet->GetPool()->GetWhich(SID_ATTR_NUMBERING_RULE); - eState = rSet->GetItemState(nNumItemId, false, &pItem); + nNumItemId = rSet->GetPool()->GetWhichIDFromSlotID(SID_ATTR_NUMBERING_RULE); + pBulletItem = rSet->GetItemIfSet(nNumItemId, false); - if( eState != SfxItemState::SET ) + if( !pBulletItem ) { - pItem = &static_cast< const SvxNumBulletItem& >( rSet->Get( nNumItemId ) ); - eState = SfxItemState::SET; + pBulletItem = & rSet->Get( nNumItemId ); } - } - DBG_ASSERT(eState == SfxItemState::SET, "no item found!"); - pSaveNum.reset( new SvxNumRule(static_cast<const SvxNumBulletItem*>(pItem)->GetNumRule()) ); + DBG_ASSERT(pBulletItem, "no item found!"); + pSaveNum.reset( new SvxNumRule(pBulletItem->GetNumRule()) ); // insert levels if (!m_xLevelLB->n_children()) @@ -1253,12 +1265,16 @@ void SvxNumOptionsTabPage::Reset( const SfxItemSet* rSet ) m_aPreviewWIN.SetNumRule(pActNum.get()); m_xSameLevelCB->set_active(pActNum->IsContinuousNumbering()); - SfxObjectShell* pShell; - if ( SfxItemState::SET == rSet->GetItemState( SID_HTML_MODE, false, &pItem ) - || ( nullptr != ( pShell = SfxObjectShell::Current()) && - nullptr != ( pItem = pShell->GetItem( SID_HTML_MODE ) ) ) ) + const SfxUInt16Item* pHtmlModeItem = + rSet->GetItemIfSet( SID_HTML_MODE, false ); + if (!pHtmlModeItem) + { + if (SfxObjectShell* pShell = SfxObjectShell::Current()) + pHtmlModeItem = pShell->GetItem( SID_HTML_MODE ); + } + if ( pHtmlModeItem ) { - sal_uInt16 nHtmlMode = static_cast<const SfxUInt16Item*>(pItem)->GetValue(); + sal_uInt16 nHtmlMode = pHtmlModeItem->GetValue(); bHTMLMode = 0 != (nHtmlMode&HTMLMODE_ON); } @@ -1271,6 +1287,7 @@ void SvxNumOptionsTabPage::Reset( const SfxItemSet* rSet ) bool bAllLevel = bContinuous && !bHTMLMode; m_xAllLevelFT->set_visible(bAllLevel); m_xAllLevelNF->set_visible(bAllLevel); + m_xIsLegalCB->set_visible(bAllLevel); m_xAllLevelsFrame->set_visible(bContinuous); @@ -1334,6 +1351,8 @@ void SvxNumOptionsTabPage::InitControls() bool bSameBulColor = true; bool bSameBulRelSize= true; + TriState isLegal = TRISTATE_INDET; + const SvxNumberFormat* aNumFmtArr[SVX_MAX_NUM]; OUString sFirstCharFmt; sal_Int16 eFirstOrient = text::VertOrientation::NONE; @@ -1358,6 +1377,7 @@ void SvxNumOptionsTabPage::InitControls() eFirstOrient = aNumFmtArr[i]->GetVertOrient(); if(bShowBitmap) aFirstSize = aNumFmtArr[i]->GetGraphicSize(); + isLegal = aNumFmtArr[i]->GetIsLegal() ? TRISTATE_TRUE : TRISTATE_FALSE; } if( i > nLvl) { @@ -1367,6 +1387,8 @@ void SvxNumOptionsTabPage::InitControls() bSamePrefix = aNumFmtArr[i]->GetPrefix() == aNumFmtArr[nLvl]->GetPrefix(); bSameSuffix = aNumFmtArr[i]->GetSuffix() == aNumFmtArr[nLvl]->GetSuffix(); bAllLevel &= aNumFmtArr[i]->GetIncludeUpperLevels() == aNumFmtArr[nLvl]->GetIncludeUpperLevels(); + if (aNumFmtArr[i]->GetIsLegal() != aNumFmtArr[nLvl]->GetIsLegal()) + isLegal = TRISTATE_INDET; bSameCharFmt &= sFirstCharFmt == aNumFmtArr[i]->GetCharFormatName(); bSameVOrient &= eFirstOrient == aNumFmtArr[i]->GetVertOrient(); if(bShowBitmap && bSameSize) @@ -1439,6 +1461,9 @@ void SvxNumOptionsTabPage::InitControls() m_xAllLevelNF->set_text(""); } + m_xIsLegalCB->set_state(isLegal); + m_xIsLegalCB->set_sensitive(!m_xSameLevelCB->get_active()); + if(bBullRelSize) { if(bSameBulRelSize) @@ -1453,6 +1478,7 @@ void SvxNumOptionsTabPage::InitControls() else m_xBulColLB->SetNoSelection(); } + m_xStartED->set_value(1); // If this isn't set then changing the bullet type to a numbered type doesn't reset the start level switch(nBullet) { case SHOW_NUMBERING: @@ -1482,7 +1508,7 @@ void SvxNumOptionsTabPage::InitControls() { if (!sFirstCharFmt.isEmpty()) m_xCharFmtLB->set_active_text(sFirstCharFmt); - else + else if (m_xCharFmtLB->get_count()) m_xCharFmtLB->set_active(0); } else @@ -1518,6 +1544,7 @@ void SvxNumOptionsTabPage::SwitchNumberType( sal_uInt8 nType ) bool bAllLevel = bNumeric && bAllLevelFeature && !bHTMLMode; m_xAllLevelFT->set_visible(bAllLevel); m_xAllLevelNF->set_visible(bAllLevel); + m_xIsLegalCB->set_visible(bAllLevel); m_xStartFT->set_visible(!(bBullet||bBitmap)); m_xStartED->set_visible(!(bBullet||bBitmap)); @@ -1539,6 +1566,9 @@ void SvxNumOptionsTabPage::SwitchNumberType( sal_uInt8 nType ) m_xHeightFT->set_visible(bBitmap); m_xHeightMF->set_visible(bBitmap); m_xRatioCB->set_visible(bBitmap); + m_xCbxScaleImg->set_visible(bBitmap); + m_xImgRatioTop->set_visible(bBitmap); + m_xImgRatioBottom->set_visible(bBitmap); m_xOrientFT->set_visible(bBitmap && bAllLevelFeature); m_xOrientLB->set_visible(bBitmap && bAllLevelFeature); @@ -1617,7 +1647,7 @@ IMPL_LINK(SvxNumOptionsTabPage, AllLevelHdl_Impl, weld::SpinButton&, rBox, void) if(nActNumLvl & nMask) { SvxNumberFormat aNumFmt(pActNum->GetLevel(e)); - aNumFmt.SetIncludeUpperLevels(static_cast<sal_uInt8>(std::min(rBox.get_value(), int(e + 1))) ); + aNumFmt.SetIncludeUpperLevels(static_cast<sal_uInt8>(std::min(rBox.get_value(), sal_Int64(e + 1))) ); // Set the same prefix/suffix to generate list format with changed IncludedUpperLevels aNumFmt.SetListFormat(aNumFmt.GetPrefix(), aNumFmt.GetSuffix(), e); pActNum->SetLevel(e, aNumFmt); @@ -1627,6 +1657,21 @@ IMPL_LINK(SvxNumOptionsTabPage, AllLevelHdl_Impl, weld::SpinButton&, rBox, void) SetModified(); } +IMPL_LINK(SvxNumOptionsTabPage, IsLegalHdl_Impl, weld::Toggleable&, rBox, void) +{ + bool bSet = rBox.get_active(); + for (sal_uInt16 i = 0; i < pActNum->GetLevelCount(); i++) + { + if (nActNumLvl & (sal_uInt16(1) << i)) + { + SvxNumberFormat aNumFmt(pActNum->GetLevel(i)); + aNumFmt.SetIsLegal(bSet); + pActNum->SetLevel(i, aNumFmt); + } + } + SetModified(); +} + IMPL_LINK(SvxNumOptionsTabPage, NumberTypeSelectHdl_Impl, weld::ComboBox&, rBox, void) { OUString sSelectStyle; @@ -1796,14 +1841,14 @@ IMPL_LINK(SvxNumOptionsTabPage, BulRelSizeHdl_Impl, weld::MetricSpinButton&, rFi SetModified(); } -IMPL_LINK(SvxNumOptionsTabPage, GraphicHdl_Impl, const OString&, rIdent, void) +IMPL_LINK(SvxNumOptionsTabPage, GraphicHdl_Impl, const OUString&, rIdent, void) { OUString aGrfName; Size aSize; bool bSucc(false); - SvxOpenGraphicDialog aGrfDlg(CuiResId(RID_SVXSTR_EDIT_GRAPHIC), GetFrameWeld()); + SvxOpenGraphicDialog aGrfDlg(CuiResId(RID_CUISTR_EDIT_GRAPHIC), GetFrameWeld()); - OString sNumber; + OUString sNumber; if (rIdent.startsWith("gallery", &sNumber)) { auto idx = sNumber.toUInt32(); @@ -2056,6 +2101,7 @@ IMPL_LINK( SvxNumOptionsTabPage, SizeHdl_Impl, weld::MetricSpinButton&, rField, IMPL_LINK(SvxNumOptionsTabPage, RatioHdl_Impl, weld::Toggleable&, rBox, void) { + m_xCbxScaleImg->set_from_icon_name(m_xRatioCB->get_active() ? RID_SVXBMP_LOCKED : RID_SVXBMP_UNLOCKED); if (rBox.get_active()) { if (bLastWidthModified) @@ -2121,353 +2167,6 @@ void SvxNumOptionsTabPage::EditModifyHdl_Impl(const weld::Entry* pEdit) SetModified(); } -static tools::Long lcl_DrawGraphic(VirtualDevice& rVDev, const SvxNumberFormat &rFmt, tools::Long nXStart, - tools::Long nYMiddle, tools::Long nDivision) -{ - const SvxBrushItem* pBrushItem = rFmt.GetBrush(); - tools::Long nRet = 0; - if(pBrushItem) - { - const Graphic* pGrf = pBrushItem->GetGraphic(); - if(pGrf) - { - Size aGSize( rFmt.GetGraphicSize() ); - aGSize.setWidth( aGSize.Width() / nDivision ); - nRet = aGSize.Width(); - aGSize.setHeight( aGSize.Height() / nDivision ); - pGrf->Draw(rVDev, Point(nXStart,nYMiddle - ( aGSize.Height() / 2) ), - rVDev.PixelToLogic( aGSize ) ); - } - } - return nRet; - -} - -static tools::Long lcl_DrawBullet(VirtualDevice* pVDev, - const SvxNumberFormat& rFmt, tools::Long nXStart, - tools::Long nYStart, const Size& rSize) -{ - vcl::Font aTmpFont(pVDev->GetFont()); - - // via Uno it's possible that no font has been set! - vcl::Font aFont(rFmt.GetBulletFont() ? *rFmt.GetBulletFont() : aTmpFont); - Size aTmpSize(rSize); - aTmpSize.setWidth( aTmpSize.Width() * ( rFmt.GetBulletRelSize()) ); - aTmpSize.setWidth( aTmpSize.Width() / 100 ) ; - aTmpSize.setHeight( aTmpSize.Height() * ( rFmt.GetBulletRelSize()) ); - aTmpSize.setHeight( aTmpSize.Height() / 100 ) ; - // in case of a height of zero it is drawn in original height - if(!aTmpSize.Height()) - aTmpSize.setHeight( 1 ); - aFont.SetFontSize(aTmpSize); - aFont.SetTransparent(true); - Color aBulletColor = rFmt.GetBulletColor(); - if(aBulletColor == COL_AUTO) - aBulletColor = pVDev->GetFillColor().IsDark() ? COL_WHITE : COL_BLACK; - else if(aBulletColor == pVDev->GetFillColor()) - aBulletColor.Invert(); - aFont.SetColor(aBulletColor); - pVDev->SetFont( aFont ); - sal_UCS4 cChar = rFmt.GetBulletChar(); - OUString aText(&cChar, 1); - tools::Long nY = nYStart; - nY -= ((aTmpSize.Height() - rSize.Height())/ 2); - pVDev->DrawText( Point(nXStart, nY), aText ); - tools::Long nRet = pVDev->GetTextWidth(aText); - - pVDev->SetFont(aTmpFont); - return nRet; -} - -SvxNumberingPreview::SvxNumberingPreview() - : pActNum(nullptr) - , bPosition(false) - , nActLevel(SAL_MAX_UINT16) -{ -} - -// paint preview of numeration -void SvxNumberingPreview::Paint(vcl::RenderContext& rRenderContext, const ::tools::Rectangle& /*rRect*/) -{ - Size aSize(rRenderContext.PixelToLogic(GetOutputSizePixel())); - - const StyleSettings& rStyleSettings = rRenderContext.GetSettings().GetStyleSettings(); - const Color aBackColor = rStyleSettings.GetFieldColor(); - const Color aTextColor = rStyleSettings.GetFieldTextColor(); - - ScopedVclPtrInstance<VirtualDevice> pVDev(rRenderContext); - pVDev->EnableRTL(rRenderContext.IsRTLEnabled()); - pVDev->SetMapMode(rRenderContext.GetMapMode()); - pVDev->SetOutputSize(aSize); - - Color aLineColor(COL_LIGHTGRAY); - if (aLineColor == aBackColor) - aLineColor.Invert(); - pVDev->SetLineColor(aLineColor); - pVDev->SetFillColor(aBackColor); - - if (pActNum) - { - tools::Long nWidthRelation = 30; // chapter dialog - - // height per level - tools::Long nXStep = aSize.Width() / (3 * pActNum->GetLevelCount()); - if (pActNum->GetLevelCount() < 10) - nXStep /= 2; - tools::Long nYStart = 4; - // the whole height mustn't be used for a single level - tools::Long nYStep = (aSize.Height() - 6)/ (pActNum->GetLevelCount() > 1 ? pActNum->GetLevelCount() : 5); - - aStdFont = OutputDevice::GetDefaultFont(DefaultFontType::UI_SANS, MsLangId::getConfiguredSystemLanguage(), GetDefaultFontFlags::OnlyOne); - aStdFont.SetColor(aTextColor); - aStdFont.SetFillColor(aBackColor); - - tools::Long nFontHeight = nYStep * 6 / 10; - if (bPosition) - nFontHeight = nYStep * 15 / 10; - aStdFont.SetFontSize(Size( 0, nFontHeight )); - - SvxNodeNum aNum; - sal_uInt16 nPreNum = pActNum->GetLevel(0).GetStart(); - - if (bPosition) - { - tools::Long nLineHeight = nFontHeight * 8 / 7; - sal_uInt8 nStart = 0; - while (!(nActLevel & (1<<nStart))) - { - nStart++; - } - if (nStart) - nStart--; - sal_uInt8 nEnd = std::min(sal_uInt8(nStart + 3), sal_uInt8(pActNum->GetLevelCount())); - for (sal_uInt8 nLevel = nStart; nLevel < nEnd; ++nLevel) - { - const SvxNumberFormat &rFmt = pActNum->GetLevel(nLevel); - aNum.GetLevelVal()[nLevel] = rFmt.GetStart(); - - tools::Long nXStart( 0 ); - short nTextOffset( 0 ); - tools::Long nNumberXPos( 0 ); - if (rFmt.GetPositionAndSpaceMode() == SvxNumberFormat::LABEL_WIDTH_AND_POSITION) - { - nXStart = rFmt.GetAbsLSpace() / nWidthRelation; - nTextOffset = rFmt.GetCharTextDistance() / nWidthRelation; - nNumberXPos = nXStart; - tools::Long nFirstLineOffset = (-rFmt.GetFirstLineOffset()) / nWidthRelation; - - if (nFirstLineOffset <= nNumberXPos) - nNumberXPos = nNumberXPos - nFirstLineOffset; - else - nNumberXPos = 0; - // in draw this is valid - if (nTextOffset < 0) - nNumberXPos = nNumberXPos + nTextOffset; - } - else if (rFmt.GetPositionAndSpaceMode() == SvxNumberFormat::LABEL_ALIGNMENT) - { - const tools::Long nTmpNumberXPos((rFmt.GetIndentAt() + rFmt.GetFirstLineIndent() ) / nWidthRelation); - if (nTmpNumberXPos < 0) - { - nNumberXPos = 0; - } - else - { - nNumberXPos = nTmpNumberXPos; - } - } - - tools::Long nBulletWidth = 0; - if (SVX_NUM_BITMAP == (rFmt.GetNumberingType() &(~LINK_TOKEN))) - { - tools::Long nYMiddle = nYStart + ( nFontHeight / 2 ); - nBulletWidth = rFmt.IsShowSymbol() ? lcl_DrawGraphic(*pVDev, rFmt, nNumberXPos, nYMiddle, nWidthRelation) : 0; - } - else if (SVX_NUM_CHAR_SPECIAL == rFmt.GetNumberingType()) - { - nBulletWidth = rFmt.IsShowSymbol() ? lcl_DrawBullet(pVDev.get(), rFmt, nNumberXPos, nYStart, aStdFont.GetFontSize()) : 0; - } - else - { - pVDev->SetFont(aStdFont); - aNum.SetLevel(nLevel); - if (pActNum->IsContinuousNumbering()) - aNum.GetLevelVal()[nLevel] = nPreNum; - OUString aText(pActNum->MakeNumString( aNum )); - vcl::Font aSaveFont = pVDev->GetFont(); - vcl::Font aColorFont(aSaveFont); - Color aTmpBulletColor = rFmt.GetBulletColor(); - if (aTmpBulletColor == COL_AUTO) - aTmpBulletColor = aBackColor.IsDark() ? COL_WHITE : COL_BLACK; - else if (aTmpBulletColor == aBackColor) - aTmpBulletColor.Invert(); - aColorFont.SetColor(aTmpBulletColor); - pVDev->SetFont(aColorFont); - pVDev->DrawText(Point(nNumberXPos, nYStart), aText); - pVDev->SetFont(aSaveFont); - nBulletWidth = pVDev->GetTextWidth(aText); - nPreNum++; - } - if (rFmt.GetPositionAndSpaceMode() == SvxNumberFormat::LABEL_ALIGNMENT && - rFmt.GetLabelFollowedBy() == SvxNumberFormat::SPACE ) - { - pVDev->SetFont(aStdFont); - OUString aText(' '); - pVDev->DrawText( Point(nNumberXPos, nYStart), aText ); - nBulletWidth = nBulletWidth + pVDev->GetTextWidth(aText); - } - - tools::Long nTextXPos( 0 ); - if (rFmt.GetPositionAndSpaceMode() == SvxNumberFormat::LABEL_WIDTH_AND_POSITION) - { - nTextXPos = nXStart; - if (nTextOffset < 0) - nTextXPos = nTextXPos + nTextOffset; - if (nNumberXPos + nBulletWidth + nTextOffset > nTextXPos) - nTextXPos = nNumberXPos + nBulletWidth + nTextOffset; - } - else if (rFmt.GetPositionAndSpaceMode() == SvxNumberFormat::LABEL_ALIGNMENT) - { - switch (rFmt.GetLabelFollowedBy()) - { - case SvxNumberFormat::LISTTAB: - { - nTextXPos = rFmt.GetListtabPos() / nWidthRelation; - if (nTextXPos < nNumberXPos + nBulletWidth) - { - nTextXPos = nNumberXPos + nBulletWidth; - } - } - break; - case SvxNumberFormat::SPACE: - case SvxNumberFormat::NOTHING: - case SvxNumberFormat::NEWLINE: - { - nTextXPos = nNumberXPos + nBulletWidth; - } - break; - } - - nXStart = rFmt.GetIndentAt() / nWidthRelation; - } - - ::tools::Rectangle aRect1(Point(nTextXPos, nYStart + nFontHeight / 2), Size(aSize.Width() / 2, 2)); - pVDev->SetFillColor(aBackColor); - pVDev->DrawRect(aRect1); - - ::tools::Rectangle aRect2(Point(nXStart, nYStart + nLineHeight + nFontHeight / 2 ), Size(aSize.Width() / 2, 2)); - pVDev->DrawRect(aRect2); - nYStart += 2 * nLineHeight; - } - } - else - { - //#i5153# painting gray or black rectangles as 'normal' numbering text - tools::Long nWidth = pVDev->GetTextWidth("Preview"); - tools::Long nTextHeight = pVDev->GetTextHeight(); - tools::Long nRectHeight = nTextHeight * 2 / 3; - tools::Long nTopOffset = nTextHeight - nRectHeight; - Color aBlackColor(COL_BLACK); - if (aBlackColor == aBackColor) - aBlackColor.Invert(); - - for (sal_uInt16 nLevel = 0; nLevel < pActNum->GetLevelCount(); ++nLevel, nYStart = nYStart + nYStep) - { - const SvxNumberFormat &rFmt = pActNum->GetLevel(nLevel); - aNum.GetLevelVal()[ nLevel ] = rFmt.GetStart(); - tools::Long nXStart( 0 ); - pVDev->SetFillColor( aBackColor ); - - if (rFmt.GetPositionAndSpaceMode() == SvxNumberFormat::LABEL_WIDTH_AND_POSITION) - { - nXStart = rFmt.GetAbsLSpace() / nWidthRelation; - } - else if (rFmt.GetPositionAndSpaceMode() == SvxNumberFormat::LABEL_ALIGNMENT) - { - const tools::Long nTmpXStart((rFmt.GetIndentAt() + rFmt.GetFirstLineIndent() ) / nWidthRelation); - if (nTmpXStart < 0) - { - nXStart = 0; - } - else - { - nXStart = nTmpXStart; - } - } - nXStart /= 2; - nXStart += 2; - tools::Long nTextOffset = 2 * nXStep; - if (SVX_NUM_BITMAP == (rFmt.GetNumberingType()&(~LINK_TOKEN))) - { - if (rFmt.IsShowSymbol()) - { - tools::Long nYMiddle = nYStart + ( nFontHeight / 2 ); - nTextOffset = lcl_DrawGraphic(*pVDev, rFmt, nXStart, nYMiddle, nWidthRelation); - nTextOffset = nTextOffset + nXStep; - } - } - else if (SVX_NUM_CHAR_SPECIAL == rFmt.GetNumberingType()) - { - if (rFmt.IsShowSymbol()) - { - nTextOffset = lcl_DrawBullet(pVDev.get(), rFmt, nXStart, nYStart, aStdFont.GetFontSize()); - nTextOffset = nTextOffset + nXStep; - } - } - else - { - vcl::Font aFont(aStdFont); - Size aTmpSize(aStdFont.GetFontSize()); - if(pActNum->IsFeatureSupported(SvxNumRuleFlags::BULLET_REL_SIZE)) - { - aTmpSize.setWidth( aTmpSize.Width() * ( rFmt.GetBulletRelSize()) ); - aTmpSize.setWidth( aTmpSize.Width() / 100 ) ; - aTmpSize.setHeight( aTmpSize.Height() * ( rFmt.GetBulletRelSize()) ); - aTmpSize.setHeight( aTmpSize.Height() / 100 ) ; - } - if(!aTmpSize.Height()) - aTmpSize.setHeight( 1 ); - aFont.SetFontSize(aTmpSize); - Color aTmpBulletColor = rFmt.GetBulletColor(); - if (aTmpBulletColor == COL_AUTO) - aTmpBulletColor = aBackColor.IsDark() ? COL_WHITE : COL_BLACK; - else if (aTmpBulletColor == aBackColor) - aTmpBulletColor.Invert(); - aFont.SetColor(aTmpBulletColor); - pVDev->SetFont(aFont); - aNum.SetLevel( nLevel ); - if (pActNum->IsContinuousNumbering()) - aNum.GetLevelVal()[nLevel] = nPreNum; - OUString aText(pActNum->MakeNumString(aNum)); - tools::Long nY = nYStart; - nY -= (pVDev->GetTextHeight() - nTextHeight - pVDev->GetFontMetric().GetDescent()); - pVDev->DrawText(Point(nXStart, nY), aText); - nTextOffset = pVDev->GetTextWidth(aText); - nTextOffset = nTextOffset + nXStep; - nPreNum++; - pVDev->SetFont(aStdFont); - } - //#i5153# the selected rectangle(s) should be black - if (0 != (nActLevel & (1<<nLevel))) - { - pVDev->SetFillColor( aBlackColor ); - pVDev->SetLineColor( aBlackColor ); - } - else - { - //#i5153# unselected levels are gray - pVDev->SetFillColor( aLineColor ); - pVDev->SetLineColor( aLineColor ); - } - ::tools::Rectangle aRect1(Point(nXStart + nTextOffset, nYStart + nTopOffset), Size(nWidth, nRectHeight)); - pVDev->DrawRect(aRect1); - } - } - } - rRenderContext.DrawOutDev(Point(), aSize, Point(), aSize, *pVDev); -} - - //See uiconfig/swriter/ui/outlinepositionpage.ui for effectively a duplicate //dialog to this one, except with a different preview window impl. //TODO, determine if SwNumPositionTabPage and SvxNumPositionTabPage can be @@ -2506,6 +2205,13 @@ SvxNumPositionTabPage::SvxNumPositionTabPage(weld::Container* pPage, weld::Dialo { SetExchangeSupport(); + // set metric + FieldUnit eFUnit = GetModuleFieldUnit(rSet); + + SetFieldUnit( *m_xDistBorderMF, eFUnit ); + SetFieldUnit( *m_xIndentMF, eFUnit ); + SetFieldUnit( *m_xDistNumMF, eFUnit ); + m_xAlignedAtMF->set_range(0, SAL_MAX_INT32, FieldUnit::NONE); m_xListtabMF->set_range(0, SAL_MAX_INT32, FieldUnit::NONE); m_xIndentAtMF->set_range(0, SAL_MAX_INT32, FieldUnit::NONE); @@ -2536,7 +2242,7 @@ SvxNumPositionTabPage::SvxNumPositionTabPage(weld::Container* pPage, weld::Dialo m_xRelativeCB->set_active(bLastRelative); m_aPreviewWIN.SetPositionMode(); - eCoreUnit = rSet.GetPool()->GetMetric(rSet.GetPool()->GetWhich(SID_ATTR_NUMBERING_RULE)); + eCoreUnit = rSet.GetPool()->GetMetric(rSet.GetPool()->GetWhichIDFromSlotID(SID_ATTR_NUMBERING_RULE)); } SvxNumPositionTabPage::~SvxNumPositionTabPage() @@ -2747,19 +2453,18 @@ void SvxNumPositionTabPage::InitControls() void SvxNumPositionTabPage::ActivatePage(const SfxItemSet& rSet) { - const SfxPoolItem* pItem; sal_uInt16 nTmpNumLvl = 1; const SfxItemSet* pExampleSet = GetDialogExampleSet(); if(pExampleSet) { - if(SfxItemState::SET == pExampleSet->GetItemState(SID_PARAM_NUM_PRESET, false, &pItem)) - bPreset = static_cast<const SfxBoolItem*>(pItem)->GetValue(); - if(SfxItemState::SET == pExampleSet->GetItemState(SID_PARAM_CUR_NUM_LEVEL, false, &pItem)) - nTmpNumLvl = static_cast<const SfxUInt16Item*>(pItem)->GetValue(); + if(const SfxBoolItem* pPresetItem = pExampleSet->GetItemIfSet(SID_PARAM_NUM_PRESET, false)) + bPreset = pPresetItem->GetValue(); + if(const SfxUInt16Item* pLevelItem = pExampleSet->GetItemIfSet(SID_PARAM_CUR_NUM_LEVEL, false)) + nTmpNumLvl = pLevelItem->GetValue(); } - if(SfxItemState::SET == rSet.GetItemState(nNumItemId, false, &pItem)) + if(const SvxNumBulletItem* pBulletItem = rSet.GetItemIfSet(nNumItemId, false)) { - pSaveNum.reset( new SvxNumRule(static_cast<const SvxNumBulletItem*>(pItem)->GetNumRule()) ); + pSaveNum.reset( new SvxNumRule(pBulletItem->GetNumRule()) ); } bModified = (!pActNum->Get( 0 ) || bPreset); if(*pSaveNum != *pActNum || @@ -2816,23 +2521,21 @@ bool SvxNumPositionTabPage::FillItemSet( SfxItemSet* rSet ) void SvxNumPositionTabPage::Reset( const SfxItemSet* rSet ) { - const SfxPoolItem* pItem; // in Draw the item exists as WhichId, in Writer only as SlotId - SfxItemState eState = rSet->GetItemState(SID_ATTR_NUMBERING_RULE, false, &pItem); - if(eState != SfxItemState::SET) + const SvxNumBulletItem* pItem = + rSet->GetItemIfSet(SID_ATTR_NUMBERING_RULE, false); + if(!pItem) { - nNumItemId = rSet->GetPool()->GetWhich(SID_ATTR_NUMBERING_RULE); - eState = rSet->GetItemState(nNumItemId, false, &pItem); + nNumItemId = rSet->GetPool()->GetWhichIDFromSlotID(SID_ATTR_NUMBERING_RULE); + pItem = rSet->GetItemIfSet(nNumItemId, false); - if( eState != SfxItemState::SET ) + if( !pItem ) { - pItem = &static_cast< const SvxNumBulletItem& >( rSet->Get( nNumItemId ) ); - eState = SfxItemState::SET; + pItem = & rSet->Get( nNumItemId ); } - } - DBG_ASSERT(eState == SfxItemState::SET, "no item found!"); - pSaveNum.reset( new SvxNumRule(static_cast<const SvxNumBulletItem*>(pItem)->GetNumRule()) ); + DBG_ASSERT(pItem, "no item found!"); + pSaveNum.reset( new SvxNumRule(pItem->GetNumRule()) ); // insert levels if (!m_xLevelLB->count_selected_rows()) @@ -3340,9 +3043,8 @@ void SvxNumOptionsTabPage::PageCreated(const SfxAllItemSet& aSet) if (pListItem) { const std::vector<OUString> &aList = pListItem->GetList(); - sal_uInt32 nCount = aList.size(); - for(sal_uInt32 i = 0; i < nCount; i++) - m_xCharFmtLB->append_text(aList[i]); + for (const auto& rItem : aList) + m_xCharFmtLB->append_text(rItem); } if (pMetricItem) SetMetric(static_cast<FieldUnit>(pMetricItem->GetValue())); diff --git a/cui/source/tabpages/page.cxx b/cui/source/tabpages/page.cxx index 0e29feaaeae6..0fec60690e9a 100644 --- a/cui/source/tabpages/page.cxx +++ b/cui/source/tabpages/page.cxx @@ -22,7 +22,6 @@ #include <sfx2/objsh.hxx> #include <sfx2/printer.hxx> #include <sfx2/viewsh.hxx> -#include <svl/languageoptions.hxx> #include <svl/cjkoptions.hxx> #include <svl/ctloptions.hxx> #include <svtools/unitconv.hxx> @@ -50,13 +49,13 @@ #include <editeng/eerdll.hxx> #include <editeng/editrids.hrc> #include <svx/svxids.hrc> -#include <svtools/optionsdrawinglayer.hxx> #include <svl/slstitm.hxx> #include <svx/xdef.hxx> #include <svx/unobrushitemhelper.hxx> #include <svx/SvxNumOptionsTabPageHelper.hxx> #include <sal/log.hxx> #include <svl/grabbagitem.hxx> +#include <officecfg/Office/Common.hxx> // static ---------------------------------------------------------------- @@ -81,7 +80,7 @@ const SvxPageUsage aArr[] = static sal_uInt16 PageUsageToPos_Impl( SvxPageUsage nUsage ) { - for ( size_t i = 0; i < SAL_N_ELEMENTS(aArr); ++i ) + for ( size_t i = 0; i < std::size(aArr); ++i ) if ( aArr[i] == nUsage ) return i; return 3; @@ -90,7 +89,7 @@ static sal_uInt16 PageUsageToPos_Impl( SvxPageUsage nUsage ) static SvxPageUsage PosToPageUsage_Impl( sal_uInt16 nPos ) { - if ( nPos >= SAL_N_ELEMENTS(aArr) ) + if ( nPos >= std::size(aArr) ) return SvxPageUsage::NONE; return aArr[nPos]; } @@ -150,7 +149,6 @@ SvxPageDescPage::SvxPageDescPage(weld::Container* pPage, weld::DialogController* , m_xPaperSizeBox(new SvxPaperSizeListBox(m_xBuilder->weld_combo_box("comboPageFormat"))) , m_xPaperWidthEdit(m_xBuilder->weld_metric_spin_button("spinWidth", FieldUnit::CM)) , m_xPaperHeightEdit(m_xBuilder->weld_metric_spin_button("spinHeight", FieldUnit::CM)) - , m_xOrientationFT(m_xBuilder->weld_label("labelOrientation")) , m_xPortraitBtn(m_xBuilder->weld_radio_button("radiobuttonPortrait")) , m_xLandscapeBtn(m_xBuilder->weld_radio_button("radiobuttonLandscape")) , m_xTextFlowLbl(m_xBuilder->weld_label("labelTextFlow")) @@ -193,17 +191,18 @@ SvxPageDescPage::SvxPageDescPage(weld::Container* pPage, weld::DialogController* // this page needs ExchangeSupport SetExchangeSupport(); - SvtCTLOptions aCTLLanguageOptions; bool bCJK = SvtCJKOptions::IsAsianTypographyEnabled(); - bool bCTL = aCTLLanguageOptions.IsCTLFontEnabled(); + bool bCTL = SvtCTLOptions::IsCTLFontEnabled(); bool bWeb = false; - const SfxPoolItem* pItem; - SfxObjectShell* pShell; - if(SfxItemState::SET == rAttr.GetItemState(SID_HTML_MODE, false, &pItem) || - ( nullptr != (pShell = SfxObjectShell::Current()) && - nullptr != (pItem = pShell->GetItem(SID_HTML_MODE)))) - bWeb = 0 != (static_cast<const SfxUInt16Item*>(pItem)->GetValue() & HTMLMODE_ON); + const SfxUInt16Item* pHtmlModeItem = rAttr.GetItemIfSet(SID_HTML_MODE, false); + if (!pHtmlModeItem) + { + if (SfxObjectShell* pShell = SfxObjectShell::Current()) + pHtmlModeItem = pShell->GetItem(SID_HTML_MODE); + } + if (pHtmlModeItem) + bWeb = 0 != (pHtmlModeItem->GetValue() & HTMLMODE_ON); // fill text flow listbox with valid entries @@ -277,16 +276,16 @@ SvxPageDescPage::SvxPageDescPage(weld::Container* pPage, weld::DialogController* // #i4219# take Maximum now from configuration (1/100th cm) // was: 11900 -> 119 cm ;new value 3 meters -> 300 cm -> 30000 - m_xPaperWidthEdit->set_max(m_xPaperWidthEdit->normalize(SvtOptionsDrawinglayer::GetMaximumPaperWidth()), FieldUnit::CM); - m_xPaperHeightEdit->set_max(m_xPaperHeightEdit->normalize(SvtOptionsDrawinglayer::GetMaximumPaperHeight()), FieldUnit::CM); + m_xPaperWidthEdit->set_max(m_xPaperWidthEdit->normalize(officecfg::Office::Common::Drawinglayer::MaximumPaperWidth::get()), FieldUnit::CM); + m_xPaperHeightEdit->set_max(m_xPaperHeightEdit->normalize(officecfg::Office::Common::Drawinglayer::MaximumPaperHeight::get()), FieldUnit::CM); // #i4219# also for margins (1/100th cm). Was: 9999, keeping. - m_xLeftMarginEdit->set_max(m_xLeftMarginEdit->normalize(SvtOptionsDrawinglayer::GetMaximumPaperLeftMargin()), FieldUnit::MM); - m_xRightMarginEdit->set_max(m_xRightMarginEdit->normalize(SvtOptionsDrawinglayer::GetMaximumPaperRightMargin()), FieldUnit::MM); - m_xTopMarginEdit->set_max(m_xTopMarginEdit->normalize(SvtOptionsDrawinglayer::GetMaximumPaperTopMargin()), FieldUnit::MM); - m_xBottomMarginEdit->set_max(m_xBottomMarginEdit->normalize(SvtOptionsDrawinglayer::GetMaximumPaperBottomMargin()), FieldUnit::MM); + m_xLeftMarginEdit->set_max(m_xLeftMarginEdit->normalize(officecfg::Office::Common::Drawinglayer::MaximumPaperLeftMargin::get()), FieldUnit::MM); + m_xRightMarginEdit->set_max(m_xRightMarginEdit->normalize(officecfg::Office::Common::Drawinglayer::MaximumPaperRightMargin::get()), FieldUnit::MM); + m_xTopMarginEdit->set_max(m_xTopMarginEdit->normalize(officecfg::Office::Common::Drawinglayer::MaximumPaperTopMargin::get()), FieldUnit::MM); + m_xBottomMarginEdit->set_max(m_xBottomMarginEdit->normalize(officecfg::Office::Common::Drawinglayer::MaximumPaperBottomMargin::get()), FieldUnit::MM); m_xGutterMarginEdit->set_max( - m_xGutterMarginEdit->normalize(SvtOptionsDrawinglayer::GetMaximumPaperLeftMargin()), + m_xGutterMarginEdit->normalize(officecfg::Office::Common::Drawinglayer::MaximumPaperLeftMargin::get()), FieldUnit::MM); // Get the i18n framework numberings and add them to the listbox. @@ -360,12 +359,11 @@ void SvxPageDescPage::Reset( const SfxItemSet* rSet ) static_cast<sal_uInt16>(ConvertLong_Impl( static_cast<tools::Long>(rULSpace.GetLower()), eUnit )) ); } - if (rSet->HasItem(SID_ATTR_CHAR_GRABBAG, &pItem)) + if (const SfxGrabBagItem* pGragbagItem = rSet->GetItemIfSet(SID_ATTR_CHAR_GRABBAG)) { - const auto& rGrabBagItem = static_cast<const SfxGrabBagItem&>(*pItem); bool bGutterAtTop{}; - auto it = rGrabBagItem.GetGrabBag().find("GutterAtTop"); - if (it != rGrabBagItem.GetGrabBag().end()) + auto it = pGragbagItem->GetGrabBag().find("GutterAtTop"); + if (it != pGragbagItem->GetGrabBag().end()) { it->second >>= bGutterAtTop; } @@ -379,17 +377,17 @@ void SvxPageDescPage::Reset( const SfxItemSet* rSet ) // Left. m_xGutterPositionLB->set_active(0); } - it = rGrabBagItem.GetGrabBag().find("RtlGutter"); + it = pGragbagItem->GetGrabBag().find("RtlGutter"); bool bRtlGutter{}; - if (it != rGrabBagItem.GetGrabBag().end()) + if (it != pGragbagItem->GetGrabBag().end()) { it->second >>= bRtlGutter; m_xRtlGutterCB->set_active(bRtlGutter); m_xRtlGutterCB->show(); } - it = rGrabBagItem.GetGrabBag().find("BackgroundFullSize"); + it = pGragbagItem->GetGrabBag().find("BackgroundFullSize"); bool isBackgroundFullSize{}; - if (it != rGrabBagItem.GetGrabBag().end()) + if (it != pGragbagItem->GetGrabBag().end()) { it->second >>= isBackgroundFullSize; m_xBackgroundFullSizeCB->set_active(isBackgroundFullSize); @@ -584,15 +582,14 @@ void SvxPageDescPage::Reset( const SfxItemSet* rSet ) if(SfxItemState::SET == rSet->GetItemState(SID_SWREGISTER_MODE)) { - m_xRegisterCB->set_active(static_cast<const SfxBoolItem&>(rSet->Get( - SID_SWREGISTER_MODE)).GetValue()); + m_xRegisterCB->set_active(rSet->Get(SID_SWREGISTER_MODE).GetValue()); m_xRegisterCB->save_state(); RegisterModify(*m_xRegisterCB); } if(SfxItemState::SET == rSet->GetItemState(SID_SWREGISTER_COLLECTION)) { m_xRegisterLB->set_active_text( - static_cast<const SfxStringItem&>(rSet->Get(SID_SWREGISTER_COLLECTION)).GetValue()); + rSet->Get(SID_SWREGISTER_COLLECTION).GetValue()); m_xRegisterLB->save_value(); } @@ -666,8 +663,7 @@ bool SvxPageDescPage::FillItemSet( SfxItemSet* rSet ) if (rOldSet.HasItem(SID_ATTR_CHAR_GRABBAG)) { // Set gutter position. - SfxGrabBagItem aGrabBagItem( - static_cast<const SfxGrabBagItem&>(rOldSet.Get(SID_ATTR_CHAR_GRABBAG))); + SfxGrabBagItem aGrabBagItem(rOldSet.Get(SID_ATTR_CHAR_GRABBAG)); if (m_xGutterPositionLB->get_value_changed_from_saved()) { bool bGutterAtTop = m_xGutterPositionLB->get_active() == 1; @@ -726,14 +722,14 @@ bool SvxPageDescPage::FillItemSet( SfxItemSet* rSet ) } // paper tray - nWhich = GetWhich( SID_ATTR_PAGE_PAPERBIN ); + TypedWhichId<SvxPaperBinItem> nPaperWhich = GetWhich( SID_ATTR_PAGE_PAPERBIN ); sal_Int32 nPos = m_xPaperTrayBox->get_active(); sal_uInt16 nBin = m_xPaperTrayBox->get_id(nPos).toInt32(); pOld = GetOldItem( *rSet, SID_ATTR_PAGE_PAPERBIN ); if ( !pOld || static_cast<const SvxPaperBinItem*>(pOld)->GetValue() != nBin ) { - rSet->Put( SvxPaperBinItem( nWhich, static_cast<sal_uInt8>(nBin) ) ); + rSet->Put( SvxPaperBinItem( nPaperWhich, static_cast<sal_uInt8>(nBin) ) ); bModified = true; } @@ -852,7 +848,7 @@ bool SvxPageDescPage::FillItemSet( SfxItemSet* rSet ) if (m_xRegisterCB->get_visible() && (m_xRegisterCB->get_active() || m_xRegisterCB->get_state_changed_from_saved())) { - const SfxBoolItem& rRegItem = static_cast<const SfxBoolItem&>(rOldSet.Get(SID_SWREGISTER_MODE)); + const SfxBoolItem& rRegItem = rOldSet.Get(SID_SWREGISTER_MODE); std::unique_ptr<SfxBoolItem> pRegItem(rRegItem.Clone()); bool bCheck = m_xRegisterCB->get_active(); pRegItem->SetValue(bCheck); @@ -924,8 +920,8 @@ IMPL_LINK_NOARG(SvxPageDescPage, PaperBinHdl_Impl, weld::Widget&, void) } m_xPaperTrayBox->append(OUString::number(i), aName); } - m_xPaperTrayBox->set_active_text(aOldName); m_xPaperTrayBox->thaw(); + m_xPaperTrayBox->set_active_text(aOldName); // tdf#123650 explicitly grab-focus after the modification otherwise gtk loses track // of there the focus should be @@ -1137,7 +1133,7 @@ void SvxPageDescPage::ResetBackground_Impl(const SfxItemSet& rSet) { const SvxSetItem& rSetItem = static_cast< const SvxSetItem& >(rSet.Get(nWhich, false)); const SfxItemSet& rTmpSet = rSetItem.GetItemSet(); - const SfxBoolItem& rOn = static_cast< const SfxBoolItem& >(rTmpSet.Get(GetWhich(SID_ATTR_PAGE_ON))); + const SfxBoolItem& rOn = rTmpSet.Get(GetWhich(SID_ATTR_PAGE_ON)); if(rOn.GetValue()) { @@ -1173,7 +1169,7 @@ void SvxPageDescPage::ResetBackground_Impl(const SfxItemSet& rSet) { const SvxSetItem& rSetItem = static_cast< const SvxSetItem& >(rSet.Get(nWhich,false)); const SfxItemSet& rTmpSet = rSetItem.GetItemSet(); - const SfxBoolItem& rOn = static_cast< const SfxBoolItem& >(rTmpSet.Get(GetWhich(SID_ATTR_PAGE_ON))); + const SfxBoolItem& rOn = rTmpSet.Get(GetWhich(SID_ATTR_PAGE_ON)); if(rOn.GetValue()) { @@ -1246,19 +1242,19 @@ void SvxPageDescPage::InitHeadFoot_Impl( const SfxItemSet& rSet ) { const SfxItemSet& rHeaderSet = pSetItem->GetItemSet(); const SfxBoolItem& rHeaderOn = - static_cast<const SfxBoolItem&>(rHeaderSet.Get( GetWhich( SID_ATTR_PAGE_ON ) )); + rHeaderSet.Get( GetWhich( SID_ATTR_PAGE_ON ) ); if ( rHeaderOn.GetValue() ) { - const SvxSizeItem& rSize = static_cast<const SvxSizeItem&>( - rHeaderSet.Get( GetWhich( SID_ATTR_PAGE_SIZE ) )); - const SvxULSpaceItem& rUL = static_cast<const SvxULSpaceItem&>( - rHeaderSet.Get( GetWhich( SID_ATTR_ULSPACE ) )); + const SvxSizeItem& rSize = + rHeaderSet.Get( GetWhich( SID_ATTR_PAGE_SIZE ) ); + const SvxULSpaceItem& rUL = + rHeaderSet.Get( GetWhich( SID_ATTR_ULSPACE ) ); tools::Long nDist = rUL.GetLower(); m_aBspWin.SetHdHeight( rSize.GetSize().Height() - nDist ); m_aBspWin.SetHdDist( nDist ); - const SvxLRSpaceItem& rLR = static_cast<const SvxLRSpaceItem&>( - rHeaderSet.Get( GetWhich( SID_ATTR_LRSPACE ) )); + const SvxLRSpaceItem& rLR = + rHeaderSet.Get( GetWhich( SID_ATTR_LRSPACE ) ); m_aBspWin.SetHdLeft( rLR.GetLeft() ); m_aBspWin.SetHdRight( rLR.GetRight() ); m_aBspWin.SetHeader( true ); @@ -1301,19 +1297,19 @@ void SvxPageDescPage::InitHeadFoot_Impl( const SfxItemSet& rSet ) const SfxItemSet& rFooterSet = pSetItem->GetItemSet(); const SfxBoolItem& rFooterOn = - static_cast<const SfxBoolItem&>(rFooterSet.Get( GetWhich( SID_ATTR_PAGE_ON ) )); + rFooterSet.Get( GetWhich( SID_ATTR_PAGE_ON ) ); if ( rFooterOn.GetValue() ) { - const SvxSizeItem& rSize = static_cast<const SvxSizeItem&>( - rFooterSet.Get( GetWhich( SID_ATTR_PAGE_SIZE ) )); - const SvxULSpaceItem& rUL = static_cast<const SvxULSpaceItem&>( - rFooterSet.Get( GetWhich( SID_ATTR_ULSPACE ) )); + const SvxSizeItem& rSize = + rFooterSet.Get( GetWhich( SID_ATTR_PAGE_SIZE ) ); + const SvxULSpaceItem& rUL = + rFooterSet.Get( GetWhich( SID_ATTR_ULSPACE ) ); tools::Long nDist = rUL.GetUpper(); m_aBspWin.SetFtHeight( rSize.GetSize().Height() - nDist ); m_aBspWin.SetFtDist( nDist ); - const SvxLRSpaceItem& rLR = static_cast<const SvxLRSpaceItem&>( - rFooterSet.Get( GetWhich( SID_ATTR_LRSPACE ) )); + const SvxLRSpaceItem& rLR = + rFooterSet.Get( GetWhich( SID_ATTR_LRSPACE ) ); m_aBspWin.SetFtLeft( rLR.GetLeft() ); m_aBspWin.SetFtRight( rLR.GetRight() ); m_aBspWin.SetFooter( true ); @@ -1438,8 +1434,8 @@ void SvxPageDescPage::RangeHdl_Impl() SfxItemState::DEFAULT ) { aBorder = GetMinBorderSpace_Impl( - static_cast<const SvxShadowItem&>(_pSet->Get(GetWhich(SID_ATTR_BORDER_SHADOW))), - static_cast<const SvxBoxItem&>(_pSet->Get(GetWhich(SID_ATTR_BORDER_OUTER)))); + _pSet->Get(GetWhich(SID_ATTR_BORDER_SHADOW)), + _pSet->Get(GetWhich(SID_ATTR_BORDER_OUTER))); } // limits paper diff --git a/cui/source/tabpages/paragrph.cxx b/cui/source/tabpages/paragrph.cxx index a7075bd862e7..11fefa11ed07 100644 --- a/cui/source/tabpages/paragrph.cxx +++ b/cui/source/tabpages/paragrph.cxx @@ -25,8 +25,8 @@ #include <vcl/settings.hxx> #include <svx/flagsdef.hxx> #include <svx/svxids.hrc> +#include <svx/sdtaitm.hxx> -#include <svl/languageoptions.hxx> #include <svl/cjkoptions.hxx> #include <editeng/pgrditem.hxx> #include <svx/strings.hrc> @@ -45,29 +45,47 @@ #include <editeng/lrspitem.hxx> #include <editeng/formatbreakitem.hxx> #include <editeng/keepitem.hxx> +#include <editeng/scriptspaceitem.hxx> +#include <editeng/hngpnctitem.hxx> +#include <editeng/forbiddenruleitem.hxx> +#include <i18nlangtag/languagetag.hxx> +#include <i18nlangtag/mslangid.hxx> #include <svx/dlgutil.hxx> #include <sfx2/htmlmode.hxx> #include <editeng/paravertalignitem.hxx> #include <svl/eitem.hxx> #include <svl/intitem.hxx> +#include <unotools/syslocaleoptions.hxx> +#include <com/sun/star/text/ParagraphHyphenationKeepType.hpp> const WhichRangesContainer SvxStdParagraphTabPage::pStdRanges( svl::Items< SID_ATTR_PARA_LINESPACE, SID_ATTR_PARA_LINESPACE, // 10033 + SID_ATTR_PARA_LEFTSPACE, SID_ATTR_PARA_FIRSTLINESPACE, SID_ATTR_LRSPACE, SID_ATTR_ULSPACE, // 10048 - 10049 SID_ATTR_PARA_REGISTER, SID_ATTR_PARA_REGISTER // 10413 >); const WhichRangesContainer SvxParaAlignTabPage::pAlignRanges( - svl::Items<SID_ATTR_PARA_ADJUST, SID_ATTR_PARA_ADJUST>); // 10027 + svl::Items< + SID_ATTR_PARA_ADJUST, SID_ATTR_PARA_ADJUST, // 10027 + // tdf#154543 - reset snap to grid to parent + SID_ATTR_PARA_SNAPTOGRID, SID_ATTR_PARA_SNAPTOGRID // 10945 + >); + +const WhichRangesContainer SvxParaAlignTabPage::pSdrAlignRanges( + svl::Items< + SDRATTR_TEXT_VERTADJUST, SDRATTR_TEXT_VERTADJUST, // 1076 + SID_ATTR_PARA_ADJUST, SID_ATTR_PARA_ADJUST , // 10027 + SID_ATTR_FRAMEDIRECTION, SID_ATTR_FRAMEDIRECTION // 10944 + >); const WhichRangesContainer SvxExtParagraphTabPage::pExtRanges(svl::Items< SID_ATTR_PARA_PAGEBREAK, SID_ATTR_PARA_WIDOWS, // 10037 - 10041 SID_ATTR_PARA_MODEL, SID_ATTR_PARA_KEEP // 10065 - 10066 >); -#define MAX_DURCH 5670 // 10 cm makes sense as maximum interline lead - // according to BP +#define MAX_DURCH 31680 // tdf#68335: 1584 pt for UX interoperability with Word #define FIX_DIST_DEF 283 // standard fix distance 0,5 cm namespace { @@ -139,13 +157,15 @@ void SetLineSpace_Impl( SvxLineSpacingItem& rLineSpace, static sal_uInt16 GetHtmlMode_Impl(const SfxItemSet& rSet) { sal_uInt16 nHtmlMode = 0; - const SfxPoolItem* pItem = nullptr; - SfxObjectShell* pShell; - if(SfxItemState::SET == rSet.GetItemState(SID_HTML_MODE, false, &pItem) || - ( nullptr != (pShell = SfxObjectShell::Current()) && - nullptr != (pItem = pShell->GetItem(SID_HTML_MODE)))) + const SfxUInt16Item* pItem = rSet.GetItemIfSet(SID_HTML_MODE, false); + if (!pItem) + { + if (SfxObjectShell* pShell = SfxObjectShell::Current()) + pItem = pShell->GetItem(SID_HTML_MODE); + } + if(pItem) { - nHtmlMode = static_cast<const SfxUInt16Item*>(pItem)->GetValue(); + nHtmlMode = pItem->GetValue(); } return nHtmlMode; @@ -158,34 +178,34 @@ void SvxStdParagraphTabPage::ELRLoseFocus() FieldUnit eUnit = MapToFieldUnit( pPool->GetMetric( GetWhich( SID_ATTR_LRSPACE ) ) ); - sal_Int64 nL = m_xLeftIndent->denormalize(m_xLeftIndent->get_value(eUnit)); - sal_Int64 nR = m_xRightIndent->denormalize(m_xRightIndent->get_value(eUnit)); - OUString aTmp = m_xFLineIndent->get_text(); + sal_Int64 nL = m_aLeftIndent.denormalize(m_aLeftIndent.get_value(eUnit)); + sal_Int64 nR = m_aRightIndent.denormalize(m_aRightIndent.get_value(eUnit)); + OUString aTmp = m_aFLineIndent.get_text(); - if (m_xLeftIndent->get_min(FieldUnit::NONE) < 0) - m_xFLineIndent->set_min(-99999, FieldUnit::MM); + if (m_aLeftIndent.get_min(FieldUnit::NONE) < 0) + m_aFLineIndent.set_min(-99999, FieldUnit::MM); else - m_xFLineIndent->set_min(m_xFLineIndent->normalize(-nL), eUnit); + m_aFLineIndent.set_min(m_aFLineIndent.normalize(-nL), eUnit); // Check only for concrete width (Shell) sal_Int64 nTmp = nWidth - nL - nR - MM50; - m_xFLineIndent->set_max(m_xFLineIndent->normalize(nTmp), eUnit); + m_aFLineIndent.set_max(m_aFLineIndent.normalize(nTmp), eUnit); if (aTmp.isEmpty()) - m_xFLineIndent->set_text(OUString()); + m_aFLineIndent.set_text(OUString()); // maximum left right - aTmp = m_xLeftIndent->get_text(); + aTmp = m_aLeftIndent.get_text(); nTmp = nWidth - nR - MM50; - m_xLeftIndent->set_max(m_xLeftIndent->normalize(nTmp), eUnit); + m_aLeftIndent.set_max(m_aLeftIndent.normalize(nTmp), eUnit); if ( aTmp.isEmpty() ) - m_xLeftIndent->set_text(OUString()); - aTmp = m_xRightIndent->get_text(); + m_aLeftIndent.set_text(OUString()); + aTmp = m_aRightIndent.get_text(); nTmp = nWidth - nL - MM50; - m_xRightIndent->set_max(m_xRightIndent->normalize(nTmp), eUnit); + m_aRightIndent.set_max(m_aRightIndent.normalize(nTmp), eUnit); if ( aTmp.isEmpty() ) - m_xRightIndent->set_text(OUString()); + m_aRightIndent.set_text(OUString()); UpdateExample_Impl(); } @@ -251,14 +271,14 @@ bool SvxStdParagraphTabPage::FillItemSet( SfxItemSet* rOutSet ) if ( m_bLineDistToggled || !pOld || !( *static_cast<const SvxLineSpacingItem*>(pOld) == aSpacing ) || - SfxItemState::DONTCARE == GetItemSet().GetItemState( nWhich ) ) + SfxItemState::INVALID == GetItemSet().GetItemState( nWhich ) ) { rOutSet->Put( aSpacing ); bModified = true; } } - if ( m_xTopDist->get_value_changed_from_saved() || m_xBottomDist->get_value_changed_from_saved() + if ( m_aTopDist.get_value_changed_from_saved() || m_aBottomDist.get_value_changed_from_saved() || m_xContextualCB->get_state_changed_from_saved()) { nWhich = GetWhich( SID_ATTR_ULSPACE ); @@ -273,28 +293,28 @@ bool SvxStdParagraphTabPage::FillItemSet( SfxItemSet* rOutSet ) const SvxULSpaceItem& rOldItem = static_cast<const SvxULSpaceItem&>(GetItemSet().GetParent()->Get( nWhich )); - if ( m_xTopDist->IsRelative() ) + if ( m_aTopDist.IsRelative() ) aMargin.SetUpper( rOldItem.GetUpper(), - static_cast<sal_uInt16>(m_xTopDist->get_value(FieldUnit::NONE)) ); + static_cast<sal_uInt16>(m_aTopDist.get_value(FieldUnit::NONE)) ); else - aMargin.SetUpper( static_cast<sal_uInt16>(m_xTopDist->GetCoreValue(eUnit)) ); + aMargin.SetUpper( static_cast<sal_uInt16>(m_aTopDist.GetCoreValue(eUnit)) ); - if ( m_xBottomDist->IsRelative() ) + if ( m_aBottomDist.IsRelative() ) aMargin.SetLower( rOldItem.GetLower(), - static_cast<sal_uInt16>(m_xBottomDist->get_value(FieldUnit::NONE)) ); + static_cast<sal_uInt16>(m_aBottomDist.get_value(FieldUnit::NONE)) ); else - aMargin.SetLower( static_cast<sal_uInt16>(m_xBottomDist->GetCoreValue(eUnit)) ); + aMargin.SetLower( static_cast<sal_uInt16>(m_aBottomDist.GetCoreValue(eUnit)) ); } else { - aMargin.SetUpper(static_cast<sal_uInt16>(m_xTopDist->GetCoreValue(eUnit))); - aMargin.SetLower(static_cast<sal_uInt16>(m_xBottomDist->GetCoreValue(eUnit))); + aMargin.SetUpper(static_cast<sal_uInt16>(m_aTopDist.GetCoreValue(eUnit))); + aMargin.SetLower(static_cast<sal_uInt16>(m_aBottomDist.GetCoreValue(eUnit))); } aMargin.SetContextValue(m_xContextualCB->get_active()); if ( !pOld || *static_cast<const SvxULSpaceItem*>(pOld) != aMargin || - SfxItemState::DONTCARE == GetItemSet().GetItemState( nWhich ) ) + SfxItemState::INVALID == GetItemSet().GetItemState( nWhich ) ) { rOutSet->Put( aMargin ); bModified = true; @@ -302,10 +322,126 @@ bool SvxStdParagraphTabPage::FillItemSet( SfxItemSet* rOutSet ) } bool bNullTab = false; - if ( m_xLeftIndent->get_value_changed_from_saved() || - m_xFLineIndent->get_value_changed_from_saved() || - m_xRightIndent->get_value_changed_from_saved() || - m_xAutoCB->get_state_changed_from_saved() ) + if (m_bSplitLRSpace && m_aLeftIndent.get_value_changed_from_saved()) + { + nWhich = GetWhich(SID_ATTR_PARA_LEFTSPACE); + MapUnit const eUnit = pPool->GetMetric(nWhich); + SvxTextLeftMarginItem item(nWhich); + pOld = GetOldItem(*rOutSet, SID_ATTR_PARA_LEFTSPACE); + + if (bRelativeMode) + { + assert(GetItemSet().GetParent()); + + const SvxTextLeftMarginItem & rOldItem( + static_cast<const SvxTextLeftMarginItem&>(GetItemSet().GetParent()->Get(nWhich))); + + if (m_aLeftIndent.IsRelative()) + { + item.SetTextLeft(rOldItem.GetTextLeft(), + static_cast<sal_uInt16>(m_aLeftIndent.get_value(FieldUnit::NONE))); + } + else + { + item.SetTextLeft(m_aLeftIndent.GetCoreValue(eUnit)); + } + } + else + { + item.SetTextLeft(m_aLeftIndent.GetCoreValue(eUnit)); + } + if (!pOld || *static_cast<const SvxTextLeftMarginItem*>(pOld) != item + || SfxItemState::INVALID == GetItemSet().GetItemState(nWhich)) + { + rOutSet->Put(item); + bModified = true; + } + } + + if (m_bSplitLRSpace && m_aRightIndent.get_value_changed_from_saved()) + { + nWhich = GetWhich(SID_ATTR_PARA_RIGHTSPACE); + MapUnit const eUnit = pPool->GetMetric(nWhich); + SvxRightMarginItem item(nWhich); + pOld = GetOldItem(*rOutSet, SID_ATTR_PARA_RIGHTSPACE); + + if (bRelativeMode) + { + assert(GetItemSet().GetParent()); + + const SvxRightMarginItem & rOldItem( + static_cast<const SvxRightMarginItem&>(GetItemSet().GetParent()->Get(nWhich))); + + if (m_aRightIndent.IsRelative()) + { + item.SetRight(rOldItem.GetRight(), + static_cast<sal_uInt16>(m_aRightIndent.get_value(FieldUnit::NONE))); + } + else + { + item.SetRight(m_aRightIndent.GetCoreValue(eUnit)); + } + } + else + { + item.SetRight(m_aRightIndent.GetCoreValue(eUnit)); + } + if (!pOld || *static_cast<const SvxRightMarginItem*>(pOld) != item + || SfxItemState::INVALID == GetItemSet().GetItemState(nWhich)) + { + rOutSet->Put(item); + bModified = true; + } + } + + if (m_bSplitLRSpace && (m_aFLineIndent.get_value_changed_from_saved() + || m_xAutoCB->get_state_changed_from_saved())) + { + nWhich = GetWhich(SID_ATTR_PARA_FIRSTLINESPACE); + MapUnit const eUnit = pPool->GetMetric(nWhich); + SvxFirstLineIndentItem item(nWhich); + pOld = GetOldItem(*rOutSet, SID_ATTR_PARA_FIRSTLINESPACE); + + if (bRelativeMode) + { + assert(GetItemSet().GetParent()); + + const SvxFirstLineIndentItem & rOldItem( + static_cast<const SvxFirstLineIndentItem&>(GetItemSet().GetParent()->Get(nWhich))); + + if (m_aFLineIndent.IsRelative()) + { + item.SetTextFirstLineOffset(rOldItem.GetTextFirstLineOffset(), + static_cast<sal_uInt16>(m_aFLineIndent.get_value(FieldUnit::NONE))); + } + else + { + item.SetTextFirstLineOffset(static_cast<sal_uInt16>(m_aFLineIndent.GetCoreValue(eUnit))); + } + } + else + { + item.SetTextFirstLineOffset(static_cast<sal_uInt16>(m_aFLineIndent.GetCoreValue(eUnit))); + } + item.SetAutoFirst(m_xAutoCB->get_active()); + if (item.GetTextFirstLineOffset() < 0) + { + bNullTab = true; + } + + if (!pOld || *static_cast<const SvxFirstLineIndentItem*>(pOld) != item + || SfxItemState::INVALID == GetItemSet().GetItemState(nWhich)) + { + rOutSet->Put(item); + bModified = true; + } + } + + if (!m_bSplitLRSpace && + (m_aLeftIndent.get_value_changed_from_saved() || + m_aFLineIndent.get_value_changed_from_saved() || + m_aRightIndent.get_value_changed_from_saved() || + m_xAutoCB->get_state_changed_from_saved())) { nWhich = GetWhich( SID_ATTR_LRSPACE ); MapUnit eUnit = pPool->GetMetric( nWhich ); @@ -319,36 +455,36 @@ bool SvxStdParagraphTabPage::FillItemSet( SfxItemSet* rOutSet ) const SvxLRSpaceItem& rOldItem = static_cast<const SvxLRSpaceItem&>(GetItemSet().GetParent()->Get( nWhich )); - if (m_xLeftIndent->IsRelative()) + if (m_aLeftIndent.IsRelative()) aMargin.SetTextLeft( rOldItem.GetTextLeft(), - static_cast<sal_uInt16>(m_xLeftIndent->get_value(FieldUnit::NONE)) ); + static_cast<sal_uInt16>(m_aLeftIndent.get_value(FieldUnit::NONE)) ); else - aMargin.SetTextLeft(m_xLeftIndent->GetCoreValue(eUnit)); + aMargin.SetTextLeft(m_aLeftIndent.GetCoreValue(eUnit)); - if ( m_xRightIndent->IsRelative() ) + if ( m_aRightIndent.IsRelative() ) aMargin.SetRight( rOldItem.GetRight(), - static_cast<sal_uInt16>(m_xRightIndent->get_value(FieldUnit::NONE)) ); + static_cast<sal_uInt16>(m_aRightIndent.get_value(FieldUnit::NONE)) ); else - aMargin.SetRight(m_xRightIndent->GetCoreValue(eUnit)); + aMargin.SetRight(m_aRightIndent.GetCoreValue(eUnit)); - if ( m_xFLineIndent->IsRelative() ) + if ( m_aFLineIndent.IsRelative() ) aMargin.SetTextFirstLineOffset( rOldItem.GetTextFirstLineOffset(), - static_cast<sal_uInt16>(m_xFLineIndent->get_value(FieldUnit::NONE)) ); + static_cast<sal_uInt16>(m_aFLineIndent.get_value(FieldUnit::NONE)) ); else - aMargin.SetTextFirstLineOffset(static_cast<sal_uInt16>(m_xFLineIndent->GetCoreValue(eUnit))); + aMargin.SetTextFirstLineOffset(static_cast<sal_uInt16>(m_aFLineIndent.GetCoreValue(eUnit))); } else { - aMargin.SetTextLeft(m_xLeftIndent->GetCoreValue(eUnit)); - aMargin.SetRight(m_xRightIndent->GetCoreValue(eUnit)); - aMargin.SetTextFirstLineOffset(static_cast<sal_uInt16>(m_xFLineIndent->GetCoreValue(eUnit))); + aMargin.SetTextLeft(m_aLeftIndent.GetCoreValue(eUnit)); + aMargin.SetRight(m_aRightIndent.GetCoreValue(eUnit)); + aMargin.SetTextFirstLineOffset(static_cast<sal_uInt16>(m_aFLineIndent.GetCoreValue(eUnit))); } aMargin.SetAutoFirst(m_xAutoCB->get_active()); if ( aMargin.GetTextFirstLineOffset() < 0 ) bNullTab = true; if ( !pOld || *static_cast<const SvxLRSpaceItem*>(pOld) != aMargin || - SfxItemState::DONTCARE == GetItemSet().GetItemState( nWhich ) ) + SfxItemState::INVALID == GetItemSet().GetItemState( nWhich ) ) { rOutSet->Put( aMargin ); bModified = true; @@ -382,14 +518,14 @@ bool SvxStdParagraphTabPage::FillItemSet( SfxItemSet* rOutSet ) *rOutSet, SID_ATTR_PARA_REGISTER)); if (!pBoolItem) return bModified; - std::unique_ptr<SfxBoolItem> pRegItem(pBoolItem->Clone()); sal_uInt16 _nWhich = GetWhich( SID_ATTR_PARA_REGISTER ); - bool bSet = pRegItem->GetValue(); + bool bSet = pBoolItem->GetValue(); if (m_xRegisterCB->get_active() != bSet) { + std::unique_ptr<SfxBoolItem> pRegItem(pBoolItem->Clone()); pRegItem->SetValue(!bSet); - rOutSet->Put(*pRegItem); + rOutSet->Put(std::move(pRegItem)); bModified = true; } else if ( SfxItemState::DEFAULT == GetItemSet().GetItemState( _nWhich, false ) ) @@ -399,6 +535,19 @@ bool SvxStdParagraphTabPage::FillItemSet( SfxItemSet* rOutSet ) return bModified; } +static bool UseCharUnitInUI(const SfxItemSet& rSet) +{ + const bool bApplyCharUnit = GetApplyCharUnit(rSet); + if (!bApplyCharUnit) + return false; + if (!SvtCJKOptions::IsAsianTypographyEnabled()) + return false; + // tdf#101895 Given that we choose to show cm vs inch based on this Locale + // setting, also choose to use ch[ar] and line based on that locale when + // bApplyCharUnit is enabled. + return MsLangId::isCJK(SvtSysLocaleOptions().GetRealLanguageTag().getLanguageType()); +} + void SvxStdParagraphTabPage::Reset( const SfxItemSet* rSet ) { SfxItemPool* pPool = rSet->GetPool(); @@ -406,32 +555,134 @@ void SvxStdParagraphTabPage::Reset( const SfxItemSet* rSet ) // adjust metric FieldUnit eFUnit = GetModuleFieldUnit( *rSet ); - - bool bApplyCharUnit = GetApplyCharUnit( *rSet ); - - if(SvtCJKOptions::IsAsianTypographyEnabled() && bApplyCharUnit ) + if (UseCharUnitInUI(*rSet)) eFUnit = FieldUnit::CHAR; - m_xLeftIndent->SetFieldUnit(eFUnit); - m_xRightIndent->SetFieldUnit(eFUnit); - m_xFLineIndent->SetFieldUnit(eFUnit); + m_aLeftIndent.SetFieldUnit(eFUnit); + m_aRightIndent.SetFieldUnit(eFUnit); + m_aFLineIndent.SetFieldUnit(eFUnit); if ( eFUnit == FieldUnit::CHAR ) { - m_xTopDist->SetFieldUnit(FieldUnit::LINE); - m_xBottomDist->SetFieldUnit(FieldUnit::LINE); + m_aTopDist.SetFieldUnit(FieldUnit::LINE); + m_aBottomDist.SetFieldUnit(FieldUnit::LINE); SetFieldUnit(*m_xLineDistAtMetricBox, FieldUnit::POINT); } else { - m_xTopDist->SetFieldUnit(eFUnit); - m_xBottomDist->SetFieldUnit(eFUnit); + m_aTopDist.SetFieldUnit(eFUnit); + m_aBottomDist.SetFieldUnit(eFUnit); SetFieldUnit(*m_xLineDistAtMetricBox, eFUnit); } + sal_uInt16 const nWhichFL(GetWhich(SID_ATTR_PARA_FIRSTLINESPACE)); + m_bSplitLRSpace = (nWhichFL != SID_ATTR_PARA_FIRSTLINESPACE); + SfxItemState const eItemStateFL(rSet->GetItemState(nWhichFL)); + sal_uInt16 const nWhichLM(GetWhich(SID_ATTR_PARA_LEFTSPACE)); + SfxItemState const eItemStateLM(rSet->GetItemState(nWhichLM)); + sal_uInt16 const nWhichRM(GetWhich(SID_ATTR_PARA_RIGHTSPACE)); + SfxItemState const eItemStateRM(rSet->GetItemState(nWhichRM)); + + if (m_bSplitLRSpace && SfxItemState::DEFAULT <= eItemStateLM) + { + const SvxTextLeftMarginItem & rOldLeftMargin( + static_cast<const SvxTextLeftMarginItem &>(rSet->Get(nWhichLM))); + + MapUnit const eUnit = pPool->GetMetric(nWhichLM); + + if (bRelativeMode) + { + if (rOldLeftMargin.GetPropLeft() != 100) + { + m_aLeftIndent.SetRelative( true ); + m_aLeftIndent.set_value(rOldLeftMargin.GetPropLeft(), FieldUnit::NONE); + } + else + { + m_aLeftIndent.SetRelative(false); + m_aLeftIndent.SetFieldUnit(eFUnit); + m_aLeftIndent.SetMetricValue(rOldLeftMargin.GetTextLeft(), eUnit); + } + } + else + { + m_aLeftIndent.SetMetricValue(rOldLeftMargin.GetTextLeft(), eUnit); + } + } + else if (m_bSplitLRSpace) + { + m_aLeftIndent.set_text(OUString()); + } + + if (m_bSplitLRSpace && SfxItemState::DEFAULT <= eItemStateRM) + { + const SvxRightMarginItem & rOldRightMargin( + static_cast<const SvxRightMarginItem &>(rSet->Get(nWhichRM))); + + MapUnit const eUnit = pPool->GetMetric(nWhichRM); + + if (bRelativeMode) + { + if (rOldRightMargin.GetPropRight() != 100) + { + m_aRightIndent.SetRelative( true ); + m_aRightIndent.set_value(rOldRightMargin.GetPropRight(), FieldUnit::NONE); + } + else + { + m_aRightIndent.SetRelative(false); + m_aRightIndent.SetFieldUnit(eFUnit); + m_aRightIndent.SetMetricValue(rOldRightMargin.GetRight(), eUnit); + } + } + else + { + m_aRightIndent.SetMetricValue(rOldRightMargin.GetRight(), eUnit); + } + } + else if (m_bSplitLRSpace) + { + m_aRightIndent.set_text(OUString()); + } + + if (m_bSplitLRSpace && SfxItemState::DEFAULT <= eItemStateFL) + { + const SvxFirstLineIndentItem & rOldFirstLine( + static_cast<const SvxFirstLineIndentItem &>(rSet->Get(nWhichFL))); + + MapUnit const eUnit = pPool->GetMetric(nWhichFL); + + if (bRelativeMode) + { + if (rOldFirstLine.GetPropTextFirstLineOffset() != 100) + { + m_aFLineIndent.SetRelative(true); + m_aFLineIndent.set_value(rOldFirstLine.GetPropTextFirstLineOffset(), FieldUnit::NONE); + } + else + { + m_aFLineIndent.SetRelative(false); + m_aFLineIndent.set_min(-9999, FieldUnit::NONE); + m_aFLineIndent.SetFieldUnit(eFUnit); + m_aFLineIndent.SetMetricValue(rOldFirstLine.GetTextFirstLineOffset(), eUnit); + } + m_xAutoCB->set_active(rOldFirstLine.IsAutoFirst()); + } + else + { + m_aFLineIndent.SetMetricValue(rOldFirstLine.GetTextFirstLineOffset(), eUnit); + m_xAutoCB->set_active(rOldFirstLine.IsAutoFirst()); + } + AutoHdl_Impl(*m_xAutoCB); + } + else if (m_bSplitLRSpace) + { + m_aFLineIndent.set_text(OUString()); + } + sal_uInt16 _nWhich = GetWhich( SID_ATTR_LRSPACE ); SfxItemState eItemState = rSet->GetItemState( _nWhich ); - if ( eItemState >= SfxItemState::DEFAULT ) + if (!m_bSplitLRSpace && SfxItemState::DEFAULT <= eItemState) { MapUnit eUnit = pPool->GetMetric( _nWhich ); @@ -442,39 +693,39 @@ void SvxStdParagraphTabPage::Reset( const SfxItemSet* rSet ) if ( rOldItem.GetPropLeft() != 100 ) { - m_xLeftIndent->SetRelative( true ); - m_xLeftIndent->set_value(rOldItem.GetPropLeft(), FieldUnit::NONE); + m_aLeftIndent.SetRelative( true ); + m_aLeftIndent.set_value(rOldItem.GetPropLeft(), FieldUnit::NONE); } else { - m_xLeftIndent->SetRelative(false); - m_xLeftIndent->SetFieldUnit(eFUnit); - m_xLeftIndent->SetMetricValue(rOldItem.GetTextLeft(), eUnit); + m_aLeftIndent.SetRelative(false); + m_aLeftIndent.SetFieldUnit(eFUnit); + m_aLeftIndent.SetMetricValue(rOldItem.GetTextLeft(), eUnit); } if ( rOldItem.GetPropRight() != 100 ) { - m_xRightIndent->SetRelative( true ); - m_xRightIndent->set_value(rOldItem.GetPropRight(), FieldUnit::NONE); + m_aRightIndent.SetRelative( true ); + m_aRightIndent.set_value(rOldItem.GetPropRight(), FieldUnit::NONE); } else { - m_xRightIndent->SetRelative(false); - m_xRightIndent->SetFieldUnit(eFUnit); - m_xRightIndent->SetMetricValue(rOldItem.GetRight(), eUnit); + m_aRightIndent.SetRelative(false); + m_aRightIndent.SetFieldUnit(eFUnit); + m_aRightIndent.SetMetricValue(rOldItem.GetRight(), eUnit); } if ( rOldItem.GetPropTextFirstLineOffset() != 100 ) { - m_xFLineIndent->SetRelative(true); - m_xFLineIndent->set_value(rOldItem.GetPropTextFirstLineOffset(), FieldUnit::NONE); + m_aFLineIndent.SetRelative(true); + m_aFLineIndent.set_value(rOldItem.GetPropTextFirstLineOffset(), FieldUnit::NONE); } else { - m_xFLineIndent->SetRelative(false); - m_xFLineIndent->set_min(-9999, FieldUnit::NONE); - m_xFLineIndent->SetFieldUnit(eFUnit); - m_xFLineIndent->SetMetricValue(rOldItem.GetTextFirstLineOffset(), eUnit); + m_aFLineIndent.SetRelative(false); + m_aFLineIndent.set_min(-9999, FieldUnit::NONE); + m_aFLineIndent.SetFieldUnit(eFUnit); + m_aFLineIndent.SetMetricValue(rOldItem.GetTextFirstLineOffset(), eUnit); } m_xAutoCB->set_active(rOldItem.IsAutoFirst()); } @@ -483,18 +734,18 @@ void SvxStdParagraphTabPage::Reset( const SfxItemSet* rSet ) const SvxLRSpaceItem& rSpace = static_cast<const SvxLRSpaceItem&>(rSet->Get( _nWhich )); - m_xLeftIndent->SetMetricValue(rSpace.GetTextLeft(), eUnit); - m_xRightIndent->SetMetricValue(rSpace.GetRight(), eUnit); - m_xFLineIndent->SetMetricValue(rSpace.GetTextFirstLineOffset(), eUnit); + m_aLeftIndent.SetMetricValue(rSpace.GetTextLeft(), eUnit); + m_aRightIndent.SetMetricValue(rSpace.GetRight(), eUnit); + m_aFLineIndent.SetMetricValue(rSpace.GetTextFirstLineOffset(), eUnit); m_xAutoCB->set_active(rSpace.IsAutoFirst()); } AutoHdl_Impl(*m_xAutoCB); } - else + else if (!m_bSplitLRSpace) { - m_xLeftIndent->set_text(OUString()); - m_xRightIndent->set_text(OUString()); - m_xFLineIndent->set_text(OUString()); + m_aLeftIndent.set_text(OUString()); + m_aRightIndent.set_text(OUString()); + m_aFLineIndent.set_text(OUString()); } _nWhich = GetWhich( SID_ATTR_ULSPACE ); @@ -511,45 +762,45 @@ void SvxStdParagraphTabPage::Reset( const SfxItemSet* rSet ) if ( rOldItem.GetPropUpper() != 100 ) { - m_xTopDist->SetRelative( true ); - m_xTopDist->set_value(rOldItem.GetPropUpper(), FieldUnit::NONE); + m_aTopDist.SetRelative( true ); + m_aTopDist.set_value(rOldItem.GetPropUpper(), FieldUnit::NONE); } else { - m_xTopDist->SetRelative(false); + m_aTopDist.SetRelative(false); if (eFUnit == FieldUnit::CHAR) - m_xTopDist->SetFieldUnit(FieldUnit::LINE); + m_aTopDist.SetFieldUnit(FieldUnit::LINE); else - m_xTopDist->SetFieldUnit(eFUnit); - m_xTopDist->SetMetricValue(rOldItem.GetUpper(), eUnit); + m_aTopDist.SetFieldUnit(eFUnit); + m_aTopDist.SetMetricValue(rOldItem.GetUpper(), eUnit); } if ( rOldItem.GetPropLower() != 100 ) { - m_xBottomDist->SetRelative( true ); - m_xBottomDist->set_value(rOldItem.GetPropLower(), FieldUnit::NONE); + m_aBottomDist.SetRelative( true ); + m_aBottomDist.set_value(rOldItem.GetPropLower(), FieldUnit::NONE); } else { - m_xBottomDist->SetRelative(false); + m_aBottomDist.SetRelative(false); if (eFUnit == FieldUnit::CHAR) - m_xBottomDist->SetFieldUnit(FieldUnit::LINE); + m_aBottomDist.SetFieldUnit(FieldUnit::LINE); else - m_xBottomDist->SetFieldUnit(eFUnit); - m_xBottomDist->SetMetricValue(rOldItem.GetLower(), eUnit); + m_aBottomDist.SetFieldUnit(eFUnit); + m_aBottomDist.SetMetricValue(rOldItem.GetLower(), eUnit); } } else { - m_xTopDist->SetMetricValue(rOldItem.GetUpper(), eUnit); - m_xBottomDist->SetMetricValue(rOldItem.GetLower(), eUnit); + m_aTopDist.SetMetricValue(rOldItem.GetUpper(), eUnit); + m_aBottomDist.SetMetricValue(rOldItem.GetLower(), eUnit); } m_xContextualCB->set_active(rOldItem.GetContext()); } else { - m_xTopDist->set_text(OUString()); - m_xBottomDist->set_text(OUString()); + m_aTopDist.set_text(OUString()); + m_aBottomDist.set_text(OUString()); } _nWhich = GetWhich( SID_ATTR_PARA_LINESPACE ); @@ -582,15 +833,15 @@ void SvxStdParagraphTabPage::Reset( const SfxItemSet* rSet ) void SvxStdParagraphTabPage::ChangesApplied() { - m_xLeftIndent->save_value(); - m_xRightIndent->save_value(); - m_xFLineIndent->save_value(); + m_aLeftIndent.save_value(); + m_aRightIndent.save_value(); + m_aFLineIndent.save_value(); m_xLineDist->save_value(); m_xLineDistAtPercentBox->save_value(); m_xLineDistAtMetricBox->save_value(); m_xRegisterCB->save_state(); - m_xTopDist->save_value(); - m_xBottomDist->save_value(); + m_aTopDist.save_value(); + m_aBottomDist.save_value(); m_xContextualCB->save_state(); m_xAutoCB->save_state(); } @@ -599,11 +850,11 @@ void SvxStdParagraphTabPage::EnableRelativeMode() { DBG_ASSERT( GetItemSet().GetParent(), "RelativeMode, but no parent-set!" ); - m_xLeftIndent->EnableRelativeMode( 0, 999 ); - m_xFLineIndent->EnableRelativeMode( 0, 999 ); - m_xRightIndent->EnableRelativeMode( 0, 999 ); - m_xTopDist->EnableRelativeMode( 0, 999 ); - m_xBottomDist->EnableRelativeMode( 0, 999 ); + m_aLeftIndent.EnableRelativeMode( 0, 999 ); + m_aFLineIndent.EnableRelativeMode( 0, 999 ); + m_aRightIndent.EnableRelativeMode( 0, 999 ); + m_aTopDist.EnableRelativeMode( 0, 999 ); + m_aBottomDist.EnableRelativeMode( 0, 999 ); bRelativeMode = true; } @@ -658,32 +909,32 @@ SvxStdParagraphTabPage::SvxStdParagraphTabPage(weld::Container* pPage, weld::Dia , nWidth(11905 /*567 * 50*/) , nMinFixDist(0) , bRelativeMode(false) - , m_xLeftIndent(new SvxRelativeField(m_xBuilder->weld_metric_spin_button("spinED_LEFTINDENT", FieldUnit::CM))) - , m_xRightLabel(m_xBuilder->weld_label("labelFT_RIGHTINDENT")) - , m_xRightIndent(new SvxRelativeField(m_xBuilder->weld_metric_spin_button("spinED_RIGHTINDENT", FieldUnit::CM))) + , m_aLeftIndent(m_xBuilder->weld_metric_spin_button("spinED_LEFTINDENT", FieldUnit::CM)) + , m_aRightIndent(m_xBuilder->weld_metric_spin_button("spinED_RIGHTINDENT", FieldUnit::CM)) , m_xFLineLabel(m_xBuilder->weld_label("labelFT_FLINEINDENT")) - , m_xFLineIndent(new SvxRelativeField(m_xBuilder->weld_metric_spin_button("spinED_FLINEINDENT", FieldUnit::CM))) + , m_aFLineIndent(m_xBuilder->weld_metric_spin_button("spinED_FLINEINDENT", FieldUnit::CM)) , m_xAutoCB(m_xBuilder->weld_check_button("checkCB_AUTO")) - , m_xTopDist(new SvxRelativeField(m_xBuilder->weld_metric_spin_button("spinED_TOPDIST", FieldUnit::CM))) - , m_xBottomDist(new SvxRelativeField(m_xBuilder->weld_metric_spin_button("spinED_BOTTOMDIST", FieldUnit::CM))) + , m_aTopDist(m_xBuilder->weld_metric_spin_button("spinED_TOPDIST", FieldUnit::CM)) + , m_aBottomDist(m_xBuilder->weld_metric_spin_button("spinED_BOTTOMDIST", FieldUnit::CM)) , m_xContextualCB(m_xBuilder->weld_check_button("checkCB_CONTEXTUALSPACING")) , m_xLineDist(m_xBuilder->weld_combo_box("comboLB_LINEDIST")) , m_xLineDistAtPercentBox(m_xBuilder->weld_metric_spin_button("spinED_LINEDISTPERCENT", FieldUnit::PERCENT)) , m_xLineDistAtMetricBox(m_xBuilder->weld_metric_spin_button("spinED_LINEDISTMETRIC", FieldUnit::CM)) + , m_xLineDistAtPlaceHolderBox(m_xBuilder->weld_metric_spin_button("spinED_BLANK", FieldUnit::CM)) , m_xLineDistAtLabel(m_xBuilder->weld_label("labelFT_LINEDIST")) , m_xAbsDist(m_xBuilder->weld_label("labelST_LINEDIST_ABS")) , m_xRegisterCB(m_xBuilder->weld_check_button("checkCB_REGISTER")) , m_xExampleWin(new weld::CustomWeld(*m_xBuilder, "drawingareaWN_EXAMPLE", m_aExampleWin)) { - sAbsDist = m_xAbsDist->get_label(); - // this page needs ExchangeSupport SetExchangeSupport(); m_xLineDistAtMetricBox->hide(); + m_xLineDistAtPlaceHolderBox->hide(); + m_xLineDistAtPlaceHolderBox->set_text(OUString()); Init_Impl(); - m_xFLineIndent->set_min(-9999, FieldUnit::NONE); // is set to 0 on default + m_aFLineIndent.set_min(-9999, FieldUnit::NONE); // is set to 0 on default } SvxStdParagraphTabPage::~SvxStdParagraphTabPage() @@ -692,10 +943,10 @@ SvxStdParagraphTabPage::~SvxStdParagraphTabPage() void SvxStdParagraphTabPage::EnableNegativeMode() { - m_xLeftIndent->set_min(-9999, FieldUnit::NONE); - m_xRightIndent->set_min(-9999, FieldUnit::NONE); - m_xRightIndent->EnableNegativeMode(); - m_xLeftIndent->EnableNegativeMode(); + m_aLeftIndent.set_min(-9999, FieldUnit::NONE); + m_aRightIndent.set_min(-9999, FieldUnit::NONE); + m_aRightIndent.EnableNegativeMode(); + m_aLeftIndent.EnableNegativeMode(); } void SvxStdParagraphTabPage::SetLineSpacing_Impl @@ -784,10 +1035,9 @@ IMPL_LINK(SvxStdParagraphTabPage, LineDistHdl_Impl, weld::ComboBox&, rBox, void) case LLINESPACE_15: case LLINESPACE_2: m_xLineDistAtLabel->set_sensitive(false); - m_xLineDistAtPercentBox->set_sensitive(false); - m_xLineDistAtPercentBox->set_text(OUString()); - m_xLineDistAtMetricBox->set_sensitive(false); - m_xLineDistAtMetricBox->set_text(OUString()); + m_xLineDistAtPercentBox->hide(); + m_xLineDistAtMetricBox->hide(); + m_xLineDistAtPlaceHolderBox->show(); break; case LLINESPACE_DURCH: @@ -795,32 +1045,32 @@ IMPL_LINK(SvxStdParagraphTabPage, LineDistHdl_Impl, weld::ComboBox&, rBox, void) // limit MS min(10, aPageSize) m_xLineDistAtMetricBox->set_min(0, FieldUnit::NONE); - if (m_xLineDistAtMetricBox->get_text().isEmpty()) + if (m_xLineDistAtPlaceHolderBox->get_visible()) m_xLineDistAtMetricBox->set_value(m_xLineDistAtMetricBox->normalize(1), FieldUnit::NONE); + m_xLineDistAtPlaceHolderBox->hide(); m_xLineDistAtPercentBox->hide(); m_xLineDistAtMetricBox->show(); - m_xLineDistAtMetricBox->set_sensitive(true); m_xLineDistAtLabel->set_sensitive(true); break; case LLINESPACE_MIN: m_xLineDistAtMetricBox->set_min(0, FieldUnit::NONE); - if (m_xLineDistAtMetricBox->get_text().isEmpty()) + if (m_xLineDistAtPlaceHolderBox->get_visible()) m_xLineDistAtMetricBox->set_value(m_xLineDistAtMetricBox->normalize(10), FieldUnit::TWIP); + m_xLineDistAtPlaceHolderBox->hide(); m_xLineDistAtPercentBox->hide(); m_xLineDistAtMetricBox->show(); - m_xLineDistAtMetricBox->set_sensitive(true); m_xLineDistAtLabel->set_sensitive(true); break; case LLINESPACE_PROP: - if (m_xLineDistAtPercentBox->get_text().isEmpty()) + if (m_xLineDistAtPlaceHolderBox->get_visible()) m_xLineDistAtPercentBox->set_value(m_xLineDistAtPercentBox->normalize(100), FieldUnit::TWIP); + m_xLineDistAtPlaceHolderBox->hide(); m_xLineDistAtMetricBox->hide(); m_xLineDistAtPercentBox->show(); - m_xLineDistAtPercentBox->set_sensitive(true); m_xLineDistAtLabel->set_sensitive(true); break; case LLINESPACE_FIX: @@ -832,9 +1082,9 @@ IMPL_LINK(SvxStdParagraphTabPage, LineDistHdl_Impl, weld::ComboBox&, rBox, void) // it is time for the default if (m_xLineDistAtMetricBox->get_value(FieldUnit::NONE) != nTemp) SetMetricValue( *m_xLineDistAtMetricBox, FIX_DIST_DEF, MapUnit::MapTwip ); // fix is only in Writer + m_xLineDistAtPlaceHolderBox->hide(); m_xLineDistAtPercentBox->hide(); m_xLineDistAtMetricBox->show(); - m_xLineDistAtMetricBox->set_sensitive(true); m_xLineDistAtLabel->set_sensitive(true); } break; @@ -853,31 +1103,31 @@ void SvxStdParagraphTabPage::Init_Impl() m_xLineDist->connect_changed(LINK(this, SvxStdParagraphTabPage, LineDistHdl_Impl)); Link<weld::MetricSpinButton&,void> aLink2 = LINK(this, SvxStdParagraphTabPage, ELRLoseFocusHdl); - m_xFLineIndent->connect_value_changed(aLink2); - m_xLeftIndent->connect_value_changed(aLink2); - m_xRightIndent->connect_value_changed(aLink2); + m_aFLineIndent.connect_value_changed(aLink2); + m_aLeftIndent.connect_value_changed(aLink2); + m_aRightIndent.connect_value_changed(aLink2); Link<weld::MetricSpinButton&,void> aLink = LINK(this, SvxStdParagraphTabPage, ModifyHdl_Impl); - m_xTopDist->connect_value_changed(aLink); - m_xBottomDist->connect_value_changed(aLink); + m_aTopDist.connect_value_changed(aLink); + m_aBottomDist.connect_value_changed(aLink); m_xAutoCB->connect_toggled(LINK(this, SvxStdParagraphTabPage, AutoHdl_Impl)); SfxItemPool* pPool = GetItemSet().GetPool(); DBG_ASSERT( pPool, "Where is the pool?" ); FieldUnit eUnit = MapToFieldUnit( pPool->GetMetric( GetWhich( SID_ATTR_LRSPACE ) ) ); - m_xTopDist->set_max( m_xTopDist->normalize( MAX_DURCH ), eUnit ); - m_xBottomDist->set_max( m_xBottomDist->normalize( MAX_DURCH ), eUnit ); + m_aTopDist.set_max( m_aTopDist.normalize( MAX_DURCH ), eUnit ); + m_aBottomDist.set_max( m_aBottomDist.normalize( MAX_DURCH ), eUnit ); m_xLineDistAtMetricBox->set_max( m_xLineDistAtMetricBox->normalize( MAX_DURCH ), eUnit ); } void SvxStdParagraphTabPage::UpdateExample_Impl() { - m_aExampleWin.SetFirstLineOffset( static_cast<short>(m_xFLineIndent->denormalize( m_xFLineIndent->get_value( FieldUnit::TWIP ) )) ); - m_aExampleWin.SetLeftMargin( static_cast<tools::Long>(m_xLeftIndent->denormalize( m_xLeftIndent->get_value( FieldUnit::TWIP ) ) ) ); - m_aExampleWin.SetRightMargin( static_cast<tools::Long>(m_xRightIndent->denormalize( m_xRightIndent->get_value( FieldUnit::TWIP ) ) ) ); - m_aExampleWin.SetUpper( static_cast<sal_uInt16>(m_xTopDist->denormalize( m_xTopDist->get_value( FieldUnit::TWIP ) )) ); - m_aExampleWin.SetLower( static_cast<sal_uInt16>(m_xBottomDist->denormalize( m_xBottomDist->get_value( FieldUnit::TWIP ) )) ); + m_aExampleWin.SetFirstLineOffset( static_cast<short>(m_aFLineIndent.denormalize( m_aFLineIndent.get_value( FieldUnit::TWIP ) )) ); + m_aExampleWin.SetLeftMargin( static_cast<tools::Long>(m_aLeftIndent.denormalize( m_aLeftIndent.get_value( FieldUnit::TWIP ) ) ) ); + m_aExampleWin.SetRightMargin( static_cast<tools::Long>(m_aRightIndent.denormalize( m_aRightIndent.get_value( FieldUnit::TWIP ) ) ) ); + m_aExampleWin.SetUpper( static_cast<sal_uInt16>(m_aTopDist.denormalize( m_aTopDist.get_value( FieldUnit::TWIP ) )) ); + m_aExampleWin.SetLower( static_cast<sal_uInt16>(m_aBottomDist.denormalize( m_aBottomDist.get_value( FieldUnit::TWIP ) )) ); int nPos = m_xLineDist->get_active(); @@ -911,7 +1161,7 @@ IMPL_LINK(SvxStdParagraphTabPage, AutoHdl_Impl, weld::Toggleable&, rBox, void) { bool bEnable = !rBox.get_active(); m_xFLineLabel->set_sensitive(bEnable); - m_xFLineIndent->set_sensitive(bEnable); + m_aFLineIndent.set_sensitive(bEnable); } void SvxStdParagraphTabPage::EnableAutoFirstLine() @@ -919,12 +1169,6 @@ void SvxStdParagraphTabPage::EnableAutoFirstLine() m_xAutoCB->show(); } -void SvxStdParagraphTabPage::EnableAbsLineDist(tools::Long nMinTwip) -{ - m_xLineDist->append_text(sAbsDist); - nMinFixDist = nMinTwip; -} - void SvxStdParagraphTabPage::PageCreated(const SfxAllItemSet& aSet) { @@ -937,7 +1181,6 @@ void SvxStdParagraphTabPage::PageCreated(const SfxAllItemSet& aSet) */ const SfxUInt16Item* pPageWidthItem = aSet.GetItem<SfxUInt16Item>(SID_SVXSTDPARAGRAPHTABPAGE_PAGEWIDTH, false); const SfxUInt32Item* pFlagSetItem = aSet.GetItem<SfxUInt32Item>(SID_SVXSTDPARAGRAPHTABPAGE_FLAGSET, false); - const SfxUInt32Item* pLineDistItem = aSet.GetItem<SfxUInt32Item>(SID_SVXSTDPARAGRAPHTABPAGE_ABSLINEDIST, false); if (pPageWidthItem) nWidth = pPageWidthItem->GetValue(); @@ -954,9 +1197,6 @@ void SvxStdParagraphTabPage::PageCreated(const SfxAllItemSet& aSet) EnableAutoFirstLine(); } - if(pLineDistItem) - EnableAbsLineDist(pLineDistItem->GetValue()); - if (pFlagSetItem) { if (( 0x0008 & pFlagSetItem->GetValue()) == 0x0008 ) @@ -975,6 +1215,7 @@ void SvxStdParagraphTabPage::PageCreated(const SfxAllItemSet& aSet) SvxParaAlignTabPage::SvxParaAlignTabPage(weld::Container* pPage, weld::DialogController* pController, const SfxItemSet& rSet) : SfxTabPage(pPage, pController, "cui/ui/paragalignpage.ui", "ParaAlignPage", &rSet) + , m_bSdrVertAlign(false) , m_xLeft(m_xBuilder->weld_radio_button("radioBTN_LEFTALIGN")) , m_xRight(m_xBuilder->weld_radio_button("radioBTN_RIGHTALIGN")) , m_xCenter(m_xBuilder->weld_radio_button("radioBTN_CENTERALIGN")) @@ -988,7 +1229,8 @@ SvxParaAlignTabPage::SvxParaAlignTabPage(weld::Container* pPage, weld::DialogCon , m_xExampleWin(new weld::CustomWeld(*m_xBuilder, "drawingareaWN_EXAMPLE", m_aExampleWin)) , m_xVertAlignFL(m_xBuilder->weld_widget("frameFL_VERTALIGN")) , m_xVertAlignLB(m_xBuilder->weld_combo_box("comboLB_VERTALIGN")) - , m_xPropertiesFL(m_xBuilder->weld_widget("framePROPERTIES")) + , m_xVertAlign(m_xBuilder->weld_label("labelFL_VERTALIGN")) + , m_xVertAlignSdr(m_xBuilder->weld_label("labelST_VERTALIGN_SDR")) , m_xTextDirectionLB(new svx::FrameDirectionListBox(m_xBuilder->weld_combo_box("comboLB_TEXTDIRECTION"))) { SetExchangeSupport(); @@ -1104,7 +1346,10 @@ bool SvxParaAlignTabPage::FillItemSet( SfxItemSet* rOutSet ) if (m_xVertAlignLB->get_value_changed_from_saved()) { - rOutSet->Put(SvxParaVertAlignItem(static_cast<SvxParaVertAlignItem::Align>(m_xVertAlignLB->get_active()), GetWhich( SID_PARA_VERTALIGN ))); + if (m_bSdrVertAlign) + rOutSet->Put(SdrTextVertAdjustItem(static_cast<SdrTextVertAdjust>(m_xVertAlignLB->get_active()))); + else + rOutSet->Put(SvxParaVertAlignItem(static_cast<SvxParaVertAlignItem::Align>(m_xVertAlignLB->get_active()), GetWhich( SID_PARA_VERTALIGN ))); bModified = true; } @@ -1190,16 +1435,23 @@ void SvxParaAlignTabPage::Reset( const SfxItemSet* rSet ) m_xSnapToGridCB->set_active(rSnap.GetValue()); } - _nWhich = GetWhich( SID_PARA_VERTALIGN ); + _nWhich = m_bSdrVertAlign ? SDRATTR_TEXT_VERTADJUST : GetWhich( SID_PARA_VERTALIGN ); eItemState = rSet->GetItemState( _nWhich ); if ( eItemState >= SfxItemState::DEFAULT ) { m_xVertAlignFL->show(); - const SvxParaVertAlignItem& rAlign = static_cast<const SvxParaVertAlignItem&>(rSet->Get( _nWhich )); - - m_xVertAlignLB->set_active(static_cast<sal_Int32>(rAlign.GetValue())); + if (m_bSdrVertAlign) + { + const SdrTextVertAdjustItem& rAlign = static_cast<const SdrTextVertAdjustItem&>(rSet->Get( _nWhich )); + m_xVertAlignLB->set_active(rAlign.GetValue()); + } + else + { + const SvxParaVertAlignItem& rAlign = static_cast<const SvxParaVertAlignItem&>(rSet->Get( _nWhich )); + m_xVertAlignLB->set_active(static_cast<sal_Int32>(rAlign.GetValue())); + } } _nWhich = GetWhich( SID_ATTR_FRAMEDIRECTION ); @@ -1329,6 +1581,15 @@ void SvxParaAlignTabPage::EnableJustifyExt() } +void SvxParaAlignTabPage::EnableSdrVertAlign() +{ + m_bSdrVertAlign = true; + + m_xVertAlignLB->remove_id("0"); + m_xVertAlignLB->remove_id("1"); + m_xVertAlign->set_label(m_xVertAlignSdr->get_label()); +} + void SvxParaAlignTabPage::PageCreated (const SfxAllItemSet& aSet) { const SfxBoolItem* pBoolItem = aSet.GetItem<SfxBoolItem>(SID_SVXPARAALIGNTABPAGE_ENABLEJUSTIFYEXT, false); @@ -1350,22 +1611,68 @@ bool SvxExtParagraphTabPage::FillItemSet( SfxItemSet* rOutSet ) if ( m_xHyphenBox->get_state_changed_from_saved() || m_xHyphenNoCapsBox->get_state_changed_from_saved() || + m_xHyphenNoLastWordBox->get_state_changed_from_saved() || m_xExtHyphenBeforeBox->get_value_changed_from_saved() || m_xExtHyphenAfterBox->get_value_changed_from_saved() || - m_xMaxHyphenEdit->get_value_changed_from_saved() ) + m_xExtCompoundHyphenBeforeBox->get_value_changed_from_saved() || + m_xMaxHyphenEdit->get_value_changed_from_saved() || + m_xMinWordLength->get_value_changed_from_saved() || + m_aHyphenZone.get_value_changed_from_saved() || + m_xAcrossColumnBox->get_state_changed_from_saved() || + m_xAcrossPageBox->get_state_changed_from_saved() || + m_xAcrossSpreadBox->get_state_changed_from_saved() ) { SvxHyphenZoneItem aHyphen( static_cast<const SvxHyphenZoneItem&>(GetItemSet().Get( _nWhich )) ); aHyphen.SetHyphen( eHyphenState == TRISTATE_TRUE ); - aHyphen.SetNoCapsHyphenation(m_xHyphenNoCapsBox->get_state() == TRISTATE_TRUE); + aHyphen.SetNoCapsHyphenation(m_xHyphenNoCapsBox->get_state() != TRISTATE_TRUE); + aHyphen.SetNoLastWordHyphenation(m_xHyphenNoLastWordBox->get_state() != TRISTATE_TRUE); if ( eHyphenState == TRISTATE_TRUE ) { aHyphen.GetMinLead() = static_cast<sal_uInt8>(m_xExtHyphenBeforeBox->get_value()); aHyphen.GetMinTrail() = static_cast<sal_uInt8>(m_xExtHyphenAfterBox->get_value()); + aHyphen.GetCompoundMinLead() = static_cast<sal_uInt8>(m_xExtCompoundHyphenBeforeBox->get_value()); + aHyphen.GetMinWordLength() = static_cast<sal_uInt8>(m_xMinWordLength->get_value()); } aHyphen.GetMaxHyphens() = static_cast<sal_uInt8>(m_xMaxHyphenEdit->get_value()); + SfxItemPool* pPool = GetItemSet().GetPool(); + DBG_ASSERT( pPool, "Where is the pool?" ); + MapUnit eUnit = pPool->GetMetric( _nWhich ); + aHyphen.GetTextHyphenZone() = static_cast<sal_uInt16>(m_aHyphenZone.GetCoreValue(eUnit)); + aHyphen.SetHyphen( eHyphenState == TRISTATE_TRUE ); + aHyphen.SetNoLastWordHyphenation(m_xHyphenNoLastWordBox->get_state() != TRISTATE_TRUE); + const TriState eAcrossColumnState = m_xAcrossColumnBox->get_state(); + const TriState eAcrossPageState = m_xAcrossPageBox->get_state(); + const TriState eAcrossSpreadState = m_xAcrossSpreadBox->get_state(); + aHyphen.SetKeep( eAcrossSpreadState != TRISTATE_TRUE ); + if ( eAcrossSpreadState == TRISTATE_TRUE ) + { + // hyphenate across column, page and spread -> ParaHyphenationKeep = false and + // set default value 3 (COLUMN) + aHyphen.GetKeepType() = + static_cast<sal_uInt8>(css::text::ParagraphHyphenationKeepType::COLUMN); + } + else if ( eAcrossPageState == TRISTATE_TRUE ) + { + // hyphenate across column and page, but not spread -> 1 (SPREAD) + aHyphen.GetKeepType() = + static_cast<sal_uInt8>(css::text::ParagraphHyphenationKeepType::SPREAD); + } + else if ( eAcrossColumnState == TRISTATE_TRUE ) + { + // hyphenate across column, but not page and spread -> 2 (PAGE) + aHyphen.GetKeepType() = + static_cast<sal_uInt8>(css::text::ParagraphHyphenationKeepType::PAGE); + } + else + { + // don't hyphenate across column, page and spread -> 3 (COLUMN) + aHyphen.GetKeepType() = + static_cast<sal_uInt8>(css::text::ParagraphHyphenationKeepType::COLUMN); + } + if ( !pOld || *static_cast<const SvxHyphenZoneItem*>(pOld) != aHyphen || m_xHyphenBox->get_state_changed_from_saved()) @@ -1403,7 +1710,6 @@ bool SvxExtParagraphTabPage::FillItemSet( SfxItemSet* rOutSet ) TriState eState = m_xApplyCollBtn->get_state(); bool bIsPageModel = false; - _nWhich = GetWhich( SID_ATTR_PARA_MODEL ); OUString sPage; if ( m_xApplyCollBtn->get_state_changed_from_saved() || ( TRISTATE_TRUE == eState && @@ -1418,7 +1724,7 @@ bool SvxExtParagraphTabPage::FillItemSet( SfxItemSet* rOutSet ) if ( !pOld || static_cast<const SvxPageModelItem*>(pOld)->GetValue() != sPage ) { - rOutSet->Put( SvxPageModelItem( sPage, false, _nWhich ) ); + rOutSet->Put( SvxPageModelItem( sPage, false, SID_ATTR_PARA_MODEL ) ); bModified = true; } else @@ -1427,7 +1733,7 @@ bool SvxExtParagraphTabPage::FillItemSet( SfxItemSet* rOutSet ) else if(TRISTATE_TRUE == eState && m_xApplyCollBtn->get_sensitive()) bIsPageModel = true; else - rOutSet->Put( SvxPageModelItem( sPage, false, _nWhich ) ); + rOutSet->Put( SvxPageModelItem( sPage, false, SID_ATTR_PARA_MODEL ) ); _nWhich = GetWhich( SID_ATTR_PARA_PAGEBREAK ); @@ -1489,9 +1795,9 @@ bool SvxExtParagraphTabPage::FillItemSet( SfxItemSet* rOutSet ) // paragraph split _nWhich = GetWhich( SID_ATTR_PARA_SPLIT ); - eState = m_xKeepTogetherBox->get_state(); + eState = m_xAllowSplitBox->get_state(); - if (m_xKeepTogetherBox->get_state_changed_from_saved()) + if (m_xAllowSplitBox->get_state_changed_from_saved()) { pOld = GetOldItem( *rOutSet, SID_ATTR_PARA_SPLIT ); @@ -1515,14 +1821,14 @@ bool SvxExtParagraphTabPage::FillItemSet( SfxItemSet* rOutSet ) } // widows and orphans - _nWhich = GetWhich( SID_ATTR_PARA_WIDOWS ); + TypedWhichId<SvxWidowsItem> nWidowsWhich = GetWhich( SID_ATTR_PARA_WIDOWS ); eState = m_xWidowBox->get_state(); if ( m_xWidowBox->get_state_changed_from_saved() || m_xWidowRowNo->get_value_changed_from_saved() ) { SvxWidowsItem rItem( eState == TRISTATE_TRUE ? - static_cast<sal_uInt8>(m_xWidowRowNo->get_value()) : 0, _nWhich ); + static_cast<sal_uInt8>(m_xWidowRowNo->get_value()) : 0, nWidowsWhich ); pOld = GetOldItem( *rOutSet, SID_ATTR_PARA_WIDOWS ); if ( m_xWidowBox->get_state_changed_from_saved() || !pOld || !( *static_cast<const SvxWidowsItem*>(pOld) == rItem ) ) @@ -1532,14 +1838,14 @@ bool SvxExtParagraphTabPage::FillItemSet( SfxItemSet* rOutSet ) } } - _nWhich = GetWhich( SID_ATTR_PARA_ORPHANS ); + TypedWhichId<SvxOrphansItem> nOrphansWhich = GetWhich( SID_ATTR_PARA_ORPHANS ); eState = m_xOrphanBox->get_state(); if ( m_xOrphanBox->get_state_changed_from_saved() || m_xOrphanRowNo->get_value_changed_from_saved() ) { SvxOrphansItem rItem( eState == TRISTATE_TRUE ? - static_cast<sal_uInt8>(m_xOrphanRowNo->get_value()) : 0, _nWhich ); + static_cast<sal_uInt8>(m_xOrphanRowNo->get_value()) : 0, nOrphansWhich ); pOld = GetOldItem( *rOutSet, SID_ATTR_PARA_ORPHANS ); if ( m_xOrphanBox->get_state_changed_from_saved() || @@ -1555,6 +1861,14 @@ bool SvxExtParagraphTabPage::FillItemSet( SfxItemSet* rOutSet ) } void SvxExtParagraphTabPage::Reset( const SfxItemSet* rSet ) { + SfxItemPool* pPool = rSet->GetPool(); + DBG_ASSERT( pPool, "Where is the pool?" ); + + // adjust metric + FieldUnit eFUnit = GetModuleFieldUnit( *rSet ); + if (UseCharUnitInUI(*rSet)) + eFUnit = FieldUnit::CHAR; + sal_uInt16 _nWhich = GetWhich( SID_ATTR_PARA_HYPHENZONE ); SfxItemState eItemState = rSet->GetItemState( _nWhich ); @@ -1568,40 +1882,61 @@ void SvxExtParagraphTabPage::Reset( const SfxItemSet* rSet ) bIsHyphen = rHyphen.IsHyphen(); m_xHyphenBox->set_state(bIsHyphen ? TRISTATE_TRUE : TRISTATE_FALSE); - m_xHyphenNoCapsBox->set_state(rHyphen.IsNoCapsHyphenation() ? TRISTATE_TRUE : TRISTATE_FALSE); + m_xHyphenNoCapsBox->set_state(rHyphen.IsNoCapsHyphenation() ? TRISTATE_FALSE : TRISTATE_TRUE); + m_xHyphenNoLastWordBox->set_state(rHyphen.IsNoLastWordHyphenation() ? TRISTATE_FALSE : TRISTATE_TRUE); m_xExtHyphenBeforeBox->set_value(rHyphen.GetMinLead()); m_xExtHyphenAfterBox->set_value(rHyphen.GetMinTrail()); + m_xExtCompoundHyphenBeforeBox->set_value(rHyphen.GetCompoundMinLead()); m_xMaxHyphenEdit->set_value(rHyphen.GetMaxHyphens()); + m_xMinWordLength->set_value(rHyphen.GetMinWordLength()); + m_aHyphenZone.SetFieldUnit(eFUnit); + m_aHyphenZone.SetMetricValue(rHyphen.GetTextHyphenZone(), MapUnit::MapTwip); + m_xAcrossColumnBox->set_state(!rHyphen.IsKeep() || rHyphen.GetKeepType() < 3 ? TRISTATE_TRUE : TRISTATE_FALSE); + m_xAcrossPageBox->set_state(!rHyphen.IsKeep() || rHyphen.GetKeepType() < 2 ? TRISTATE_TRUE : TRISTATE_FALSE); + m_xAcrossSpreadBox->set_state(!rHyphen.IsKeep() || rHyphen.GetKeepType() == 0 ? TRISTATE_TRUE : TRISTATE_FALSE); + aAcrossColumnState.bTriStateEnabled = false; + aAcrossPageState.bTriStateEnabled = false; + aAcrossSpreadState.bTriStateEnabled = false; } else { m_xHyphenBox->set_state(TRISTATE_INDET); m_xHyphenNoCapsBox->set_state(TRISTATE_INDET); + m_xHyphenNoLastWordBox->set_state(TRISTATE_INDET); } bool bEnable = bItemAvailable && bIsHyphen; m_xHyphenNoCapsBox->set_sensitive(bEnable); + m_xHyphenNoLastWordBox->set_sensitive(bEnable); m_xExtHyphenBeforeBox->set_sensitive(bEnable); m_xExtHyphenAfterBox->set_sensitive(bEnable); + m_xExtCompoundHyphenBeforeBox->set_sensitive(bEnable); m_xBeforeText->set_sensitive(bEnable); m_xAfterText->set_sensitive(bEnable); + m_xCompoundBeforeText->set_sensitive(bEnable); m_xMaxHyphenLabel->set_sensitive(bEnable); m_xMaxHyphenEdit->set_sensitive(bEnable); + m_xMinWordLabel->set_sensitive(bEnable); + m_xMinWordLength->set_sensitive(bEnable); + m_xHyphenZoneLabel->set_sensitive(bEnable); + m_aHyphenZone.set_sensitive(bEnable); + m_xAcrossText->set_sensitive(bEnable); + m_xAcrossColumnBox->set_sensitive(bEnable); + m_xAcrossPageBox->set_sensitive(bEnable); + m_xAcrossSpreadBox->set_sensitive(bEnable); - _nWhich = GetWhich( SID_ATTR_PARA_PAGENUM ); - - switch (rSet->GetItemState(_nWhich)) + switch (rSet->GetItemState(SID_ATTR_PARA_PAGENUM)) { case SfxItemState::SET: { aPageNumState.bTriStateEnabled = false; m_xPageNumBox->set_state(TRISTATE_TRUE); - SfxUInt16Item const*const pItem(rSet->GetItem<SfxUInt16Item>(_nWhich)); + SfxUInt16Item const*const pItem(rSet->GetItem<SfxUInt16Item>(SID_ATTR_PARA_PAGENUM)); const sal_uInt16 nPageNum(pItem->GetValue()); m_xPagenumEdit->set_value(nPageNum); break; } - case SfxItemState::DONTCARE: + case SfxItemState::INVALID: { aPageNumState.bTriStateEnabled = true; m_xPageNumBox->set_state(TRISTATE_INDET); @@ -1623,16 +1958,14 @@ void SvxExtParagraphTabPage::Reset( const SfxItemSet* rSet ) if ( bPageBreak ) { // first handle PageModel - _nWhich = GetWhich( SID_ATTR_PARA_MODEL ); bool bIsPageModel = false; - eItemState = rSet->GetItemState( _nWhich ); + eItemState = rSet->GetItemState( SID_ATTR_PARA_MODEL ); if ( eItemState >= SfxItemState::SET ) { aApplyCollState.bTriStateEnabled = false; - const SvxPageModelItem& rModel = - static_cast<const SvxPageModelItem&>(rSet->Get( _nWhich )); + const SvxPageModelItem& rModel = rSet->Get( SID_ATTR_PARA_MODEL ); const OUString& aStr( rModel.GetValue() ); if (!aStr.isEmpty() && m_xApplyCollBox->find_text(aStr) != -1) @@ -1661,7 +1994,7 @@ void SvxExtParagraphTabPage::Reset( const SfxItemSet* rSet ) m_xApplyCollBtn->set_state(TRISTATE_FALSE); } } - else if ( SfxItemState::DONTCARE == eItemState ) + else if ( SfxItemState::INVALID == eItemState ) { aApplyCollState.bTriStateEnabled = true; m_xApplyCollBtn->set_state(TRISTATE_INDET); @@ -1733,7 +2066,7 @@ void SvxExtParagraphTabPage::Reset( const SfxItemSet* rSet ) m_xBreakTypeLB->set_active(nType); m_xBreakPositionLB->set_active(nPosition); } - else if ( SfxItemState::DONTCARE == eItemState ) + else if ( SfxItemState::INVALID == eItemState ) m_xPageBreakBox->set_state(TRISTATE_INDET); else { @@ -1763,7 +2096,7 @@ void SvxExtParagraphTabPage::Reset( const SfxItemSet* rSet ) else m_xKeepParaBox->set_state(TRISTATE_FALSE); } - else if ( SfxItemState::DONTCARE == eItemState ) + else if ( SfxItemState::INVALID == eItemState ) m_xKeepParaBox->set_state(TRISTATE_INDET); else m_xKeepParaBox->set_sensitive(false); @@ -1775,70 +2108,69 @@ void SvxExtParagraphTabPage::Reset( const SfxItemSet* rSet ) { const SvxFormatSplitItem& rSplit = static_cast<const SvxFormatSplitItem&>(rSet->Get( _nWhich )); - aKeepTogetherState.bTriStateEnabled = false; + aAllowSplitState.bTriStateEnabled = false; if ( !rSplit.GetValue() ) - m_xKeepTogetherBox->set_state(TRISTATE_TRUE); + m_xAllowSplitBox->set_state(TRISTATE_FALSE); else { - m_xKeepTogetherBox->set_state(TRISTATE_FALSE); - - // widows and orphans + m_xAllowSplitBox->set_state(TRISTATE_TRUE); + // default widows and orphans to enabled m_xWidowBox->set_sensitive(true); - _nWhich = GetWhich( SID_ATTR_PARA_WIDOWS ); - SfxItemState eTmpState = rSet->GetItemState( _nWhich ); - - if ( eTmpState >= SfxItemState::DEFAULT ) - { - const SvxWidowsItem& rWidow = - static_cast<const SvxWidowsItem&>(rSet->Get( _nWhich )); - aWidowState.bTriStateEnabled = false; - const sal_uInt16 nLines = rWidow.GetValue(); + m_xOrphanBox->set_sensitive(true); + } - bool _bEnable = nLines > 0; - m_xWidowRowNo->set_value(m_xWidowRowNo->normalize(nLines)); - m_xWidowBox->set_state(_bEnable ? TRISTATE_TRUE : TRISTATE_FALSE); - m_xWidowRowNo->set_sensitive(_bEnable); - //m_xWidowRowLabel->set_sensitive(_bEnable); + // widows and orphans + _nWhich = GetWhich( SID_ATTR_PARA_WIDOWS ); + SfxItemState eTmpState = rSet->GetItemState( _nWhich ); - } - else if ( SfxItemState::DONTCARE == eTmpState ) - m_xWidowBox->set_state( TRISTATE_INDET ); - else - m_xWidowBox->set_sensitive(false); + if ( eTmpState >= SfxItemState::DEFAULT ) + { + const SvxWidowsItem& rWidow = + static_cast<const SvxWidowsItem&>(rSet->Get( _nWhich )); + aWidowState.bTriStateEnabled = false; + const sal_uInt16 nLines = rWidow.GetValue(); + + bool _bEnable = nLines > 0; + m_xWidowRowNo->set_value(m_xWidowRowNo->normalize(nLines)); + m_xWidowBox->set_state(_bEnable ? TRISTATE_TRUE : TRISTATE_FALSE); + m_xWidowRowNo->set_sensitive(_bEnable); + } + else if ( SfxItemState::INVALID == eTmpState ) + m_xWidowBox->set_state( TRISTATE_INDET ); + else + m_xWidowBox->set_sensitive(false); - m_xOrphanBox->set_sensitive(true); - _nWhich = GetWhich( SID_ATTR_PARA_ORPHANS ); - eTmpState = rSet->GetItemState( _nWhich ); + _nWhich = GetWhich( SID_ATTR_PARA_ORPHANS ); + eTmpState = rSet->GetItemState( _nWhich ); - if ( eTmpState >= SfxItemState::DEFAULT ) - { - const SvxOrphansItem& rOrphan = - static_cast<const SvxOrphansItem&>(rSet->Get( _nWhich )); - const sal_uInt16 nLines = rOrphan.GetValue(); - aOrphanState.bTriStateEnabled = false; + if ( eTmpState >= SfxItemState::DEFAULT ) + { + const SvxOrphansItem& rOrphan = + static_cast<const SvxOrphansItem&>(rSet->Get( _nWhich )); + const sal_uInt16 nLines = rOrphan.GetValue(); + aOrphanState.bTriStateEnabled = false; - bool _bEnable = nLines > 0; - m_xOrphanBox->set_state(_bEnable ? TRISTATE_TRUE : TRISTATE_FALSE); - m_xOrphanRowNo->set_value(m_xOrphanRowNo->normalize(nLines)); - m_xOrphanRowNo->set_sensitive(_bEnable); - m_xOrphanRowLabel->set_sensitive(_bEnable); + bool _bEnable = nLines > 0; + m_xOrphanBox->set_state(_bEnable ? TRISTATE_TRUE : TRISTATE_FALSE); + m_xOrphanRowNo->set_value(m_xOrphanRowNo->normalize(nLines)); + m_xOrphanRowNo->set_sensitive(_bEnable); + m_xOrphanRowLabel->set_sensitive(_bEnable); - } - else if ( SfxItemState::DONTCARE == eTmpState ) - m_xOrphanBox->set_state(TRISTATE_INDET); - else - m_xOrphanBox->set_sensitive(false); - aOrphanState.eState = m_xOrphanBox->get_state(); } + else if ( SfxItemState::INVALID == eTmpState ) + m_xOrphanBox->set_state(TRISTATE_INDET); + else + m_xOrphanBox->set_sensitive(false); + aOrphanState.eState = m_xOrphanBox->get_state(); } - else if ( SfxItemState::DONTCARE == eItemState ) - m_xKeepTogetherBox->set_state(TRISTATE_INDET); + else if ( SfxItemState::INVALID == eItemState ) + m_xAllowSplitBox->set_state(TRISTATE_INDET); else - m_xKeepTogetherBox->set_sensitive(false); + m_xAllowSplitBox->set_sensitive(false); // so that everything is enabled correctly - KeepTogetherHdl(); + AllowSplitHdl(); WidowHdl(); OrphanHdl(); ChangesApplied(); @@ -1847,9 +2179,16 @@ void SvxExtParagraphTabPage::ChangesApplied() { m_xHyphenBox->save_state(); m_xHyphenNoCapsBox->save_state(); - m_xExtHyphenBeforeBox->set_value(m_xExtHyphenBeforeBox->get_value()); - m_xExtHyphenAfterBox->set_value(m_xExtHyphenAfterBox->get_value()); - m_xMaxHyphenEdit->set_value(m_xMaxHyphenEdit->get_value()); + m_xHyphenNoLastWordBox->save_state(); + m_xExtHyphenBeforeBox->save_value(); + m_xExtHyphenAfterBox->save_value(); + m_xExtCompoundHyphenBeforeBox->save_value(); + m_xMaxHyphenEdit->save_value(); + m_xMinWordLength->save_value(); + m_aHyphenZone.save_value(); + m_xAcrossColumnBox->save_state(); + m_xAcrossPageBox->save_state(); + m_xAcrossSpreadBox->save_state(); m_xPageBreakBox->save_state(); m_xBreakPositionLB->save_value(); m_xBreakTypeLB->save_value(); @@ -1857,7 +2196,7 @@ void SvxExtParagraphTabPage::ChangesApplied() m_xApplyCollBox->save_value(); m_xPageNumBox->save_state(); m_xPagenumEdit->save_value(); - m_xKeepTogetherBox->save_state(); + m_xAllowSplitBox->save_state(); m_xKeepParaBox->save_state(); m_xWidowBox->save_state(); m_xOrphanBox->save_state(); @@ -1893,12 +2232,19 @@ SvxExtParagraphTabPage::SvxExtParagraphTabPage(weld::Container* pPage, weld::Dia // Hyphenation , m_xHyphenBox(m_xBuilder->weld_check_button("checkAuto")) , m_xHyphenNoCapsBox(m_xBuilder->weld_check_button("checkNoCaps")) + , m_xHyphenNoLastWordBox(m_xBuilder->weld_check_button("checkNoLastWord")) , m_xBeforeText(m_xBuilder->weld_label("labelLineBegin")) , m_xExtHyphenBeforeBox(m_xBuilder->weld_spin_button("spinLineEnd")) , m_xAfterText(m_xBuilder->weld_label("labelLineEnd")) , m_xExtHyphenAfterBox(m_xBuilder->weld_spin_button("spinLineBegin")) + , m_xCompoundBeforeText(m_xBuilder->weld_label("labelCompoundLineEnd")) + , m_xExtCompoundHyphenBeforeBox(m_xBuilder->weld_spin_button("spinCompoundLineEnd")) , m_xMaxHyphenLabel(m_xBuilder->weld_label("labelMaxNum")) , m_xMaxHyphenEdit(m_xBuilder->weld_spin_button("spinMaxNum")) + , m_xMinWordLabel(m_xBuilder->weld_label("labelMinLen")) + , m_xMinWordLength(m_xBuilder->weld_spin_button("spinMinLen")) + , m_xHyphenZoneLabel(m_xBuilder->weld_label("labelHyphenZone")) + , m_aHyphenZone(m_xBuilder->weld_metric_spin_button("spinHyphenZone", FieldUnit::CM)) //Page break , m_xPageBreakBox(m_xBuilder->weld_check_button("checkInsert")) , m_xBreakTypeFT(m_xBuilder->weld_label("labelType")) @@ -1910,7 +2256,7 @@ SvxExtParagraphTabPage::SvxExtParagraphTabPage(weld::Container* pPage, weld::Dia , m_xPageNumBox(m_xBuilder->weld_check_button("labelPageNum")) , m_xPagenumEdit(m_xBuilder->weld_spin_button("spinPageNumber")) // Options - , m_xKeepTogetherBox(m_xBuilder->weld_check_button("checkSplitPara")) + , m_xAllowSplitBox(m_xBuilder->weld_check_button("checkSplitPara")) , m_xKeepParaBox(m_xBuilder->weld_check_button("checkKeepPara")) , m_xOrphanBox(m_xBuilder->weld_check_button("checkOrphan")) , m_xOrphanRowNo(m_xBuilder->weld_spin_button("spinOrphan")) @@ -1918,13 +2264,18 @@ SvxExtParagraphTabPage::SvxExtParagraphTabPage(weld::Container* pPage, weld::Dia , m_xWidowBox(m_xBuilder->weld_check_button("checkWidow")) , m_xWidowRowNo(m_xBuilder->weld_spin_button("spinWidow")) , m_xWidowRowLabel(m_xBuilder->weld_label("labelWidow")) + // Avoid hyphenation across + , m_xAcrossText(m_xBuilder->weld_label("labelHyphenAcross")) + , m_xAcrossColumnBox(m_xBuilder->weld_check_button("checkAcrossColumn")) + , m_xAcrossPageBox(m_xBuilder->weld_check_button("checkAcrossPage")) + , m_xAcrossSpreadBox(m_xBuilder->weld_check_button("checkAcrossSpread")) { // this page needs ExchangeSupport SetExchangeSupport(); m_xHyphenBox->connect_toggled(LINK(this, SvxExtParagraphTabPage, HyphenClickHdl_Impl)); m_xPageBreakBox->connect_toggled(LINK(this, SvxExtParagraphTabPage, PageBreakHdl_Impl)); - m_xKeepTogetherBox->connect_toggled(LINK(this, SvxExtParagraphTabPage, KeepTogetherHdl_Impl)); + m_xAllowSplitBox->connect_toggled(LINK(this, SvxExtParagraphTabPage, AllowSplitHdl_Impl)); m_xWidowBox->connect_toggled(LINK(this, SvxExtParagraphTabPage, WidowHdl_Impl)); m_xOrphanBox->connect_toggled(LINK(this, SvxExtParagraphTabPage, OrphanHdl_Impl)); m_xApplyCollBtn->connect_toggled(LINK(this, SvxExtParagraphTabPage, ApplyCollClickHdl_Impl)); @@ -1932,9 +2283,11 @@ SvxExtParagraphTabPage::SvxExtParagraphTabPage(weld::Container* pPage, weld::Dia m_xBreakPositionLB->connect_changed(LINK(this, SvxExtParagraphTabPage, PageBreakPosHdl_Impl)); m_xPageNumBox->connect_toggled(LINK(this, SvxExtParagraphTabPage, PageNumBoxClickHdl_Impl)); m_xKeepParaBox->connect_toggled(LINK(this, SvxExtParagraphTabPage, KeepParaBoxClickHdl_Impl)); + m_xAcrossColumnBox->connect_toggled(LINK(this, SvxExtParagraphTabPage, AcrossColumnHdl_Impl)); + m_xAcrossPageBox->connect_toggled(LINK(this, SvxExtParagraphTabPage, AcrossPageHdl_Impl)); + m_xAcrossSpreadBox->connect_toggled(LINK(this, SvxExtParagraphTabPage, AcrossSpreadHdl_Impl)); - SfxObjectShell* pSh = SfxObjectShell::Current(); - if ( pSh ) + if (SfxObjectShell* pSh = SfxObjectShell::Current()) { SfxStyleSheetBasePool* pPool = pSh->GetStyleSheetPool(); SfxStyleSheetBase* pStyle = pPool->First(SfxStyleFamily::Page); @@ -1960,14 +2313,25 @@ SvxExtParagraphTabPage::SvxExtParagraphTabPage(weld::Container* pPage, weld::Dia bHtmlMode = true; m_xHyphenBox->set_sensitive(false); m_xHyphenNoCapsBox->set_sensitive(false); + m_xHyphenNoLastWordBox->set_sensitive(false); m_xBeforeText->set_sensitive(false); m_xExtHyphenBeforeBox->set_sensitive(false); m_xAfterText->set_sensitive(false); m_xExtHyphenAfterBox->set_sensitive(false); + m_xCompoundBeforeText->set_sensitive(false); + m_xExtCompoundHyphenBeforeBox->set_sensitive(false); m_xMaxHyphenLabel->set_sensitive(false); m_xMaxHyphenEdit->set_sensitive(false); + m_xMinWordLabel->set_sensitive(false); + m_xMinWordLength->set_sensitive(false); + m_xHyphenZoneLabel->set_sensitive(false); + m_aHyphenZone.set_sensitive(false); m_xPageNumBox->set_sensitive(false); m_xPagenumEdit->set_sensitive(false); + m_xAcrossText->set_sensitive(false); + m_xAcrossColumnBox->set_sensitive(false); + m_xAcrossPageBox->set_sensitive(false); + m_xAcrossSpreadBox->set_sensitive(false); // no column break in HTML m_xBreakTypeLB->remove(1); } @@ -2022,17 +2386,17 @@ IMPL_LINK(SvxExtParagraphTabPage, PageBreakHdl_Impl, weld::Toggleable&, rToggle, PageBreakHdl(); } -void SvxExtParagraphTabPage::KeepTogetherHdl() +void SvxExtParagraphTabPage::AllowSplitHdl() { - bool bEnable = m_xKeepTogetherBox->get_state() == TRISTATE_FALSE; + bool bEnable = m_xAllowSplitBox->get_state() == TRISTATE_TRUE; m_xWidowBox->set_sensitive(bEnable); m_xOrphanBox->set_sensitive(bEnable); } -IMPL_LINK(SvxExtParagraphTabPage, KeepTogetherHdl_Impl, weld::Toggleable&, rToggle, void) +IMPL_LINK(SvxExtParagraphTabPage, AllowSplitHdl_Impl, weld::Toggleable&, rToggle, void) { - aKeepTogetherState.ButtonToggled(rToggle); - KeepTogetherHdl(); + aAllowSplitState.ButtonToggled(rToggle); + AllowSplitHdl(); } void SvxExtParagraphTabPage::WidowHdl() @@ -2042,11 +2406,11 @@ void SvxExtParagraphTabPage::WidowHdl() case TRISTATE_TRUE: m_xWidowRowNo->set_sensitive(true); m_xWidowRowLabel->set_sensitive(true); - m_xKeepTogetherBox->set_sensitive(false); + m_xAllowSplitBox->set_sensitive(true); break; case TRISTATE_FALSE: if (m_xOrphanBox->get_state() == TRISTATE_FALSE) - m_xKeepTogetherBox->set_sensitive(true); + m_xAllowSplitBox->set_sensitive(false); [[fallthrough]]; case TRISTATE_INDET: m_xWidowRowNo->set_sensitive(false); @@ -2074,12 +2438,12 @@ void SvxExtParagraphTabPage::OrphanHdl() case TRISTATE_TRUE: m_xOrphanRowNo->set_sensitive(true); m_xOrphanRowLabel->set_sensitive(true); - m_xKeepTogetherBox->set_sensitive(false); + m_xAllowSplitBox->set_sensitive(true); break; case TRISTATE_FALSE: if (m_xWidowBox->get_state() == TRISTATE_FALSE) - m_xKeepTogetherBox->set_sensitive(true); + m_xAllowSplitBox->set_sensitive(true); [[fallthrough]]; case TRISTATE_INDET: m_xOrphanRowNo->set_sensitive(false); @@ -2092,12 +2456,23 @@ void SvxExtParagraphTabPage::HyphenClickHdl() { bool bEnable = m_xHyphenBox->get_state() == TRISTATE_TRUE; m_xHyphenNoCapsBox->set_sensitive(bEnable); + m_xHyphenNoLastWordBox->set_sensitive(bEnable); m_xBeforeText->set_sensitive(bEnable); m_xExtHyphenBeforeBox->set_sensitive(bEnable); m_xAfterText->set_sensitive(bEnable); m_xExtHyphenAfterBox->set_sensitive(bEnable); + m_xCompoundBeforeText->set_sensitive(bEnable); + m_xExtCompoundHyphenBeforeBox->set_sensitive(bEnable); m_xMaxHyphenLabel->set_sensitive(bEnable); m_xMaxHyphenEdit->set_sensitive(bEnable); + m_xMinWordLabel->set_sensitive(bEnable); + m_xMinWordLength->set_sensitive(bEnable); + m_xHyphenZoneLabel->set_sensitive(bEnable); + m_aHyphenZone.set_sensitive(bEnable); + m_xAcrossText->set_sensitive(bEnable); + m_xAcrossColumnBox->set_sensitive(bEnable); + m_xAcrossPageBox->set_sensitive(bEnable); + m_xAcrossSpreadBox->set_sensitive(bEnable); m_xHyphenBox->set_state(bEnable ? TRISTATE_TRUE : TRISTATE_FALSE); } @@ -2199,6 +2574,35 @@ void SvxExtParagraphTabPage::PageCreated(const SfxAllItemSet& aSet) DisablePageBreak(); } +IMPL_LINK(SvxExtParagraphTabPage, AcrossColumnHdl_Impl, weld::Toggleable&, rToggle, void) +{ + aAcrossColumnState.ButtonToggled(rToggle); + if (m_xAcrossColumnBox->get_state() != TRISTATE_TRUE ) + { + m_xAcrossPageBox->set_state( TRISTATE_FALSE ); + m_xAcrossSpreadBox->set_state( TRISTATE_FALSE ); + } +} + +IMPL_LINK(SvxExtParagraphTabPage, AcrossPageHdl_Impl, weld::Toggleable&, rToggle, void) +{ + aAcrossPageState.ButtonToggled(rToggle); + if (m_xAcrossPageBox->get_state() == TRISTATE_TRUE ) + m_xAcrossColumnBox->set_state( TRISTATE_TRUE ); + else + m_xAcrossSpreadBox->set_state( TRISTATE_FALSE ); +} + +IMPL_LINK(SvxExtParagraphTabPage, AcrossSpreadHdl_Impl, weld::Toggleable&, rToggle, void) +{ + aAcrossSpreadState.ButtonToggled(rToggle); + if (m_xAcrossSpreadBox->get_state() == TRISTATE_TRUE ) + { + m_xAcrossColumnBox->set_state( TRISTATE_TRUE ); + m_xAcrossPageBox->set_state( TRISTATE_TRUE ); + } +} + SvxAsianTabPage::SvxAsianTabPage(weld::Container* pPage, weld::DialogController* pController, const SfxItemSet& rSet) : SfxTabPage(pPage, pController, "cui/ui/asiantypography.ui", "AsianTypography", &rSet) , m_xForbiddenRulesCB(m_xBuilder->weld_check_button("checkForbidList")) @@ -2228,7 +2632,7 @@ bool SvxAsianTabPage::FillItemSet( SfxItemSet* rSet ) if (m_xScriptSpaceCB->get_sensitive() && m_xScriptSpaceCB->get_state_changed_from_saved()) { std::unique_ptr<SfxBoolItem> pNewItem(static_cast<SfxBoolItem*>(rSet->Get( - pPool->GetWhich(SID_ATTR_PARA_SCRIPTSPACE)).Clone())); + pPool->GetWhichIDFromSlotID(SID_ATTR_PARA_SCRIPTSPACE)).Clone())); pNewItem->SetValue(m_xScriptSpaceCB->get_active()); rSet->Put(std::move(pNewItem)); bRet = true; @@ -2236,7 +2640,7 @@ bool SvxAsianTabPage::FillItemSet( SfxItemSet* rSet ) if (m_xHangingPunctCB->get_sensitive() && m_xHangingPunctCB->get_state_changed_from_saved()) { std::unique_ptr<SfxBoolItem> pNewItem(static_cast<SfxBoolItem*>(rSet->Get( - pPool->GetWhich(SID_ATTR_PARA_HANGPUNCTUATION)).Clone())); + pPool->GetWhichIDFromSlotID(SID_ATTR_PARA_HANGPUNCTUATION)).Clone())); pNewItem->SetValue(m_xHangingPunctCB->get_active()); rSet->Put(std::move(pNewItem)); bRet = true; @@ -2244,7 +2648,7 @@ bool SvxAsianTabPage::FillItemSet( SfxItemSet* rSet ) if (m_xForbiddenRulesCB->get_sensitive() && m_xForbiddenRulesCB->get_state_changed_from_saved()) { std::unique_ptr<SfxBoolItem> pNewItem(static_cast<SfxBoolItem*>(rSet->Get( - pPool->GetWhich(SID_ATTR_PARA_FORBIDDEN_RULES)).Clone())); + pPool->GetWhichIDFromSlotID(SID_ATTR_PARA_FORBIDDEN_RULES)).Clone())); pNewItem->SetValue(m_xForbiddenRulesCB->get_active()); rSet->Put(std::move(pNewItem)); bRet = true; @@ -2254,7 +2658,7 @@ bool SvxAsianTabPage::FillItemSet( SfxItemSet* rSet ) static void lcl_SetBox(const SfxItemSet& rSet, sal_uInt16 nSlotId, weld::CheckButton& rBox) { - sal_uInt16 _nWhich = rSet.GetPool()->GetWhich(nSlotId); + sal_uInt16 _nWhich = rSet.GetPool()->GetWhichIDFromSlotID(nSlotId); SfxItemState eState = rSet.GetItemState(_nWhich); if( eState == SfxItemState::UNKNOWN || eState == SfxItemState::DISABLED ) rBox.set_sensitive(false); diff --git a/cui/source/tabpages/swpossizetabpage.cxx b/cui/source/tabpages/swpossizetabpage.cxx index 5e5352aff400..1a0d14759eac 100644 --- a/cui/source/tabpages/swpossizetabpage.cxx +++ b/cui/source/tabpages/swpossizetabpage.cxx @@ -19,6 +19,7 @@ #include <memory> #include <cstddef> +#include <type_traits> #include <swpossizetabpage.hxx> #include <svx/dlgutil.hxx> #include <svx/anchorid.hxx> @@ -37,6 +38,8 @@ #include <svtools/unitconv.hxx> #include <osl/diagnose.h> +#include <bitmaps.hlst> + using namespace ::com::sun::star::text; namespace { @@ -205,7 +208,7 @@ FrmMap const aHFlyHtmlMap[] = // #i18732# - own vertical alignment map for to frame anchored objects // #i22305# -#define VERT_FRAME_REL (LB::VertFrame|LB::FlyVertPrintArea) +#define VERT_FRAME_REL (LB::FlyVertFrame|LB::FlyVertPrintArea) FrmMap const aVFrameMap[] = { @@ -379,55 +382,54 @@ FrmMap const aVAsCharHtmlMap[] = static std::size_t lcl_GetFrmMapCount(const FrmMap* pMap) { - if( pMap ) - { - if( pMap == aVParaHtmlMap ) - return SAL_N_ELEMENTS(aVParaHtmlMap); - if( pMap == aVAsCharHtmlMap ) - return SAL_N_ELEMENTS( aVAsCharHtmlMap ); - if( pMap == aHParaHtmlMap ) - return SAL_N_ELEMENTS( aHParaHtmlMap ); - if( pMap == aHParaHtmlAbsMap ) - return SAL_N_ELEMENTS( aHParaHtmlAbsMap ); - if( pMap == aVPageMap ) - return SAL_N_ELEMENTS( aVPageMap ); - if( pMap == aVPageHtmlMap ) - return SAL_N_ELEMENTS( aVPageHtmlMap ); - if( pMap == aVAsCharMap ) - return SAL_N_ELEMENTS( aVAsCharMap ); - if( pMap == aVParaMap ) - return SAL_N_ELEMENTS( aVParaMap ); - if( pMap == aHParaMap ) - return SAL_N_ELEMENTS( aHParaMap ); - if( pMap == aHFrameMap ) - return SAL_N_ELEMENTS( aHFrameMap ); - if( pMap == aVFrameMap ) - return SAL_N_ELEMENTS( aVFrameMap ); - if( pMap == aHCharMap ) - return SAL_N_ELEMENTS( aHCharMap ); - if( pMap == aHCharHtmlMap ) - return SAL_N_ELEMENTS( aHCharHtmlMap ); - if( pMap == aHCharHtmlAbsMap ) - return SAL_N_ELEMENTS( aHCharHtmlAbsMap ); - if( pMap == aVCharMap ) - return SAL_N_ELEMENTS( aVCharMap ); - if( pMap == aVCharHtmlMap ) - return SAL_N_ELEMENTS( aVCharHtmlMap ); - if( pMap == aVCharHtmlAbsMap ) - return SAL_N_ELEMENTS( aVCharHtmlAbsMap ); - if( pMap == aHPageHtmlMap ) - return SAL_N_ELEMENTS( aHPageHtmlMap ); - if( pMap == aHFlyHtmlMap ) - return SAL_N_ELEMENTS( aHFlyHtmlMap ); - if( pMap == aVFlyHtmlMap ) - return SAL_N_ELEMENTS( aVFlyHtmlMap ); - if( pMap == aVMultiSelectionMap ) - return SAL_N_ELEMENTS( aVMultiSelectionMap ); - if( pMap == aHMultiSelectionMap ) - return SAL_N_ELEMENTS( aHMultiSelectionMap ); - return SAL_N_ELEMENTS(aHPageMap); - } - return 0; + if( !pMap ) + return 0; + + if( pMap == aVParaHtmlMap ) + return std::size(aVParaHtmlMap); + if( pMap == aVAsCharHtmlMap ) + return std::size( aVAsCharHtmlMap ); + if( pMap == aHParaHtmlMap ) + return std::size( aHParaHtmlMap ); + if( pMap == aHParaHtmlAbsMap ) + return std::size( aHParaHtmlAbsMap ); + if( pMap == aVPageMap ) + return std::size( aVPageMap ); + if( pMap == aVPageHtmlMap ) + return std::size( aVPageHtmlMap ); + if( pMap == aVAsCharMap ) + return std::size( aVAsCharMap ); + if( pMap == aVParaMap ) + return std::size( aVParaMap ); + if( pMap == aHParaMap ) + return std::size( aHParaMap ); + if( pMap == aHFrameMap ) + return std::size( aHFrameMap ); + if( pMap == aVFrameMap ) + return std::size( aVFrameMap ); + if( pMap == aHCharMap ) + return std::size( aHCharMap ); + if( pMap == aHCharHtmlMap ) + return std::size( aHCharHtmlMap ); + if( pMap == aHCharHtmlAbsMap ) + return std::size( aHCharHtmlAbsMap ); + if( pMap == aVCharMap ) + return std::size( aVCharMap ); + if( pMap == aVCharHtmlMap ) + return std::size( aVCharHtmlMap ); + if( pMap == aVCharHtmlAbsMap ) + return std::size( aVCharHtmlAbsMap ); + if( pMap == aHPageHtmlMap ) + return std::size( aHPageHtmlMap ); + if( pMap == aHFlyHtmlMap ) + return std::size( aHFlyHtmlMap ); + if( pMap == aVFlyHtmlMap ) + return std::size( aVFlyHtmlMap ); + if( pMap == aVMultiSelectionMap ) + return std::size( aVMultiSelectionMap ); + if( pMap == aHMultiSelectionMap ) + return std::size( aHMultiSelectionMap ); + return std::size(aHPageMap); } static SvxSwFramePosString::StringId lcl_ChangeResIdToVerticalOrRTL( @@ -466,19 +468,19 @@ static SvxSwFramePosString::StringId lcl_ChangeResIdToVerticalOrRTL( {SvxSwFramePosString::REL_FRM_TOP, SvxSwFramePosString::REL_FRM_LEFT }, {SvxSwFramePosString::REL_FRM_BOTTOM, SvxSwFramePosString::REL_FRM_RIGHT } }; - for(size_t nIndex = 0; nIndex < SAL_N_ELEMENTS(aHoriIds); ++nIndex) + for(const auto &a : aHoriIds) { - if(aHoriIds[nIndex].eHori == eStringId) + if(a.eHori == eStringId) { - eStringId = aHoriIds[nIndex].eVert; + eStringId = a.eVert; return eStringId; } } - for(size_t nIndex = 0; nIndex < SAL_N_ELEMENTS(aVertIds); ++nIndex) + for(const auto &a : aVertIds) { - if(aVertIds[nIndex].eHori == eStringId) + if(a.eHori == eStringId) { - eStringId = aVertIds[nIndex].eVert; + eStringId = a.eVert; break; } } @@ -539,9 +541,14 @@ SvxSwPosSizeTabPage::SvxSwPosSizeTabPage(weld::Container* pPage, weld::DialogCon , m_bIsMultiSelection(false) , m_bIsInRightToLeft(false) , m_nProtectSizeState(TRISTATE_FALSE) + , m_aRatioTop(ConnectorType::Top) + , m_aRatioBottom(ConnectorType::Bottom) , m_xWidthMF(m_xBuilder->weld_metric_spin_button("width", FieldUnit::CM)) , m_xHeightMF(m_xBuilder->weld_metric_spin_button("height", FieldUnit::CM)) , m_xKeepRatioCB(m_xBuilder->weld_check_button("ratio")) + , m_xCbxScaleImg(m_xBuilder->weld_image("imRatio")) + , m_xImgRatioTop(new weld::CustomWeld(*m_xBuilder, "daRatioTop", m_aRatioTop)) + , m_xImgRatioBottom(new weld::CustomWeld(*m_xBuilder, "daRatioBottom", m_aRatioBottom)) , m_xToPageRB(m_xBuilder->weld_radio_button("topage")) , m_xToParaRB(m_xBuilder->weld_radio_button("topara")) , m_xToCharRB(m_xBuilder->weld_radio_button("tochar")) @@ -575,6 +582,20 @@ SvxSwPosSizeTabPage::SvxSwPosSizeTabPage(weld::Container* pPage, weld::DialogCon SetFieldUnit(*m_xWidthMF , eDlgUnit, true); SetFieldUnit(*m_xHeightMF, eDlgUnit, true); + // vertical alignment = fill makes the drawingarea expand the associated spinedits so we have to size it here + const sal_Int16 aHeight + = static_cast<sal_Int16>(std::max(int(m_xKeepRatioCB->get_preferred_size().getHeight() / 2 + - m_xWidthMF->get_preferred_size().getHeight() / 2), + 12)); + const sal_Int16 aWidth + = static_cast<sal_Int16>(m_xKeepRatioCB->get_preferred_size().getWidth() / 2); + m_xImgRatioTop->set_size_request(aWidth, aHeight); + m_xImgRatioBottom->set_size_request(aWidth, aHeight); + //init needed for gtk3 + m_xCbxScaleImg->set_from_icon_name(m_xKeepRatioCB->get_active() ? RID_SVXBMP_LOCKED + : RID_SVXBMP_UNLOCKED); + m_xKeepRatioCB->connect_toggled(LINK(this, SvxSwPosSizeTabPage, RatioHdl_Impl)); + SetExchangeSupport(); Link<weld::Widget&,void> aLk3 = LINK(this, SvxSwPosSizeTabPage, RangeModifyHdl); @@ -627,27 +648,27 @@ namespace void SvxSwPosSizeTabPage::setOptimalFrmWidth() { static const FrmMaps aMaps[] = { - { aHPageMap, SAL_N_ELEMENTS(aHPageMap) }, - { aHPageHtmlMap, SAL_N_ELEMENTS(aHPageHtmlMap) }, - { aVPageMap, SAL_N_ELEMENTS(aVPageMap) }, - { aVPageHtmlMap, SAL_N_ELEMENTS(aVPageHtmlMap) }, - { aHFrameMap, SAL_N_ELEMENTS(aHFrameMap) }, - { aHFlyHtmlMap, SAL_N_ELEMENTS(aHFlyHtmlMap) }, - { aVFrameMap, SAL_N_ELEMENTS(aVFrameMap) }, - { aVFlyHtmlMap, SAL_N_ELEMENTS(aVFlyHtmlMap) }, - { aHParaMap, SAL_N_ELEMENTS(aHParaMap) }, - { aHParaHtmlMap, SAL_N_ELEMENTS(aHParaHtmlMap) }, - { aHParaHtmlAbsMap, SAL_N_ELEMENTS(aHParaHtmlAbsMap) }, - { aVParaMap, SAL_N_ELEMENTS(aVParaMap) }, - { aVParaHtmlMap, SAL_N_ELEMENTS(aVParaHtmlMap) }, - { aHCharMap, SAL_N_ELEMENTS(aHCharMap) }, - { aHCharHtmlMap, SAL_N_ELEMENTS(aHCharHtmlMap) }, - { aHCharHtmlAbsMap, SAL_N_ELEMENTS(aHCharHtmlAbsMap) }, - { aVCharMap, SAL_N_ELEMENTS(aVCharMap) }, - { aVCharHtmlMap, SAL_N_ELEMENTS(aVCharHtmlMap) }, - { aVCharHtmlAbsMap, SAL_N_ELEMENTS(aVCharHtmlAbsMap) }, - { aVAsCharMap, SAL_N_ELEMENTS(aVAsCharMap) }, - { aVAsCharHtmlMap, SAL_N_ELEMENTS(aVAsCharHtmlMap) } + { aHPageMap, std::size(aHPageMap) }, + { aHPageHtmlMap, std::size(aHPageHtmlMap) }, + { aVPageMap, std::size(aVPageMap) }, + { aVPageHtmlMap, std::size(aVPageHtmlMap) }, + { aHFrameMap, std::size(aHFrameMap) }, + { aHFlyHtmlMap, std::size(aHFlyHtmlMap) }, + { aVFrameMap, std::size(aVFrameMap) }, + { aVFlyHtmlMap, std::size(aVFlyHtmlMap) }, + { aHParaMap, std::size(aHParaMap) }, + { aHParaHtmlMap, std::size(aHParaHtmlMap) }, + { aHParaHtmlAbsMap, std::size(aHParaHtmlAbsMap) }, + { aVParaMap, std::size(aVParaMap) }, + { aVParaHtmlMap, std::size(aVParaHtmlMap) }, + { aHCharMap, std::size(aHCharMap) }, + { aHCharHtmlMap, std::size(aHCharHtmlMap) }, + { aHCharHtmlAbsMap, std::size(aHCharHtmlAbsMap) }, + { aVCharMap, std::size(aVCharMap) }, + { aVCharHtmlMap, std::size(aVCharHtmlMap) }, + { aVCharHtmlAbsMap, std::size(aVCharHtmlAbsMap) }, + { aVAsCharMap, std::size(aVAsCharMap) }, + { aVAsCharHtmlMap, std::size(aVAsCharHtmlMap) } }; std::vector<SvxSwFramePosString::StringId> aFrames; @@ -686,8 +707,8 @@ namespace void SvxSwPosSizeTabPage::setOptimalRelWidth() { static const RelationMaps aMaps[] = { - { aRelationMap, SAL_N_ELEMENTS(aRelationMap) }, - { aAsCharRelationMap, SAL_N_ELEMENTS(aAsCharRelationMap) } + { aRelationMap, std::size(aRelationMap) }, + { aAsCharRelationMap, std::size(aAsCharRelationMap) } }; std::vector<SvxSwFramePosString::StringId> aRels; @@ -749,7 +770,7 @@ bool SvxSwPosSizeTabPage::FillItemSet( SfxItemSet* rSet) rSet->InvalidateItem( SID_ATTR_TRANSFORM_PROTECT_POS ); else rSet->Put( - SfxBoolItem( GetWhich( SID_ATTR_TRANSFORM_PROTECT_POS ), + SfxBoolItem( SID_ATTR_TRANSFORM_PROTECT_POS, m_xPositionCB->get_state() == TRISTATE_TRUE ) ); bModified = true; } @@ -760,7 +781,7 @@ bool SvxSwPosSizeTabPage::FillItemSet( SfxItemSet* rSet) rSet->InvalidateItem( SID_ATTR_TRANSFORM_PROTECT_SIZE ); else rSet->Put( - SfxBoolItem( GetWhich( SID_ATTR_TRANSFORM_PROTECT_SIZE ), + SfxBoolItem( SID_ATTR_TRANSFORM_PROTECT_SIZE, m_xSizeCB->get_state() == TRISTATE_TRUE ) ); bModified = true; } @@ -784,8 +805,8 @@ bool SvxSwPosSizeTabPage::FillItemSet( SfxItemSet* rSet) nHoriByPos += m_aAnchorPos.X(); nVertByPos += m_aAnchorPos.Y(); - rSet->Put( SfxInt32Item( GetWhich( SID_ATTR_TRANSFORM_POS_X ), nHoriByPos ) ); - rSet->Put( SfxInt32Item( GetWhich( SID_ATTR_TRANSFORM_POS_Y ), nVertByPos ) ); + rSet->Put( SfxInt32Item( SID_ATTR_TRANSFORM_POS_X, nHoriByPos ) ); + rSet->Put( SfxInt32Item( SID_ATTR_TRANSFORM_POS_Y, nVertByPos ) ); bModified = true; } @@ -795,11 +816,11 @@ bool SvxSwPosSizeTabPage::FillItemSet( SfxItemSet* rSet) if ( m_pHMap ) { const SfxInt16Item& rHoriOrient = - static_cast<const SfxInt16Item&>(rOldSet.Get( SID_ATTR_TRANSFORM_HORI_ORIENT)); + rOldSet.Get( SID_ATTR_TRANSFORM_HORI_ORIENT ); const SfxInt16Item& rHoriRelation = - static_cast<const SfxInt16Item&>(rOldSet.Get( SID_ATTR_TRANSFORM_HORI_RELATION)); + rOldSet.Get( SID_ATTR_TRANSFORM_HORI_RELATION); const SfxInt32Item& rHoriPosition = - static_cast<const SfxInt32Item&>(rOldSet.Get( SID_ATTR_TRANSFORM_HORI_POSITION)) ; + rOldSet.Get( SID_ATTR_TRANSFORM_HORI_POSITION); sal_uInt16 nMapPos = GetMapPos(m_pHMap, *m_xHoriLB); short nAlign = GetAlignment(m_pHMap, nMapPos, *m_xHoriToLB); @@ -824,11 +845,11 @@ bool SvxSwPosSizeTabPage::FillItemSet( SfxItemSet* rSet) if ( m_pVMap ) { const SfxInt16Item& rVertOrient = - static_cast<const SfxInt16Item&>(rOldSet.Get( SID_ATTR_TRANSFORM_VERT_ORIENT)); + rOldSet.Get( SID_ATTR_TRANSFORM_VERT_ORIENT); const SfxInt16Item& rVertRelation = - static_cast<const SfxInt16Item&>(rOldSet.Get( SID_ATTR_TRANSFORM_VERT_RELATION)); + rOldSet.Get( SID_ATTR_TRANSFORM_VERT_RELATION); const SfxInt32Item& rVertPosition = - static_cast<const SfxInt32Item&>(rOldSet.Get( SID_ATTR_TRANSFORM_VERT_POSITION)); + rOldSet.Get( SID_ATTR_TRANSFORM_VERT_POSITION); sal_uInt16 nMapPos = GetMapPos(m_pVMap, *m_xVertLB); short nAlign = GetAlignment(m_pVMap, nMapPos, *m_xVertToLB); @@ -862,7 +883,7 @@ bool SvxSwPosSizeTabPage::FillItemSet( SfxItemSet* rSet) { std::unique_ptr<SfxBoolItem> pFollow(static_cast<SfxBoolItem*>(pItem->Clone())); pFollow->SetValue(m_xFollowCB->get_active()); - bModified |= nullptr != rSet->Put(*pFollow); + bModified |= nullptr != rSet->Put(std::move(pFollow)); } } } @@ -871,10 +892,10 @@ bool SvxSwPosSizeTabPage::FillItemSet( SfxItemSet* rSet) { sal_uInt32 nWidth = static_cast<sal_uInt32>(m_xWidthMF->denormalize(m_xWidthMF->get_value(FieldUnit::TWIP))); sal_uInt32 nHeight = static_cast<sal_uInt32>(m_xHeightMF->denormalize(m_xHeightMF->get_value(FieldUnit::TWIP))); - rSet->Put( SfxUInt32Item( GetWhich( SID_ATTR_TRANSFORM_WIDTH ), nWidth ) ); - rSet->Put( SfxUInt32Item( GetWhich( SID_ATTR_TRANSFORM_HEIGHT ), nHeight ) ); + rSet->Put( SfxUInt32Item( SID_ATTR_TRANSFORM_WIDTH, nWidth ) ); + rSet->Put( SfxUInt32Item( SID_ATTR_TRANSFORM_HEIGHT, nHeight ) ); //this item is required by SdrEditView::SetGeoAttrToMarked() - rSet->Put( SfxUInt16Item( GetWhich( SID_ATTR_TRANSFORM_SIZE_POINT ), sal_uInt16(RectPoint::LT) ) ); + rSet->Put( SfxUInt16Item( SID_ATTR_TRANSFORM_SIZE_POINT, sal_uInt16(RectPoint::LT) ) ); bModified = true; } @@ -1050,9 +1071,9 @@ DeactivateRC SvxSwPosSizeTabPage::DeactivatePage( SfxItemSet* _pSet ) { if( _pSet ) { - _pSet->Put(SfxBoolItem(GetWhich( SID_ATTR_TRANSFORM_PROTECT_POS ), + _pSet->Put(SfxBoolItem( SID_ATTR_TRANSFORM_PROTECT_POS, m_xPositionCB->get_active())); - _pSet->Put(SfxBoolItem(GetWhich( SID_ATTR_TRANSFORM_PROTECT_SIZE ), + _pSet->Put(SfxBoolItem( SID_ATTR_TRANSFORM_PROTECT_SIZE, m_xSizeCB->get_active())); FillItemSet( _pSet ); } @@ -1109,6 +1130,11 @@ RndStdIds SvxSwPosSizeTabPage::GetAnchorType(bool* pbHasChanged) return nRet; } +IMPL_LINK_NOARG(SvxSwPosSizeTabPage, RatioHdl_Impl, weld::Toggleable&, void) +{ + m_xCbxScaleImg->set_from_icon_name(m_xKeepRatioCB->get_active() ? RID_SVXBMP_LOCKED : RID_SVXBMP_UNLOCKED); +} + IMPL_LINK_NOARG(SvxSwPosSizeTabPage, RangeModifyClickHdl, weld::Toggleable&, void) { RangeModifyHdl(m_xWidthMF->get_widget()); @@ -1269,7 +1295,7 @@ IMPL_LINK(SvxSwPosSizeTabPage, PosHdl, weld::ComboBox&, rLB, void) if (rLB.get_active() != -1) { if (pRelLB->get_active() != -1) - nRel = reinterpret_cast<RelationMap*>(pRelLB->get_active_id().toUInt64())->nRelation; + nRel = weld::fromId<RelationMap*>(pRelLB->get_active_id())->nRelation; FillRelLB(pMap, nMapPos, nAlign, nRel, *pRelLB, *pRelFT); } @@ -1372,7 +1398,7 @@ short SvxSwPosSizeTabPage::GetRelation(const weld::ComboBox& rRelationLB) int nPos = rRelationLB.get_active(); if (nPos != -1) { - RelationMap *pEntry = reinterpret_cast<RelationMap*>(rRelationLB.get_id(nPos).toUInt64()); + RelationMap *pEntry = weld::fromId<RelationMap*>(rRelationLB.get_id(nPos)); nRel = pEntry->nRelation; } @@ -1390,7 +1416,7 @@ short SvxSwPosSizeTabPage::GetAlignment(FrmMap const *pMap, sal_uInt16 nMapPos, { if (rRelationLB.get_active() != -1) { - LB nRel = reinterpret_cast<RelationMap*>(rRelationLB.get_active_id().toUInt64())->nLBRelation; + LB nRel = weld::fromId<RelationMap*>(rRelationLB.get_active_id())->nLBRelation; std::size_t nMapCount = ::lcl_GetFrmMapCount(pMap); SvxSwFramePosString::StringId eStrId = pMap[nMapPos].eStrId; @@ -1460,7 +1486,7 @@ void SvxSwPosSizeTabPage::InitPos(RndStdIds nAnchor, m_nOldV = m_pVMap[nPos].nAlign; nPos = m_xVertToLB->get_active(); if (nPos != -1) - m_nOldVRel = reinterpret_cast<RelationMap*>(m_xVertToLB->get_id(nPos).toUInt64())->nRelation; + m_nOldVRel = weld::fromId<RelationMap*>(m_xVertToLB->get_id(nPos))->nRelation; } nPos = m_xHoriLB->get_active(); @@ -1470,7 +1496,7 @@ void SvxSwPosSizeTabPage::InitPos(RndStdIds nAnchor, nPos = m_xHoriToLB->get_active(); if (nPos != -1) - m_nOldHRel = reinterpret_cast<RelationMap*>(m_xHoriToLB->get_id(nPos).toUInt64())->nRelation; + m_nOldHRel = weld::fromId<RelationMap*>(m_xHoriToLB->get_id(nPos))->nRelation; } bool bEnable = true; @@ -1645,7 +1671,7 @@ void SvxSwPosSizeTabPage::FillRelLB(FrmMap const *pMap, sal_uInt16 nMapPos, sal_ if (pMap[_nMapPos].eStrId == eStrId) { nLBRelations = pMap[_nMapPos].nLBRelations; - for (size_t nRelPos = 0; nRelPos < SAL_N_ELEMENTS(aAsCharRelationMap); nRelPos++) + for (size_t nRelPos = 0; nRelPos < std::size(aAsCharRelationMap); nRelPos++) { if (nLBRelations & aAsCharRelationMap[nRelPos].nLBRelation) { @@ -1653,7 +1679,7 @@ void SvxSwPosSizeTabPage::FillRelLB(FrmMap const *pMap, sal_uInt16 nMapPos, sal_ sStrId1 = lcl_ChangeResIdToVerticalOrRTL(sStrId1, m_bIsVerticalFrame, m_bIsInRightToLeft); OUString sEntry = SvxSwFramePosString::GetString(sStrId1); - rLB.append(OUString::number(reinterpret_cast<sal_uInt64>(&aAsCharRelationMap[nRelPos])), sEntry); + rLB.append(weld::toId(&aAsCharRelationMap[nRelPos]), sEntry); if (pMap[_nMapPos].nAlign == nAlign) sSelEntry = sEntry; break; @@ -1670,7 +1696,7 @@ void SvxSwPosSizeTabPage::FillRelLB(FrmMap const *pMap, sal_uInt16 nMapPos, sal_ { for (int i = 0; i < rLB.get_count(); i++) { - RelationMap *pEntry = reinterpret_cast<RelationMap*>(rLB.get_id(i).toUInt64()); + RelationMap *pEntry = weld::fromId<RelationMap*>(rLB.get_id(i)); if (pEntry->nLBRelation == LB::RelChar) // Default { rLB.set_active(i); @@ -1697,18 +1723,18 @@ void SvxSwPosSizeTabPage::FillRelLB(FrmMap const *pMap, sal_uInt16 nMapPos, sal_ nLBRelations = pMap[nMapPos].nLBRelations; } - for (sal_uLong nBit = 1; nBit < sal_uLong(LB::LAST); nBit <<= 1) + for (std::underlying_type_t<LB> nBit = 1; nBit < o3tl::to_underlying(LB::LAST) ; nBit <<= 1) { if (nLBRelations & static_cast<LB>(nBit)) { - for (size_t nRelPos = 0; nRelPos < SAL_N_ELEMENTS(aRelationMap); nRelPos++) + for (size_t nRelPos = 0; nRelPos < std::size(aRelationMap); nRelPos++) { if (aRelationMap[nRelPos].nLBRelation == static_cast<LB>(nBit)) { SvxSwFramePosString::StringId sStrId1 = m_xHoriMirrorCB->get_active() ? aRelationMap[nRelPos].eMirrorStrId : aRelationMap[nRelPos].eStrId; sStrId1 = lcl_ChangeResIdToVerticalOrRTL(sStrId1, m_bIsVerticalFrame, m_bIsInRightToLeft); OUString sEntry = SvxSwFramePosString::GetString(sStrId1); - rLB.append(OUString::number(reinterpret_cast<sal_uInt64>(&aRelationMap[nRelPos])), sEntry); + rLB.append(weld::toId(&aRelationMap[nRelPos]), sEntry); if (sSelEntry.isEmpty() && aRelationMap[nRelPos].nRelation == nRel) sSelEntry = sEntry; } @@ -1734,7 +1760,7 @@ void SvxSwPosSizeTabPage::FillRelLB(FrmMap const *pMap, sal_uInt16 nMapPos, sal_ default: if (rLB.get_count()) { - RelationMap *pEntry = reinterpret_cast<RelationMap*>(rLB.get_id(rLB.get_count() - 1).toUInt64()); + RelationMap *pEntry = weld::fromId<RelationMap*>(rLB.get_id(rLB.get_count() - 1)); nRel = pEntry->nRelation; } break; @@ -1742,7 +1768,7 @@ void SvxSwPosSizeTabPage::FillRelLB(FrmMap const *pMap, sal_uInt16 nMapPos, sal_ for (int i = 0; i < rLB.get_count(); ++i) { - RelationMap *pEntry = reinterpret_cast<RelationMap*>(rLB.get_id(i).toUInt64()); + RelationMap *pEntry = weld::fromId<RelationMap*>(rLB.get_id(i)); if (pEntry->nRelation == nRel) { rLB.set_active(i); @@ -1867,7 +1893,7 @@ void SvxSwPosSizeTabPage::SetView( const SdrView* pSdrView ) const SdrObject* pObj = rMarkList.GetMark( 0 )->GetMarkedSdrObj(); SdrObjKind eKind = (SdrObjKind) pObj->GetObjIdentifier(); if( ( pObj->GetObjInventor() == SdrInventor::Default ) && - ( eKind==OBJ_TEXT || eKind==OBJ_TITLETEXT || eKind==OBJ_OUTLINETEXT) && + ( eKind==SdrObjKind::Text || eKind==SdrObjKind::TitleText || eKind==SdrObjKind::OutlineText) && pObj->HasText() ) { OSL_FAIL("AutoWidth/AutoHeight should be enabled"); diff --git a/cui/source/tabpages/tabarea.cxx b/cui/source/tabpages/tabarea.cxx index a400c0207839..a568eb08223b 100644 --- a/cui/source/tabpages/tabarea.cxx +++ b/cui/source/tabpages/tabarea.cxx @@ -31,7 +31,8 @@ SvxAreaTabDialog::SvxAreaTabDialog weld::Window* pParent, const SfxItemSet* pAttr, SdrModel* pModel, - bool bShadow + bool bShadow, + bool bSlideBackground ) : SfxTabDialogController(pParent, "cui/ui/areadialog.ui", "AreaDialog", pAttr) , mpDrawModel ( pModel ), @@ -52,7 +53,10 @@ SvxAreaTabDialog::SvxAreaTabDialog mnGradientListState ( ChangeType::NONE ), mnHatchingListState ( ChangeType::NONE ) { - AddTabPage("RID_SVXPAGE_AREA", SvxAreaTabPage::Create, nullptr); + if (bSlideBackground) + AddTabPage("RID_SVXPAGE_AREA", SvxAreaTabPage::CreateWithSlideBackground, nullptr); + else + AddTabPage("RID_SVXPAGE_AREA", SvxAreaTabPage::Create, nullptr); if (bShadow) { @@ -71,55 +75,46 @@ SvxAreaTabDialog::SvxAreaTabDialog void SvxAreaTabDialog::SavePalettes() { - SfxObjectShell* pShell = SfxObjectShell::Current(); + SfxObjectShell* pShell(SfxObjectShell::Current()); + if (!pShell) + { + SAL_WARN("cui.dialogs", "SvxAreaTabDialog: No SfxObjectShell!"); + return; + } + if( mpNewColorList != mpDrawModel->GetColorList() ) { mpDrawModel->SetPropertyList( static_cast<XPropertyList *>(mpNewColorList.get()) ); SvxColorListItem aColorListItem( mpNewColorList, SID_COLOR_TABLE ); - if ( pShell ) - pShell->PutItem( aColorListItem ); - else - mpDrawModel->GetItemPool().Put(aColorListItem,SID_COLOR_TABLE); + pShell->PutItem( aColorListItem ); mpColorList = mpDrawModel->GetColorList(); } if( mpNewGradientList != mpDrawModel->GetGradientList() ) { mpDrawModel->SetPropertyList( static_cast<XPropertyList *>(mpNewGradientList.get()) ); SvxGradientListItem aItem( mpNewGradientList, SID_GRADIENT_LIST ); - if ( pShell ) - pShell->PutItem( aItem ); - else - mpDrawModel->GetItemPool().Put(aItem,SID_GRADIENT_LIST); + pShell->PutItem( aItem ); mpGradientList = mpDrawModel->GetGradientList(); } if( mpNewHatchingList != mpDrawModel->GetHatchList() ) { mpDrawModel->SetPropertyList( static_cast<XPropertyList *>(mpNewHatchingList.get()) ); SvxHatchListItem aItem( mpNewHatchingList, SID_HATCH_LIST ); - if ( pShell ) - pShell->PutItem( aItem ); - else - mpDrawModel->GetItemPool().Put(aItem,SID_HATCH_LIST); + pShell->PutItem( aItem ); mpHatchingList = mpDrawModel->GetHatchList(); } if( mpNewBitmapList != mpDrawModel->GetBitmapList() ) { mpDrawModel->SetPropertyList( static_cast<XPropertyList *>(mpNewBitmapList.get()) ); SvxBitmapListItem aItem( mpNewBitmapList, SID_BITMAP_LIST ); - if ( pShell ) - pShell->PutItem( aItem ); - else - mpDrawModel->GetItemPool().Put(aItem,SID_BITMAP_LIST); + pShell->PutItem( aItem ); mpBitmapList = mpDrawModel->GetBitmapList(); } if( mpNewPatternList != mpDrawModel->GetPatternList() ) { mpDrawModel->SetPropertyList( static_cast<XPropertyList *>(mpNewPatternList.get()) ); SvxPatternListItem aItem( mpNewPatternList, SID_PATTERN_LIST ); - if( pShell ) - pShell->PutItem( aItem ); - else - mpDrawModel->GetItemPool().Put(aItem,SID_PATTERN_LIST); + pShell->PutItem( aItem ); mpPatternList = mpDrawModel->GetPatternList(); } @@ -141,10 +136,7 @@ void SvxAreaTabDialog::SavePalettes() SvxHatchListItem aItem( mpHatchingList, SID_HATCH_LIST ); // ToolBoxControls are informed: - if ( pShell ) - pShell->PutItem( aItem ); - else - mpDrawModel->GetItemPool().Put(aItem); + pShell->PutItem( aItem ); } if( mnBitmapListState & ChangeType::MODIFIED ) @@ -154,12 +146,7 @@ void SvxAreaTabDialog::SavePalettes() SvxBitmapListItem aItem( mpBitmapList, SID_BITMAP_LIST ); // ToolBoxControls are informed: - if ( pShell ) - pShell->PutItem( aItem ); - else - { - mpDrawModel->GetItemPool().Put(aItem); - } + pShell->PutItem( aItem ); } if( mnPatternListState & ChangeType::MODIFIED ) @@ -169,10 +156,7 @@ void SvxAreaTabDialog::SavePalettes() SvxPatternListItem aItem( mpPatternList, SID_PATTERN_LIST ); // ToolBoxControls are informed: - if( pShell ) - pShell->PutItem( aItem ); - else - mpDrawModel->GetItemPool().Put(aItem); + pShell->PutItem( aItem ); } if( mnGradientListState & ChangeType::MODIFIED ) @@ -182,24 +166,14 @@ void SvxAreaTabDialog::SavePalettes() SvxGradientListItem aItem( mpGradientList, SID_GRADIENT_LIST ); // ToolBoxControls are informed: - if ( pShell ) - pShell->PutItem( aItem ); - else - { - mpDrawModel->GetItemPool().Put(aItem); - } + pShell->PutItem( aItem ); } if (mnColorListState & ChangeType::MODIFIED && mpColorList.is()) { SvxColorListItem aItem( mpColorList, SID_COLOR_TABLE ); // ToolBoxControls are informed: - if ( pShell ) - pShell->PutItem( aItem ); - else - { - mpDrawModel->GetItemPool().Put(aItem); - } + pShell->PutItem( aItem ); } } @@ -218,7 +192,7 @@ IMPL_LINK_NOARG(SvxAreaTabDialog, CancelHdlImpl, weld::Button&, void) m_xDialog->response(RET_CANCEL); } -void SvxAreaTabDialog::PageCreated(const OString& rId, SfxTabPage &rPage) +void SvxAreaTabDialog::PageCreated(const OUString& rId, SfxTabPage &rPage) { if (rId == "RID_SVXPAGE_AREA") { diff --git a/cui/source/tabpages/tabline.cxx b/cui/source/tabpages/tabline.cxx index f4e0a1268013..ac6cadd51109 100644 --- a/cui/source/tabpages/tabline.cxx +++ b/cui/source/tabpages/tabline.cxx @@ -50,12 +50,12 @@ SvxLineTabDialog::SvxLineTabDialog(weld::Window* pParent, const SfxItemSet* pAtt { switch( pObj->GetObjIdentifier() ) { - case OBJ_LINE: - case OBJ_PLIN: - case OBJ_PATHLINE: - case OBJ_FREELINE: - case OBJ_MEASURE: - case OBJ_EDGE: + case SdrObjKind::Line: + case SdrObjKind::PolyLine: + case SdrObjKind::PathLine: + case SdrObjKind::FreehandLine: + case SdrObjKind::Measure: + case SdrObjKind::Edge: bLineOnly = true; break; @@ -160,7 +160,7 @@ IMPL_LINK_NOARG(SvxLineTabDialog, CancelHdlImpl, weld::Button&, void) m_xDialog->response(RET_CANCEL); } -void SvxLineTabDialog::PageCreated(const OString& rId, SfxTabPage &rPage) +void SvxLineTabDialog::PageCreated(const OUString& rId, SfxTabPage &rPage) { if (rId == "RID_SVXPAGE_LINE") { diff --git a/cui/source/tabpages/tabstpge.cxx b/cui/source/tabpages/tabstpge.cxx index 7a4beeb8437e..b3a1745c26f9 100644 --- a/cui/source/tabpages/tabstpge.cxx +++ b/cui/source/tabpages/tabstpge.cxx @@ -52,7 +52,11 @@ void TabWin_Impl::Paint(vcl::RenderContext& rRenderContext, const ::tools::Recta Size aSize(GetOutputSizePixel()); aPoint.setX( aSize.Width() / 2 ); aPoint.setY( aSize.Height() / 2 ); - Ruler::DrawTab(rRenderContext, rRenderContext.GetSettings().GetStyleSettings().GetFontColor(), aPoint, nTabStyle); + const StyleSettings& rStyleSettings = Application::GetSettings().GetStyleSettings(); + rRenderContext.SetLineColor(rStyleSettings.GetShadowColor()); + rRenderContext.SetFillColor(rStyleSettings.GetDialogColor()); + rRenderContext.DrawRect(tools::Rectangle(Point(0,0), rRenderContext.GetOutputSize())); + Ruler::DrawTab(rRenderContext, rStyleSettings.GetDialogTextColor(), aPoint, nTabStyle); } SvxTabulatorTabPage::SvxTabulatorTabPage(weld::Container* pPage, weld::DialogController* pController, const SfxItemSet& rAttr) @@ -190,7 +194,7 @@ bool SvxTabulatorTabPage::FillItemSet(SfxItemSet* rSet) if (!pOld || *static_cast<const SvxTabStopItem*>(pOld) != *aTmp) { - rSet->Put(*aTmp); + rSet->Put(std::move(aTmp)); bModified = true; } } @@ -312,10 +316,9 @@ void SvxTabulatorTabPage::InitTabPos_Impl( sal_uInt16 nTabPos ) m_xTabBox->clear(); tools::Long nOffset = 0; - const SfxPoolItem* pItem = nullptr; - if (GetItemSet().GetItemState(SID_ATTR_TABSTOP_OFFSET, true, &pItem) == SfxItemState::SET) + if (const SfxInt32Item* pOffSetItem = GetItemSet().GetItemIfSet(SID_ATTR_TABSTOP_OFFSET)) { - nOffset = static_cast<const SfxInt32Item*>(pItem)->GetValue(); + nOffset = pOffSetItem->GetValue(); MapUnit eUnit = GetItemSet().GetPool()->GetMetric(GetWhich(SID_ATTR_TABSTOP)); nOffset = OutputDevice::LogicToLogic(nOffset, eUnit, MapUnit::Map100thMM); } @@ -426,12 +429,10 @@ void SvxTabulatorTabPage::NewHdl_Impl(const weld::Button* pBtn) return; tools::Long nOffset = 0; - const SfxPoolItem* pItem = nullptr; - if ( GetItemSet().GetItemState( SID_ATTR_TABSTOP_OFFSET, true, &pItem ) == - SfxItemState::SET ) + if ( const SfxInt32Item* pOffsetItem = GetItemSet().GetItemIfSet( SID_ATTR_TABSTOP_OFFSET ) ) { - nOffset = static_cast<const SfxInt32Item*>(pItem)->GetValue(); + nOffset = pOffsetItem->GetValue(); MapUnit eUnit = GetItemSet().GetPool()->GetMetric( GetWhich( SID_ATTR_TABSTOP ) ); nOffset = OutputDevice::LogicToLogic( nOffset, eUnit, MapUnit::Map100thMM ); } diff --git a/cui/source/tabpages/textanim.cxx b/cui/source/tabpages/textanim.cxx index 95d3463a1607..f0964e4957d6 100644 --- a/cui/source/tabpages/textanim.cxx +++ b/cui/source/tabpages/textanim.cxx @@ -53,12 +53,12 @@ SvxTextTabDialog::SvxTextTabDialog(weld::Window* pParent, const SfxItemSet* pAtt |* \************************************************************************/ -void SvxTextTabDialog::PageCreated(const OString& rId, SfxTabPage &rPage) +void SvxTextTabDialog::PageCreated(const OUString& rId, SfxTabPage &rPage) { if (rId != "RID_SVXPAGE_TEXTATTR") return; - SdrObjKind eKind = OBJ_NONE; + SdrObjKind eKind = SdrObjKind::NONE; if (pView) { const SdrMarkList& rMarkList = pView->GetMarkedObjectList(); @@ -140,7 +140,7 @@ void SvxTextAnimationPage::Reset( const SfxItemSet* rAttrs ) const SfxPoolItem* pItem = GetItem( *rAttrs, SDRATTR_TEXT_ANIKIND ); if( !pItem ) - pItem = &pPool->GetDefaultItem( SDRATTR_TEXT_ANIKIND ); + pItem = &pPool->GetUserOrPoolDefaultItem( SDRATTR_TEXT_ANIKIND ); eAniKind = static_cast<const SdrTextAniKindItem*>(pItem)->GetValue(); m_xLbEffect->set_active(sal::static_int_cast<sal_Int32>(eAniKind)); @@ -149,7 +149,7 @@ void SvxTextAnimationPage::Reset( const SfxItemSet* rAttrs ) // animation direction pItem = GetItem( *rAttrs, SDRATTR_TEXT_ANIDIRECTION ); if( !pItem ) - pItem = &pPool->GetDefaultItem( SDRATTR_TEXT_ANIDIRECTION ); + pItem = &pPool->GetUserOrPoolDefaultItem( SDRATTR_TEXT_ANIDIRECTION ); SelectDirection(static_cast<const SdrTextAniDirectionItem*>(pItem)->GetValue()); m_aUpState = m_xBtnUp->get_state(); @@ -160,7 +160,7 @@ void SvxTextAnimationPage::Reset( const SfxItemSet* rAttrs ) // Start inside pItem = GetItem( *rAttrs, SDRATTR_TEXT_ANISTARTINSIDE ); if( !pItem ) - pItem = &pPool->GetDefaultItem( SDRATTR_TEXT_ANISTARTINSIDE ); + pItem = &pPool->GetUserOrPoolDefaultItem( SDRATTR_TEXT_ANISTARTINSIDE ); if (static_cast<const SdrTextAniStartInsideItem*>(pItem)->GetValue()) m_xTsbStartInside->set_state(TRISTATE_TRUE); @@ -171,7 +171,7 @@ void SvxTextAnimationPage::Reset( const SfxItemSet* rAttrs ) // Stop inside pItem = GetItem( *rAttrs, SDRATTR_TEXT_ANISTOPINSIDE ); if( !pItem ) - pItem = &pPool->GetDefaultItem( SDRATTR_TEXT_ANISTOPINSIDE ); + pItem = &pPool->GetUserOrPoolDefaultItem( SDRATTR_TEXT_ANISTOPINSIDE ); if (static_cast<const SdrTextAniStopInsideItem*>(pItem)->GetValue()) m_xTsbStopInside->set_state(TRISTATE_TRUE); @@ -182,7 +182,7 @@ void SvxTextAnimationPage::Reset( const SfxItemSet* rAttrs ) // quantity pItem = GetItem( *rAttrs, SDRATTR_TEXT_ANICOUNT ); if( !pItem ) - pItem = &pPool->GetDefaultItem( SDRATTR_TEXT_ANICOUNT ); + pItem = &pPool->GetUserOrPoolDefaultItem( SDRATTR_TEXT_ANICOUNT ); tools::Long nValue = static_cast<tools::Long>(static_cast<const SdrTextAniCountItem*>(pItem)->GetValue()); m_xNumFldCount->set_value(nValue); @@ -207,7 +207,7 @@ void SvxTextAnimationPage::Reset( const SfxItemSet* rAttrs ) // delay pItem = GetItem( *rAttrs, SDRATTR_TEXT_ANIDELAY ); if( !pItem ) - pItem = &pPool->GetDefaultItem( SDRATTR_TEXT_ANIDELAY ); + pItem = &pPool->GetUserOrPoolDefaultItem( SDRATTR_TEXT_ANIDELAY ); nValue = static_cast<tools::Long>(static_cast<const SdrTextAniDelayItem*>(pItem)->GetValue()); m_xMtrFldDelay->set_value(nValue, FieldUnit::NONE); @@ -224,7 +224,7 @@ void SvxTextAnimationPage::Reset( const SfxItemSet* rAttrs ) // step size pItem = GetItem( *rAttrs, SDRATTR_TEXT_ANIAMOUNT ); if( !pItem ) - pItem = &pPool->GetDefaultItem( SDRATTR_TEXT_ANIAMOUNT ); + pItem = &pPool->GetUserOrPoolDefaultItem( SDRATTR_TEXT_ANIAMOUNT ); nValue = static_cast<tools::Long>(static_cast<const SdrTextAniAmountItem*>(pItem)->GetValue()); if (nValue <= 0) diff --git a/cui/source/tabpages/textattr.cxx b/cui/source/tabpages/textattr.cxx index d542f9b0810e..a803efffe5cb 100644 --- a/cui/source/tabpages/textattr.cxx +++ b/cui/source/tabpages/textattr.cxx @@ -24,7 +24,6 @@ #include <svx/sdtaitm.hxx> #include <svx/sdtfsitm.hxx> #include <svx/sdtcfitm.hxx> -#include <svx/svdobj.hxx> #include <svx/svxids.hrc> #include <textattr.hxx> @@ -49,7 +48,7 @@ const WhichRangesContainer SvxTextAttrPage::pRanges( SvxTextAttrPage::SvxTextAttrPage(weld::Container* pPage, weld::DialogController* pController, const SfxItemSet& rInAttrs) : SvxTabPage(pPage, pController, "cui/ui/textattrtabpage.ui", "TextAttributesPage", rInAttrs) , rOutAttrs(rInAttrs) - , m_eObjKind(OBJ_NONE) + , m_eObjKind(SdrObjKind::NONE) , bAutoGrowSizeEnabled(false) , bContourEnabled(false) , bAutoGrowWidthEnabled(false) @@ -110,34 +109,34 @@ void SvxTextAttrPage::Reset( const SfxItemSet* rAttrs ) const SdrMetricItem* pItem = GetItem(*rAttrs, SDRATTR_TEXT_LEFTDIST); if( !pItem ) - pItem = &pPool->GetDefaultItem( SDRATTR_TEXT_LEFTDIST ); + pItem = &pPool->GetUserOrPoolDefaultItem( SDRATTR_TEXT_LEFTDIST ); SetMetricValue(*m_xMtrFldLeft, pItem->GetValue(), eUnit); m_xMtrFldLeft->save_value(); pItem = GetItem( *rAttrs, SDRATTR_TEXT_RIGHTDIST ); if( !pItem ) - pItem = &pPool->GetDefaultItem( SDRATTR_TEXT_RIGHTDIST ); + pItem = &pPool->GetUserOrPoolDefaultItem( SDRATTR_TEXT_RIGHTDIST ); SetMetricValue(*m_xMtrFldRight, pItem->GetValue(), eUnit); m_xMtrFldRight->save_value(); pItem = GetItem( *rAttrs, SDRATTR_TEXT_UPPERDIST ); if( !pItem ) - pItem = &pPool->GetDefaultItem( SDRATTR_TEXT_UPPERDIST ); + pItem = &pPool->GetUserOrPoolDefaultItem( SDRATTR_TEXT_UPPERDIST ); SetMetricValue(*m_xMtrFldTop, pItem->GetValue(), eUnit); m_xMtrFldTop->save_value(); pItem = GetItem( *rAttrs, SDRATTR_TEXT_LOWERDIST ); if( !pItem ) - pItem = &pPool->GetDefaultItem( SDRATTR_TEXT_LOWERDIST ); + pItem = &pPool->GetUserOrPoolDefaultItem( SDRATTR_TEXT_LOWERDIST ); SetMetricValue(*m_xMtrFldBottom, pItem->GetValue(), eUnit); m_xMtrFldBottom->save_value(); // adjust to height and autogrowsize - if ( rAttrs->GetItemState( SDRATTR_TEXT_AUTOGROWHEIGHT ) != SfxItemState::DONTCARE ) + if ( rAttrs->GetItemState( SDRATTR_TEXT_AUTOGROWHEIGHT ) != SfxItemState::INVALID ) { m_xTsbAutoGrowHeight->set_state( rAttrs->Get( SDRATTR_TEXT_AUTOGROWHEIGHT ). GetValue() ? TRISTATE_TRUE : TRISTATE_FALSE ); @@ -154,7 +153,7 @@ void SvxTextAttrPage::Reset( const SfxItemSet* rAttrs ) m_xTsbAutoGrowSize->save_state(); // adjust to width - if ( rAttrs->GetItemState( SDRATTR_TEXT_AUTOGROWWIDTH ) != SfxItemState::DONTCARE ) + if ( rAttrs->GetItemState( SDRATTR_TEXT_AUTOGROWWIDTH ) != SfxItemState::INVALID ) { m_xTsbAutoGrowWidth->set_state( rAttrs->Get( SDRATTR_TEXT_AUTOGROWWIDTH ). GetValue() ? TRISTATE_TRUE : TRISTATE_FALSE ); @@ -164,7 +163,7 @@ void SvxTextAttrPage::Reset( const SfxItemSet* rAttrs ) m_xTsbAutoGrowWidth->save_state(); // wordwrap text - if ( rAttrs->GetItemState( SDRATTR_TEXT_WORDWRAP ) != SfxItemState::DONTCARE ) + if ( rAttrs->GetItemState( SDRATTR_TEXT_WORDWRAP ) != SfxItemState::INVALID ) { m_xTsbWordWrapText->set_state( rAttrs->Get( SDRATTR_TEXT_WORDWRAP ). GetValue() ? TRISTATE_TRUE : TRISTATE_FALSE ); @@ -179,7 +178,7 @@ void SvxTextAttrPage::Reset( const SfxItemSet* rAttrs ) SfxItemState eVState = rAttrs->GetItemState( SDRATTR_TEXT_VERTADJUST ); SfxItemState eHState = rAttrs->GetItemState( SDRATTR_TEXT_HORZADJUST ); - if(SfxItemState::DONTCARE != eVState && SfxItemState::DONTCARE != eHState) + if(SfxItemState::INVALID != eVState && SfxItemState::INVALID != eHState) { // VertAdjust and HorAdjust are unequivocal, thus SdrTextVertAdjust eTVA = rAttrs->Get(SDRATTR_TEXT_VERTADJUST).GetValue(); @@ -255,7 +254,7 @@ void SvxTextAttrPage::Reset( const SfxItemSet* rAttrs ) } // adjust to border - if (rAttrs->GetItemState(SDRATTR_TEXT_FITTOSIZE) != SfxItemState::DONTCARE) + if (rAttrs->GetItemState(SDRATTR_TEXT_FITTOSIZE) != SfxItemState::INVALID) { drawing::TextFitToSizeType const eFTS = rAttrs->Get( SDRATTR_TEXT_FITTOSIZE ).GetValue(); @@ -268,7 +267,7 @@ void SvxTextAttrPage::Reset( const SfxItemSet* rAttrs ) m_xTsbFitToSize->set_state( TRISTATE_INDET ); m_xTsbFitToSize->save_state(); - if( rAttrs->GetItemState( SDRATTR_TEXT_CONTOURFRAME ) != SfxItemState::DONTCARE ) + if( rAttrs->GetItemState( SDRATTR_TEXT_CONTOURFRAME ) != SfxItemState::INVALID ) { bool bContour = rAttrs->Get( SDRATTR_TEXT_CONTOURFRAME ).GetValue(); m_xTsbContour->set_state( bContour ? TRISTATE_TRUE : TRISTATE_FALSE ); @@ -395,34 +394,34 @@ bool SvxTextAttrPage::FillItemSet( SfxItemSet* rAttrs) // #103516# Do not change values if adjust controls were disabled. bool bIsDisabled(m_aCtlPosition.IsCompletelyDisabled()); - if(!bIsDisabled) - { - if( m_xTsbFullWidth->get_state() == TRISTATE_TRUE ) - { - if (IsTextDirectionLeftToRight()) - eTHA = SDRTEXTHORZADJUST_BLOCK; - else - eTVA = SDRTEXTVERTADJUST_BLOCK; - } + if(bIsDisabled) + return true; - if ( rOutAttrs.GetItemState( SDRATTR_TEXT_VERTADJUST ) != SfxItemState::DONTCARE ) - { - SdrTextVertAdjust eOldTVA = rOutAttrs.Get( SDRATTR_TEXT_VERTADJUST ).GetValue(); - if( eOldTVA != eTVA ) - rAttrs->Put( SdrTextVertAdjustItem( eTVA ) ); - } + if( m_xTsbFullWidth->get_state() == TRISTATE_TRUE ) + { + if (IsTextDirectionLeftToRight()) + eTHA = SDRTEXTHORZADJUST_BLOCK; else + eTVA = SDRTEXTVERTADJUST_BLOCK; + } + + if ( rOutAttrs.GetItemState( SDRATTR_TEXT_VERTADJUST ) != SfxItemState::INVALID ) + { + SdrTextVertAdjust eOldTVA = rOutAttrs.Get( SDRATTR_TEXT_VERTADJUST ).GetValue(); + if( eOldTVA != eTVA ) rAttrs->Put( SdrTextVertAdjustItem( eTVA ) ); + } + else + rAttrs->Put( SdrTextVertAdjustItem( eTVA ) ); - if ( rOutAttrs.GetItemState( SDRATTR_TEXT_HORZADJUST ) != SfxItemState::DONTCARE ) - { - SdrTextHorzAdjust eOldTHA = rOutAttrs.Get( SDRATTR_TEXT_HORZADJUST ).GetValue(); - if( eOldTHA != eTHA ) - rAttrs->Put( SdrTextHorzAdjustItem( eTHA ) ); - } - else + if ( rOutAttrs.GetItemState( SDRATTR_TEXT_HORZADJUST ) != SfxItemState::INVALID ) + { + SdrTextHorzAdjust eOldTHA = rOutAttrs.Get( SDRATTR_TEXT_HORZADJUST ).GetValue(); + if( eOldTHA != eTHA ) rAttrs->Put( SdrTextHorzAdjustItem( eTHA ) ); } + else + rAttrs->Put( SdrTextHorzAdjustItem( eTHA ) ); return true; } @@ -431,17 +430,17 @@ void SvxTextAttrPage::Construct() { switch (m_eObjKind) { - case OBJ_NONE: + case SdrObjKind::NONE: // indeterminate, show them all bFitToSizeEnabled = bContourEnabled = bWordWrapTextEnabled = bAutoGrowSizeEnabled = bAutoGrowWidthEnabled = bAutoGrowHeightEnabled = true; m_xCustomShapeText->show(); m_xDrawingText->show(); break; - case OBJ_TEXT: - case OBJ_TITLETEXT: - case OBJ_OUTLINETEXT: - case OBJ_CAPTION: + case SdrObjKind::Text: + case SdrObjKind::TitleText: + case SdrObjKind::OutlineText: + case SdrObjKind::Caption: // contour NOT possible for pure text objects bContourEnabled = bWordWrapTextEnabled = bAutoGrowSizeEnabled = false; @@ -450,7 +449,7 @@ void SvxTextAttrPage::Construct() m_xCustomShapeText->hide(); m_xDrawingText->show(); break; - case OBJ_CUSTOMSHAPE: + case SdrObjKind::CustomShape: bFitToSizeEnabled = bContourEnabled = bAutoGrowWidthEnabled = bAutoGrowHeightEnabled = false; bWordWrapTextEnabled = bAutoGrowSizeEnabled = true; m_xDrawingText->hide(); @@ -631,7 +630,7 @@ IMPL_LINK(SvxTextAttrPage, ClickHdl_Impl, weld::Toggleable&, rButton, void) // #103516# Do the setup based on states of hor/ver adjust SfxItemState eVState = rOutAttrs.GetItemState( SDRATTR_TEXT_VERTADJUST ); SfxItemState eHState = rOutAttrs.GetItemState( SDRATTR_TEXT_HORZADJUST ); - bool bHorAndVer(SfxItemState::DONTCARE == eVState || SfxItemState::DONTCARE == eHState); + bool bHorAndVer(SfxItemState::INVALID == eVState || SfxItemState::INVALID == eHState); // #83698# enable/disable text anchoring dependent of contour m_xFlPosition->set_sensitive(!bContour && !bHorAndVer); @@ -644,7 +643,7 @@ bool SvxTextAttrPage::IsTextDirectionLeftToRight() const bool bLeftToRightDirection = true; SfxItemState eState = rOutAttrs.GetItemState(SDRATTR_TEXTDIRECTION); - if(SfxItemState::DONTCARE != eState) + if(SfxItemState::INVALID != eState) { const SvxWritingModeItem& rItem = rOutAttrs.Get(SDRATTR_TEXTDIRECTION); if (rItem.GetValue() == css::text::WritingMode_TB_RL) diff --git a/cui/source/tabpages/tparea.cxx b/cui/source/tabpages/tparea.cxx index 2bacae4da9f5..b67990e29625 100644 --- a/cui/source/tabpages/tparea.cxx +++ b/cui/source/tabpages/tparea.cxx @@ -19,12 +19,14 @@ #include <svx/svxids.hrc> #include <svx/xfillit0.hxx> +#include <svx/xfilluseslidebackgrounditem.hxx> #include <svx/xflbckit.hxx> #include <svx/drawitem.hxx> #include <svx/xflclit.hxx> #include <svx/xflgrit.hxx> #include <svx/xflhtit.hxx> #include <svx/xbtmpit.hxx> +#include <svx/xgrscit.hxx> #include <cuitabarea.hxx> #include <sfx2/tabdlg.hxx> @@ -41,7 +43,8 @@ enum FillType GRADIENT, HATCH, BITMAP, - PATTERN + PATTERN, + USE_BACKGROUND_FILL }; } @@ -70,7 +73,8 @@ void lclExtendSize(Size& rSize, const Size& rInputSize) |* \************************************************************************/ -SvxAreaTabPage::SvxAreaTabPage(weld::Container* pPage, weld::DialogController* pController, const SfxItemSet& rInAttrs) +SvxAreaTabPage::SvxAreaTabPage(weld::Container* pPage, weld::DialogController* pController, + const SfxItemSet& rInAttrs, bool bSlideBackground) : SfxTabPage(pPage, pController, "cui/ui/areatabpage.ui", "AreaTabPage", &rInAttrs) // local fixed not o be changed values for local pointers , maFixed_ChangeType(ChangeType::NONE) @@ -89,6 +93,7 @@ SvxAreaTabPage::SvxAreaTabPage(weld::Container* pPage, weld::DialogController* p , m_xBtnHatch(m_xBuilder->weld_toggle_button("btnhatch")) , m_xBtnBitmap(m_xBuilder->weld_toggle_button("btnbitmap")) , m_xBtnPattern(m_xBuilder->weld_toggle_button("btnpattern")) + , m_xBtnUseBackground(m_xBuilder->weld_toggle_button("btnusebackground")) { maBox.AddButton(m_xBtnNone.get()); maBox.AddButton(m_xBtnColor.get()); @@ -96,6 +101,7 @@ SvxAreaTabPage::SvxAreaTabPage(weld::Container* pPage, weld::DialogController* p maBox.AddButton(m_xBtnHatch.get()); maBox.AddButton(m_xBtnBitmap.get()); maBox.AddButton(m_xBtnPattern.get()); + Link<weld::Toggleable&, void> aLink = LINK(this, SvxAreaTabPage, SelectFillTypeHdl_Impl); m_xBtnNone->connect_toggled(aLink); m_xBtnColor->connect_toggled(aLink); @@ -103,6 +109,13 @@ SvxAreaTabPage::SvxAreaTabPage(weld::Container* pPage, weld::DialogController* p m_xBtnHatch->connect_toggled(aLink); m_xBtnBitmap->connect_toggled(aLink); m_xBtnPattern->connect_toggled(aLink); + if (bSlideBackground) + { + maBox.AddButton(m_xBtnUseBackground.get()); + m_xBtnUseBackground->connect_toggled(aLink); + } + else + m_xBtnUseBackground->hide(); SetExchangeSupport(); } @@ -154,9 +167,9 @@ SvxAreaTabPage::~SvxAreaTabPage() void SvxAreaTabPage::ActivatePage( const SfxItemSet& rSet ) { drawing::FillStyle eXFS = drawing::FillStyle_NONE; - if( rSet.GetItemState( XATTR_FILLSTYLE ) != SfxItemState::DONTCARE ) + if( rSet.GetItemState( XATTR_FILLSTYLE ) != SfxItemState::INVALID ) { - XFillStyleItem aFillStyleItem( static_cast<const XFillStyleItem&>( rSet.Get( GetWhich( XATTR_FILLSTYLE ) ) ) ); + XFillStyleItem aFillStyleItem( rSet.Get( GetWhich( XATTR_FILLSTYLE ) ) ); eXFS = aFillStyleItem.GetValue(); m_rXFSet.Put( aFillStyleItem ); } @@ -166,33 +179,37 @@ void SvxAreaTabPage::ActivatePage( const SfxItemSet& rSet ) default: case drawing::FillStyle_NONE: { - SelectFillType(*m_xBtnNone); + XFillUseSlideBackgroundItem aBckItem( rSet.Get(XATTR_FILLUSESLIDEBACKGROUND)); + if (aBckItem.GetValue()) + SelectFillType(*m_xBtnUseBackground); + else + SelectFillType(*m_xBtnNone); break; } case drawing::FillStyle_SOLID: { - m_rXFSet.Put( static_cast<const XFillColorItem&>( rSet.Get( GetWhich( XATTR_FILLCOLOR ) ) ) ); + m_rXFSet.Put( rSet.Get( GetWhich( XATTR_FILLCOLOR ) ) ); SelectFillType(*m_xBtnColor); break; } case drawing::FillStyle_GRADIENT: { - m_rXFSet.Put( static_cast<const XFillGradientItem&>( rSet.Get( GetWhich( XATTR_FILLGRADIENT ) ) ) ); + m_rXFSet.Put( rSet.Get( GetWhich( XATTR_FILLGRADIENT ) ) ); + m_rXFSet.Put(rSet.Get(GetWhich(XATTR_GRADIENTSTEPCOUNT))); SelectFillType(*m_xBtnGradient); break; } case drawing::FillStyle_HATCH: { m_rXFSet.Put( rSet.Get(XATTR_FILLHATCH) ); - m_rXFSet.Put( rSet.Get(XATTR_FILLBACKGROUND) ); + m_rXFSet.Put( rSet.Get(XATTR_FILLUSESLIDEBACKGROUND) ); m_rXFSet.Put( rSet.Get(XATTR_FILLCOLOR) ); SelectFillType(*m_xBtnHatch); break; } case drawing::FillStyle_BITMAP: { - const bool bPattern - = rSet.Get(TypedWhichId<XFillBitmapItem>(GetWhich(XATTR_FILLBITMAP))).isPattern(); + const bool bPattern = rSet.Get(GetWhich(XATTR_FILLBITMAP)).isPattern(); // pass full item set here, bitmap fill has many attributes (tiling, size, offset etc.) m_rXFSet.Put( rSet ); if (!bPattern) @@ -223,6 +240,8 @@ DeactivateRC SvxAreaTabPage::DeactivatePage( SfxItemSet* _pSet ) { XFillStyleItem aStyleItem( drawing::FillStyle_NONE ); _pSet->Put( aStyleItem ); + XFillUseSlideBackgroundItem aFillBgItem( false ); + _pSet->Put( aFillBgItem ); } break; } @@ -236,6 +255,17 @@ DeactivateRC SvxAreaTabPage::DeactivatePage( SfxItemSet* _pSet ) return DeactivatePage_Impl<SvxBitmapTabPage&>(_pSet); case PATTERN: return DeactivatePage_Impl<SvxPatternTabPage>(_pSet); + case USE_BACKGROUND_FILL: + { + if ( m_bBtnClicked ) + { + XFillStyleItem aStyleItem( drawing::FillStyle_NONE ); + _pSet->Put( aStyleItem ); + XFillUseSlideBackgroundItem aFillBgItem( true ); + _pSet->Put( aFillBgItem ); + } + break; + } default: break; } @@ -248,6 +278,21 @@ bool SvxAreaTabPage::FillItemSet_Impl( SfxItemSet* rAttrs) return static_cast<TTabPage&>( *m_xFillTabPage ).FillItemSet( rAttrs ); } +OUString SvxAreaTabPage::GetAllStrings() +{ + OUString sAllStrings; + OUString toggleButton[] = { "btnnone", "btncolor", "btngradient", "btnbitmap", + "btnpattern", "btnhatch", "btnusebackground" }; + + for (const auto& toggle : toggleButton) + { + if (const auto& pString = m_xBuilder->weld_toggle_button(toggle)) + sAllStrings += pString->get_label() + " "; + } + + return sAllStrings.replaceAll("_", ""); +} + bool SvxAreaTabPage::FillItemSet( SfxItemSet* rAttrs ) { FillType eFillType = static_cast<FillType>(maBox.GetCurrentButtonPos()); @@ -256,6 +301,7 @@ bool SvxAreaTabPage::FillItemSet( SfxItemSet* rAttrs ) case TRANSPARENT: { rAttrs->Put( XFillStyleItem( drawing::FillStyle_NONE ) ); + rAttrs->Put( XFillUseSlideBackgroundItem( false ) ); return true; } case SOLID: @@ -278,6 +324,12 @@ bool SvxAreaTabPage::FillItemSet( SfxItemSet* rAttrs ) { return FillItemSet_Impl<SvxPatternTabPage>( rAttrs ); } + case USE_BACKGROUND_FILL: + { + rAttrs->Put( XFillStyleItem( drawing::FillStyle_NONE ) ); + rAttrs->Put( XFillUseSlideBackgroundItem( true ) ); + return true; + } default: return false; } @@ -332,6 +384,14 @@ std::unique_ptr<SfxTabPage> SvxAreaTabPage::Create(weld::Container* pPage, weld: return xRet; } +std::unique_ptr<SfxTabPage> SvxAreaTabPage::CreateWithSlideBackground( + weld::Container* pPage, weld::DialogController* pController, const SfxItemSet* rAttrs) +{ + auto xRet = std::make_unique<SvxAreaTabPage>(pPage, pController, *rAttrs, true); + xRet->SetOptimalSize(pController); + return xRet; +} + namespace { std::unique_ptr<SfxTabPage> lcl_CreateFillStyleTabPage(sal_uInt16 nId, weld::Container* pPage, weld::DialogController* pController, const SfxItemSet& rSet) @@ -345,6 +405,7 @@ std::unique_ptr<SfxTabPage> lcl_CreateFillStyleTabPage(sal_uInt16 nId, weld::Con case HATCH: fnCreate = &SvxHatchTabPage::Create; break; case BITMAP: fnCreate = &SvxBitmapTabPage::Create; break; case PATTERN: fnCreate = &SvxPatternTabPage::Create; break; + case USE_BACKGROUND_FILL: fnCreate = nullptr; break; } return fnCreate ? (*fnCreate)( pPage, pController, &rSet ) : nullptr; } @@ -373,8 +434,10 @@ void SvxAreaTabPage::SelectFillType(weld::Toggleable& rButton, const SfxItemSet* FillType eFillType = static_cast<FillType>(maBox.GetCurrentButtonPos()); m_xFillTabPage = lcl_CreateFillStyleTabPage(eFillType, m_xFillTab.get(), GetDialogController(), m_rXFSet); if (m_xFillTabPage) + { m_xFillTabPage->SetDialogController(GetDialogController()); - CreatePage(eFillType, m_xFillTabPage.get()); + CreatePage(eFillType, *m_xFillTabPage); + } } } @@ -398,63 +461,63 @@ void SvxAreaTabPage::PageCreated(const SfxAllItemSet& aSet) SetPatternList(pPatternListItem->GetPatternList()); } -void SvxAreaTabPage::CreatePage( sal_Int32 nId, SfxTabPage* pTab ) +void SvxAreaTabPage::CreatePage(sal_Int32 nId, SfxTabPage& rTab) { if(nId == SOLID ) { - auto* pColorTab = static_cast<SvxColorTabPage*>(pTab); - pColorTab->SetColorList(m_pColorList); - pColorTab->SetColorChgd(m_pnColorListState); - pColorTab->Construct(); - pColorTab->ActivatePage(m_rXFSet); - pColorTab->Reset(&m_rXFSet); - pColorTab->set_visible(true); + auto& rColorTab = static_cast<SvxColorTabPage&>(rTab); + rColorTab.SetColorList(m_pColorList); + rColorTab.SetColorChgd(m_pnColorListState); + rColorTab.Construct(); + rColorTab.ActivatePage(m_rXFSet); + rColorTab.Reset(&m_rXFSet); + rColorTab.set_visible(true); } else if(nId == GRADIENT) { - auto* pGradientTab = static_cast<SvxGradientTabPage*>(pTab); - pGradientTab->SetColorList(m_pColorList); - pGradientTab->SetGradientList(m_pGradientList); - pGradientTab->SetGrdChgd(m_pnGradientListState); - pGradientTab->SetColorChgd(m_pnColorListState); - pGradientTab->Construct(); - pGradientTab->ActivatePage(m_rXFSet); - pGradientTab->Reset(&m_rXFSet); - pGradientTab->set_visible(true); + auto& rGradientTab = static_cast<SvxGradientTabPage&>(rTab); + rGradientTab.SetColorList(m_pColorList); + rGradientTab.SetGradientList(m_pGradientList); + rGradientTab.SetGrdChgd(m_pnGradientListState); + rGradientTab.SetColorChgd(m_pnColorListState); + rGradientTab.Construct(); + rGradientTab.ActivatePage(m_rXFSet); + rGradientTab.Reset(&m_rXFSet); + rGradientTab.set_visible(true); } else if(nId == HATCH) { - auto* pHatchTab = static_cast<SvxHatchTabPage*>(pTab); - pHatchTab->SetColorList(m_pColorList); - pHatchTab->SetHatchingList(m_pHatchingList); - pHatchTab->SetHtchChgd(m_pnHatchingListState); - pHatchTab->SetColorChgd(m_pnColorListState); - pHatchTab->Construct(); - pHatchTab->ActivatePage(m_rXFSet); - pHatchTab->Reset(&m_rXFSet); - pHatchTab->set_visible(true); + auto& rHatchTab = static_cast<SvxHatchTabPage&>(rTab); + rHatchTab.SetColorList(m_pColorList); + rHatchTab.SetHatchingList(m_pHatchingList); + rHatchTab.SetHtchChgd(m_pnHatchingListState); + rHatchTab.SetColorChgd(m_pnColorListState); + rHatchTab.Construct(); + rHatchTab.ActivatePage(m_rXFSet); + rHatchTab.Reset(&m_rXFSet); + rHatchTab.set_visible(true); } else if(nId == BITMAP) { - auto* pBitmapTab = static_cast<SvxBitmapTabPage*>(pTab); - pBitmapTab->SetBitmapList(m_pBitmapList); - pBitmapTab->SetBmpChgd(m_pnBitmapListState); - pBitmapTab->Construct(); - pBitmapTab->ActivatePage(m_rXFSet); - pBitmapTab->Reset(&m_rXFSet); - pBitmapTab->set_visible(true); + auto& rBitmapTab = static_cast<SvxBitmapTabPage&>(rTab); + rBitmapTab.SetBitmapList(m_pBitmapList); + rBitmapTab.SetBmpChgd(m_pnBitmapListState); + rBitmapTab.Construct(); + rBitmapTab.ActivatePage(m_rXFSet); + rBitmapTab.Reset(&m_rXFSet); + rBitmapTab.set_visible(true); } else if(nId == PATTERN) { - auto* pPatternTab = static_cast<SvxPatternTabPage*>(pTab); - pPatternTab->SetColorList(m_pColorList); - pPatternTab->SetPatternList(m_pPatternList); - pPatternTab->SetPtrnChgd(m_pnPatternListState); - pPatternTab->SetColorChgd(m_pnColorListState); - pPatternTab->Construct(); - pPatternTab->ActivatePage(m_rXFSet); - pPatternTab->Reset(&m_rXFSet); - pPatternTab->set_visible(true); + auto& rPatternTab = static_cast<SvxPatternTabPage&>(rTab); + rPatternTab.SetColorList(m_pColorList); + rPatternTab.SetPatternList(m_pPatternList); + rPatternTab.SetPtrnChgd(m_pnPatternListState); + rPatternTab.SetColorChgd(m_pnColorListState); + rPatternTab.Construct(); + rPatternTab.ActivatePage(m_rXFSet); + rPatternTab.Reset(&m_rXFSet); + rPatternTab.set_visible(true); } } diff --git a/cui/source/tabpages/tpbitmap.cxx b/cui/source/tabpages/tpbitmap.cxx index 65cb4136cd5e..2990f4473e91 100644 --- a/cui/source/tabpages/tpbitmap.cxx +++ b/cui/source/tabpages/tpbitmap.cxx @@ -260,7 +260,7 @@ void SvxBitmapTabPage::Reset( const SfxItemSet* rAttrs ) double fUIScale = 1.0; if (mpView) { - fUIScale = ( mpView->GetModel() ? double(mpView->GetModel()->GetUIScale()) : 1.0); + fUIScale = double(mpView->GetModel().GetUIScale()); if (mpView->AreObjectsMarked()) @@ -298,9 +298,9 @@ void SvxBitmapTabPage::Reset( const SfxItemSet* rAttrs ) CalculateBitmapPresetSize(); bool bTiled = false; bool bStretched = false; - if(rAttrs->GetItemState( XATTR_FILLBMP_TILE ) != SfxItemState::DONTCARE) + if(rAttrs->GetItemState( XATTR_FILLBMP_TILE ) != SfxItemState::INVALID) bTiled = rAttrs->Get( XATTR_FILLBMP_TILE ).GetValue(); - if(rAttrs->GetItemState( XATTR_FILLBMP_STRETCH ) != SfxItemState::DONTCARE) + if(rAttrs->GetItemState( XATTR_FILLBMP_STRETCH ) != SfxItemState::INVALID) bStretched = rAttrs->Get( XATTR_FILLBMP_STRETCH ).GetValue(); if (bTiled) @@ -313,42 +313,38 @@ void SvxBitmapTabPage::Reset( const SfxItemSet* rAttrs ) tools::Long nWidth = 0; tools::Long nHeight = 0; - if(rAttrs->GetItemState(XATTR_FILLBMP_SIZELOG) != SfxItemState::DONTCARE) + if(rAttrs->GetItemState(XATTR_FILLBMP_SIZELOG) != SfxItemState::INVALID) { if (rAttrs->Get( XATTR_FILLBMP_SIZELOG ).GetValue()) - { m_xTsbScale->set_state(TRISTATE_FALSE); - m_bLogicalSize = true; - } else - { m_xTsbScale->set_state(TRISTATE_TRUE); - m_bLogicalSize = false; - } } else m_xTsbScale->set_state(TRISTATE_INDET); TriState eRelative = TRISTATE_FALSE; - if(rAttrs->GetItemState(XATTR_FILLBMP_SIZEX) != SfxItemState::DONTCARE) + if(rAttrs->GetItemState(XATTR_FILLBMP_SIZEX) != SfxItemState::INVALID) { nWidth = static_cast<const XFillBmpSizeXItem&>( rAttrs->Get( XATTR_FILLBMP_SIZEX ) ).GetValue(); if(nWidth == 0) nWidth = rBitmapSize.Width(); else if(nWidth < 0) { + m_bLogicalSize = true; eRelative = TRISTATE_TRUE; nWidth = std::abs(nWidth); } } - if(rAttrs->GetItemState( XATTR_FILLBMP_SIZEY ) != SfxItemState::DONTCARE) + if(rAttrs->GetItemState( XATTR_FILLBMP_SIZEY ) != SfxItemState::INVALID) { nHeight = rAttrs->Get( XATTR_FILLBMP_SIZEY ).GetValue(); if(nHeight == 0) nHeight = rBitmapSize.Height(); else if(nHeight < 0) { + m_bLogicalSize = true; eRelative = TRISTATE_TRUE; nHeight = std::abs(nHeight); } @@ -371,13 +367,13 @@ void SvxBitmapTabPage::Reset( const SfxItemSet* rAttrs ) } } - if( rAttrs->GetItemState( XATTR_FILLBMP_POS ) != SfxItemState::DONTCARE ) + if( rAttrs->GetItemState( XATTR_FILLBMP_POS ) != SfxItemState::INVALID ) { RectPoint eValue = rAttrs->Get( XATTR_FILLBMP_POS ).GetValue(); m_xPositionLB->set_active( static_cast< sal_Int32 >(eValue) ); } - if( rAttrs->GetItemState( XATTR_FILLBMP_POSOFFSETX ) != SfxItemState::DONTCARE ) + if( rAttrs->GetItemState( XATTR_FILLBMP_POSOFFSETX ) != SfxItemState::INVALID ) { sal_Int32 nValue = rAttrs->Get( XATTR_FILLBMP_POSOFFSETX ).GetValue(); m_xPositionOffX->set_value(nValue, FieldUnit::PERCENT); @@ -385,7 +381,7 @@ void SvxBitmapTabPage::Reset( const SfxItemSet* rAttrs ) else m_xPositionOffX->set_text(""); - if( rAttrs->GetItemState( XATTR_FILLBMP_POSOFFSETY ) != SfxItemState::DONTCARE ) + if( rAttrs->GetItemState( XATTR_FILLBMP_POSOFFSETY ) != SfxItemState::INVALID ) { sal_Int32 nValue = rAttrs->Get( XATTR_FILLBMP_POSOFFSETY ).GetValue(); m_xPositionOffY->set_value(nValue, FieldUnit::PERCENT); @@ -393,7 +389,7 @@ void SvxBitmapTabPage::Reset( const SfxItemSet* rAttrs ) else m_xPositionOffY->set_text(""); - if( rAttrs->GetItemState( XATTR_FILLBMP_TILEOFFSETX ) != SfxItemState::DONTCARE) + if( rAttrs->GetItemState( XATTR_FILLBMP_TILEOFFSETX ) != SfxItemState::INVALID) { sal_Int32 nValue = rAttrs->Get( XATTR_FILLBMP_TILEOFFSETX ).GetValue(); if(nValue > 0) @@ -403,7 +399,7 @@ void SvxBitmapTabPage::Reset( const SfxItemSet* rAttrs ) } } - if( rAttrs->GetItemState( XATTR_FILLBMP_TILEOFFSETY ) != SfxItemState::DONTCARE ) + if( rAttrs->GetItemState( XATTR_FILLBMP_TILEOFFSETY ) != SfxItemState::INVALID ) { sal_Int32 nValue = rAttrs->Get( XATTR_FILLBMP_TILEOFFSETY ).GetValue(); if(nValue > 0) @@ -464,15 +460,14 @@ IMPL_LINK_NOARG(SvxBitmapTabPage, ModifyBitmapHdl, ValueSet*, void) } else { - const SfxPoolItem* pPoolItem = nullptr; - - if(SfxItemState::SET == m_rOutAttrs.GetItemState(GetWhich(XATTR_FILLSTYLE), true, &pPoolItem)) + if(const XFillStyleItem* pFillStyleItem = m_rOutAttrs.GetItemIfSet(GetWhich(XATTR_FILLSTYLE))) { - const drawing::FillStyle eXFS(static_cast<const XFillStyleItem*>(pPoolItem)->GetValue()); + const drawing::FillStyle eXFS(pFillStyleItem->GetValue()); - if((drawing::FillStyle_BITMAP == eXFS) && (SfxItemState::SET == m_rOutAttrs.GetItemState(GetWhich(XATTR_FILLBITMAP), true, &pPoolItem))) + const XFillBitmapItem* pBitmapItem; + if((drawing::FillStyle_BITMAP == eXFS) && (pBitmapItem = m_rOutAttrs.GetItemIfSet(GetWhich(XATTR_FILLBITMAP)))) { - pGraphicObject.reset(new GraphicObject(static_cast<const XFillBitmapItem*>(pPoolItem)->GetGraphicObject())); + pGraphicObject.reset(new GraphicObject(pBitmapItem->GetGraphicObject())); } } @@ -492,7 +487,7 @@ IMPL_LINK_NOARG(SvxBitmapTabPage, ModifyBitmapHdl, ValueSet*, void) { BitmapEx aBmpEx(pGraphicObject->GetGraphic().GetBitmapEx()); Size aTempBitmapSize = aBmpEx.GetSizePixel(); - const double fUIScale = ( (mpView && mpView->GetModel()) ? double(mpView->GetModel()->GetUIScale()) : 1.0); + const double fUIScale = mpView ? double(mpView->GetModel().GetUIScale()) : 1.0; Size aBitmapSize100mm = o3tl::convert(aTempBitmapSize, o3tl::Length::pt, o3tl::Length::mm100); rBitmapSize.setWidth(aBitmapSize100mm.Width() / fUIScale); @@ -523,7 +518,7 @@ IMPL_LINK_NOARG(SvxBitmapTabPage, ClickRenameHdl, SvxPresetListBox*, void) if( nPos == VALUESET_ITEM_NOTFOUND ) return; - OUString aDesc( CuiResId( RID_SVXSTR_DESC_NEW_BITMAP ) ); + OUString aDesc( CuiResId( RID_CUISTR_DESC_NEW_BITMAP ) ); OUString aName( m_pBitmapList->GetBitmap( nPos )->GetName() ); SvxAbstractDialogFactory* pFact = SvxAbstractDialogFactory::Create(); @@ -532,7 +527,7 @@ IMPL_LINK_NOARG(SvxBitmapTabPage, ClickRenameHdl, SvxPresetListBox*, void) bool bLoop = true; while( bLoop && pDlg->Execute() == RET_OK ) { - pDlg->GetName( aName ); + aName = pDlg->GetName(); sal_Int32 nBitmapPos = SearchBitmapList( aName ); bool bValidBitmapName = (nBitmapPos == static_cast<sal_Int32>(nPos) ) || (nBitmapPos == -1); @@ -718,7 +713,7 @@ IMPL_LINK_NOARG(SvxBitmapTabPage, ClickImportHdl, weld::Button&, void) { weld::Window* pDialogFrameWeld = GetFrameWeld(); - SvxOpenGraphicDialog aDlg(CuiResId(RID_SVXSTR_ADD_IMAGE), pDialogFrameWeld); + SvxOpenGraphicDialog aDlg(CuiResId(RID_CUISTR_ADD_IMAGE), pDialogFrameWeld); aDlg.EnableLink(false); tools::Long nCount = m_pBitmapList->Count(); @@ -733,7 +728,7 @@ IMPL_LINK_NOARG(SvxBitmapTabPage, ClickImportHdl, weld::Button&, void) if( !nError ) { - OUString aDesc(CuiResId(RID_SVXSTR_DESC_EXT_BITMAP)); + OUString aDesc(CuiResId(RID_CUISTR_DESC_EXT_BITMAP)); // convert file URL to UI name OUString aName; @@ -745,7 +740,7 @@ IMPL_LINK_NOARG(SvxBitmapTabPage, ClickImportHdl, weld::Button&, void) while( pDlg->Execute() == RET_OK ) { - pDlg->GetName( aName ); + aName = pDlg->GetName(); bool bDifferent = true; diff --git a/cui/source/tabpages/tpcolor.cxx b/cui/source/tabpages/tpcolor.cxx index 5669f73adc76..ccfe75232bef 100644 --- a/cui/source/tabpages/tpcolor.cxx +++ b/cui/source/tabpages/tpcolor.cxx @@ -36,6 +36,7 @@ #include <officecfg/Office/Common.hxx> #include <osl/diagnose.h> #include <comphelper/dispatchcommand.hxx> +#include <comphelper/lok.hxx> #include <comphelper/propertyvalue.hxx> using namespace com::sun::star; @@ -48,7 +49,6 @@ SvxColorTabPage::SvxColorTabPage(weld::Container* pPage, weld::DialogController* , aXFillAttr( rInAttrs.GetPool() ) , rXFSet( aXFillAttr.GetItemSet() ) , eCM( ColorModel::RGB ) - , m_context(comphelper::getProcessComponentContext()) , m_xValSetColorList(new SvxColorValueSet(m_xBuilder->weld_scrolled_window("colorsetwin", true))) , m_xValSetRecentList(new SvxColorValueSet(nullptr)) , m_xSelectPalette(m_xBuilder->weld_combo_box("paletteselector")) @@ -129,9 +129,8 @@ SvxColorTabPage::SvxColorTabPage(weld::Container* pPage, weld::DialogController* // disable modify buttons // Color palettes can't be modified m_xBtnDelete->set_sensitive(false); - m_xBtnDelete->set_tooltip_text( SvxResId(RID_SVXSTR_DELETEUSERCOLOR1) ); + m_xBtnDelete->set_tooltip_text( CuiResId(RID_CUISTR_DELETEUSERCOLOR1) ); - m_xMoreColors->set_from_icon_name("cmd/sc_additionsdialog.png"); m_xMoreColors->connect_clicked(LINK(this, SvxColorTabPage, OnMoreColorsClick)); // disable preset color values @@ -150,6 +149,12 @@ SvxColorTabPage::SvxColorTabPage(weld::Container* pPage, weld::DialogController* maPaletteManager.ReloadRecentColorSet(*m_xValSetRecentList); aSize = m_xValSetRecentList->layoutAllVisible(maPaletteManager.GetRecentColorCount()); m_xValSetRecentList->set_size_request(aSize.Width(), aSize.Height()); + + // it is not possible to install color palette extensions in Online or mobile apps + if(comphelper::LibreOfficeKit::isActive()) + { + m_xMoreColors->hide(); + } } SvxColorTabPage::~SvxColorTabPage() @@ -198,14 +203,15 @@ void SvxColorTabPage::ActivatePage( const SfxItemSet& ) if( !pColorList.is() ) return; - const SfxPoolItem* pPoolItem = nullptr; - if( SfxItemState::SET == rOutAttrs.GetItemState( GetWhich( XATTR_FILLCOLOR ), true, &pPoolItem ) ) + if( const XFillColorItem* pFillColorItem = rOutAttrs.GetItemIfSet( GetWhich( XATTR_FILLCOLOR ) ) ) { SetColorModel( ColorModel::RGB ); ChangeColorModel(); - const Color aColor = static_cast<const XFillColorItem*>(pPoolItem)->GetColorValue(); - ChangeColor( aColor ); + const Color aColor = pFillColorItem->GetColorValue(); + NamedColor aNamedColor; + aNamedColor.m_aColor = aColor; + ChangeColor(aNamedColor); sal_Int32 nPos = FindInPalette( aColor ); if ( nPos != -1 ) @@ -232,13 +238,16 @@ bool SvxColorTabPage::FillItemSet( SfxItemSet* rSet ) { Color aColor = m_xValSetColorList->GetItemColor( m_xValSetColorList->GetSelectedItemId() ); OUString sColorName; - if ( aCurrentColor == aColor ) + if (m_aCurrentColor.m_aColor == aColor) sColorName = m_xValSetColorList->GetItemText( m_xValSetColorList->GetSelectedItemId() ); else - sColorName = "#" + aCurrentColor.AsRGBHexString().toAsciiUpperCase(); - maPaletteManager.AddRecentColor( aCurrentColor, sColorName ); - rSet->Put( XFillColorItem( sColorName, aCurrentColor ) ); - rSet->Put( XFillStyleItem( drawing::FillStyle_SOLID ) ); + sColorName = "#" + m_aCurrentColor.m_aColor.AsRGBHexString().toAsciiUpperCase(); + + maPaletteManager.AddRecentColor(m_aCurrentColor.m_aColor, sColorName); + XFillColorItem aColorItem(sColorName, m_aCurrentColor.m_aColor); + aColorItem.setComplexColor(m_aCurrentColor.getComplexColor()); + rSet->Put(aColorItem); + rSet->Put(XFillStyleItem(drawing::FillStyle_SOLID)); return true; } @@ -257,7 +266,7 @@ void SvxColorTabPage::Reset( const SfxItemSet* rSet ) if ( nState >= SfxItemState::DEFAULT ) { XFillColorItem aColorItem( rSet->Get( XATTR_FILLCOLOR ) ); - aPreviousColor = aColorItem.GetColorValue(); + m_aPreviousColor = aColorItem.GetColorValue(); aNewColor = aColorItem.GetColorValue(); } @@ -267,7 +276,9 @@ void SvxColorTabPage::Reset( const SfxItemSet* rSet ) SetColorModel( eCM ); ChangeColorModel(); - ChangeColor(aNewColor); + NamedColor aColor; + aColor.m_aColor = aNewColor; + ChangeColor(aColor); UpdateModified(); } @@ -281,12 +292,12 @@ std::unique_ptr<SfxTabPage> SvxColorTabPage::Create(weld::Container* pPage, weld IMPL_LINK_NOARG(SvxColorTabPage, SpinValueHdl_Impl, weld::SpinButton&, void) { // read current MtrFields, if cmyk, then k-value as transparency - aCurrentColor = Color(static_cast<sal_uInt8>(PercentToColor_Impl(m_xRcustom->get_value())), + m_aCurrentColor.m_aColor = Color(static_cast<sal_uInt8>(PercentToColor_Impl(m_xRcustom->get_value())), static_cast<sal_uInt8>(PercentToColor_Impl(m_xGcustom->get_value())), static_cast<sal_uInt8>(PercentToColor_Impl(m_xBcustom->get_value()))); UpdateColorValues(); - rXFSet.Put( XFillColorItem( OUString(), aCurrentColor ) ); + rXFSet.Put( XFillColorItem( OUString(), m_aCurrentColor.m_aColor ) ); m_aCtlPreviewNew.SetAttributes( aXFillAttr.GetItemSet() ); m_aCtlPreviewNew.Invalidate(); @@ -295,13 +306,13 @@ IMPL_LINK_NOARG(SvxColorTabPage, SpinValueHdl_Impl, weld::SpinButton&, void) IMPL_LINK_NOARG(SvxColorTabPage, MetricSpinValueHdl_Impl, weld::MetricSpinButton&, void) { // read current MtrFields, if cmyk, then k-value as transparency - aCurrentColor = Color(ColorTransparency, static_cast<sal_uInt8>(PercentToColor_Impl(m_xKcustom->get_value(FieldUnit::NONE))), + m_aCurrentColor.m_aColor = Color(ColorTransparency, static_cast<sal_uInt8>(PercentToColor_Impl(m_xKcustom->get_value(FieldUnit::NONE))), static_cast<sal_uInt8>(PercentToColor_Impl(m_xCcustom->get_value(FieldUnit::NONE))), static_cast<sal_uInt8>(PercentToColor_Impl(m_xYcustom->get_value(FieldUnit::NONE))), static_cast<sal_uInt8>(PercentToColor_Impl(m_xMcustom->get_value(FieldUnit::NONE)))); - ConvertColorValues (aCurrentColor, ColorModel::RGB); + ConvertColorValues (m_aCurrentColor.m_aColor, ColorModel::RGB); - rXFSet.Put( XFillColorItem( OUString(), aCurrentColor ) ); + rXFSet.Put( XFillColorItem( OUString(), m_aCurrentColor.m_aColor ) ); m_aCtlPreviewNew.SetAttributes( aXFillAttr.GetItemSet() ); m_aCtlPreviewNew.Invalidate(); @@ -309,10 +320,10 @@ IMPL_LINK_NOARG(SvxColorTabPage, MetricSpinValueHdl_Impl, weld::MetricSpinButton IMPL_LINK_NOARG(SvxColorTabPage, ModifiedHdl_Impl, weld::Entry&, void) { - aCurrentColor = m_xHexcustom->GetColor(); + m_aCurrentColor.m_aColor = m_xHexcustom->GetColor(); UpdateColorValues(); - rXFSet.Put( XFillColorItem( OUString(), aCurrentColor ) ); + rXFSet.Put( XFillColorItem( OUString(), m_aCurrentColor.m_aColor ) ); m_aCtlPreviewNew.SetAttributes( aXFillAttr.GetItemSet() ); m_aCtlPreviewNew.Invalidate(); @@ -321,7 +332,7 @@ IMPL_LINK_NOARG(SvxColorTabPage, ModifiedHdl_Impl, weld::Entry&, void) IMPL_LINK_NOARG(SvxColorTabPage, ClickAddHdl_Impl, weld::Button&, void) { OUString aNewName( SvxResId( RID_SVXSTR_COLOR ) ); - OUString aDesc( CuiResId( RID_SVXSTR_DESC_COLOR ) ); + OUString aDesc( CuiResId( RID_CUISTR_DESC_COLOR ) ); OUString aName; tools::Long j = 1; @@ -339,7 +350,7 @@ IMPL_LINK_NOARG(SvxColorTabPage, ClickAddHdl_Impl, weld::Button&, void) while (pDlg->Execute() == RET_OK) { - pDlg->GetName( aName ); + aName = pDlg->GetName(); bValidColorName = (FindInCustomColors(aName) == -1); if (bValidColorName) @@ -360,22 +371,22 @@ IMPL_LINK_NOARG(SvxColorTabPage, ClickAddHdl_Impl, weld::Button&, void) { m_xSelectPalette->set_active(0); SelectPaletteLBHdl(*m_xSelectPalette); - std::shared_ptr<comphelper::ConfigurationChanges> batch(comphelper::ConfigurationChanges::create(m_context)); + std::shared_ptr<comphelper::ConfigurationChanges> batch(comphelper::ConfigurationChanges::create()); css::uno::Sequence< sal_Int32 > aCustomColorList(officecfg::Office::Common::UserColors::CustomColor::get()); css::uno::Sequence< OUString > aCustomColorNameList(officecfg::Office::Common::UserColors::CustomColorName::get()); sal_Int32 nSize = aCustomColorList.getLength(); aCustomColorList.realloc( nSize + 1 ); aCustomColorNameList.realloc( nSize + 1 ); - aCustomColorList.getArray()[nSize] = sal_Int32(aCurrentColor); + aCustomColorList.getArray()[nSize] = sal_Int32(m_aCurrentColor.m_aColor); aCustomColorNameList.getArray()[nSize] = aName; officecfg::Office::Common::UserColors::CustomColor::set(aCustomColorList, batch); officecfg::Office::Common::UserColors::CustomColorName::set(aCustomColorNameList, batch); batch->commit(); sal_uInt16 nId = m_xValSetColorList->GetItemId(nSize - 1); - m_xValSetColorList->InsertItem( nId + 1 , aCurrentColor, aName ); + m_xValSetColorList->InsertItem( nId + 1 , m_aCurrentColor.m_aColor, aName ); m_xValSetColorList->SelectItem( nId + 1 ); m_xBtnDelete->set_sensitive(false); - m_xBtnDelete->set_tooltip_text( SvxResId(RID_SVXSTR_DELETEUSERCOLOR2) ); + m_xBtnDelete->set_tooltip_text( CuiResId(RID_CUISTR_DELETEUSERCOLOR2) ); ImpColorCountChanged(); } @@ -386,13 +397,13 @@ IMPL_LINK_NOARG(SvxColorTabPage, ClickWorkOnHdl_Impl, weld::Button&, void) { SvColorDialog aColorDlg; - aColorDlg.SetColor (aCurrentColor); + aColorDlg.SetColor (m_aCurrentColor.m_aColor); aColorDlg.SetMode( svtools::ColorPickerMode::Modify ); if (aColorDlg.Execute(GetFrameWeld()) == RET_OK) { Color aPreviewColor = aColorDlg.GetColor(); - aCurrentColor = aPreviewColor; + m_aCurrentColor.m_aColor = aPreviewColor; UpdateColorValues( false ); // fill ItemSet and pass it on to XOut rXFSet.Put( XFillColorItem( OUString(), aPreviewColor ) ); @@ -410,7 +421,7 @@ IMPL_LINK_NOARG(SvxColorTabPage, ClickDeleteHdl_Impl, weld::Button&, void) if (m_xSelectPalette->get_active() != 0 || nPos == VALUESET_ITEM_NOTFOUND) return; - std::shared_ptr<comphelper::ConfigurationChanges> batch(comphelper::ConfigurationChanges::create(m_context)); + std::shared_ptr<comphelper::ConfigurationChanges> batch(comphelper::ConfigurationChanges::create()); css::uno::Sequence< sal_Int32 > aCustomColorList(officecfg::Office::Common::UserColors::CustomColor::get()); auto aCustomColorListRange = asNonConstRange(aCustomColorList); css::uno::Sequence< OUString > aCustomColorNameList(officecfg::Office::Common::UserColors::CustomColorName::get()); @@ -436,7 +447,7 @@ IMPL_LINK_NOARG(SvxColorTabPage, ClickDeleteHdl_Impl, weld::Button&, void) else { m_xBtnDelete->set_sensitive(false); - m_xBtnDelete->set_tooltip_text( SvxResId(RID_SVXSTR_DELETEUSERCOLOR2) ); + m_xBtnDelete->set_tooltip_text( CuiResId(RID_CUISTR_DELETEUSERCOLOR2) ); } } @@ -472,7 +483,7 @@ IMPL_LINK_NOARG(SvxColorTabPage, SelectPaletteLBHdl, weld::ComboBox&, void) if (nPos != 0) { m_xBtnDelete->set_sensitive(false); - m_xBtnDelete->set_tooltip_text( SvxResId(RID_SVXSTR_DELETEUSERCOLOR1) ); + m_xBtnDelete->set_tooltip_text( CuiResId(RID_CUISTR_DELETEUSERCOLOR1) ); } m_xValSetColorList->Resize(); @@ -489,7 +500,22 @@ IMPL_LINK(SvxColorTabPage, SelectValSetHdl_Impl, ValueSet*, pValSet, void) rXFSet.Put( XFillColorItem( OUString(), aColor ) ); m_aCtlPreviewNew.SetAttributes( aXFillAttr.GetItemSet() ); m_aCtlPreviewNew.Invalidate(); - ChangeColor(aColor, false); + + NamedColor aNamedColor; + aNamedColor.m_aColor = aColor; + + if (pValSet == m_xValSetColorList.get() && maPaletteManager.IsThemePaletteSelected()) + { + sal_uInt16 nThemeIndex; + sal_uInt16 nEffectIndex; + if (PaletteManager::GetThemeAndEffectIndex(nPos, nThemeIndex, nEffectIndex)) + { + aNamedColor.m_nThemeIndex = nThemeIndex; + maPaletteManager.GetLumModOff(nThemeIndex, nEffectIndex, aNamedColor.m_nLumMod, aNamedColor.m_nLumOff); + } + } + + ChangeColor(aNamedColor, false); if (pValSet == m_xValSetColorList.get()) { @@ -502,14 +528,14 @@ IMPL_LINK(SvxColorTabPage, SelectValSetHdl_Impl, ValueSet*, pValSet, void) else { m_xBtnDelete->set_sensitive(false); - m_xBtnDelete->set_tooltip_text( SvxResId(RID_SVXSTR_DELETEUSERCOLOR1) ); + m_xBtnDelete->set_tooltip_text( CuiResId(RID_CUISTR_DELETEUSERCOLOR1) ); } } if (pValSet == m_xValSetRecentList.get()) { m_xValSetColorList->SetNoSelection(); m_xBtnDelete->set_sensitive(false); - m_xBtnDelete->set_tooltip_text( SvxResId(RID_SVXSTR_DELETEUSERCOLOR2) ); + m_xBtnDelete->set_tooltip_text( CuiResId(RID_CUISTR_DELETEUSERCOLOR2) ); } } @@ -552,13 +578,16 @@ IMPL_STATIC_LINK_NOARG(SvxColorTabPage, OnMoreColorsClick, weld::Button&, void) comphelper::dispatchCommand(".uno:AdditionsDialog", aArgs); } -void SvxColorTabPage::ChangeColor(const Color &rNewColor, bool bUpdatePreset ) +void SvxColorTabPage::ChangeColor(const NamedColor &rNewColor, bool bUpdatePreset ) { - aPreviousColor = rNewColor; - aCurrentColor = rNewColor; + m_aPreviousColor = rNewColor.m_aColor; + m_aCurrentColor = rNewColor; UpdateColorValues( bUpdatePreset ); // fill ItemSet and pass it on to XOut - rXFSet.Put( XFillColorItem( OUString(), aCurrentColor ) ); + XFillColorItem aItem(OUString(), m_aCurrentColor.m_aColor); + aItem.setComplexColor(m_aCurrentColor.getComplexColor()); + rXFSet.Put(aItem); + m_aCtlPreviewNew.SetAttributes(aXFillAttr.GetItemSet()); m_aCtlPreviewNew.Invalidate(); } @@ -599,42 +628,42 @@ void SvxColorTabPage::UpdateColorValues( bool bUpdatePreset ) { if (eCM != ColorModel::RGB) { - ConvertColorValues (aPreviousColor, eCM ); - ConvertColorValues (aCurrentColor, eCM); + ConvertColorValues (m_aPreviousColor, eCM ); + ConvertColorValues (m_aCurrentColor.m_aColor, eCM); - m_xCcustom->set_value( ColorToPercent_Impl( aCurrentColor.GetRed() ), FieldUnit::PERCENT ); - m_xMcustom->set_value( ColorToPercent_Impl( aCurrentColor.GetBlue() ), FieldUnit::PERCENT ); - m_xYcustom->set_value( ColorToPercent_Impl( aCurrentColor.GetGreen() ), FieldUnit::PERCENT ); - m_xKcustom->set_value( ColorToPercent_Impl( 255 - aCurrentColor.GetAlpha() ), FieldUnit::PERCENT ); + m_xCcustom->set_value( ColorToPercent_Impl( m_aCurrentColor.m_aColor.GetRed() ), FieldUnit::PERCENT ); + m_xMcustom->set_value( ColorToPercent_Impl( m_aCurrentColor.m_aColor.GetBlue() ), FieldUnit::PERCENT ); + m_xYcustom->set_value( ColorToPercent_Impl( m_aCurrentColor.m_aColor.GetGreen() ), FieldUnit::PERCENT ); + m_xKcustom->set_value( ColorToPercent_Impl( 255 - m_aCurrentColor.m_aColor.GetAlpha() ), FieldUnit::PERCENT ); if( bUpdatePreset ) { - m_xCpreset->set_text(unicode::formatPercent(ColorToPercent_Impl(aPreviousColor.GetRed()), + m_xCpreset->set_text(unicode::formatPercent(ColorToPercent_Impl(m_aPreviousColor.GetRed()), Application::GetSettings().GetUILanguageTag())); - m_xMpreset->set_text(unicode::formatPercent(ColorToPercent_Impl(aPreviousColor.GetBlue()), + m_xMpreset->set_text(unicode::formatPercent(ColorToPercent_Impl(m_aPreviousColor.GetBlue()), Application::GetSettings().GetUILanguageTag())); - m_xYpreset->set_text(unicode::formatPercent(ColorToPercent_Impl(aPreviousColor.GetGreen()), + m_xYpreset->set_text(unicode::formatPercent(ColorToPercent_Impl(m_aPreviousColor.GetGreen()), Application::GetSettings().GetUILanguageTag())); - m_xKpreset->set_text(unicode::formatPercent(ColorToPercent_Impl(255 - aPreviousColor.GetAlpha()), + m_xKpreset->set_text(unicode::formatPercent(ColorToPercent_Impl(255 - m_aPreviousColor.GetAlpha()), Application::GetSettings().GetUILanguageTag())); } - ConvertColorValues (aPreviousColor, ColorModel::RGB); - ConvertColorValues (aCurrentColor, ColorModel::RGB); + ConvertColorValues (m_aPreviousColor, ColorModel::RGB); + ConvertColorValues (m_aCurrentColor.m_aColor, ColorModel::RGB); } else { - m_xRcustom->set_value( ColorToPercent_Impl( aCurrentColor.GetRed() ) ); - m_xGcustom->set_value( ColorToPercent_Impl( aCurrentColor.GetGreen() ) ); - m_xBcustom->set_value( ColorToPercent_Impl( aCurrentColor.GetBlue() ) ); - m_xHexcustom->SetColor( aCurrentColor ); + m_xRcustom->set_value( ColorToPercent_Impl( m_aCurrentColor.m_aColor.GetRed() ) ); + m_xGcustom->set_value( ColorToPercent_Impl( m_aCurrentColor.m_aColor.GetGreen() ) ); + m_xBcustom->set_value( ColorToPercent_Impl( m_aCurrentColor.m_aColor.GetBlue() ) ); + m_xHexcustom->SetColor( m_aCurrentColor.m_aColor ); if( bUpdatePreset ) { - m_xRpreset->set_text(OUString::number(ColorToPercent_Impl(aPreviousColor.GetRed()))); - m_xGpreset->set_text(OUString::number(ColorToPercent_Impl(aPreviousColor.GetGreen()))); - m_xBpreset->set_text(OUString::number(ColorToPercent_Impl(aPreviousColor.GetBlue()))); - m_xHexpreset->SetColor( aPreviousColor ); + m_xRpreset->set_text(OUString::number(ColorToPercent_Impl(m_aPreviousColor.GetRed()))); + m_xGpreset->set_text(OUString::number(ColorToPercent_Impl(m_aPreviousColor.GetGreen()))); + m_xBpreset->set_text(OUString::number(ColorToPercent_Impl(m_aPreviousColor.GetBlue()))); + m_xHexpreset->SetColor( m_aPreviousColor ); } } } diff --git a/cui/source/tabpages/tpgradnt.cxx b/cui/source/tabpages/tpgradnt.cxx index 00b01bd0ce33..2fb57742e0b3 100644 --- a/cui/source/tabpages/tpgradnt.cxx +++ b/cui/source/tabpages/tpgradnt.cxx @@ -34,10 +34,9 @@ #include <dialmgr.hxx> #include <svx/dialmgr.hxx> #include <svx/strings.hrc> +#include <basegfx/utils/gradienttools.hxx> #include <sal/log.hxx> -#define DEFAULT_GRADIENTSTEP 64 - using namespace com::sun::star; SvxGradientTabPage::SvxGradientTabPage(weld::Container* pPage, weld::DialogController* pController, const SfxItemSet& rInAttrs) @@ -83,7 +82,7 @@ SvxGradientTabPage::SvxGradientTabPage(weld::Container* pPage, weld::DialogContr // setting the output device m_rXFSet.Put( XFillStyleItem(drawing::FillStyle_GRADIENT) ); - m_rXFSet.Put( XFillGradientItem(OUString(), XGradient( COL_BLACK, COL_WHITE )) ); + m_rXFSet.Put( XFillGradientItem(OUString(), basegfx::BGradient())); m_aCtlPreview.SetAttributes(m_aXFillAttr.GetItemSet()); // set handler @@ -149,7 +148,7 @@ void SvxGradientTabPage::ActivatePage( const SfxItemSet& rSet ) // determining (and possibly cutting) the name and // displaying it in the GroupBox - OUString aString = CuiResId( RID_SVXSTR_TABLE ) + ": "; + OUString aString = CuiResId( RID_CUISTR_TABLE ) + ": "; INetURLObject aURL( m_pGradientList->GetPath() ); aURL.Append( m_pGradientList->GetName() ); @@ -183,19 +182,26 @@ DeactivateRC SvxGradientTabPage::DeactivatePage( SfxItemSet* _pSet ) bool SvxGradientTabPage::FillItemSet( SfxItemSet* rSet ) { - std::unique_ptr<XGradient> pXGradient; + std::unique_ptr<basegfx::BGradient> pBGradient; size_t nPos = m_xGradientLB->IsNoSelection() ? VALUESET_ITEM_NOTFOUND : m_xGradientLB->GetSelectItemPos(); + + sal_uInt16 nValue = 0; // automatic step count + if (!m_xCbIncrement->get_active()) + nValue = m_xMtrIncrement->get_value(); + if( nPos != VALUESET_ITEM_NOTFOUND ) { - pXGradient.reset(new XGradient( m_pGradientList->GetGradient( static_cast<sal_uInt16>(nPos) )->GetGradient() )); + pBGradient.reset(new basegfx::BGradient( m_pGradientList->GetGradient( static_cast<sal_uInt16>(nPos) )->GetGradient() )); OUString aString = m_xGradientLB->GetItemText( m_xGradientLB->GetSelectedItemId() ); - rSet->Put( XFillGradientItem( aString, *pXGradient ) ); + // update StepCount to current value to be in sync with FillGradientStepCount + pBGradient->SetSteps(nValue); + rSet->Put( XFillGradientItem( aString, *pBGradient ) ); } else // gradient was passed (unidentified) { - pXGradient.reset(new XGradient( m_xLbColorFrom->GetSelectEntryColor(), - m_xLbColorTo->GetSelectEntryColor(), + pBGradient.reset(new basegfx::BGradient( + createColorStops(), static_cast<css::awt::GradientStyle>(m_xLbGradientType->get_active()), Degree10(static_cast<sal_Int16>(m_xMtrAngle->get_value(FieldUnit::NONE) * 10)), // should be changed in resource static_cast<sal_uInt16>(m_xMtrCenterX->get_value(FieldUnit::NONE)), @@ -203,15 +209,11 @@ bool SvxGradientTabPage::FillItemSet( SfxItemSet* rSet ) static_cast<sal_uInt16>(m_xMtrBorder->get_value(FieldUnit::NONE)), static_cast<sal_uInt16>(m_xMtrColorFrom->get_value(FieldUnit::NONE)), static_cast<sal_uInt16>(m_xMtrColorTo->get_value(FieldUnit::NONE)), - static_cast<sal_uInt16>(m_xMtrIncrement->get_value()) )); - rSet->Put( XFillGradientItem( OUString(), *pXGradient ) ); + nValue)); + rSet->Put( XFillGradientItem( OUString(), *pBGradient ) ); } - sal_uInt16 nValue = 0; - if (!m_xCbIncrement->get_active()) - nValue = m_xMtrIncrement->get_value(); - - assert( pXGradient && "XGradient could not be created" ); + assert( pBGradient && "basegfx::BGradient could not be created" ); rSet->Put( XFillStyleItem( drawing::FillStyle_GRADIENT ) ); rSet->Put( XGradientStepCountItem( nValue ) ); return true; @@ -219,8 +221,7 @@ bool SvxGradientTabPage::FillItemSet( SfxItemSet* rSet ) void SvxGradientTabPage::Reset( const SfxItemSet* ) { - m_xMtrIncrement->set_value(DEFAULT_GRADIENTSTEP); - ChangeGradientHdl_Impl(); + ChangeGradientHdl_Impl(); // includes setting m_xCbIncrement and m_xMtrIncrement // determine state of the buttons if( m_pGradientList->Count() ) @@ -292,8 +293,12 @@ void SvxGradientTabPage::ModifiedHdl_Impl( void const * pControl ) css::awt::GradientStyle eXGS = static_cast<css::awt::GradientStyle>(m_xLbGradientType->get_active()); - XGradient aXGradient( m_xLbColorFrom->GetSelectEntryColor(), - m_xLbColorTo->GetSelectEntryColor(), + sal_uInt16 nValue = 0; // automatic + if (!m_xCbIncrement->get_active()) + nValue = static_cast<sal_uInt16>(m_xMtrIncrement->get_value()); + + basegfx::BGradient aBGradient( + createColorStops(), eXGS, Degree10(static_cast<sal_Int16>(m_xMtrAngle->get_value(FieldUnit::NONE) * 10)), // should be changed in resource static_cast<sal_uInt16>(m_xMtrCenterX->get_value(FieldUnit::NONE)), @@ -301,19 +306,16 @@ void SvxGradientTabPage::ModifiedHdl_Impl( void const * pControl ) static_cast<sal_uInt16>(m_xMtrBorder->get_value(FieldUnit::NONE)), static_cast<sal_uInt16>(m_xMtrColorFrom->get_value(FieldUnit::NONE)), static_cast<sal_uInt16>(m_xMtrColorTo->get_value(FieldUnit::NONE)), - static_cast<sal_uInt16>(m_xMtrIncrement->get_value()) ); + nValue); // enable/disable controls if (pControl == m_xLbGradientType.get() || pControl == this) SetControlState_Impl( eXGS ); - sal_uInt16 nValue = 0; - if (!m_xCbIncrement->get_active()) - nValue = static_cast<sal_uInt16>(m_xMtrIncrement->get_value()); m_rXFSet.Put( XGradientStepCountItem( nValue ) ); // displaying in XOutDev - m_rXFSet.Put( XFillGradientItem( OUString(), aXGradient ) ); + m_rXFSet.Put( XFillGradientItem( OUString(), aBGradient ) ); m_aCtlPreview.SetAttributes(m_aXFillAttr.GetItemSet()); m_aCtlPreview.Invalidate(); } @@ -321,7 +323,7 @@ void SvxGradientTabPage::ModifiedHdl_Impl( void const * pControl ) IMPL_LINK_NOARG(SvxGradientTabPage, ClickAddHdl_Impl, weld::Button&, void) { OUString aNewName( SvxResId( RID_SVXSTR_GRADIENT ) ); - OUString aDesc( CuiResId( RID_SVXSTR_DESC_GRADIENT ) ); + OUString aDesc( CuiResId( RID_CUISTR_DESC_GRADIENT ) ); OUString aName; tools::Long nCount = m_pGradientList->Count(); @@ -340,7 +342,7 @@ IMPL_LINK_NOARG(SvxGradientTabPage, ClickAddHdl_Impl, weld::Button&, void) while (pDlg->Execute() == RET_OK) { - pDlg->GetName( aName ); + aName = pDlg->GetName(); bValidGradientName = (SearchGradientList(aName) == -1); @@ -359,8 +361,11 @@ IMPL_LINK_NOARG(SvxGradientTabPage, ClickAddHdl_Impl, weld::Button&, void) if( !nError ) { - XGradient aXGradient( m_xLbColorFrom->GetSelectEntryColor(), - m_xLbColorTo->GetSelectEntryColor(), + sal_uInt16 nValue = 0; // automatic step count + if (!m_xCbIncrement->get_active()) + nValue = m_xMtrIncrement->get_value(); + basegfx::BGradient aBGradient( + createColorStops(), static_cast<css::awt::GradientStyle>(m_xLbGradientType->get_active()), Degree10(static_cast<sal_Int16>(m_xMtrAngle->get_value(FieldUnit::NONE) * 10)), // should be changed in resource static_cast<sal_uInt16>(m_xMtrCenterX->get_value(FieldUnit::NONE)), @@ -368,9 +373,9 @@ IMPL_LINK_NOARG(SvxGradientTabPage, ClickAddHdl_Impl, weld::Button&, void) static_cast<sal_uInt16>(m_xMtrBorder->get_value(FieldUnit::NONE)), static_cast<sal_uInt16>(m_xMtrColorFrom->get_value(FieldUnit::NONE)), static_cast<sal_uInt16>(m_xMtrColorTo->get_value(FieldUnit::NONE)), - static_cast<sal_uInt16>(m_xMtrIncrement->get_value()) ); + nValue); - m_pGradientList->Insert(std::make_unique<XGradientEntry>(aXGradient, aName), nCount); + m_pGradientList->Insert(std::make_unique<XGradientEntry>(aBGradient, aName), nCount); sal_Int32 nId = m_xGradientLB->GetItemId(nCount - 1); //calculate the last ID BitmapEx aBitmap = m_pGradientList->GetBitmapForPreview( nCount, m_xGradientLB->GetIconSize() ); @@ -399,8 +404,12 @@ IMPL_LINK_NOARG(SvxGradientTabPage, ClickModifyHdl_Impl, weld::Button&, void) OUString aName( m_pGradientList->GetGradient( static_cast<sal_uInt16>(nPos) )->GetName() ); - XGradient aXGradient( m_xLbColorFrom->GetSelectEntryColor(), - m_xLbColorTo->GetSelectEntryColor(), + sal_uInt16 nValue = 0; // automatic step count + if (!m_xCbIncrement->get_active()) + nValue = m_xMtrIncrement->get_value(); + + basegfx::BGradient aBGradient( + createColorStops(), static_cast<css::awt::GradientStyle>(m_xLbGradientType->get_active()), Degree10(static_cast<sal_Int16>(m_xMtrAngle->get_value(FieldUnit::NONE) * 10)), // should be changed in resource static_cast<sal_uInt16>(m_xMtrCenterX->get_value(FieldUnit::NONE)), @@ -408,9 +417,9 @@ IMPL_LINK_NOARG(SvxGradientTabPage, ClickModifyHdl_Impl, weld::Button&, void) static_cast<sal_uInt16>(m_xMtrBorder->get_value(FieldUnit::NONE)), static_cast<sal_uInt16>(m_xMtrColorFrom->get_value(FieldUnit::NONE)), static_cast<sal_uInt16>(m_xMtrColorTo->get_value(FieldUnit::NONE)), - static_cast<sal_uInt16>(m_xMtrIncrement->get_value()) ); + nValue); - m_pGradientList->Replace(std::make_unique<XGradientEntry>(aXGradient, aName), nPos); + m_pGradientList->Replace(std::make_unique<XGradientEntry>(aBGradient, aName), nPos); BitmapEx aBitmap = m_pGradientList->GetBitmapForPreview( static_cast<sal_uInt16>(nPos), m_xGradientLB->GetIconSize() ); m_xGradientLB->RemoveItem( nId ); @@ -457,7 +466,7 @@ IMPL_LINK_NOARG(SvxGradientTabPage, ClickRenameHdl_Impl, SvxPresetListBox*, void if ( nPos == VALUESET_ITEM_NOTFOUND ) return; - OUString aDesc( CuiResId( RID_SVXSTR_DESC_GRADIENT ) ); + OUString aDesc( CuiResId( RID_CUISTR_DESC_GRADIENT ) ); OUString aName( m_pGradientList->GetGradient( nPos )->GetName() ); SvxAbstractDialogFactory* pFact = SvxAbstractDialogFactory::Create(); @@ -466,7 +475,7 @@ IMPL_LINK_NOARG(SvxGradientTabPage, ClickRenameHdl_Impl, SvxPresetListBox*, void bool bLoop = true; while( bLoop && pDlg->Execute() == RET_OK ) { - pDlg->GetName( aName ); + aName = pDlg->GetName(); sal_Int32 nGradientPos = SearchGradientList(aName); bool bValidGradientName = (nGradientPos == static_cast<sal_Int32>(nPos) ) || (nGradientPos == -1); @@ -496,20 +505,20 @@ IMPL_LINK_NOARG(SvxGradientTabPage, ChangeGradientHdl, ValueSet*, void) void SvxGradientTabPage::ChangeGradientHdl_Impl() { - std::unique_ptr<XGradient> pGradient; + std::unique_ptr<basegfx::BGradient> pGradient; size_t nPos = m_xGradientLB->GetSelectItemPos(); if( nPos != VALUESET_ITEM_NOTFOUND ) - pGradient.reset(new XGradient( m_pGradientList->GetGradient( static_cast<sal_uInt16>( nPos ) )->GetGradient() )); + pGradient.reset(new basegfx::BGradient( m_pGradientList->GetGradient( static_cast<sal_uInt16>( nPos ) )->GetGradient() )); else { - const SfxPoolItem* pPoolItem = nullptr; - if( SfxItemState::SET == m_rOutAttrs.GetItemState( GetWhich( XATTR_FILLSTYLE ), true, &pPoolItem ) ) + if( const XFillStyleItem* pFillStyleItem = m_rOutAttrs.GetItemIfSet( GetWhich( XATTR_FILLSTYLE ) ) ) { - if( ( drawing::FillStyle_GRADIENT == static_cast<const XFillStyleItem*>( pPoolItem )->GetValue() ) && - ( SfxItemState::SET == m_rOutAttrs.GetItemState( GetWhich( XATTR_FILLGRADIENT ), true, &pPoolItem ) ) ) + const XFillGradientItem* pGradientItem; + if( ( drawing::FillStyle_GRADIENT == pFillStyleItem->GetValue() ) && + ( pGradientItem = m_rOutAttrs.GetItemIfSet( GetWhich( XATTR_FILLGRADIENT ) ) ) ) { - pGradient.reset(new XGradient( static_cast<const XFillGradientItem*>( pPoolItem )->GetGradientValue() )); + pGradient.reset(new basegfx::BGradient( pGradientItem->GetGradientValue() )); } } if( !pGradient ) @@ -517,7 +526,7 @@ void SvxGradientTabPage::ChangeGradientHdl_Impl() sal_uInt16 nPosition = m_xGradientLB->GetItemId(0); m_xGradientLB->SelectItem( nPosition ); if( nPosition != 0 ) - pGradient.reset(new XGradient( m_pGradientList->GetGradient( 0 )->GetGradient() )); + pGradient.reset(new basegfx::BGradient( m_pGradientList->GetGradient( 0 )->GetGradient() )); } } @@ -526,6 +535,10 @@ void SvxGradientTabPage::ChangeGradientHdl_Impl() css::awt::GradientStyle eXGS = pGradient->GetGradientStyle(); sal_uInt16 nValue = pGradient->GetSteps(); + if (const XGradientStepCountItem* pGradientStepCountItem = m_rOutAttrs.GetItemIfSet(GetWhich(XATTR_GRADIENTSTEPCOUNT))) + { + nValue = pGradientStepCountItem->GetValue(); + } if( nValue == 0 ) { m_xCbIncrement->set_state(TRISTATE_TRUE); @@ -542,10 +555,17 @@ void SvxGradientTabPage::ChangeGradientHdl_Impl() // if the entry is not in the listbox, // colors are added temporarily m_xLbColorFrom->SetNoSelection(); - m_xLbColorFrom->SelectEntry( pGradient->GetStartColor() ); + m_xLbColorFrom->SelectEntry(Color(pGradient->GetColorStops().front().getStopColor())); m_xLbColorTo->SetNoSelection(); - m_xLbColorTo->SelectEntry( pGradient->GetEndColor() ); + m_xLbColorTo->SelectEntry(Color(pGradient->GetColorStops().back().getStopColor())); + + // MCGR: preserve ColorStops if given. + // tdf#155901 We need offset of first and last stop, so include them. + if (pGradient->GetColorStops().size() >= 2) + m_aColorStops = pGradient->GetColorStops(); + else + m_aColorStops.clear(); m_xMtrAngle->set_value(pGradient->GetAngle().get() / 10, FieldUnit::NONE); // should be changed in resource m_xSliderAngle->set_value(pGradient->GetAngle().get() / 10); @@ -630,4 +650,25 @@ sal_Int32 SvxGradientTabPage::SearchGradientList(std::u16string_view rGradientNa return nPos; } +basegfx::BColorStops SvxGradientTabPage::createColorStops() +{ + basegfx::BColorStops aColorStops; + + if(m_aColorStops.size() >= 2) + { + aColorStops = m_aColorStops; + aColorStops.front() = basegfx::BColorStop(m_aColorStops.front().getStopOffset(), + m_xLbColorFrom->GetSelectEntryColor().getBColor()); + aColorStops.back() = basegfx::BColorStop(m_aColorStops.back().getStopOffset(), + m_xLbColorTo->GetSelectEntryColor().getBColor()); + } + else + { + aColorStops.emplace_back(0.0, m_xLbColorFrom->GetSelectEntryColor().getBColor()); + aColorStops.emplace_back(1.0, m_xLbColorTo->GetSelectEntryColor().getBColor()); + } + + return aColorStops; +} + /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/cui/source/tabpages/tphatch.cxx b/cui/source/tabpages/tphatch.cxx index 2b9bb9401482..ccfc12a7b445 100644 --- a/cui/source/tabpages/tphatch.cxx +++ b/cui/source/tabpages/tphatch.cxx @@ -149,7 +149,7 @@ void SvxHatchTabPage::ActivatePage( const SfxItemSet& rSet ) // determining (possibly cutting) the name // and displaying it in the GroupBox - OUString aString = CuiResId( RID_SVXSTR_TABLE ) + ": "; + OUString aString = CuiResId( RID_CUISTR_TABLE ) + ": "; INetURLObject aURL( m_pHatchingList->GetPath() ); aURL.Append( m_pHatchingList->GetName() ); @@ -245,7 +245,7 @@ bool SvxHatchTabPage::FillItemSet( SfxItemSet* rSet ) if (m_xCbBackgroundColor->get_active()) { NamedColor aColor = m_xLbBackgroundColor->GetSelectedEntry(); - rSet->Put(XFillColorItem(aColor.second, aColor.first)); + rSet->Put(XFillColorItem(aColor.m_aName, aColor.m_aColor)); } return true; } @@ -358,13 +358,13 @@ void SvxHatchTabPage::ChangeHatchHdl_Impl() pHatch.reset(new XHatch( m_pHatchingList->GetHatch( static_cast<sal_uInt16>(nPos) )->GetHatch() )); else { - const SfxPoolItem* pPoolItem = nullptr; - if( SfxItemState::SET == m_rOutAttrs.GetItemState( GetWhich( XATTR_FILLSTYLE ), true, &pPoolItem ) ) + if( const XFillStyleItem* pFillStyleItem = m_rOutAttrs.GetItemIfSet( GetWhich( XATTR_FILLSTYLE ) ) ) { - if( ( drawing::FillStyle_HATCH == static_cast<const XFillStyleItem*>( pPoolItem )->GetValue() ) && - ( SfxItemState::SET == m_rOutAttrs.GetItemState( GetWhich( XATTR_FILLHATCH ), true, &pPoolItem ) ) ) + const XFillHatchItem* pFillHatchItem; + if( ( drawing::FillStyle_HATCH == pFillStyleItem->GetValue() ) && + ( pFillHatchItem = m_rOutAttrs.GetItemIfSet( GetWhich( XATTR_FILLHATCH ) ) ) ) { - pHatch.reset(new XHatch( static_cast<const XFillHatchItem*>( pPoolItem )->GetHatchValue() )); + pHatch.reset(new XHatch( pFillHatchItem->GetHatchValue() )); } } if( !pHatch ) @@ -403,7 +403,7 @@ void SvxHatchTabPage::ChangeHatchHdl_Impl() IMPL_LINK_NOARG(SvxHatchTabPage, ClickAddHdl_Impl, weld::Button&, void) { OUString aNewName( SvxResId( RID_SVXSTR_HATCH ) ); - OUString aDesc( CuiResId( RID_SVXSTR_DESC_HATCH ) ); + OUString aDesc( CuiResId( RID_CUISTR_DESC_HATCH ) ); OUString aName; tools::Long nCount = m_pHatchingList->Count(); @@ -422,7 +422,7 @@ IMPL_LINK_NOARG(SvxHatchTabPage, ClickAddHdl_Impl, weld::Button&, void) while( pDlg->Execute() == RET_OK ) { - pDlg->GetName( aName ); + aName = pDlg->GetName(); bValidHatchName = (SearchHatchList(aName) == -1); if( bValidHatchName ) @@ -526,7 +526,7 @@ IMPL_LINK_NOARG(SvxHatchTabPage, ClickRenameHdl_Impl, SvxPresetListBox*, void ) if( nPos == VALUESET_ITEM_NOTFOUND ) return; - OUString aDesc( CuiResId( RID_SVXSTR_DESC_HATCH ) ); + OUString aDesc( CuiResId( RID_CUISTR_DESC_HATCH ) ); OUString aName( m_pHatchingList->GetHatch( nPos )->GetName() ); SvxAbstractDialogFactory* pFact = SvxAbstractDialogFactory::Create(); @@ -535,7 +535,7 @@ IMPL_LINK_NOARG(SvxHatchTabPage, ClickRenameHdl_Impl, SvxPresetListBox*, void ) bool bLoop = true; while( bLoop && pDlg->Execute() == RET_OK ) { - pDlg->GetName( aName ); + aName = pDlg->GetName(); sal_Int32 nHatchPos = SearchHatchList( aName ); bool bValidHatchName = (nHatchPos == static_cast<sal_Int32>(nPos) ) || (nHatchPos == -1); diff --git a/cui/source/tabpages/tpline.cxx b/cui/source/tabpages/tpline.cxx index e93b7bfa6310..1c1635293823 100644 --- a/cui/source/tabpages/tpline.cxx +++ b/cui/source/tabpages/tpline.cxx @@ -242,7 +242,7 @@ void SvxLineTabPage::FillListboxes() void SvxLineTabPage::ActivatePage( const SfxItemSet& rSet ) { - const CntUInt16Item* pPageTypeItem = rSet.GetItem<CntUInt16Item>(SID_PAGE_TYPE, false); + const SfxUInt16Item* pPageTypeItem = rSet.GetItem<SfxUInt16Item>(SID_PAGE_TYPE, false); if (pPageTypeItem) SetPageType(static_cast<PageType>(pPageTypeItem->GetValue())); if( m_nDlgType == 0 && m_pDashList.is() ) @@ -413,7 +413,7 @@ bool SvxLineTabPage::FillItemSet( SfxItemSet* rAttrs ) pOld = GetOldItem( *rAttrs, XATTR_LINESTYLE ); if ( !pOld || !( *static_cast<const XLineStyleItem*>(pOld) == *pStyleItem ) ) { - rAttrs->Put( *pStyleItem ); + rAttrs->Put( std::move(pStyleItem) ); bModified = true; } } @@ -456,8 +456,10 @@ bool SvxLineTabPage::FillItemSet( SfxItemSet* rAttrs ) // Line color if (m_xLbColor->IsValueChangedFromSaved()) { - NamedColor aColor = m_xLbColor->GetSelectedEntry(); - XLineColorItem aItem(aColor.second, aColor.first); + NamedColor aNamedColor = m_xLbColor->GetSelectedEntry(); + XLineColorItem aItem(aNamedColor.m_aName, aNamedColor.m_aColor); + aItem.setComplexColor(aNamedColor.getComplexColor()); + pOld = GetOldItem( *rAttrs, XATTR_LINECOLOR ); if ( !pOld || !( *static_cast<const XLineColorItem*>(pOld) == aItem ) ) { @@ -480,7 +482,7 @@ bool SvxLineTabPage::FillItemSet( SfxItemSet* rAttrs ) pOld = GetOldItem( *rAttrs, XATTR_LINESTART ); if( pItem && ( !pOld || *pOld != *pItem ) ) { - rAttrs->Put( *pItem ); + rAttrs->Put( std::move(pItem) ); bModified = true; } } @@ -497,7 +499,7 @@ bool SvxLineTabPage::FillItemSet( SfxItemSet* rAttrs ) if( pItem && ( !pOld || !( *static_cast<const XLineEndItem*>(pOld) == *pItem ) ) ) { - rAttrs->Put( *pItem ); + rAttrs->Put( std::move(pItem) ); bModified = true; } } @@ -575,7 +577,7 @@ bool SvxLineTabPage::FillItemSet( SfxItemSet* rAttrs ) if(!pOld || !(*static_cast<const XLineJointItem*>(pOld) == *pNew)) { - rAttrs->Put( *pNew ); + rAttrs->Put( std::move(pNew) ); bModified = true; } } @@ -612,7 +614,7 @@ bool SvxLineTabPage::FillItemSet( SfxItemSet* rAttrs ) if(!pOld || !(*static_cast<const XLineCapItem*>(pOld) == *pNew)) { - rAttrs->Put( *pNew ); + rAttrs->Put( std::move(pNew) ); bModified = true; } } @@ -621,8 +623,8 @@ bool SvxLineTabPage::FillItemSet( SfxItemSet* rAttrs ) if(m_nSymbolType!=SVX_SYMBOLTYPE_UNKNOWN || m_bNewSize) { // Was set by selection or the size is different - SvxSizeItem aSItem(rAttrs->GetPool()->GetWhich(SID_ATTR_SYMBOLSIZE),m_aSymbolSize); - const SfxPoolItem* pSOld = GetOldItem( *rAttrs, rAttrs->GetPool()->GetWhich(SID_ATTR_SYMBOLSIZE) ); + SvxSizeItem aSItem(rAttrs->GetPool()->GetWhichIDFromSlotID(SID_ATTR_SYMBOLSIZE),m_aSymbolSize); + const SfxPoolItem* pSOld = GetOldItem( *rAttrs, rAttrs->GetPool()->GetWhichIDFromSlotID(SID_ATTR_SYMBOLSIZE) ); m_bNewSize = pSOld ? *static_cast<const SvxSizeItem *>(pSOld) != aSItem : m_bNewSize ; if(m_bNewSize) { @@ -630,8 +632,8 @@ bool SvxLineTabPage::FillItemSet( SfxItemSet* rAttrs ) bModified=true; } - SfxInt32Item aTItem(rAttrs->GetPool()->GetWhich(SID_ATTR_SYMBOLTYPE),m_nSymbolType); - const SfxPoolItem* pTOld = GetOldItem( *rAttrs, rAttrs->GetPool()->GetWhich(SID_ATTR_SYMBOLTYPE) ); + SfxInt32Item aTItem(rAttrs->GetPool()->GetWhichIDFromSlotID(SID_ATTR_SYMBOLTYPE),m_nSymbolType); + const SfxPoolItem* pTOld = GetOldItem( *rAttrs, rAttrs->GetPool()->GetWhichIDFromSlotID(SID_ATTR_SYMBOLTYPE) ); bool bNewType = pTOld == nullptr || *static_cast<const SfxInt32Item*>(pTOld) != aTItem; if(bNewType && m_nSymbolType==SVX_SYMBOLTYPE_UNKNOWN) bNewType=false; // a small fix, type wasn't set -> don't create a type item after all! @@ -643,8 +645,8 @@ bool SvxLineTabPage::FillItemSet( SfxItemSet* rAttrs ) if(m_nSymbolType!=SVX_SYMBOLTYPE_NONE) { - SvxBrushItem aBItem(m_aSymbolGraphic,GPOS_MM,rAttrs->GetPool()->GetWhich(SID_ATTR_BRUSH)); - const SfxPoolItem* pBOld = GetOldItem( *rAttrs, rAttrs->GetPool()->GetWhich(SID_ATTR_BRUSH) ); + SvxBrushItem aBItem(m_aSymbolGraphic,GPOS_MM,rAttrs->GetPool()->GetWhichIDFromSlotID(SID_ATTR_BRUSH)); + const SfxPoolItem* pBOld = GetOldItem( *rAttrs, rAttrs->GetPool()->GetWhichIDFromSlotID(SID_ATTR_BRUSH) ); bool bNewBrush = pBOld == nullptr || *static_cast<const SvxBrushItem*>(pBOld) != aBItem; if(bNewBrush) @@ -758,8 +760,10 @@ void SvxLineTabPage::FillXLSet_Impl() m_rXLSet.Put( XLineEndWidthItem( GetCoreValue( *m_xMtrEndWidth, m_ePoolUnit ) ) ); m_rXLSet.Put( XLineWidthItem( GetCoreValue( *m_xMtrLineWidth, m_ePoolUnit ) ) ); - NamedColor aColor = m_xLbColor->GetSelectedEntry(); - m_rXLSet.Put(XLineColorItem(aColor.second, aColor.first)); + NamedColor aNamedColor = m_xLbColor->GetSelectedEntry(); + XLineColorItem aLineColor(aNamedColor.m_aName, aNamedColor.m_aColor); + aLineColor.setComplexColor(aNamedColor.getComplexColor()); + m_rXLSet.Put(aLineColor); // Centered line end if( m_xTsbCenterStart->get_state() == TRISTATE_TRUE ) @@ -785,15 +789,14 @@ void SvxLineTabPage::Reset( const SfxItemSet* rAttrs ) drawing::LineStyle eXLS; // drawing::LineStyle_NONE, drawing::LineStyle_SOLID, drawing::LineStyle_DASH // Line style - const SfxPoolItem *pPoolItem; tools::Long nSymType=SVX_SYMBOLTYPE_UNKNOWN; bool bPrevSym=false; bool bEnable=true; bool bIgnoreGraphic=false; bool bIgnoreSize=false; - if(rAttrs->GetItemState(rAttrs->GetPool()->GetWhich(SID_ATTR_SYMBOLTYPE),true,&pPoolItem) == SfxItemState::SET) + if(const SfxInt32Item* pSymbolTypeItem = rAttrs->GetItemIfSet(rAttrs->GetPool()->GetWhichIDFromSlotID(SID_ATTR_SYMBOLTYPE))) { - nSymType=static_cast<const SfxInt32Item *>(pPoolItem)->GetValue(); + nSymType = pSymbolTypeItem->GetValue(); } if(nSymType == SVX_SYMBOLTYPE_AUTO) @@ -815,7 +818,6 @@ void SvxLineTabPage::Reset( const SfxItemSet* rAttrs ) std::unique_ptr<SdrModel> pModel( new SdrModel(nullptr, nullptr, true)); - pModel->GetItemPool().FreezeIdRanges(); rtl::Reference<SdrPage> pPage = new SdrPage( *pModel, false ); pPage->SetSize(Size(1000,1000)); pModel->InsertPage( pPage.get(), 0 ); @@ -829,7 +831,7 @@ void SvxLineTabPage::Reset( const SfxItemSet* rAttrs ) if(m_pSymbolList->GetObjCount()) { nSymTmp %= m_pSymbolList->GetObjCount(); // Treat list as cyclic! - SdrObject *pObj=m_pSymbolList->GetObj(nSymTmp); + rtl::Reference<SdrObject> pObj=m_pSymbolList->GetObj(nSymTmp); if(pObj) { // directly clone to target SdrModel @@ -844,16 +846,16 @@ void SvxLineTabPage::Reset( const SfxItemSet* rAttrs ) pObj->SetMergedItemSet(m_rOutAttrs); } - pPage->NbcInsertObject(pObj); + pPage->NbcInsertObject(pObj.get()); // Generate invisible square to give all symbol types a // bitmap size, which is independent from specific glyph - SdrObject* pInvisibleSquare(m_pSymbolList->GetObj(0)); + rtl::Reference<SdrObject> pInvisibleSquare(m_pSymbolList->GetObj(0)); // directly clone to target SdrModel pInvisibleSquare = pInvisibleSquare->CloneSdrObject(*pModel); - pPage->NbcInsertObject(pInvisibleSquare); + pPage->NbcInsertObject(pInvisibleSquare.get()); pInvisibleSquare->SetMergedItem(XFillTransparenceItem(100)); pInvisibleSquare->SetMergedItem(XLineTransparenceItem(100)); @@ -869,18 +871,18 @@ void SvxLineTabPage::Reset( const SfxItemSet* rAttrs ) bIgnoreGraphic=true; aView.UnmarkAll(); - pInvisibleSquare=pPage->RemoveObject(1); - SdrObject::Free( pInvisibleSquare); - pObj=pPage->RemoveObject(0); - SdrObject::Free( pObj ); + pPage->RemoveObject(1); + pInvisibleSquare.clear(); + pPage->RemoveObject(0); + pObj.clear(); } } } } } - if(rAttrs->GetItemState(rAttrs->GetPool()->GetWhich(SID_ATTR_BRUSH),true,&pPoolItem) == SfxItemState::SET) + if(const SvxBrushItem* pBrushItem = rAttrs->GetItemIfSet(rAttrs->GetPool()->GetWhichIDFromSlotID(SID_ATTR_BRUSH))) { - const Graphic* pGraphic = static_cast<const SvxBrushItem *>(pPoolItem)->GetGraphic(); + const Graphic* pGraphic = pBrushItem->GetGraphic(); if( pGraphic ) { if(!bIgnoreGraphic) @@ -897,9 +899,9 @@ void SvxLineTabPage::Reset( const SfxItemSet* rAttrs ) } } - if(rAttrs->GetItemState(rAttrs->GetPool()->GetWhich(SID_ATTR_SYMBOLSIZE),true,&pPoolItem) == SfxItemState::SET) + if(const SvxSizeItem* pSymbolSizeItem = rAttrs->GetItemIfSet(rAttrs->GetPool()->GetWhichIDFromSlotID(SID_ATTR_SYMBOLSIZE))) { - m_aSymbolSize = static_cast<const SvxSizeItem *>(pPoolItem)->GetSize(); + m_aSymbolSize = pSymbolSizeItem->GetSize(); } m_xGridIconSize->set_sensitive(bEnable); @@ -912,7 +914,7 @@ void SvxLineTabPage::Reset( const SfxItemSet* rAttrs ) m_aSymbolLastSize=m_aSymbolSize; } - if( rAttrs->GetItemState( XATTR_LINESTYLE ) != SfxItemState::DONTCARE ) + if( rAttrs->GetItemState( XATTR_LINESTYLE ) != SfxItemState::INVALID ) { eXLS = rAttrs->Get( XATTR_LINESTYLE ).GetValue(); @@ -940,7 +942,7 @@ void SvxLineTabPage::Reset( const SfxItemSet* rAttrs ) } // Line strength - if( rAttrs->GetItemState( XATTR_LINEWIDTH ) != SfxItemState::DONTCARE ) + if( rAttrs->GetItemState( XATTR_LINEWIDTH ) != SfxItemState::INVALID ) { SetMetricValue( *m_xMtrLineWidth, rAttrs->Get( XATTR_LINEWIDTH ).GetValue(), m_ePoolUnit ); } @@ -950,7 +952,7 @@ void SvxLineTabPage::Reset( const SfxItemSet* rAttrs ) // Line color m_xLbColor->SetNoSelection(); - if ( rAttrs->GetItemState( XATTR_LINECOLOR ) != SfxItemState::DONTCARE ) + if ( rAttrs->GetItemState( XATTR_LINECOLOR ) != SfxItemState::INVALID ) { Color aCol = rAttrs->Get( XATTR_LINECOLOR ).GetColorValue(); m_xLbColor->SelectEntry( aCol ); @@ -961,7 +963,7 @@ void SvxLineTabPage::Reset( const SfxItemSet* rAttrs ) { m_xLbStartStyle->set_sensitive(false); } - else if( rAttrs->GetItemState( XATTR_LINESTART ) != SfxItemState::DONTCARE ) + else if( rAttrs->GetItemState( XATTR_LINESTART ) != SfxItemState::INVALID ) { // #86265# select entry using list and polygon, not string bool bSelected(false); @@ -993,7 +995,7 @@ void SvxLineTabPage::Reset( const SfxItemSet* rAttrs ) { m_xLbEndStyle->set_sensitive(false); } - else if( rAttrs->GetItemState( XATTR_LINEEND ) != SfxItemState::DONTCARE ) + else if( rAttrs->GetItemState( XATTR_LINEEND ) != SfxItemState::INVALID ) { // #86265# select entry using list and polygon, not string bool bSelected(false); @@ -1025,7 +1027,7 @@ void SvxLineTabPage::Reset( const SfxItemSet* rAttrs ) { m_xMtrStartWidth->set_sensitive(false); } - else if( rAttrs->GetItemState( XATTR_LINESTARTWIDTH ) != SfxItemState::DONTCARE ) + else if( rAttrs->GetItemState( XATTR_LINESTARTWIDTH ) != SfxItemState::INVALID ) { SetMetricValue( *m_xMtrStartWidth, rAttrs->Get( XATTR_LINESTARTWIDTH ).GetValue(), @@ -1039,7 +1041,7 @@ void SvxLineTabPage::Reset( const SfxItemSet* rAttrs ) { m_xMtrEndWidth->set_sensitive(false); } - else if( rAttrs->GetItemState( XATTR_LINEENDWIDTH ) != SfxItemState::DONTCARE ) + else if( rAttrs->GetItemState( XATTR_LINEENDWIDTH ) != SfxItemState::INVALID ) { SetMetricValue( *m_xMtrEndWidth, rAttrs->Get( XATTR_LINEENDWIDTH ).GetValue(), @@ -1053,7 +1055,7 @@ void SvxLineTabPage::Reset( const SfxItemSet* rAttrs ) { m_xTsbCenterStart->set_sensitive(false); } - else if( rAttrs->GetItemState( XATTR_LINESTARTCENTER ) != SfxItemState::DONTCARE ) + else if( rAttrs->GetItemState( XATTR_LINESTARTCENTER ) != SfxItemState::INVALID ) { if( rAttrs->Get( XATTR_LINESTARTCENTER ).GetValue() ) m_xTsbCenterStart->set_state(TRISTATE_TRUE); @@ -1070,7 +1072,7 @@ void SvxLineTabPage::Reset( const SfxItemSet* rAttrs ) { m_xTsbCenterEnd->set_sensitive(false); } - else if( rAttrs->GetItemState( XATTR_LINEENDCENTER ) != SfxItemState::DONTCARE ) + else if( rAttrs->GetItemState( XATTR_LINEENDCENTER ) != SfxItemState::INVALID ) { if( rAttrs->Get( XATTR_LINEENDCENTER ).GetValue() ) m_xTsbCenterEnd->set_state(TRISTATE_TRUE); @@ -1083,7 +1085,7 @@ void SvxLineTabPage::Reset( const SfxItemSet* rAttrs ) } // Transparency - if( rAttrs->GetItemState( XATTR_LINETRANSPARENCE ) != SfxItemState::DONTCARE ) + if( rAttrs->GetItemState( XATTR_LINETRANSPARENCE ) != SfxItemState::INVALID ) { sal_uInt16 nTransp = rAttrs->Get( XATTR_LINETRANSPARENCE ).GetValue(); m_xMtrTransparent->set_value(nTransp, FieldUnit::PERCENT); @@ -1113,7 +1115,7 @@ void SvxLineTabPage::Reset( const SfxItemSet* rAttrs ) // maFTEdgeStyle.set_sensitive(false); m_xLBEdgeStyle->set_sensitive(false); } - else if(SfxItemState::DONTCARE != rAttrs->GetItemState(XATTR_LINEJOINT)) + else if(SfxItemState::INVALID != rAttrs->GetItemState(XATTR_LINEJOINT)) { const css::drawing::LineJoint eLineJoint = rAttrs->Get(XATTR_LINEJOINT).GetValue(); @@ -1137,7 +1139,7 @@ void SvxLineTabPage::Reset( const SfxItemSet* rAttrs ) { m_xLBCapStyle->set_sensitive(false); } - else if(SfxItemState::DONTCARE != rAttrs->GetItemState(XATTR_LINECAP)) + else if(SfxItemState::INVALID != rAttrs->GetItemState(XATTR_LINECAP)) { const css::drawing::LineCap eLineCap(rAttrs->Get(XATTR_LINECAP).GetValue()); @@ -1443,7 +1445,6 @@ IMPL_LINK_NOARG(SvxLineTabPage, MenuCreateHdl_Impl, weld::Toggleable&, void) pVDev->SetMapMode(MapMode(MapUnit::Map100thMM)); std::unique_ptr<SdrModel> pModel( new SdrModel(nullptr, nullptr, true)); - pModel->GetItemPool().FreezeIdRanges(); // Page rtl::Reference<SdrPage> pPage = new SdrPage( *pModel, false ); pPage->SetSize(Size(1000,1000)); @@ -1456,25 +1457,25 @@ IMPL_LINK_NOARG(SvxLineTabPage, MenuCreateHdl_Impl, weld::Toggleable&, void) // Generate invisible square to give all symbols a // bitmap size, which is independent from specific glyph - SdrObject *pInvisibleSquare=m_pSymbolList->GetObj(0); + rtl::Reference<SdrObject> pInvisibleSquare=m_pSymbolList->GetObj(0); // directly clone to target SdrModel pInvisibleSquare = pInvisibleSquare->CloneSdrObject(*pModel); - pPage->NbcInsertObject(pInvisibleSquare); + pPage->NbcInsertObject(pInvisibleSquare.get()); pInvisibleSquare->SetMergedItem(XFillTransparenceItem(100)); pInvisibleSquare->SetMergedItem(XLineTransparenceItem(100)); for(size_t i=0; i < m_pSymbolList->GetObjCount(); ++i) { - SdrObject *pObj=m_pSymbolList->GetObj(i); + rtl::Reference<SdrObject> pObj=m_pSymbolList->GetObj(i); assert(pObj); // directly clone to target SdrModel pObj = pObj->CloneSdrObject(*pModel); m_aGrfNames.emplace_back(""); - pPage->NbcInsertObject(pObj); + pPage->NbcInsertObject(pObj.get()); if(m_xSymbolAttr) { pObj->SetMergedItemSet(*m_xSymbolAttr); @@ -1487,8 +1488,8 @@ IMPL_LINK_NOARG(SvxLineTabPage, MenuCreateHdl_Impl, weld::Toggleable&, void) BitmapEx aBitmapEx(aView.GetMarkedObjBitmapEx()); GDIMetaFile aMeta(aView.GetMarkedObjMetaFile()); aView.UnmarkAll(); - pObj=pPage->RemoveObject(1); - SdrObject::Free(pObj); + pPage->RemoveObject(1); + pObj.clear(); SvxBmpItemInfo* pInfo = new SvxBmpItemInfo; pInfo->pBrushItem.reset(new SvxBrushItem(Graphic(aMeta), GPOS_AREA, SID_ATTR_BRUSH)); @@ -1508,8 +1509,8 @@ IMPL_LINK_NOARG(SvxLineTabPage, MenuCreateHdl_Impl, weld::Toggleable&, void) pVD->DrawBitmapEx(Point(), aBitmapEx); m_xSymbolsMenu->append(pInfo->sItemId, "", *pVD); } - pInvisibleSquare=pPage->RemoveObject(0); - SdrObject::Free(pInvisibleSquare); + pPage->RemoveObject(0); + pInvisibleSquare.clear(); if (m_aGrfNames.empty()) m_xSymbolMB->set_item_sensitive("symbols", false); @@ -1518,7 +1519,7 @@ IMPL_LINK_NOARG(SvxLineTabPage, MenuCreateHdl_Impl, weld::Toggleable&, void) // #58425# Symbols on a list (e.g. StarChart) // Handler for menu button -IMPL_LINK(SvxLineTabPage, GraphicHdl_Impl, const OString&, rIdent, void) +IMPL_LINK(SvxLineTabPage, GraphicHdl_Impl, const OUString&, rIdent, void) { const Graphic* pGraphic = nullptr; Graphic aGraphic; @@ -1526,7 +1527,7 @@ IMPL_LINK(SvxLineTabPage, GraphicHdl_Impl, const OString&, rIdent, void) bool bEnable = true; tools::Long nPreviousSymbolType = m_nSymbolType; - OString sNumber; + OUString sNumber; if (rIdent.startsWith("gallery", &sNumber)) { SvxBmpItemInfo* pInfo = m_aGalleryBrushItems[sNumber.toUInt32()].get(); @@ -1553,7 +1554,7 @@ IMPL_LINK(SvxLineTabPage, GraphicHdl_Impl, const OString&, rIdent, void) } else if (rIdent == "file") { - SvxOpenGraphicDialog aGrfDlg(CuiResId(RID_SVXSTR_EDIT_GRAPHIC), GetFrameWeld()); + SvxOpenGraphicDialog aGrfDlg(CuiResId(RID_CUISTR_EDIT_GRAPHIC), GetFrameWeld()); aGrfDlg.EnableLink(false); aGrfDlg.AsLink(false); if( !aGrfDlg.Execute() ) diff --git a/cui/source/tabpages/tplnedef.cxx b/cui/source/tabpages/tplnedef.cxx index c895a6969c9b..c8c180b047e3 100644 --- a/cui/source/tabpages/tplnedef.cxx +++ b/cui/source/tabpages/tplnedef.cxx @@ -166,7 +166,7 @@ void SvxLineDefTabPage::ActivatePage( const SfxItemSet& ) // determining (and possibly cutting) the name // and displaying it in the GroupBox -// OUString aString( CuiResId( RID_SVXSTR_TABLE ) ); +// OUString aString( CuiResId( RID_CUISTR_TABLE ) ); // aString += ": "; INetURLObject aURL( pDashList->GetPath() ); @@ -203,10 +203,10 @@ void SvxLineDefTabPage::CheckChanges_Impl() { std::unique_ptr<weld::MessageDialog> xMessDlg(Application::CreateMessageDialog(GetFrameWeld(), VclMessageType::Warning, VclButtonsType::Cancel, - CuiResId(RID_SVXSTR_ASK_CHANGE_LINESTYLE))); + CuiResId(RID_CUISTR_ASK_CHANGE_LINESTYLE))); xMessDlg->set_title(SvxResId(RID_SVXSTR_LINESTYLE)); - xMessDlg->add_button(CuiResId(RID_SVXSTR_CHANGE), RET_BTN_1); - xMessDlg->add_button(CuiResId(RID_SVXSTR_ADD), RET_BTN_2); + xMessDlg->add_button(CuiResId(RID_CUISTR_CHANGE), RET_BTN_1); + xMessDlg->add_button(CuiResId(RID_CUISTR_ADD), RET_BTN_2); short nRet = xMessDlg->run(); @@ -256,9 +256,9 @@ bool SvxLineDefTabPage::FillItemSet( SfxItemSet* rAttrs ) void SvxLineDefTabPage::Reset( const SfxItemSet* rAttrs ) { - if( rAttrs->GetItemState( GetWhich( XATTR_LINESTYLE ) ) != SfxItemState::DONTCARE ) + if( rAttrs->GetItemState( GetWhich( XATTR_LINESTYLE ) ) != SfxItemState::INVALID ) { - drawing::LineStyle eXLS = static_cast<const XLineStyleItem&>( rAttrs->Get( GetWhich( XATTR_LINESTYLE ) ) ).GetValue(); + drawing::LineStyle eXLS = rAttrs->Get( GetWhich( XATTR_LINESTYLE ) ).GetValue(); switch( eXLS ) { @@ -489,7 +489,7 @@ void SvxLineDefTabPage::SelectTypeHdl_Impl(const weld::ComboBox* p) IMPL_LINK_NOARG(SvxLineDefTabPage, ClickAddHdl_Impl, weld::Button&, void) { OUString aNewName(SvxResId(RID_SVXSTR_LINESTYLE)); - OUString aDesc(CuiResId(RID_SVXSTR_DESC_LINESTYLE)); + OUString aDesc(CuiResId(RID_CUISTR_DESC_LINESTYLE)); OUString aName; tools::Long nCount = pDashList->Count(); @@ -512,7 +512,7 @@ IMPL_LINK_NOARG(SvxLineDefTabPage, ClickAddHdl_Impl, weld::Button&, void) while ( bLoop && pDlg->Execute() == RET_OK ) { - pDlg->GetName( aName ); + aName = pDlg->GetName(); bDifferent = true; for( tools::Long i = 0; i < nCount && bDifferent; i++ ) @@ -569,7 +569,7 @@ IMPL_LINK_NOARG(SvxLineDefTabPage, ClickModifyHdl_Impl, weld::Button&, void) if (nPos == -1) return; - OUString aDesc(CuiResId(RID_SVXSTR_DESC_LINESTYLE)); + OUString aDesc(CuiResId(RID_CUISTR_DESC_LINESTYLE)); OUString aName( pDashList->GetDash( nPos )->GetName() ); OUString aOldName = aName; @@ -581,7 +581,7 @@ IMPL_LINK_NOARG(SvxLineDefTabPage, ClickModifyHdl_Impl, weld::Button&, void) while ( bLoop && pDlg->Execute() == RET_OK ) { - pDlg->GetName( aName ); + aName = pDlg->GetName(); bool bDifferent = true; for( tools::Long i = 0; i < nCount && bDifferent; i++ ) diff --git a/cui/source/tabpages/tplneend.cxx b/cui/source/tabpages/tplneend.cxx index d34b016fa7b0..2d181a3f5cb9 100644 --- a/cui/source/tabpages/tplneend.cxx +++ b/cui/source/tabpages/tplneend.cxx @@ -109,7 +109,7 @@ void SvxLineEndDefTabPage::Construct() { SdrObjTransformInfoRec aInfoRec; pPolyObj->TakeObjInfo( aInfoRec ); - SdrObjectUniquePtr pNewObj; + rtl::Reference<SdrObject> pNewObj; if( aInfoRec.bCanConvToPath ) pNewObj = pPolyObj->ConvertToPolyObj( true, false ); @@ -270,7 +270,7 @@ IMPL_LINK_NOARG(SvxLineEndDefTabPage, ClickModifyHdl_Impl, weld::Button&, void) if (nPos == -1) return; - OUString aDesc(CuiResId(RID_SVXSTR_DESC_LINEEND)); + OUString aDesc(CuiResId(RID_CUISTR_DESC_LINEEND)); OUString aName(m_xEdtName->get_text()); tools::Long nCount = pLineEndList->Count(); bool bDifferent = true; @@ -293,7 +293,7 @@ IMPL_LINK_NOARG(SvxLineEndDefTabPage, ClickModifyHdl_Impl, weld::Button&, void) while( !bDifferent && bLoop && pDlg->Execute() == RET_OK ) { - pDlg->GetName( aName ); + aName = pDlg->GetName(); bDifferent = true; for( tools::Long i = 0; i < nCount && bDifferent; i++ ) @@ -341,7 +341,7 @@ IMPL_LINK_NOARG(SvxLineEndDefTabPage, ClickAddHdl_Impl, weld::Button&, void) if( pPolyObj ) { const SdrObject* pNewObj; - SdrObjectUniquePtr pConvPolyObj; + rtl::Reference<SdrObject> pConvPolyObj; if( nullptr != dynamic_cast<const SdrPathObj*>( pPolyObj) ) { @@ -370,10 +370,10 @@ IMPL_LINK_NOARG(SvxLineEndDefTabPage, ClickAddHdl_Impl, weld::Button&, void) // normalize aNewPolyPolygon.transform(basegfx::utils::createTranslateB2DHomMatrix( -aNewRange.getMinX(), -aNewRange.getMinY())); - pConvPolyObj.reset(); + pConvPolyObj.clear(); OUString aNewName(SvxResId(RID_SVXSTR_LINEEND)); - OUString aDesc(CuiResId(RID_SVXSTR_DESC_LINEEND)); + OUString aDesc(CuiResId(RID_CUISTR_DESC_LINEEND)); OUString aName; tools::Long nCount = pLineEndList->Count(); @@ -396,7 +396,7 @@ IMPL_LINK_NOARG(SvxLineEndDefTabPage, ClickAddHdl_Impl, weld::Button&, void) while ( bLoop && pDlg->Execute() == RET_OK ) { - pDlg->GetName( aName ); + aName = pDlg->GetName(); bDifferent = true; for( tools::Long i = 0; i < nCount && bDifferent; i++ ) diff --git a/cui/source/tabpages/tppattern.cxx b/cui/source/tabpages/tppattern.cxx index 5fe830715b7f..9a37685951dd 100644 --- a/cui/source/tabpages/tppattern.cxx +++ b/cui/source/tabpages/tppattern.cxx @@ -147,7 +147,7 @@ void SvxPatternTabPage::ActivatePage( const SfxItemSet& rSet ) // determining (possibly cutting) the name and // displaying it in the GroupBox - OUString aString = CuiResId( RID_SVXSTR_TABLE ) + ": "; + OUString aString = CuiResId( RID_CUISTR_TABLE ) + ": "; INetURLObject aURL( m_pPatternList->GetPath() ); aURL.Append( m_pPatternList->GetName() ); @@ -253,15 +253,14 @@ IMPL_LINK_NOARG(SvxPatternTabPage, ChangePatternHdl_Impl, ValueSet*, void) } else { - const SfxPoolItem* pPoolItem = nullptr; - - if(SfxItemState::SET == m_rOutAttrs.GetItemState(GetWhich(XATTR_FILLSTYLE), true, &pPoolItem)) + if(const XFillStyleItem* pFillStyleItem = m_rOutAttrs.GetItemIfSet(GetWhich(XATTR_FILLSTYLE))) { - const drawing::FillStyle eXFS(static_cast<const XFillStyleItem*>(pPoolItem)->GetValue()); + const drawing::FillStyle eXFS(pFillStyleItem->GetValue()); - if((drawing::FillStyle_BITMAP == eXFS) && (SfxItemState::SET == m_rOutAttrs.GetItemState(GetWhich(XATTR_FILLBITMAP), true, &pPoolItem))) + const XFillBitmapItem* pBitmapItem; + if((drawing::FillStyle_BITMAP == eXFS) && (pBitmapItem = m_rOutAttrs.GetItemIfSet(GetWhich(XATTR_FILLBITMAP)))) { - pGraphicObject.reset(new GraphicObject(static_cast<const XFillBitmapItem*>(pPoolItem)->GetGraphicObject())); + pGraphicObject.reset(new GraphicObject(pBitmapItem->GetGraphicObject())); } } @@ -323,7 +322,7 @@ IMPL_LINK_NOARG(SvxPatternTabPage, ClickAddHdl_Impl, weld::Button&, void) { OUString aNewName( SvxResId( RID_SVXSTR_PATTERN_UNTITLED ) ); - OUString aDesc( CuiResId( RID_SVXSTR_DESC_NEW_PATTERN ) ); + OUString aDesc( CuiResId( RID_CUISTR_DESC_NEW_PATTERN ) ); OUString aName; tools::Long nCount = m_pPatternList->Count(); @@ -342,7 +341,7 @@ IMPL_LINK_NOARG(SvxPatternTabPage, ClickAddHdl_Impl, weld::Button&, void) while( pDlg->Execute() == RET_OK ) { - pDlg->GetName( aName ); + aName = pDlg->GetName(); bValidPatternName = (SearchPatternList(aName) == -1); @@ -370,12 +369,8 @@ IMPL_LINK_NOARG(SvxPatternTabPage, ClickAddHdl_Impl, weld::Button&, void) } else // it must be a not existing imported bitmap { - const SfxPoolItem* pPoolItem = nullptr; - - if(SfxItemState::SET == m_rOutAttrs.GetItemState(XATTR_FILLBITMAP, true, &pPoolItem)) + if(const XFillBitmapItem* pFillBmpItem = m_rOutAttrs.GetItemIfSet(XATTR_FILLBITMAP)) { - auto pFillBmpItem = dynamic_cast<const XFillBitmapItem*>(pPoolItem); - assert(pFillBmpItem); pEntry.reset(new XBitmapEntry(pFillBmpItem->GetGraphicObject(), aName)); } else @@ -436,7 +431,7 @@ IMPL_LINK_NOARG(SvxPatternTabPage, ClickRenameHdl_Impl, SvxPresetListBox*, void) if ( nPos == VALUESET_ITEM_NOTFOUND ) return; - OUString aDesc(CuiResId(RID_SVXSTR_DESC_NEW_PATTERN)); + OUString aDesc(CuiResId(RID_CUISTR_DESC_NEW_PATTERN)); OUString aName(m_pPatternList->GetBitmap(nPos)->GetName()); SvxAbstractDialogFactory* pFact = SvxAbstractDialogFactory::Create(); @@ -446,7 +441,7 @@ IMPL_LINK_NOARG(SvxPatternTabPage, ClickRenameHdl_Impl, SvxPresetListBox*, void) while( bLoop && pDlg->Execute() == RET_OK ) { - pDlg->GetName( aName ); + aName = pDlg->GetName(); sal_Int32 nPatternPos = SearchPatternList(aName); bool bValidPatternName = (nPatternPos == static_cast<sal_Int32>(nPos) ) || (nPatternPos == -1); diff --git a/cui/source/tabpages/tpshadow.cxx b/cui/source/tabpages/tpshadow.cxx index 4a538968536b..ca2bc3b8a574 100644 --- a/cui/source/tabpages/tpshadow.cxx +++ b/cui/source/tabpages/tpshadow.cxx @@ -91,28 +91,27 @@ SvxShadowTabPage::SvxShadowTabPage(weld::Container* pPage, weld::DialogControlle // setting the output device drawing::FillStyle eXFS = drawing::FillStyle_SOLID; - if( m_rOutAttrs.GetItemState( XATTR_FILLSTYLE ) != SfxItemState::DONTCARE ) + if( m_rOutAttrs.GetItemState( XATTR_FILLSTYLE ) != SfxItemState::INVALID ) { - eXFS = static_cast<const XFillStyleItem&>( m_rOutAttrs. - Get( GetWhich( XATTR_FILLSTYLE ) ) ).GetValue(); + eXFS = m_rOutAttrs.Get( GetWhich( XATTR_FILLSTYLE ) ).GetValue(); switch( eXFS ) { case drawing::FillStyle_SOLID: - if( SfxItemState::DONTCARE != m_rOutAttrs.GetItemState( XATTR_FILLCOLOR ) ) + if( SfxItemState::INVALID != m_rOutAttrs.GetItemState( XATTR_FILLCOLOR ) ) { m_rXFSet.Put( m_rOutAttrs.Get( XATTR_FILLCOLOR ) ); } break; case drawing::FillStyle_GRADIENT: - if( SfxItemState::DONTCARE != m_rOutAttrs.GetItemState( XATTR_FILLGRADIENT ) ) + if( SfxItemState::INVALID != m_rOutAttrs.GetItemState( XATTR_FILLGRADIENT ) ) { m_rXFSet.Put( m_rOutAttrs.Get( XATTR_FILLGRADIENT ) ); } break; case drawing::FillStyle_HATCH: - if( SfxItemState::DONTCARE != m_rOutAttrs.GetItemState( XATTR_FILLHATCH ) ) + if( SfxItemState::INVALID != m_rOutAttrs.GetItemState( XATTR_FILLHATCH ) ) { m_rXFSet.Put( m_rOutAttrs.Get( XATTR_FILLHATCH ) ); } @@ -120,7 +119,7 @@ SvxShadowTabPage::SvxShadowTabPage(weld::Container* pPage, weld::DialogControlle case drawing::FillStyle_BITMAP: { - if( SfxItemState::DONTCARE != m_rOutAttrs.GetItemState( XATTR_FILLBITMAP ) ) + if( SfxItemState::INVALID != m_rOutAttrs.GetItemState( XATTR_FILLBITMAP ) ) { m_rXFSet.Put( m_rOutAttrs.Get( XATTR_FILLBITMAP ) ); } @@ -258,18 +257,18 @@ bool SvxShadowTabPage::FillItemSet( SfxItemSet* rAttrs ) case RectPoint::MM: break; } - // If the values of the shadow distances==SfxItemState::DONTCARE and the displayed + // If the values of the shadow distances==SfxItemState::INVALID and the displayed // string in the respective MetricField=="", then the comparison of the old // and the new distance values would return a wrong result because in such a // case the new distance values would match the default values of the MetricField !!!! if ( !m_xMtrDistance->get_text().isEmpty() || - m_rOutAttrs.GetItemState( SDRATTR_SHADOWXDIST ) != SfxItemState::DONTCARE || - m_rOutAttrs.GetItemState( SDRATTR_SHADOWYDIST ) != SfxItemState::DONTCARE ) + m_rOutAttrs.GetItemState( SDRATTR_SHADOWXDIST ) != SfxItemState::INVALID || + m_rOutAttrs.GetItemState( SDRATTR_SHADOWYDIST ) != SfxItemState::INVALID ) { sal_Int32 nOldX = 9876543; // impossible value, so DontCare sal_Int32 nOldY = 9876543; - if( m_rOutAttrs.GetItemState( SDRATTR_SHADOWXDIST ) != SfxItemState::DONTCARE && - m_rOutAttrs.GetItemState( SDRATTR_SHADOWYDIST ) != SfxItemState::DONTCARE ) + if( m_rOutAttrs.GetItemState( SDRATTR_SHADOWXDIST ) != SfxItemState::INVALID && + m_rOutAttrs.GetItemState( SDRATTR_SHADOWYDIST ) != SfxItemState::INVALID ) { nOldX = m_rOutAttrs.Get( SDRATTR_SHADOWXDIST ).GetValue(); nOldY = m_rOutAttrs.Get( SDRATTR_SHADOWYDIST ).GetValue(); @@ -339,7 +338,7 @@ void SvxShadowTabPage::Reset( const SfxItemSet* rAttrs ) // at the moment there are only 8 possible positions where a shadow can be set // has a shadow been set? - if( rAttrs->GetItemState( SDRATTR_SHADOW ) != SfxItemState::DONTCARE ) + if( rAttrs->GetItemState( SDRATTR_SHADOW ) != SfxItemState::INVALID ) { if( rAttrs->Get( SDRATTR_SHADOW ).GetValue() ) m_xTsbShowShadow->set_state(TRISTATE_TRUE); @@ -354,8 +353,8 @@ void SvxShadowTabPage::Reset( const SfxItemSet* rAttrs ) // distance (only 8 possible positions), // so there is only one item evaluated - if( rAttrs->GetItemState( SDRATTR_SHADOWXDIST ) != SfxItemState::DONTCARE && - rAttrs->GetItemState( SDRATTR_SHADOWYDIST ) != SfxItemState::DONTCARE ) + if( rAttrs->GetItemState( SDRATTR_SHADOWXDIST ) != SfxItemState::INVALID && + rAttrs->GetItemState( SDRATTR_SHADOWYDIST ) != SfxItemState::INVALID ) { sal_Int32 nX = rAttrs->Get( SDRATTR_SHADOWXDIST ).GetValue(); sal_Int32 nY = rAttrs->Get( SDRATTR_SHADOWYDIST ).GetValue(); @@ -382,9 +381,9 @@ void SvxShadowTabPage::Reset( const SfxItemSet* rAttrs ) // determine default-distance SfxItemPool* pPool = m_rOutAttrs.GetPool(); { - sal_Int32 n = pPool->GetDefaultItem(SDRATTR_SHADOWXDIST).GetValue(); + sal_Int32 n = pPool->GetUserOrPoolDefaultItem(SDRATTR_SHADOWXDIST).GetValue(); if (n == 0) - n = pPool->GetDefaultItem(SDRATTR_SHADOWYDIST).GetValue(); + n = pPool->GetUserOrPoolDefaultItem(SDRATTR_SHADOWYDIST).GetValue(); SetMetricValue(*m_xMtrDistance, std::abs(n), m_ePoolUnit); } @@ -395,14 +394,14 @@ void SvxShadowTabPage::Reset( const SfxItemSet* rAttrs ) m_aCtlPosition.SetActualRP( RectPoint::MM ); } - if( rAttrs->GetItemState( SDRATTR_SHADOWCOLOR ) != SfxItemState::DONTCARE ) + if( rAttrs->GetItemState( SDRATTR_SHADOWCOLOR ) != SfxItemState::INVALID ) { m_xLbShadowColor->SelectEntry( rAttrs->Get( SDRATTR_SHADOWCOLOR ).GetColorValue() ); } else m_xLbShadowColor->SetNoSelection(); - if( rAttrs->GetItemState( SDRATTR_SHADOWTRANSPARENCE ) != SfxItemState::DONTCARE ) + if( rAttrs->GetItemState( SDRATTR_SHADOWTRANSPARENCE ) != SfxItemState::INVALID ) { sal_uInt16 nTransp = rAttrs->Get( SDRATTR_SHADOWTRANSPARENCE ).GetValue(); m_xMtrTransparent->set_value(nTransp, FieldUnit::PERCENT); @@ -410,7 +409,7 @@ void SvxShadowTabPage::Reset( const SfxItemSet* rAttrs ) else m_xMtrTransparent->set_text(""); - if( rAttrs->GetItemState( SDRATTR_SHADOWBLUR ) != SfxItemState::DONTCARE ) + if( rAttrs->GetItemState( SDRATTR_SHADOWBLUR ) != SfxItemState::INVALID ) { sal_uInt16 nBlur = rAttrs->Get( SDRATTR_SHADOWBLUR ).GetValue(); m_xLbShadowBlurMetric->set_value(nBlur, FieldUnit::MM_100TH); diff --git a/cui/source/tabpages/tptrans.cxx b/cui/source/tabpages/tptrans.cxx index e78fcfffe16d..b2d6a10dea0a 100644 --- a/cui/source/tabpages/tptrans.cxx +++ b/cui/source/tabpages/tptrans.cxx @@ -119,11 +119,8 @@ void SvxTransparenceTabPage::ModifiedTrgrHdl_Impl(const weld::ComboBox* pControl } // preview - sal_uInt8 nStartCol = static_cast<sal_uInt8>((static_cast<sal_uInt16>(m_xMtrTrgrStartValue->get_value(FieldUnit::PERCENT)) * 255) / 100); - sal_uInt8 nEndCol = static_cast<sal_uInt8>((static_cast<sal_uInt16>(m_xMtrTrgrEndValue->get_value(FieldUnit::PERCENT)) * 255) / 100); - XGradient aTmpGradient( - Color(nStartCol, nStartCol, nStartCol), - Color(nEndCol, nEndCol, nEndCol), + basegfx::BGradient aTmpGradient( + createColorStops(), static_cast<css::awt::GradientStyle>(m_xLbTrgrGradientType->get_active()), Degree10(static_cast<sal_Int16>(m_xMtrTrgrAngle->get_value(FieldUnit::DEGREE)) * 10), static_cast<sal_uInt16>(m_xMtrTrgrCenterX->get_value(FieldUnit::PERCENT)), @@ -253,8 +250,8 @@ bool SvxTransparenceTabPage::FillItemSet(SfxItemSet* rAttrs) bool bGradActive = (eStateGradient == SfxItemState::SET && static_cast<const XFillFloatTransparenceItem*>(pGradientItem)->IsEnabled()); bool bLinearActive = (eStateLinear == SfxItemState::SET && static_cast<const XFillTransparenceItem*>(pLinearItem)->GetValue() != 0); - bool bGradUsed = (eStateGradient == SfxItemState::DONTCARE); - bool bLinearUsed = (eStateLinear == SfxItemState::DONTCARE); + bool bGradUsed = (eStateGradient == SfxItemState::INVALID); + bool bLinearUsed = (eStateLinear == SfxItemState::INVALID); bool bModified(false); bool bSwitchOffLinear(false); @@ -290,11 +287,8 @@ bool SvxTransparenceTabPage::FillItemSet(SfxItemSet* rAttrs) || m_xMtrTrgrStartValue->get_value_changed_from_saved() || m_xMtrTrgrEndValue->get_value_changed_from_saved()) { - sal_uInt8 nStartCol = static_cast<sal_uInt8>((static_cast<sal_uInt16>(m_xMtrTrgrStartValue->get_value(FieldUnit::PERCENT)) * 255) / 100); - sal_uInt8 nEndCol = static_cast<sal_uInt8>((static_cast<sal_uInt16>(m_xMtrTrgrEndValue->get_value(FieldUnit::PERCENT)) * 255) / 100); - XGradient aTmpGradient( - Color(nStartCol, nStartCol, nStartCol), - Color(nEndCol, nEndCol, nEndCol), + basegfx::BGradient aTmpGradient( + createColorStops(), static_cast<css::awt::GradientStyle>(m_xLbTrgrGradientType->get_active()), Degree10(static_cast<sal_Int16>(m_xMtrTrgrAngle->get_value(FieldUnit::DEGREE)) * 10), static_cast<sal_uInt16>(m_xMtrTrgrCenterX->get_value(FieldUnit::PERCENT)), @@ -323,9 +317,10 @@ bool SvxTransparenceTabPage::FillItemSet(SfxItemSet* rAttrs) // disable unused XFillFloatTransparenceItem if(bSwitchOffGradient && (bGradActive || bGradUsed)) { - XGradient aGrad(COL_BLACK, COL_WHITE); - aGrad.SetStartIntens(100); - aGrad.SetEndIntens(100); + // basegfx::BGradient() default already creates [COL_BLACK, COL_WHITE] with same defaults + // basegfx::BGradient() default also sets the Start/EndIntensity to 100 already + basegfx::BGradient aGrad; + XFillFloatTransparenceItem aItem(aGrad); aItem.SetEnabled(false); rAttrs->Put(aItem); @@ -347,31 +342,40 @@ bool SvxTransparenceTabPage::FillItemSet(SfxItemSet* rAttrs) void SvxTransparenceTabPage::Reset(const SfxItemSet* rAttrs) { - const SfxPoolItem* pGradientItem = nullptr; - SfxItemState eStateGradient(rAttrs->GetItemState(XATTR_FILLFLOATTRANSPARENCE, true, &pGradientItem)); + const XFillFloatTransparenceItem* pGradientItem = + rAttrs->GetItemIfSet(XATTR_FILLFLOATTRANSPARENCE); + bool bGradActive = (pGradientItem && pGradientItem->IsEnabled()); if(!pGradientItem) pGradientItem = &rAttrs->Get(XATTR_FILLFLOATTRANSPARENCE); - bool bGradActive = (eStateGradient == SfxItemState::SET && static_cast<const XFillFloatTransparenceItem*>(pGradientItem)->IsEnabled()); - const SfxPoolItem* pLinearItem = nullptr; - SfxItemState eStateLinear(rAttrs->GetItemState(XATTR_FILLTRANSPARENCE, true, &pLinearItem)); + const XFillTransparenceItem* pLinearItem = + rAttrs->GetItemIfSet(XATTR_FILLTRANSPARENCE); + bool bLinearActive = (pLinearItem && pLinearItem->GetValue() != 0); if(!pLinearItem) pLinearItem = &rAttrs->Get(XATTR_FILLTRANSPARENCE); - bool bLinearActive = (eStateLinear == SfxItemState::SET && static_cast<const XFillTransparenceItem*>(pLinearItem)->GetValue() != 0); // transparence gradient - const XGradient& rGradient = static_cast<const XFillFloatTransparenceItem*>(pGradientItem)->GetGradientValue(); + const basegfx::BGradient& rGradient = pGradientItem->GetGradientValue(); css::awt::GradientStyle eXGS(rGradient.GetGradientStyle()); m_xLbTrgrGradientType->set_active(sal::static_int_cast< sal_Int32 >(eXGS)); m_xMtrTrgrAngle->set_value(rGradient.GetAngle().get() / 10, FieldUnit::DEGREE); m_xMtrTrgrBorder->set_value(rGradient.GetBorder(), FieldUnit::PERCENT); m_xMtrTrgrCenterX->set_value(rGradient.GetXOffset(), FieldUnit::PERCENT); m_xMtrTrgrCenterY->set_value(rGradient.GetYOffset(), FieldUnit::PERCENT); - m_xMtrTrgrStartValue->set_value(static_cast<sal_uInt16>(((static_cast<sal_uInt16>(rGradient.GetStartColor().GetRed()) + 1) * 100) / 255), FieldUnit::PERCENT); - m_xMtrTrgrEndValue->set_value(static_cast<sal_uInt16>(((static_cast<sal_uInt16>(rGradient.GetEndColor().GetRed()) + 1) * 100) / 255), FieldUnit::PERCENT); + const Color aStart(rGradient.GetColorStops().front().getStopColor()); + const Color aEnd(rGradient.GetColorStops().back().getStopColor()); + m_xMtrTrgrStartValue->set_value(static_cast<sal_uInt16>(((static_cast<sal_uInt16>(aStart.GetRed()) + 1) * 100) / 255), FieldUnit::PERCENT); + m_xMtrTrgrEndValue->set_value(static_cast<sal_uInt16>(((static_cast<sal_uInt16>(aEnd.GetRed()) + 1) * 100) / 255), FieldUnit::PERCENT); + + // MCGR: preserve ColorStops if given + // tdf#155901 We need offset of first and last stop, so include them. + if (rGradient.GetColorStops().size() >= 2) + maColorStops = rGradient.GetColorStops(); + else + maColorStops.clear(); // linear transparence - sal_uInt16 nTransp = static_cast<const XFillTransparenceItem*>(pLinearItem)->GetValue(); + sal_uInt16 nTransp = pLinearItem->GetValue(); m_xMtrTransparent->set_value(bLinearActive ? nTransp : 50, FieldUnit::PERCENT); ModifyTransparentHdl_Impl(*m_xMtrTransparent); @@ -416,7 +420,7 @@ void SvxTransparenceTabPage::ChangesApplied() void SvxTransparenceTabPage::ActivatePage(const SfxItemSet& rSet) { - const CntUInt16Item* pPageTypeItem = rSet.GetItem<CntUInt16Item>(SID_PAGE_TYPE, false); + const CntUInt16Item* pPageTypeItem = rSet.GetItem<SfxUInt16Item>(SID_PAGE_TYPE, false); if (pPageTypeItem) SetPageType(static_cast<PageType>(pPageTypeItem->GetValue())); @@ -505,6 +509,29 @@ void SvxTransparenceTabPage::InvalidatePreview (bool bEnable) } } +basegfx::BColorStops SvxTransparenceTabPage::createColorStops() +{ + basegfx::BColorStops aColorStops; + basegfx::BColor aStartBColor(m_xMtrTrgrStartValue->get_value(FieldUnit::PERCENT) / 100.0); + aStartBColor.clamp(); + basegfx::BColor aEndBColor(m_xMtrTrgrEndValue->get_value(FieldUnit::PERCENT) / 100.0); + aEndBColor.clamp(); + + if(maColorStops.size() >= 2) + { + aColorStops = maColorStops; + aColorStops.front() = basegfx::BColorStop(maColorStops.front().getStopOffset(), aStartBColor); + aColorStops.back() = basegfx::BColorStop(maColorStops.back().getStopOffset(), aEndBColor); + } + else + { + aColorStops.emplace_back(0.0, aStartBColor); + aColorStops.emplace_back(1.0, aEndBColor); + } + + return aColorStops; +} + void SvxTransparenceTabPage::PageCreated(const SfxAllItemSet& aSet) { const SfxUInt16Item* pPageTypeItem = aSet.GetItem<SfxUInt16Item>(SID_PAGE_TYPE, false); diff --git a/cui/source/tabpages/transfrm.cxx b/cui/source/tabpages/transfrm.cxx index f9396cfd6ab4..78294eb5d584 100644 --- a/cui/source/tabpages/transfrm.cxx +++ b/cui/source/tabpages/transfrm.cxx @@ -34,13 +34,14 @@ #include <svtools/unitconv.hxx> #include <transfrm.hxx> -#include <svx/dlgutil.hxx> #include <svx/anchorid.hxx> #include <svl/rectitem.hxx> #include <swpossizetabpage.hxx> #include <vcl/canvastools.hxx> #include <vcl/fieldvalues.hxx> +#include <bitmaps.hlst> + // static ---------------------------------------------------------------- const WhichRangesContainer SvxPositionSizeTabPage::pPosSizeRanges(svl::Items< @@ -93,7 +94,7 @@ SvxTransformTabDialog::SvxTransformTabDialog(weld::Window* pParent, const SfxIte } -void SvxTransformTabDialog::PageCreated(const OString& rId, SfxTabPage &rPage) +void SvxTransformTabDialog::PageCreated(const OUString& rId, SfxTabPage &rPage) { if (rId == "RID_SVXPAGE_POSITION_SIZE") { @@ -207,7 +208,7 @@ void SvxAngleTabPage::Construct() } // take scale into account - const Fraction aUIScale(pView->GetModel()->GetUIScale()); + const Fraction aUIScale(pView->GetModel().GetUIScale()); TransfrmHelper::ScaleRect(maRange, aUIScale); // take UI units into account @@ -227,13 +228,13 @@ bool SvxAngleTabPage::FillItemSet(SfxItemSet* rSet) if (m_xCtlAngle->IsValueModified() || m_xMtrPosX->get_value_changed_from_saved() || m_xMtrPosY->get_value_changed_from_saved()) { - const double fUIScale(double(pView->GetModel()->GetUIScale())); + const double fUIScale(double(pView->GetModel().GetUIScale())); const double fTmpX((GetCoreValue(*m_xMtrPosX, ePoolUnit) + maAnchor.getX()) * fUIScale); const double fTmpY((GetCoreValue(*m_xMtrPosY, ePoolUnit) + maAnchor.getY()) * fUIScale); - rSet->Put(SdrAngleItem(GetWhich(SID_ATTR_TRANSFORM_ANGLE), m_xCtlAngle->GetRotation())); - rSet->Put(SfxInt32Item(GetWhich(SID_ATTR_TRANSFORM_ROT_X), basegfx::fround(fTmpX))); - rSet->Put(SfxInt32Item(GetWhich(SID_ATTR_TRANSFORM_ROT_Y), basegfx::fround(fTmpY))); + rSet->Put(SdrAngleItem(SID_ATTR_TRANSFORM_ANGLE, m_xCtlAngle->GetRotation())); + rSet->Put(SfxInt32Item(SID_ATTR_TRANSFORM_ROT_X, basegfx::fround(fTmpX))); + rSet->Put(SfxInt32Item(SID_ATTR_TRANSFORM_ROT_Y, basegfx::fround(fTmpY))); bModified = true; } @@ -244,7 +245,7 @@ bool SvxAngleTabPage::FillItemSet(SfxItemSet* rSet) void SvxAngleTabPage::Reset(const SfxItemSet* rAttrs) { - const double fUIScale(double(pView->GetModel()->GetUIScale())); + const double fUIScale(double(pView->GetModel().GetUIScale())); const SfxPoolItem* pItem = GetItem( *rAttrs, SID_ATTR_TRANSFORM_ROT_X ); if(pItem) @@ -289,8 +290,7 @@ std::unique_ptr<SfxTabPage> SvxAngleTabPage::Create(weld::Container* pPage, weld void SvxAngleTabPage::ActivatePage(const SfxItemSet& rSet) { - SfxBoolItem const * bPosProtect = nullptr; - if(SfxItemState::SET == rSet.GetItemState( GetWhich(SID_ATTR_TRANSFORM_PROTECT_POS ) , false, reinterpret_cast<SfxPoolItem const **>(&bPosProtect) )) + if(SfxBoolItem const * bPosProtect = rSet.GetItemIfSet( SID_ATTR_TRANSFORM_PROTECT_POS, false )) { m_xFlPosition->set_sensitive(!bPosProtect->GetValue()); m_xFlAngle->set_sensitive(!bPosProtect->GetValue()); @@ -387,11 +387,11 @@ SvxSlantTabPage::SvxSlantTabPage(weld::Container* pPage, weld::DialogController* { for (int i = 0; i < 2; ++i) { - m_aControlGroups[i] = m_xBuilder->weld_widget("controlgroups" + OString::number(i+1)); - m_aControlGroupX[i] = m_xBuilder->weld_widget("controlgroupx" + OString::number(i+1)); - m_aControlX[i] = m_xBuilder->weld_metric_spin_button("controlx" + OString::number(i+1), FieldUnit::CM); - m_aControlGroupY[i] = m_xBuilder->weld_widget("controlgroupy" + OString::number(i+1)); - m_aControlY[i] = m_xBuilder->weld_metric_spin_button("controly" + OString::number(i+1), FieldUnit::CM); + m_aControlGroups[i] = m_xBuilder->weld_widget("controlgroups" + OUString::number(i+1)); + m_aControlGroupX[i] = m_xBuilder->weld_widget("controlgroupx" + OUString::number(i+1)); + m_aControlX[i] = m_xBuilder->weld_metric_spin_button("controlx" + OUString::number(i+1), FieldUnit::CM); + m_aControlGroupY[i] = m_xBuilder->weld_widget("controlgroupy" + OUString::number(i+1)); + m_aControlY[i] = m_xBuilder->weld_metric_spin_button("controly" + OUString::number(i+1), FieldUnit::CM); } // this page needs ExchangeSupport @@ -431,7 +431,7 @@ bool SvxSlantTabPage::FillItemSet(SfxItemSet* rAttrs) if (m_xMtrRadius->get_value_changed_from_saved()) { - Fraction aUIScale = pView->GetModel()->GetUIScale(); + Fraction aUIScale = pView->GetModel().GetUIScale(); tools::Long nTmp = tools::Long(GetCoreValue(*m_xMtrRadius, ePoolUnit) * aUIScale); rAttrs->Put( makeSdrEckenradiusItem( nTmp ) ); @@ -562,7 +562,7 @@ void SvxSlantTabPage::Reset(const SfxItemSet* rAttrs) if( pItem ) { - const double fUIScale(double(pView->GetModel()->GetUIScale())); + const double fUIScale(double(pView->GetModel().GetUIScale())); const double fTmp(static_cast<double>(static_cast<const SdrMetricItem*>(pItem)->GetValue()) / fUIScale); SetMetricValue(*m_xMtrRadius, basegfx::fround(fTmp), ePoolUnit); } @@ -628,7 +628,7 @@ void SvxSlantTabPage::Reset(const SfxItemSet* rAttrs) *pView->GetMarkedObjectList().GetMark(0)->GetMarkedSdrObj())); //save geometry - const bool bOrigModelChangeState = pView->GetModel()->IsChanged(); + const bool bOrigModelChangeState = pView->GetModel().IsChanged(); SdrCustomShapeGeometryItem aInitialGeometry(rSdrObjCustomShape.GetMergedItem(SDRATTR_CUSTOMSHAPE_GEOMETRY)); EnhancedCustomShape2d aShape(rSdrObjCustomShape); @@ -672,7 +672,7 @@ void SvxSlantTabPage::Reset(const SfxItemSet* rAttrs) //restore geometry rSdrObjCustomShape.SetMergedItem(aInitialGeometry); - pView->GetModel()->SetChanged(bOrigModelChangeState); + pView->GetModel().SetChanged(bOrigModelChangeState); } for (int i = 0; i < 2; ++i) @@ -689,13 +689,11 @@ std::unique_ptr<SfxTabPage> SvxSlantTabPage::Create(weld::Container* pPage, weld void SvxSlantTabPage::ActivatePage( const SfxItemSet& rSet ) { - SfxBoolItem const * bPosProtect = nullptr; - if(SfxItemState::SET == rSet.GetItemState( GetWhich(SID_ATTR_TRANSFORM_PROTECT_POS ) , false, reinterpret_cast<SfxPoolItem const **>(&bPosProtect) )) + if(SfxBoolItem const * bPosProtect = rSet.GetItemIfSet( SID_ATTR_TRANSFORM_PROTECT_POS, false )) { m_xFlAngle->set_sensitive(!bPosProtect->GetValue()); } - SfxBoolItem const * bSizeProtect = nullptr; - if(SfxItemState::SET == rSet.GetItemState( GetWhich(SID_ATTR_TRANSFORM_PROTECT_SIZE ) , false, reinterpret_cast<SfxPoolItem const **>(&bSizeProtect) )) + if(SfxBoolItem const * bSizeProtect = rSet.GetItemIfSet( SID_ATTR_TRANSFORM_PROTECT_SIZE, false )) { m_xFlAngle->set_sensitive(!bSizeProtect->GetValue()); } @@ -734,6 +732,8 @@ SvxPositionSizeTabPage::SvxPositionSizeTabPage(weld::Container* pPage, weld::Dia , mfOldHeight(0.0) , m_aCtlPos(this) , m_aCtlSize(this) + , m_aRatioTop(ConnectorType::Top) + , m_aRatioBottom(ConnectorType::Bottom) , m_xFlPosition(m_xBuilder->weld_widget("FL_POSITION")) , m_xMtrPosX(m_xBuilder->weld_metric_spin_button("MTR_FLD_POS_X", FieldUnit::CM)) , m_xMtrPosY(m_xBuilder->weld_metric_spin_button("MTR_FLD_POS_Y", FieldUnit::CM)) @@ -744,6 +744,9 @@ SvxPositionSizeTabPage::SvxPositionSizeTabPage(weld::Container* pPage, weld::Dia , m_xFtHeight(m_xBuilder->weld_label("FT_HEIGHT")) , m_xMtrHeight(m_xBuilder->weld_metric_spin_button("MTR_FLD_HEIGHT", FieldUnit::CM)) , m_xCbxScale(m_xBuilder->weld_check_button("CBX_SCALE")) + , m_xCbxScaleImg(m_xBuilder->weld_image("imRatio")) + , m_xImgRatioTop(new weld::CustomWeld(*m_xBuilder, "daRatioTop", m_aRatioTop)) + , m_xImgRatioBottom(new weld::CustomWeld(*m_xBuilder, "daRatioBottom", m_aRatioBottom)) , m_xCtlSize(new weld::CustomWeld(*m_xBuilder, "CTL_SIZERECT", m_aCtlSize)) , m_xFlProtect(m_xBuilder->weld_widget("FL_PROTECT")) , m_xTsbPosProtect(m_xBuilder->weld_check_button("TSB_POSPROTECT")) @@ -764,9 +767,19 @@ SvxPositionSizeTabPage::SvxPositionSizeTabPage(weld::Container* pPage, weld::Dia m_aCtlSize.SetActualRP(RectPoint::LT); meRP = RectPoint::LT; // see above - m_xMtrWidth->connect_value_changed( LINK( this, SvxPositionSizeTabPage, ChangeWidthHdl ) ); - m_xMtrHeight->connect_value_changed( LINK( this, SvxPositionSizeTabPage, ChangeHeightHdl ) ); - m_xCbxScale->connect_toggled( LINK( this, SvxPositionSizeTabPage, ClickAutoHdl ) ); + m_xMtrWidth->connect_value_changed(LINK(this, SvxPositionSizeTabPage, ChangeWidthHdl)); + m_xMtrHeight->connect_value_changed(LINK(this, SvxPositionSizeTabPage, ChangeHeightHdl)); + + m_xCbxScale->connect_toggled(LINK(this, SvxPositionSizeTabPage, ClickAutoHdl)); + // vertical alignment = fill makes the drawingarea expand the associated spinedits so we have to size it here + const sal_Int16 aHeight + = static_cast<sal_Int16>(std::max(int(m_xCbxScale->get_preferred_size().getHeight() / 2 + - m_xFtWidth->get_preferred_size().getHeight() / 2), + 12)); + const sal_Int16 aWidth + = static_cast<sal_Int16>(m_xCbxScale->get_preferred_size().getWidth() / 2); + m_xImgRatioTop->set_size_request(aWidth, aHeight); + m_xImgRatioBottom->set_size_request(aWidth, aHeight); m_xFlAdjust->set_sensitive(false); @@ -846,7 +859,7 @@ void SvxPositionSizeTabPage::Construct() const SdrObjKind eKind(pObj->GetObjIdentifier()); if((pObj->GetObjInventor() == SdrInventor::Default) && - (OBJ_TEXT == eKind || OBJ_TITLETEXT == eKind || OBJ_OUTLINETEXT == eKind) && + (SdrObjKind::Text == eKind || SdrObjKind::TitleText == eKind || SdrObjKind::OutlineText == eKind) && pObj->HasText()) { mbAdjustDisabled = false; @@ -856,14 +869,14 @@ void SvxPositionSizeTabPage::Construct() m_xTsbAutoGrowWidth->connect_toggled( LINK( this, SvxPositionSizeTabPage, ClickSizeProtectHdl ) ); m_xTsbAutoGrowHeight->connect_toggled( LINK( this, SvxPositionSizeTabPage, ClickSizeProtectHdl ) ); - // is used as flag to evaluate if its selectable + // is used as flag to evaluate if it's selectable mbIgnoreAutoGrowWidth = false; mbIgnoreAutoGrowHeight = false; } } // take scale into account - const Fraction aUIScale(mpView->GetModel()->GetUIScale()); + const Fraction aUIScale(mpView->GetModel().GetUIScale()); TransfrmHelper::ScaleRect( maWorkRange, aUIScale ); TransfrmHelper::ScaleRect( maRange, aUIScale ); @@ -894,7 +907,7 @@ bool SvxPositionSizeTabPage::FillItemSet( SfxItemSet* rOutAttrs ) { if (m_xMtrPosX->get_value_changed_from_saved() || m_xMtrPosY->get_value_changed_from_saved()) { - const double fUIScale(double(mpView->GetModel()->GetUIScale())); + const double fUIScale(double(mpView->GetModel().GetUIScale())); double fX((GetCoreValue( *m_xMtrPosX, mePoolUnit ) + maAnchor.getX()) * fUIScale); double fY((GetCoreValue( *m_xMtrPosY, mePoolUnit ) + maAnchor.getY()) * fUIScale); @@ -907,8 +920,8 @@ bool SvxPositionSizeTabPage::FillItemSet( SfxItemSet* rOutAttrs ) // #101581# GetTopLeftPosition(...) needs coordinates after UI scaling, in real PagePositions GetTopLeftPosition(fX, fY, maRange); - rOutAttrs->Put(SfxInt32Item(GetWhich(SID_ATTR_TRANSFORM_POS_X), basegfx::fround(fX))); - rOutAttrs->Put(SfxInt32Item(GetWhich(SID_ATTR_TRANSFORM_POS_Y), basegfx::fround(fY))); + rOutAttrs->Put(SfxInt32Item(SID_ATTR_TRANSFORM_POS_X, basegfx::fround(fX))); + rOutAttrs->Put(SfxInt32Item(SID_ATTR_TRANSFORM_POS_Y, basegfx::fround(fY))); bModified = true; } @@ -922,7 +935,7 @@ bool SvxPositionSizeTabPage::FillItemSet( SfxItemSet* rOutAttrs ) else { rOutAttrs->Put( - SfxBoolItem( GetWhich( SID_ATTR_TRANSFORM_PROTECT_POS ), + SfxBoolItem( SID_ATTR_TRANSFORM_PROTECT_POS, m_xTsbPosProtect->get_active() ) ); } @@ -932,7 +945,7 @@ bool SvxPositionSizeTabPage::FillItemSet( SfxItemSet* rOutAttrs ) if (m_xMtrWidth->get_value_changed_from_saved() || m_xMtrHeight->get_value_changed_from_saved()) { - Fraction aUIScale = mpView->GetModel()->GetUIScale(); + Fraction aUIScale = mpView->GetModel().GetUIScale(); // get Width double nWidth = static_cast<double>(m_xMtrWidth->get_value(FieldUnit::MM_100TH)); @@ -947,9 +960,9 @@ bool SvxPositionSizeTabPage::FillItemSet( SfxItemSet* rOutAttrs ) lHeight = static_cast<tools::Long>(m_xMtrHeight->denormalize( lHeight )); // put Width & Height to itemset - rOutAttrs->Put( SfxUInt32Item( GetWhich( SID_ATTR_TRANSFORM_WIDTH ), static_cast<sal_uInt32>(lWidth) ) ); - rOutAttrs->Put( SfxUInt32Item( GetWhich( SID_ATTR_TRANSFORM_HEIGHT ), static_cast<sal_uInt32>(lHeight) ) ); - rOutAttrs->Put( SfxUInt16Item( GetWhich( SID_ATTR_TRANSFORM_SIZE_POINT ), sal::static_int_cast< sal_uInt16 >( meRP ) ) ); + rOutAttrs->Put( SfxUInt32Item( SID_ATTR_TRANSFORM_WIDTH, static_cast<sal_uInt32>(lWidth) ) ); + rOutAttrs->Put( SfxUInt32Item( SID_ATTR_TRANSFORM_HEIGHT, static_cast<sal_uInt32>(lHeight) ) ); + rOutAttrs->Put( SfxUInt16Item( SID_ATTR_TRANSFORM_SIZE_POINT, sal::static_int_cast< sal_uInt16 >( meRP ) ) ); bModified = true; } @@ -959,7 +972,7 @@ bool SvxPositionSizeTabPage::FillItemSet( SfxItemSet* rOutAttrs ) rOutAttrs->InvalidateItem( SID_ATTR_TRANSFORM_PROTECT_SIZE ); else rOutAttrs->Put( - SfxBoolItem( GetWhich( SID_ATTR_TRANSFORM_PROTECT_SIZE ), + SfxBoolItem( SID_ATTR_TRANSFORM_PROTECT_SIZE, m_xTsbSizeProtect->get_active() ) ); bModified = true; } @@ -972,7 +985,7 @@ bool SvxPositionSizeTabPage::FillItemSet( SfxItemSet* rOutAttrs ) rOutAttrs->InvalidateItem( SID_ATTR_TRANSFORM_AUTOWIDTH ); else rOutAttrs->Put( - SfxBoolItem( GetWhich( SID_ATTR_TRANSFORM_AUTOWIDTH ), + SfxBoolItem( SID_ATTR_TRANSFORM_AUTOWIDTH, m_xTsbAutoGrowWidth->get_active() ) ); } bModified = true; @@ -989,7 +1002,7 @@ bool SvxPositionSizeTabPage::FillItemSet( SfxItemSet* rOutAttrs ) else { rOutAttrs->Put( - SfxBoolItem( GetWhich( SID_ATTR_TRANSFORM_AUTOHEIGHT ), + SfxBoolItem( SID_ATTR_TRANSFORM_AUTOHEIGHT, m_xTsbAutoGrowHeight->get_active() ) ); } } @@ -1002,7 +1015,7 @@ bool SvxPositionSizeTabPage::FillItemSet( SfxItemSet* rOutAttrs ) void SvxPositionSizeTabPage::Reset( const SfxItemSet* ) { const SfxPoolItem* pItem; - const double fUIScale(double(mpView->GetModel()->GetUIScale())); + const double fUIScale(double(mpView->GetModel().GetUIScale())); if ( !mbPageDisabled ) { @@ -1044,7 +1057,7 @@ void SvxPositionSizeTabPage::Reset( const SfxItemSet* ) double fTmpWidth((OutputDevice::LogicToLogic(static_cast<sal_Int32>(mfOldWidth), mePoolUnit, MapUnit::Map100thMM)) / fUIScale); if (m_xMtrWidth->get_digits()) fTmpWidth *= pow(10.0, m_xMtrWidth->get_digits()); - m_xMtrWidth->set_value(static_cast<int>(fTmpWidth), FieldUnit::MM_100TH); + m_xMtrWidth->set_value(fTmpWidth, FieldUnit::MM_100TH); } { // #i75273# set height @@ -1053,7 +1066,7 @@ void SvxPositionSizeTabPage::Reset( const SfxItemSet* ) double fTmpHeight((OutputDevice::LogicToLogic(static_cast<sal_Int32>(mfOldHeight), mePoolUnit, MapUnit::Map100thMM)) / fUIScale); if (m_xMtrHeight->get_digits()) fTmpHeight *= pow(10.0, m_xMtrHeight->get_digits()); - m_xMtrHeight->set_value(static_cast<int>(fTmpHeight), FieldUnit::MM_100TH); + m_xMtrHeight->set_value(fTmpHeight, FieldUnit::MM_100TH); } pItem = GetItem( mrOutAttrs, SID_ATTR_TRANSFORM_PROTECT_SIZE ); @@ -1083,6 +1096,7 @@ void SvxPositionSizeTabPage::Reset( const SfxItemSet* ) // Is matching set? OUString aStr = GetUserData(); m_xCbxScale->set_active(aStr.toInt32() != 0); + m_xCbxScaleImg->set_from_icon_name(m_xCbxScale->get_active() ? RID_SVXBMP_LOCKED : RID_SVXBMP_UNLOCKED); m_xMtrPosX->save_value(); m_xMtrPosY->save_value(); @@ -1105,9 +1119,7 @@ std::unique_ptr<SfxTabPage> SvxPositionSizeTabPage::Create(weld::Container* pPag void SvxPositionSizeTabPage::ActivatePage( const SfxItemSet& rSet ) { - SfxRectangleItem const * pRectItem = nullptr; - - if( SfxItemState::SET == rSet.GetItemState( GetWhich( SID_ATTR_TRANSFORM_INTERN ) , false, reinterpret_cast<SfxPoolItem const **>(&pRectItem) ) ) + if( SfxRectangleItem const * pRectItem = rSet.GetItemIfSet( SID_ATTR_TRANSFORM_INTERN, false ) ) { { // #i75273# const ::tools::Rectangle aTempRect(pRectItem->GetValue()); @@ -1128,12 +1140,12 @@ DeactivateRC SvxPositionSizeTabPage::DeactivatePage( SfxItemSet* _pSet ) GetTopLeftPosition(fX, fY, maRange); const ::tools::Rectangle aOutRectangle( - basegfx::fround(fX), basegfx::fround(fY), - basegfx::fround(fX + maRange.getWidth()), basegfx::fround(fY + maRange.getHeight())); + basegfx::fround<tools::Long>(fX), basegfx::fround<tools::Long>(fY), + basegfx::fround<tools::Long>(fX + maRange.getWidth()), basegfx::fround<tools::Long>(fY + maRange.getHeight())); _pSet->Put(SfxRectangleItem(SID_ATTR_TRANSFORM_INTERN, aOutRectangle)); - _pSet->Put(SfxBoolItem( GetWhich( SID_ATTR_TRANSFORM_PROTECT_POS ), + _pSet->Put(SfxBoolItem( SID_ATTR_TRANSFORM_PROTECT_POS, m_xTsbPosProtect->get_state() == TRISTATE_TRUE )); - _pSet->Put(SfxBoolItem( GetWhich( SID_ATTR_TRANSFORM_PROTECT_SIZE ), + _pSet->Put(SfxBoolItem( SID_ATTR_TRANSFORM_PROTECT_SIZE, m_xTsbSizeProtect->get_state() == TRISTATE_TRUE )); FillItemSet(_pSet); } @@ -1271,7 +1283,7 @@ void SvxPositionSizeTabPage::SetMinMaxPosition() } } - const double fMaxLong(static_cast<double>(vcl::ConvertValue( LONG_MAX, 0, MapUnit::Map100thMM, meDlgUnit ) - 1)); + const double fMaxLong(vcl::ConvertValue(std::numeric_limits<sal_Int64>::max(), 0, MapUnit::Map100thMM, meDlgUnit) - 1); fLeft = std::clamp(fLeft, -fMaxLong, fMaxLong); fRight = std::clamp(fRight, -fMaxLong, fMaxLong); fTop = std::clamp(fTop, - fMaxLong, fMaxLong); @@ -1503,7 +1515,7 @@ IMPL_LINK_NOARG(SvxPositionSizeTabPage, ChangeWidthHdl, weld::MetricSpinButton&, return; sal_Int64 nHeight(basegfx::fround64((mfOldHeight * static_cast<double>(m_xMtrWidth->get_value(FieldUnit::NONE))) / mfOldWidth)); - int nMin, nMax; + sal_Int64 nMin, nMax; m_xMtrHeight->get_range(nMin, nMax, FieldUnit::NONE); if (nHeight <= nMax) @@ -1526,7 +1538,7 @@ IMPL_LINK_NOARG(SvxPositionSizeTabPage, ChangeHeightHdl, weld::MetricSpinButton& return; sal_Int64 nWidth(basegfx::fround64((mfOldWidth * static_cast<double>(m_xMtrHeight->get_value(FieldUnit::NONE))) / mfOldHeight)); - int nMin, nMax; + sal_Int64 nMin, nMax; m_xMtrWidth->get_range(nMin, nMax, FieldUnit::NONE); if (nWidth <= nMax) @@ -1550,6 +1562,7 @@ IMPL_LINK_NOARG(SvxPositionSizeTabPage, ClickSizeProtectHdl, weld::Toggleable&, IMPL_LINK_NOARG(SvxPositionSizeTabPage, ClickAutoHdl, weld::Toggleable&, void) { + m_xCbxScaleImg->set_from_icon_name(m_xCbxScale->get_active() ? RID_SVXBMP_LOCKED : RID_SVXBMP_UNLOCKED); if (m_xCbxScale->get_active()) { mfOldWidth = std::max( static_cast<double>(GetCoreValue( *m_xMtrWidth, mePoolUnit )), 1.0 ); |