Bump version to 21.06.18.1
[LibreOffice.git] / include / sfx2 / dinfdlg.hxx
blobbea521a535fcd577748db6cfd39a62cacccaf6fe
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
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 <config_options.h>
23 #include <sal/config.h>
24 #include <sfx2/dllapi.h>
26 #include <com/sun/star/beans/PropertyValue.hpp>
27 #include <com/sun/star/util/DateTime.hpp>
28 #include <com/sun/star/util/Duration.hpp>
29 #include <com/sun/star/document/CmisProperty.hpp>
31 #include <svl/stritem.hxx>
32 #include <svl/zforlist.hxx>
33 #include <svtools/ctrlbox.hxx>
35 #include <vcl/idle.hxx>
37 #include <sfx2/tabdlg.hxx>
39 #include <optional>
40 #include <memory>
42 namespace com::sun::star::beans { struct PropertyValue; }
44 namespace com::sun::star {
45 namespace document {
46 class XDocumentProperties;
50 struct CustomProperty;
51 class SvtCalendarBox;
53 // class SfxDocumentInfoItem ---------------------------------------------
55 class UNLESS_MERGELIBS(SFX2_DLLPUBLIC) SfxDocumentInfoItem final : public SfxStringItem
57 private:
58 sal_Int32 m_AutoloadDelay;
59 OUString m_AutoloadURL;
60 bool m_isAutoloadEnabled;
61 OUString m_DefaultTarget;
62 OUString m_TemplateName;
63 OUString m_Author;
64 css::util::DateTime m_CreationDate;
65 OUString m_ModifiedBy;
66 css::util::DateTime m_ModificationDate;
67 OUString m_PrintedBy;
68 css::util::DateTime m_PrintDate;
69 sal_Int16 m_EditingCycles;
70 sal_Int32 m_EditingDuration;
71 OUString m_Description;
72 OUString m_Keywords;
73 OUString m_Subject;
74 OUString m_Title;
75 bool m_bHasTemplate;
76 bool m_bDeleteUserData;
77 bool m_bUseUserData;
78 bool m_bUseThumbnailSave;
79 std::vector< std::unique_ptr<CustomProperty> > m_aCustomProperties;
80 css::uno::Sequence< css::document::CmisProperty > m_aCmisProperties;
82 public:
83 static SfxPoolItem* CreateDefault();
84 SfxDocumentInfoItem();
85 SfxDocumentInfoItem( const OUString &rFileName,
86 const css::uno::Reference< css::document::XDocumentProperties> & i_xDocProps,
87 const css::uno::Sequence< css::document::CmisProperty> & i_cmisProps,
88 bool bUseUserData, bool bUseThumbnailSave );
89 SfxDocumentInfoItem( const SfxDocumentInfoItem& );
90 virtual ~SfxDocumentInfoItem() override;
92 /// update i_xDocProps with the data in this object
93 void UpdateDocumentInfo(
94 const css::uno::Reference< css::document::XDocumentProperties> & i_xDocProps,
95 bool i_bDoNotUpdateUserDefined = false)
96 const;
97 bool isCmisDocument() const { return m_aCmisProperties.hasElements();}
99 bool isAutoloadEnabled() const { return m_isAutoloadEnabled; }
100 sal_Int32 getAutoloadDelay() const { return m_AutoloadDelay; }
101 const OUString& getAutoloadURL() const { return m_AutoloadURL; }
102 const OUString& getDefaultTarget() const { return m_DefaultTarget; }
103 const OUString& getTemplateName() const { return m_TemplateName; }
104 const OUString& getAuthor() const { return m_Author; }
106 const css::util::DateTime&
107 getCreationDate() const { return m_CreationDate; }
108 const OUString& getModifiedBy() const { return m_ModifiedBy; }
110 const css::util::DateTime&
111 getModificationDate() const { return m_ModificationDate; }
112 const OUString& getPrintedBy() const { return m_PrintedBy; }
113 const css::util::DateTime&
114 getPrintDate() const { return m_PrintDate; }
115 sal_Int16 getEditingCycles() const { return m_EditingCycles; }
116 sal_Int32 getEditingDuration() const { return m_EditingDuration; }
117 const OUString& getDescription() const { return m_Description; }
118 void setDescription(const OUString& i_val) { m_Description = i_val; }
119 const OUString& getKeywords() const { return m_Keywords; }
120 void setKeywords(const OUString& i_val) { m_Keywords = i_val; }
121 const OUString& getSubject() const { return m_Subject; }
122 void setSubject(const OUString& i_val) { m_Subject = i_val; }
123 const OUString& getTitle() const { return m_Title; }
124 void setTitle(const OUString& i_val) { m_Title = i_val; }
126 /// reset user-specific data (author, modified-by, ...)
127 void resetUserData(const OUString & i_rAuthor);
129 void SetTemplate( bool b ) { m_bHasTemplate = b; }
130 bool HasTemplate() const { return m_bHasTemplate; }
131 void SetDeleteUserData( bool bSet );
132 void SetUseUserData( bool bSet );
133 void SetUseThumbnailSave( bool bSet );
134 bool IsUseUserData() const { return m_bUseUserData;}
135 bool IsUseThumbnailSave() const { return m_bUseThumbnailSave;}
138 std::vector< std::unique_ptr<CustomProperty> > GetCustomProperties() const;
139 void ClearCustomProperties();
140 void AddCustomProperty( const OUString& sName,
141 const css::uno::Any& rValue );
143 const css::uno::Sequence< css::document::CmisProperty >&
144 GetCmisProperties() const { return m_aCmisProperties;}
146 void SetCmisProperties(const css::uno::Sequence< css::document::CmisProperty >& cmisProps );
147 virtual SfxDocumentInfoItem* Clone( SfxItemPool* pPool = nullptr ) const override;
148 virtual bool operator==( const SfxPoolItem& ) const override;
149 virtual bool QueryValue( css::uno::Any& rVal, sal_uInt8 nMemberId = 0 ) const override;
150 virtual bool PutValue( const css::uno::Any& rVal, sal_uInt8 nMemberId ) override;
153 // class SfxDocumentPage -------------------------------------------------
155 class SfxDocumentPage final : public SfxTabPage
157 private:
158 OUString m_aUnknownSize;
159 OUString m_aMultiSignedStr;
161 bool bEnableUseUserData : 1,
162 bHandleDelete : 1;
164 std::unique_ptr<weld::Image> m_xBmp;
165 std::unique_ptr<weld::Label> m_xNameED;
166 std::unique_ptr<weld::Button> m_xChangePassBtn;
168 std::unique_ptr<weld::Label> m_xShowTypeFT;
169 std::unique_ptr<weld::Label> m_xFileValEd;
170 std::unique_ptr<weld::Label> m_xShowSizeFT;
172 std::unique_ptr<weld::Label> m_xCreateValFt;
173 std::unique_ptr<weld::Label> m_xChangeValFt;
174 std::unique_ptr<weld::Label> m_xSignedValFt;
175 std::unique_ptr<weld::Button> m_xSignatureBtn;
176 std::unique_ptr<weld::Label> m_xPrintValFt;
177 std::unique_ptr<weld::Label> m_xTimeLogValFt;
178 std::unique_ptr<weld::Label> m_xDocNoValFt;
180 std::unique_ptr<weld::CheckButton> m_xUseUserDataCB;
181 std::unique_ptr<weld::Button> m_xDeleteBtn;
182 std::unique_ptr<weld::CheckButton> m_xUseThumbnailSaveCB;
184 std::unique_ptr<weld::Label> m_xTemplFt;
185 std::unique_ptr<weld::Label> m_xTemplValFt;
186 std::unique_ptr<weld::CheckButton> m_xImagePreferredDpiCheckButton;
187 std::unique_ptr<weld::ComboBox> m_xImagePreferredDpiComboBox;
189 DECL_LINK(DeleteHdl, weld::Button&, void);
190 DECL_LINK(SignatureHdl, weld::Button&, void);
191 DECL_LINK(ChangePassHdl, weld::Button&, void);
192 DECL_LINK(ImagePreferredDPICheckBoxClicked, weld::ToggleButton&, void);
194 void ImplUpdateSignatures();
195 void ImplCheckPasswordState();
197 virtual bool FillItemSet( SfxItemSet* ) override;
198 virtual void Reset( const SfxItemSet* ) override;
200 public:
201 SfxDocumentPage(weld::Container* pPage, weld::DialogController* pController, const SfxItemSet&);
202 static std::unique_ptr<SfxTabPage> Create( weld::Container* pPage, weld::DialogController* pController, const SfxItemSet* );
203 virtual ~SfxDocumentPage() override;
205 void EnableUseUserData();
208 // class SfxDocumentDescPage ---------------------------------------------
210 class SfxDocumentDescPage final : public SfxTabPage
212 private:
213 SfxDocumentInfoItem* m_pInfoItem;
214 std::unique_ptr<weld::Entry> m_xTitleEd;
215 std::unique_ptr<weld::Entry> m_xThemaEd;
216 std::unique_ptr<weld::Entry> m_xKeywordsEd;
217 std::unique_ptr<weld::TextView> m_xCommentEd;
219 virtual bool FillItemSet( SfxItemSet* ) override;
220 virtual void Reset( const SfxItemSet* ) override;
222 public:
223 SfxDocumentDescPage(weld::Container* pPage, weld::DialogController* pController, const SfxItemSet&);
224 virtual ~SfxDocumentDescPage() override;
225 static std::unique_ptr<SfxTabPage> Create( weld::Container* pPage, weld::DialogController* pController, const SfxItemSet* );
228 // class SfxDocumentInfoDialog -------------------------------------------
230 class SFX2_DLLPUBLIC SfxDocumentInfoDialog final : public SfxTabDialogController
232 virtual void PageCreated(const OString& rId, SfxTabPage& rPage) override;
234 public:
235 SfxDocumentInfoDialog(weld::Window* pParent, const SfxItemSet&);
236 void AddFontTabPage();
239 // class CustomPropertiesRemoveButton ------------------------------------
240 struct CustomPropertyLine;
242 class CustomPropertiesDateField
244 private:
245 std::unique_ptr<SvtCalendarBox> m_xDateField;
246 public:
247 ::std::optional<sal_Int16> m_TZ;
249 CustomPropertiesDateField(SvtCalendarBox* pDateField);
250 void set_visible(bool bVisible);
251 Date get_date() const;
252 void set_date(const Date& rDate);
253 ~CustomPropertiesDateField();
256 namespace weld
258 class TimeFormatter;
261 class CustomPropertiesTimeField
263 public:
264 std::unique_ptr<weld::FormattedSpinButton> m_xTimeField;
265 std::unique_ptr<weld::TimeFormatter> m_xFormatter;
266 bool m_isUTC;
268 CustomPropertiesTimeField(std::unique_ptr<weld::FormattedSpinButton> xTimeField);
269 void set_visible(bool bVisible) { m_xTimeField->set_visible(bVisible); }
270 tools::Time get_value() const;
271 void set_value(const tools::Time& rTime);
273 ~CustomPropertiesTimeField();
276 class CustomPropertiesDurationField
278 css::util::Duration m_aDuration;
279 std::unique_ptr<weld::Entry> m_xEntry;
280 std::unique_ptr<weld::Button> m_xEditButton;
282 DECL_LINK(ClickHdl, weld::Button&, void);
283 public:
284 CustomPropertiesDurationField(std::unique_ptr<weld::Entry> xEntry,
285 std::unique_ptr<weld::Button> xEditButton);
287 void SetDuration( const css::util::Duration& rDuration );
288 const css::util::Duration& GetDuration() const { return m_aDuration; }
290 void set_visible(bool bVisible);
293 class CustomPropertiesYesNoButton
295 private:
296 std::unique_ptr<weld::Widget> m_xTopLevel;
297 std::unique_ptr<weld::RadioButton> m_xYesButton;
298 std::unique_ptr<weld::RadioButton> m_xNoButton;
300 public:
301 CustomPropertiesYesNoButton(std::unique_ptr<weld::Widget>,
302 std::unique_ptr<weld::RadioButton> xYesButton,
303 std::unique_ptr<weld::RadioButton> xNoButton);
304 ~CustomPropertiesYesNoButton();
306 void CheckYes() { m_xYesButton->set_active(true); }
307 void CheckNo() { m_xNoButton->set_active(true); }
308 bool IsYesChecked() const { return m_xYesButton->get_active(); }
309 void set_visible(bool bVisible) { m_xTopLevel->set_visible(bVisible); }
312 class CustomPropertiesWindow;
314 // struct CustomPropertyLine ---------------------------------------------
315 struct CustomPropertyLine
317 CustomPropertiesWindow* m_pParent;
319 std::unique_ptr<weld::Builder> m_xBuilder;
320 std::unique_ptr<weld::Container> m_xLine;
321 std::unique_ptr<weld::ComboBox> m_xNameBox;
322 std::unique_ptr<weld::ComboBox> m_xTypeBox;
323 std::unique_ptr<weld::Entry> m_xValueEdit;
324 std::unique_ptr<weld::Widget> m_xDateTimeBox;
325 std::unique_ptr<CustomPropertiesDateField> m_xDateField;
326 std::unique_ptr<CustomPropertiesTimeField> m_xTimeField;
327 std::unique_ptr<weld::Widget> m_xDurationBox;
328 std::unique_ptr<CustomPropertiesDurationField> m_xDurationField;
329 std::unique_ptr<CustomPropertiesYesNoButton> m_xYesNoButton;
330 std::unique_ptr<weld::Button> m_xRemoveButton;
332 bool m_bTypeLostFocus;
334 CustomPropertyLine(CustomPropertiesWindow* pParent, weld::Widget* pContainer);
335 DECL_LINK(TypeHdl, weld::ComboBox&, void);
336 DECL_LINK(RemoveHdl, weld::Button&, void);
337 DECL_LINK(EditLoseFocusHdl, weld::Widget&, void);
338 DECL_LINK(BoxLoseFocusHdl, weld::Widget&, void);
340 void DoTypeHdl(const weld::ComboBox& rBox);
342 void Clear();
343 void Hide();
346 // class CustomPropertiesWindow ------------------------------------------
348 class CustomPropertiesWindow
350 private:
351 sal_Int32 m_nHeight;
352 sal_Int32 m_nLineHeight;
353 sal_Int32 m_nScrollPos;
354 std::vector<std::unique_ptr<CustomProperty>> m_aCustomProperties;
355 std::vector<std::unique_ptr<CustomPropertyLine>> m_aCustomPropertiesLines;
356 CustomPropertyLine* m_pCurrentLine;
357 SvNumberFormatter m_aNumberFormatter;
358 Idle m_aEditLoseFocusIdle;
359 Idle m_aBoxLoseFocusIdle;
360 Link<void*,void> m_aRemovedHdl;
362 weld::Container& m_rBody;
363 weld::Label& m_rHeaderAccName;
364 weld::Label& m_rHeaderAccType;
365 weld::Label& m_rHeaderAccValue;
367 DECL_LINK(EditTimeoutHdl, Timer *, void);
368 DECL_LINK(BoxTimeoutHdl, Timer *, void);
370 bool IsLineValid( CustomPropertyLine* pLine ) const;
371 void ValidateLine( CustomPropertyLine* pLine, bool bIsFromTypeBox );
372 void CreateNewLine();
373 void StoreCustomProperties();
374 sal_uInt32 GetCurrentDataModelPosition() const { return -1 * m_nScrollPos / m_nLineHeight; }
376 public:
377 CustomPropertiesWindow(weld::Container& rParent, weld::Label& rHeaderAccName,
378 weld::Label& rHeaderAccType, weld::Label& rHeaderAccValue);
379 ~CustomPropertiesWindow();
381 sal_uInt16 GetExistingLineCount() const { return m_aCustomPropertiesLines.size(); }
382 sal_uInt16 GetTotalLineCount() const { return m_aCustomProperties.size(); }
383 void SetVisibleLineCount(sal_uInt32 nCount);
384 sal_Int32 GetHeight() const { return m_nHeight; }
385 void SetHeight(int nHeight) { m_nHeight = nHeight; }
386 sal_Int32 GetLineHeight() const { return m_nLineHeight; }
387 void SetLineHeight(sal_Int32 nLineHeight) { m_nLineHeight = nLineHeight; }
388 void AddLine( const OUString& sName, css::uno::Any const & rAny );
389 bool AreAllLinesValid() const;
390 void ClearAllLines();
391 void DoScroll( sal_Int32 nNewPos );
392 void ReloadLinesContent();
394 css::uno::Sequence< css::beans::PropertyValue >
395 GetCustomProperties();
396 void SetCustomProperties(std::vector< std::unique_ptr<CustomProperty> >&& rProperties);
397 void SetRemovedHdl( const Link<void*,void>& rLink ) { m_aRemovedHdl = rLink; }
399 void BoxLoseFocus(CustomPropertyLine* pLine);
400 void EditLoseFocus(CustomPropertyLine* pLine);
401 void Remove(const CustomPropertyLine* pLine);
404 // class CustomPropertiesControl -----------------------------------------
406 class CustomPropertiesControl
408 private:
409 sal_Int32 m_nThumbPos;
411 std::unique_ptr<weld::Widget> m_xBox;
412 std::unique_ptr<weld::Container> m_xBody;
413 std::unique_ptr<weld::ScrolledWindow> m_xVertScroll;
414 std::unique_ptr<CustomPropertiesWindow> m_xPropertiesWin;
415 std::unique_ptr<weld::Label> m_xName;
416 std::unique_ptr<weld::Label> m_xType;
417 std::unique_ptr<weld::Label> m_xValue;
419 DECL_LINK( ResizeHdl, const Size&, void );
420 DECL_LINK( ScrollHdl, weld::ScrolledWindow&, void );
421 DECL_LINK( RemovedHdl, void*, void );
423 public:
424 CustomPropertiesControl();
425 ~CustomPropertiesControl();
427 void AddLine(css::uno::Any const & rAny);
429 bool AreAllLinesValid() const { return m_xPropertiesWin->AreAllLinesValid(); }
430 void ClearAllLines() { m_xPropertiesWin->ClearAllLines(); }
432 css::uno::Sequence<css::beans::PropertyValue>
433 GetCustomProperties() const
434 { return m_xPropertiesWin->GetCustomProperties(); }
435 void SetCustomProperties(std::vector< std::unique_ptr<CustomProperty> >&& rProperties);
437 void Init(weld::Builder& rParent);
440 // class SfxCustomPropertiesPage -----------------------------------------
442 class SfxCustomPropertiesPage final : public SfxTabPage
444 private:
445 DECL_LINK(AddHdl, weld::Button&, void);
447 std::unique_ptr<CustomPropertiesControl> m_xPropertiesCtrl;
448 std::unique_ptr<weld::Button> m_xAdd;
450 virtual bool FillItemSet( SfxItemSet* ) override;
451 virtual void Reset( const SfxItemSet* ) override;
452 virtual DeactivateRC DeactivatePage( SfxItemSet* pSet ) override;
454 public:
455 SfxCustomPropertiesPage(weld::Container* pPage, weld::DialogController* pController, const SfxItemSet&);
456 static std::unique_ptr<SfxTabPage> Create( weld::Container* pPage, weld::DialogController* pController, const SfxItemSet* );
457 virtual ~SfxCustomPropertiesPage() override;
460 struct CmisValue
462 std::unique_ptr<weld::Builder> m_xBuilder;
463 std::unique_ptr<weld::Frame> m_xFrame;
464 std::unique_ptr<weld::Entry> m_xValueEdit;
466 CmisValue(weld::Widget* pParent, const OUString& rStr);
469 struct CmisDateTime
471 std::unique_ptr<weld::Builder> m_xBuilder;
472 std::unique_ptr<weld::Frame> m_xFrame;
473 std::unique_ptr<SvtCalendarBox> m_xDateField;
474 std::unique_ptr<weld::FormattedSpinButton> m_xTimeField;
475 std::unique_ptr<weld::TimeFormatter> m_xFormatter;
477 CmisDateTime(weld::Widget* pParent, const css::util::DateTime& rDateTime);
480 struct CmisYesNo
482 std::unique_ptr<weld::Builder> m_xBuilder;
483 std::unique_ptr<weld::Frame> m_xFrame;
484 std::unique_ptr<weld::RadioButton> m_xYesButton;
485 std::unique_ptr<weld::RadioButton> m_xNoButton;
487 CmisYesNo(weld::Widget* pParent, bool bValue);
490 // struct CmisPropertyLine ---------------------------------------------
492 struct CmisPropertyLine
494 std::unique_ptr<weld::Builder> m_xBuilder;
495 OUString m_sId;
496 OUString m_sType;
497 bool m_bUpdatable;
498 bool m_bRequired;
499 bool m_bMultiValued;
500 bool m_bOpenChoice;
501 std::unique_ptr<weld::Frame> m_xFrame;
502 std::unique_ptr<weld::Label> m_xName;
503 std::unique_ptr<weld::Label> m_xType;
504 std::vector< std::unique_ptr<CmisValue> > m_aValues;
505 std::vector< std::unique_ptr<CmisDateTime> > m_aDateTimes;
506 std::vector< std::unique_ptr<CmisYesNo> > m_aYesNos;
507 CmisPropertyLine(weld::Widget* pParent);
508 ~CmisPropertyLine();
511 // class CmisPropertiesWindow ------------------------------------------
513 class CmisPropertiesWindow
515 private:
516 std::unique_ptr<weld::Container> m_xBox;
517 SvNumberFormatter m_aNumberFormatter;
518 std::vector< std::unique_ptr<CmisPropertyLine> > m_aCmisPropertiesLines;
519 public:
520 CmisPropertiesWindow(std::unique_ptr<weld::Container> xParent);
521 ~CmisPropertiesWindow();
523 void AddLine( const OUString& sId, const OUString& sName,
524 const OUString& sType, const bool bUpdatable,
525 const bool bRequired, const bool bMultiValued,
526 const bool bOpenChoice,
527 css::uno::Any& aChoices,
528 css::uno::Any const & rAny );
529 void ClearAllLines();
531 css::uno::Sequence< css::document::CmisProperty >
532 GetCmisProperties() const;
535 // class CmisPropertiesControl -----------------------------------------
537 class CmisPropertiesControl
539 private:
540 CmisPropertiesWindow m_aPropertiesWin;
541 std::unique_ptr<weld::ScrolledWindow> m_xScrolledWindow;
543 public:
544 CmisPropertiesControl(weld::Builder& rBuilder);
546 void AddLine( const OUString& sId, const OUString& sName,
547 const OUString& sType, const bool bUpdatable,
548 const bool bRequired, const bool bMultiValude,
549 const bool bOpenChoice,
550 css::uno::Any& aChoices,
551 css::uno::Any const & rAny );
553 void ClearAllLines();
554 css::uno::Sequence< css::document::CmisProperty >
555 GetCmisProperties() const
556 { return m_aPropertiesWin.GetCmisProperties(); }
559 // class SfxCmisPropertiesPage -------------------------------------------------
561 class SfxCmisPropertiesPage final : public SfxTabPage
563 private:
564 std::unique_ptr<CmisPropertiesControl> m_xPropertiesCtrl;
566 virtual bool FillItemSet( SfxItemSet* ) override;
567 virtual void Reset( const SfxItemSet* ) override;
568 virtual DeactivateRC DeactivatePage( SfxItemSet* pSet ) override;
570 public:
571 SfxCmisPropertiesPage(weld::Container* pPage, weld::DialogController* pController, const SfxItemSet&);
572 virtual ~SfxCmisPropertiesPage() override;
573 static std::unique_ptr<SfxTabPage> Create(weld::Container* pPage, weld::DialogController* pController, const SfxItemSet*);
576 #endif // #ifndef _ INCLUDED_SFX2_DINFDLG_HXX
578 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */