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