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 #ifndef INCLUDED_SW_SOURCE_UI_DBUI_MMGREETINGSPAGE_HXX
20 #define INCLUDED_SW_SOURCE_UI_DBUI_MMGREETINGSPAGE_HXX
21 
22 #include <vcl/wizardmachine.hxx>
23 #include <sfx2/basedlgs.hxx>
24 #include <mailmergehelper.hxx>
25 #include <vcl/weld.hxx>
26 
27 #include <mailmergewizard.hxx>
28 
29 class SwMailMergeWizard;
30 
31 class SwGreetingsHandler
32 {
33 protected:
34     SwMailMergeWizard* m_pWizard;
35     /// The mail merge state, available even when m_pWizard is nullptr.
36     SwMailMergeConfigItem& m_rConfigItem;
37     bool m_bIsTabPage;
38 
39     std::unique_ptr<weld::CheckButton> m_xGreetingLineCB;
40     std::unique_ptr<weld::CheckButton> m_xPersonalizedCB;
41     std::unique_ptr<weld::Label> m_xFemaleFT;
42     std::unique_ptr<weld::ComboBox> m_xFemaleLB;
43     std::unique_ptr<weld::Button> m_xFemalePB;
44     std::unique_ptr<weld::Label> m_xMaleFT;
45     std::unique_ptr<weld::ComboBox> m_xMaleLB;
46     std::unique_ptr<weld::Button> m_xMalePB;
47     std::unique_ptr<weld::Label> m_xFemaleFI;
48     std::unique_ptr<weld::Label> m_xFemaleColumnFT;
49     std::unique_ptr<weld::ComboBox> m_xFemaleColumnLB;
50     std::unique_ptr<weld::Label> m_xFemaleFieldFT;
51     std::unique_ptr<weld::ComboBox> m_xFemaleFieldCB;
52     std::unique_ptr<weld::Label> m_xNeutralFT;
53     std::unique_ptr<weld::ComboBox> m_xNeutralCB;
54 
SwGreetingsHandler(SwMailMergeConfigItem & rConfigItem,weld::Builder & rBuilder)55     SwGreetingsHandler(SwMailMergeConfigItem& rConfigItem, weld::Builder& rBuilder)
56         : m_pWizard(nullptr)
57         , m_rConfigItem(rConfigItem)
58         , m_bIsTabPage(false)
59         , m_xGreetingLineCB(rBuilder.weld_check_button("greeting"))
60         , m_xPersonalizedCB(rBuilder.weld_check_button("personalized"))
61         , m_xFemaleFT(rBuilder.weld_label("femaleft"))
62         , m_xFemaleLB(rBuilder.weld_combo_box("female"))
63         , m_xFemalePB(rBuilder.weld_button("newfemale"))
64         , m_xMaleFT(rBuilder.weld_label("maleft"))
65         , m_xMaleLB(rBuilder.weld_combo_box("male"))
66         , m_xMalePB(rBuilder.weld_button("newmale"))
67         , m_xFemaleFI(rBuilder.weld_label("femalefi"))
68         , m_xFemaleColumnFT(rBuilder.weld_label("femalecolft"))
69         , m_xFemaleColumnLB(rBuilder.weld_combo_box("femalecol"))
70         , m_xFemaleFieldFT(rBuilder.weld_label("femalefieldft"))
71         , m_xFemaleFieldCB(rBuilder.weld_combo_box("femalefield"))
72         , m_xNeutralFT(rBuilder.weld_label("generalft"))
73         , m_xNeutralCB(rBuilder.weld_combo_box("general"))
74     {
75     }
76 
~SwGreetingsHandler()77     ~SwGreetingsHandler() {}
78 
79     DECL_LINK(IndividualHdl_Impl, weld::Toggleable&, void);
80     DECL_LINK(GreetingHdl_Impl, weld::Button&, void);
81 
82     void Contains(bool bContainsGreeting);
83     virtual void UpdatePreview();
84 };
85 
86 class SwMailMergeGreetingsPage : public vcl::OWizardPage, public SwGreetingsHandler
87 {
88     std::unique_ptr<SwAddressPreview> m_xPreview;
89     std::unique_ptr<weld::Label> m_xPreviewFI;
90     std::unique_ptr<weld::Button> m_xAssignPB;
91     std::unique_ptr<weld::Label> m_xDocumentIndexFI;
92     std::unique_ptr<weld::Button> m_xPrevSetIB;
93     std::unique_ptr<weld::Button> m_xNextSetIB;
94     std::unique_ptr<weld::CustomWeld> m_xPreviewWIN;
95 
96     OUString m_sDocument;
97 
98     DECL_LINK(ContainsHdl_Impl, weld::Toggleable&, void);
99     DECL_LINK(InsertDataHdl_Impl, weld::Button&, void);
100     DECL_LINK(GreetingSelectComboBoxHdl_Impl, weld::ComboBox&, void);
101     DECL_LINK(GreetingSelectListBoxHdl_Impl, weld::ComboBox&, void);
102     DECL_LINK(AssignHdl_Impl, weld::Button&, void);
103 
104     virtual void UpdatePreview() override;
105     virtual void Activate() override;
106     virtual bool commitPage(::vcl::WizardTypes::CommitPageReason _eReason) override;
107 
108 public:
109     SwMailMergeGreetingsPage(weld::Container* pPage, SwMailMergeWizard* pWizard);
110     virtual ~SwMailMergeGreetingsPage() override;
111 };
112 
113 class SwMailBodyDialog : public SfxDialogController, public SwGreetingsHandler
114 {
115     std::unique_ptr<weld::Label> m_xBodyFT;
116     std::unique_ptr<weld::TextView> m_xBodyMLE;
117     std::unique_ptr<weld::Button> m_xOK;
118 
119     DECL_LINK(ContainsHdl_Impl, weld::Toggleable&, void);
120     DECL_LINK(OKHdl, weld::Button&, void);
121 
122 public:
123     SwMailBodyDialog(weld::Window* pParent);
124     virtual ~SwMailBodyDialog() override;
125 
SetBody(const OUString & rBody)126     void SetBody(const OUString& rBody) { m_xBodyMLE->set_text(rBody); }
GetBody() const127     OUString GetBody() const { return m_xBodyMLE->get_text(); }
128 };
129 #endif
130 
131 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
132