1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
3 * This file is part of the LibreOffice project.
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/.
9 * This file incorporates work covered by the following license notice:
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 .
19 #ifndef INCLUDED_SW_SOURCE_UI_DBUI_MMADDRESSBLOCKPAGE_HXX
20 #define INCLUDED_SW_SOURCE_UI_DBUI_MMADDRESSBLOCKPAGE_HXX
22 #include <svx/weldeditview.hxx>
23 #include <vcl/wizardmachine.hxx>
24 #include <mailmergehelper.hxx>
25 #include <sfx2/basedlgs.hxx>
26 #include <vcl/textfilter.hxx>
27 #include <svl/lstner.hxx>
28 #include <vcl/idle.hxx>
29 #include <o3tl/typed_flags_set.hxx>
31 class SwMailMergeWizard
;
32 class SwMailMergeConfigItem
;
34 class SwMailMergeAddressBlockPage
: public vcl::OWizardPage
37 OUString m_sCurrentAddress
;
38 OUString m_sChangeAddress
;
40 SwMailMergeWizard
* m_pWizard
;
42 std::unique_ptr
<weld::Button
> m_xAddressListPB
;
43 std::unique_ptr
<weld::Label
> m_xCurrentAddressFI
;
45 std::unique_ptr
<weld::Container
> m_xStep2
;
46 std::unique_ptr
<weld::Container
> m_xStep3
;
47 std::unique_ptr
<weld::Container
> m_xStep4
;
49 std::unique_ptr
<weld::Label
> m_xSettingsFI
;
50 std::unique_ptr
<weld::CheckButton
> m_xAddressCB
;
51 std::unique_ptr
<weld::Button
> m_xSettingsPB
;
52 std::unique_ptr
<weld::CheckButton
> m_xHideEmptyParagraphsCB
;
54 std::unique_ptr
<weld::Button
> m_xAssignPB
;
56 std::unique_ptr
<weld::Label
> m_xDocumentIndexFI
;
57 std::unique_ptr
<weld::Button
> m_xPrevSetIB
;
58 std::unique_ptr
<weld::Button
> m_xNextSetIB
;
60 std::unique_ptr
<weld::Button
> m_xDifferentlist
;
62 std::unique_ptr
<SwAddressPreview
> m_xSettings
;
63 std::unique_ptr
<SwAddressPreview
> m_xPreview
;
64 std::unique_ptr
<weld::CustomWeld
> m_xSettingsWIN
;
65 std::unique_ptr
<weld::CustomWeld
> m_xPreviewWIN
;
67 void InsertDataHdl(const weld::Button
* pButton
);
69 DECL_LINK(AddressListHdl_Impl
, weld::Button
&, void);
70 DECL_LINK(SettingsHdl_Impl
, weld::Button
&, void);
71 DECL_LINK(AssignHdl_Impl
, weld::Button
&, void);
72 DECL_LINK(AddressBlockHdl_Impl
, weld::Toggleable
&, void);
73 DECL_LINK(InsertDataHdl_Impl
, weld::Button
&, void);
74 DECL_LINK(AddressBlockSelectHdl_Impl
, LinkParamNone
*, void);
75 DECL_LINK(HideParagraphsHdl_Impl
, weld::Toggleable
&, void);
77 void EnableAddressBlock(bool bAll
, bool bSelective
);
79 virtual void Activate() override
;
80 virtual bool commitPage( ::vcl::WizardTypes::CommitPageReason _eReason
) override
;
81 virtual bool canAdvance() const override
;
84 SwMailMergeAddressBlockPage(weld::Container
* pPage
, SwMailMergeWizard
* pWizard
);
85 virtual ~SwMailMergeAddressBlockPage() override
;
86 SwMailMergeWizard
* GetWizard() { return m_pWizard
; }
89 class SwSelectAddressBlockDialog
: public SfxDialogController
91 css::uno::Sequence
< OUString
> m_aAddressBlocks
;
92 SwMailMergeConfigItem
& m_rConfig
;
94 std::unique_ptr
<SwAddressPreview
> m_xPreview
;
95 std::unique_ptr
<weld::Button
> m_xNewPB
;
96 std::unique_ptr
<weld::Button
> m_xCustomizePB
;
97 std::unique_ptr
<weld::Button
> m_xDeletePB
;
98 std::unique_ptr
<weld::RadioButton
> m_xNeverRB
;
99 std::unique_ptr
<weld::RadioButton
> m_xAlwaysRB
;
100 std::unique_ptr
<weld::RadioButton
> m_xDependentRB
;
101 std::unique_ptr
<weld::Entry
> m_xCountryED
;
102 std::unique_ptr
<weld::CustomWeld
> m_xPreviewWin
;
104 DECL_LINK(NewCustomizeHdl_Impl
, weld::Button
&, void);
105 DECL_LINK(DeleteHdl_Impl
, weld::Button
&, void);
106 DECL_LINK(IncludeHdl_Impl
, weld::Toggleable
&, void);
109 SwSelectAddressBlockDialog(weld::Window
* pParent
, SwMailMergeConfigItem
& rConfig
);
110 virtual ~SwSelectAddressBlockDialog() override
;
112 void SetAddressBlocks(const css::uno::Sequence
< OUString
>& rBlocks
,
113 sal_uInt16 nSelected
);
114 const css::uno::Sequence
< OUString
>& GetAddressBlocks();
116 void SetSettings(bool bIsCountry
, const OUString
& sCountry
);
117 bool IsIncludeCountry() const {return !m_xNeverRB
->get_active();}
118 OUString
GetCountry() const;
121 class SwCustomizeAddressBlockDialog
;
123 enum class MoveItemFlags
{
131 template<> struct typed_flags
<MoveItemFlags
> : is_typed_flags
<MoveItemFlags
, 0x0f> {};
134 class AddressMultiLineEdit
;
136 class AddressMultiLineEdit
: public WeldEditView
139 Link
<bool,void> m_aSelectionLink
;
140 Link
<AddressMultiLineEdit
&,void> m_aModifyLink
;
141 SwCustomizeAddressBlockDialog
* m_pParentDialog
;
143 virtual void EditViewSelectionChange() override
;
144 virtual css::uno::Reference
<css::datatransfer::dnd::XDropTarget
> GetDropTarget() override
;
146 virtual bool KeyInput(const KeyEvent
& rKEvt
) override
;
147 virtual bool Command(const CommandEvent
& rCEvt
) override
;
148 virtual bool MouseButtonDown(const MouseEvent
& rMEvt
) override
;
151 AddressMultiLineEdit(SwCustomizeAddressBlockDialog
*pParent
);
152 virtual void SetDrawingArea(weld::DrawingArea
* pDrawingArea
) override
;
153 void EndDropTarget();
154 bool SetCursorLogicPosition(const Point
& rPosition
);
156 virtual ~AddressMultiLineEdit() override
;
158 void SetSelectionChangedHdl( const Link
<bool,void>& rLink
) { m_aSelectionLink
= rLink
; }
159 void SetModifyHdl( const Link
<AddressMultiLineEdit
&,void>& rLink
) { m_aModifyLink
= rLink
; }
161 void SetText( const OUString
& rStr
);
162 OUString
GetText() const;
163 OUString
GetAddress() const;
165 void InsertNewEntry( const OUString
& rStr
);
166 void InsertNewEntryAtPosition( const OUString
& rStr
, sal_uLong nPara
, sal_uInt16 nIndex
);
167 void RemoveCurrentEntry();
169 void MoveCurrentItem(MoveItemFlags nMove
);
170 MoveItemFlags
IsCurrentItemMoveable() const;
171 bool HasCurrentItem() const;
172 OUString
GetCurrentItem() const;
173 void SelectCurrentItem();
176 class SwCustomizeAddressBlockDialog
: public SfxDialogController
178 friend class AddressMultiLineEdit
;
188 TextFilter m_aTextFilter
;
190 std::vector
<OUString
> m_aSalutations
;
191 std::vector
<OUString
> m_aPunctuations
;
193 OUString m_sCurrentSalutation
;
194 OUString m_sCurrentPunctuation
;
195 OUString m_sCurrentText
;
197 SwMailMergeConfigItem
& m_rConfigItem
;
200 Idle m_aSelectionChangedIdle
;
202 std::unique_ptr
<weld::Label
> m_xAddressElementsFT
;
203 std::unique_ptr
<weld::TreeView
> m_xAddressElementsLB
;
204 std::unique_ptr
<weld::Button
> m_xInsertFieldIB
;
205 std::unique_ptr
<weld::Button
> m_xRemoveFieldIB
;
206 std::unique_ptr
<weld::Label
> m_xDragFT
;
207 std::unique_ptr
<weld::Button
> m_xUpIB
;
208 std::unique_ptr
<weld::Button
> m_xLeftIB
;
209 std::unique_ptr
<weld::Button
> m_xRightIB
;
210 std::unique_ptr
<weld::Button
> m_xDownIB
;
211 std::unique_ptr
<weld::Label
> m_xFieldFT
;
212 std::unique_ptr
<weld::ComboBox
> m_xFieldCB
;
213 std::unique_ptr
<weld::Button
> m_xOK
;
214 std::unique_ptr
<SwAddressPreview
> m_xPreview
;
215 std::unique_ptr
<weld::CustomWeld
> m_xPreviewWIN
;
216 std::unique_ptr
<AddressMultiLineEdit
> m_xDragED
;
217 std::unique_ptr
<weld::CustomWeld
> m_xDragWIN
;
219 DECL_LINK(OKHdl_Impl
, weld::Button
&, void);
220 DECL_LINK(ListBoxSelectHdl_Impl
, weld::TreeView
&, void);
221 DECL_LINK(EditModifyHdl_Impl
, AddressMultiLineEdit
&, void);
222 DECL_LINK(ImageButtonHdl_Impl
, weld::Button
&, void);
223 DECL_LINK(SelectionChangedHdl_Impl
, bool, void);
224 DECL_LINK(FieldChangeComboBoxHdl_Impl
, weld::ComboBox
&, void);
225 DECL_LINK(TextFilterHdl
, OUString
&, bool);
226 DECL_LINK(SelectionChangedIdleHdl
, Timer
*, void);
228 sal_Int32
GetSelectedItem_Impl() const;
229 void UpdateImageButtons_Impl();
232 SwCustomizeAddressBlockDialog(weld::Widget
* pParent
, SwMailMergeConfigItem
& rConfig
, DialogType
);
233 virtual ~SwCustomizeAddressBlockDialog() override
;
235 bool SetCursorLogicPosition(const Point
& rPosition
);
238 // for dragging from the TreeViews, return the active source
239 weld::TreeView
* get_drag_source() const { return m_xAddressElementsLB
->get_drag_source(); }
240 bool HasItem(sal_Int32 nUserData
);
242 void SetAddress(const OUString
& rAddress
);
243 OUString
GetAddress() const;
246 class SwAssignFieldsControl
;
247 class SwAssignFieldsDialog
: public SfxDialogController
250 OUString m_rPreviewString
;
252 SwMailMergeConfigItem
& m_rConfigItem
;
254 std::unique_ptr
<SwAddressPreview
> m_xPreview
;
255 std::unique_ptr
<weld::Label
> m_xMatchingFI
;
256 std::unique_ptr
<weld::Label
> m_xAddressTitle
;
257 std::unique_ptr
<weld::Label
> m_xMatchTitle
;
258 std::unique_ptr
<weld::Label
> m_xPreviewTitle
;
259 std::unique_ptr
<weld::Label
> m_xPreviewFI
;
260 std::unique_ptr
<weld::Button
> m_xOK
;
261 std::unique_ptr
<weld::CustomWeld
> m_xPreviewWin
;
262 std::unique_ptr
<SwAssignFieldsControl
> m_xFieldsControl
;
264 css::uno::Sequence
< OUString
> CreateAssignments();
265 DECL_LINK(OkHdl_Impl
, weld::Button
&, void);
266 DECL_LINK(AssignmentModifyHdl_Impl
, LinkParamNone
*, void);
269 SwAssignFieldsDialog(weld::Window
* pParent
,
270 SwMailMergeConfigItem
& rConfigItem
,
272 bool bIsAddressBlock
);
274 void ConnectSizeGroups(int nLabelWidth
, int nComboBoxWidth
, int nPreviewWidth
);
276 virtual ~SwAssignFieldsDialog() override
;
280 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */