Branch data Line data Source code
1 : : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 : : /*************************************************************************
3 : : *
4 : : * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 : : *
6 : : * Copyright 2000, 2010 Oracle and/or its affiliates.
7 : : *
8 : : * OpenOffice.org - a multi-platform office productivity suite
9 : : *
10 : : * This file is part of OpenOffice.org.
11 : : *
12 : : * OpenOffice.org is free software: you can redistribute it and/or modify
13 : : * it under the terms of the GNU Lesser General Public License version 3
14 : : * only, as published by the Free Software Foundation.
15 : : *
16 : : * OpenOffice.org is distributed in the hope that it will be useful,
17 : : * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 : : * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 : : * GNU Lesser General Public License version 3 for more details
20 : : * (a copy is included in the LICENSE file that accompanied this code).
21 : : *
22 : : * You should have received a copy of the GNU Lesser General Public License
23 : : * version 3 along with OpenOffice.org. If not, see
24 : : * <http://www.openoffice.org/license.html>
25 : : * for a copy of the LGPLv3 License.
26 : : *
27 : : ************************************************************************/
28 : : #ifndef _MAILMERGEADDRESSBLOCKPAGE_HXX
29 : : #define _MAILMERGEADDRESSBLOCKPAGE_HXX
30 : :
31 : : #include <svtools/wizardmachine.hxx>
32 : : #include <vcl/button.hxx>
33 : : #include <svtools/stdctrl.hxx>
34 : : #include <mailmergehelper.hxx>
35 : : #include <sfx2/basedlgs.hxx>
36 : : #include <vcl/edit.hxx>
37 : : #include <vcl/lstbox.hxx>
38 : : #include <svtools/svmedit.hxx>
39 : : #include <svtools/headbar.hxx>
40 : : #include <svtools/svtreebx.hxx>
41 : : #include <vcl/combobox.hxx>
42 : : #include <svl/lstner.hxx>
43 : : class SwMailMergeWizard;
44 : : class SwMailMergeConfigItem;
45 : :
46 : : class SwMailMergeAddressBlockPage : public svt::OWizardPage
47 : : {
48 : : SwBoldFixedInfo m_aHeaderFI;
49 : : FixedInfo m_aFirstFI;
50 : : FixedInfo m_aAddressListFI;
51 : : PushButton m_aAddressListPB;
52 : : FixedInfo m_aCurrentAddressFI;
53 : :
54 : : FixedLine m_aFirstFL;
55 : :
56 : : FixedInfo m_aSecondFI;
57 : : FixedInfo m_aSettingsFI;
58 : : CheckBox m_aAddressCB;
59 : : SwAddressPreview m_aSettingsWIN;
60 : : PushButton m_aSettingsPB;
61 : :
62 : : CheckBox m_aHideEmptyParagraphsCB;
63 : :
64 : : FixedLine m_aSecondFL;
65 : :
66 : : FixedInfo m_aThirdFI;
67 : : FixedInfo m_aMatchFieldsFI;
68 : :
69 : : PushButton m_aAssignPB;
70 : :
71 : : FixedLine m_aThirdFL;
72 : :
73 : : FixedInfo m_aFourthFI;
74 : : FixedInfo m_aPreviewFI;
75 : :
76 : : SwAddressPreview m_aPreviewWIN;
77 : : FixedInfo m_aDocumentIndexFI;
78 : : ImageButton m_aPrevSetIB;
79 : : ImageButton m_aNextSetIB;
80 : :
81 : : String m_sDocument;
82 : : String m_sCurrentAddress;
83 : : String m_sChangeAddress;
84 : :
85 : : SwMailMergeWizard* m_pWizard;
86 : :
87 : : DECL_LINK(AddressListHdl_Impl, void *);
88 : : DECL_LINK(SettingsHdl_Impl, PushButton*);
89 : : DECL_LINK(AssignHdl_Impl, PushButton*);
90 : : DECL_LINK(AddressBlockHdl_Impl, CheckBox*);
91 : : DECL_LINK(InsertDataHdl_Impl, ImageButton*);
92 : : DECL_LINK(AddressBlockSelectHdl_Impl, void *);
93 : : DECL_LINK(HideParagraphsHdl_Impl, CheckBox*);
94 : :
95 : : void EnableAddressBlock(sal_Bool bAll, sal_Bool bSelective);
96 : :
97 : : virtual void ActivatePage();
98 : : virtual sal_Bool commitPage( ::svt::WizardTypes::CommitPageReason _eReason );
99 : : virtual bool canAdvance() const;
100 : :
101 : : public:
102 : : SwMailMergeAddressBlockPage( SwMailMergeWizard* _pParent);
103 : : ~SwMailMergeAddressBlockPage();
104 : :
105 : 0 : SwMailMergeWizard* GetWizard() { return m_pWizard;}
106 : : };
107 : :
108 : : class SwSelectAddressBlockDialog : public SfxModalDialog
109 : : {
110 : : FixedText m_aSelectFT;
111 : : SwAddressPreview m_aPreview;
112 : : PushButton m_aNewPB;
113 : : PushButton m_aCustomizePB;
114 : : PushButton m_aDeletePB;
115 : :
116 : : FixedInfo m_aSettingsFI;
117 : : RadioButton m_aNeverRB;
118 : : RadioButton m_aAlwaysRB;
119 : : RadioButton m_aDependentRB;
120 : : Edit m_aCountryED;
121 : :
122 : : FixedLine m_aSeparatorFL;
123 : :
124 : : OKButton m_aOK;
125 : : CancelButton m_aCancel;
126 : : HelpButton m_aHelp;
127 : :
128 : : com::sun::star::uno::Sequence< ::rtl::OUString> m_aAddressBlocks;
129 : : SwMailMergeConfigItem& m_rConfig;
130 : :
131 : : DECL_LINK(NewCustomizeHdl_Impl, PushButton*);
132 : : DECL_LINK(DeleteHdl_Impl, PushButton*);
133 : : DECL_LINK(IncludeHdl_Impl, RadioButton*);
134 : :
135 : : using Window::SetSettings;
136 : :
137 : : public:
138 : : SwSelectAddressBlockDialog(Window* pParent, SwMailMergeConfigItem& rConfig);
139 : : ~SwSelectAddressBlockDialog();
140 : :
141 : : void SetAddressBlocks(const com::sun::star::uno::Sequence< ::rtl::OUString>& rBlocks,
142 : : sal_uInt16 nSelected);
143 : : const com::sun::star::uno::Sequence< ::rtl::OUString>& GetAddressBlocks();
144 : :
145 : : void SetSettings(sal_Bool bIsCountry, ::rtl::OUString sCountry);
146 : 0 : sal_Bool IsIncludeCountry() const {return !m_aNeverRB.IsChecked();}
147 : : ::rtl::OUString GetCountry() const;
148 : : };
149 : :
150 : : class SwCustomizeAddressBlockDialog;
151 : : class DDListBox : public SvTreeListBox
152 : : {
153 : : SwCustomizeAddressBlockDialog* m_pParentDialog;
154 : : public:
155 : : DDListBox(SwCustomizeAddressBlockDialog* pParent, const ResId rResId);
156 : : ~DDListBox();
157 : :
158 : : virtual void StartDrag( sal_Int8 nAction, const Point& rPosPixel );
159 : : };
160 : :
161 : : #define MOVE_ITEM_LEFT 1
162 : : #define MOVE_ITEM_RIGHT 2
163 : : #define MOVE_ITEM_UP 4
164 : : #define MOVE_ITEM_DOWN 8
165 : :
166 : : class AddressMultiLineEdit : public MultiLineEdit, public SfxListener
167 : : {
168 : : Link m_aSelectionLink;
169 : : SwCustomizeAddressBlockDialog* m_pParentDialog;
170 : :
171 : : using MultiLineEdit::Notify;
172 : :
173 : : using MultiLineEdit::SetText;
174 : :
175 : : protected:
176 : : long PreNotify( NotifyEvent& rNEvt );
177 : : public:
178 : : AddressMultiLineEdit(SwCustomizeAddressBlockDialog* pParent, const ResId& rResId);
179 : : ~AddressMultiLineEdit();
180 : :
181 : : virtual void Notify( SfxBroadcaster& rBC, const SfxHint& rHint );
182 : :
183 : 0 : void SetSelectionChangedHdl( const Link& rLink ) {m_aSelectionLink = rLink;}
184 : :
185 : : void SetText( const String& rStr );
186 : : String GetAddress();
187 : :
188 : : void InsertNewEntry( const String& rStr );
189 : : void InsertNewEntryAtPosition( const String& rStr, sal_uLong nPara, sal_uInt16 nIndex );
190 : : void RemoveCurrentEntry();
191 : :
192 : : void MoveCurrentItem(sal_uInt16 nMove);
193 : : sal_uInt16 IsCurrentItemMoveable();
194 : : bool HasCurrentItem();
195 : : String GetCurrentItem();
196 : : void SelectCurrentItem();
197 : : };
198 : :
199 : : // Dialog is used to create custom address blocks as well as custom greeting lines
200 : : class SwRestrictedComboBox : public ComboBox
201 : : {
202 : : String sForbiddenChars;
203 : :
204 : : protected:
205 : : virtual void KeyInput( const KeyEvent& );
206 : : virtual void Modify();
207 : : public:
208 : 0 : SwRestrictedComboBox(Window* pParent, const ResId& rResId):
209 : 0 : ComboBox( pParent, rResId ){}
210 : :
211 : : ~SwRestrictedComboBox();
212 : :
213 : 0 : void SetForbiddenChars(const String& rSet){sForbiddenChars = rSet;}
214 : :
215 : : };
216 : : class SwCustomizeAddressBlockDialog : public SfxModalDialog
217 : : {
218 : : friend class DDListBox;
219 : : friend class AddressMultiLineEdit;
220 : : public:
221 : : enum DialogType
222 : : {
223 : : ADDRESSBLOCK_NEW,
224 : : ADDRESSBLOCK_EDIT,
225 : : GREETING_FEMALE,
226 : : GREETING_MALE
227 : : };
228 : : private:
229 : : FixedText m_aAddressElementsFT;
230 : : DDListBox m_aAddressElementsLB;
231 : :
232 : : ImageButton m_aInsertFieldIB;
233 : : ImageButton m_aRemoveFieldIB;
234 : :
235 : : FixedText m_aDragFT;
236 : : AddressMultiLineEdit m_aDragED;
237 : : ImageButton m_aUpIB;
238 : : ImageButton m_aLeftIB;
239 : : ImageButton m_aRightIB;
240 : : ImageButton m_aDownIB;
241 : :
242 : : FixedText m_aFieldFT;
243 : : SwRestrictedComboBox m_aFieldCB;
244 : :
245 : : FixedInfo m_aPreviewFI;
246 : : SwAddressPreview m_aPreviewWIN;
247 : :
248 : : FixedLine m_aSeparatorFL;
249 : :
250 : : OKButton m_aOK;
251 : : CancelButton m_aCancel;
252 : : HelpButton m_aHelp;
253 : :
254 : : ::std::vector<String> m_aSalutations;
255 : : ::std::vector<String> m_aPunctuations;
256 : :
257 : : String m_sCurrentSalutation;
258 : : String m_sCurrentPunctuation;
259 : : String m_sCurrentText;
260 : :
261 : : SwMailMergeConfigItem& m_rConfigItem;
262 : : DialogType m_eType;
263 : :
264 : : DECL_LINK(OKHdl_Impl, void *);
265 : : DECL_LINK(ListBoxSelectHdl_Impl, DDListBox*);
266 : : DECL_LINK(EditModifyHdl_Impl, void *);
267 : : DECL_LINK(ImageButtonHdl_Impl, ImageButton*);
268 : : DECL_LINK(SelectionChangedHdl_Impl, AddressMultiLineEdit*);
269 : : DECL_LINK(FieldChangeHdl_Impl, void *);
270 : :
271 : : bool HasItem_Impl(sal_Int32 nUserData);
272 : : sal_Int32 GetSelectedItem_Impl();
273 : : void UpdateImageButtons_Impl();
274 : : void MoveFocus( Window* pMember, bool bNext );
275 : :
276 : : public:
277 : : SwCustomizeAddressBlockDialog(Window* pParent, SwMailMergeConfigItem& rConfig, DialogType);
278 : : ~SwCustomizeAddressBlockDialog();
279 : :
280 : : void SetAddress(const ::rtl::OUString& rAddress);
281 : : ::rtl::OUString GetAddress();
282 : : };
283 : :
284 : : class SwAssignFieldsControl;
285 : : class SwAssignFieldsDialog : public SfxModalDialog
286 : : {
287 : : FixedInfo m_aMatchingFI;
288 : : SwAssignFieldsControl* m_pFieldsControl;
289 : :
290 : : FixedInfo m_aPreviewFI;
291 : : SwAddressPreview m_aPreviewWIN;
292 : :
293 : : FixedLine m_aSeparatorFL;
294 : :
295 : : OKButton m_aOK;
296 : : CancelButton m_aCancel;
297 : : HelpButton m_aHelp;
298 : :
299 : : String m_sNone;
300 : : ::rtl::OUString m_rPreviewString;
301 : :
302 : : SwMailMergeConfigItem& m_rConfigItem;
303 : :
304 : : ::com::sun::star::uno::Sequence< ::rtl::OUString > CreateAssignments();
305 : : DECL_LINK(OkHdl_Impl, void *);
306 : : DECL_LINK(AssignmentModifyHdl_Impl, void*);
307 : :
308 : : public:
309 : : SwAssignFieldsDialog(Window* pParent,
310 : : SwMailMergeConfigItem& rConfigItem,
311 : : const ::rtl::OUString& rPreview,
312 : : bool bIsAddressBlock);
313 : : ~SwAssignFieldsDialog();
314 : : };
315 : : #endif
316 : :
317 : :
318 : : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|