From c4a8e6b62e80d79d98743af022b3d5e5d1f22f51 Mon Sep 17 00:00:00 2001 From: Noel Power Date: Wed, 20 Feb 2013 19:29:10 +0000 Subject: clone documentfontsdialog from sw, add method to SfxDocumentInfoDialog add tab Change-Id: I9cfb4f65e27a73921ac7944376677c5ddecdf9a9 --- sc/source/ui/docshell/docsh.cxx | 1 + sfx2/Library_sfx.mk | 1 + sfx2/UI_sfx.mk | 1 + sfx2/inc/sfx2/dinfdlg.hxx | 1 + sfx2/source/dialog/dialog.hrc | 1 + sfx2/source/dialog/dialog.src | 5 ++ sfx2/source/dialog/dinfdlg.cxx | 8 ++++ sfx2/source/dialog/documentfontsdialog.cxx | 75 ++++++++++++++++++++++++++++++ sfx2/source/inc/documentfontsdialog.hxx | 44 ++++++++++++++++++ sfx2/uiconfig/ui/documentfontspage.ui | 29 ++++++++++++ 10 files changed, 166 insertions(+) create mode 100644 sfx2/source/dialog/documentfontsdialog.cxx create mode 100644 sfx2/source/inc/documentfontsdialog.hxx create mode 100644 sfx2/uiconfig/ui/documentfontspage.ui diff --git a/sc/source/ui/docshell/docsh.cxx b/sc/source/ui/docshell/docsh.cxx index adeefaf63c0e..08cfe0019f14 100644 --- a/sc/source/ui/docshell/docsh.cxx +++ b/sc/source/ui/docshell/docsh.cxx @@ -2813,6 +2813,7 @@ SfxDocumentInfoDialog* ScDocShell::CreateDocumentInfoDialog( OSL_ENSURE(pFact, "ScAbstractFactory create fail!"); ::CreateTabPage ScDocStatPageCreate = pFact->GetTabPageCreatorFunc( RID_SCPAGE_STAT ); OSL_ENSURE(ScDocStatPageCreate, "Tabpage create fail!"); + pDlg->AddFontTabPage(); pDlg->AddTabPage( 42, ScGlobal::GetRscString( STR_DOC_STAT ), ScDocStatPageCreate, diff --git a/sfx2/Library_sfx.mk b/sfx2/Library_sfx.mk index 032d7c4e2f7f..f8024b1e7cf1 100644 --- a/sfx2/Library_sfx.mk +++ b/sfx2/Library_sfx.mk @@ -157,6 +157,7 @@ $(eval $(call gb_Library_add_exception_objects,sfx,\ sfx2/source/dialog/dinfdlg \ sfx2/source/dialog/dinfedt \ sfx2/source/dialog/dockwin \ + sfx2/source/dialog/documentfontsdialog \ sfx2/source/dialog/filedlghelper \ sfx2/source/dialog/filtergrouping \ sfx2/source/dialog/itemconnect \ diff --git a/sfx2/UI_sfx.mk b/sfx2/UI_sfx.mk index 6c02310854d9..4b6466d1fc29 100644 --- a/sfx2/UI_sfx.mk +++ b/sfx2/UI_sfx.mk @@ -21,6 +21,7 @@ $(eval $(call gb_UI_add_uifiles,sfx,\ sfx2/uiconfig/ui/printeroptionsdialog \ sfx2/uiconfig/ui/securityinfopage \ sfx2/uiconfig/ui/singletabdialog \ + sfx2/uiconfig/ui/documentfontspage \ )) # vim: set noet sw=4 ts=4: diff --git a/sfx2/inc/sfx2/dinfdlg.hxx b/sfx2/inc/sfx2/dinfdlg.hxx index d365e5e91f0f..b90b548e27ef 100644 --- a/sfx2/inc/sfx2/dinfdlg.hxx +++ b/sfx2/inc/sfx2/dinfdlg.hxx @@ -310,6 +310,7 @@ protected: public: SfxDocumentInfoDialog( Window* pParent, const SfxItemSet& ); + void AddFontTabPage(); }; // class CustomPropertiesRemoveButton ------------------------------------ diff --git a/sfx2/source/dialog/dialog.hrc b/sfx2/source/dialog/dialog.hrc index 5cb1b355bfbd..243110f64a10 100644 --- a/sfx2/source/dialog/dialog.hrc +++ b/sfx2/source/dialog/dialog.hrc @@ -68,6 +68,7 @@ #define SFX_PB_EDIT ( RC_DIALOG_BEGIN + 124 ) #define STR_STYLE_ELEMTLIST ( RC_DIALOG_BEGIN + 125 ) +#define STR_FONT_TABPAGE ( RC_DIALOG_BEGIN + 126 ) #endif // #ifndef _SFX_DIALOG_HRC diff --git a/sfx2/source/dialog/dialog.src b/sfx2/source/dialog/dialog.src index 27f50e0bfd08..6951af91128d 100644 --- a/sfx2/source/dialog/dialog.src +++ b/sfx2/source/dialog/dialog.src @@ -128,5 +128,10 @@ Image IMG_INFO }; }; +String STR_FONT_TABPAGE +{ + Text [ en-US ] = "Font" ; +}; + // ******************************************************************* EOF diff --git a/sfx2/source/dialog/dinfdlg.cxx b/sfx2/source/dialog/dinfdlg.cxx index 894072f6e87a..fee23481e897 100644 --- a/sfx2/source/dialog/dinfdlg.cxx +++ b/sfx2/source/dialog/dinfdlg.cxx @@ -61,6 +61,7 @@ #include #include +#include "documentfontsdialog.hxx" #include #include "dinfdlg.hrc" #include "../appl/app.hrc" @@ -75,6 +76,8 @@ 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 { ::rtl::OUString m_sName; @@ -1489,6 +1492,11 @@ void SfxDocumentInfoDialog::PageCreated( sal_uInt16 nId, SfxTabPage &rPage ) ( (SfxDocumentPage&)rPage ).EnableUseUserData(); } +void SfxDocumentInfoDialog::AddFontTabPage() +{ + AddTabPage( FONT_PAGE_ID, SfxResId( STR_FONT_TABPAGE ).toString(), SfxDocumentFontsPage::Create, 0); +} + // class CustomPropertiesYesNoButton ------------------------------------- CustomPropertiesYesNoButton::CustomPropertiesYesNoButton( Window* pParent, const ResId& rResId ) : diff --git a/sfx2/source/dialog/documentfontsdialog.cxx b/sfx2/source/dialog/documentfontsdialog.cxx new file mode 100644 index 000000000000..46094fbd4fd4 --- /dev/null +++ b/sfx2/source/dialog/documentfontsdialog.cxx @@ -0,0 +1,75 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ + +#include "documentfontsdialog.hxx" + +#include + +using namespace ::com::sun::star; + +SfxTabPage* SfxDocumentFontsPage::Create( Window* parent, const SfxItemSet& set ) +{ + return new SfxDocumentFontsPage( parent, set ); +} + +SfxDocumentFontsPage::SfxDocumentFontsPage( Window* parent, const SfxItemSet& set ) + : SfxTabPage( parent, "DocumentFontsPage", "sfx/ui/documentfontspage.ui", set ) +{ + get( embedFontsCheckbox, "embedFonts" ); +} + +void SfxDocumentFontsPage::Reset( const SfxItemSet& ) +{ + bool bVal = false; + SfxObjectShell* pDocSh = SfxObjectShell::Current(); + if ( pDocSh ) + { + try + { + uno::Reference< lang::XMultiServiceFactory > xFac( pDocSh->GetModel(), uno::UNO_QUERY_THROW ); + uno::Reference< beans::XPropertySet > xProps( xFac->createInstance("com.sun.star.document.Settings"), uno::UNO_QUERY_THROW ); + xProps->getPropertyValue("EmbedFonts") >>= bVal; + } + catch( uno::Exception& ) + { + } + } + embedFontsCheckbox->Check( bVal ); +} + +sal_Bool SfxDocumentFontsPage::FillItemSet( SfxItemSet& ) +{ + bool bVal = embedFontsCheckbox->IsChecked(); + SfxObjectShell* pDocSh = SfxObjectShell::Current(); + if ( pDocSh ) + { + try + { + uno::Reference< lang::XMultiServiceFactory > xFac( pDocSh->GetModel(), uno::UNO_QUERY_THROW ); + uno::Reference< beans::XPropertySet > xProps( xFac->createInstance("com.sun.star.document.Settings"), uno::UNO_QUERY_THROW ); + xProps->setPropertyValue("EmbedFonts", uno::makeAny( bVal ) ); + } + catch( uno::Exception& ) + { + } + } + return false; +} + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sfx2/source/inc/documentfontsdialog.hxx b/sfx2/source/inc/documentfontsdialog.hxx new file mode 100644 index 000000000000..1f0c56038e0d --- /dev/null +++ b/sfx2/source/inc/documentfontsdialog.hxx @@ -0,0 +1,44 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ +#ifndef SW_DOCUMENTFONTSDIALOG_HXX +#define SW_DOCUMENTFONTSDIALOG_HXX + +#include + +#include +#include + +/** + Tab page for document font settings in the document properties dialog. +*/ +class SfxDocumentFontsPage: public SfxTabPage +{ +public: + SfxDocumentFontsPage( Window* parent, const SfxItemSet& set ); + static SfxTabPage* Create( Window* parent, const SfxItemSet& set ); +protected: + virtual sal_Bool FillItemSet( SfxItemSet& set ); + virtual void Reset( const SfxItemSet& set ); +private: + CheckBox* embedFontsCheckbox; +}; + +#endif + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sfx2/uiconfig/ui/documentfontspage.ui b/sfx2/uiconfig/ui/documentfontspage.ui new file mode 100644 index 000000000000..0003f477811e --- /dev/null +++ b/sfx2/uiconfig/ui/documentfontspage.ui @@ -0,0 +1,29 @@ + + + + + True + False + 12 + 18 + + + _Embed fonts in the document + False + True + True + False + False + True + 0 + True + + + 0 + 0 + 1 + 1 + + + + -- cgit