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 <o3tl/typed_flags_set.hxx>
29 
30 class SwMailMergeWizard;
32 
34 {
35  OUString m_sDocument;
37  OUString m_sChangeAddress;
38 
40 
41  std::unique_ptr<weld::Button> m_xAddressListPB;
42  std::unique_ptr<weld::Label> m_xCurrentAddressFI;
43 
44  std::unique_ptr<weld::Container> m_xStep2;
45  std::unique_ptr<weld::Container> m_xStep3;
46  std::unique_ptr<weld::Container> m_xStep4;
47 
48  std::unique_ptr<weld::Label> m_xSettingsFI;
49  std::unique_ptr<weld::CheckButton> m_xAddressCB;
50  std::unique_ptr<weld::Button> m_xSettingsPB;
51  std::unique_ptr<weld::CheckButton> m_xHideEmptyParagraphsCB;
52 
53  std::unique_ptr<weld::Button> m_xAssignPB;
54 
55  std::unique_ptr<weld::Label> m_xDocumentIndexFI;
56  std::unique_ptr<weld::Button> m_xPrevSetIB;
57  std::unique_ptr<weld::Button> m_xNextSetIB;
58 
59  std::unique_ptr<weld::Button> m_xDifferentlist;
60 
61  std::unique_ptr<SwAddressPreview> m_xSettings;
62  std::unique_ptr<SwAddressPreview> m_xPreview;
63  std::unique_ptr<weld::CustomWeld> m_xSettingsWIN;
64  std::unique_ptr<weld::CustomWeld> m_xPreviewWIN;
65 
66  void InsertDataHdl(const weld::Button* pButton);
67 
68  DECL_LINK(AddressListHdl_Impl, weld::Button&, void);
69  DECL_LINK(SettingsHdl_Impl, weld::Button&, void);
70  DECL_LINK(AssignHdl_Impl, weld::Button&, void);
71  DECL_LINK(AddressBlockHdl_Impl, weld::ToggleButton&, void);
72  DECL_LINK(InsertDataHdl_Impl, weld::Button&, void);
73  DECL_LINK(AddressBlockSelectHdl_Impl, LinkParamNone*, void);
74  DECL_LINK(HideParagraphsHdl_Impl, weld::ToggleButton&, void);
75 
76  void EnableAddressBlock(bool bAll, bool bSelective);
77 
78  virtual void Activate() override;
79  virtual bool commitPage( ::vcl::WizardTypes::CommitPageReason _eReason ) override;
80  virtual bool canAdvance() const override;
81 
82 public:
84  virtual ~SwMailMergeAddressBlockPage() override;
86 };
87 
89 {
90  css::uno::Sequence< OUString> m_aAddressBlocks;
92 
93  std::unique_ptr<SwAddressPreview> m_xPreview;
94  std::unique_ptr<weld::Button> m_xNewPB;
95  std::unique_ptr<weld::Button> m_xCustomizePB;
96  std::unique_ptr<weld::Button> m_xDeletePB;
97  std::unique_ptr<weld::RadioButton> m_xNeverRB;
98  std::unique_ptr<weld::RadioButton> m_xAlwaysRB;
99  std::unique_ptr<weld::RadioButton> m_xDependentRB;
100  std::unique_ptr<weld::Entry> m_xCountryED;
101  std::unique_ptr<weld::CustomWeld> m_xPreviewWin;
102 
103  DECL_LINK(NewCustomizeHdl_Impl, weld::Button&, void);
104  DECL_LINK(DeleteHdl_Impl, weld::Button&, void);
105  DECL_LINK(IncludeHdl_Impl, weld::ToggleButton&, void);
106 
107 public:
109  virtual ~SwSelectAddressBlockDialog() override;
110 
111  void SetAddressBlocks(const css::uno::Sequence< OUString>& rBlocks,
112  sal_uInt16 nSelected);
113  const css::uno::Sequence< OUString>& GetAddressBlocks();
114 
115  void SetSettings(bool bIsCountry, const OUString& sCountry);
116  bool IsIncludeCountry() const {return !m_xNeverRB->get_active();}
117  OUString GetCountry() const;
118 };
119 
121 
122 enum class MoveItemFlags {
123  NONE = 0,
124  Left = 1,
125  Right = 2,
126  Up = 4,
127  Down = 8,
128 };
129 namespace o3tl {
130  template<> struct typed_flags<MoveItemFlags> : is_typed_flags<MoveItemFlags, 0x0f> {};
131 }
132 
134 
136  , public SfxListener
137 {
141 
142  css::uno::Reference<css::datatransfer::dnd::XDropTarget> m_xDropTarget;
143 
144  virtual void EditViewSelectionChange() const override;
145  virtual css::uno::Reference<css::datatransfer::dnd::XDropTarget> GetDropTarget() const override;
146 
147  virtual bool KeyInput(const KeyEvent& rKEvt) override;
148  virtual bool MouseButtonDown(const MouseEvent& rMEvt) override;
149 
150 public:
152  virtual void SetDrawingArea(weld::DrawingArea* pDrawingArea) override;
153  void EndDropTarget();
154  bool SetCursorLogicPosition(const Point& rPosition);
155  void UpdateFields();
156  virtual ~AddressMultiLineEdit() override;
157 
158  void SetSelectionChangedHdl( const Link<bool,void>& rLink ) { m_aSelectionLink = rLink; }
159  void SetModifyHdl( const Link<AddressMultiLineEdit&,void>& rLink ) { m_aModifyLink = rLink; }
160 
161  void SetText( const OUString& rStr );
162  OUString GetText() const;
163  OUString GetAddress() const;
164 
165  void InsertNewEntry( const OUString& rStr );
166  void InsertNewEntryAtPosition( const OUString& rStr, sal_uLong nPara, sal_uInt16 nIndex );
167  void RemoveCurrentEntry();
168 
169  void MoveCurrentItem(MoveItemFlags nMove);
171  bool HasCurrentItem() const;
172  OUString GetCurrentItem() const;
173  void SelectCurrentItem();
174 };
175 
177 {
178  friend class AddressMultiLineEdit;
179 public:
181  {
186  };
187 private:
189 
190  std::vector<OUString> m_aSalutations;
191  std::vector<OUString> m_aPunctuations;
192 
195  OUString m_sCurrentText;
196 
199 
201 
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;
218 
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);
227 
228  sal_Int32 GetSelectedItem_Impl() const;
230 
231 public:
233  virtual ~SwCustomizeAddressBlockDialog() override;
234 
235  bool SetCursorLogicPosition(const Point& rPosition);
236  void UpdateFields();
237 
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);
241 
242  void SetAddress(const OUString& rAddress);
243  OUString GetAddress() const;
244 };
245 
248 {
249  OUString const m_sNone;
250  OUString const m_rPreviewString;
251 
253 
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;
263 
264  std::unique_ptr<weld::SizeGroup> m_xLabelGroup;
265  std::unique_ptr<weld::SizeGroup> m_xComboGroup;
266  std::unique_ptr<weld::SizeGroup> m_xPreviewGroup;
267 
268  css::uno::Sequence< OUString > CreateAssignments();
269  DECL_LINK(OkHdl_Impl, weld::Button&, void);
270  DECL_LINK(AssignmentModifyHdl_Impl, LinkParamNone*, void);
271 
272 public:
274  SwMailMergeConfigItem& rConfigItem,
275  const OUString& rPreview,
276  bool bIsAddressBlock);
277 
278  void ConnectSizeGroups(int nLabelWidth, int nComboBoxWidth, int nPreviewWidth);
279 
280  virtual ~SwAssignFieldsDialog() override;
281 };
282 #endif
283 
284 /* 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
OUString const m_rPreviewString
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
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
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)
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
bool SetCursorLogicPosition(const Point &rPosition)
void SetSelectionChangedHdl(const Link< bool, void > &rLink)
std::unique_ptr< weld::Button > m_xSettingsPB
OUString GetCurrentItem() const
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 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