diff options
-rw-r--r-- | include/sfx2/dinfdlg.hxx | 13 | ||||
-rw-r--r-- | include/vcl/weld.hxx | 7 | ||||
-rw-r--r-- | sfx2/source/dialog/dinfdlg.cxx | 72 | ||||
-rw-r--r-- | sfx2/uiconfig/ui/descriptioninfopage.ui | 14 |
4 files changed, 51 insertions, 55 deletions
diff --git a/include/sfx2/dinfdlg.hxx b/include/sfx2/dinfdlg.hxx index 2e61a28583ee..66c5726e8eca 100644 --- a/include/sfx2/dinfdlg.hxx +++ b/include/sfx2/dinfdlg.hxx @@ -225,21 +225,20 @@ public: class SfxDocumentDescPage : public SfxTabPage { private: - VclPtr<Edit> m_pTitleEd; - VclPtr<Edit> m_pThemaEd; - VclPtr<Edit> m_pKeywordsEd; - VclPtr<VclMultiLineEdit> m_pCommentEd; - SfxDocumentInfoItem* m_pInfoItem; + SfxDocumentInfoItem* m_pInfoItem; + std::unique_ptr<weld::Entry> m_xTitleEd; + std::unique_ptr<weld::Entry> m_xThemaEd; + std::unique_ptr<weld::Entry> m_xKeywordsEd; + std::unique_ptr<weld::TextView> m_xCommentEd; protected: virtual ~SfxDocumentDescPage() override; - virtual void dispose() override; virtual bool FillItemSet( SfxItemSet* ) override; virtual void Reset( const SfxItemSet* ) override; public: - SfxDocumentDescPage( vcl::Window* pParent, const SfxItemSet& ); + SfxDocumentDescPage(TabPageParent pParent, const SfxItemSet&); static VclPtr<SfxTabPage> Create( TabPageParent pParent, const SfxItemSet* ); }; diff --git a/include/vcl/weld.hxx b/include/vcl/weld.hxx index 68c5b48363d5..b15b77d0aff8 100644 --- a/include/vcl/weld.hxx +++ b/include/vcl/weld.hxx @@ -494,7 +494,6 @@ public: } void save_value() { m_sSavedValue = get_text(); } - bool get_value_changed_from_saved() const { return m_sSavedValue != get_text(); } }; @@ -777,6 +776,9 @@ public: class VCL_DLLPUBLIC TextView : virtual public Container { +private: + OUString m_sSavedValue; + public: virtual void set_text(const OUString& rText) = 0; virtual OUString get_text() const = 0; @@ -789,6 +791,9 @@ public: //can improve this if needed return get_text_height() * nRows; } + + void save_value() { m_sSavedValue = get_text(); } + bool get_value_changed_from_saved() const { return m_sSavedValue != get_text(); } }; class VCL_DLLPUBLIC Expander : virtual public Container diff --git a/sfx2/source/dialog/dinfdlg.cxx b/sfx2/source/dialog/dinfdlg.cxx index cd435adafa31..a2bacfe4e008 100644 --- a/sfx2/source/dialog/dinfdlg.cxx +++ b/sfx2/source/dialog/dinfdlg.cxx @@ -604,45 +604,34 @@ bool SfxDocumentInfoItem::PutValue( const Any& rVal, sal_uInt8 nMemberId ) return bRet; } -SfxDocumentDescPage::SfxDocumentDescPage( vcl::Window * pParent, const SfxItemSet& rItemSet ) - : SfxTabPage(pParent, "DescriptionInfoPage", "sfx/ui/descriptioninfopage.ui", &rItemSet) - , m_pInfoItem ( nullptr ) - +SfxDocumentDescPage::SfxDocumentDescPage(TabPageParent pParent, const SfxItemSet& rItemSet) + : SfxTabPage(pParent, "sfx/ui/descriptioninfopage.ui", "DescriptionInfoPage", &rItemSet) + , m_pInfoItem( nullptr) + , m_xTitleEd(m_xBuilder->weld_entry("title")) + , m_xThemaEd(m_xBuilder->weld_entry("subject")) + , m_xKeywordsEd(m_xBuilder->weld_entry("keywords")) + , m_xCommentEd(m_xBuilder->weld_text_view("comments")) { - get(m_pTitleEd, "title"); - get(m_pThemaEd, "subject"); - get(m_pKeywordsEd, "keywords"); - get(m_pCommentEd, "comments"); - m_pCommentEd->set_width_request(m_pKeywordsEd->get_preferred_size().Width()); - m_pCommentEd->set_height_request(m_pCommentEd->GetTextHeight() * 16); + m_xCommentEd->set_size_request(m_xKeywordsEd->get_preferred_size().Width(), + m_xCommentEd->get_height_rows(16)); } SfxDocumentDescPage::~SfxDocumentDescPage() { - disposeOnce(); -} - -void SfxDocumentDescPage::dispose() -{ - m_pTitleEd.clear(); - m_pThemaEd.clear(); - m_pKeywordsEd.clear(); - m_pCommentEd.clear(); - SfxTabPage::dispose(); } VclPtr<SfxTabPage> SfxDocumentDescPage::Create(TabPageParent pParent, const SfxItemSet *rItemSet) { - return VclPtr<SfxDocumentDescPage>::Create(pParent.pParent, *rItemSet); + return VclPtr<SfxDocumentDescPage>::Create(pParent, *rItemSet); } bool SfxDocumentDescPage::FillItemSet(SfxItemSet *rSet) { // Test whether a change is present - const bool bTitleMod = m_pTitleEd->IsModified(); - const bool bThemeMod = m_pThemaEd->IsModified(); - const bool bKeywordsMod = m_pKeywordsEd->IsModified(); - const bool bCommentMod = m_pCommentEd->IsModified(); + const bool bTitleMod = m_xTitleEd->get_value_changed_from_saved(); + const bool bThemeMod = m_xThemaEd->get_value_changed_from_saved(); + const bool bKeywordsMod = m_xKeywordsEd->get_value_changed_from_saved(); + const bool bCommentMod = m_xCommentEd->get_value_changed_from_saved(); if ( !( bTitleMod || bThemeMod || bKeywordsMod || bCommentMod ) ) { return false; @@ -670,19 +659,19 @@ bool SfxDocumentDescPage::FillItemSet(SfxItemSet *rSet) if ( bTitleMod ) { - pInfo->setTitle( m_pTitleEd->GetText() ); + pInfo->setTitle( m_xTitleEd->get_text() ); } if ( bThemeMod ) { - pInfo->setSubject( m_pThemaEd->GetText() ); + pInfo->setSubject( m_xThemaEd->get_text() ); } if ( bKeywordsMod ) { - pInfo->setKeywords( m_pKeywordsEd->GetText() ); + pInfo->setKeywords( m_xKeywordsEd->get_text() ); } if ( bCommentMod ) { - pInfo->setDescription( m_pCommentEd->GetText() ); + pInfo->setDescription( m_xCommentEd->get_text() ); } rSet->Put( *pInfo ); if ( pInfo != m_pInfoItem ) @@ -693,27 +682,30 @@ bool SfxDocumentDescPage::FillItemSet(SfxItemSet *rSet) return true; } - void SfxDocumentDescPage::Reset(const SfxItemSet *rSet) { m_pInfoItem = const_cast<SfxDocumentInfoItem*>(&rSet->Get(SID_DOCINFO)); - m_pTitleEd->SetText( m_pInfoItem->getTitle() ); - m_pThemaEd->SetText( m_pInfoItem->getSubject() ); - m_pKeywordsEd->SetText( m_pInfoItem->getKeywords() ); - m_pCommentEd->SetText( m_pInfoItem->getDescription() ); + m_xTitleEd->set_text(m_pInfoItem->getTitle()); + m_xThemaEd->set_text(m_pInfoItem->getSubject()); + m_xKeywordsEd->set_text(m_pInfoItem->getKeywords()); + m_xCommentEd->set_text(m_pInfoItem->getDescription()); + + m_xTitleEd->save_value(); + m_xThemaEd->save_value(); + m_xKeywordsEd->save_value(); + m_xCommentEd->save_value(); const SfxBoolItem* pROItem = SfxItemSet::GetItem<SfxBoolItem>(rSet, SID_DOC_READONLY, false); - if ( pROItem && pROItem->GetValue() ) + if (pROItem && pROItem->GetValue()) { - m_pTitleEd->SetReadOnly(); - m_pThemaEd->SetReadOnly(); - m_pKeywordsEd->SetReadOnly(); - m_pCommentEd->SetReadOnly(); + m_xTitleEd->set_editable(false); + m_xThemaEd->set_editable(false); + m_xKeywordsEd->set_editable(false); + m_xCommentEd->set_editable(false); } } - namespace { OUString GetDateTimeString( sal_Int32 _nDate, sal_Int32 _nTime ) diff --git a/sfx2/uiconfig/ui/descriptioninfopage.ui b/sfx2/uiconfig/ui/descriptioninfopage.ui index 29e68e4d558e..f2db5badd612 100644 --- a/sfx2/uiconfig/ui/descriptioninfopage.ui +++ b/sfx2/uiconfig/ui/descriptioninfopage.ui @@ -1,5 +1,5 @@ <?xml version="1.0" encoding="UTF-8"?> -<!-- Generated with glade 3.18.3 --> +<!-- Generated with glade 3.22.1 --> <interface domain="sfx"> <requires lib="gtk+" version="3.18"/> <object class="GtkGrid" id="DescriptionInfoPage"> @@ -14,10 +14,10 @@ <object class="GtkLabel" id="label27"> <property name="visible">True</property> <property name="can_focus">False</property> - <property name="xalign">1</property> <property name="label" translatable="yes" context="descriptioninfopage|label27">_Title:</property> <property name="use_underline">True</property> <property name="mnemonic_widget">title</property> + <property name="xalign">1</property> </object> <packing> <property name="left_attach">0</property> @@ -28,10 +28,10 @@ <object class="GtkLabel" id="label28"> <property name="visible">True</property> <property name="can_focus">False</property> - <property name="xalign">1</property> <property name="label" translatable="yes" context="descriptioninfopage|label28">_Subject:</property> <property name="use_underline">True</property> <property name="mnemonic_widget">subject</property> + <property name="xalign">1</property> </object> <packing> <property name="left_attach">0</property> @@ -42,10 +42,10 @@ <object class="GtkLabel" id="label29"> <property name="visible">True</property> <property name="can_focus">False</property> - <property name="xalign">1</property> <property name="label" translatable="yes" context="descriptioninfopage|label29">_Keywords:</property> <property name="use_underline">True</property> <property name="mnemonic_widget">keywords</property> + <property name="xalign">1</property> </object> <packing> <property name="left_attach">0</property> @@ -57,10 +57,10 @@ <property name="visible">True</property> <property name="can_focus">False</property> <property name="valign">start</property> - <property name="xalign">1</property> <property name="label" translatable="yes" context="descriptioninfopage|label30">_Comments:</property> <property name="use_underline">True</property> - <property name="mnemonic_widget">comments:border</property> + <property name="mnemonic_widget">comments</property> + <property name="xalign">1</property> </object> <packing> <property name="left_attach">0</property> @@ -108,7 +108,7 @@ <property name="vexpand">True</property> <property name="shadow_type">in</property> <child> - <object class="GtkTextView" id="comments:border"> + <object class="GtkTextView" id="comments"> <property name="visible">True</property> <property name="can_focus">True</property> <property name="hexpand">True</property> |