LibreOffice Module sw (master)  1
mmaddressblockpage.hxx
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 #ifndef INCLUDED_SW_SOURCE_UI_DBUI_MMADDRESSBLOCKPAGE_HXX
20 #define INCLUDED_SW_SOURCE_UI_DBUI_MMADDRESSBLOCKPAGE_HXX
21 
23 #include <vcl/button.hxx>
24 #include <mailmergehelper.hxx>
25 #include <sfx2/basedlgs.hxx>
26 #include <vcl/edit.hxx>
27 #include <vcl/layout.hxx>
28 #include <vcl/vclmedit.hxx>
29 #include <vcl/headbar.hxx>
30 #include <vcl/treelistbox.hxx>
31 #include <vcl/combobox.hxx>
32 #include <svl/lstner.hxx>
33 #include <o3tl/typed_flags_set.hxx>
34 
35 class SwMailMergeWizard;
37 
39 {
42 
46 
52 
54 
59 
60  OUString m_sDocument;
62  OUString m_sChangeAddress;
63 
65 
66  DECL_LINK(AddressListHdl_Impl, Button *, void);
67  DECL_LINK(SettingsHdl_Impl, Button*, void);
68  DECL_LINK(AssignHdl_Impl, Button*, void);
69  DECL_LINK(AddressBlockHdl_Impl, Button*, void);
70  DECL_LINK(InsertDataHdl_Impl, Button*, void);
71  DECL_LINK(AddressBlockSelectHdl_Impl, LinkParamNone*, void);
72  DECL_LINK(HideParagraphsHdl_Impl, Button*, void);
73 
74  void EnableAddressBlock(bool bAll, bool bSelective);
75 
76  virtual void ActivatePage() override;
77  virtual bool commitPage( ::svt::WizardTypes::CommitPageReason _eReason ) override;
78  virtual bool canAdvance() const override;
79 
80 public:
82  virtual ~SwMailMergeAddressBlockPage() override;
83  virtual void dispose() override;
85 };
86 
88 {
89  css::uno::Sequence< OUString> m_aAddressBlocks;
91 
92  std::unique_ptr<AddressPreview> m_xPreview;
93  std::unique_ptr<weld::Button> m_xNewPB;
94  std::unique_ptr<weld::Button> m_xCustomizePB;
95  std::unique_ptr<weld::Button> m_xDeletePB;
96  std::unique_ptr<weld::RadioButton> m_xNeverRB;
97  std::unique_ptr<weld::RadioButton> m_xAlwaysRB;
98  std::unique_ptr<weld::RadioButton> m_xDependentRB;
99  std::unique_ptr<weld::Entry> m_xCountryED;
100  std::unique_ptr<weld::CustomWeld> m_xPreviewWin;
101 
102  DECL_LINK(NewCustomizeHdl_Impl, weld::Button&, void);
103  DECL_LINK(DeleteHdl_Impl, weld::Button&, void);
104  DECL_LINK(IncludeHdl_Impl, weld::ToggleButton&, void);
105 
106 public:
108  virtual ~SwSelectAddressBlockDialog() override;
109 
110  void SetAddressBlocks(const css::uno::Sequence< OUString>& rBlocks,
111  sal_uInt16 nSelected);
112  const css::uno::Sequence< OUString>& GetAddressBlocks();
113 
114  void SetSettings(bool bIsCountry, const OUString& sCountry);
115  bool IsIncludeCountry() const {return !m_xNeverRB->get_active();}
116  OUString GetCountry() const;
117 };
118 
120 class DDListBox : public SvTreeListBox
121 {
123 public:
124  DDListBox(vcl::Window* pParent, const WinBits nStyle);
125  virtual ~DDListBox() override;
126  virtual void dispose() override;
127 
129 
130  virtual void StartDrag( sal_Int8 nAction, const Point& rPosPixel ) override;
131 };
132 
133 enum class MoveItemFlags {
134  NONE = 0,
135  Left = 1,
136  Right = 2,
137  Up = 4,
138  Down = 8,
139 };
140 namespace o3tl {
141  template<> struct typed_flags<MoveItemFlags> : is_typed_flags<MoveItemFlags, 0x0f> {};
142 }
143 
145 {
148 
150 
151 protected:
152  bool PreNotify( NotifyEvent& rNEvt ) override;
153 public:
154  AddressMultiLineEdit(vcl::Window* pParent, WinBits nWinStyle);
155  virtual ~AddressMultiLineEdit() override;
156  virtual void dispose() override;
157 
159 
160  virtual void Notify( SfxBroadcaster& rBC, const SfxHint& rHint ) override;
161 
162  virtual Size GetOptimalSize() const override;
163 
164  void SetSelectionChangedHdl( const Link<AddressMultiLineEdit&,void>& rLink ) {m_aSelectionLink = rLink;}
165 
166  void SetText( const OUString& rStr ) override;
167  OUString GetAddress();
168 
169  void InsertNewEntry( const OUString& rStr );
170  void InsertNewEntryAtPosition( const OUString& rStr, sal_uLong nPara, sal_uInt16 nIndex );
171  void RemoveCurrentEntry();
172 
173  void MoveCurrentItem(MoveItemFlags nMove);
175  bool HasCurrentItem();
176  OUString GetCurrentItem();
177  void SelectCurrentItem();
178 };
179 
181 {
182  friend class DDListBox;
183  friend class AddressMultiLineEdit;
184 public:
186  {
191  };
192 private:
195 
198 
205 
209 
211 
213 
214  std::vector<OUString> m_aSalutations;
215  std::vector<OUString> m_aPunctuations;
216 
219  OUString m_sCurrentText;
220 
223 
224  DECL_LINK(OKHdl_Impl, Button*, void);
225  DECL_LINK(ListBoxSelectHdl_Impl, SvTreeListBox*, void);
226  DECL_LINK(EditModifyHdl_Impl, Edit&, void);
227  DECL_LINK(ImageButtonHdl_Impl, Button*, void);
228  DECL_LINK(SelectionChangedHdl_Impl, AddressMultiLineEdit&, void);
229  DECL_LINK(FieldChangeHdl_Impl, Edit&, void);
230  DECL_LINK(FieldChangeComboBoxHdl_Impl, ComboBox&, void);
231 
232  bool HasItem_Impl(sal_Int32 nUserData);
233  sal_Int32 GetSelectedItem_Impl();
235 
236 public:
238  virtual ~SwCustomizeAddressBlockDialog() override;
239  virtual void dispose() override;
240 
241  void SetAddress(const OUString& rAddress);
242  OUString GetAddress();
243 };
244 
247 {
248  OUString const m_sNone;
249  OUString const m_rPreviewString;
250 
252 
253  std::unique_ptr<AddressPreview> m_xPreview;
254  std::unique_ptr<weld::Label> m_xMatchingFI;
255  std::unique_ptr<weld::Label> m_xAddressTitle;
256  std::unique_ptr<weld::Label> m_xMatchTitle;
257  std::unique_ptr<weld::Label> m_xPreviewTitle;
258  std::unique_ptr<weld::Label> m_xPreviewFI;
259  std::unique_ptr<weld::Button> m_xOK;
260  std::unique_ptr<weld::CustomWeld> m_xPreviewWin;
261  std::unique_ptr<SwAssignFieldsControl> m_xFieldsControl;
262 
263  std::unique_ptr<weld::SizeGroup> m_xLabelGroup;
264  std::unique_ptr<weld::SizeGroup> m_xComboGroup;
265  std::unique_ptr<weld::SizeGroup> m_xPreviewGroup;
266 
267  css::uno::Sequence< OUString > CreateAssignments();
268  DECL_LINK(OkHdl_Impl, weld::Button&, void);
269  DECL_LINK(AssignmentModifyHdl_Impl, LinkParamNone*, void);
270 
271 public:
273  SwMailMergeConfigItem& rConfigItem,
274  const OUString& rPreview,
275  bool bIsAddressBlock);
276 
277  void ConnectSizeGroups(int nLabelWidth, int nComboBoxWidth, int nPreviewWidth);
278 
279  virtual ~SwAssignFieldsDialog() override;
280 };
281 #endif
282 
283 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
void SetAddressDialog(SwCustomizeAddressBlockDialog *pParent)
void SetAddress(const OUString &rAddress)
std::unique_ptr< AddressPreview > m_xPreview
VclPtr< SwAddressPreview > m_pSettingsWIN
std::vector< OUString > m_aSalutations
std::unique_ptr< weld::Button > m_xNewPB
OUString const m_rPreviewString
DDListBox(vcl::Window *pParent, const WinBits nStyle)
VclPtr< SwAddressPreview > m_pPreviewWIN
std::unique_ptr< weld::Label > m_xPreviewTitle
VclPtr< VclContainer > m_pStep3
virtual void dispose() override
std::unique_ptr< weld::Label > m_xMatchTitle
void SetAddressDialog(SwCustomizeAddressBlockDialog *pParent)
std::unique_ptr< SwAssignFieldsControl > m_xFieldsControl
signed char sal_Int8
virtual ~DDListBox() override
SwSelectAddressBlockDialog(weld::Window *pParent, SwMailMergeConfigItem &rConfig)
std::unique_ptr< weld::RadioButton > m_xNeverRB
VclPtr< SwCustomizeAddressBlockDialog > m_pParentDialog
sal_uIntPtr sal_uLong
VclPtr< DDListBox > m_pAddressElementsLB
DECL_LINK(OkHdl_Impl, weld::Button &, void)
void SetText(const OUString &rStr) override
SwAssignFieldsDialog(weld::Window *pParent, SwMailMergeConfigItem &rConfigItem, const OUString &rPreview, bool bIsAddressBlock)
VclPtr< CheckBox > m_pHideEmptyParagraphsCB
VclPtr< FixedText > m_pCurrentAddressFI
void InsertNewEntry(const OUString &rStr)
SwMailMergeWizard * GetWizard()
sal_Int64 WinBits
void MoveCurrentItem(MoveItemFlags nMove)
std::unique_ptr< weld::CustomWeld > m_xPreviewWin
const css::uno::Sequence< OUString > & GetAddressBlocks()
std::vector< OUString > m_aPunctuations
VclPtr< PushButton > m_pRemoveFieldIB
virtual void dispose() override
std::unique_ptr< weld::CustomWeld > m_xPreviewWin
VclPtr< SwCustomizeAddressBlockDialog > m_pParentDialog
virtual ~AddressMultiLineEdit() override
VclPtr< FixedText > m_pSettingsFI
virtual ~SwSelectAddressBlockDialog() override
std::unique_ptr< weld::Button > m_xCustomizePB
std::unique_ptr< weld::SizeGroup > m_xComboGroup
DECL_LINK(NewCustomizeHdl_Impl, weld::Button &, void)
virtual Size GetOptimalSize() const override
std::unique_ptr< AddressPreview > m_xPreview
virtual void dispose() override
virtual void ActivatePage() override
bool HasItem_Impl(sal_Int32 nUserData)
DECL_LINK(AddressListHdl_Impl, Button *, void)
AddressMultiLineEdit(vcl::Window *pParent, WinBits nWinStyle)
virtual void StartDrag(sal_Int8 nAction, const Point &rPosPixel) override
virtual ~SwAssignFieldsDialog() override
SwMailMergeAddressBlockPage(SwMailMergeWizard *_pParent)
VclPtr< PushButton > m_pAddressListPB
VclPtr< PushButton > m_pSettingsPB
VclPtr< PushButton > m_pInsertFieldIB
std::unique_ptr< weld::Label > m_xPreviewFI
virtual bool commitPage(::svt::WizardTypes::CommitPageReason _eReason) override
VclPtr< SwAddressPreview > m_pPreviewWIN
virtual void dispose() override
VclPtr< SwMailMergeWizard > m_pWizard
std::unique_ptr< weld::SizeGroup > m_xPreviewGroup
VclPtr< PushButton > m_pPrevSetIB
virtual ~SwMailMergeAddressBlockPage() override
VclPtr< VclContainer > m_pStep4
std::unique_ptr< weld::Label > m_xMatchingFI
css::uno::Sequence< OUString > CreateAssignments()
std::unique_ptr< weld::RadioButton > m_xAlwaysRB
std::unique_ptr< weld::Button > m_xOK
Link< AddressMultiLineEdit &, void > m_aSelectionLink
std::unique_ptr< weld::RadioButton > m_xDependentRB
void SetSettings(bool bIsCountry, const OUString &sCountry)
void EnableAddressBlock(bool bAll, bool bSelective)
virtual void Notify(SfxBroadcaster &rBC, const SfxHint &rHint) override
VclPtr< FixedText > m_pAddressElementsFT
void SetAddressBlocks(const css::uno::Sequence< OUString > &rBlocks, sal_uInt16 nSelected)
virtual bool canAdvance() const override
VclPtr< AddressMultiLineEdit > m_pDragED
SwMailMergeConfigItem & m_rConfig
std::unique_ptr< weld::Button > m_xDeletePB
MoveItemFlags IsCurrentItemMoveable()
void SetSelectionChangedHdl(const Link< AddressMultiLineEdit &, void > &rLink)
VclPtr< PushButton > m_pNextSetIB
bool PreNotify(NotifyEvent &rNEvt) override
VclPtr< PushButton > m_pAssignPB
css::uno::Sequence< OUString > m_aAddressBlocks
virtual ~SwCustomizeAddressBlockDialog() override
void InsertNewEntryAtPosition(const OUString &rStr, sal_uLong nPara, sal_uInt16 nIndex)
void ConnectSizeGroups(int nLabelWidth, int nComboBoxWidth, int nPreviewWidth)
SwMailMergeConfigItem & m_rConfigItem
VclPtr< FixedText > m_pDocumentIndexFI
VclPtr< VclContainer > m_pStep2
SwCustomizeAddressBlockDialog(vcl::Window *pParent, SwMailMergeConfigItem &rConfig, DialogType)
std::unique_ptr< weld::Entry > m_xCountryED
virtual void SetText(const OUString &rStr) override
SwMailMergeConfigItem & m_rConfigItem
DECL_LINK(OKHdl_Impl, Button *, void)
std::unique_ptr< weld::SizeGroup > m_xLabelGroup
std::unique_ptr< weld::Label > m_xAddressTitle