summaryrefslogtreecommitdiff
path: root/cui/source/dialogs
diff options
context:
space:
mode:
Diffstat (limited to 'cui/source/dialogs')
-rw-r--r--cui/source/dialogs/AdditionsDialog.cxx104
-rw-r--r--cui/source/dialogs/DiagramDialog.cxx95
-rw-r--r--cui/source/dialogs/FontFeaturesDialog.cxx95
-rw-r--r--cui/source/dialogs/GraphicTestsDialog.cxx31
-rw-r--r--cui/source/dialogs/QrCodeGenDialog.cxx65
-rw-r--r--cui/source/dialogs/SignSignatureLineDialog.cxx15
-rw-r--r--cui/source/dialogs/SignatureLineDialogBase.cxx8
-rw-r--r--cui/source/dialogs/SpellAttrib.hxx13
-rw-r--r--cui/source/dialogs/SpellDialog.cxx214
-rw-r--r--cui/source/dialogs/about.cxx90
-rw-r--r--cui/source/dialogs/colorpicker.cxx119
-rw-r--r--cui/source/dialogs/cuicharmap.cxx1277
-rw-r--r--cui/source/dialogs/cuifmsearch.cxx18
-rw-r--r--cui/source/dialogs/cuigaldlg.cxx40
-rw-r--r--cui/source/dialogs/cuigrfflt.cxx30
-rw-r--r--cui/source/dialogs/cuihyperdlg.cxx44
-rw-r--r--cui/source/dialogs/dlgname.cxx187
-rw-r--r--cui/source/dialogs/hangulhanjadlg.cxx10
-rw-r--r--cui/source/dialogs/hldocntp.cxx52
-rw-r--r--cui/source/dialogs/hldoctp.cxx4
-rw-r--r--cui/source/dialogs/hlinettp.cxx153
-rw-r--r--cui/source/dialogs/hlmailtp.cxx14
-rw-r--r--cui/source/dialogs/hlmarkwn.cxx51
-rw-r--r--cui/source/dialogs/hltpbase.cxx87
-rw-r--r--cui/source/dialogs/hyphen.cxx15
-rw-r--r--cui/source/dialogs/iconcdlg.cxx21
-rw-r--r--cui/source/dialogs/insdlg.cxx24
-rw-r--r--cui/source/dialogs/insrc.cxx31
-rw-r--r--cui/source/dialogs/linkdlg.cxx24
-rw-r--r--cui/source/dialogs/multipat.cxx16
-rw-r--r--cui/source/dialogs/passwdomdlg.cxx182
-rw-r--r--cui/source/dialogs/pastedlg.cxx4
-rw-r--r--cui/source/dialogs/postdlg.cxx30
-rw-r--r--cui/source/dialogs/screenshotannotationdlg.cxx21
-rw-r--r--cui/source/dialogs/scriptdlg.cxx142
-rw-r--r--cui/source/dialogs/sdrcelldlg.cxx47
-rw-r--r--cui/source/dialogs/showcols.cxx5
-rw-r--r--cui/source/dialogs/srchxtra.cxx89
-rw-r--r--cui/source/dialogs/thesdlg.cxx16
-rw-r--r--cui/source/dialogs/tipofthedaydlg.cxx75
-rw-r--r--cui/source/dialogs/toolbarmodedlg.cxx26
-rw-r--r--cui/source/dialogs/whatsnew.cxx172
-rw-r--r--cui/source/dialogs/widgettestdlg.cxx57
-rw-r--r--cui/source/dialogs/zoom.cxx22
44 files changed, 1642 insertions, 2193 deletions
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));