/src/libreoffice/sfx2/source/dialog/newstyle.cxx
Line | Count | Source |
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 | | |
30 | | IMPL_LINK_NOARG(SfxNewStyleDlg, OKClickHdl, weld::Button&, void) |
31 | 0 | { |
32 | 0 | const OUString aName(m_xColBox->get_active_text()); |
33 | 0 | SfxStyleSheetBase* pStyle = m_rPool.Find(aName, m_eSearchFamily); |
34 | 0 | if ( pStyle ) |
35 | 0 | { |
36 | 0 | if ( !pStyle->IsUserDefined() ) |
37 | 0 | { |
38 | 0 | std::unique_ptr<weld::MessageDialog> xBox(Application::CreateMessageDialog(m_xDialog.get(), |
39 | 0 | VclMessageType::Info, VclButtonsType::Ok, |
40 | 0 | SfxResId(STR_POOL_STYLE_NAME))); |
41 | 0 | xBox->run(); |
42 | 0 | return; |
43 | 0 | } |
44 | | |
45 | 0 | if (RET_YES == m_xQueryOverwriteBox->run()) |
46 | 0 | m_xDialog->response(RET_OK); |
47 | 0 | } |
48 | 0 | else |
49 | 0 | m_xDialog->response(RET_OK); |
50 | 0 | } |
51 | | |
52 | | IMPL_LINK_NOARG(SfxNewStyleDlg, OKHdl, weld::TreeView&, bool) |
53 | 0 | { |
54 | 0 | OKClickHdl(*m_xOKBtn); |
55 | 0 | return true; |
56 | 0 | } |
57 | | |
58 | | IMPL_LINK(SfxNewStyleDlg, ModifyHdl, weld::ComboBox&, rBox, void) |
59 | 0 | { |
60 | 0 | m_xOKBtn->set_sensitive(!rBox.get_active_text().replaceAll(" ", "").isEmpty()); |
61 | 0 | } |
62 | | |
63 | | SfxNewStyleDlg::SfxNewStyleDlg(weld::Widget* pParent, SfxStyleSheetBasePool& rInPool, SfxStyleFamily eFam) |
64 | 0 | : GenericDialogController(pParent, u"sfx/ui/newstyle.ui"_ustr, u"CreateStyleDialog"_ustr) |
65 | 0 | , m_rPool(rInPool) |
66 | 0 | , m_eSearchFamily(eFam) |
67 | 0 | , m_xColBox(m_xBuilder->weld_entry_tree_view(u"stylegrid"_ustr, u"stylename"_ustr, u"styles"_ustr)) |
68 | 0 | , m_xOKBtn(m_xBuilder->weld_button(u"ok"_ustr)) |
69 | 0 | , m_xQueryOverwriteBox(Application::CreateMessageDialog(m_xDialog.get(), VclMessageType::Question, VclButtonsType::YesNo, |
70 | 0 | SfxResId(STR_QUERY_OVERWRITE))) |
71 | 0 | { |
72 | 0 | m_xColBox->set_entry_width_chars(20); |
73 | 0 | m_xColBox->set_height_request_by_rows(8); |
74 | |
|
75 | 0 | m_xOKBtn->connect_clicked(LINK(this, SfxNewStyleDlg, OKClickHdl)); |
76 | 0 | m_xColBox->connect_changed(LINK(this, SfxNewStyleDlg, ModifyHdl)); |
77 | 0 | m_xColBox->connect_row_activated(LINK(this, SfxNewStyleDlg, OKHdl)); |
78 | |
|
79 | 0 | auto xIter = m_rPool.CreateIterator(eFam, SfxStyleSearchBits::UserDefined); |
80 | 0 | SfxStyleSheetBase *pStyle = xIter->First(); |
81 | 0 | while (pStyle) |
82 | 0 | { |
83 | 0 | m_xColBox->append_text(pStyle->GetName()); |
84 | 0 | pStyle = xIter->Next(); |
85 | 0 | } |
86 | 0 | } |
87 | | |
88 | | SfxNewStyleDlg::~SfxNewStyleDlg() |
89 | 0 | { |
90 | 0 | } |
91 | | |
92 | | /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ |