Line data Source code
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"
21 : #include <com/sun/star/text/XTextDocument.hpp>
22 : #include <xmloff/XMLFontAutoStylePool.hxx>
23 : #include <editeng/fontitem.hxx>
24 : #include <unotext.hxx>
25 : #include <doc.hxx>
26 : #include <xmlexp.hxx>
27 : #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 :
33 0 : class SwXMLFontAutoStylePool_Impl: public XMLFontAutoStylePool
34 : {
35 : public:
36 : SwXMLFontAutoStylePool_Impl( SwXMLExport& rExport, bool blockFontEmbedding );
37 : };
38 :
39 0 : SwXMLFontAutoStylePool_Impl::SwXMLFontAutoStylePool_Impl(
40 : SwXMLExport& _rExport, bool blockFontEmbedding ) :
41 0 : XMLFontAutoStylePool( _rExport, blockFontEmbedding )
42 : {
43 : sal_uInt16 aWhichIds[3] = { RES_CHRATR_FONT, RES_CHRATR_CJK_FONT,
44 0 : RES_CHRATR_CTL_FONT };
45 :
46 0 : const SfxItemPool& rPool = _rExport.getDoc()->GetAttrPool();
47 : const SfxPoolItem* pItem;
48 0 : for( sal_uInt16 i=0; i<3; i++ )
49 : {
50 0 : sal_uInt16 nWhichId = aWhichIds[i];
51 :
52 : const SvxFontItem& rFont =
53 0 : (const SvxFontItem&)rPool.GetDefaultItem( nWhichId );
54 0 : Add( rFont.GetFamilyName(), rFont.GetStyleName(),
55 : rFont.GetFamily(), rFont.GetPitch(),
56 0 : rFont.GetCharSet() );
57 0 : sal_uInt32 nItems = rPool.GetItemCount2( nWhichId );
58 0 : for( sal_uInt32 j = 0; j < nItems; ++j )
59 : {
60 0 : if( 0 != (pItem = rPool.GetItem2( nWhichId, j ) ) )
61 : {
62 : const SvxFontItem *pFont =
63 0 : (const SvxFontItem *)pItem;
64 0 : Add( pFont->GetFamilyName(), pFont->GetStyleName(),
65 : pFont->GetFamily(), pFont->GetPitch(),
66 0 : pFont->GetCharSet() );
67 : }
68 : }
69 : }
70 0 : }
71 :
72 0 : XMLFontAutoStylePool* SwXMLExport::CreateFontAutoStylePool()
73 : {
74 0 : bool blockFontEmbedding = false;
75 : // We write font info to both content.xml and styles.xml, but they are both
76 : // written by different SwXMLExport instance, and would therefore write each
77 : // font file twice without complicated checking for duplicates, so handle
78 : // the embedding only in one of them.
79 0 : if(( getExportFlags() & EXPORT_CONTENT ) == 0 )
80 0 : blockFontEmbedding = true;
81 0 : if( !getDoc()->get( IDocumentSettingAccess::EMBED_FONTS ))
82 0 : blockFontEmbedding = true;
83 0 : return new SwXMLFontAutoStylePool_Impl( *this, !blockFontEmbedding );
84 : }
85 :
86 0 : void SwXMLImport::NotifyEmbeddedFontRead()
87 : {
88 0 : getDoc()->set( IDocumentSettingAccess::EMBED_FONTS, true );
89 0 : }
90 :
91 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|