weld SfxDocumentDescPage

Change-Id: I52abfe33e39fbb2e96fe0634b9ac3d8d50068ee7
Reviewed-on: https://gerrit.libreoffice.org/55988
Tested-by: Jenkins
Reviewed-by: Caolán McNamara <caolanm@redhat.com>
Tested-by: Caolán McNamara <caolanm@redhat.com>
This commit is contained in:
Caolán McNamara
2018-06-18 10:32:50 +01:00
parent 4b6d171592
commit 294e66018d
4 changed files with 51 additions and 55 deletions

View File

@@ -225,21 +225,20 @@ public:
class SfxDocumentDescPage : public SfxTabPage class SfxDocumentDescPage : public SfxTabPage
{ {
private: 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: protected:
virtual ~SfxDocumentDescPage() override; virtual ~SfxDocumentDescPage() override;
virtual void dispose() override;
virtual bool FillItemSet( SfxItemSet* ) override; virtual bool FillItemSet( SfxItemSet* ) override;
virtual void Reset( const SfxItemSet* ) override; virtual void Reset( const SfxItemSet* ) override;
public: public:
SfxDocumentDescPage( vcl::Window* pParent, const SfxItemSet& ); SfxDocumentDescPage(TabPageParent pParent, const SfxItemSet&);
static VclPtr<SfxTabPage> Create( TabPageParent pParent, const SfxItemSet* ); static VclPtr<SfxTabPage> Create( TabPageParent pParent, const SfxItemSet* );
}; };

View File

