1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
3 * This file is part of the LibreOffice project.
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/.
9 * This file incorporates work covered by the following license notice:
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 .
19 #ifndef INCLUDED_SFX2_DINFDLG_HXX
20 #define INCLUDED_SFX2_DINFDLG_HXX
22 #include <boost/optional/optional.hpp>
24 #include <boost/ptr_container/ptr_vector.hpp>
26 #include <sal/config.h>
27 #include <sfx2/dllapi.h>
29 #include <com/sun/star/util/DateTime.hpp>
30 #include <com/sun/star/util/Duration.hpp>
31 #include <com/sun/star/document/CmisProperty.hpp>
33 #include <svl/stritem.hxx>
34 #include <svl/zforlist.hxx>
36 #include <svtools/headbar.hxx>
37 #include <svtools/stdctrl.hxx>
38 #include <svtools/svmedit.hxx>
40 #include <unotools/syslocale.hxx>
42 #include <vcl/edit.hxx>
43 #include <vcl/field.hxx>
44 #include <vcl/layout.hxx>
45 #include <vcl/lstbox.hxx>
46 #include <vcl/scrbar.hxx>
47 #include <vcl/fixed.hxx>
48 #include <vcl/ctrl.hxx>
50 #include <sfx2/tabdlg.hxx>
52 namespace com
{ namespace sun
{ namespace star
{
54 class XDocumentProperties
;
58 struct CustomProperty
;
60 // class SfxDocumentInfoItem ---------------------------------------------
62 class SFX2_DLLPUBLIC SfxDocumentInfoItem
: public SfxStringItem
65 sal_Int32 m_AutoloadDelay
;
66 OUString m_AutoloadURL
;
67 sal_Bool m_isAutoloadEnabled
;
68 OUString m_DefaultTarget
;
69 OUString m_TemplateName
;
71 ::com::sun::star::util::DateTime m_CreationDate
;
72 OUString m_ModifiedBy
;
73 ::com::sun::star::util::DateTime m_ModificationDate
;
75 ::com::sun::star::util::DateTime m_PrintDate
;
76 sal_Int16 m_EditingCycles
;
77 sal_Int32 m_EditingDuration
;
78 OUString m_Description
;
82 sal_Bool m_bHasTemplate
;
83 sal_Bool m_bDeleteUserData
;
84 sal_Bool m_bUseUserData
;
85 std::vector
< CustomProperty
* > m_aCustomProperties
;
86 ::com::sun::star::uno::Sequence
< ::com::sun::star::document::CmisProperty
> m_aCmisProperties
;
90 SfxDocumentInfoItem();
91 SfxDocumentInfoItem( const OUString
&rFileName
,
92 const ::com::sun::star::uno::Reference
<
93 ::com::sun::star::document::XDocumentProperties
> & i_xDocProps
,
94 const ::com::sun::star::uno::Sequence
<
95 ::com::sun::star::document::CmisProperty
> & i_cmisProps
,
96 sal_Bool bUseUserData
);
97 SfxDocumentInfoItem( const SfxDocumentInfoItem
& );
98 virtual ~SfxDocumentInfoItem();
100 /// update i_xDocProps with the data in this object
101 void UpdateDocumentInfo(
102 const ::com::sun::star::uno::Reference
<
103 ::com::sun::star::document::XDocumentProperties
> & i_xDocProps
,
104 bool i_bDoNotUpdateUserDefined
= false)
106 sal_Bool
isCmisDocument() const { return m_aCmisProperties
.getLength() > 0;}
108 sal_Bool
isAutoloadEnabled() const { return m_isAutoloadEnabled
; }
109 void setAutoloadEnabled(sal_Bool i_val
) { m_isAutoloadEnabled
= i_val
; }
110 sal_Int32
getAutoloadDelay() const { return m_AutoloadDelay
; }
111 void setAutoloadDelay(sal_Int32 i_val
) { m_AutoloadDelay
= i_val
; }
112 OUString
getAutoloadURL() const { return m_AutoloadURL
; }
113 void setAutoloadURL(OUString i_val
) { m_AutoloadURL
= i_val
; }
114 OUString
getDefaultTarget() const { return m_DefaultTarget
; }
115 void setDefaultTarget(OUString i_val
) { m_DefaultTarget
= i_val
; }
116 OUString
getTemplateName() const { return m_TemplateName
; }
117 void setTemplateName(OUString i_val
) { m_TemplateName
= i_val
; }
118 OUString
getAuthor() const { return m_Author
; }
119 void setAuthor(OUString i_val
) { m_Author
= i_val
; }
121 ::com::sun::star::util::DateTime
122 getCreationDate() const { return m_CreationDate
; }
123 void setCreationDate(::com::sun::star::util::DateTime i_val
) {
124 m_CreationDate
= i_val
;
126 OUString
getModifiedBy() const { return m_ModifiedBy
; }
127 void setModifiedBy(OUString i_val
) { m_ModifiedBy
= i_val
; }
129 ::com::sun::star::util::DateTime
130 getModificationDate() const { return m_ModificationDate
; }
131 void setModificationDate(::com::sun::star::util::DateTime i_val
) {
132 m_ModificationDate
= i_val
;
134 OUString
getPrintedBy() const { return m_PrintedBy
; }
135 void setPrintedBy(OUString i_val
) { m_PrintedBy
= i_val
; }
136 ::com::sun::star::util::DateTime
137 getPrintDate() const { return m_PrintDate
; }
138 void setPrintDate(::com::sun::star::util::DateTime i_val
) {
141 sal_Int16
getEditingCycles() const { return m_EditingCycles
; }
142 void setEditingCycles(sal_Int16 i_val
) { m_EditingCycles
= i_val
; }
143 sal_Int32
getEditingDuration() const { return m_EditingDuration
; }
144 void setEditingDuration(sal_Int32 i_val
) { m_EditingDuration
= i_val
; }
145 OUString
getDescription() const { return m_Description
; }
146 void setDescription(OUString i_val
) { m_Description
= i_val
; }
147 OUString
getKeywords() const { return m_Keywords
; }
148 void setKeywords(OUString i_val
) { m_Keywords
= i_val
; }
149 OUString
getSubject() const { return m_Subject
; }
150 void setSubject(OUString i_val
) { m_Subject
= i_val
; }
151 OUString
getTitle() const { return m_Title
; }
152 void setTitle(OUString i_val
) { m_Title
= i_val
; }
154 /// reset user-specific data (author, modified-by, ...)
155 void resetUserData(const OUString
& i_rAuthor
);
157 void SetTemplate( sal_Bool b
) { m_bHasTemplate
= b
; }
158 sal_Bool
HasTemplate() const { return m_bHasTemplate
; }
159 void SetDeleteUserData( sal_Bool bSet
);
160 void SetUseUserData( sal_Bool bSet
);
161 sal_Bool
IsDeleteUserData() const;
162 sal_Bool
IsUseUserData() const;
164 std::vector
< CustomProperty
* > GetCustomProperties() const;
165 void ClearCustomProperties();
166 void AddCustomProperty( const OUString
& sName
,
167 const com::sun::star::uno::Any
& rValue
);
169 ::com::sun::star::uno::Sequence
< ::com::sun::star::document::CmisProperty
>
170 GetCmisProperties() const;
172 void SetCmisProperties(::com::sun::star::uno::Sequence
< ::com::sun::star::document::CmisProperty
> cmisProps
);
173 virtual SfxPoolItem
* Clone( SfxItemPool
* pPool
= NULL
) const;
174 virtual int operator==( const SfxPoolItem
& ) const;
175 virtual bool QueryValue( com::sun::star::uno::Any
& rVal
, sal_uInt8 nMemberId
= 0 ) const;
176 virtual bool PutValue( const com::sun::star::uno::Any
& rVal
, sal_uInt8 nMemberId
= 0 );
179 // class SfxDocumentPage -------------------------------------------------
181 class SfxDocumentPage
: public SfxTabPage
186 PushButton
* m_pChangePassBtn
;
188 SelectableFixedText
* m_pShowTypeFT
;
189 CheckBox
* m_pReadOnlyCB
;
190 FixedText
* m_pFileValFt
;
191 SelectableFixedText
* m_pShowSizeFT
;
193 SelectableFixedText
* m_pCreateValFt
;
194 SelectableFixedText
* m_pChangeValFt
;
195 SelectableFixedText
* m_pSignedValFt
;
196 PushButton
* m_pSignatureBtn
;
197 SelectableFixedText
* m_pPrintValFt
;
198 SelectableFixedText
* m_pTimeLogValFt
;
199 SelectableFixedText
* m_pDocNoValFt
;
201 CheckBox
* m_pUseUserDataCB
;
202 PushButton
* m_pDeleteBtn
;
204 FixedText
* m_pTemplFt
;
205 SelectableFixedText
* m_pTemplValFt
;
207 OUString m_aUnknownSize
;
208 OUString m_aMultiSignedStr
;
210 sal_Bool bEnableUseUserData
: 1,
213 DECL_LINK(DeleteHdl
, void *);
214 DECL_LINK(SignatureHdl
, void *);
215 DECL_LINK(ChangePassHdl
, void *);
216 void ImplUpdateSignatures();
217 void ImplCheckPasswordState();
220 SfxDocumentPage( Window
* pParent
, const SfxItemSet
& );
222 virtual sal_Bool
FillItemSet( SfxItemSet
& );
223 virtual void Reset( const SfxItemSet
& );
226 static SfxTabPage
* Create( Window
* pParent
, const SfxItemSet
& );
228 void EnableUseUserData();
231 // class SfxDocumentDescPage ---------------------------------------------
233 class SfxDocumentDescPage
: public SfxTabPage
239 VclMultiLineEdit
* m_pCommentEd
;
240 SfxDocumentInfoItem
* m_pInfoItem
;
243 SfxDocumentDescPage( Window
* pParent
, const SfxItemSet
& );
245 virtual sal_Bool
FillItemSet( SfxItemSet
& );
246 virtual void Reset( const SfxItemSet
& );
249 static SfxTabPage
* Create( Window
* pParent
, const SfxItemSet
& );
252 // class SfxDocumentInfoDialog -------------------------------------------
254 class SFX2_DLLPUBLIC SfxDocumentInfoDialog
: public SfxTabDialog
257 sal_uInt16 m_nDocInfoId
;
259 virtual void PageCreated( sal_uInt16 nId
, SfxTabPage
& rPage
);
262 SfxDocumentInfoDialog( Window
* pParent
, const SfxItemSet
& );
263 void AddFontTabPage();
266 // class CustomPropertiesRemoveButton ------------------------------------
268 struct CustomPropertyLine
;
270 class CustomPropertiesEdit
: public Edit
273 CustomPropertyLine
* m_pLine
;
276 inline CustomPropertiesEdit(
277 Window
* pParent
, const ResId
& rResId
, CustomPropertyLine
* pLine
) :
278 Edit( pParent
, rResId
), m_pLine( pLine
) {}
280 inline CustomPropertyLine
* GetLine() const { return m_pLine
; }
283 class CustomPropertiesTypeBox
: public ListBox
286 CustomPropertyLine
* m_pLine
;
289 inline CustomPropertiesTypeBox(
290 Window
* pParent
, const ResId
& rResId
, CustomPropertyLine
* pLine
) :
291 ListBox( pParent
, rResId
), m_pLine( pLine
) {}
293 inline CustomPropertyLine
* GetLine() const { return m_pLine
; }
296 class CustomPropertiesDateField
: public DateField
299 CustomPropertyLine
* m_pLine
;
302 ::boost::optional
<sal_Int16
> m_TZ
;
304 inline CustomPropertiesDateField(
305 Window
* pParent
, const ResId
& rResId
, CustomPropertyLine
* pLine
) :
306 DateField( pParent
, rResId
), m_pLine( pLine
) {}
308 inline CustomPropertyLine
* GetLine() const { return m_pLine
; }
310 class CustomPropertiesTimeField
: public TimeField
313 CustomPropertyLine
* m_pLine
;
318 inline CustomPropertiesTimeField(
319 Window
* pParent
, const ResId
& rResId
, CustomPropertyLine
* pLine
) :
320 TimeField( pParent
, rResId
), m_pLine( pLine
), m_isUTC(false) {}
322 inline CustomPropertyLine
* GetLine() const { return m_pLine
; }
324 class CustomPropertiesDurationField
: public Edit
326 CustomPropertyLine
* m_pLine
;
327 com::sun::star::util::Duration m_aDuration
;
329 virtual void RequestHelp(const HelpEvent
& rEvt
);
331 CustomPropertiesDurationField( Window
* pParent
, const ResId
& rResId
, CustomPropertyLine
* pLine
);
332 ~CustomPropertiesDurationField();
334 void SetDuration( const com::sun::star::util::Duration
& rDuration
);
335 const com::sun::star::util::Duration
& GetDuration() const { return m_aDuration
; }
338 class CustomPropertiesEditButton
: public PushButton
340 CustomPropertyLine
* m_pLine
;
343 CustomPropertiesEditButton( Window
* pParent
, const ResId
& rResId
, CustomPropertyLine
* pLine
);
344 ~CustomPropertiesEditButton();
346 DECL_LINK(ClickHdl
, void *);
349 class CustomPropertiesRemoveButton
: public ImageButton
352 CustomPropertyLine
* m_pLine
;
355 inline CustomPropertiesRemoveButton(
356 Window
* pParent
, const ResId
& rResId
, CustomPropertyLine
* pLine
) :
357 ImageButton( pParent
, rResId
), m_pLine( pLine
) {}
359 inline CustomPropertyLine
* GetLine() const { return m_pLine
; }
362 class CustomPropertiesYesNoButton
: public Control
365 RadioButton m_aYesButton
;
366 RadioButton m_aNoButton
;
369 CustomPropertiesYesNoButton( Window
* pParent
, const ResId
& rResId
);
371 virtual void Resize();
373 inline void CheckYes() { m_aYesButton
.Check(); }
374 inline void CheckNo() { m_aNoButton
.Check(); }
375 inline bool IsYesChecked() const { return m_aYesButton
.IsChecked() != sal_False
; }
378 // struct CustomPropertyLine ---------------------------------------------
380 struct CustomPropertyLine
383 CustomPropertiesTypeBox m_aTypeBox
;
384 CustomPropertiesEdit m_aValueEdit
;
385 CustomPropertiesDateField m_aDateField
;
386 CustomPropertiesTimeField m_aTimeField
;
387 const OUString m_sDurationFormat
;
388 CustomPropertiesDurationField m_aDurationField
;
389 CustomPropertiesEditButton m_aEditButton
;
390 CustomPropertiesYesNoButton m_aYesNoButton
;
391 CustomPropertiesRemoveButton m_aRemoveButton
;
395 Size m_aDateTimeSize
;
398 bool m_bTypeLostFocus
;
400 CustomPropertyLine( Window
* pParent
);
405 // class CustomPropertiesWindow ------------------------------------------
407 class CustomPropertiesWindow
: public Window
413 DateField m_aDateField
;
414 TimeField m_aTimeField
;
415 Edit m_aDurationField
;
416 PushButton m_aEditButton
;
417 CustomPropertiesYesNoButton m_aYesNoButton
;
418 ImageButton m_aRemoveButton
;
420 sal_Int32 m_nLineHeight
;
421 sal_Int32 m_nScrollPos
;
422 SvtSysLocale m_aSysLocale
;
423 std::vector
< CustomPropertyLine
* > m_aCustomPropertiesLines
;
424 CustomPropertyLine
* m_pCurrentLine
;
425 SvNumberFormatter m_aNumberFormatter
;
426 Timer m_aEditLoseFocusTimer
;
427 Timer m_aBoxLoseFocusTimer
;
430 DECL_LINK( TypeHdl
, CustomPropertiesTypeBox
* );
431 DECL_LINK( RemoveHdl
, CustomPropertiesRemoveButton
* );
432 DECL_LINK( EditLoseFocusHdl
, CustomPropertiesEdit
* );
433 DECL_LINK( BoxLoseFocusHdl
, CustomPropertiesTypeBox
* );
434 //add lose focus handlers of Date/TimeField?
436 DECL_LINK(EditTimeoutHdl
, void *);
437 DECL_LINK(BoxTimeoutHdl
, void *);
439 bool IsLineValid( CustomPropertyLine
* pLine
) const;
440 void ValidateLine( CustomPropertyLine
* pLine
, bool bIsFromTypeBox
);
443 CustomPropertiesWindow(Window
* pParent
,
444 const OUString
&rHeaderAccName
,
445 const OUString
&rHeaderAccType
,
446 const OUString
&rHeaderAccValue
);
447 ~CustomPropertiesWindow();
449 void InitControls( HeaderBar
* pHeaderBar
, const ScrollBar
* pScrollBar
);
450 sal_uInt16
GetVisibleLineCount() const;
451 inline sal_Int32
GetLineHeight() const { return m_nLineHeight
; }
452 void AddLine( const OUString
& sName
, com::sun::star::uno::Any
& rAny
);
453 bool AreAllLinesValid() const;
454 void ClearAllLines();
455 void DoScroll( sal_Int32 nNewPos
);
457 ::com::sun::star::uno::Sequence
< ::com::sun::star::beans::PropertyValue
>
458 GetCustomProperties() const;
459 void SetRemovedHdl( const Link
& rLink
) { m_aRemovedHdl
= rLink
; }
461 void InitRemoveButton(const ScrollBar
&rScrollBar
);
462 void updateLineWidth();
465 // class CustomPropertiesControl -----------------------------------------
467 class CustomPropertiesControl
: public VclVBox
470 HeaderBar
* m_pHeaderBar
;
472 CustomPropertiesWindow
* m_pPropertiesWin
;
473 ScrollBar
* m_pVertScroll
;
475 sal_Int32 m_nThumbPos
;
477 DECL_LINK( ScrollHdl
, ScrollBar
* );
478 DECL_LINK( RemovedHdl
, void* );
481 CustomPropertiesControl(Window
* pParent
);
482 ~CustomPropertiesControl();
484 void AddLine( const OUString
& sName
, com::sun::star::uno::Any
& rAny
, bool bInteractive
);
486 inline bool AreAllLinesValid() const { return m_pPropertiesWin
->AreAllLinesValid(); }
487 inline void ClearAllLines() { m_pPropertiesWin
->ClearAllLines(); }
488 inline ::com::sun::star::uno::Sequence
< ::com::sun::star::beans::PropertyValue
>
489 GetCustomProperties() const
490 { return m_pPropertiesWin
->GetCustomProperties(); }
491 void Init(VclBuilderContainer
& rParent
);
492 virtual void setAllocation(const Size
&rAllocation
);
495 // class SfxCustomPropertiesPage -----------------------------------------
497 class SfxCustomPropertiesPage
: public SfxTabPage
500 CustomPropertiesControl
* m_pPropertiesCtrl
;
502 DECL_LINK(AddHdl
, void *);
504 using TabPage::DeactivatePage
;
507 SfxCustomPropertiesPage( Window
* pParent
, const SfxItemSet
& );
509 virtual sal_Bool
FillItemSet( SfxItemSet
& );
510 virtual void Reset( const SfxItemSet
& );
511 virtual int DeactivatePage( SfxItemSet
* pSet
= NULL
);
514 static SfxTabPage
* Create( Window
* pParent
, const SfxItemSet
& );
517 struct CmisValue
: public VclBuilderContainer
521 CmisValue( Window
* pParent
, const OUString
& aStr
);
524 struct CmisDateTime
: public VclBuilderContainer
526 DateField
* m_aDateField
;
527 TimeField
* m_aTimeField
;
529 CmisDateTime( Window
* pParent
, const ::com::sun::star::util::DateTime
& aDateTime
);
532 struct CmisYesNo
: public VclBuilderContainer
534 RadioButton
* m_aYesButton
;
535 RadioButton
* m_aNoButton
;
537 CmisYesNo( Window
* pParent
, bool bValue
);
540 // struct CmisPropertyLine ---------------------------------------------
542 struct CmisPropertyLine
: public VclBuilderContainer
553 std::vector
< CmisValue
* > m_aValues
;
554 std::vector
< CmisDateTime
* > m_aDateTimes
;
555 std::vector
< CmisYesNo
* > m_aYesNos
;
556 sal_Int32 m_nNumValue
;
557 long getItemHeight() const;
558 CmisPropertyLine( Window
* pParent
);
562 // class CmisPropertiesWindow ------------------------------------------
564 class CmisPropertiesWindow
568 sal_Int32 m_nItemHeight
;
569 SvNumberFormatter m_aNumberFormatter
;
570 std::vector
< CmisPropertyLine
* > m_aCmisPropertiesLines
;
572 CmisPropertiesWindow(SfxTabPage
* pParent
);
573 ~CmisPropertiesWindow();
575 sal_uInt16
GetLineCount() const;
576 inline sal_Int32
GetItemHeight() const { return m_nItemHeight
; }
577 void AddLine( const OUString
& sId
, const OUString
& sName
,
578 const OUString
& sType
, const bool bUpdatable
,
579 const bool bRequired
, const bool bMultiValued
,
580 const bool bOpenChoice
,
581 com::sun::star::uno::Any
& aChoices
,
582 com::sun::star::uno::Any
& rAny
);
583 void ClearAllLines();
584 void DoScroll( sal_Int32 nNewPos
);
586 ::com::sun::star::uno::Sequence
< ::com::sun::star::document::CmisProperty
>
587 GetCmisProperties() const;
590 // class CmisPropertiesControl -----------------------------------------
592 class CmisPropertiesControl
595 CmisPropertiesWindow m_pPropertiesWin
;
596 VclScrolledWindow
& m_rScrolledWindow
;
597 ScrollBar
& m_rVertScroll
;
598 DECL_LINK( ScrollHdl
, ScrollBar
* );
600 void checkAutoVScroll();
603 CmisPropertiesControl(SfxTabPage
* pParent
);
604 void setScrollRange();
606 void AddLine( const OUString
& sId
, const OUString
& sName
,
607 const OUString
& sType
, const bool bUpdatable
,
608 const bool bRequired
, const bool bMultiValude
,
609 const bool bOpenChoice
,
610 com::sun::star::uno::Any
& aChoices
,
611 com::sun::star::uno::Any
& rAny
);
613 void ClearAllLines();
614 inline ::com::sun::star::uno::Sequence
< ::com::sun::star::document::CmisProperty
>
615 GetCmisProperties() const
616 { return m_pPropertiesWin
.GetCmisProperties(); }
619 // class SfxCmisPropertiesPage -------------------------------------------------
621 class SfxCmisPropertiesPage
: public SfxTabPage
624 CmisPropertiesControl m_pPropertiesCtrl
;
625 using TabPage::DeactivatePage
;
626 DECL_LINK(UpdateHdl
, void *);
629 SfxCmisPropertiesPage( Window
* pParent
, const SfxItemSet
& );
631 virtual sal_Bool
FillItemSet( SfxItemSet
& );
632 virtual void Reset( const SfxItemSet
& );
633 virtual int DeactivatePage( SfxItemSet
* pSet
= NULL
);
636 static SfxTabPage
* Create( Window
* pParent
, const SfxItemSet
& );
639 #endif // #ifndef _ INCLUDED_SFX2_DINFDLG_HXX
641 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */