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 _SFX_DINFDLG_HXX
20 : #define _SFX_DINFDLG_HXX
21 :
22 : #include "sal/config.h"
23 : #include "sfx2/dllapi.h"
24 :
25 : #include <com/sun/star/util/DateTime.hpp>
26 : #include <vcl/edit.hxx>
27 : #include <vcl/field.hxx>
28 : #include <svtools/stdctrl.hxx>
29 : #include <svl/stritem.hxx>
30 : #include <svtools/svmedit.hxx>
31 :
32 : #include <vcl/lstbox.hxx>
33 : #include <vcl/scrbar.hxx>
34 : #include <svtools/headbar.hxx>
35 : #include <unotools/syslocale.hxx>
36 : #include <svl/zforlist.hxx>
37 : #include <com/sun/star/util/Duration.hpp>
38 : #include "tabdlg.hxx"
39 :
40 : namespace com { namespace sun { namespace star {
41 : namespace document {
42 : class XDocumentProperties;
43 : }
44 : } } }
45 :
46 : struct CustomProperty;
47 :
48 :
49 : // class SfxDocumentInfoItem ---------------------------------------------
50 :
51 : class SFX2_DLLPUBLIC SfxDocumentInfoItem : public SfxStringItem
52 : {
53 : private:
54 : sal_Int32 m_AutoloadDelay;
55 : ::rtl::OUString m_AutoloadURL;
56 : sal_Bool m_isAutoloadEnabled;
57 : ::rtl::OUString m_DefaultTarget;
58 : ::rtl::OUString m_TemplateName;
59 : ::rtl::OUString m_Author;
60 : ::com::sun::star::util::DateTime m_CreationDate;
61 : ::rtl::OUString m_ModifiedBy;
62 : ::com::sun::star::util::DateTime m_ModificationDate;
63 : ::rtl::OUString m_PrintedBy;
64 : ::com::sun::star::util::DateTime m_PrintDate;
65 : sal_Int16 m_EditingCycles;
66 : sal_Int32 m_EditingDuration;
67 : ::rtl::OUString m_Description;
68 : ::rtl::OUString m_Keywords;
69 : ::rtl::OUString m_Subject;
70 : ::rtl::OUString m_Title;
71 : sal_Bool m_bHasTemplate;
72 : sal_Bool m_bDeleteUserData;
73 : sal_Bool m_bUseUserData;
74 : std::vector< CustomProperty* > m_aCustomProperties;
75 :
76 : public:
77 : TYPEINFO();
78 : SfxDocumentInfoItem();
79 : SfxDocumentInfoItem( const String &rFileName,
80 : const ::com::sun::star::uno::Reference<
81 : ::com::sun::star::document::XDocumentProperties> & i_xDocProps,
82 : sal_Bool bUseUserData );
83 : SfxDocumentInfoItem( const SfxDocumentInfoItem& );
84 : virtual ~SfxDocumentInfoItem();
85 :
86 : /// update i_xDocProps with the data in this object
87 : void UpdateDocumentInfo(
88 : const ::com::sun::star::uno::Reference<
89 : ::com::sun::star::document::XDocumentProperties> & i_xDocProps,
90 : bool i_bDoNotUpdateUserDefined = false)
91 : const;
92 :
93 : sal_Bool isAutoloadEnabled() const { return m_isAutoloadEnabled; }
94 : void setAutoloadEnabled(sal_Bool i_val) { m_isAutoloadEnabled = i_val; }
95 : sal_Int32 getAutoloadDelay() const { return m_AutoloadDelay; }
96 : void setAutoloadDelay(sal_Int32 i_val) { m_AutoloadDelay = i_val; }
97 : ::rtl::OUString getAutoloadURL() const { return m_AutoloadURL; }
98 : void setAutoloadURL(::rtl::OUString i_val) { m_AutoloadURL = i_val; }
99 : ::rtl::OUString getDefaultTarget() const { return m_DefaultTarget; }
100 : void setDefaultTarget(::rtl::OUString i_val) { m_DefaultTarget = i_val; }
101 : ::rtl::OUString getTemplateName() const { return m_TemplateName; }
102 : void setTemplateName(::rtl::OUString i_val) { m_TemplateName = i_val; }
103 : ::rtl::OUString getAuthor() const { return m_Author; }
104 : void setAuthor(::rtl::OUString i_val) { m_Author = i_val; }
105 :
106 : ::com::sun::star::util::DateTime
107 : getCreationDate() const { return m_CreationDate; }
108 : void setCreationDate(::com::sun::star::util::DateTime i_val) {
109 : m_CreationDate = i_val;
110 : }
111 : ::rtl::OUString getModifiedBy() const { return m_ModifiedBy; }
112 : void setModifiedBy(::rtl::OUString i_val) { m_ModifiedBy = i_val; }
113 :
114 : ::com::sun::star::util::DateTime
115 : getModificationDate() const { return m_ModificationDate; }
116 : void setModificationDate(::com::sun::star::util::DateTime i_val) {
117 : m_ModificationDate = i_val;
118 : }
119 : ::rtl::OUString getPrintedBy() const { return m_PrintedBy; }
120 : void setPrintedBy(::rtl::OUString i_val) { m_PrintedBy = i_val; }
121 : ::com::sun::star::util::DateTime
122 : getPrintDate() const { return m_PrintDate; }
123 : void setPrintDate(::com::sun::star::util::DateTime i_val) {
124 : m_PrintDate = i_val;
125 : }
126 : sal_Int16 getEditingCycles() const { return m_EditingCycles; }
127 : void setEditingCycles(sal_Int16 i_val) { m_EditingCycles = i_val; }
128 : sal_Int32 getEditingDuration() const { return m_EditingDuration; }
129 : void setEditingDuration(sal_Int32 i_val) { m_EditingDuration = i_val; }
130 : ::rtl::OUString getDescription() const { return m_Description; }
131 : void setDescription(::rtl::OUString i_val) { m_Description = i_val; }
132 : ::rtl::OUString getKeywords() const { return m_Keywords; }
133 : void setKeywords(::rtl::OUString i_val) { m_Keywords = i_val; }
134 : ::rtl::OUString getSubject() const { return m_Subject; }
135 : void setSubject(::rtl::OUString i_val) { m_Subject = i_val; }
136 : ::rtl::OUString getTitle() const { return m_Title; }
137 : void setTitle(::rtl::OUString i_val) { m_Title = i_val; }
138 :
139 : /// reset user-specific data (author, modified-by, ...)
140 : void resetUserData(const ::rtl::OUString & i_rAuthor);
141 :
142 : void SetTemplate( sal_Bool b ) { m_bHasTemplate = b; }
143 : sal_Bool HasTemplate() const { return m_bHasTemplate; }
144 : void SetDeleteUserData( sal_Bool bSet );
145 : void SetUseUserData( sal_Bool bSet );
146 : sal_Bool IsDeleteUserData() const;
147 : sal_Bool IsUseUserData() const;
148 :
149 : std::vector< CustomProperty* > GetCustomProperties() const;
150 : void ClearCustomProperties();
151 : void AddCustomProperty( const ::rtl::OUString& sName,
152 : const com::sun::star::uno::Any& rValue );
153 :
154 : virtual SfxPoolItem* Clone( SfxItemPool* pPool = NULL ) const;
155 : virtual int operator==( const SfxPoolItem& ) const;
156 : virtual bool QueryValue( com::sun::star::uno::Any& rVal, sal_uInt8 nMemberId = 0 ) const;
157 : virtual bool PutValue( const com::sun::star::uno::Any& rVal, sal_uInt8 nMemberId = 0 );
158 : };
159 :
160 : // class SfxDocumentPage -------------------------------------------------
161 :
162 : class SfxDocumentPage : public SfxTabPage
163 : {
164 : private:
165 : FixedImage aBmp1;
166 : Edit aNameED;
167 : PushButton aChangePassBtn;
168 :
169 : FixedLine aLine1FL;
170 : FixedText aTypeFT;
171 : svt::SelectableFixedText aShowTypeFT;
172 : CheckBox aReadOnlyCB;
173 : FixedText aFileFt;
174 : svt::SelectableFixedText aFileValFt;
175 : FixedText aSizeFT;
176 : svt::SelectableFixedText aShowSizeFT;
177 :
178 : FixedLine aLine2FL;
179 : FixedText aCreateFt;
180 : svt::SelectableFixedText aCreateValFt;
181 : FixedText aChangeFt;
182 : svt::SelectableFixedText aChangeValFt;
183 : FixedText aSignedFt;
184 : svt::SelectableFixedText aSignedValFt;
185 : PushButton aSignatureBtn;
186 : FixedText aPrintFt;
187 : svt::SelectableFixedText aPrintValFt;
188 : FixedText aTimeLogFt;
189 : svt::SelectableFixedText aTimeLogValFt;
190 : FixedText aDocNoFt;
191 : svt::SelectableFixedText aDocNoValFt;
192 : CheckBox aUseUserDataCB;
193 : PushButton aDeleteBtn;
194 :
195 : FixedLine aLine3FL;
196 : FixedText aTemplFt;
197 : svt::SelectableFixedText aTemplValFt;
198 :
199 : String aUnknownSize;
200 : String aMultiSignedStr;
201 :
202 : sal_Bool bEnableUseUserData : 1,
203 : bHandleDelete : 1;
204 :
205 : DECL_LINK(DeleteHdl, void *);
206 : DECL_LINK(SignatureHdl, void *);
207 : DECL_LINK(ChangePassHdl, void *);
208 : void ImplUpdateSignatures();
209 : void ImplCheckPasswordState();
210 :
211 : protected:
212 : SfxDocumentPage( Window* pParent, const SfxItemSet& );
213 :
214 : virtual sal_Bool FillItemSet( SfxItemSet& );
215 : virtual void Reset( const SfxItemSet& );
216 :
217 : public:
218 : static SfxTabPage* Create( Window* pParent, const SfxItemSet& );
219 :
220 : void EnableUseUserData();
221 : };
222 :
223 : // class SfxDocumentDescPage ---------------------------------------------
224 :
225 : class SfxDocumentDescPage : public SfxTabPage
226 : {
227 : private:
228 : FixedText aTitleFt;
229 : Edit aTitleEd;
230 : FixedText aThemaFt;
231 : Edit aThemaEd;
232 : FixedText aKeywordsFt;
233 : Edit aKeywordsEd;
234 : FixedText aCommentFt;
235 : MultiLineEdit aCommentEd;
236 : SfxDocumentInfoItem* pInfoItem;
237 :
238 : protected:
239 : SfxDocumentDescPage( Window* pParent, const SfxItemSet& );
240 :
241 : virtual sal_Bool FillItemSet( SfxItemSet& );
242 : virtual void Reset( const SfxItemSet& );
243 :
244 : public:
245 : static SfxTabPage* Create( Window* pParent, const SfxItemSet& );
246 : };
247 :
248 : // class SfxInternetPage -------------------------------------------------
249 :
250 : namespace sfx2
251 : {
252 : class FileDialogHelper;
253 : }
254 :
255 : class SfxInternetPage : public SfxTabPage
256 : {
257 : private:
258 : RadioButton aRBNoAutoUpdate;
259 : RadioButton aRBReloadUpdate;
260 : RadioButton aRBForwardUpdate;
261 :
262 : FixedText aFTEvery;
263 : NumericField aNFReload;
264 : FixedText aFTReloadSeconds;
265 :
266 : FixedText aFTAfter;
267 : NumericField aNFAfter;
268 : FixedText aFTAfterSeconds;
269 : FixedText aFTURL;
270 : Edit aEDForwardURL;
271 : PushButton aPBBrowseURL;
272 : FixedText aFTFrame;
273 : ComboBox aCBFrame;
274 :
275 : String aForwardErrorMessg;
276 : String aBaseURL;
277 : SfxDocumentInfoItem* pInfoItem;
278 : sfx2::FileDialogHelper* pFileDlg;
279 :
280 : enum STATE { S_Init, S_NoUpdate, S_Reload, S_Forward };
281 : // S_Init is only valid as initial value
282 : STATE eState;
283 :
284 : void ChangeState( STATE eNewState ); // S_Init is not a valid value here
285 : // also checks corresponding radiobutton
286 : void EnableNoUpdate( sal_Bool bEnable );
287 : void EnableReload( sal_Bool bEnable );
288 : void EnableForward( sal_Bool bEnable );
289 :
290 : DECL_LINK( ClickHdlNoUpdate, Control* );
291 : DECL_LINK( ClickHdlReload, Control* );
292 : DECL_LINK( ClickHdlForward, Control* );
293 : DECL_LINK(ClickHdlBrowseURL, void *);
294 : DECL_LINK(DialogClosedHdl, void *);
295 :
296 : using TabPage::DeactivatePage;
297 :
298 : protected:
299 : SfxInternetPage( Window* pParent, const SfxItemSet& );
300 : ~SfxInternetPage();
301 :
302 : virtual sal_Bool FillItemSet( SfxItemSet& );
303 : virtual void Reset( const SfxItemSet& );
304 : virtual int DeactivatePage( SfxItemSet* pSet = 0 );
305 :
306 : public:
307 : static SfxTabPage* Create( Window* pParent, const SfxItemSet& );
308 : };
309 :
310 : // class SfxDocumentInfoDialog -------------------------------------------
311 :
312 : class SFX2_DLLPUBLIC SfxDocumentInfoDialog : public SfxTabDialog
313 : {
314 : protected:
315 : virtual void PageCreated( sal_uInt16 nId, SfxTabPage& rPage );
316 :
317 : public:
318 : SfxDocumentInfoDialog( Window* pParent, const SfxItemSet& );
319 : };
320 :
321 : // class CustomPropertiesRemoveButton ------------------------------------
322 :
323 : struct CustomPropertyLine;
324 :
325 0 : class CustomPropertiesEdit : public Edit
326 : {
327 : private:
328 : CustomPropertyLine* m_pLine;
329 :
330 : public:
331 : inline CustomPropertiesEdit(
332 : Window* pParent, const ResId& rResId, CustomPropertyLine* pLine ) :
333 : Edit( pParent, rResId ), m_pLine( pLine ) {}
334 :
335 : inline CustomPropertyLine* GetLine() const { return m_pLine; }
336 : };
337 :
338 0 : class CustomPropertiesTypeBox : public ListBox
339 : {
340 : private:
341 : CustomPropertyLine* m_pLine;
342 :
343 : public:
344 : inline CustomPropertiesTypeBox(
345 : Window* pParent, const ResId& rResId, CustomPropertyLine* pLine ) :
346 : ListBox( pParent, rResId ), m_pLine( pLine ) {}
347 :
348 : inline CustomPropertyLine* GetLine() const { return m_pLine; }
349 : };
350 :
351 0 : class CustomPropertiesDateField : public DateField
352 : {
353 : private:
354 : CustomPropertyLine* m_pLine;
355 :
356 : public:
357 : inline CustomPropertiesDateField(
358 : Window* pParent, const ResId& rResId, CustomPropertyLine* pLine ) :
359 : DateField( pParent, rResId ), m_pLine( pLine ) {}
360 :
361 : inline CustomPropertyLine* GetLine() const { return m_pLine; }
362 : };
363 0 : class CustomPropertiesTimeField : public TimeField
364 : {
365 : private:
366 : CustomPropertyLine* m_pLine;
367 :
368 : public:
369 : inline CustomPropertiesTimeField(
370 : Window* pParent, const ResId& rResId, CustomPropertyLine* pLine ) :
371 : TimeField( pParent, rResId ), m_pLine( pLine ) {}
372 :
373 : inline CustomPropertyLine* GetLine() const { return m_pLine; }
374 : };
375 : class CustomPropertiesDurationField : public Edit
376 : {
377 : CustomPropertyLine* m_pLine;
378 : com::sun::star::util::Duration m_aDuration;
379 : protected:
380 : virtual void RequestHelp(const HelpEvent& rEvt);
381 : public:
382 : CustomPropertiesDurationField( Window* pParent, const ResId& rResId, CustomPropertyLine* pLine );
383 : ~CustomPropertiesDurationField();
384 :
385 : void SetDuration( const com::sun::star::util::Duration& rDuration );
386 : const com::sun::star::util::Duration& GetDuration() const { return m_aDuration; }
387 : };
388 :
389 : class CustomPropertiesEditButton : public PushButton
390 : {
391 : CustomPropertyLine* m_pLine;
392 :
393 : public:
394 : CustomPropertiesEditButton( Window* pParent, const ResId& rResId, CustomPropertyLine* pLine );
395 : ~CustomPropertiesEditButton();
396 :
397 : DECL_LINK(ClickHdl, void *);
398 : };
399 :
400 0 : class CustomPropertiesRemoveButton : public ImageButton
401 : {
402 : private:
403 : CustomPropertyLine* m_pLine;
404 :
405 : public:
406 : inline CustomPropertiesRemoveButton(
407 : Window* pParent, const ResId& rResId, CustomPropertyLine* pLine ) :
408 : ImageButton( pParent, rResId ), m_pLine( pLine ) {}
409 :
410 : inline CustomPropertyLine* GetLine() const { return m_pLine; }
411 : };
412 :
413 : class CustomPropertiesYesNoButton : public Control
414 : {
415 : private:
416 : RadioButton m_aYesButton;
417 : RadioButton m_aNoButton;
418 :
419 : public:
420 : CustomPropertiesYesNoButton( Window* pParent, const ResId& rResId );
421 :
422 : virtual void Resize();
423 :
424 : inline void CheckYes() { m_aYesButton.Check(); }
425 : inline void CheckNo() { m_aNoButton.Check(); }
426 : inline bool IsYesChecked() const { return m_aYesButton.IsChecked() != sal_False; }
427 : };
428 :
429 : // struct CustomPropertyLine ---------------------------------------------
430 :
431 : struct CustomPropertyLine
432 : {
433 : ComboBox m_aNameBox;
434 : CustomPropertiesTypeBox m_aTypeBox;
435 : CustomPropertiesEdit m_aValueEdit;
436 : CustomPropertiesDateField m_aDateField;
437 : CustomPropertiesTimeField m_aTimeField;
438 : const String m_sDurationFormat;
439 : CustomPropertiesDurationField m_aDurationField;
440 : CustomPropertiesEditButton m_aEditButton;
441 : CustomPropertiesYesNoButton m_aYesNoButton;
442 : CustomPropertiesRemoveButton m_aRemoveButton;
443 :
444 : Point m_aDatePos;
445 : Point m_aTimePos;
446 : Size m_aDateTimeSize;
447 :
448 : bool m_bIsRemoved;
449 : bool m_bTypeLostFocus;
450 :
451 : CustomPropertyLine( Window* pParent );
452 :
453 : void SetRemoved();
454 : };
455 :
456 : // class CustomPropertiesWindow ------------------------------------------
457 :
458 : class CustomPropertiesWindow : public Window
459 : {
460 : private:
461 : ComboBox m_aNameBox;
462 : ListBox m_aTypeBox;
463 : Edit m_aValueEdit;
464 : DateField m_aDateField;
465 : TimeField m_aTimeField;
466 : Edit m_aDurationField;
467 : PushButton m_aEditButton;
468 : CustomPropertiesYesNoButton m_aYesNoButton;
469 : ImageButton m_aRemoveButton;
470 :
471 : sal_Int32 m_nLineHeight;
472 : sal_Int32 m_nScrollPos;
473 : SvtSysLocale m_aSysLocale;
474 : std::vector< CustomPropertyLine* > m_aCustomPropertiesLines;
475 : CustomPropertyLine* m_pCurrentLine;
476 : SvNumberFormatter m_aNumberFormatter;
477 : Timer m_aEditLoseFocusTimer;
478 : Timer m_aBoxLoseFocusTimer;
479 : Link m_aRemovedHdl;
480 :
481 : DECL_LINK( TypeHdl, CustomPropertiesTypeBox* );
482 : DECL_LINK( RemoveHdl, CustomPropertiesRemoveButton* );
483 : DECL_LINK( EditLoseFocusHdl, CustomPropertiesEdit* );
484 : DECL_LINK( BoxLoseFocusHdl, CustomPropertiesTypeBox* );
485 : //add lose focus handlers of Date/TimeField?
486 :
487 : DECL_LINK(EditTimeoutHdl, void *);
488 : DECL_LINK(BoxTimeoutHdl, void *);
489 :
490 : bool IsLineValid( CustomPropertyLine* pLine ) const;
491 : void ValidateLine( CustomPropertyLine* pLine, bool bIsFromTypeBox );
492 :
493 : public:
494 : CustomPropertiesWindow( Window* pParent, const ResId& rResId );
495 : ~CustomPropertiesWindow();
496 :
497 : void InitControls( HeaderBar* pHeaderBar, const ScrollBar* pScrollBar );
498 : sal_uInt16 GetVisibleLineCount() const;
499 : inline sal_Int32 GetLineHeight() const { return m_nLineHeight; }
500 : void AddLine( const ::rtl::OUString& sName, com::sun::star::uno::Any& rAny );
501 : bool AreAllLinesValid() const;
502 : void ClearAllLines();
503 : void DoScroll( sal_Int32 nNewPos );
504 :
505 : ::com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyValue >
506 : GetCustomProperties() const;
507 : void SetRemovedHdl( const Link& rLink ) { m_aRemovedHdl = rLink; }
508 : };
509 :
510 : // class CustomPropertiesControl -----------------------------------------
511 :
512 : class CustomPropertiesControl : public Control
513 : {
514 : private:
515 : HeaderBar m_aHeaderBar;
516 : CustomPropertiesWindow m_aPropertiesWin;
517 : ScrollBar m_aVertScroll;
518 :
519 : sal_Int32 m_nThumbPos;
520 :
521 : DECL_LINK( ScrollHdl, ScrollBar* );
522 : DECL_LINK( RemovedHdl, void* );
523 :
524 : public:
525 : CustomPropertiesControl( Window* pParent, const ResId& rResId );
526 : ~CustomPropertiesControl();
527 :
528 : void AddLine( const ::rtl::OUString& sName, com::sun::star::uno::Any& rAny, bool bInteractive );
529 :
530 : inline bool AreAllLinesValid() const { return m_aPropertiesWin.AreAllLinesValid(); }
531 : inline void ClearAllLines() { m_aPropertiesWin.ClearAllLines(); }
532 : inline ::com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyValue >
533 : GetCustomProperties() const
534 : { return m_aPropertiesWin.GetCustomProperties(); }
535 : };
536 :
537 : // class SfxCustomPropertiesPage -----------------------------------------
538 :
539 : class SfxCustomPropertiesPage : public SfxTabPage
540 : {
541 : private:
542 : CustomPropertiesControl m_aPropertiesCtrl;
543 : PushButton m_aAddBtn;
544 : FixedText m_aPropertiesFT; // Sym2_5121----, Moved by Steve Yin
545 :
546 : DECL_LINK(AddHdl, void *);
547 :
548 : using TabPage::DeactivatePage;
549 :
550 : protected:
551 : SfxCustomPropertiesPage( Window* pParent, const SfxItemSet& );
552 :
553 : virtual sal_Bool FillItemSet( SfxItemSet& );
554 : virtual void Reset( const SfxItemSet& );
555 : virtual int DeactivatePage( SfxItemSet* pSet = NULL );
556 :
557 : public:
558 : static SfxTabPage* Create( Window* pParent, const SfxItemSet& );
559 : };
560 :
561 : #endif // #ifndef _SFX_DINFDLG_HXX
562 :
563 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|