LibreOffice Module sw (master) 1
xmlfonte.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
20#include <hintids.hxx>
22#include <editeng/fontitem.hxx>
23#include <doc.hxx>
24#include "xmlexp.hxx"
25#include "xmlimp.hxx"
27
28using namespace ::com::sun::star::uno;
29using namespace ::com::sun::star::lang;
30using namespace ::com::sun::star::text;
31
32namespace {
33
34class SwXMLFontAutoStylePool_Impl: public XMLFontAutoStylePool
35{
36public:
37 SwXMLFontAutoStylePool_Impl(SwXMLExport& rExport, bool bFontEmbedding);
38};
39
40}
41
42SwXMLFontAutoStylePool_Impl::SwXMLFontAutoStylePool_Impl(SwXMLExport& _rExport, bool bFontEmbedding)
43 : XMLFontAutoStylePool(_rExport, bFontEmbedding)
44{
45 sal_uInt16 const aWhichIds[3] = { RES_CHRATR_FONT, RES_CHRATR_CJK_FONT,
47
48 const SfxItemPool& rPool = _rExport.getDoc()->GetAttrPool();
49 std::vector<const SvxFontItem *> aFonts;
50 for(sal_uInt16 nWhichId : aWhichIds)
51 {
52 const SvxFontItem& rFont =
53 static_cast<const SvxFontItem&>(rPool.GetDefaultItem( nWhichId ));
54 aFonts.push_back(&rFont);
55 for (const SfxPoolItem* pItem : rPool.GetItemSurrogates(nWhichId))
56 {
57 auto pFont = static_cast<const SvxFontItem *>(pItem);
58 aFonts.push_back(pFont);
59 }
60 }
61
62 std::sort(aFonts.begin(), aFonts.end(),
63 [](const SvxFontItem* pA, const SvxFontItem* pB) -> bool { return *pA < *pB; });
64 for (const auto& pFont : aFonts)
65 {
66 Add(pFont->GetFamilyName(), pFont->GetStyleName(), pFont->GetFamily(), pFont->GetPitch(),
67 pFont->GetCharSet());
68 }
69
70 auto const & pDocument = _rExport.getDoc();
71
73 m_bEmbedLatinScript = pDocument->getIDocumentSettingAccess().get(DocumentSettingId::EMBED_LATIN_SCRIPT_FONTS);
74 m_bEmbedAsianScript = pDocument->getIDocumentSettingAccess().get(DocumentSettingId::EMBED_ASIAN_SCRIPT_FONTS);
75 m_bEmbedComplexScript = pDocument->getIDocumentSettingAccess().get(DocumentSettingId::EMBED_COMPLEX_SCRIPT_FONTS);
76
77}
78
80{
81 bool blockFontEmbedding = false;
82 // We write font info to both content.xml and styles.xml, but they are both
83 // written by different SwXMLExport instance, and would therefore write each
84 // font file twice without complicated checking for duplicates, so handle
85 // the embedding only in one of them.
86 if( !( getExportFlags() & SvXMLExportFlags::CONTENT) )
87 blockFontEmbedding = true;
88 if( !getDoc()->getIDocumentSettingAccess().get( DocumentSettingId::EMBED_FONTS ))
89 blockFontEmbedding = true;
90 return new SwXMLFontAutoStylePool_Impl( *this, !blockFontEmbedding );
91}
92
94{
96}
97
98/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
virtual bool get(DocumentSettingId id) const =0
Return the specified document setting.
virtual void set(DocumentSettingId id, bool value)=0
Set the specified document setting.
Item2Range GetItemSurrogates(sal_uInt16 nWhich) const
const SfxPoolItem & GetDefaultItem(sal_uInt16 nWhich) const
SvXMLExportFlags getExportFlags() const
IDocumentSettingAccess const & getIDocumentSettingAccess() const
Definition: doc.cxx:190
const SwAttrPool & GetAttrPool() const
Definition: doc.hxx:1337
const SwDoc * getDoc() const
Definition: xmlexp.cxx:533
virtual XMLFontAutoStylePool * CreateFontAutoStylePool() override
Definition: xmlfonte.cxx:79
const SwDoc * getDoc() const
Definition: xmlimp.cxx:1683
virtual void NotifyContainsEmbeddedFont() override
Definition: xmlfonte.cxx:93
constexpr TypedWhichId< SvxFontItem > RES_CHRATR_CJK_FONT(22)
constexpr TypedWhichId< SvxFontItem > RES_CHRATR_CTL_FONT(27)
constexpr TypedWhichId< SvxFontItem > RES_CHRATR_FONT(7)
css::uno::Reference< css::linguistic2::XProofreadingIterator > get(css::uno::Reference< css::uno::XComponentContext > const &context)
static void Add(SwRegionRects &rRegion, const SwRect &rRect)
Definition: trvlfrm.cxx:1989