LibreOffice Module sfx2 (master) 1
documentfontsdialog.cxx
Go to the documentation of this file.
1/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2/*
3 * This file is part of the LibreOffice project.
4 *
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/.
8 *
9 * This file incorporates work covered by the following license notice:
10 *
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 .
18 */
19
21
22#include <sfx2/objsh.hxx>
23
24#include <com/sun/star/beans/XPropertySet.hpp>
25#include <com/sun/star/frame/XModel.hpp>
26#include <com/sun/star/lang/XMultiServiceFactory.hpp>
27
28using namespace ::com::sun::star;
29
30std::unique_ptr<SfxTabPage> SfxDocumentFontsPage::Create(weld::Container* pPage, weld::DialogController* pController, const SfxItemSet* set)
31{
32 return std::make_unique<SfxDocumentFontsPage>(pPage, pController, *set);
33}
34
36 : SfxTabPage(pPage, pController, "sfx/ui/documentfontspage.ui", "DocumentFontsPage", &set)
37 , embedFontsCheckbox(m_xBuilder->weld_check_button("embedFonts"))
38 , embedUsedFontsCheckbox(m_xBuilder->weld_check_button("embedUsedFonts"))
39 , embedLatinScriptFontsCheckbox(m_xBuilder->weld_check_button("embedLatinScriptFonts"))
40 , embedAsianScriptFontsCheckbox(m_xBuilder->weld_check_button("embedAsianScriptFonts"))
41 , embedComplexScriptFontsCheckbox(m_xBuilder->weld_check_button("embedComplexScriptFonts"))
42{
43}
44
46{
47}
48
50{
51 bool bEmbedFonts = false;
52 bool bEmbedUsedFonts = false;
53
54 bool bEmbedLatinScriptFonts = false;
55 bool bEmbedAsianScriptFonts = false;
56 bool bEmbedComplexScriptFonts = false;
57
59 if (pDocSh)
60 {
61 try
62 {
63 uno::Reference< lang::XMultiServiceFactory > xFac( pDocSh->GetModel(), uno::UNO_QUERY_THROW );
64 uno::Reference< beans::XPropertySet > xProps( xFac->createInstance("com.sun.star.document.Settings"), uno::UNO_QUERY_THROW );
65
66 xProps->getPropertyValue("EmbedFonts") >>= bEmbedFonts;
67 xProps->getPropertyValue("EmbedOnlyUsedFonts") >>= bEmbedUsedFonts;
68 xProps->getPropertyValue("EmbedLatinScriptFonts") >>= bEmbedLatinScriptFonts;
69 xProps->getPropertyValue("EmbedAsianScriptFonts") >>= bEmbedAsianScriptFonts;
70 xProps->getPropertyValue("EmbedComplexScriptFonts") >>= bEmbedComplexScriptFonts;
71 }
72 catch( uno::Exception& )
73 {
74 }
75 }
76 embedFontsCheckbox->set_active(bEmbedFonts);
77 embedUsedFontsCheckbox->set_active(bEmbedUsedFonts);
78
79 embedLatinScriptFontsCheckbox->set_active(bEmbedLatinScriptFonts);
80 embedAsianScriptFontsCheckbox->set_active(bEmbedAsianScriptFonts);
81 embedComplexScriptFontsCheckbox->set_active(bEmbedComplexScriptFonts);
82}
83
85{
86 bool bEmbedFonts = embedFontsCheckbox->get_active();
87 bool bEmbedUsedFonts = embedUsedFontsCheckbox->get_active();
88
89 bool bEmbedLatinScriptFonts = embedLatinScriptFontsCheckbox->get_active();
90 bool bEmbedAsianScriptFonts = embedAsianScriptFontsCheckbox->get_active();
91 bool bEmbedComplexScriptFonts = embedComplexScriptFontsCheckbox->get_active();
92
94 if ( pDocSh )
95 {
96 try
97 {
98 uno::Reference< lang::XMultiServiceFactory > xFac( pDocSh->GetModel(), uno::UNO_QUERY_THROW );
99 uno::Reference< beans::XPropertySet > xProps( xFac->createInstance("com.sun.star.document.Settings"), uno::UNO_QUERY_THROW );
100 xProps->setPropertyValue("EmbedFonts", uno::Any(bEmbedFonts));
101 xProps->setPropertyValue("EmbedOnlyUsedFonts", uno::Any(bEmbedUsedFonts));
102 xProps->setPropertyValue("EmbedLatinScriptFonts", uno::Any(bEmbedLatinScriptFonts));
103 xProps->setPropertyValue("EmbedAsianScriptFonts", uno::Any(bEmbedAsianScriptFonts));
104 xProps->setPropertyValue("EmbedComplexScriptFonts", uno::Any(bEmbedComplexScriptFonts));
105 }
106 catch( uno::Exception& )
107 {
108 }
109 }
110 return false;
111}
112
113/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
SfxDocumentFontsPage(weld::Container *pPage, weld::DialogController *pController, const SfxItemSet &set)
virtual ~SfxDocumentFontsPage() override
virtual bool FillItemSet(SfxItemSet *set) override
std::unique_ptr< weld::CheckButton > embedUsedFontsCheckbox
std::unique_ptr< weld::CheckButton > embedFontsCheckbox
std::unique_ptr< weld::CheckButton > embedComplexScriptFontsCheckbox
std::unique_ptr< weld::CheckButton > embedLatinScriptFontsCheckbox
std::unique_ptr< weld::CheckButton > embedAsianScriptFontsCheckbox
virtual void Reset(const SfxItemSet *set) override
static std::unique_ptr< SfxTabPage > Create(weld::Container *pPage, weld::DialogController *pController, const SfxItemSet *set)
css::uno::Reference< css::frame::XModel3 > GetModel() const
Definition: objxtor.cxx:838
static SAL_WARN_UNUSED_RESULT SfxObjectShell * Current()
Definition: objxtor.cxx:481
void set(css::uno::UnoInterfaceReference const &value)