Coverage Report

Created: 2026-04-09 11:41

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/src/libreoffice/sfx2/source/dialog/documentfontsdialog.cxx
Line
Count
Source
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
20
#include <documentfontsdialog.hxx>
21
22
#include <sfx2/objsh.hxx>
23
#include <vcl/weld/Builder.hxx>
24
25
#include <com/sun/star/beans/XPropertySet.hpp>
26
#include <com/sun/star/frame/XModel.hpp>
27
#include <com/sun/star/frame/XModel3.hpp>
28
#include <com/sun/star/lang/XMultiServiceFactory.hpp>
29
30
using namespace ::com::sun::star;
31
32
std::unique_ptr<SfxTabPage> SfxDocumentFontsPage::Create(weld::Container* pPage, weld::DialogController* pController, const SfxItemSet* set)
33
0
{
34
0
    return std::make_unique<SfxDocumentFontsPage>(pPage, pController, *set);
35
0
}
36
37
SfxDocumentFontsPage::SfxDocumentFontsPage(weld::Container* pPage, weld::DialogController* pController, const SfxItemSet& set)
38
0
    : SfxTabPage(pPage, pController, u"sfx/ui/documentfontspage.ui"_ustr, u"DocumentFontsPage"_ustr, &set)
39
0
    , embedFontsCheckbox(m_xBuilder->weld_check_button(u"embedFonts"_ustr))
40
0
    , embedUsedFontsCheckbox(m_xBuilder->weld_check_button(u"embedUsedFonts"_ustr))
41
0
    , embedLatinScriptFontsCheckbox(m_xBuilder->weld_check_button(u"embedLatinScriptFonts"_ustr))
42
0
    , embedAsianScriptFontsCheckbox(m_xBuilder->weld_check_button(u"embedAsianScriptFonts"_ustr))
43
0
    , embedComplexScriptFontsCheckbox(m_xBuilder->weld_check_button(u"embedComplexScriptFonts"_ustr))
44
0
{
45
0
}
46
47
SfxDocumentFontsPage::~SfxDocumentFontsPage()
48
0
{
49
0
}
50
51
void SfxDocumentFontsPage::Reset( const SfxItemSet* )
52
0
{
53
0
    bool bEmbedFonts = false;
54
0
    bool bEmbedUsedFonts = false;
55
56
0
    bool bEmbedLatinScriptFonts  = false;
57
0
    bool bEmbedAsianScriptFonts  = false;
58
0
    bool bEmbedComplexScriptFonts  = false;
59
60
0
    SfxObjectShell* pDocSh = SfxObjectShell::Current();
61
0
    if (pDocSh)
62
0
    {
63
0
        try
64
0
        {
65
0
            uno::Reference< lang::XMultiServiceFactory > xFac( pDocSh->GetModel(), uno::UNO_QUERY );
66
0
            if (xFac)
67
0
            {
68
0
                uno::Reference< beans::XPropertySet > xProps( xFac->createInstance(u"com.sun.star.document.Settings"_ustr), uno::UNO_QUERY);
69
0
                if (xProps)
70
0
                {
71
0
                    xProps->getPropertyValue(u"EmbedFonts"_ustr) >>= bEmbedFonts;
72
0
                    xProps->getPropertyValue(u"EmbedOnlyUsedFonts"_ustr) >>= bEmbedUsedFonts;
73
0
                    xProps->getPropertyValue(u"EmbedLatinScriptFonts"_ustr) >>= bEmbedLatinScriptFonts;
74
0
                    xProps->getPropertyValue(u"EmbedAsianScriptFonts"_ustr) >>= bEmbedAsianScriptFonts;
75
0
                    xProps->getPropertyValue(u"EmbedComplexScriptFonts"_ustr) >>= bEmbedComplexScriptFonts;
76
0
                }
77
0
            }
78
0
        }
79
0
        catch( uno::Exception& )
80
0
        {
81
0
        }
82
0
    }
83
0
    embedFontsCheckbox->set_active(bEmbedFonts);
84
0
    embedUsedFontsCheckbox->set_active(bEmbedUsedFonts);
85
86
0
    embedLatinScriptFontsCheckbox->set_active(bEmbedLatinScriptFonts);
87
0
    embedAsianScriptFontsCheckbox->set_active(bEmbedAsianScriptFonts);
88
0
    embedComplexScriptFontsCheckbox->set_active(bEmbedComplexScriptFonts);
89
0
}
90
91
bool SfxDocumentFontsPage::FillItemSet( SfxItemSet* )
92
0
{
93
0
    bool bEmbedFonts = embedFontsCheckbox->get_active();
94
0
    bool bEmbedUsedFonts = embedUsedFontsCheckbox->get_active();
95
96
0
    bool bEmbedLatinScriptFonts  = embedLatinScriptFontsCheckbox->get_active();
97
0
    bool bEmbedAsianScriptFonts  = embedAsianScriptFontsCheckbox->get_active();
98
0
    bool bEmbedComplexScriptFonts  = embedComplexScriptFontsCheckbox->get_active();
99
100
0
    SfxObjectShell* pDocSh = SfxObjectShell::Current();
101
0
    if ( pDocSh )
102
0
    {
103
0
        try
104
0
        {
105
0
            uno::Reference< lang::XMultiServiceFactory > xFac( pDocSh->GetModel(), uno::UNO_QUERY );
106
0
            if (xFac)
107
0
            {
108
0
                uno::Reference< beans::XPropertySet > xProps( xFac->createInstance(u"com.sun.star.document.Settings"_ustr), uno::UNO_QUERY );
109
0
                if (xProps)
110
0
                {
111
0
                    xProps->setPropertyValue(u"EmbedFonts"_ustr, uno::Any(bEmbedFonts));
112
0
                    xProps->setPropertyValue(u"EmbedOnlyUsedFonts"_ustr, uno::Any(bEmbedUsedFonts));
113
0
                    xProps->setPropertyValue(u"EmbedLatinScriptFonts"_ustr, uno::Any(bEmbedLatinScriptFonts));
114
0
                    xProps->setPropertyValue(u"EmbedAsianScriptFonts"_ustr, uno::Any(bEmbedAsianScriptFonts));
115
0
                    xProps->setPropertyValue(u"EmbedComplexScriptFonts"_ustr, uno::Any(bEmbedComplexScriptFonts));
116
0
                }
117
0
            }
118
0
        }
119
0
        catch( uno::Exception& )
120
0
        {
121
0
        }
122
0
    }
123
0
    return false;
124
0
}
125
126
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */