summaryrefslogtreecommitdiff
path: root/sw/source/ui/misc
diff options
context:
space:
mode:
authorMiklos Vajna <vmiklos@collabora.com>2022-05-13 13:35:23 +0200
committerMiklos Vajna <vmiklos@collabora.com>2022-05-13 15:05:24 +0200
commit75f7e057039aaa49558e22d18cad651d11589da9 (patch)
tree196bc31749d9eaebd8fb418436ab994ffcf71ec4 /sw/source/ui/misc
parent923c1a79efd0885be37feb4a5b3c847e659e4f53 (diff)
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
Diffstat (limited to 'sw/source/ui/misc')
-rw-r--r--sw/source/ui/misc/contentcontroldlg.cxx84
1 files changed, 84 insertions, 0 deletions
diff --git a/sw/source/ui/misc/contentcontroldlg.cxx b/sw/source/ui/misc/contentcontroldlg.cxx
new file mode 100644
index 000000000000..d18c3077f24d
--- /dev/null
+++ b/sw/source/ui/misc/contentcontroldlg.cxx
@@ -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: */