Line data Source code
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 <svtools/wizardmachine.hxx>
23 : #include <vcl/button.hxx>
24 : #include <svtools/stdctrl.hxx>
25 : #include <mailmergehelper.hxx>
26 : #include <sfx2/basedlgs.hxx>
27 : #include <vcl/edit.hxx>
28 : #include <vcl/layout.hxx>
29 : #include <vcl/lstbox.hxx>
30 : #include <svtools/svmedit.hxx>
31 : #include <svtools/headbar.hxx>
32 : #include <svtools/treelistbox.hxx>
33 : #include <vcl/combobox.hxx>
34 : #include <svl/lstner.hxx>
35 : class SwMailMergeWizard;
36 : class SwMailMergeConfigItem;
37 :
38 : class SwMailMergeAddressBlockPage : public svt::OWizardPage
39 : {
40 : VclPtr<PushButton> m_pAddressListPB;
41 : VclPtr<FixedText> m_pCurrentAddressFI;
42 :
43 : VclPtr<VclContainer> m_pStep2;
44 : VclPtr<VclContainer> m_pStep3;
45 : VclPtr<VclContainer> m_pStep4;
46 :
47 : VclPtr<FixedText> m_pSettingsFI;
48 : VclPtr<CheckBox> m_pAddressCB;
49 : VclPtr<SwAddressPreview> m_pSettingsWIN;
50 : VclPtr<PushButton> m_pSettingsPB;
51 : VclPtr<CheckBox> m_pHideEmptyParagraphsCB;
52 :
53 : VclPtr<PushButton> m_pAssignPB;
54 :
55 : VclPtr<SwAddressPreview> m_pPreviewWIN;
56 : VclPtr<FixedText> m_pDocumentIndexFI;
57 : VclPtr<PushButton> m_pPrevSetIB;
58 : VclPtr<PushButton> m_pNextSetIB;
59 :
60 : OUString m_sDocument;
61 : OUString m_sCurrentAddress;
62 : OUString m_sChangeAddress;
63 :
64 : VclPtr<SwMailMergeWizard> m_pWizard;
65 :
66 : DECL_LINK(AddressListHdl_Impl, void *);
67 : DECL_LINK(SettingsHdl_Impl, PushButton*);
68 : DECL_LINK(AssignHdl_Impl, PushButton*);
69 : DECL_LINK(AddressBlockHdl_Impl, CheckBox*);
70 : DECL_LINK(InsertDataHdl_Impl, ImageButton*);
71 : DECL_LINK(AddressBlockSelectHdl_Impl, void *);
72 : DECL_LINK(HideParagraphsHdl_Impl, CheckBox*);
73 :
74 : void EnableAddressBlock(bool bAll, bool bSelective);
75 :
76 : virtual void ActivatePage() SAL_OVERRIDE;
77 : virtual bool commitPage( ::svt::WizardTypes::CommitPageReason _eReason ) SAL_OVERRIDE;
78 : virtual bool canAdvance() const SAL_OVERRIDE;
79 :
80 : public:
81 : SwMailMergeAddressBlockPage(SwMailMergeWizard* _pParent);
82 : virtual ~SwMailMergeAddressBlockPage();
83 : virtual void dispose() SAL_OVERRIDE;
84 0 : SwMailMergeWizard* GetWizard() { return m_pWizard; }
85 : };
86 :
87 : class SwSelectAddressBlockDialog : public SfxModalDialog
88 : {
89 : VclPtr<SwAddressPreview> m_pPreview;
90 : VclPtr<PushButton> m_pNewPB;
91 : VclPtr<PushButton> m_pCustomizePB;
92 : VclPtr<PushButton> m_pDeletePB;
93 :
94 : VclPtr<RadioButton> m_pNeverRB;
95 : VclPtr<RadioButton> m_pAlwaysRB;
96 : VclPtr<RadioButton> m_pDependentRB;
97 : VclPtr<Edit> m_pCountryED;
98 :
99 : com::sun::star::uno::Sequence< OUString> m_aAddressBlocks;
100 : SwMailMergeConfigItem& m_rConfig;
101 :
102 : DECL_LINK(NewCustomizeHdl_Impl, PushButton*);
103 : DECL_LINK(DeleteHdl_Impl, PushButton*);
104 : DECL_LINK(IncludeHdl_Impl, RadioButton*);
105 :
106 : using Window::SetSettings;
107 :
108 : public:
109 : SwSelectAddressBlockDialog(vcl::Window* pParent, SwMailMergeConfigItem& rConfig);
110 : virtual ~SwSelectAddressBlockDialog();
111 : virtual void dispose() SAL_OVERRIDE;
112 :
113 : void SetAddressBlocks(const com::sun::star::uno::Sequence< OUString>& rBlocks,
114 : sal_uInt16 nSelected);
115 : const com::sun::star::uno::Sequence< OUString>& GetAddressBlocks();
116 :
117 : void SetSettings(bool bIsCountry, const OUString& sCountry);
118 0 : bool IsIncludeCountry() const {return !m_pNeverRB->IsChecked();}
119 : OUString GetCountry() const;
120 : };
121 :
122 : class SwCustomizeAddressBlockDialog;
123 : class DDListBox : public SvTreeListBox
124 : {
125 : VclPtr<SwCustomizeAddressBlockDialog> m_pParentDialog;
126 : public:
127 : DDListBox(vcl::Window* pParent, const WinBits nStyle);
128 : virtual ~DDListBox();
129 : virtual void dispose() SAL_OVERRIDE;
130 :
131 : void SetAddressDialog(SwCustomizeAddressBlockDialog *pParent);
132 :
133 : virtual void StartDrag( sal_Int8 nAction, const Point& rPosPixel ) SAL_OVERRIDE;
134 : };
135 :
136 : #define MOVE_ITEM_LEFT 1
137 : #define MOVE_ITEM_RIGHT 2
138 : #define MOVE_ITEM_UP 4
139 : #define MOVE_ITEM_DOWN 8
140 :
141 : class AddressMultiLineEdit : public VclMultiLineEdit, public SfxListener
142 : {
143 : Link<> m_aSelectionLink;
144 : VclPtr<SwCustomizeAddressBlockDialog> m_pParentDialog;
145 :
146 : using VclMultiLineEdit::Notify;
147 :
148 : using VclMultiLineEdit::SetText;
149 :
150 : protected:
151 : bool PreNotify( NotifyEvent& rNEvt ) SAL_OVERRIDE;
152 : public:
153 : AddressMultiLineEdit(vcl::Window* pParent, WinBits nWinStyle = WB_LEFT | WB_BORDER);
154 : virtual ~AddressMultiLineEdit();
155 : virtual void dispose() SAL_OVERRIDE;
156 :
157 : void SetAddressDialog(SwCustomizeAddressBlockDialog *pParent);
158 :
159 : virtual void Notify( SfxBroadcaster& rBC, const SfxHint& rHint ) SAL_OVERRIDE;
160 :
161 : virtual Size GetOptimalSize() const SAL_OVERRIDE;
162 :
163 0 : void SetSelectionChangedHdl( const Link<>& rLink ) {m_aSelectionLink = rLink;}
164 :
165 : void SetText( const OUString& rStr ) SAL_OVERRIDE;
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(sal_uInt16 nMove);
173 : sal_uInt16 IsCurrentItemMoveable();
174 : bool HasCurrentItem();
175 : OUString GetCurrentItem();
176 : void SelectCurrentItem();
177 : };
178 :
179 : class SwCustomizeAddressBlockDialog : public SfxModalDialog
180 : {
181 : friend class DDListBox;
182 : friend class AddressMultiLineEdit;
183 : public:
184 : enum DialogType
185 : {
186 : ADDRESSBLOCK_NEW,
187 : ADDRESSBLOCK_EDIT,
188 : GREETING_FEMALE,
189 : GREETING_MALE
190 : };
191 : private:
192 : VclPtr<FixedText> m_pAddressElementsFT;
193 : VclPtr<DDListBox> m_pAddressElementsLB;
194 :
195 : VclPtr<PushButton> m_pInsertFieldIB;
196 : VclPtr<PushButton> m_pRemoveFieldIB;
197 :
198 : VclPtr<FixedText> m_pDragFT;
199 : VclPtr<AddressMultiLineEdit> m_pDragED;
200 : VclPtr<PushButton> m_pUpIB;
201 : VclPtr<PushButton> m_pLeftIB;
202 : VclPtr<PushButton> m_pRightIB;
203 : VclPtr<PushButton> m_pDownIB;
204 :
205 : VclPtr<FixedText> m_pFieldFT;
206 : VclPtr<ComboBox> m_pFieldCB;
207 : TextFilter m_aTextFilter;
208 :
209 : VclPtr<SwAddressPreview> m_pPreviewWIN;
210 :
211 : VclPtr<OKButton> m_pOK;
212 :
213 : ::std::vector<OUString> m_aSalutations;
214 : ::std::vector<OUString> m_aPunctuations;
215 :
216 : OUString m_sCurrentSalutation;
217 : OUString m_sCurrentPunctuation;
218 : OUString m_sCurrentText;
219 :
220 : SwMailMergeConfigItem& m_rConfigItem;
221 : DialogType m_eType;
222 :
223 : DECL_LINK(OKHdl_Impl, void *);
224 : DECL_LINK(ListBoxSelectHdl_Impl, DDListBox*);
225 : DECL_LINK(EditModifyHdl_Impl, void *);
226 : DECL_LINK(ImageButtonHdl_Impl, ImageButton*);
227 : DECL_LINK(SelectionChangedHdl_Impl, AddressMultiLineEdit*);
228 : DECL_LINK(FieldChangeHdl_Impl, void *);
229 :
230 : bool HasItem_Impl(sal_Int32 nUserData);
231 : sal_Int32 GetSelectedItem_Impl();
232 : void UpdateImageButtons_Impl();
233 :
234 : public:
235 : SwCustomizeAddressBlockDialog(vcl::Window* pParent, SwMailMergeConfigItem& rConfig, DialogType);
236 : virtual ~SwCustomizeAddressBlockDialog();
237 : virtual void dispose() SAL_OVERRIDE;
238 :
239 : void SetAddress(const OUString& rAddress);
240 : OUString GetAddress();
241 : };
242 :
243 : class SwAssignFieldsControl;
244 : class SwAssignFieldsDialog : public SfxModalDialog
245 : {
246 : VclPtr<FixedText> m_pMatchingFI;
247 : VclPtr<SwAssignFieldsControl> m_pFieldsControl;
248 :
249 : VclPtr<FixedText> m_pPreviewFI;
250 : VclPtr<SwAddressPreview> m_pPreviewWIN;
251 :
252 : VclPtr<OKButton> m_pOK;
253 :
254 : OUString m_sNone;
255 : OUString m_rPreviewString;
256 :
257 : SwMailMergeConfigItem& m_rConfigItem;
258 :
259 : ::com::sun::star::uno::Sequence< OUString > CreateAssignments();
260 : DECL_LINK(OkHdl_Impl, void *);
261 : DECL_LINK(AssignmentModifyHdl_Impl, void*);
262 :
263 : public:
264 : SwAssignFieldsDialog(vcl::Window* pParent,
265 : SwMailMergeConfigItem& rConfigItem,
266 : const OUString& rPreview,
267 : bool bIsAddressBlock);
268 : virtual ~SwAssignFieldsDialog();
269 : virtual void dispose() SAL_OVERRIDE;
270 : };
271 : #endif
272 :
273 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|