Update ooo320-m1
[ooovba.git] / sfx2 / inc / sfx2 / dinfdlg.hxx
blobc8adeee9ba67d87adfb146ef922ab4f90f6fb9b7
1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: dinfdlg.hxx,v $
10 * $Revision: 1.7 $
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 _SFX_DINFDLG_HXX
31 #define _SFX_DINFDLG_HXX
33 #include "sal/config.h"
34 #include "sfx2/dllapi.h"
36 #include <com/sun/star/util/DateTime.hpp>
37 #include <vcl/edit.hxx>
38 #include <vcl/field.hxx>
39 #include <svtools/stdctrl.hxx>
40 #include <svtools/stritem.hxx>
41 #include <svtools/svmedit.hxx>
43 #include <vcl/edit.hxx>
44 #include <vcl/lstbox.hxx>
45 #include <vcl/scrbar.hxx>
46 #include <svtools/headbar.hxx>
47 #include <svtools/syslocale.hxx>
48 #include <svtools/zforlist.hxx>
50 #include "tabdlg.hxx"
52 namespace com { namespace sun { namespace star {
53 namespace document {
54 class XDocumentProperties;
56 } } }
58 struct CustomProperty;
61 // class SfxDocumentInfoItem ---------------------------------------------
63 class SFX2_DLLPUBLIC SfxDocumentInfoItem : public SfxStringItem
65 private:
66 sal_Int32 m_AutoloadDelay;
67 ::rtl::OUString m_AutoloadURL;
68 sal_Bool m_isAutoloadEnabled;
69 ::rtl::OUString m_DefaultTarget;
70 ::rtl::OUString m_TemplateName;
71 ::rtl::OUString m_Author;
72 ::com::sun::star::util::DateTime m_CreationDate;
73 ::rtl::OUString m_ModifiedBy;
74 ::com::sun::star::util::DateTime m_ModificationDate;
75 ::rtl::OUString m_PrintedBy;
76 ::com::sun::star::util::DateTime m_PrintDate;
77 sal_Int16 m_EditingCycles;
78 sal_Int32 m_EditingDuration;
79 ::rtl::OUString m_Description;
80 ::rtl::OUString m_Keywords;
81 ::rtl::OUString m_Subject;
82 ::rtl::OUString m_Title;
83 sal_Bool m_bHasTemplate;
84 sal_Bool m_bDeleteUserData;
85 sal_Bool m_bUseUserData;
86 std::vector< CustomProperty* > m_aCustomProperties;
88 public:
89 TYPEINFO();
90 SfxDocumentInfoItem();
91 SfxDocumentInfoItem( const String &rFileName,
92 const ::com::sun::star::uno::Reference<
93 ::com::sun::star::document::XDocumentProperties> & i_xDocProps,
94 sal_Bool bUseUserData );
95 SfxDocumentInfoItem( const SfxDocumentInfoItem& );
96 virtual ~SfxDocumentInfoItem();
98 /// update i_xDocProps with the data in this object
99 void UpdateDocumentInfo(
100 const ::com::sun::star::uno::Reference<
101 ::com::sun::star::document::XDocumentProperties> & i_xDocProps,
102 bool i_bDoNotUpdateUserDefined = false)
103 const;
105 sal_Bool isAutoloadEnabled() const { return m_isAutoloadEnabled; }
106 void setAutoloadEnabled(sal_Bool i_val) { m_isAutoloadEnabled = i_val; }
107 sal_Int32 getAutoloadDelay() const { return m_AutoloadDelay; }
108 void setAutoloadDelay(sal_Int32 i_val) { m_AutoloadDelay = i_val; }
109 ::rtl::OUString getAutoloadURL() const { return m_AutoloadURL; }
110 void setAutoloadURL(::rtl::OUString i_val) { m_AutoloadURL = i_val; }
111 ::rtl::OUString getDefaultTarget() const { return m_DefaultTarget; }
112 void setDefaultTarget(::rtl::OUString i_val) { m_DefaultTarget = i_val; }
113 ::rtl::OUString getTemplateName() const { return m_TemplateName; }
114 void setTemplateName(::rtl::OUString i_val) { m_TemplateName = i_val; }
115 ::rtl::OUString getAuthor() const { return m_Author; }
116 void setAuthor(::rtl::OUString i_val) { m_Author = i_val; }
118 ::com::sun::star::util::DateTime
119 getCreationDate() const { return m_CreationDate; }
120 void setCreationDate(::com::sun::star::util::DateTime i_val) {
121 m_CreationDate = i_val;
123 ::rtl::OUString getModifiedBy() const { return m_ModifiedBy; }
124 void setModifiedBy(::rtl::OUString i_val) { m_ModifiedBy = i_val; }
126 ::com::sun::star::util::DateTime
127 getModificationDate() const { return m_ModificationDate; }
128 void setModificationDate(::com::sun::star::util::DateTime i_val) {
129 m_ModificationDate = i_val;
131 ::rtl::OUString getPrintedBy() const { return m_PrintedBy; }
132 void setPrintedBy(::rtl::OUString i_val) { m_PrintedBy = i_val; }
133 ::com::sun::star::util::DateTime
134 getPrintDate() const { return m_PrintDate; }
135 void setPrintDate(::com::sun::star::util::DateTime i_val) {
136 m_PrintDate = i_val;
138 sal_Int16 getEditingCycles() const { return m_EditingCycles; }
139 void setEditingCycles(sal_Int16 i_val) { m_EditingCycles = i_val; }
140 sal_Int32 getEditingDuration() const { return m_EditingDuration; }
141 void setEditingDuration(sal_Int32 i_val) { m_EditingDuration = i_val; }
142 ::rtl::OUString getDescription() const { return m_Description; }
143 void setDescription(::rtl::OUString i_val) { m_Description = i_val; }
144 ::rtl::OUString getKeywords() const { return m_Keywords; }
145 void setKeywords(::rtl::OUString i_val) { m_Keywords = i_val; }
146 ::rtl::OUString getSubject() const { return m_Subject; }
147 void setSubject(::rtl::OUString i_val) { m_Subject = i_val; }
148 ::rtl::OUString getTitle() const { return m_Title; }
149 void setTitle(::rtl::OUString i_val) { m_Title = i_val; }
151 /// reset user-specific data (author, modified-by, ...)
152 void resetUserData(const ::rtl::OUString & i_rAuthor);
154 void SetTemplate( sal_Bool b ) { m_bHasTemplate = b; }
155 sal_Bool HasTemplate() const { return m_bHasTemplate; }
156 void SetDeleteUserData( sal_Bool bSet );
157 void SetUseUserData( sal_Bool bSet );
158 sal_Bool IsDeleteUserData() const;
159 sal_Bool IsUseUserData() const;
161 std::vector< CustomProperty* > GetCustomProperties() const;
162 void ClearCustomProperties();
163 void AddCustomProperty( const ::rtl::OUString& sName,
164 const com::sun::star::uno::Any& rValue );
166 virtual SfxPoolItem* Clone( SfxItemPool* pPool = NULL ) const;
167 virtual int operator==( const SfxPoolItem& ) const;
168 virtual sal_Bool QueryValue( com::sun::star::uno::Any& rVal, BYTE nMemberId = 0 ) const;
169 virtual sal_Bool PutValue( const com::sun::star::uno::Any& rVal, BYTE nMemberId = 0 );
172 // class SfxDocumentPage -------------------------------------------------
174 class SfxDocumentPage : public SfxTabPage
176 private:
177 FixedImage aBmp1;
178 Edit aNameED;
179 PushButton aChangePassBtn;
181 FixedLine aLine1FL;
182 FixedText aTypeFT;
183 svt::SelectableFixedText aShowTypeFT;
184 CheckBox aReadOnlyCB;
185 FixedText aFileFt;
186 svt::SelectableFixedText aFileValFt;
187 FixedText aSizeFT;
188 svt::SelectableFixedText aShowSizeFT;
190 FixedLine aLine2FL;
191 FixedText aCreateFt;
192 svt::SelectableFixedText aCreateValFt;
193 FixedText aChangeFt;
194 svt::SelectableFixedText aChangeValFt;
195 FixedText aSignedFt;
196 svt::SelectableFixedText aSignedValFt;
197 PushButton aSignatureBtn;
198 FixedText aPrintFt;
199 svt::SelectableFixedText aPrintValFt;
200 FixedText aTimeLogFt;
201 svt::SelectableFixedText aTimeLogValFt;
202 FixedText aDocNoFt;
203 svt::SelectableFixedText aDocNoValFt;
204 CheckBox aUseUserDataCB;
205 PushButton aDeleteBtn;
207 FixedLine aLine3FL;
208 FixedText aTemplFt;
209 svt::SelectableFixedText aTemplValFt;
211 String aUnknownSize;
212 String aMultiSignedStr;
214 BOOL bEnableUseUserData : 1,
215 bHandleDelete : 1;
217 DECL_LINK( DeleteHdl, PushButton * );
218 DECL_LINK( SignatureHdl, PushButton * );
219 DECL_LINK( ChangePassHdl, PushButton * );
220 void ImplUpdateSignatures();
221 void ImplCheckPasswordState();
223 protected:
224 SfxDocumentPage( Window* pParent, const SfxItemSet& );
226 virtual BOOL FillItemSet( SfxItemSet& );
227 virtual void Reset( const SfxItemSet& );
229 public:
230 static SfxTabPage* Create( Window* pParent, const SfxItemSet& );
232 void EnableUseUserData();
235 // class SfxDocumentDescPage ---------------------------------------------
237 class SfxDocumentDescPage : public SfxTabPage
239 private:
240 FixedText aTitleFt;
241 Edit aTitleEd;
242 FixedText aThemaFt;
243 Edit aThemaEd;
244 FixedText aKeywordsFt;
245 Edit aKeywordsEd;
246 FixedText aCommentFt;
247 MultiLineEdit aCommentEd;
248 SfxDocumentInfoItem* pInfoItem;
250 protected:
251 SfxDocumentDescPage( Window* pParent, const SfxItemSet& );
253 virtual BOOL FillItemSet( SfxItemSet& );
254 virtual void Reset( const SfxItemSet& );
256 public:
257 static SfxTabPage* Create( Window* pParent, const SfxItemSet& );
260 // class SfxInternetPage -------------------------------------------------
262 class TargetList;
263 namespace sfx2
265 class FileDialogHelper;
268 class SfxInternetPage : public SfxTabPage
270 private:
271 RadioButton aRBNoAutoUpdate;
272 RadioButton aRBReloadUpdate;
273 RadioButton aRBForwardUpdate;
275 FixedText aFTEvery;
276 NumericField aNFReload;
277 FixedText aFTReloadSeconds;
279 FixedText aFTAfter;
280 NumericField aNFAfter;
281 FixedText aFTAfterSeconds;
282 FixedText aFTURL;
283 Edit aEDForwardURL;
284 PushButton aPBBrowseURL;
285 FixedText aFTFrame;
286 ComboBox aCBFrame;
288 String aForwardErrorMessg;
289 String aBaseURL;
290 SfxDocumentInfoItem* pInfoItem;
291 sfx2::FileDialogHelper* pFileDlg;
293 enum STATE { S_Init, S_NoUpdate, S_Reload, S_Forward };
294 // S_Init is only valid as initial value
295 STATE eState;
297 void ChangeState( STATE eNewState ); // S_Init is not a valid value here
298 // also checks corresponding radiobutton
299 void EnableNoUpdate( BOOL bEnable );
300 void EnableReload( BOOL bEnable );
301 void EnableForward( BOOL bEnable );
303 DECL_LINK( ClickHdlNoUpdate, Control* );
304 DECL_LINK( ClickHdlReload, Control* );
305 DECL_LINK( ClickHdlForward, Control* );
306 DECL_LINK( ClickHdlBrowseURL, PushButton* );
307 DECL_LINK( DialogClosedHdl, sfx2::FileDialogHelper* );
309 using TabPage::DeactivatePage;
311 protected:
312 SfxInternetPage( Window* pParent, const SfxItemSet& );
313 ~SfxInternetPage();
315 virtual BOOL FillItemSet( SfxItemSet& );
316 virtual void Reset( const SfxItemSet& );
317 virtual int DeactivatePage( SfxItemSet* pSet = 0 );
319 public:
320 static SfxTabPage* Create( Window* pParent, const SfxItemSet& );
323 // class SfxDocumentInfoDialog -------------------------------------------
325 class SFX2_DLLPUBLIC SfxDocumentInfoDialog : public SfxTabDialog
327 protected:
328 virtual void PageCreated( USHORT nId, SfxTabPage& rPage );
330 public:
331 SfxDocumentInfoDialog( Window* pParent, const SfxItemSet& );
334 // class CustomPropertiesRemoveButton ------------------------------------
336 struct CustomPropertyLine;
338 class CustomPropertiesEdit : public Edit
340 private:
341 CustomPropertyLine* m_pLine;
343 public:
344 inline CustomPropertiesEdit(
345 Window* pParent, const ResId& rResId, CustomPropertyLine* pLine ) :
346 Edit( pParent, rResId ), m_pLine( pLine ) {}
348 inline CustomPropertyLine* GetLine() const { return m_pLine; }
351 class CustomPropertiesTypeBox : public ListBox
353 private:
354 CustomPropertyLine* m_pLine;
356 public:
357 inline CustomPropertiesTypeBox(
358 Window* pParent, const ResId& rResId, CustomPropertyLine* pLine ) :
359 ListBox( pParent, rResId ), m_pLine( pLine ) {}
361 inline CustomPropertyLine* GetLine() const { return m_pLine; }
364 class CustomPropertiesRemoveButton : public ImageButton
366 private:
367 CustomPropertyLine* m_pLine;
369 public:
370 inline CustomPropertiesRemoveButton(
371 Window* pParent, const ResId& rResId, CustomPropertyLine* pLine ) :
372 ImageButton( pParent, rResId ), m_pLine( pLine ) {}
374 inline CustomPropertyLine* GetLine() const { return m_pLine; }
377 class CustomPropertiesYesNoButton : public Control
379 private:
380 RadioButton m_aYesButton;
381 RadioButton m_aNoButton;
383 public:
384 CustomPropertiesYesNoButton( Window* pParent, const ResId& rResId );
386 virtual void Resize();
388 inline void CheckYes() { m_aYesButton.Check(); }
389 inline void CheckNo() { m_aNoButton.Check(); }
390 inline bool IsYesChecked() const { return m_aYesButton.IsChecked() != FALSE; }
393 // struct CustomPropertyLine ---------------------------------------------
395 struct CustomPropertyLine
397 ComboBox m_aNameBox;
398 CustomPropertiesTypeBox m_aTypeBox;
399 CustomPropertiesEdit m_aValueEdit;
400 CustomPropertiesYesNoButton m_aYesNoButton;
401 CustomPropertiesRemoveButton m_aRemoveButton;
403 bool m_bIsRemoved;
404 bool m_bTypeLostFocus;
406 CustomPropertyLine( Window* pParent );
408 void SetRemoved();
411 // class CustomPropertiesWindow ------------------------------------------
413 class CustomPropertiesWindow : public Window
415 private:
416 ComboBox m_aNameBox;
417 ListBox m_aTypeBox;
418 Edit m_aValueEdit;
419 CustomPropertiesYesNoButton m_aYesNoButton;
420 ImageButton m_aRemoveButton;
422 sal_Int32 m_nLineHeight;
423 sal_Int32 m_nScrollPos;
424 SvtSysLocale m_aSysLocale;
425 std::vector< CustomPropertyLine* > m_aCustomPropertiesLines;
426 CustomPropertyLine* m_pCurrentLine;
427 SvNumberFormatter m_aNumberFormatter;
428 Timer m_aEditLoseFocusTimer;
429 Timer m_aBoxLoseFocusTimer;
430 Link m_aRemovedHdl;
432 DECL_LINK( TypeHdl, CustomPropertiesTypeBox* );
433 DECL_LINK( RemoveHdl, CustomPropertiesRemoveButton* );
434 DECL_LINK( EditLoseFocusHdl, CustomPropertiesEdit* );
435 DECL_LINK( BoxLoseFocusHdl, CustomPropertiesTypeBox* );
436 DECL_LINK( EditTimeoutHdl, Timer* );
437 DECL_LINK( BoxTimeoutHdl, Timer* );
439 bool IsLineValid( CustomPropertyLine* pLine ) const;
440 void ValidateLine( CustomPropertyLine* pLine, bool bIsFromTypeBox );
442 public:
443 CustomPropertiesWindow( Window* pParent, const ResId& rResId );
444 ~CustomPropertiesWindow();
446 void InitControls( HeaderBar* pHeaderBar, const ScrollBar* pScrollBar );
447 USHORT GetVisibleLineCount() const;
448 inline sal_Int32 GetLineHeight() const { return m_nLineHeight; }
449 void AddLine( const ::rtl::OUString& sName, com::sun::star::uno::Any& rAny );
450 bool AreAllLinesValid() const;
451 void ClearAllLines();
452 void DoScroll( sal_Int32 nNewPos );
454 bool DoesCustomPropertyExist( const String& rName ) const;
455 ::com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyValue >
456 GetCustomProperties() const;
457 void SetRemovedHdl( const Link& rLink ) { m_aRemovedHdl = rLink; }
460 // class CustomPropertiesControl -----------------------------------------
462 class CustomPropertiesControl : public Control
464 private:
465 HeaderBar m_aHeaderBar;
466 CustomPropertiesWindow m_aPropertiesWin;
467 ScrollBar m_aVertScroll;
469 bool m_bIsInitialized;
470 sal_Int32 m_nThumbPos;
472 void Initialize();
474 DECL_LINK( ScrollHdl, ScrollBar* );
475 DECL_LINK( RemovedHdl, void* );
477 public:
478 CustomPropertiesControl( Window* pParent, const ResId& rResId );
479 ~CustomPropertiesControl();
481 void AddLine( const ::rtl::OUString& sName, com::sun::star::uno::Any& rAny, bool bInteractive );
483 inline bool AreAllLinesValid() const { return m_aPropertiesWin.AreAllLinesValid(); }
484 inline void ClearAllLines() { m_aPropertiesWin.ClearAllLines(); }
485 inline bool DoesCustomPropertyExist( const String& rName ) const
486 { return m_aPropertiesWin.DoesCustomPropertyExist( rName ); }
487 inline ::com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyValue >
488 GetCustomProperties() const
489 { return m_aPropertiesWin.GetCustomProperties(); }
492 // class SfxCustomPropertiesPage -----------------------------------------
494 class SfxCustomPropertiesPage : public SfxTabPage
496 private:
497 FixedText m_aPropertiesFT;
498 CustomPropertiesControl m_aPropertiesCtrl;
499 PushButton m_aAddBtn;
501 DECL_LINK( AddHdl, PushButton* );
503 using TabPage::DeactivatePage;
505 protected:
506 SfxCustomPropertiesPage( Window* pParent, const SfxItemSet& );
508 virtual BOOL FillItemSet( SfxItemSet& );
509 virtual void Reset( const SfxItemSet& );
510 virtual int DeactivatePage( SfxItemSet* pSet = NULL );
512 public:
513 static SfxTabPage* Create( Window* pParent, const SfxItemSet& );
516 #endif // #ifndef _SFX_DINFDLG_HXX