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 <editeng/weldeditview.hxx>
24 #include <vcl/button.hxx>
25 #include <mailmergehelper.hxx>
26 #include <sfx2/basedlgs.hxx>
27 #include <vcl/edit.hxx>
28 #include <vcl/layout.hxx>
29 #include <vcl/vclmedit.hxx>
30 #include <vcl/headbar.hxx>
31 #include <vcl/transfer.hxx>
32 #include <vcl/treelistbox.hxx>
33 #include <vcl/combobox.hxx>
34 #include <svl/lstner.hxx>
35 #include <o3tl/typed_flags_set.hxx>
36 
37 class SwMailMergeWizard;
39 
41 {
44 
48 
54 
56 
61 
62  OUString m_sDocument;
64  OUString m_sChangeAddress;
65 
67 
68  DECL_LINK(AddressListHdl_Impl, Button *, void);
69  DECL_LINK(SettingsHdl_Impl, Button*, void);
70  DECL_LINK(AssignHdl_Impl, Button*, void);
71  DECL_LINK(AddressBlockHdl_Impl, Button*, void);
72  DECL_LINK(InsertDataHdl_Impl, Button*, void);
73  DECL_LINK(AddressBlockSelectHdl_Impl, LinkParamNone*, void);
74  DECL_LINK(HideParagraphsHdl_Impl, Button*, void);
75 
76  void EnableAddressBlock(bool bAll, bool bSelective);
77 
78  virtual void ActivatePage() override;
79  virtual bool commitPage( ::svt::WizardTypes::CommitPageReason _eReason ) override;
80  virtual bool canAdvance() const override;
81 
82 public:
84  virtual ~SwMailMergeAddressBlockPage() override;
85  virtual void dispose() override;
87 };
88 
90 {
91  css::uno::Sequence< OUString> m_aAddressBlocks;
93 
94  std::unique_ptr<AddressPreview> 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() const override;
146  virtual css::uno::Reference<css::datatransfer::dnd::XDropTarget> GetDropTarget() const 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 
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<AddressPreview> 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<AddressPreview> 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
void SetAddress(const OUString &rAddress)
std::unique_ptr< AddressPreview > m_xPreview
VclPtr< SwAddressPreview > m_pSettingsWIN
std::unique_ptr< AddressPreview > m_xPreview
std::vector< OUString > m_aSalutations
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
VclPtr< VclContainer > m_pStep3
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)
virtual css::uno::Reference< css::datatransfer::dnd::XDropTarget > GetDropTarget() const override
SwAssignFieldsDialog(weld::Window *pParent, SwMailMergeConfigItem &rConfigItem, const OUString &rPreview, bool bIsAddressBlock)
VclPtr< CheckBox > m_pHideEmptyParagraphsCB
VclPtr< FixedText > m_pCurrentAddressFI
Link< AddressMultiLineEdit &, void > m_aModifyLink
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
virtual ~AddressMultiLineEdit() override
virtual void SetDrawingArea(weld::DrawingArea *pDrawingArea) override
virtual bool MouseButtonDown(const MouseEvent &rMEvt) override
VclPtr< FixedText > m_pSettingsFI
virtual ~SwSelectAddressBlockDialog() override
std::unique_ptr< weld::Button > m_xCustomizePB
std::unique_ptr< weld::SizeGroup > m_xComboGroup
Link< bool, void > m_aSelectionLink
DECL_LINK(NewCustomizeHdl_Impl, weld::Button &, void)
std::unique_ptr< weld::CustomWeld > m_xPreviewWIN
std::unique_ptr< AddressPreview > m_xPreview
virtual void ActivatePage() override
std::unique_ptr< weld::CustomWeld > m_xDragWIN
DECL_LINK(AddressListHdl_Impl, Button *, void)
std::unique_ptr< weld::ComboBox > m_xFieldCB
SwCustomizeAddressBlockDialog(weld::Widget *pParent, SwMailMergeConfigItem &rConfig, DialogType)
virtual ~SwAssignFieldsDialog() override
SwMailMergeAddressBlockPage(SwMailMergeWizard *_pParent)
VclPtr< PushButton > m_pAddressListPB
std::unique_ptr< weld::Button > m_xOK
VclPtr< PushButton > m_pSettingsPB
std::unique_ptr< weld::Label > m_xPreviewFI
virtual bool commitPage(::svt::WizardTypes::CommitPageReason _eReason) override
VclPtr< SwAddressPreview > m_pPreviewWIN
std::unique_ptr< weld::Label > m_xAddressElementsFT
std::unique_ptr< weld::Label > m_xFieldFT
virtual void dispose() override
VclPtr< SwMailMergeWizard > m_pWizard
std::unique_ptr< weld::SizeGroup > m_xPreviewGroup
VclPtr< PushButton > m_pPrevSetIB
virtual bool KeyInput(const KeyEvent &rKEvt) override
virtual ~SwMailMergeAddressBlockPage() override
VclPtr< VclContainer > m_pStep4
std::unique_ptr< weld::Label > m_xMatchingFI
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
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
SwCustomizeAddressBlockDialog * GetAddressDialog()
void SetAddressBlocks(const css::uno::Sequence< OUString > &rBlocks, sal_uInt16 nSelected)
virtual bool canAdvance() const override
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)
VclPtr< PushButton > m_pNextSetIB
VclPtr< PushButton > m_pAssignPB
std::unique_ptr< AddressMultiLineEdit > m_xDragED
bool HasItem(sal_Int32 nUserData)
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
std::unique_ptr< weld::TreeView > m_xAddressElementsLB
std::unique_ptr< weld::Entry > m_xCountryED
virtual weld::TreeView * get_drag_source() const
SwMailMergeConfigItem & m_rConfigItem
std::unique_ptr< weld::SizeGroup > m_xLabelGroup
std::unique_ptr< weld::Label > m_xAddressTitle