LibreOffice Module xmloff (master)  1
XMLFontAutoStylePool.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 <o3tl/sorted_vector.hxx>
21 #include <tools/fontenum.hxx>
22 #include <xmloff/xmlnmspe.hxx>
23 #include <xmloff/xmltoken.hxx>
24 #include <xmloff/xmluconv.hxx>
25 #include "fonthdl.hxx"
26 #include <xmloff/xmlexp.hxx>
29 #include <osl/file.hxx>
30 #include <sal/log.hxx>
31 #include <tools/diagnose_ex.h>
32 
33 #include <com/sun/star/beans/XPropertySet.hpp>
34 #include <com/sun/star/embed/ElementModes.hpp>
35 #include <com/sun/star/embed/XTransactedObject.hpp>
36 #include <com/sun/star/embed/XStorage.hpp>
37 #include <com/sun/star/frame/XModel.hpp>
38 #include <com/sun/star/ucb/SimpleFileAccess.hpp>
39 #include <com/sun/star/style/XStyleFamiliesSupplier.hpp>
40 #include <com/sun/star/style/XStyle.hpp>
41 #include <com/sun/star/container/XNameAccess.hpp>
42 
43 #include <XMLBase64Export.hxx>
44 #include <AutoStyleEntry.hxx>
45 #include <comphelper/hash.hxx>
46 
47 using namespace ::com::sun::star;
48 using namespace ::com::sun::star::uno;
49 using namespace ::xmloff::token;
50 
51 namespace {
52 
53 class XMLFontAutoStylePoolEntry_Impl
54 {
55  OUString sName;
56  OUString sFamilyName;
57  OUString sStyleName;
58  FontFamily nFamily;
59  FontPitch nPitch;
60  rtl_TextEncoding eEnc;
61 
62 public:
63 
64  inline XMLFontAutoStylePoolEntry_Impl(
65  const OUString& rName,
66  const OUString& rFamilyName,
67  const OUString& rStyleName,
68  FontFamily nFamily,
69  FontPitch nPitch,
70  rtl_TextEncoding eEnc );
71 
72  inline XMLFontAutoStylePoolEntry_Impl(
73  const OUString& rFamilyName,
74  const OUString& rStyleName,
75  FontFamily nFamily,
76  FontPitch nPitch,
77  rtl_TextEncoding eEnc );
78 
79  const OUString& GetName() const { return sName; }
80  const OUString& GetFamilyName() const { return sFamilyName; }
81  const OUString& GetStyleName() const { return sStyleName; }
82  FontFamily GetFamily() const { return nFamily; }
83  FontPitch GetPitch() const { return nPitch; }
84  rtl_TextEncoding GetEncoding() const { return eEnc; }
85 };
86 
87 }
88 
89 inline XMLFontAutoStylePoolEntry_Impl::XMLFontAutoStylePoolEntry_Impl(
90  const OUString& rName,
91  const OUString& rFamilyName,
92  const OUString& rStyleName,
93  FontFamily nFam,
94  FontPitch nP,
95  rtl_TextEncoding eE ) :
96  sName( rName ),
97  sFamilyName( rFamilyName ),
98  sStyleName( rStyleName ),
99  nFamily( nFam ),
100  nPitch( nP ),
101  eEnc( eE )
102 {
103 }
104 
105 inline XMLFontAutoStylePoolEntry_Impl::XMLFontAutoStylePoolEntry_Impl(
106  const OUString& rFamilyName,
107  const OUString& rStyleName,
108  FontFamily nFam,
109  FontPitch nP,
110  rtl_TextEncoding eE ) :
111  sFamilyName( rFamilyName ),
112  sStyleName( rStyleName ),
113  nFamily( nFam ),
114  nPitch( nP ),
115  eEnc( eE )
116 {
117 }
118 
119 namespace {
120 
121 struct XMLFontAutoStylePoolEntryCmp_Impl {
122  bool operator()(
123  std::unique_ptr<XMLFontAutoStylePoolEntry_Impl> const& r1,
124  std::unique_ptr<XMLFontAutoStylePoolEntry_Impl> const& r2 ) const
125  {
126  bool bEnc1(r1->GetEncoding() != RTL_TEXTENCODING_SYMBOL);
127  bool bEnc2(r2->GetEncoding() != RTL_TEXTENCODING_SYMBOL);
128  if( bEnc1 != bEnc2 )
129  return bEnc1 < bEnc2;
130  else if( r1->GetPitch() != r2->GetPitch() )
131  return r1->GetPitch() < r2->GetPitch();
132  else if( r1->GetFamily() != r2->GetFamily() )
133  return r1->GetFamily() < r2->GetFamily();
134  else
135  {
136  sal_Int32 nCmp = r1->GetFamilyName().compareTo( r2->GetFamilyName() );
137  if( 0 == nCmp )
138  return r1->GetStyleName().compareTo( r2->GetStyleName() ) < 0;
139  else
140  return nCmp < 0;
141  }
142  }
143 };
144 
145 }
146 
147 class XMLFontAutoStylePool_Impl : public o3tl::sorted_vector<std::unique_ptr<XMLFontAutoStylePoolEntry_Impl>, XMLFontAutoStylePoolEntryCmp_Impl>
148 {
149 };
150 
152  rExport( rExp ),
153  m_pFontAutoStylePool( new XMLFontAutoStylePool_Impl ),
154  m_bTryToEmbedFonts( bTryToEmbedFonts ),
155  m_bEmbedUsedOnly(false),
156  m_bEmbedLatinScript(true),
157  m_bEmbedAsianScript(true),
158  m_bEmbedComplexScript(true)
159 {
160 }
161 
163 {
164 }
165 
167  const OUString& rFamilyName,
168  const OUString& rStyleName,
169  FontFamily nFamily,
170  FontPitch nPitch,
171  rtl_TextEncoding eEnc )
172 {
173  OUString sPoolName;
174  XMLFontAutoStylePoolEntry_Impl aTmp( rFamilyName, rStyleName, nFamily,
175  nPitch, eEnc );
177  if( it != m_pFontAutoStylePool->end() )
178  {
179  sPoolName = (*it)->GetName();
180  }
181  else
182  {
183  OUString sName;
184  sal_Int32 nLen = rFamilyName.indexOf( ';' );
185  if( -1 == nLen )
186  {
187  sName = rFamilyName;
188  }
189  else if( nLen > 0 )
190  {
191  sName = rFamilyName.copy( 0, nLen );
192  sName = sName.trim();
193  }
194 
195  if( sName.isEmpty() )
196  sName = "F";
197 
198  if( m_aNames.find(sName) != m_aNames.end() )
199  {
200  sal_Int32 nCount = 1;
201  OUString sPrefix( sName );
202  sName = sPrefix + OUString::number( nCount );
203  while( m_aNames.find(sName) != m_aNames.end() )
204  {
205  sName = sPrefix + OUString::number( ++nCount );
206  }
207  }
208 
209  std::unique_ptr<XMLFontAutoStylePoolEntry_Impl> pEntry(
210  new XMLFontAutoStylePoolEntry_Impl( sName, rFamilyName, rStyleName,
211  nFamily, nPitch, eEnc ));
212  m_pFontAutoStylePool->insert( std::move(pEntry) );
213  m_aNames.insert(sName);
214  }
215 
216  return sPoolName;
217 }
218 
220  const OUString& rFamilyName,
221  const OUString& rStyleName,
222  FontFamily nFamily,
223  FontPitch nPitch,
224  rtl_TextEncoding eEnc ) const
225 {
226  OUString sName;
227  XMLFontAutoStylePoolEntry_Impl aTmp( rFamilyName, rStyleName, nFamily,
228  nPitch, eEnc );
230  if( it != m_pFontAutoStylePool->end() )
231  {
232  sName = (*it)->GetName();
233  }
234 
235  return sName;
236 }
237 
238 namespace
239 {
240 
241 OUString lcl_checkFontFile( const OUString &fileUrl )
242 {
243  osl::DirectoryItem aDirItem;
244  if( osl::DirectoryItem::get( fileUrl, aDirItem ) == osl::File::E_None )
245  {
246  osl::FileStatus aStatus( osl_FileStatus_Mask_Type );
247  if( aDirItem.getFileStatus( aStatus ) == osl::File::E_None )
248  {
249  if( !aStatus.isDirectory() )
250  return fileUrl;
251  }
252  }
253  return OUString();
254 }
255 
257 struct EmbeddedFontInfo
258 {
259  OUString aURL;
260  FontWeight eWeight = WEIGHT_NORMAL;
261  FontItalic eItalic = ITALIC_NONE;
262 };
263 
265 OUString FontWeightToString(FontWeight eWeight)
266 {
267  OUString aRet;
268 
269  switch (eWeight)
270  {
271  case WEIGHT_BOLD:
272  aRet = "bold";
273  break;
274  default:
275  aRet = "normal";
276  break;
277  }
278 
279  return aRet;
280 }
281 
283 OUString FontItalicToString(FontItalic eWeight)
284 {
285  OUString aRet;
286 
287  switch (eWeight)
288  {
289  case ITALIC_NORMAL:
290  aRet = "italic";
291  break;
292  default:
293  aRet = "normal";
294  break;
295  }
296 
297  return aRet;
298 }
299 
300 }
301 
302 std::unordered_set<OUString> XMLFontAutoStylePool::getUsedFontList()
303 {
304  std::unordered_set<OUString> aReturnSet;
305 
306  uno::Reference<style::XStyleFamiliesSupplier> xFamiliesSupp(GetExport().GetModel(), UNO_QUERY);
307  if (!xFamiliesSupp.is())
308  return aReturnSet;
309 
310  // Check styles first
311  uno::Reference<container::XNameAccess> xFamilies(xFamiliesSupp->getStyleFamilies());
312  if (xFamilies.is())
313  {
314  const uno::Sequence<OUString> aFamilyNames = xFamilies->getElementNames();
315  for (OUString const & sFamilyName : aFamilyNames)
316  {
317  uno::Reference<container::XNameAccess> xStyleContainer;
318  xFamilies->getByName(sFamilyName) >>= xStyleContainer;
319 
320  if (xStyleContainer.is())
321  {
322  const uno::Sequence<OUString> aStyleNames = xStyleContainer->getElementNames();
323  for (OUString const & rName : aStyleNames)
324  {
325  uno::Reference<style::XStyle> xStyle;
326  xStyleContainer->getByName(rName) >>= xStyle;
327  if (xStyle->isInUse())
328  {
329  uno::Reference<beans::XPropertySet> xPropertySet(xStyle, UNO_QUERY);
330  if (xPropertySet.is())
331  {
332  uno::Reference<beans::XPropertySetInfo> xInfo(xPropertySet->getPropertySetInfo());
333  if (m_bEmbedLatinScript && xInfo->hasPropertyByName("CharFontName"))
334  {
335  OUString sCharFontName;
336  Any aFontAny = xPropertySet->getPropertyValue("CharFontName");
337  aFontAny >>= sCharFontName;
338  if (!sCharFontName.isEmpty())
339  aReturnSet.insert(sCharFontName);
340  }
341  if (m_bEmbedAsianScript && xInfo->hasPropertyByName("CharFontNameAsian"))
342  {
343  OUString sCharFontNameAsian;
344  Any aFontAny = xPropertySet->getPropertyValue("CharFontNameAsian");
345  aFontAny >>= sCharFontNameAsian;
346  if (!sCharFontNameAsian.isEmpty())
347  aReturnSet.insert(sCharFontNameAsian);
348  }
349  if (m_bEmbedComplexScript && xInfo->hasPropertyByName("CharFontNameComplex"))
350  {
351  OUString sCharFontNameComplex;
352  Any aFontAny = xPropertySet->getPropertyValue("CharFontNameComplex");
353  aFontAny >>= sCharFontNameComplex;
354  if (!sCharFontNameComplex.isEmpty())
355  aReturnSet.insert(sCharFontNameComplex);
356  }
357  }
358  }
359  }
360  }
361  }
362  }
363 
364  // make sure auto-styles are collected
366 
367  // Check auto-styles for fonts
368  std::vector<xmloff::AutoStyleEntry> aAutoStyleEntries = GetExport().GetAutoStylePool()->GetAutoStyleEntries();
369  for (auto const & rAutoStyleEntry : aAutoStyleEntries)
370  {
371  for (auto const & rPair : rAutoStyleEntry.m_aXmlProperties)
372  {
373  if (rPair.first == "font-name" ||
374  rPair.first == "font-weight-asian" ||
375  rPair.first == "font-weight-complex")
376  {
377  if (rPair.second.has<OUString>())
378  {
379  OUString sFontName = rPair.second.get<OUString>();
380  if (!sFontName.isEmpty())
381  aReturnSet.insert(sFontName);
382  }
383  }
384  }
385  }
386 
387  return aReturnSet;
388 }
389 
391 {
394  true, true);
395  Any aAny;
396  OUString sTmp;
397  XMLFontFamilyNamePropHdl aFamilyNameHdl;
398  XMLFontFamilyPropHdl aFamilyHdl;
399  XMLFontPitchPropHdl aPitchHdl;
400  XMLFontEncodingPropHdl aEncHdl;
401  const SvXMLUnitConverter& rUnitConv = GetExport().GetMM100UnitConverter();
402 
403  std::map<OUString, OUString> fontFilesMap; // our url to document url
404 
405  std::unordered_set<OUString> aUsedFontNames;
406  if (m_bEmbedUsedOnly)
407  aUsedFontNames = getUsedFontList();
408 
409  for (const auto& pEntry : *m_pFontAutoStylePool)
410  {
411  GetExport().AddAttribute(XML_NAMESPACE_STYLE, XML_NAME, pEntry->GetName());
412 
413  aAny <<= pEntry->GetFamilyName();
414  if (aFamilyNameHdl.exportXML(sTmp, aAny, rUnitConv))
416  XML_FONT_FAMILY, sTmp);
417 
418  const OUString& rStyleName = pEntry->GetStyleName();
419  if (!rStyleName.isEmpty())
422  rStyleName);
423 
424  aAny <<= static_cast<sal_Int16>(pEntry->GetFamily());
425  if (aFamilyHdl.exportXML(sTmp, aAny, rUnitConv))
426  {
429  }
430  aAny <<= static_cast<sal_Int16>(pEntry->GetPitch());
431  if (aPitchHdl.exportXML(sTmp, aAny, rUnitConv))
432  {
434  XML_FONT_PITCH, sTmp);
435  }
436 
437  aAny <<= static_cast<sal_Int16>(pEntry->GetEncoding());
438  if (aEncHdl.exportXML( sTmp, aAny, rUnitConv))
439  {
441  XML_FONT_CHARSET, sTmp);
442  }
443 
445  XML_FONT_FACE, true, true);
446 
447  if (m_bTryToEmbedFonts)
448  {
449  const bool bExportFlat(GetExport().getExportFlags() & SvXMLExportFlags::EMBEDDED);
450  std::vector<EmbeddedFontInfo> aEmbeddedFonts;
451  static const std::vector<std::pair<FontWeight, FontItalic>> aCombinations =
452  {
457  };
458 
459  for (auto const & aCombinationPair : aCombinations)
460  {
461  // Embed font if at least viewing is allowed (in which case the opening app must check
462  // the font license rights too and open either read-only or not use the font for editing).
463  OUString sFileUrl = EmbeddedFontsHelper::fontFileUrl(
464  pEntry->GetFamilyName(), pEntry->GetFamily(),
465  aCombinationPair.second, aCombinationPair.first, pEntry->GetPitch(),
467  if (sFileUrl.isEmpty())
468  continue;
469 
470  // When embedded only is not set or font is used
471  if (!m_bEmbedUsedOnly ||
472  aUsedFontNames.find(pEntry->GetFamilyName()) != aUsedFontNames.end())
473  {
474  if (!fontFilesMap.count(sFileUrl))
475  {
476  const OUString docUrl = bExportFlat ?
477  lcl_checkFontFile(sFileUrl) : embedFontFile(sFileUrl, pEntry->GetFamilyName());
478  if (!docUrl.isEmpty())
479  fontFilesMap[sFileUrl] = docUrl;
480  else
481  continue; // --> failed to embed
482  }
483  EmbeddedFontInfo aEmbeddedFont;
484  aEmbeddedFont.aURL = sFileUrl;
485  aEmbeddedFont.eWeight = aCombinationPair.first;
486  aEmbeddedFont.eItalic = aCombinationPair.second;
487  aEmbeddedFonts.push_back(aEmbeddedFont);
488  }
489  }
490  if (!aEmbeddedFonts.empty())
491  {
493  for (EmbeddedFontInfo const & rEmbeddedFont : aEmbeddedFonts)
494  {
495  if (fontFilesMap.count(rEmbeddedFont.aURL))
496  {
497  if (!bExportFlat)
498  {
500  fontFilesMap[rEmbeddedFont.aURL]);
502  }
503 
504  // Help consumers of our output by telling them which
505  // font file is which one.
507  FontItalicToString(rEmbeddedFont.eItalic));
509  FontWeightToString(rEmbeddedFont.eWeight));
510 
512  XML_FONT_FACE_URI, true, true);
513 
514  if (bExportFlat)
515  {
516  const uno::Reference<ucb::XSimpleFileAccess> xFileAccess(
517  ucb::SimpleFileAccess::create(GetExport().getComponentContext()));
518  try
519  {
520  const uno::Reference<io::XInputStream> xInput(xFileAccess->openFileRead(fontFilesMap[rEmbeddedFont.aURL]));
521  XMLBase64Export aBase64Exp(GetExport());
522  aBase64Exp.exportOfficeBinaryDataElement(xInput);
523  }
524  catch (const uno::Exception &)
525  {
526  // opening the file failed, ignore
527  }
528  }
529 
532  XML_FONT_FACE_FORMAT, true, true);
533  }
534  }
535  }
536  }
537  }
538 }
539 
540 static OUString getFreeFontName(uno::Reference<embed::XStorage> const & rxStorage, OUString const & rFamilyName)
541 {
542  OUString sName;
543  int nIndex = 1;
544  do
545  {
546  sName = "Font_" +
547  rFamilyName.replaceAll(" ", "_") + "_" +
548  OUString::number(nIndex) + ".ttf";
549  nIndex++;
550  } while (rxStorage->hasByName(sName));
551 
552  return sName;
553 }
554 
555 static OString convertToHashString(std::vector<unsigned char> const & rHash)
556 {
557  std::stringstream aStringStream;
558  for (auto const & rByte : rHash)
559  {
560  aStringStream << std::setw(2) << std::setfill('0') << std::hex << int(rByte);
561  }
562 
563  return aStringStream.str().c_str();
564 }
565 
566 static OString getFileHash(OUString const & rFileUrl)
567 {
568  OString aHash;
569  osl::File aFile(rFileUrl);
570  if (aFile.open(osl_File_OpenFlag_Read) != osl::File::E_None)
571  return aHash;
572 
574  for (;;)
575  {
576  sal_Int8 aBuffer[4096];
577  sal_uInt64 nReadSize;
578  sal_Bool bEof;
579  if (aFile.isEndOfFile(&bEof) != osl::File::E_None)
580  {
581  SAL_WARN("xmloff", "Error reading font file " << rFileUrl);
582  return aHash;
583  }
584  if (bEof)
585  break;
586  if (aFile.read(aBuffer, 4096, nReadSize) != osl::File::E_None)
587  {
588  SAL_WARN("xmloff", "Error reading font file " << rFileUrl);
589  return aHash;
590  }
591  if (nReadSize == 0)
592  break;
593  aHashEngine.update(reinterpret_cast<unsigned char*>(aBuffer), nReadSize);
594  }
595  return convertToHashString(aHashEngine.finalize());
596 }
597 
598 OUString XMLFontAutoStylePool::embedFontFile(OUString const & fileUrl, OUString const & rFamilyName)
599 {
600  try
601  {
602  OString sHashString = getFileHash(fileUrl);
603  if (m_aEmbeddedFontFiles.find(sHashString) != m_aEmbeddedFontFiles.end())
604  return m_aEmbeddedFontFiles.at(sHashString);
605 
606  osl::File file( fileUrl );
607  if( file.open( osl_File_OpenFlag_Read ) != osl::File::E_None )
608  return OUString();
609 
610  if ( !GetExport().GetTargetStorage().is() )
611  return OUString();
612 
613  uno::Reference< embed::XStorage > storage;
614  storage.set( GetExport().GetTargetStorage()->openStorageElement( "Fonts",
615  ::embed::ElementModes::WRITE ), uno::UNO_SET_THROW );
616 
617  OUString name = getFreeFontName(storage, rFamilyName);
618 
619  uno::Reference< io::XOutputStream > outputStream;
620  outputStream.set( storage->openStreamElement( name, ::embed::ElementModes::WRITE ), UNO_QUERY_THROW );
621  uno::Reference < beans::XPropertySet > propertySet( outputStream, uno::UNO_QUERY );
622  assert( propertySet.is());
623  propertySet->setPropertyValue( "MediaType", uno::makeAny( OUString( "application/x-font-ttf" ))); // TODO
624  for(;;)
625  {
626  sal_Int8 buffer[ 4096 ];
627  sal_uInt64 readSize;
628  sal_Bool eof;
629  if( file.isEndOfFile( &eof ) != osl::File::E_None )
630  {
631  SAL_WARN( "xmloff", "Error reading font file " << fileUrl );
632  outputStream->closeOutput();
633  return OUString();
634  }
635  if( eof )
636  break;
637  if( file.read( buffer, 4096, readSize ) != osl::File::E_None )
638  {
639  SAL_WARN( "xmloff", "Error reading font file " << fileUrl );
640  outputStream->closeOutput();
641  return OUString();
642  }
643  if( readSize == 0 )
644  break;
645  // coverity[overrun-buffer-arg : FALSE] - coverity has difficulty with css::uno::Sequence
646  outputStream->writeBytes(uno::Sequence<sal_Int8>(buffer, readSize));
647  }
648  outputStream->closeOutput();
649  if( storage.is() )
650  {
651  Reference< embed::XTransactedObject > transaction( storage, UNO_QUERY );
652  if( transaction.is())
653  {
654  transaction->commit();
655  OUString sInternalName = "Fonts/" + name;
656  m_aEmbeddedFontFiles.emplace(sHashString, sInternalName);
657  return sInternalName;
658  }
659  }
660  } catch( const Exception& )
661  {
662  TOOLS_WARN_EXCEPTION( "xmloff", "Exception when embedding a font file" );
663  }
664  return OUString();
665 }
666 
667 
668 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
css::uno::Reference< css::embed::XStorage > const & GetTargetStorage() const
Definition: xmlexp.cxx:2297
constexpr sal_uInt16 XML_NAMESPACE_LO_EXT
Definition: xmlnmspe.hxx:80
std::unordered_set< OUString > getUsedFontList()
static OString convertToHashString(std::vector< unsigned char > const &rHash)
constexpr sal_uInt16 XML_NAMESPACE_STYLE
Definition: xmlnmspe.hxx:30
URL aURL
OUString Add(const OUString &rFamilyName, const OUString &rStyleName, FontFamily nFamily, FontPitch nPitch, rtl_TextEncoding eEnc)
sal_Int32 nIndex
PropertyHandler for the XML-data-type:
Definition: fonthdl.hxx:64
the SvXMLTypeConverter converts values of various types from their internal representation to the tex...
Definition: xmluconv.hxx:77
OUString embedFontFile(OUString const &rFileUrl, OUString const &rFamilyName)
signed char sal_Int8
const SvXMLUnitConverter & GetMM100UnitConverter() const
Definition: xmlexp.hxx:395
virtual ~XMLFontAutoStylePool() override
const wchar_t *typedef int(__stdcall *DllNativeUnregProc)(int
static OString getFileHash(OUString const &rFileUrl)
virtual bool exportXML(OUString &rStrExpValue, const css::uno::Any &rValue, const SvXMLUnitConverter &rUnitConverter) const override
Exports the given value according to the XML-data-type corresponding to the derived class...
Definition: fonthdl.cxx:274
WEIGHT_BOLD
static OUString fontFileUrl(const OUString &familyName, FontFamily family, FontItalic italic, FontWeight weight, FontPitch pitch, FontRights rights)
int nCount
void AddAttribute(sal_uInt16 nPrefix, const char *pName, const OUString &rValue)
Definition: xmlexp.cxx:926
const char * sName
PropertyHandler for the XML-data-type:
Definition: fonthdl.hxx:28
static OUString getFreeFontName(uno::Reference< embed::XStorage > const &rxStorage, OUString const &rFamilyName)
OUString sPrefix
PropertyHandler for the XML-data-type:
Definition: fonthdl.hxx:52
#define TOOLS_WARN_EXCEPTION(area, stream)
virtual bool exportXML(OUString &rStrExpValue, const css::uno::Any &rValue, const SvXMLUnitConverter &rUnitConverter) const override
Exports the given value according to the XML-data-type corresponding to the derived class...
Definition: fonthdl.cxx:239
WEIGHT_NORMAL
virtual bool exportXML(OUString &rStrExpValue, const css::uno::Any &rValue, const SvXMLUnitConverter &rUnitConverter) const override
Exports the given value according to the XML-data-type corresponding to the derived class...
Definition: fonthdl.cxx:207
unsigned char sal_Bool
std::unique_ptr< XMLFontAutoStylePool_Impl > m_pFontAutoStylePool
ITALIC_NONE
XMLFontAutoStylePool(SvXMLExport &rExport, bool tryToEmbedFonts=false)
Reference< XComponentContext > getComponentContext(Reference< XMultiServiceFactory > const &factory)
FontPitch
constexpr sal_uInt16 XML_NAMESPACE_XLINK
Definition: xmlnmspe.hxx:35
FontFamily
FontWeight
std::unique_ptr< char[]> aBuffer
ITALIC_NORMAL
void update(const unsigned char *pInput, size_t length)
rtl::Reference< SvXMLAutoStylePoolP > const & GetAutoStylePool()
Definition: xmlexp.hxx:577
Handling of tokens in XML:
std::set< OUString > m_aNames
virtual bool exportXML(OUString &rStrExpValue, const css::uno::Any &rValue, const SvXMLUnitConverter &rUnitConverter) const override
Exports the given value according to the XML-data-type corresponding to the derived class...
Definition: fonthdl.cxx:117
const char * name
#define SAL_WARN(area, stream)
OUString Find(const OUString &rFamilyName, const OUString &rStyleName, FontFamily nFamily, FontPitch nPitch, rtl_TextEncoding eEnc) const
PropertyHandler for the XML-data-type:
Definition: fonthdl.hxx:40
css::uno::Any const SvXMLExport & rExport
Definition: ImageStyle.hxx:38
std::vector< unsigned char > finalize()
constexpr sal_uInt16 XML_NAMESPACE_SVG
Definition: xmlnmspe.hxx:40
std::unordered_map< OString, OUString > m_aEmbeddedFontFiles
std::vector< std::unique_ptr< XMLFontAutoStylePoolEntry_Impl > >::const_iterator const_iterator
FontItalic
constexpr sal_uInt16 XML_NAMESPACE_OFFICE
Definition: xmlnmspe.hxx:29
virtual void collectAutoStyles()
Definition: xmlexp.cxx:1715