LibreOffice Module sfx2 (master) 1
newstyle.cxx
Go to the documentation of this file.
1/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2/*
3 * This file is part of the LibreOffice project.
4 *
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
8 *
9 * This file incorporates work covered by the following license notice:
10 *
11 * Licensed to the Apache Software Foundation (ASF) under one or more
12 * contributor license agreements. See the NOTICE file distributed
13 * with this work for additional information regarding copyright
14 * ownership. The ASF licenses this file to you under the Apache
15 * License, Version 2.0 (the "License"); you may not use this file
16 * except in compliance with the License. You may obtain a copy of
17 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
18 */
19
20#include <svl/style.hxx>
21
22#include <sfx2/newstyle.hxx>
23#include <sfx2/strings.hrc>
24#include <sfx2/sfxresid.hxx>
25#include <vcl/svapp.hxx>
26#include <vcl/weld.hxx>
27
28// Private methods ------------------------------------------------------
29
31{
32 const OUString aName(m_xColBox->get_active_text());
33 SfxStyleSheetBase* pStyle = m_rPool.Find(aName, m_eSearchFamily);
34 if ( pStyle )
35 {
36 if ( !pStyle->IsUserDefined() )
37 {
38 std::unique_ptr<weld::MessageDialog> xBox(Application::CreateMessageDialog(m_xDialog.get(),
39 VclMessageType::Info, VclButtonsType::Ok,
40 SfxResId(STR_POOL_STYLE_NAME)));
41 xBox->run();
42 return;
43 }
44
45 if (RET_YES == m_xQueryOverwriteBox->run())
46 m_xDialog->response(RET_OK);
47 }
48 else
49 m_xDialog->response(RET_OK);
50}
51
53{
54 OKClickHdl(*m_xOKBtn);
55 return true;
56}
57
58IMPL_LINK(SfxNewStyleDlg, ModifyHdl, weld::ComboBox&, rBox, void)
59{
60 m_xOKBtn->set_sensitive(!rBox.get_active_text().replaceAll(" ", "").isEmpty());
61}
62
64 : GenericDialogController(pParent, "sfx/ui/newstyle.ui", "CreateStyleDialog")
65 , m_rPool(rInPool)
66 , m_eSearchFamily(eFam)
67 , m_xColBox(m_xBuilder->weld_entry_tree_view("stylegrid", "stylename", "styles"))
68 , m_xOKBtn(m_xBuilder->weld_button("ok"))
69 , m_xQueryOverwriteBox(Application::CreateMessageDialog(m_xDialog.get(), VclMessageType::Question, VclButtonsType::YesNo,
70 SfxResId(STR_QUERY_OVERWRITE)))
71{
72 m_xColBox->set_entry_width_chars(20);
73 m_xColBox->set_height_request_by_rows(8);
74
75 m_xOKBtn->connect_clicked(LINK(this, SfxNewStyleDlg, OKClickHdl));
76 m_xColBox->connect_changed(LINK(this, SfxNewStyleDlg, ModifyHdl));
77 m_xColBox->connect_row_activated(LINK(this, SfxNewStyleDlg, OKHdl));
78
79 auto xIter = m_rPool.CreateIterator(eFam, SfxStyleSearchBits::UserDefined);
80 SfxStyleSheetBase *pStyle = xIter->First();
81 while (pStyle)
82 {
83 m_xColBox->append_text(pStyle->GetName());
84 pStyle = xIter->Next();
85 }
86}
87
89{
90}
91
92/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
Reference< XExecutableDialog > m_xDialog
static weld::MessageDialog * CreateMessageDialog(weld::Widget *pParent, VclMessageType eMessageType, VclButtonsType eButtonType, const OUString &rPrimaryMessage, const ILibreOfficeKitNotifier *pNotifier=nullptr)
std::unique_ptr< weld::Button > m_xOKBtn
Definition: newstyle.hxx:35
SfxNewStyleDlg(weld::Widget *pParent, SfxStyleSheetBasePool &rPool, SfxStyleFamily eFam)
Definition: newstyle.cxx:63
std::unique_ptr< weld::EntryTreeView > m_xColBox
Definition: newstyle.hxx:34
virtual ~SfxNewStyleDlg() override
Definition: newstyle.cxx:88
SfxStyleSheetBasePool & m_rPool
Definition: newstyle.hxx:31
virtual std::unique_ptr< SfxStyleSheetIterator > CreateIterator(SfxStyleFamily, SfxStyleSearchBits nMask=SfxStyleSearchBits::All)
const OUString & GetName() const
bool IsUserDefined() const
OUString aName
css::uno::Reference< css::linguistic2::XProofreadingIterator > get(css::uno::Reference< css::uno::XComponentContext > const &context)
IMPL_LINK(SfxNewStyleDlg, ModifyHdl, weld::ComboBox &, rBox, void)
Definition: newstyle.cxx:58
IMPL_LINK_NOARG(SfxNewStyleDlg, OKClickHdl, weld::Button &, void)
Definition: newstyle.cxx:30
OUString SfxResId(TranslateId aId)
Definition: sfxresid.cxx:22
SfxStyleFamily
RET_OK
RET_YES
VclMessageType
VclButtonsType