Kaydet (Commit) aa687b22 authored tarafından Caolán McNamara's avatar Caolán McNamara

weld SfxDocumentInfoDialog

Change-Id: I79d5d8973a19c0e639081ec61ac596620518d0b5
Reviewed-on: https://gerrit.libreoffice.org/73145
Tested-by: Jenkins
Reviewed-by: 's avatarCaolán McNamara <caolanm@redhat.com>
Tested-by: 's avatarCaolán McNamara <caolanm@redhat.com>
üst b7b78dfc
......@@ -242,15 +242,13 @@ public:
// class SfxDocumentInfoDialog -------------------------------------------
class SFX2_DLLPUBLIC SfxDocumentInfoDialog : public SfxTabDialog
class SFX2_DLLPUBLIC SfxDocumentInfoDialog : public SfxTabDialogController
{
private:
sal_uInt16 m_nDocInfoId;
protected:
virtual void PageCreated( sal_uInt16 nId, SfxTabPage& rPage ) override;
virtual void PageCreated(const OString& rId, SfxTabPage& rPage) override;
public:
SfxDocumentInfoDialog( vcl::Window* pParent, const SfxItemSet& );
SfxDocumentInfoDialog(weld::Window* pParent, const SfxItemSet&);
void AddFontTabPage();
};
......
......@@ -358,7 +358,7 @@ public:
void SignScriptingContent(weld::Window* pDialogParent);
DECL_LINK(SignDocumentHandler, Button*, void);
virtual VclPtr<SfxDocumentInfoDialog> CreateDocumentInfoDialog( const SfxItemSet& );
virtual std::unique_ptr<SfxDocumentInfoDialog> CreateDocumentInfoDialog(weld::Window* pParent, const SfxItemSet& rItemSet);
ErrCode CallBasic( const OUString& rMacro, const OUString& rBasicName,
SbxArray* pArgs, SbxValue* pRet = nullptr );
......
......@@ -2912,9 +2912,9 @@ void ScDocShell::GetDocStat( ScDocStat& rDocStat )
static_cast<sal_uInt16>(ScPrintFunc( this, pPrinter, i ).GetTotalPages()) );
}
VclPtr<SfxDocumentInfoDialog> ScDocShell::CreateDocumentInfoDialog( const SfxItemSet &rSet )
std::unique_ptr<SfxDocumentInfoDialog> ScDocShell::CreateDocumentInfoDialog(weld::Window* pParent, const SfxItemSet &rSet)
{
VclPtr<SfxDocumentInfoDialog> pDlg = VclPtr<SfxDocumentInfoDialog>::Create( nullptr, rSet );
std::unique_ptr<SfxDocumentInfoDialog> xDlg = std::make_unique<SfxDocumentInfoDialog>(pParent, rSet);
ScDocShell* pDocSh = dynamic_cast< ScDocShell *>( SfxObjectShell::Current() );
// Only for statistics, if this Doc is shown; not from the Doc Manager
......@@ -2923,12 +2923,10 @@ VclPtr<SfxDocumentInfoDialog> ScDocShell::CreateDocumentInfoDialog( const SfxIte
ScAbstractDialogFactory* pFact = ScAbstractDialogFactory::Create();
::CreateTabPage ScDocStatPageCreate = pFact->GetTabPageCreatorFunc(SID_SC_TP_STAT);
OSL_ENSURE(ScDocStatPageCreate, "Tabpage create fail!");
pDlg->AddFontTabPage();
pDlg->AddTabPage( 42,
ScResId( STR_DOC_STAT ),
ScDocStatPageCreate);
xDlg->AddFontTabPage();
xDlg->AddTabPage("calcstats", ScResId(STR_DOC_STAT), ScDocStatPageCreate);
}
return pDlg;
return xDlg;
}
vcl::Window* ScDocShell::GetActiveDialogParent()
......
......@@ -213,7 +213,7 @@ public:
void SetVisAreaOrSize( const tools::Rectangle& rVisArea );
virtual VclPtr<SfxDocumentInfoDialog> CreateDocumentInfoDialog( const SfxItemSet &rSet ) override;
virtual std::unique_ptr<SfxDocumentInfoDialog> CreateDocumentInfoDialog(weld::Window* pParent, const SfxItemSet &rSet) override;
void GetDocStat( ScDocStat& rDocStat );
......
......@@ -956,16 +956,15 @@ void DrawDocShell::OpenBookmark( const OUString& rBookmarkURL )
( mpViewShell ? mpViewShell->GetViewFrame() : SfxViewFrame::Current() )->GetBindings().Execute( SID_OPENHYPERLINK, ppArgs );
}
VclPtr<SfxDocumentInfoDialog> DrawDocShell::CreateDocumentInfoDialog( const SfxItemSet &rSet )
std::unique_ptr<SfxDocumentInfoDialog> DrawDocShell::CreateDocumentInfoDialog(weld::Window* pParent, const SfxItemSet &rSet)
{
VclPtr<SfxDocumentInfoDialog> pDlg = VclPtr<SfxDocumentInfoDialog>::Create( nullptr, rSet );
DrawDocShell* pDocSh = dynamic_cast< DrawDocShell *>( SfxObjectShell::Current() );
std::unique_ptr<SfxDocumentInfoDialog> xDlg = std::make_unique<SfxDocumentInfoDialog>(pParent, rSet);
DrawDocShell* pDocSh = dynamic_cast<DrawDocShell*>(SfxObjectShell::Current());
if( pDocSh == this )
{
pDlg->AddFontTabPage();
xDlg->AddFontTabPage();
}
return pDlg;
return xDlg;
}
void DrawDocShell::setEditMode(DrawViewShell* pDrawViewShell, bool isMasterPage)
......
......@@ -98,7 +98,8 @@ public:
virtual SfxStyleSheetBasePool* GetStyleSheetPool() override;
virtual void FillClass(SvGlobalName* pClassName, SotClipboardFormatId* pFormat, OUString* pAppName, OUString* pFullTypeName, OUString* pShortTypeName, sal_Int32 nFileFormat, bool bTemplate = false ) const override;
virtual void SetModified( bool = true ) override;
virtual VclPtr<SfxDocumentInfoDialog> CreateDocumentInfoDialog( const SfxItemSet &rSet ) override;
virtual std::unique_ptr<SfxDocumentInfoDialog> CreateDocumentInfoDialog(weld::Window* pParent,
const SfxItemSet &rSet) override;
using SfxObjectShell::GetVisArea;
using SfxShell::GetViewShell;
......
......@@ -87,8 +87,6 @@ using namespace ::com::sun::star::lang;
using namespace ::com::sun::star::ui::dialogs;
using namespace ::com::sun::star::uno;
const sal_uInt16 FONT_PAGE_ID = 99;
struct CustomProperty
{
OUString m_sName;
......@@ -1089,11 +1087,9 @@ void SfxDocumentPage::Reset( const SfxItemSet* rSet )
m_xUseThumbnailSaveCB->save_state();
}
SfxDocumentInfoDialog::SfxDocumentInfoDialog( vcl::Window* pParent,
const SfxItemSet& rItemSet )
: SfxTabDialog(pParent, "DocumentPropertiesDialog",
"sfx/ui/documentpropertiesdialog.ui", &rItemSet)
, m_nDocInfoId(0)
SfxDocumentInfoDialog::SfxDocumentInfoDialog(weld::Window* pParent, const SfxItemSet& rItemSet)
: SfxTabDialogController(pParent, "sfx/ui/documentpropertiesdialog.ui",
"DocumentPropertiesDialog", &rItemSet)
{
const SfxDocumentInfoItem& rInfoItem = rItemSet.Get( SID_DOCINFO );
......@@ -1104,7 +1100,7 @@ SfxDocumentInfoDialog::SfxDocumentInfoDialog( vcl::Window* pParent,
// Determine the Titles
const SfxPoolItem* pItem = nullptr;
OUString aTitle( GetText() );
OUString aTitle(m_xDialog->get_title());
if ( SfxItemState::SET !=
rItemSet.GetItemState( SID_EXPLORER_PROPS_START, false, &pItem ) )
{
......@@ -1131,27 +1127,26 @@ SfxDocumentInfoDialog::SfxDocumentInfoDialog( vcl::Window* pParent,
"SfxDocumentInfoDialog:<SfxStringItem> expected" );
aTitle = aTitle.replaceFirst("%1", static_cast<const SfxStringItem*>(pItem)->GetValue());
}
SetText( aTitle );
m_xDialog->set_title(aTitle);
// Property Pages
m_nDocInfoId = AddTabPage("general", SfxDocumentPage::Create);
AddTabPage("description", SfxDocumentDescPage::Create);
AddTabPage("customprops", SfxCustomPropertiesPage::Create);
AddTabPage("cmisprops", SfxCmisPropertiesPage::Create);
AddTabPage("security", SfxSecurityPage::Create);
AddTabPage("general", SfxDocumentPage::Create, nullptr);
AddTabPage("description", SfxDocumentDescPage::Create, nullptr);
AddTabPage("customprops", SfxCustomPropertiesPage::Create, nullptr);
AddTabPage("cmisprops", SfxCmisPropertiesPage::Create, nullptr);
AddTabPage("security", SfxSecurityPage::Create, nullptr);
}
void SfxDocumentInfoDialog::PageCreated( sal_uInt16 nId, SfxTabPage &rPage )
void SfxDocumentInfoDialog::PageCreated(const OString& rId, SfxTabPage &rPage)
{
if ( m_nDocInfoId == nId )
if (rId == "general")
static_cast<SfxDocumentPage&>(rPage).EnableUseUserData();
}
void SfxDocumentInfoDialog::AddFontTabPage()
{
AddTabPage(FONT_PAGE_ID, SfxResId(STR_FONT_TABPAGE), SfxDocumentFontsPage::Create);
SetPageName(FONT_PAGE_ID , "font");
AddTabPage("font", SfxResId(STR_FONT_TABPAGE), SfxDocumentFontsPage::Create);
}
// class CustomPropertiesYesNoButton -------------------------------------
......@@ -1263,6 +1258,8 @@ namespace
{
for (size_t i = 0; i < SAL_N_ELEMENTS(SFX_CB_PROPERTY_STRINGARRAY); ++i)
rNameBox.append_text(SfxResId(SFX_CB_PROPERTY_STRINGARRAY[i]));
Size aSize(rNameBox.get_preferred_size());
rNameBox.set_size_request(aSize.Width(), aSize.Height());
}
void fillTypeBox(weld::ComboBox& rTypeBox)
......@@ -1273,6 +1270,8 @@ namespace
rTypeBox.append(sId, SfxResId(SFX_LB_PROPERTY_STRINGARRAY[i].first));
}
rTypeBox.set_active(0);
Size aSize(rTypeBox.get_preferred_size());
rTypeBox.set_size_request(aSize.Width(), aSize.Height());
}
}
......@@ -1781,7 +1780,7 @@ void CustomPropertiesControl::Init(weld::Builder& rBuilder)
std::unique_ptr<CustomPropertyLine> xNewLine(new CustomPropertyLine(m_xPropertiesWin.get(), m_xBody.get()));
Size aLineSize(xNewLine->m_xLine->get_preferred_size());
m_xPropertiesWin->SetLineHeight(aLineSize.Height() + 6);
m_xBody->set_size_request(aLineSize.Width(), -1);
m_xBody->set_size_request(aLineSize.Width() + 6, -1);
auto nHeight = aLineSize.Height() * 8;
m_xVertScroll->set_size_request(-1, nHeight + 6);
......@@ -1808,6 +1807,8 @@ void CustomPropertiesControl::Init(weld::Builder& rBuilder)
IMPL_LINK(CustomPropertiesControl, ResizeHdl, const Size&, rSize, void)
{
int nHeight = rSize.Height() - 6;
if (nHeight == m_xPropertiesWin->GetHeight())
return;
m_xPropertiesWin->SetHeight(nHeight);
sal_Int32 nScrollOffset = m_xPropertiesWin->GetLineHeight();
sal_Int32 nVisibleEntries = nHeight / nScrollOffset;
......
......@@ -282,16 +282,12 @@ void SfxObjectShell::UpdateTime_Impl(
}
}
VclPtr<SfxDocumentInfoDialog> SfxObjectShell::CreateDocumentInfoDialog
(
const SfxItemSet& rSet
)
std::unique_ptr<SfxDocumentInfoDialog> SfxObjectShell::CreateDocumentInfoDialog(weld::Window* pParent,
const SfxItemSet& rSet)
{
return VclPtr<SfxDocumentInfoDialog>::Create(nullptr, rSet);
return std::make_unique<SfxDocumentInfoDialog>(pParent, rSet);
}
std::set<Color> SfxObjectShell::GetDocColors()
{
std::set<Color> empty;
......
......@@ -500,16 +500,13 @@ void SfxObjectShell::ExecFile_Impl(SfxRequest &rReq)
// creating dialog is done via virtual method; application will
// add its own statistics page
VclAbstractDialog::AsyncContext aCtx;
std::shared_ptr<SfxRequest> pReq = std::make_shared<SfxRequest>(rReq);
VclPtr<SfxDocumentInfoDialog> pDlg(CreateDocumentInfoDialog(aSet));
aCtx.mxOwner = pDlg;
aCtx.maEndDialogFn = [this, pDlg, xCmisDoc, pReq](sal_Int32 nResult)
std::shared_ptr<SfxDocumentInfoDialog> xDlg(CreateDocumentInfoDialog(rReq.GetFrameWeld(), aSet));
SfxTabDialogController::runAsync(xDlg, [this, xDlg, xCmisDoc, pReq](sal_Int32 nResult)
{
if (RET_OK == nResult)
{
const SfxDocumentInfoItem* pDocInfoItem = SfxItemSet::GetItem<SfxDocumentInfoItem>(pDlg->GetOutputItemSet(), SID_DOCINFO, false);
const SfxDocumentInfoItem* pDocInfoItem = SfxItemSet::GetItem<SfxDocumentInfoItem>(xDlg->GetOutputItemSet(), SID_DOCINFO, false);
if ( pDocInfoItem )
{
// user has done some changes to DocumentInfo
......@@ -537,9 +534,8 @@ void SfxObjectShell::ExecFile_Impl(SfxRequest &rReq)
else
// nothing done; no recording
pReq->Ignore();
};
});
pDlg->StartExecuteAsync(aCtx);
rReq.Ignore();
}
......
......@@ -96,6 +96,8 @@
<object class="GtkBox" id="properties">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="valign">start</property>
<property name="vexpand">False</property>
<property name="border_width">3</property>
<property name="orientation">vertical</property>
<property name="spacing">6</property>
......
<?xml version="1.0" encoding="UTF-8"?>
<!-- Generated with glade 3.20.0 -->
<!-- Generated with glade 3.22.1 -->
<interface domain="sfx">
<requires lib="gtk+" version="3.18"/>
<object class="GtkDialog" id="DocumentPropertiesDialog">
<property name="can_focus">False</property>
<property name="border_width">6</property>
<property name="title" translatable="yes" context="documentpropertiesdialog|DocumentPropertiesDialog">Properties of “%1”</property>
<property name="modal">True</property>
<property name="default_width">0</property>
<property name="default_height">0</property>
<property name="type_hint">dialog</property>
<child>
<placeholder/>
</child>
<child internal-child="vbox">
<object class="GtkBox" id="dialog-vbox1">
<property name="can_focus">False</property>
......@@ -17,12 +23,10 @@
<property name="can_focus">False</property>
<property name="layout_style">end</property>
<child>
<object class="GtkButton" id="ok">
<property name="label">gtk-ok</property>
<object class="GtkButton" id="reset">
<property name="label">gtk-revert-to-saved</property>
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="can_default">True</property>
<property name="has_default">True</property>
<property name="receives_default">True</property>
<property name="use_stock">True</property>
</object>
......@@ -33,10 +37,12 @@
</packing>
</child>
<child>
<object class="GtkButton" id="cancel">
<property name="label">gtk-cancel</property>
<object class="GtkButton" id="ok">
<property name="label">gtk-ok</property>
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="can_default">True</property>
<property name="has_default">True</property>
<property name="receives_default">True</property>
<property name="use_stock">True</property>
</object>
......@@ -47,8 +53,8 @@
</packing>
</child>
<child>
<object class="GtkButton" id="help">
<property name="label">gtk-help</property>
<object class="GtkButton" id="cancel">
<property name="label">gtk-cancel</property>
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="receives_default">True</property>
......@@ -58,12 +64,11 @@
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">2</property>
<property name="secondary">True</property>
</packing>
</child>
<child>
<object class="GtkButton" id="reset">
<property name="label">gtk-revert-to-saved</property>
<object class="GtkButton" id="help">
<property name="label">gtk-help</property>
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="receives_default">True</property>
......@@ -73,6 +78,7 @@
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">3</property>
<property name="secondary">True</property>
</packing>
</child>
</object>
......@@ -87,7 +93,6 @@
<object class="GtkNotebook" id="tabcontrol">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="scrollable">True</property>
<property name="enable_popup">True</property>
<child>
<object class="GtkGrid">
......@@ -96,6 +101,30 @@
<child>
<placeholder/>
</child>
<child>
<placeholder/>
</child>
<child>
<placeholder/>
</child>
<child>
<placeholder/>
</child>
<child>
<placeholder/>
</child>
<child>
<placeholder/>
</child>
<child>
<placeholder/>
</child>
<child>
<placeholder/>
</child>
<child>
<placeholder/>
</child>
</object>
</child>
<child type="tab">
......@@ -115,6 +144,30 @@
<child>
<placeholder/>
</child>
<child>
<placeholder/>
</child>
<child>
<placeholder/>
</child>
<child>
<placeholder/>
</child>
<child>
<placeholder/>
</child>
<child>
<placeholder/>
</child>
<child>
<placeholder/>
</child>
<child>
<placeholder/>
</child>
<child>
<placeholder/>
</child>
</object>
<packing>
<property name="position">1</property>
......@@ -138,6 +191,30 @@
<child>
<placeholder/>
</child>
<child>
<placeholder/>
</child>
<child>
<placeholder/>
</child>
<child>
<placeholder/>
</child>
<child>
<placeholder/>
</child>
<child>
<placeholder/>
</child>
<child>
<placeholder/>
</child>
<child>
<placeholder/>
</child>
<child>
<placeholder/>
</child>
</object>
<packing>
<property name="position">2</property>
......@@ -161,6 +238,30 @@
<child>
<placeholder/>
</child>
<child>
<placeholder/>
</child>
<child>
<placeholder/>
</child>
<child>
<placeholder/>
</child>
<child>
<placeholder/>
</child>
<child>
<placeholder/>
</child>
<child>
<placeholder/>
</child>
<child>
<placeholder/>
</child>
<child>
<placeholder/>
</child>
</object>
<packing>
<property name="position">3</property>
......@@ -184,6 +285,30 @@
<child>
<placeholder/>
</child>
<child>
<placeholder/>
</child>
<child>
<placeholder/>
</child>
<child>
<placeholder/>
</child>
<child>
<placeholder/>
</child>
<child>
<placeholder/>
</child>
<child>
<placeholder/>
</child>
<child>
<placeholder/>
</child>
<child>
<placeholder/>
</child>
</object>
<packing>
<property name="position">4</property>
......@@ -210,10 +335,10 @@
</object>
</child>
<action-widgets>
<action-widget response="101">reset</action-widget>
<action-widget response="-5">ok</action-widget>
<action-widget response="-6">cancel</action-widget>
<action-widget response="-11">help</action-widget>
<action-widget response="101">reset</action-widget>
</action-widgets>
</object>
</interface>
......@@ -117,7 +117,8 @@ class SW_DLLPUBLIC SwDocShell
override;
/// Make DocInfo known to the Doc.
SAL_DLLPRIVATE virtual VclPtr<SfxDocumentInfoDialog> CreateDocumentInfoDialog(const SfxItemSet &) override;
SAL_DLLPRIVATE virtual std::unique_ptr<SfxDocumentInfoDialog> CreateDocumentInfoDialog(weld::Window* pParent,
const SfxItemSet &rSet) override;
/// OLE-stuff
SAL_DLLPRIVATE virtual void Draw( OutputDevice*, const JobSetup&, sal_uInt16 nAspect) override;
......
......@@ -147,11 +147,9 @@ using namespace ::com::sun::star;
using namespace ::sfx2;
// create DocInfo (virtual)
VclPtr<SfxDocumentInfoDialog> SwDocShell::CreateDocumentInfoDialog(const SfxItemSet &rSet)
std::unique_ptr<SfxDocumentInfoDialog> SwDocShell::CreateDocumentInfoDialog(weld::Window* pParent, const SfxItemSet &rSet)
{
SfxViewShell* pViewShell = GetView() ? GetView() : SfxViewShell::Current();
vcl::Window* pWindow = pViewShell ? &pViewShell->GetViewFrame()->GetWindow() : nullptr;
VclPtr<SfxDocumentInfoDialog> pDlg = VclPtr<SfxDocumentInfoDialog>::Create(pWindow, rSet);
std::unique_ptr<SfxDocumentInfoDialog> xDlg = std::make_unique<SfxDocumentInfoDialog>(pParent, rSet);
//only with statistics, when this document is being shown, not
//from within the Doc-Manager
SwDocShell* pDocSh = static_cast<SwDocShell*>( SfxObjectShell::Current());
......@@ -162,11 +160,11 @@ VclPtr<SfxDocumentInfoDialog> SwDocShell::CreateDocumentInfoDialog(const SfxItem
if ( pVSh && dynamic_cast< const SwSrcView *>( pVSh ) == nullptr )
{
SwAbstractDialogFactory* pFact = SwAbstractDialogFactory::Create();
pDlg->AddFontTabPage();
pDlg->AddTabPage(RID_SW_TP_DOC_STAT, SwResId(STR_DOC_STAT), pFact->GetTabPageCreatorFunc(RID_SW_TP_DOC_STAT));
xDlg->AddFontTabPage();
xDlg->AddTabPage("writerstats", SwResId(STR_DOC_STAT), pFact->GetTabPageCreatorFunc(RID_SW_TP_DOC_STAT));
}
}
return pDlg;
return xDlg;
}
void SwDocShell::ToggleLayoutMode(SwView* pView)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment