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