summaryrefslogtreecommitdiff
path: root/svx
diff options
context:
space:
mode:
authorCaolán McNamara <caolanm@redhat.com>2020-02-13 17:10:54 +0000
committerCaolán McNamara <caolanm@redhat.com>2020-02-14 09:59:52 +0100
commit1e57442fc9f275828943d316ac4b64f1d29b3f9b (patch)
tree0aeedc49c27da3df473ccaa431482d1b46212636 /svx
parent832a120473ff352cd4e3f2c0486c8718806cb2aa (diff)
weld SearchLabelToolboxController
and split out LabelItemWindow to reuse it Change-Id: Ie14f1bdc6d8684db088c018afd341e10bee9d977 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/88623 Tested-by: Jenkins Reviewed-by: Caolán McNamara <caolanm@redhat.com>
Diffstat (limited to 'svx')
-rw-r--r--svx/inc/pch/precompiled_svx.hxx3
-rw-r--r--svx/source/dialog/srchdlg.cxx13
-rw-r--r--svx/source/form/tbxform.cxx64
-rw-r--r--svx/source/inc/labelitemwindow.hxx29
-rw-r--r--svx/source/tbxctrls/tbunosearchcontrollers.cxx28
5 files changed, 89 insertions, 48 deletions
diff --git a/svx/inc/pch/precompiled_svx.hxx b/svx/inc/pch/precompiled_svx.hxx
index 2fbeb6430aac..3581e2087a00 100644
--- a/svx/inc/pch/precompiled_svx.hxx
+++ b/svx/inc/pch/precompiled_svx.hxx
@@ -13,7 +13,7 @@
manual changes will be rewritten by the next run of update_pch.sh (which presumably
also fixes all possible problems, so it's usually better to use it).
- Generated on 2020-02-13 17:41:02 using:
+ Generated on 2020-02-13 20:23:51 using:
./bin/update_pch svx svx --cutoff=3 --exclude:system --exclude:module --include:local
If after updating build fails, use the following command to locate conflicting headers:
@@ -368,6 +368,7 @@
#include <fmservs.hxx>
#include <fmshimp.hxx>
#include <helpids.h>
+#include <labelitemwindow.hxx>
#include <svx/AccessibleControlShape.hxx>
#include <svx/AccessibleShape.hxx>
#include <svx/AccessibleShapeInfo.hxx>
diff --git a/svx/source/dialog/srchdlg.cxx b/svx/source/dialog/srchdlg.cxx
index 8f9cf9ed0be9..10357d49f944 100644
--- a/svx/source/dialog/srchdlg.cxx
+++ b/svx/source/dialog/srchdlg.cxx
@@ -74,6 +74,7 @@
#include <memory>
#include <findtextfield.hxx>
+#include <labelitemwindow.hxx>
#include <svx/xdef.hxx>
#include <officecfg/Office/Common.hxx>
@@ -2400,13 +2401,13 @@ static void lcl_SetSearchLabelWindow(const OUString& rStr)
sal_uInt16 id = pToolBox->GetItemId(i);
if (pToolBox->GetItemCommand(id) == ".uno:SearchLabel")
{
- vcl::Window* pSearchLabel = pToolBox->GetItemWindow(id);
+ LabelItemWindow* pSearchLabel = dynamic_cast<LabelItemWindow*>(pToolBox->GetItemWindow(id));
assert(pSearchLabel);
- pSearchLabel->SetText(rStr);
+ pSearchLabel->set_label(rStr);
if (rStr.isEmpty())
- pSearchLabel->SetSizePixel(Size(16, pSearchLabel->get_preferred_size().Height()));
+ pSearchLabel->SetSizePixel(Size(16, pSearchLabel->GetSizePixel().Height()));
else
- pSearchLabel->SetSizePixel(pSearchLabel->get_preferred_size());
+ pSearchLabel->SetOptimalSize();
}
if (pToolBox->GetItemCommand(id) == ".uno:FindText")
@@ -2445,8 +2446,8 @@ OUString SvxSearchDialogWrapper::GetSearchLabel()
sal_uInt16 id = pToolBox->GetItemId(i);
if (pToolBox->GetItemCommand(id) == ".uno:SearchLabel")
{
- vcl::Window* pSearchLabel = pToolBox->GetItemWindow(id);
- return pSearchLabel ? pSearchLabel->GetText() : OUString();
+ LabelItemWindow* pSearchLabel = dynamic_cast<LabelItemWindow*>(pToolBox->GetItemWindow(id));
+ return pSearchLabel ? pSearchLabel->get_label() : OUString();
}
}
return OUString();
diff --git a/svx/source/form/tbxform.cxx b/svx/source/form/tbxform.cxx
index 1bd90475e1cb..3d45d19519a1 100644
--- a/svx/source/form/tbxform.cxx
+++ b/svx/source/form/tbxform.cxx
@@ -21,12 +21,12 @@
#include <svl/intitem.hxx>
#include <svl/eitem.hxx>
#include <svl/stritem.hxx>
-#include <sfx2/InterimItemWindow.hxx>
#include <sfx2/dispatch.hxx>
#include <vcl/event.hxx>
#include <vcl/toolbox.hxx>
#include <vcl/settings.hxx>
#include <formtoolbars.hxx>
+#include <labelitemwindow.hxx>
#include <svx/dialmgr.hxx>
#include <svx/svxids.hrc>
@@ -163,41 +163,45 @@ SvxFmTbxCtlRecText::~SvxFmTbxCtlRecText()
{
}
-class LabelItemWindow final : public InterimItemWindow
+LabelItemWindow::LabelItemWindow(vcl::Window *pParent, const OUString& rLabel)
+ : InterimItemWindow(pParent, "svx/ui/labelbox.ui", "LabelBox")
+ , m_xLabel(m_xBuilder->weld_label("label"))
{
-private:
- std::unique_ptr<weld::Label> m_xLabel;
-public:
- LabelItemWindow(vcl::Window *pParent, const OUString& rLabel)
- : InterimItemWindow(pParent, "svx/ui/labelbox.ui", "LabelBox")
- , m_xLabel(m_xBuilder->weld_label("label"))
- {
- m_xLabel->set_label(rLabel);
- Size aSize(m_xLabel->get_preferred_size());
- aSize.AdjustWidth(12);
- m_xLabel->set_size_request(aSize.Width(), -1);
+ m_xLabel->set_label(rLabel);
- SetSizePixel(m_xLabel->get_preferred_size());
+ SetOptimalSize();
- m_xLabel->set_toolbar_background();
- }
+ m_xLabel->set_toolbar_background();
+}
- void set_label(const OUString& rLabel)
- {
- m_xLabel->set_label(rLabel);
- }
+void LabelItemWindow::SetOptimalSize()
+{
+ Size aSize(m_xLabel->get_preferred_size());
+ aSize.AdjustWidth(12);
- virtual void dispose() override
- {
- m_xLabel.reset();
- InterimItemWindow::dispose();
- }
+ SetSizePixel(aSize);
+}
- virtual ~LabelItemWindow() override
- {
- disposeOnce();
- }
-};
+void LabelItemWindow::set_label(const OUString& rLabel)
+{
+ m_xLabel->set_label(rLabel);
+}
+
+OUString LabelItemWindow::get_label() const
+{
+ return m_xLabel->get_label();
+}
+
+void LabelItemWindow::dispose()
+{
+ m_xLabel.reset();
+ InterimItemWindow::dispose();
+}
+
+LabelItemWindow::~LabelItemWindow()
+{
+ disposeOnce();
+}
VclPtr<vcl::Window> SvxFmTbxCtlRecText::CreateItemWindow( vcl::Window* pParent )
{
diff --git a/svx/source/inc/labelitemwindow.hxx b/svx/source/inc/labelitemwindow.hxx
new file mode 100644
index 000000000000..1667cdc4edc6
--- /dev/null
+++ b/svx/source/inc/labelitemwindow.hxx
@@ -0,0 +1,29 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4; fill-column: 100 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ */
+
+#pragma once
+
+#include <sfx2/InterimItemWindow.hxx>
+
+class LabelItemWindow final : public InterimItemWindow
+{
+private:
+ std::unique_ptr<weld::Label> m_xLabel;
+
+public:
+ LabelItemWindow(vcl::Window* pParent, const OUString& rLabel);
+ void set_label(const OUString& rLabel);
+ OUString get_label() const;
+
+ void SetOptimalSize();
+ virtual void dispose() override;
+ virtual ~LabelItemWindow() override;
+};
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab cinoptions=b1,g0,N-s cinkeys+=0=break: */
diff --git a/svx/source/tbxctrls/tbunosearchcontrollers.cxx b/svx/source/tbxctrls/tbunosearchcontrollers.cxx
index 1c620ef7da3e..ec8f23b7f8f0 100644
--- a/svx/source/tbxctrls/tbunosearchcontrollers.cxx
+++ b/svx/source/tbxctrls/tbunosearchcontrollers.cxx
@@ -59,10 +59,9 @@
#include <rtl/instance.hxx>
#include <svx/srchdlg.hxx>
#include <vcl/event.hxx>
-#include <vcl/fixed.hxx>
-#include <vcl/window.hxx>
#include <findtextfield.hxx>
+#include <labelitemwindow.hxx>
using namespace css;
@@ -1300,7 +1299,7 @@ public:
virtual void SAL_CALL statusChanged( const css::frame::FeatureStateEvent& rEvent ) override;
private:
- VclPtr<vcl::Window> m_pSL;
+ VclPtr<LabelItemWindow> m_xSL;
};
SearchLabelToolboxController::SearchLabelToolboxController( const css::uno::Reference< css::uno::XComponentContext > & rxContext )
@@ -1355,7 +1354,7 @@ void SAL_CALL SearchLabelToolboxController::dispose()
SearchToolbarControllersManager::createControllersManager().freeController(m_xFrame, m_aCommandURL);
svt::ToolboxController::dispose();
- m_pSL.disposeAndClear();
+ m_xSL.disposeAndClear();
}
// XInitialization
@@ -1368,20 +1367,27 @@ void SAL_CALL SearchLabelToolboxController::initialize( const css::uno::Sequence
// XStatusListener
void SAL_CALL SearchLabelToolboxController::statusChanged( const css::frame::FeatureStateEvent& )
{
- if (m_pSL)
+ if (m_xSL)
{
OUString aStr = SvxSearchDialogWrapper::GetSearchLabel();
- m_pSL->SetText(aStr);
- long aWidth = !aStr.isEmpty() ? m_pSL->get_preferred_size().getWidth() : 16;
- m_pSL->SetSizePixel(Size(aWidth, m_pSL->get_preferred_size().getHeight()));
+ m_xSL->set_label(aStr);
+ m_xSL->SetOptimalSize();
+ Size aSize(m_xSL->GetSizePixel());
+ long nWidth = !aStr.isEmpty() ? aSize.getWidth() : 16;
+ m_xSL->SetSizePixel(Size(nWidth, aSize.Height()));
}
}
css::uno::Reference< css::awt::XWindow > SAL_CALL SearchLabelToolboxController::createItemWindow( const css::uno::Reference< css::awt::XWindow >& Parent )
{
- m_pSL = VclPtr<FixedText>::Create(VCLUnoHelper::GetWindow( Parent ));
- m_pSL->SetSizePixel(Size(16, 25));
- return VCLUnoHelper::GetInterface(m_pSL);
+ ToolBox* pToolBox = nullptr;
+ sal_uInt16 nId = 0;
+ if (getToolboxId(nId, &pToolBox))
+ pToolBox->SetItemWindowNonInteractive(nId, true);
+
+ m_xSL = VclPtr<LabelItemWindow>::Create(VCLUnoHelper::GetWindow(Parent), "");
+ m_xSL->SetSizePixel(Size(16, m_xSL->GetSizePixel().Height()));
+ return VCLUnoHelper::GetInterface(m_xSL);
}
// protocol handler for "vnd.sun.star.findbar:*" URLs