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 <unotext.hxx>
24 #include <doc.hxx>
25 #include "xmlexp.hxx"
26 #include "xmlimp.hxx"
28 
29 using namespace ::com::sun::star::uno;
30 using namespace ::com::sun::star::lang;
31 using namespace ::com::sun::star::text;
32 
34 {
35 public:
36  SwXMLFontAutoStylePool_Impl(SwXMLExport& rExport, bool bFontEmbedding);
37 };
38 
40  : XMLFontAutoStylePool(_rExport, bFontEmbedding)
41 {
42  sal_uInt16 const aWhichIds[3] = { RES_CHRATR_FONT, RES_CHRATR_CJK_FONT,
44 
45  const SfxItemPool& rPool = _rExport.getDoc()->GetAttrPool();
46  for(sal_uInt16 nWhichId : aWhichIds)
47  {
48  const SvxFontItem& rFont =
49  static_cast<const SvxFontItem&>(rPool.GetDefaultItem( nWhichId ));
50  Add( rFont.GetFamilyName(), rFont.GetStyleName(),
51  rFont.GetFamily(), rFont.GetPitch(),
52  rFont.GetCharSet() );
53  for (const SfxPoolItem* pItem : rPool.GetItemSurrogates(nWhichId))
54  {
55  auto pFont = static_cast<const SvxFontItem *>(pItem);
56  Add( pFont->GetFamilyName(), pFont->GetStyleName(),
57  pFont->GetFamily(), pFont->GetPitch(),
58  pFont->GetCharSet() );
59  }
60  }
61  auto const & pDocument = _rExport.getDoc();
62 
63  m_bEmbedUsedOnly = pDocument->getIDocumentSettingAccess().get(DocumentSettingId::EMBED_USED_FONTS);
64  m_bEmbedLatinScript = pDocument->getIDocumentSettingAccess().get(DocumentSettingId::EMBED_LATIN_SCRIPT_FONTS);
65  m_bEmbedAsianScript = pDocument->getIDocumentSettingAccess().get(DocumentSettingId::EMBED_ASIAN_SCRIPT_FONTS);
66  m_bEmbedComplexScript = pDocument->getIDocumentSettingAccess().get(DocumentSettingId::EMBED_COMPLEX_SCRIPT_FONTS);
67 
68 }
69 
71 {
72  bool blockFontEmbedding = false;
73  // We write font info to both content.xml and styles.xml, but they are both
74  // written by different SwXMLExport instance, and would therefore write each
75  // font file twice without complicated checking for duplicates, so handle
76  // the embedding only in one of them.
77  if( !( getExportFlags() & SvXMLExportFlags::CONTENT) )
78  blockFontEmbedding = true;
79  if( !getDoc()->getIDocumentSettingAccess().get( DocumentSettingId::EMBED_FONTS ))
80  blockFontEmbedding = true;
81  return new SwXMLFontAutoStylePool_Impl( *this, !blockFontEmbedding );
82 }
83 
85 {
87 }
88 
89 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
OUString Add(const OUString &rFamilyName, const OUString &rStyleName, FontFamily nFamily, FontPitch nPitch, rtl_TextEncoding eEnc)
const SwDoc * getDoc() const
Definition: xmlimp.cxx:1762
#define RES_CHRATR_FONT
Definition: hintids.hxx:75
#define RES_CHRATR_CJK_FONT
Definition: hintids.hxx:90
FontPitch GetPitch() const
FontFamily GetFamily() const
virtual void set(DocumentSettingId id, bool value)=0
Set the specified document setting.
rtl_TextEncoding GetCharSet() const
const OUString & GetStyleName() const
#define RES_CHRATR_CTL_FONT
Definition: hintids.hxx:95
const SwDoc * getDoc() const
Definition: xmlexp.cxx:523
SvXMLExport & rExport
virtual void NotifyEmbeddedFontRead() override
Definition: xmlfonte.cxx:84
const SfxPoolItem & GetDefaultItem(sal_uInt16 nWhich) const
const OUString & GetFamilyName() const
IDocumentSettingAccess const & getIDocumentSettingAccess() const
Definition: doc.cxx:208
Item2Range GetItemSurrogates(sal_uInt16 nWhich) const
SvXMLExportFlags getExportFlags() const
virtual XMLFontAutoStylePool * CreateFontAutoStylePool() override
Definition: xmlfonte.cxx:70
const SwAttrPool & GetAttrPool() const
Definition: doc.hxx:1307
SwXMLFontAutoStylePool_Impl(SwXMLExport &rExport, bool bFontEmbedding)
Definition: xmlfonte.cxx:39