sw content controls, dropdown: add an initial properties dialog
- read the doc model: show if a content control is a placeholder or not - work with a shared pointer in the dialog, which avoids lifetime issues in case the content control we edit in one view gets deleted in an other view - write the doc model: set the placeholder mode of the content control based on the checkbox state and mark the doc as modified if any widget is touched when pressing OK - handle command state: allow this dialog only inside content controls Change-Id: Ie0b9075ccd3450dd403cc7f8bbf93fc04de3b234 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/134278 Reviewed-by: Miklos Vajna <vmiklos@collabora.com> Tested-by: Jenkins
This commit is contained in:
parent
923c1a79ef
commit
75f7e05703
@ -512,6 +512,14 @@
|
||||
<value>1</value>
|
||||
</prop>
|
||||
</node>
|
||||
<node oor:name=".uno:ContentControlProperties" oor:op="replace">
|
||||
<prop oor:name="Label" oor:type="xs:string">
|
||||
<value xml:lang="en-US">Content Control Properties</value>
|
||||
</prop>
|
||||
<prop oor:name="Properties" oor:type="xs:int">
|
||||
<value>1</value>
|
||||
</prop>
|
||||
</node>
|
||||
<node oor:name=".uno:SetReminder" oor:op="replace">
|
||||
<prop oor:name="Label" oor:type="xs:string">
|
||||
<value xml:lang="en-US">Set Reminder</value>
|
||||
|
@ -139,6 +139,7 @@ $(eval $(call gb_Library_add_exception_objects,swui,\
|
||||
sw/source/ui/index/multmrk \
|
||||
sw/source/ui/index/swuiidxmrk \
|
||||
sw/source/ui/misc/bookmark \
|
||||
sw/source/ui/misc/contentcontroldlg \
|
||||
sw/source/ui/misc/docfnote \
|
||||
sw/source/ui/misc/glosbib \
|
||||
sw/source/ui/misc/glossary \
|
||||
|
@ -118,6 +118,7 @@ $(eval $(call gb_UIConfig_add_uifiles,modules/swriter,\
|
||||
sw/uiconfig/swriter/ui/columndialog \
|
||||
sw/uiconfig/swriter/ui/columnpage \
|
||||
sw/uiconfig/swriter/ui/columnwidth \
|
||||
sw/uiconfig/swriter/ui/contentcontroldlg \
|
||||
sw/uiconfig/swriter/ui/combobox \
|
||||
sw/uiconfig/swriter/ui/comboboxfragment \
|
||||
sw/uiconfig/swriter/ui/conditionpage \
|
||||
|
@ -222,6 +222,7 @@ class SwUINumRuleItem;
|
||||
#define FN_INSERT_OBJECT_DLG (FN_INSERT + 22) /* Object */
|
||||
#define FN_INSERT_PAGEBREAK (FN_INSERT + 23) /* Page break*/
|
||||
#define FN_INSERT_DROPDOWN_CONTENT_CONTROL (FN_INSERT + 24) /* Dropdown content control */
|
||||
#define FN_CONTENT_CONTROL_PROPERTIES (FN_INSERT + 25) /* Content control properties */
|
||||
#define FN_POSTIT (FN_INSERT + 29) /* Insert/edit PostIt */
|
||||
#define FN_INSERT_TABLE (FN_INSERT + 30) /* Insert Table */
|
||||
#define FN_INSERT_STRING (FN_INSERT+31)
|
||||
|
@ -69,8 +69,8 @@ public:
|
||||
*/
|
||||
void NotifyChangeTextNode(SwTextNode* pTextNode);
|
||||
static SwFormatContentControl* CreatePoolDefault(sal_uInt16 nWhich);
|
||||
SwContentControl* GetContentControl() { return m_pContentControl.get(); }
|
||||
const SwContentControl* GetContentControl() const { return m_pContentControl.get(); }
|
||||
std::shared_ptr<SwContentControl> GetContentControl() { return m_pContentControl; }
|
||||
const std::shared_ptr<SwContentControl>& GetContentControl() const { return m_pContentControl; }
|
||||
|
||||
void dumpAsXml(xmlTextWriterPtr pWriter) const override;
|
||||
};
|
||||
|
@ -389,6 +389,7 @@ public:
|
||||
virtual VclPtr<AbstractSwAsciiFilterDlg> CreateSwAsciiFilterDlg(weld::Window* pParent, SwDocShell& rDocSh,
|
||||
SvStream* pStream) = 0;
|
||||
virtual VclPtr<VclAbstractDialog> CreateSwInsertBookmarkDlg(weld::Window *pParent, SwWrtShell &rSh) = 0;
|
||||
virtual VclPtr<VclAbstractDialog> CreateSwContentControlDlg(weld::Window *pParent, SwWrtShell &rSh) = 0;
|
||||
|
||||
virtual std::shared_ptr<AbstractSwBreakDlg> CreateSwBreakDlg(weld::Window *pParent, SwWrtShell &rSh) = 0;
|
||||
virtual VclPtr<VclAbstractDialog> CreateSwChangeDBDlg(SwView& rVw) = 0;
|
||||
|
@ -342,7 +342,7 @@ CPPUNIT_TEST_FIXTURE(SwCoreUnocoreTest, testContentControlInsert)
|
||||
auto pTextContentControl = static_txtattr_cast<SwTextContentControl*>(pAttr);
|
||||
auto& rFormatContentControl
|
||||
= static_cast<SwFormatContentControl&>(pTextContentControl->GetAttr());
|
||||
SwContentControl* pContentControl = rFormatContentControl.GetContentControl();
|
||||
std::shared_ptr<SwContentControl> pContentControl = rFormatContentControl.GetContentControl();
|
||||
CPPUNIT_ASSERT(pContentControl->GetShowingPlaceHolder());
|
||||
}
|
||||
|
||||
@ -459,7 +459,7 @@ CPPUNIT_TEST_FIXTURE(SwCoreUnocoreTest, testContentControlCheckbox)
|
||||
auto pTextContentControl = static_txtattr_cast<SwTextContentControl*>(pAttr);
|
||||
auto& rFormatContentControl
|
||||
= static_cast<SwFormatContentControl&>(pTextContentControl->GetAttr());
|
||||
SwContentControl* pContentControl = rFormatContentControl.GetContentControl();
|
||||
std::shared_ptr<SwContentControl> pContentControl = rFormatContentControl.GetContentControl();
|
||||
CPPUNIT_ASSERT(pContentControl->GetCheckbox());
|
||||
CPPUNIT_ASSERT(pContentControl->GetChecked());
|
||||
CPPUNIT_ASSERT_EQUAL(OUString(u"☒"), pContentControl->GetCheckedState());
|
||||
@ -510,7 +510,7 @@ CPPUNIT_TEST_FIXTURE(SwCoreUnocoreTest, testContentControlDropdown)
|
||||
auto pTextContentControl = static_txtattr_cast<SwTextContentControl*>(pAttr);
|
||||
auto& rFormatContentControl
|
||||
= static_cast<SwFormatContentControl&>(pTextContentControl->GetAttr());
|
||||
SwContentControl* pContentControl = rFormatContentControl.GetContentControl();
|
||||
std::shared_ptr<SwContentControl> pContentControl = rFormatContentControl.GetContentControl();
|
||||
std::vector<SwContentControlListItem> aListItems = pContentControl->GetListItems();
|
||||
CPPUNIT_ASSERT_EQUAL(static_cast<size_t>(3), aListItems.size());
|
||||
CPPUNIT_ASSERT_EQUAL(OUString("red"), aListItems[0].m_aDisplayText);
|
||||
|
@ -160,7 +160,7 @@ CPPUNIT_TEST_FIXTURE(Test, testInsertCheckboxContentControl)
|
||||
auto pTextContentControl = static_txtattr_cast<SwTextContentControl*>(pAttr);
|
||||
auto& rFormatContentControl
|
||||
= static_cast<SwFormatContentControl&>(pTextContentControl->GetAttr());
|
||||
SwContentControl* pContentControl = rFormatContentControl.GetContentControl();
|
||||
std::shared_ptr<SwContentControl> pContentControl = rFormatContentControl.GetContentControl();
|
||||
// Without the accompanying fix in place, this test would have failed, the inserted content
|
||||
// control wasn't a checkbox one.
|
||||
CPPUNIT_ASSERT(pContentControl->GetCheckbox());
|
||||
@ -232,7 +232,7 @@ CPPUNIT_TEST_FIXTURE(Test, testInsertDropdownContentControl)
|
||||
auto pTextContentControl = static_txtattr_cast<SwTextContentControl*>(pAttr);
|
||||
auto& rFormatContentControl
|
||||
= static_cast<SwFormatContentControl&>(pTextContentControl->GetAttr());
|
||||
SwContentControl* pContentControl = rFormatContentControl.GetContentControl();
|
||||
std::shared_ptr<SwContentControl> pContentControl = rFormatContentControl.GetContentControl();
|
||||
// Without the accompanying fix in place, this test would have failed:
|
||||
// - Expected: 1
|
||||
// - Actual : 0
|
||||
|
@ -290,6 +290,12 @@ interface BaseText
|
||||
StateMethod = NoState ;
|
||||
DisableFlags="SfxDisableFlags::SwOnProtectedCursor";
|
||||
]
|
||||
FN_CONTENT_CONTROL_PROPERTIES // status(final|play)
|
||||
[
|
||||
ExecMethod = ExecInsert ;
|
||||
StateMethod = GetState ;
|
||||
DisableFlags="SfxDisableFlags::SwOnProtectedCursor";
|
||||
]
|
||||
FN_INSERT_COLUMN_BREAK // status(final|play)
|
||||
[
|
||||
ExecMethod = ExecInsert ;
|
||||
|
@ -3083,6 +3083,23 @@ SfxVoidItem InsertDropdownContentControl FN_INSERT_DROPDOWN_CONTENT_CONTROL
|
||||
GroupId = SfxGroupId::Insert;
|
||||
]
|
||||
|
||||
SfxVoidItem ContentControlProperties FN_CONTENT_CONTROL_PROPERTIES
|
||||
()
|
||||
[
|
||||
AutoUpdate = FALSE,
|
||||
FastCall = FALSE,
|
||||
ReadOnlyDoc = FALSE,
|
||||
Toggle = FALSE,
|
||||
Container = FALSE,
|
||||
RecordAbsolute = FALSE,
|
||||
RecordPerSet;
|
||||
|
||||
AccelConfig = TRUE,
|
||||
MenuConfig = TRUE,
|
||||
ToolBoxConfig = TRUE,
|
||||
GroupId = SfxGroupId::Insert;
|
||||
]
|
||||
|
||||
SfxVoidItem InsertMultiIndex FN_INSERT_MULTI_TOX
|
||||
()
|
||||
[
|
||||
|
@ -14,10 +14,10 @@
|
||||
|
||||
#include <edtwin.hxx>
|
||||
|
||||
SwContentControlButton::SwContentControlButton(SwEditWin* pEditWin,
|
||||
const SwContentControl& rContentControl)
|
||||
SwContentControlButton::SwContentControlButton(
|
||||
SwEditWin* pEditWin, const std::shared_ptr<SwContentControl>& pContentControl)
|
||||
: Control(pEditWin, WB_DIALOGCONTROL)
|
||||
, m_rContentControl(rContentControl)
|
||||
, m_pContentControl(pContentControl)
|
||||
{
|
||||
assert(GetParent());
|
||||
assert(dynamic_cast<SwEditWin*>(GetParent()));
|
||||
|
@ -856,7 +856,7 @@ bool SwCursorShell::GotoFootnoteAnchor(const SwTextFootnote& rTextFootnote)
|
||||
bool SwCursorShell::GotoFormatContentControl(const SwFormatContentControl& rContentControl)
|
||||
{
|
||||
bool bRet = false;
|
||||
auto pContentControl = const_cast<SwContentControl*>(rContentControl.GetContentControl());
|
||||
std::shared_ptr<SwContentControl> pContentControl = rContentControl.GetContentControl();
|
||||
if (!pContentControl->GetShowingPlaceHolder() && !pContentControl->GetCheckbox()
|
||||
&& !pContentControl->GetSelectedListItem())
|
||||
{
|
||||
|
@ -21,7 +21,7 @@
|
||||
|
||||
void SwDropDownContentControlButton::InitDropdown()
|
||||
{
|
||||
std::vector<SwContentControlListItem> aListItems = m_rContentControl.GetListItems();
|
||||
std::vector<SwContentControlListItem> aListItems = m_pContentControl->GetListItems();
|
||||
|
||||
for (const auto& rListItem : aListItems)
|
||||
{
|
||||
@ -60,17 +60,16 @@ IMPL_LINK(SwDropDownContentControlButton, ListBoxHandler, weld::TreeView&, rBox,
|
||||
{
|
||||
SwView& rView = static_cast<SwEditWin*>(GetParent())->GetView();
|
||||
SwWrtShell& rWrtShell = rView.GetWrtShell();
|
||||
auto& rContentControl = const_cast<SwContentControl&>(m_rContentControl);
|
||||
rContentControl.SetSelectedListItem(nSelection);
|
||||
rWrtShell.GotoContentControl(*m_rContentControl.GetFormatContentControl());
|
||||
m_pContentControl->SetSelectedListItem(nSelection);
|
||||
rWrtShell.GotoContentControl(*m_pContentControl->GetFormatContentControl());
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
SwDropDownContentControlButton::SwDropDownContentControlButton(
|
||||
SwEditWin* pEditWin, const SwContentControl& rContentControl)
|
||||
: SwContentControlButton(pEditWin, rContentControl)
|
||||
SwEditWin* pEditWin, const std::shared_ptr<SwContentControl>& pContentControl)
|
||||
: SwContentControlButton(pEditWin, pContentControl)
|
||||
{
|
||||
}
|
||||
|
||||
|
@ -640,7 +640,7 @@ void SwSelPaintRects::HighlightContentControl()
|
||||
std::vector<basegfx::B2DRange> aContentControlRanges;
|
||||
std::vector<OString> aLOKRectangles;
|
||||
SwRect aLastPortionPaintArea;
|
||||
const SwContentControl* pContentControl = nullptr;
|
||||
std::shared_ptr<SwContentControl> pContentControl;
|
||||
|
||||
if (m_bShowContentControlOverlay)
|
||||
{
|
||||
@ -740,14 +740,14 @@ void SwSelPaintRects::HighlightContentControl()
|
||||
{
|
||||
auto& rEditWin = const_cast<SwEditWin&>(pWrtShell->GetView().GetEditWin());
|
||||
if (m_pContentControlButton
|
||||
&& &m_pContentControlButton->GetContentControl() != pContentControl)
|
||||
&& m_pContentControlButton->GetContentControl() != pContentControl)
|
||||
{
|
||||
m_pContentControlButton.disposeAndClear();
|
||||
}
|
||||
if (!m_pContentControlButton)
|
||||
{
|
||||
m_pContentControlButton = VclPtr<SwDropDownContentControlButton>::Create(
|
||||
&rEditWin, *pContentControl);
|
||||
&rEditWin, pContentControl);
|
||||
}
|
||||
m_pContentControlButton->CalcPosAndSize(aLastPortionPaintArea);
|
||||
m_pContentControlButton->Show();
|
||||
|
@ -20,7 +20,8 @@ class SwContentControl;
|
||||
class SwContentControlButton : public Control
|
||||
{
|
||||
public:
|
||||
SwContentControlButton(SwEditWin* pEditWin, const SwContentControl& rContentControl);
|
||||
SwContentControlButton(SwEditWin* pEditWin,
|
||||
const std::shared_ptr<SwContentControl>& pContentControl);
|
||||
virtual ~SwContentControlButton() override;
|
||||
virtual void dispose() override;
|
||||
|
||||
@ -35,13 +36,13 @@ public:
|
||||
virtual void LaunchPopup();
|
||||
virtual void DestroyPopup();
|
||||
|
||||
const SwContentControl& GetContentControl() const { return m_rContentControl; }
|
||||
const std::shared_ptr<SwContentControl>& GetContentControl() const { return m_pContentControl; }
|
||||
|
||||
private:
|
||||
tools::Rectangle m_aFramePixel;
|
||||
|
||||
protected:
|
||||
const SwContentControl& m_rContentControl;
|
||||
std::shared_ptr<SwContentControl> m_pContentControl;
|
||||
std::unique_ptr<weld::Builder> m_xPopupBuilder;
|
||||
std::unique_ptr<weld::Popover> m_xPopup;
|
||||
};
|
||||
|
@ -28,7 +28,8 @@ private:
|
||||
void InitDropdown();
|
||||
|
||||
public:
|
||||
SwDropDownContentControlButton(SwEditWin* pEditWin, const SwContentControl& rContentControl);
|
||||
SwDropDownContentControlButton(SwEditWin* pEditWin,
|
||||
const std::shared_ptr<SwContentControl>& pContentControl);
|
||||
virtual ~SwDropDownContentControlButton() override;
|
||||
|
||||
virtual void LaunchPopup() override;
|
||||
|
@ -787,7 +787,7 @@ private:
|
||||
rtl::Reference<sax_fastparser::FastAttributeList> m_pSectionSpacingAttrList;
|
||||
rtl::Reference<sax_fastparser::FastAttributeList> m_pParagraphSpacingAttrList;
|
||||
rtl::Reference<sax_fastparser::FastAttributeList> m_pHyperlinkAttrList;
|
||||
const SwContentControl* m_pContentControl = nullptr;
|
||||
std::shared_ptr<SwContentControl> m_pContentControl;
|
||||
/// If the current SDT around runs should be ended before the current run.
|
||||
bool m_bEndCharSdt;
|
||||
/// Attributes of the run color
|
||||
|
@ -33,6 +33,7 @@
|
||||
#include <changedb.hxx>
|
||||
#include <chrdlg.hxx>
|
||||
#include <colwd.hxx>
|
||||
#include <contentcontroldlg.hxx>
|
||||
#include <convert.hxx>
|
||||
#include <cption.hxx>
|
||||
#include <dbinsdlg.hxx>
|
||||
@ -834,6 +835,12 @@ VclPtr<VclAbstractDialog> SwAbstractDialogFactory_Impl::CreateSwInsertBookmarkDl
|
||||
return VclPtr<AbstractGenericDialog_Impl>::Create(std::make_shared<SwInsertBookmarkDlg>(pParent, rSh));
|
||||
}
|
||||
|
||||
VclPtr<VclAbstractDialog> SwAbstractDialogFactory_Impl::CreateSwContentControlDlg(weld::Window* pParent,
|
||||
SwWrtShell &rSh)
|
||||
{
|
||||
return VclPtr<AbstractGenericDialog_Impl>::Create(std::make_shared<SwContentControlDlg>(pParent, rSh));
|
||||
}
|
||||
|
||||
std::shared_ptr<AbstractSwBreakDlg> SwAbstractDialogFactory_Impl::CreateSwBreakDlg(weld::Window* pParent, SwWrtShell &rSh)
|
||||
{
|
||||
return std::make_shared<AbstractSwBreakDlg_Impl>(std::make_unique<SwBreakDlg>(pParent, rSh));
|
||||
|
@ -658,6 +658,7 @@ public:
|
||||
virtual VclPtr<AbstractSwAsciiFilterDlg> CreateSwAsciiFilterDlg(weld::Window* pParent, SwDocShell& rDocSh,
|
||||
SvStream* pStream) override;
|
||||
virtual VclPtr<VclAbstractDialog> CreateSwInsertBookmarkDlg(weld::Window *pParent, SwWrtShell &rSh) override;
|
||||
virtual VclPtr<VclAbstractDialog> CreateSwContentControlDlg(weld::Window *pParent, SwWrtShell &rSh) override;
|
||||
virtual std::shared_ptr<AbstractSwBreakDlg> CreateSwBreakDlg(weld::Window *pParent, SwWrtShell &rSh) override;
|
||||
virtual VclPtr<VclAbstractDialog> CreateSwChangeDBDlg(SwView& rVw) override;
|
||||
virtual VclPtr<SfxAbstractTabDialog> CreateSwCharDlg(weld::Window* pParent, SwView& pVw, const SfxItemSet& rCoreSet,
|
||||
|
84
sw/source/ui/misc/contentcontroldlg.cxx
Normal file
84
sw/source/ui/misc/contentcontroldlg.cxx
Normal file
@ -0,0 +1,84 @@
|
||||
/* -*- 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 <contentcontroldlg.hxx>
|
||||
|
||||
#include <vcl/weld.hxx>
|
||||
|
||||
#include <wrtsh.hxx>
|
||||
#include <ndtxt.hxx>
|
||||
#include <textcontentcontrol.hxx>
|
||||
#include <IDocumentState.hxx>
|
||||
|
||||
using namespace com::sun::star;
|
||||
|
||||
SwContentControlDlg::SwContentControlDlg(weld::Window* pParent, SwWrtShell& rWrtShell)
|
||||
: SfxDialogController(pParent, "modules/swriter/ui/contentcontroldlg.ui",
|
||||
"ContentControlDialog")
|
||||
, m_rWrtShell(rWrtShell)
|
||||
, m_xShowingPlaceHolderCB(m_xBuilder->weld_check_button("showing_place_holder"))
|
||||
, m_xOk(m_xBuilder->weld_button("ok"))
|
||||
{
|
||||
m_xOk->connect_clicked(LINK(this, SwContentControlDlg, OkHdl));
|
||||
|
||||
const SwPosition* pStart = rWrtShell.GetCursor()->Start();
|
||||
SwTextNode* pTextNode = pStart->nNode.GetNode().GetTextNode();
|
||||
if (!pTextNode)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
SwTextAttr* pAttr = pTextNode->GetTextAttrAt(pStart->nContent.GetIndex(),
|
||||
RES_TXTATR_CONTENTCONTROL, SwTextNode::PARENT);
|
||||
if (!pAttr)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
SwTextContentControl* pTextContentControl = static_txtattr_cast<SwTextContentControl*>(pAttr);
|
||||
const SwFormatContentControl& rFormatContentControl = pTextContentControl->GetContentControl();
|
||||
m_pContentControl = rFormatContentControl.GetContentControl();
|
||||
|
||||
bool bShowingPlaceHolder = m_pContentControl->GetShowingPlaceHolder();
|
||||
TriState eShowingPlaceHolder = bShowingPlaceHolder ? TRISTATE_TRUE : TRISTATE_FALSE;
|
||||
m_xShowingPlaceHolderCB->set_state(eShowingPlaceHolder);
|
||||
m_xShowingPlaceHolderCB->save_state();
|
||||
}
|
||||
|
||||
SwContentControlDlg::~SwContentControlDlg() {}
|
||||
|
||||
IMPL_LINK_NOARG(SwContentControlDlg, OkHdl, weld::Button&, void)
|
||||
{
|
||||
bool bChanged = false;
|
||||
if (m_xShowingPlaceHolderCB->get_state_changed_from_saved())
|
||||
{
|
||||
bool bShowingPlaceHolder = m_xShowingPlaceHolderCB->get_state() == TRISTATE_TRUE;
|
||||
m_pContentControl->SetShowingPlaceHolder(bShowingPlaceHolder);
|
||||
bChanged = true;
|
||||
}
|
||||
|
||||
if (bChanged)
|
||||
{
|
||||
m_rWrtShell.GetDoc()->getIDocumentState().SetModified();
|
||||
}
|
||||
|
||||
m_xDialog->response(RET_OK);
|
||||
}
|
||||
|
||||
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|
46
sw/source/uibase/inc/contentcontroldlg.hxx
Normal file
46
sw/source/uibase/inc/contentcontroldlg.hxx
Normal file
@ -0,0 +1,46 @@
|
||||
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
|
||||
/*
|
||||
* This file is part of the LibreOffice project.
|
||||
*
|
||||
* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
||||
*
|
||||
* This file incorporates work covered by the following license notice:
|
||||
*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one or more
|
||||
* contributor license agreements. See the NOTICE file distributed
|
||||
* with this work for additional information regarding copyright
|
||||
* ownership. The ASF licenses this file to you under the Apache
|
||||
* License, Version 2.0 (the "License"); you may not use this file
|
||||
* except in compliance with the License. You may obtain a copy of
|
||||
* the License at http://www.apache.org/licenses/LICENSE-2.0 .
|
||||
*/
|
||||
#pragma once
|
||||
|
||||
#include <sfx2/basedlgs.hxx>
|
||||
#include <vcl/weld.hxx>
|
||||
|
||||
class SwWrtShell;
|
||||
class SwContentControl;
|
||||
|
||||
/**
|
||||
* The content control dialog allows editing the properties of the content control under the
|
||||
* cursor.
|
||||
*/
|
||||
class SwContentControlDlg final : public SfxDialogController
|
||||
{
|
||||
SwWrtShell& m_rWrtShell;
|
||||
std::shared_ptr<SwContentControl> m_pContentControl;
|
||||
|
||||
std::unique_ptr<weld::CheckButton> m_xShowingPlaceHolderCB;
|
||||
std::unique_ptr<weld::Button> m_xOk;
|
||||
|
||||
DECL_LINK(OkHdl, weld::Button&, void);
|
||||
|
||||
public:
|
||||
SwContentControlDlg(weld::Window* pParent, SwWrtShell& rSh);
|
||||
virtual ~SwContentControlDlg() override;
|
||||
};
|
||||
|
||||
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|
@ -234,6 +234,18 @@ void SwTextShell::ExecInsert(SfxRequest &rReq)
|
||||
rReq.Done();
|
||||
break;
|
||||
|
||||
case FN_CONTENT_CONTROL_PROPERTIES:
|
||||
{
|
||||
SwWrtShell& rWrtSh = GetShell();
|
||||
SwAbstractDialogFactory* pFact = SwAbstractDialogFactory::Create();
|
||||
ScopedVclPtr<VclAbstractDialog> pDlg(pFact->CreateSwContentControlDlg(GetView().GetFrameWeld(), rWrtSh));
|
||||
VclAbstractDialog::AsyncContext aContext;
|
||||
aContext.maEndDialogFn = [](sal_Int32){};
|
||||
pDlg->StartExecuteAsync(aContext);
|
||||
rReq.Done();
|
||||
break;
|
||||
}
|
||||
|
||||
case FN_INSERT_COLUMN_BREAK:
|
||||
rSh.InsertColumnBreak();
|
||||
rReq.Done();
|
||||
|
@ -2240,6 +2240,14 @@ void SwTextShell::GetState( SfxItemSet &rSet )
|
||||
rSet.Put(SfxBoolItem(nWhich, bProtected));
|
||||
}
|
||||
break;
|
||||
case FN_CONTENT_CONTROL_PROPERTIES:
|
||||
{
|
||||
if (!GetShell().CursorInsideContentControl())
|
||||
{
|
||||
rSet.DisableItem(nWhich);
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
nWhich = aIter.NextWhich();
|
||||
}
|
||||
|
@ -3383,7 +3383,7 @@ void SwXTextDocument::executeContentControlEvent(const StringMap& rArguments)
|
||||
|
||||
auto pTextContentControl = static_txtattr_cast<SwTextContentControl*>(pAttr);
|
||||
const SwFormatContentControl& rFormatContentControl = pTextContentControl->GetContentControl();
|
||||
auto pContentControl = const_cast<SwContentControl*>(rFormatContentControl.GetContentControl());
|
||||
std::shared_ptr<SwContentControl> pContentControl = rFormatContentControl.GetContentControl();
|
||||
auto it = rArguments.find("type");
|
||||
if (it == rArguments.end())
|
||||
{
|
||||
|
@ -94,7 +94,7 @@ bool SwWrtShell::GotoContentControl(const SwFormatContentControl& rContentContro
|
||||
|
||||
bool bRet = SwCursorShell::GotoFormatContentControl(rContentControl);
|
||||
|
||||
auto pContentControl = const_cast<SwContentControl*>(rContentControl.GetContentControl());
|
||||
std::shared_ptr<SwContentControl> pContentControl = rContentControl.GetContentControl();
|
||||
if (bRet && pContentControl && pContentControl->GetCheckbox())
|
||||
{
|
||||
// Checkbox: GotoFormatContentControl() selected the old state.
|
||||
|
@ -715,6 +715,7 @@
|
||||
<menu:menuitem menu:id=".uno:InsertContentControl"/>
|
||||
<menu:menuitem menu:id=".uno:InsertCheckboxContentControl"/>
|
||||
<menu:menuitem menu:id=".uno:InsertDropdownContentControl"/>
|
||||
<menu:menuitem menu:id=".uno:ContentControlProperties"/>
|
||||
</menu:menupopup>
|
||||
</menu:menu>
|
||||
</menu:menupopup>
|
||||
|
@ -19,6 +19,7 @@
|
||||
<menu:menuitem menu:id=".uno:InsertCheckboxContentControl"/>
|
||||
<menu:menuitem menu:id=".uno:InsertDropdownContentControl"/>
|
||||
<menu:menuitem menu:id=".uno:DatePickerFormField"/>
|
||||
<menu:menuitem menu:id=".uno:ContentControlProperties"/>
|
||||
</menu:menupopup>
|
||||
</menu:menu>
|
||||
<menu:menu menu:id=".uno:MSCompatLegacyControls">
|
||||
|
114
sw/uiconfig/swriter/ui/contentcontroldlg.ui
Normal file
114
sw/uiconfig/swriter/ui/contentcontroldlg.ui
Normal file
@ -0,0 +1,114 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!-- Generated with glade 3.38.2 -->
|
||||
<interface domain="sw">
|
||||
<requires lib="gtk+" version="3.20"/>
|
||||
<object class="GtkDialog" id="ContentControlDialog">
|
||||
<property name="can-focus">False</property>
|
||||
<property name="border-width">6</property>
|
||||
<property name="title" translatable="yes" context="contentcontroldlg|ContentControlDialog">Content Control Properties</property>
|
||||
<property name="modal">True</property>
|
||||
<property name="default-width">0</property>
|
||||
<property name="default-height">0</property>
|
||||
<property name="type-hint">dialog</property>
|
||||
<child internal-child="vbox">
|
||||
<object class="GtkBox" id="dialog-vbox1">
|
||||
<property name="can-focus">False</property>
|
||||
<property name="hexpand">True</property>
|
||||
<property name="vexpand">True</property>
|
||||
<property name="orientation">vertical</property>
|
||||
<property name="spacing">6</property>
|
||||
<child internal-child="action_area">
|
||||
<object class="GtkButtonBox">
|
||||
<property name="can-focus">False</property>
|
||||
<child>
|
||||
<object class="GtkButton" id="ok">
|
||||
<property name="label" translatable="yes" context="stock">_OK</property>
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">True</property>
|
||||
<property name="can_default">True</property>
|
||||
<property name="has_default">True</property>
|
||||
<property name="receives_default">True</property>
|
||||
<property name="use-underline">True</property>
|
||||
</object>
|
||||
<packing>
|
||||
<property name="expand">False</property>
|
||||
<property name="fill">True</property>
|
||||
<property name="position">0</property>
|
||||
</packing>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkButton" id="cancel">
|
||||
<property name="label" translatable="yes" context="stock">_Cancel</property>
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">True</property>
|
||||
<property name="receives_default">True</property>
|
||||
<property name="use-underline">True</property>
|
||||
</object>
|
||||
<packing>
|
||||
<property name="expand">False</property>
|
||||
<property name="fill">True</property>
|
||||
<property name="position">1</property>
|
||||
</packing>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkButton" id="help">
|
||||
<property name="label" translatable="yes" context="stock">_Help</property>
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">True</property>
|
||||
<property name="receives_default">True</property>
|
||||
<property name="use-underline">True</property>
|
||||
</object>
|
||||
<packing>
|
||||
<property name="expand">False</property>
|
||||
<property name="fill">True</property>
|
||||
<property name="position">2</property>
|
||||
<property name="secondary">True</property>
|
||||
</packing>
|
||||
</child>
|
||||
</object>
|
||||
<packing>
|
||||
<property name="expand">False</property>
|
||||
<property name="fill">False</property>
|
||||
<property name="position">1</property>
|
||||
</packing>
|
||||
</child>
|
||||
<child>
|
||||
<!-- n-columns=1 n-rows=1 -->
|
||||
<object class="GtkGrid">
|
||||
<property name="visible">True</property>
|
||||
<property name="can-focus">False</property>
|
||||
<property name="row-spacing">6</property>
|
||||
<property name="column-spacing">6</property>
|
||||
<child>
|
||||
<object class="GtkCheckButton" id="showing_place_holder">
|
||||
<property name="label" translatable="yes" context="contentcontroldlg|showing_place_holder">Content is placeholder text</property>
|
||||
<property name="visible">True</property>
|
||||
<property name="can-focus">True</property>
|
||||
<property name="receives-default">False</property>
|
||||
<property name="halign">start</property>
|
||||
<property name="valign">start</property>
|
||||
<property name="use-underline">True</property>
|
||||
<property name="draw-indicator">True</property>
|
||||
</object>
|
||||
<packing>
|
||||
<property name="left-attach">0</property>
|
||||
<property name="top-attach">0</property>
|
||||
</packing>
|
||||
</child>
|
||||
</object>
|
||||
<packing>
|
||||
<property name="expand">False</property>
|
||||
<property name="fill">False</property>
|
||||
<property name="position">0</property>
|
||||
</packing>
|
||||
</child>
|
||||
</object>
|
||||
</child>
|
||||
<action-widgets>
|
||||
<action-widget response="-5">ok</action-widget>
|
||||
<action-widget response="-6">cancel</action-widget>
|
||||
<action-widget response="-11">help</action-widget>
|
||||
</action-widgets>
|
||||
</object>
|
||||
<object class="GtkSizeGroup" id="sgLabels"/>
|
||||
</interface>
|
Loading…
x
Reference in New Issue
Block a user