LibreOffice Module sw (master)  1
swfntcch.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 <sal/config.h>
21 
22 #include <shellio.hxx>
23 #include <viewsh.hxx>
24 #include <swfntcch.hxx>
25 #include <fmtcol.hxx>
26 #include <fntcache.hxx>
27 #include <swfont.hxx>
28 
29 // from atrstck.cxx
30 extern const sal_uInt8 StackPos[];
31 
32 // FontCache is created in txtinit.cxx TextInit_ and deleted in TextFinit
34 
35 SwFontObj::SwFontObj( const void *pOwn, SwViewShell *pSh ) :
36  SwCacheObj( pOwn ),
37  m_aSwFont( &static_cast<SwTextFormatColl const *>(pOwn)->GetAttrSet(), pSh ? &pSh->getIDocumentSettingAccess() : nullptr )
38 {
40  const SwAttrSet& rAttrSet = static_cast<SwTextFormatColl const *>(pOwn)->GetAttrSet();
41  for (sal_uInt16 i = RES_CHRATR_BEGIN; i < RES_CHRATR_END; i++)
42  m_pDefaultArray[ StackPos[ i ] ] = &rAttrSet.Get( i );
43 }
44 
46 {
47 }
48 
49 SwFontAccess::SwFontAccess( const void *pOwn, SwViewShell *pSh ) :
50  SwCacheAccess( *pSwFontCache, pOwn,
51  static_cast<const SwTextFormatColl*>(pOwn)->IsInSwFntCache() ),
52  m_pShell( pSh )
53 {
54 }
55 
57 {
58  return static_cast<SwFontObj *>( SwCacheAccess::Get( ) );
59 }
60 
62 {
63  const_cast<SwTextFormatColl*>(static_cast<const SwTextFormatColl*>(m_pOwner))->SetInSwFntCache( true );
64  return new SwFontObj( m_pOwner, m_pShell );
65 }
66 
67 SAL_DLLPUBLIC_EXPORT void FlushFontCache()
68 {
69  if (pSwFontCache)
70  pSwFontCache->Flush();
71  if (pFntCache)
72  pFntCache->Flush();
73 }
74 
75 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
Represents the style of a paragraph.
Definition: fmtcol.hxx:55
SwFont m_aSwFont
Definition: swfntcch.hxx:50
const SfxPoolItem * m_pDefaultArray[NUM_DEFAULT_VALUES]
Definition: swfntcch.hxx:51
const void * m_pOwner
Definition: swcache.hxx:202
SwCacheObj * Get(bool isDuplicateOwnerAllowed)
Definition: swcache.hxx:252
#define RES_CHRATR_END
Definition: hintids.hxx:114
void Flush()
Definition: fntcache.cxx:166
SwFontScript GetActual() const
Definition: swfont.hxx:180
SwFontCache * pSwFontCache
Definition: swfntcch.cxx:33
SwViewShell *const m_pShell
Definition: swfntcch.hxx:65
int i
SwFontObj(const void *pOwner, SwViewShell *pSh)
Definition: swfntcch.cxx:35
#define RES_CHRATR_BEGIN
Definition: hintids.hxx:68
Shell * m_pShell
SwFntCache * pFntCache
Definition: fntcache.cxx:67
SAL_DLLPUBLIC_EXPORT void FlushFontCache()
Definition: swfntcch.cxx:67
void Flush()
Definition: swcache.cxx:150
SwFontAccess(const void *pOwner, SwViewShell *pSh)
Definition: swfntcch.cxx:49
SwFontObj * Get()
Definition: swfntcch.cxx:56
const SfxPoolItem & Get(sal_uInt16 nWhich, bool bSrchInParent=true) const
unsigned char sal_uInt8
The Cache object base class Users of the Cache must derive a class from the SwCacheObj and store thei...
Definition: swcache.hxx:133
virtual ~SwFontObj() override
Definition: swfntcch.cxx:45
Access class for the Cache.
Definition: swcache.hxx:194
virtual SwCacheObj * NewObj() override
Can be use in NewObj.
Definition: swfntcch.cxx:61
const sal_uInt8 StackPos[]
Attribute to Stack Mapping.
Definition: atrstck.cxx:69
void SetInSwFntCache(bool bNew)
Definition: calbck.hxx:219
void AllocFontCacheId(SwViewShell const *pSh, SwFontScript nWhich)
Definition: swfont.cxx:943