1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: mmaddressblockpage.hxx,v $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
30 #ifndef _MAILMERGEADDRESSBLOCKPAGE_HXX
31 #define _MAILMERGEADDRESSBLOCKPAGE_HXX
33 #include <svtools/wizardmachine.hxx>
34 #ifndef _SV_BUTTON_HXX
35 #include <vcl/button.hxx>
37 #include <svtools/stdctrl.hxx>
38 #include <mailmergehelper.hxx>
39 #include <sfx2/basedlgs.hxx>
40 #include <vcl/edit.hxx>
41 #include <vcl/lstbox.hxx>
42 #include <svtools/svmedit.hxx>
43 #include <svtools/headbar.hxx>
44 #include <svtools/svtreebx.hxx>
45 #include <vcl/combobox.hxx>
46 #include <svtools/lstner.hxx>
47 class SwMailMergeWizard
;
48 class SwMailMergeConfigItem
;
49 /*-- 13.04.2004 15:50:37---------------------------------------------------
51 -----------------------------------------------------------------------*/
52 class SwMailMergeAddressBlockPage
: public svt::OWizardPage
54 SwBoldFixedInfo m_aHeaderFI
;
56 FixedInfo m_aAddressListFI
;
57 PushButton m_aAddressListPB
;
58 FixedInfo m_aCurrentAddressFI
;
62 FixedInfo m_aSecondFI
;
63 FixedInfo m_aSettingsFI
;
64 CheckBox m_aAddressCB
;
65 SwAddressPreview m_aSettingsWIN
;
66 PushButton m_aSettingsPB
;
68 CheckBox m_aHideEmptyParagraphsCB
;
70 FixedLine m_aSecondFL
;
73 FixedInfo m_aMatchFieldsFI
;
75 PushButton m_aAssignPB
;
79 FixedInfo m_aFourthFI
;
80 FixedInfo m_aPreviewFI
;
82 SwAddressPreview m_aPreviewWIN
;
83 FixedInfo m_aDocumentIndexFI
;
84 ImageButton m_aPrevSetIB
;
85 ImageButton m_aNextSetIB
;
88 String m_sCurrentAddress
;
89 String m_sChangeAddress
;
91 SwMailMergeWizard
* m_pWizard
;
93 DECL_LINK(AddressListHdl_Impl
, PushButton
*);
94 DECL_LINK(SettingsHdl_Impl
, PushButton
*);
95 DECL_LINK(AssignHdl_Impl
, PushButton
*);
96 DECL_LINK(AddressBlockHdl_Impl
, CheckBox
*);
97 DECL_LINK(InsertDataHdl_Impl
, ImageButton
*);
98 DECL_LINK(AddressBlockSelectHdl_Impl
, SwAddressPreview
*);
99 DECL_LINK(HideParagraphsHdl_Impl
, CheckBox
*);
101 void EnableAddressBlock(sal_Bool bAll
, sal_Bool bSelective
);
103 virtual void ActivatePage();
104 virtual sal_Bool
commitPage( CommitPageReason _eReason
);
105 virtual bool canAdvance() const;
108 SwMailMergeAddressBlockPage( SwMailMergeWizard
* _pParent
);
109 ~SwMailMergeAddressBlockPage();
111 SwMailMergeWizard
* GetWizard() { return m_pWizard
;}
113 /*-- 13.04.2004 15:45:31---------------------------------------------------
115 -----------------------------------------------------------------------*/
116 class SwSelectAddressBlockDialog
: public SfxModalDialog
118 FixedText m_aSelectFT
;
119 SwAddressPreview m_aPreview
;
121 PushButton m_aCustomizePB
;
122 PushButton m_aDeletePB
;
124 FixedInfo m_aSettingsFI
;
125 RadioButton m_aNeverRB
;
126 RadioButton m_aAlwaysRB
;
127 RadioButton m_aDependentRB
;
130 FixedLine m_aSeparatorFL
;
133 CancelButton m_aCancel
;
136 com::sun::star::uno::Sequence
< ::rtl::OUString
> m_aAddressBlocks
;
137 SwMailMergeConfigItem
& m_rConfig
;
139 DECL_LINK(NewCustomizeHdl_Impl
, PushButton
*);
140 DECL_LINK(DeleteHdl_Impl
, PushButton
*);
141 DECL_LINK(IncludeHdl_Impl
, RadioButton
*);
143 using Window::SetSettings
;
146 SwSelectAddressBlockDialog(Window
* pParent
, SwMailMergeConfigItem
& rConfig
);
147 ~SwSelectAddressBlockDialog();
149 void SetAddressBlocks(const com::sun::star::uno::Sequence
< ::rtl::OUString
>& rBlocks
,
150 sal_uInt16 nSelected
);
151 const com::sun::star::uno::Sequence
< ::rtl::OUString
>& GetAddressBlocks();
153 void SetSettings(sal_Bool bIsCountry
, ::rtl::OUString sCountry
);
154 sal_Bool
IsIncludeCountry() const {return !m_aNeverRB
.IsChecked();}
155 ::rtl::OUString
GetCountry() const;
159 /*-- 26.05.2004 11:16:25---------------------------------------------------
161 -----------------------------------------------------------------------*/
162 class SwCustomizeAddressBlockDialog
;
163 class DDListBox
: public SvTreeListBox
165 SwCustomizeAddressBlockDialog
* m_pParentDialog
;
167 DDListBox(SwCustomizeAddressBlockDialog
* pParent
, const ResId rResId
);
170 virtual void StartDrag( sal_Int8 nAction
, const Point
& rPosPixel
);
172 /*-- 26.05.2004 11:16:25---------------------------------------------------
174 -----------------------------------------------------------------------*/
175 #define MOVE_ITEM_LEFT 1
176 #define MOVE_ITEM_RIGHT 2
177 #define MOVE_ITEM_UP 4
178 #define MOVE_ITEM_DOWN 8
180 class AddressMultiLineEdit
: public MultiLineEdit
, public SfxListener
182 Link m_aSelectionLink
;
183 SwCustomizeAddressBlockDialog
* m_pParentDialog
;
185 using Window::Notify
;
187 using MultiLineEdit::SetText
;
190 long PreNotify( NotifyEvent
& rNEvt
);
192 AddressMultiLineEdit(SwCustomizeAddressBlockDialog
* pParent
, const ResId
& rResId
);
193 ~AddressMultiLineEdit();
195 virtual void Notify( SfxBroadcaster
& rBC
, const SfxHint
& rHint
);
197 void SetSelectionChangedHdl( const Link
& rLink
) {m_aSelectionLink
= rLink
;}
199 void SetText( const String
& rStr
);
202 void InsertNewEntry( const String
& rStr
);
203 void InsertNewEntryAtPosition( const String
& rStr
, ULONG nPara
, USHORT nIndex
);
204 void RemoveCurrentEntry();
206 void MoveCurrentItem(sal_uInt16 nMove
);
207 sal_uInt16
IsCurrentItemMoveable();
208 bool HasCurrentItem();
209 String
GetCurrentItem();
210 void SelectCurrentItem();
212 /*-- 13.04.2004 15:45:31---------------------------------------------------
213 Dialog is used to create custom address blocks as well as
214 custom greeting lines
215 -----------------------------------------------------------------------*/
216 class SwRestrictedComboBox
: public ComboBox
218 String sForbiddenChars
;
221 virtual void KeyInput( const KeyEvent
& );
222 virtual void Modify();
224 SwRestrictedComboBox(Window
* pParent
, const ResId
& rResId
):
225 ComboBox( pParent
, rResId
){}
227 ~SwRestrictedComboBox();
229 void SetForbiddenChars(const String
& rSet
){sForbiddenChars
= rSet
;}
232 class SwCustomizeAddressBlockDialog
: public SfxModalDialog
234 friend class DDListBox
;
235 friend class AddressMultiLineEdit
;
245 FixedText m_aAddressElementsFT
;
246 DDListBox m_aAddressElementsLB
;
248 ImageButton m_aInsertFieldIB
;
249 ImageButton m_aRemoveFieldIB
;
252 AddressMultiLineEdit m_aDragED
;
254 ImageButton m_aLeftIB
;
255 ImageButton m_aRightIB
;
256 ImageButton m_aDownIB
;
258 FixedText m_aFieldFT
;
259 SwRestrictedComboBox m_aFieldCB
;
261 FixedInfo m_aPreviewFI
;
262 SwAddressPreview m_aPreviewWIN
;
264 FixedLine m_aSeparatorFL
;
267 CancelButton m_aCancel
;
270 ::std::vector
<String
> m_aSalutations
;
271 ::std::vector
<String
> m_aPunctuations
;
273 String m_sCurrentSalutation
;
274 String m_sCurrentPunctuation
;
275 String m_sCurrentText
;
277 SwMailMergeConfigItem
& m_rConfigItem
;
280 DECL_LINK(OKHdl_Impl
, OKButton
*);
281 DECL_LINK(ListBoxSelectHdl_Impl
, DDListBox
*);
282 DECL_LINK(EditModifyHdl_Impl
, AddressMultiLineEdit
*);
283 DECL_LINK(ImageButtonHdl_Impl
, ImageButton
*);
284 DECL_LINK(SelectionChangedHdl_Impl
, AddressMultiLineEdit
*);
285 DECL_LINK(FieldChangeHdl_Impl
, ComboBox
*);
287 bool HasItem_Impl(sal_Int32 nUserData
);
288 sal_Int32
GetSelectedItem_Impl();
289 void UpdateImageButtons_Impl();
290 void MoveFocus( Window
* pMember
, bool bNext
);
293 SwCustomizeAddressBlockDialog(Window
* pParent
, SwMailMergeConfigItem
& rConfig
, DialogType
);
294 ~SwCustomizeAddressBlockDialog();
296 void SetAddress(const ::rtl::OUString
& rAddress
);
297 ::rtl::OUString
GetAddress();
299 /*-- 13.04.2004 17:41:11---------------------------------------------------
301 -----------------------------------------------------------------------*/
302 class SwAssignFieldsControl
;
303 class SwAssignFieldsDialog
: public SfxModalDialog
305 FixedInfo m_aMatchingFI
;
306 SwAssignFieldsControl
* m_pFieldsControl
;
308 FixedInfo m_aPreviewFI
;
309 SwAddressPreview m_aPreviewWIN
;
311 FixedLine m_aSeparatorFL
;
314 CancelButton m_aCancel
;
318 ::rtl::OUString m_rPreviewString
;
320 SwMailMergeConfigItem
& m_rConfigItem
;
322 ::com::sun::star::uno::Sequence
< ::rtl::OUString
> CreateAssignments();
323 DECL_LINK(OkHdl_Impl
, PushButton
*);
324 DECL_LINK(AssignmentModifyHdl_Impl
, void*);
327 SwAssignFieldsDialog(Window
* pParent
,
328 SwMailMergeConfigItem
& rConfigItem
,
329 const ::rtl::OUString
& rPreview
,
330 bool bIsAddressBlock
);
331 ~SwAssignFieldsDialog();