@@ -494,7 +494,6 @@ public:
} }
void save_value() { m_sSavedValue = get_text(); } void save_value() { m_sSavedValue = get_text(); }
bool get_value_changed_from_saved() const { return 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 class VCL_DLLPUBLIC TextView : virtual public Container
{ {
private:
OUString m_sSavedValue;
public: public:
virtual void set_text(const OUString& rText) = 0; virtual void set_text(const OUString& rText) = 0;
virtual OUString get_text() const = 0; virtual OUString get_text() const = 0;
@@ -789,6 +791,9 @@ public:
//can improve this if needed //can improve this if needed
return get_text_height() * nRows; 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 class VCL_DLLPUBLIC Expander : virtual public Container

View File

@@ -604,45 +604,34 @@ bool SfxDocumentInfoItem::PutValue( const Any& rVal, sal_uInt8 nMemberId )
return bRet; return bRet;
} }
SfxDocumentDescPage::SfxDocumentDescPage( vcl::Window * pParent, const SfxItemSet& rItemSet ) SfxDocumentDescPage::SfxDocumentDescPage(TabPageParent pParent, const SfxItemSet& rItemSet)
: SfxTabPage(pParent, "DescriptionInfoPage", "sfx/ui/descriptioninfopage.ui", &rItemSet) : SfxTabPage(pParent, "sfx/ui/descriptioninfopage.ui", "DescriptionInfoPage", &rItemSet)
, m_pInfoItem ( nullptr ) , 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"); m_xCommentEd->set_size_request(m_xKeywordsEd->get_preferred_size().Width(),
get(m_pThemaEd, "subject"); m_xCommentEd->get_height_rows(16));
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);
} }
SfxDocumentDescPage::~SfxDocumentDescPage() 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) 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) bool SfxDocumentDescPage::FillItemSet(SfxItemSet *rSet)
{ {
// Test whether a change is present // Test whether a change is present
const bool bTitleMod = m_pTitleEd->IsModified(); const bool bTitleMod = m_xTitleEd->get_value_changed_from_saved();
const bool bThemeMod = m_pThemaEd->IsModified(); const bool bThemeMod = m_xThemaEd->get_value_changed_from_saved();
const bool bKeywordsMod = m_pKeywordsEd->IsModified(); const bool bKeywordsMod = m_xKeywordsEd->get_value_changed_from_saved();
const bool bCommentMod = m_pCommentEd->IsModified(); const bool bCommentMod = m_xCommentEd->get_value_changed_from_saved();
if ( !( bTitleMod || bThemeMod || bKeywordsMod || bCommentMod ) ) if ( !( bTitleMod || bThemeMod || bKeywordsMod || bCommentMod ) )
{ {
return false; return false;
@@ -670,19 +659,19 @@ bool SfxDocumentDescPage::FillItemSet(SfxItemSet *rSet)
if ( bTitleMod ) if ( bTitleMod )
{ {
pInfo->setTitle( m_pTitleEd->GetText() ); pInfo->setTitle( m_xTitleEd->get_text() );
} }
if ( bThemeMod ) if ( bThemeMod )
{ {
pInfo->setSubject( m_pThemaEd->GetText() ); pInfo->setSubject( m_xThemaEd->get_text() );
} }
if ( bKeywordsMod ) if ( bKeywordsMod )
{ {
pInfo->setKeywords( m_pKeywordsEd->GetText() ); pInfo->setKeywords( m_xKeywordsEd->get_text() );
} }
if ( bCommentMod ) if ( bCommentMod )
{ {
pInfo->setDescription( m_pCommentEd->GetText() ); pInfo->setDescription( m_xCommentEd->get_text() );
} }
rSet->Put( *pInfo ); rSet->Put( *pInfo );
if ( pInfo != m_pInfoItem ) if ( pInfo != m_pInfoItem )
@@ -693,27 +682,30 @@ bool SfxDocumentDescPage::FillItemSet(SfxItemSet *rSet)
return true; return true;
} }
void SfxDocumentDescPage::Reset(const SfxItemSet *rSet) void SfxDocumentDescPage::Reset(const SfxItemSet *rSet)
{ {
m_pInfoItem = const_cast<SfxDocumentInfoItem*>(&rSet->Get(SID_DOCINFO)); m_pInfoItem = const_cast<SfxDocumentInfoItem*>(&rSet->Get(SID_DOCINFO));
m_pTitleEd->SetText( m_pInfoItem->getTitle() ); m_xTitleEd->set_text(m_pInfoItem->getTitle());
m_pThemaEd->SetText( m_pInfoItem->getSubject() ); m_xThemaEd->set_text(m_pInfoItem->getSubject());
m_pKeywordsEd->SetText( m_pInfoItem->getKeywords() ); m_xKeywordsEd->set_text(m_pInfoItem->getKeywords());
m_pCommentEd->SetText( m_pInfoItem->getDescription() ); 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); const SfxBoolItem* pROItem = SfxItemSet::GetItem<SfxBoolItem>(rSet, SID_DOC_READONLY, false);
if ( pROItem && pROItem->GetValue() ) if (pROItem && pROItem->GetValue())
{ {
m_pTitleEd->SetReadOnly(); m_xTitleEd->set_editable(false);
m_pThemaEd->SetReadOnly(); m_xThemaEd->set_editable(false);
m_pKeywordsEd->SetReadOnly(); m_xKeywordsEd->set_editable(false);
m_pCommentEd->SetReadOnly(); m_xCommentEd->set_editable(false);
} }
} }
namespace namespace
{ {
OUString GetDateTimeString( sal_Int32 _nDate, sal_Int32 _nTime ) OUString GetDateTimeString( sal_Int32 _nDate, sal_Int32 _nTime )

View File

@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="UTF-8"?> <?xml version="1.0" encoding="UTF-8"?>
<!-- Generated with glade 3.18.3 --> <!-- Generated with glade 3.22.1 -->
<interface domain="sfx"> <interface domain="sfx">
<requires lib="gtk+" version="3.18"/> <requires lib="gtk+" version="3.18"/>
<object class="GtkGrid" id="DescriptionInfoPage"> <object class="GtkGrid" id="DescriptionInfoPage">
@@ -14,10 +14,10 @@
<object class="GtkLabel" id="label27"> <object class="GtkLabel" id="label27">
<property name="visible">True</property> <property name="visible">True</property>
<property name="can_focus">False</property> <property name="can_focus">False</property>
<property name="xalign">1</property>
<property name="label" translatable="yes" context="descriptioninfopage|label27">_Title:</property> <property name="label" translatable="yes" context="descriptioninfopage|label27">_Title:</property>
<property name="use_underline">True</property> <property name="use_underline">True</property>
<property name="mnemonic_widget">title</property> <property name="mnemonic_widget">title</property>
<property name="xalign">1</property>
</object> </object>
<packing> <packing>
<property name="left_attach">0</property> <property name="left_attach">0</property>
@@ -28,10 +28,10 @@
<object class="GtkLabel" id="label28"> <object class="GtkLabel" id="label28">
<property name="visible">True</property> <property name="visible">True</property>
<property name="can_focus">False</property> <property name="can_focus">False</property>
<property name="xalign">1</property>
<property name="label" translatable="yes" context="descriptioninfopage|label28">_Subject:</property> <property name="label" translatable="yes" context="descriptioninfopage|label28">_Subject:</property>
<property name="use_underline">True</property> <property name="use_underline">True</property>
<property name="mnemonic_widget">subject</property> <property name="mnemonic_widget">subject</property>
<property name="xalign">1</property>
</object> </object>
<packing> <packing>
<property name="left_attach">0</property> <property name="left_attach">0</property>
@@ -42,10 +42,10 @@
<object class="GtkLabel" id="label29"> <object class="GtkLabel" id="label29">
<property name="visible">True</property> <property name="visible">True</property>
<property name="can_focus">False</property> <property name="can_focus">False</property>
<property name="xalign">1</property>
<property name="label" translatable="yes" context="descriptioninfopage|label29">_Keywords:</property> <property name="label" translatable="yes" context="descriptioninfopage|label29">_Keywords:</property>
<property name="use_underline">True</property> <property name="use_underline">True</property>
<property name="mnemonic_widget">keywords</property> <property name="mnemonic_widget">keywords</property>
<property name="xalign">1</property>
</object> </object>
<packing> <packing>
<property name="left_attach">0</property> <property name="left_attach">0</property>
@@ -57,10 +57,10 @@
<property name="visible">True</property> <property name="visible">True</property>
<property name="can_focus">False</property> <property name="can_focus">False</property>
<property name="valign">start</property> <property name="valign">start</property>
<property name="xalign">1</property>
<property name="label" translatable="yes" context="descriptioninfopage|label30">_Comments:</property> <property name="label" translatable="yes" context="descriptioninfopage|label30">_Comments:</property>
<property name="use_underline">True</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> </object>
<packing> <packing>
<property name="left_attach">0</property> <property name="left_attach">0</property>
@@ -108,7 +108,7 @@
<property name="vexpand">True</property> <property name="vexpand">True</property>
<property name="shadow_type">in</property> <property name="shadow_type">in</property>
<child> <child>
<object class="GtkTextView" id="comments:border"> <object class="GtkTextView" id="comments">
<property name="visible">True</property> <property name="visible">True</property>
<property name="can_focus">True</property> <property name="can_focus">True</property>
<property name="hexpand">True</property> <property name="hexpand">True</property>