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 
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>
30 
31 class SwMailMergeWizard;
33 
35 {
36  OUString m_sDocument;
38  OUString m_sChangeAddress;
39 
41 
42  std::unique_ptr<weld::Button> m_xAddressListPB;
43  std::unique_ptr<weld::Label> m_xCurrentAddressFI;
44 
45  std::unique_ptr<weld::Container> m_xStep2;
46  std::unique_ptr<weld::Container> m_xStep3;
47  std::unique_ptr<weld::Container> m_xStep4;
48 
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;
53 
54  std::unique_ptr<weld::Button> m_xAssignPB;
55 
56  std::unique_ptr<weld::Label> m_xDocumentIndexFI;
57  std::unique_ptr<weld::Button> m_xPrevSetIB;
58  std::unique_ptr<weld::Button> m_xNextSetIB;
59 
60  std::unique_ptr<weld::Button> m_xDifferentlist;
61 
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;
66 
67  void InsertDataHdl(const weld::Button* pButton);
68 
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::ToggleButton&, void);
73  DECL_LINK(InsertDataHdl_Impl, weld::Button&, void);
74  DECL_LINK(AddressBlockSelectHdl_Impl, LinkParamNone*, void);
75  DECL_LINK(HideParagraphsHdl_Impl, weld::ToggleButton&, void);
76 
77  void EnableAddressBlock(bool bAll, bool bSelective);
78 
79  virtual void Activate() override;
80  virtual bool commitPage( ::vcl::WizardTypes::CommitPageReason _eReason ) override;
81  virtual bool canAdvance() const override;
82 
83 public:
85  virtual ~SwMailMergeAddressBlockPage() override;
87 };
88 
90 {
91  css::uno::Sequence< OUString> m_aAddressBlocks;
93 
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;
103 
104  DECL_LINK(NewCustomizeHdl_Impl, weld::Button&, void);
105  DECL_LINK(DeleteHdl_Impl, weld::Button&, void);
106  DECL_LINK(IncludeHdl_Impl, weld::ToggleButton&, void);
107 
108 public:
110  virtual ~SwSelectAddressBlockDialog() override;
111 
112  void SetAddressBlocks(const css::uno::Sequence< OUString>& rBlocks,
113  sal_uInt16 nSelected);
114  const css::uno::Sequence< OUString>& GetAddressBlocks();
115 
116  void SetSettings(bool bIsCountry, const OUString& sCountry);
117  bool IsIncludeCountry() const {return !m_xNeverRB->get_active();}
118  OUString GetCountry() const;
119 };
120 
122 
123 enum class MoveItemFlags {
124  NONE = 0,
125  Left = 1,
126  Right = 2,
127  Up = 4,
128  Down = 8,
129 };
130 namespace o3tl {
131  template<> struct typed_flags<MoveItemFlags> : is_typed_flags<MoveItemFlags, 0x0f> {};
132 }
133 
135 
137  , public SfxListener
138 {
142 
143  css::uno::Reference<css::datatransfer::dnd::XDropTarget> m_xDropTarget;
144 
145  virtual void EditViewSelectionChange() override;
146  virtual css::uno::Reference<css::datatransfer::dnd::XDropTarget> GetDropTarget() override;
147 
148  virtual bool KeyInput(const KeyEvent& rKEvt) override;
149  virtual bool MouseButtonDown(const MouseEvent& rMEvt) override;
150 
151 public:
153  virtual void SetDrawingArea(weld::DrawingArea* pDrawingArea) override;
154  void EndDropTarget();
155  bool SetCursorLogicPosition(const Point& rPosition);
156  void UpdateFields();
157  virtual ~AddressMultiLineEdit() override;
158 
159  void SetSelectionChangedHdl( const Link<bool,void>& rLink ) { m_aSelectionLink = rLink; }
160  void SetModifyHdl( const Link<AddressMultiLineEdit&,void>& rLink ) { m_aModifyLink = rLink; }
161 
162  void SetText( const OUString& rStr );
163  OUString GetText() const;
164  OUString GetAddress() const;
165 
166  void InsertNewEntry( const OUString& rStr );
167  void InsertNewEntryAtPosition( const OUString& rStr, sal_uLong nPara, sal_uInt16 nIndex );
168  void RemoveCurrentEntry();
169 
170  void MoveCurrentItem(MoveItemFlags nMove);
172  bool HasCurrentItem() const;
173  OUString GetCurrentItem() const;
174  void SelectCurrentItem();
175 };
176 
178 {
179  friend class AddressMultiLineEdit;
180 public:
182  {
187  };
188 private:
190 
191  std::vector<OUString> m_aSalutations;
192  std::vector<OUString> m_aPunctuations;
193 
196  OUString m_sCurrentText;
197 
200 
202 
203  std::unique_ptr<weld::Label> m_xAddressElementsFT;
204  std::unique_ptr<weld::TreeView> m_xAddressElementsLB;
205  std::unique_ptr<weld::Button> m_xInsertFieldIB;
206  std::unique_ptr<weld::Button> m_xRemoveFieldIB;
207  std::unique_ptr<weld::Label> m_xDragFT;
208  std::unique_ptr<weld::Button> m_xUpIB;
209  std::unique_ptr<weld::Button> m_xLeftIB;
210  std::unique_ptr<weld::Button> m_xRightIB;
211  std::unique_ptr<weld::Button> m_xDownIB;
212  std::unique_ptr<weld::Label> m_xFieldFT;
213  std::unique_ptr<weld::ComboBox> m_xFieldCB;
214  std::unique_ptr<weld::Button> m_xOK;
215  std::unique_ptr<SwAddressPreview> m_xPreview;
216  std::unique_ptr<weld::CustomWeld> m_xPreviewWIN;
217  std::unique_ptr<AddressMultiLineEdit> m_xDragED;
218  std::unique_ptr<weld::CustomWeld> m_xDragWIN;
219 
220  DECL_LINK(OKHdl_Impl, weld::Button&, void);
221  DECL_LINK(ListBoxSelectHdl_Impl, weld::TreeView&, void);
222  DECL_LINK(EditModifyHdl_Impl, AddressMultiLineEdit&, void);
223  DECL_LINK(ImageButtonHdl_Impl, weld::Button&, void);
224  DECL_LINK(SelectionChangedHdl_Impl, bool, void);
225  DECL_LINK(FieldChangeComboBoxHdl_Impl, weld::ComboBox&, void);
226  DECL_LINK(TextFilterHdl, OUString&, bool);
227  DECL_LINK(SelectionChangedIdleHdl, Timer*, void);
228 
229  sal_Int32 GetSelectedItem_Impl() const;
231 
232 public:
234  virtual ~SwCustomizeAddressBlockDialog() override;
235 
236  bool SetCursorLogicPosition(const Point& rPosition);
237  void UpdateFields();
238 
239  // for dragging from the TreeViews, return the active source
240  weld::TreeView* get_drag_source() const { return m_xAddressElementsLB->get_drag_source(); }
241  bool HasItem(sal_Int32 nUserData);
242 
243  void SetAddress(const OUString& rAddress);
244  OUString GetAddress() const;
245 };
246 
249 {
250  OUString m_sNone;
252 
254 
255  std::unique_ptr<SwAddressPreview> m_xPreview;
256  std::unique_ptr<weld::Label> m_xMatchingFI;
257  std::unique_ptr<weld::Label> m_xAddressTitle;
258  std::unique_ptr<weld::Label> m_xMatchTitle;
259  std::unique_ptr<weld::Label> m_xPreviewTitle;
260  std::unique_ptr<weld::Label> m_xPreviewFI;
261  std::unique_ptr<weld::Button> m_xOK;
262  std::unique_ptr<weld::CustomWeld> m_xPreviewWin;
263  std::unique_ptr<SwAssignFieldsControl> m_xFieldsControl;
264 
265  std::unique_ptr<weld::SizeGroup> m_xLabelGroup;
266  std::unique_ptr<weld::SizeGroup> m_xComboGroup;
267  std::unique_ptr<weld::SizeGroup> m_xPreviewGroup;
268 
269  css::uno::Sequence< OUString > CreateAssignments();
270  DECL_LINK(OkHdl_Impl, weld::Button&, void);
271  DECL_LINK(AssignmentModifyHdl_Impl, LinkParamNone*, void);
272 
273 public:
275  SwMailMergeConfigItem& rConfigItem,
276  const OUString& rPreview,
277  bool bIsAddressBlock);
278 
279  void ConnectSizeGroups(int nLabelWidth, int nComboBoxWidth, int nPreviewWidth);
280 
281  virtual ~SwAssignFieldsDialog() override;
282 };
283 #endif
284 
285 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
std::unique_ptr< weld::Button > m_xRightIB
std::unique_ptr< weld::Button > m_xInsertFieldIB
std::unique_ptr< SwAddressPreview > m_xPreview
void SetAddress(const OUString &rAddress)
std::vector< OUString > m_aSalutations
std::unique_ptr< weld::Button > m_xLeftIB
std::unique_ptr< weld::Button > m_xNewPB
void InsertDataHdl(const weld::Button *pButton)
std::unique_ptr< weld::Label > m_xPreviewTitle
std::unique_ptr< weld::Button > m_xDifferentlist
OUString GetAddress() const
std::unique_ptr< weld::Label > m_xMatchTitle
MoveItemFlags IsCurrentItemMoveable() const
std::unique_ptr< SwAssignFieldsControl > m_xFieldsControl
SwSelectAddressBlockDialog(weld::Window *pParent, SwMailMergeConfigItem &rConfig)
std::unique_ptr< weld::RadioButton > m_xNeverRB
sal_uIntPtr sal_uLong
virtual TreeView * get_drag_source() const =0
DECL_LINK(OkHdl_Impl, weld::Button &, void)
std::unique_ptr< SwAddressPreview > m_xPreview
SwAssignFieldsDialog(weld::Window *pParent, SwMailMergeConfigItem &rConfigItem, const OUString &rPreview, bool bIsAddressBlock)
std::unique_ptr< weld::CheckButton > m_xAddressCB
Link< AddressMultiLineEdit &, void > m_aModifyLink
std::unique_ptr< weld::CustomWeld > m_xSettingsWIN
void InsertNewEntry(const OUString &rStr)
SwMailMergeWizard * GetWizard()
bool SetCursorLogicPosition(const Point &rPosition)
void MoveCurrentItem(MoveItemFlags nMove)
std::unique_ptr< weld::CustomWeld > m_xPreviewWin
css::uno::Reference< css::datatransfer::dnd::XDropTarget > m_xDropTarget
const css::uno::Sequence< OUString > & GetAddressBlocks()
std::vector< OUString > m_aPunctuations
std::unique_ptr< weld::Button > m_xUpIB
std::unique_ptr< weld::CustomWeld > m_xPreviewWIN
DECL_LINK(AddressListHdl_Impl, weld::Button &, void)
std::unique_ptr< weld::CustomWeld > m_xPreviewWin
virtual ~AddressMultiLineEdit() override
virtual void SetDrawingArea(weld::DrawingArea *pDrawingArea) override
std::unique_ptr< weld::Button > m_xNextSetIB
virtual bool MouseButtonDown(const MouseEvent &rMEvt) override
virtual ~SwSelectAddressBlockDialog() override
std::unique_ptr< weld::Button > m_xCustomizePB
std::unique_ptr< weld::SizeGroup > m_xComboGroup
Link< bool, void > m_aSelectionLink
std::unique_ptr< weld::Container > m_xStep3
DECL_LINK(NewCustomizeHdl_Impl, weld::Button &, void)
std::unique_ptr< weld::CustomWeld > m_xPreviewWIN
std::unique_ptr< weld::CustomWeld > m_xDragWIN
SwMailMergeAddressBlockPage(weld::Container *pPage, SwMailMergeWizard *pWizard)
std::unique_ptr< weld::ComboBox > m_xFieldCB
SwCustomizeAddressBlockDialog(weld::Widget *pParent, SwMailMergeConfigItem &rConfig, DialogType)
virtual ~SwAssignFieldsDialog() override
weld::TreeView * get_drag_source() const
std::unique_ptr< weld::Button > m_xOK
std::unique_ptr< weld::Container > m_xStep2
std::unique_ptr< weld::Label > m_xDocumentIndexFI
std::unique_ptr< weld::Label > m_xPreviewFI
std::unique_ptr< weld::Label > m_xAddressElementsFT
std::unique_ptr< weld::Label > m_xFieldFT
std::unique_ptr< weld::SizeGroup > m_xPreviewGroup
virtual bool KeyInput(const KeyEvent &rKEvt) override
std::unique_ptr< weld::Button > m_xPrevSetIB
virtual ~SwMailMergeAddressBlockPage() override
std::unique_ptr< weld::Label > m_xMatchingFI
std::unique_ptr< SwAddressPreview > m_xPreview
std::unique_ptr< weld::Button > m_xRemoveFieldIB
std::unique_ptr< weld::Button > m_xDownIB
DECL_LINK(OKHdl_Impl, weld::Button &, void)
void SetText(const OUString &rStr)
css::uno::Sequence< OUString > CreateAssignments()
std::unique_ptr< weld::RadioButton > m_xAlwaysRB
std::unique_ptr< weld::Button > m_xOK
std::unique_ptr< weld::Label > m_xSettingsFI
AddressMultiLineEdit(SwCustomizeAddressBlockDialog *pParent)
std::unique_ptr< weld::RadioButton > m_xDependentRB
void SetSettings(bool bIsCountry, const OUString &sCountry)
void EnableAddressBlock(bool bAll, bool bSelective)
SwCustomizeAddressBlockDialog * m_pParentDialog
std::unique_ptr< weld::Label > m_xDragFT
void SetAddressBlocks(const css::uno::Sequence< OUString > &rBlocks, sal_uInt16 nSelected)
virtual bool canAdvance() const override
std::unique_ptr< weld::Button > m_xAssignPB
SwMailMergeConfigItem & m_rConfig
void SetModifyHdl(const Link< AddressMultiLineEdit &, void > &rLink)
std::unique_ptr< weld::Button > m_xDeletePB
bool SetCursorLogicPosition(const Point &rPosition)
void SetSelectionChangedHdl(const Link< bool, void > &rLink)
std::unique_ptr< weld::Button > m_xSettingsPB
virtual void EditViewSelectionChange() override
OUString GetCurrentItem() const
std::unique_ptr< weld::CheckButton > m_xHideEmptyParagraphsCB
std::unique_ptr< SwAddressPreview > m_xPreview
virtual css::uno::Reference< css::datatransfer::dnd::XDropTarget > GetDropTarget() override
std::unique_ptr< AddressMultiLineEdit > m_xDragED
bool HasItem(sal_Int32 nUserData)
css::uno::Sequence< OUString > m_aAddressBlocks
std::unique_ptr< weld::Container > m_xStep4
virtual ~SwCustomizeAddressBlockDialog() override
void InsertNewEntryAtPosition(const OUString &rStr, sal_uLong nPara, sal_uInt16 nIndex)
std::unique_ptr< SwAddressPreview > m_xSettings
void ConnectSizeGroups(int nLabelWidth, int nComboBoxWidth, int nPreviewWidth)
SwMailMergeConfigItem & m_rConfigItem
std::unique_ptr< weld::Label > m_xCurrentAddressFI
std::unique_ptr< weld::TreeView > m_xAddressElementsLB
std::unique_ptr< weld::Entry > m_xCountryED
virtual void Activate() override
SwMailMergeConfigItem & m_rConfigItem
virtual bool commitPage(::vcl::WizardTypes::CommitPageReason _eReason) override
std::unique_ptr< weld::SizeGroup > m_xLabelGroup
std::unique_ptr< weld::Button > m_xAddressListPB
std::unique_ptr< weld::Label > m_xAddressTitle