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 <vcl/button.hxx>
25 #include <mailmergehelper.hxx>
26 #include <sfx2/basedlgs.hxx>
27 #include <vcl/textfilter.hxx>
28 #include <vcl/layout.hxx>
29 #include <svl/lstner.hxx>
30 #include <o3tl/typed_flags_set.hxx>
31 
32 class SwMailMergeWizard;
34 
36 {
37  OUString m_sDocument;
39  OUString m_sChangeAddress;
40 
42 
43  std::unique_ptr<weld::Button> m_xAddressListPB;
44  std::unique_ptr<weld::Label> m_xCurrentAddressFI;
45 
46  std::unique_ptr<weld::Container> m_xStep2;
47  std::unique_ptr<weld::Container> m_xStep3;
48  std::unique_ptr<weld::Container> m_xStep4;
49 
50  std::unique_ptr<weld::Label> m_xSettingsFI;
51  std::unique_ptr<weld::CheckButton> m_xAddressCB;
52  std::unique_ptr<weld::Button> m_xSettingsPB;
53  std::unique_ptr<weld::CheckButton> m_xHideEmptyParagraphsCB;
54 
55  std::unique_ptr<weld::Button> m_xAssignPB;
56 
57  std::unique_ptr<weld::Label> m_xDocumentIndexFI;
58  std::unique_ptr<weld::Button> m_xPrevSetIB;
59  std::unique_ptr<weld::Button> m_xNextSetIB;
60 
61  std::unique_ptr<weld::Button> m_xDifferentlist;
62 
63  std::unique_ptr<SwAddressPreview> m_xSettings;
64  std::unique_ptr<SwAddressPreview> m_xPreview;
65  std::unique_ptr<weld::CustomWeld> m_xSettingsWIN;
66  std::unique_ptr<weld::CustomWeld> m_xPreviewWIN;
67 
68  void InsertDataHdl(weld::Button* pButton);
69 
70  DECL_LINK(AddressListHdl_Impl, weld::Button&, void);
71  DECL_LINK(SettingsHdl_Impl, weld::Button&, void);
72  DECL_LINK(AssignHdl_Impl, weld::Button&, void);
73  DECL_LINK(AddressBlockHdl_Impl, weld::ToggleButton&, void);
74  DECL_LINK(InsertDataHdl_Impl, weld::Button&, void);
75  DECL_LINK(AddressBlockSelectHdl_Impl, LinkParamNone*, void);
76  DECL_LINK(HideParagraphsHdl_Impl, weld::ToggleButton&, void);
77 
78  void EnableAddressBlock(bool bAll, bool bSelective);
79 
80  virtual void ActivatePage() override;
81  virtual bool commitPage( ::vcl::WizardTypes::CommitPageReason _eReason ) override;
82  virtual bool canAdvance() const override;
83 
84 public:
86  virtual ~SwMailMergeAddressBlockPage() override;
87  virtual void dispose() override;
89 };
90 
92 {
93  css::uno::Sequence< OUString> m_aAddressBlocks;
95 
96  std::unique_ptr<SwAddressPreview> m_xPreview;
97  std::unique_ptr<weld::Button> m_xNewPB;
98  std::unique_ptr<weld::Button> m_xCustomizePB;
99  std::unique_ptr<weld::Button> m_xDeletePB;
100  std::unique_ptr<weld::RadioButton> m_xNeverRB;
101  std::unique_ptr<weld::RadioButton> m_xAlwaysRB;
102  std::unique_ptr<weld::RadioButton> m_xDependentRB;
103  std::unique_ptr<weld::Entry> m_xCountryED;
104  std::unique_ptr<weld::CustomWeld> m_xPreviewWin;
105 
106  DECL_LINK(NewCustomizeHdl_Impl, weld::Button&, void);
107  DECL_LINK(DeleteHdl_Impl, weld::Button&, void);
108  DECL_LINK(IncludeHdl_Impl, weld::ToggleButton&, void);
109 
110 public:
112  virtual ~SwSelectAddressBlockDialog() override;
113 
114  void SetAddressBlocks(const css::uno::Sequence< OUString>& rBlocks,
115  sal_uInt16 nSelected);
116  const css::uno::Sequence< OUString>& GetAddressBlocks();
117 
118  void SetSettings(bool bIsCountry, const OUString& sCountry);
119  bool IsIncludeCountry() const {return !m_xNeverRB->get_active();}
120  OUString GetCountry() const;
121 };
122 
124 
125 enum class MoveItemFlags {
126  NONE = 0,
127  Left = 1,
128  Right = 2,
129  Up = 4,
130  Down = 8,
131 };
132 namespace o3tl {
133  template<> struct typed_flags<MoveItemFlags> : is_typed_flags<MoveItemFlags, 0x0f> {};
134 }
135 
137 
139  , public SfxListener
140 {
144 
145  css::uno::Reference<css::datatransfer::dnd::XDropTarget> m_xDropTarget;
146 
147  virtual void EditViewSelectionChange() const override;
148  virtual css::uno::Reference<css::datatransfer::dnd::XDropTarget> GetDropTarget() const override;
149 
150  virtual bool KeyInput(const KeyEvent& rKEvt) override;
151  virtual bool MouseButtonDown(const MouseEvent& rMEvt) override;
152 
153 public:
155  virtual void SetDrawingArea(weld::DrawingArea* pDrawingArea) override;
156  void EndDropTarget();
157  bool SetCursorLogicPosition(const Point& rPosition);
158  void UpdateFields();
159  virtual ~AddressMultiLineEdit() override;
160 
161  void SetSelectionChangedHdl( const Link<bool,void>& rLink ) { m_aSelectionLink = rLink; }
162  void SetModifyHdl( const Link<AddressMultiLineEdit&,void>& rLink ) { m_aModifyLink = rLink; }
163 
164  void SetText( const OUString& rStr );
165  OUString GetText() const;
166  OUString GetAddress();
167 
168  void InsertNewEntry( const OUString& rStr );
169  void InsertNewEntryAtPosition( const OUString& rStr, sal_uLong nPara, sal_uInt16 nIndex );
170  void RemoveCurrentEntry();
171 
172  void MoveCurrentItem(MoveItemFlags nMove);
174  bool HasCurrentItem();
175  OUString GetCurrentItem();
176  void SelectCurrentItem();
177 };
178 
180 {
181  friend class AddressMultiLineEdit;
182 public:
184  {
189  };
190 private:
192 
193  std::vector<OUString> m_aSalutations;
194  std::vector<OUString> m_aPunctuations;
195 
198  OUString m_sCurrentText;
199 
202 
204 
205  std::unique_ptr<weld::Label> m_xAddressElementsFT;
206  std::unique_ptr<weld::TreeView> m_xAddressElementsLB;
207  std::unique_ptr<weld::Button> m_xInsertFieldIB;
208  std::unique_ptr<weld::Button> m_xRemoveFieldIB;
209  std::unique_ptr<weld::Label> m_xDragFT;
210  std::unique_ptr<weld::Button> m_xUpIB;
211  std::unique_ptr<weld::Button> m_xLeftIB;
212  std::unique_ptr<weld::Button> m_xRightIB;
213  std::unique_ptr<weld::Button> m_xDownIB;
214  std::unique_ptr<weld::Label> m_xFieldFT;
215  std::unique_ptr<weld::ComboBox> m_xFieldCB;
216  std::unique_ptr<weld::Button> m_xOK;
217  std::unique_ptr<SwAddressPreview> m_xPreview;
218  std::unique_ptr<weld::CustomWeld> m_xPreviewWIN;
219  std::unique_ptr<AddressMultiLineEdit> m_xDragED;
220  std::unique_ptr<weld::CustomWeld> m_xDragWIN;
221 
222  DECL_LINK(OKHdl_Impl, weld::Button&, void);
223  DECL_LINK(ListBoxSelectHdl_Impl, weld::TreeView&, void);
224  DECL_LINK(EditModifyHdl_Impl, AddressMultiLineEdit&, void);
225  DECL_LINK(ImageButtonHdl_Impl, weld::Button&, void);
226  DECL_LINK(SelectionChangedHdl_Impl, bool, void);
227  DECL_LINK(FieldChangeComboBoxHdl_Impl, weld::ComboBox&, void);
228  DECL_LINK(TextFilterHdl, OUString&, bool);
229  DECL_LINK(SelectionChangedIdleHdl, Timer*, void);
230 
231  sal_Int32 GetSelectedItem_Impl();
233 
234 public:
236  virtual ~SwCustomizeAddressBlockDialog() override;
237 
238  bool SetCursorLogicPosition(const Point& rPosition);
239  void UpdateFields();
240 
241  // for dragging from the TreeViews, return the active source
242  virtual weld::TreeView* get_drag_source() const { return m_xAddressElementsLB->get_drag_source(); }
243  bool HasItem(sal_Int32 nUserData);
244 
245  void SetAddress(const OUString& rAddress);
246  OUString GetAddress();
247 };
248 
251 {
252  OUString const m_sNone;
253  OUString const m_rPreviewString;
254 
256 
257  std::unique_ptr<SwAddressPreview> m_xPreview;
258  std::unique_ptr<weld::Label> m_xMatchingFI;
259  std::unique_ptr<weld::Label> m_xAddressTitle;
260  std::unique_ptr<weld::Label> m_xMatchTitle;
261  std::unique_ptr<weld::Label> m_xPreviewTitle;
262  std::unique_ptr<weld::Label> m_xPreviewFI;
263  std::unique_ptr<weld::Button> m_xOK;
264  std::unique_ptr<weld::CustomWeld> m_xPreviewWin;
265  std::unique_ptr<SwAssignFieldsControl> m_xFieldsControl;
266 
267  std::unique_ptr<weld::SizeGroup> m_xLabelGroup;
268  std::unique_ptr<weld::SizeGroup> m_xComboGroup;
269  std::unique_ptr<weld::SizeGroup> m_xPreviewGroup;
270 
271  css::uno::Sequence< OUString > CreateAssignments();
272  DECL_LINK(OkHdl_Impl, weld::Button&, void);
273  DECL_LINK(AssignmentModifyHdl_Impl, LinkParamNone*, void);
274 
275 public:
277  SwMailMergeConfigItem& rConfigItem,
278  const OUString& rPreview,
279  bool bIsAddressBlock);
280 
281  void ConnectSizeGroups(int nLabelWidth, int nComboBoxWidth, int nPreviewWidth);
282 
283  virtual ~SwAssignFieldsDialog() override;
284 };
285 #endif
286 
287 /* 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
SwMailMergeAddressBlockPage(SwMailMergeWizard *pWizard, TabPageParent pParent)
std::unique_ptr< weld::Button > m_xLeftIB
std::unique_ptr< weld::Button > m_xNewPB
OUString const m_rPreviewString
std::unique_ptr< weld::Label > m_xPreviewTitle
std::unique_ptr< weld::Button > m_xDifferentlist
std::unique_ptr< weld::Label > m_xMatchTitle
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
virtual css::uno::Reference< css::datatransfer::dnd::XDropTarget > GetDropTarget() const override
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
virtual void ActivatePage() override
std::unique_ptr< weld::CustomWeld > m_xDragWIN
std::unique_ptr< weld::ComboBox > m_xFieldCB
void InsertDataHdl(weld::Button *pButton)
SwCustomizeAddressBlockDialog(weld::Widget *pParent, SwMailMergeConfigItem &rConfig, DialogType)
virtual ~SwAssignFieldsDialog() override
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
virtual void dispose() override
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)
virtual void EditViewSelectionChange() const override
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
MoveItemFlags IsCurrentItemMoveable()
bool SetCursorLogicPosition(const Point &rPosition)
void SetSelectionChangedHdl(const Link< bool, void > &rLink)
std::unique_ptr< weld::Button > m_xSettingsPB
std::unique_ptr< weld::CheckButton > m_xHideEmptyParagraphsCB
std::unique_ptr< SwAddressPreview > m_xPreview
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 weld::TreeView * get_drag_source() const
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