1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
3 * This file is part of the LibreOffice project.
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/.
9 * This file incorporates work covered by the following license notice:
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 .
20 #include <documentfontsdialog.hxx>
22 #include <sfx2/objsh.hxx>
24 #include <com/sun/star/beans/XPropertySet.hpp>
25 #include <com/sun/star/frame/XModel.hpp>
26 #include <com/sun/star/lang/XMultiServiceFactory.hpp>
28 using namespace ::com::sun::star
;
30 std::unique_ptr
<SfxTabPage
> SfxDocumentFontsPage::Create(weld::Container
* pPage
, weld::DialogController
* pController
, const SfxItemSet
* set
)
32 return std::make_unique
<SfxDocumentFontsPage
>(pPage
, pController
, *set
);
35 SfxDocumentFontsPage::SfxDocumentFontsPage(weld::Container
* pPage
, weld::DialogController
* pController
, const SfxItemSet
& set
)
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"))
45 SfxDocumentFontsPage::~SfxDocumentFontsPage()
49 void SfxDocumentFontsPage::Reset( const SfxItemSet
* )
51 bool bEmbedFonts
= false;
52 bool bEmbedUsedFonts
= false;
54 bool bEmbedLatinScriptFonts
= false;
55 bool bEmbedAsianScriptFonts
= false;
56 bool bEmbedComplexScriptFonts
= false;
58 SfxObjectShell
* pDocSh
= SfxObjectShell::Current();
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
);
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
;
72 catch( uno::Exception
& )
76 embedFontsCheckbox
->set_active(bEmbedFonts
);
77 embedUsedFontsCheckbox
->set_active(bEmbedUsedFonts
);
79 embedLatinScriptFontsCheckbox
->set_active(bEmbedLatinScriptFonts
);
80 embedAsianScriptFontsCheckbox
->set_active(bEmbedAsianScriptFonts
);
81 embedComplexScriptFontsCheckbox
->set_active(bEmbedComplexScriptFonts
);
84 bool SfxDocumentFontsPage::FillItemSet( SfxItemSet
* )
86 bool bEmbedFonts
= embedFontsCheckbox
->get_active();
87 bool bEmbedUsedFonts
= embedUsedFontsCheckbox
->get_active();
89 bool bEmbedLatinScriptFonts
= embedLatinScriptFontsCheckbox
->get_active();
90 bool bEmbedAsianScriptFonts
= embedAsianScriptFontsCheckbox
->get_active();
91 bool bEmbedComplexScriptFonts
= embedComplexScriptFontsCheckbox
->get_active();
93 SfxObjectShell
* pDocSh
= SfxObjectShell::Current();
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::makeAny(bEmbedFonts
));
101 xProps
->setPropertyValue("EmbedOnlyUsedFonts", uno::makeAny(bEmbedUsedFonts
));
102 xProps
->setPropertyValue("EmbedLatinScriptFonts", uno::makeAny(bEmbedLatinScriptFonts
));
103 xProps
->setPropertyValue("EmbedAsianScriptFonts", uno::makeAny(bEmbedAsianScriptFonts
));
104 xProps
->setPropertyValue("EmbedComplexScriptFonts", uno::makeAny(bEmbedComplexScriptFonts
));
106 catch( uno::Exception
& )
113 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */