LibreOffice Module xmloff (master)  1
impastpl.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 <memory>
21 #include <algorithm>
22 
23 #include <rtl/ustrbuf.hxx>
24 #include <sal/log.hxx>
25 #include <tools/solar.h>
26 #include <PageMasterStyleMap.hxx>
27 #include <xmloff/families.hxx>
28 #include <xmloff/xmlaustp.hxx>
29 #include <xmloff/xmlexp.hxx>
30 #include <xmloff/xmlexppr.hxx>
31 #include <xmloff/xmlnamespace.hxx>
32 #include <xmloff/xmlprmap.hxx>
33 #include <xmloff/xmltoken.hxx>
34 
35 #include "impastpl.hxx"
36 
37 using namespace ::std;
38 
39 using namespace ::com::sun::star;
40 using namespace ::xmloff::token;
41 
42 // Class XMLAutoStyleFamily
43 // ctor/dtor class XMLAutoStyleFamily
44 
46  XmlStyleFamily nFamily,
47  const OUString& rStrName,
49  const OUString& rStrPrefix,
50  bool bAsFamily ) :
51  mnFamily( nFamily ), maStrFamilyName( rStrName), mxMapper( rMapper ),
52  mnCount( 0 ), mnName( 0 ), maStrPrefix( rStrPrefix ), mbAsFamily( bAsFamily )
53 {}
54 
56  mnFamily(nFamily), mnCount(0), mnName(0), mbAsFamily(false) {}
57 
59 {
60  m_ParentSet.clear();
61 }
62 
63 static OUString
64 data2string(void *data,
65  const typelib_TypeDescriptionReference *type);
66 
67 static OUString
68 struct2string(void *data,
69  const typelib_TypeDescription *type)
70 {
71  assert(type->eTypeClass == typelib_TypeClass_STRUCT);
72 
73  OUStringBuffer result;
74 
75  result.append("{");
76 
77  const typelib_CompoundTypeDescription *compoundType =
78  &reinterpret_cast<const typelib_StructTypeDescription*>(type)->aBase;
79 
80  for (int i = 0; i < compoundType->nMembers; i++)
81  {
82  if (i > 0)
83  result.append(":");
84  result.append(compoundType->ppMemberNames[i]);
85  result.append("=");
86  result.append(data2string(static_cast<char *>(data)+compoundType->pMemberOffsets[i],
87  compoundType->ppTypeRefs[i]));
88  }
89 
90  result.append("}");
91 
92  return result.makeStringAndClear();
93 }
94 
95 static OUString
96 data2string(void *data,
97  const typelib_TypeDescriptionReference *type)
98 {
99  switch (type->eTypeClass)
100  {
101  case typelib_TypeClass_VOID:
102  return "";
103  case typelib_TypeClass_BOOLEAN:
104  return *static_cast<const sal_Bool*>(data) ? OUString("true") : OUString("false");
105  case typelib_TypeClass_BYTE:
106  return OUString::number((*static_cast<const sal_Int8*>(data)));
107  case typelib_TypeClass_SHORT:
108  return OUString::number((*static_cast<const sal_Int16*>(data)));
109  case typelib_TypeClass_LONG:
110  return OUString::number((*static_cast<const sal_Int32*>(data)));
111  case typelib_TypeClass_HYPER:
112  return OUString::number((*static_cast<const sal_Int64*>(data)));
113  case typelib_TypeClass_UNSIGNED_SHORT:
114  return OUString::number((*static_cast<const sal_uInt16*>(data)));
115  case typelib_TypeClass_UNSIGNED_LONG:
116  return OUString::number((*static_cast<const sal_uInt32*>(data)), 16);
117  case typelib_TypeClass_UNSIGNED_HYPER:
118  return OUString::number((*static_cast<const sal_uInt64*>(data)), 16);
119  case typelib_TypeClass_FLOAT:
120  return OUString::number(*static_cast<const float*>(data));
121  case typelib_TypeClass_DOUBLE:
122  return OUString::number(*static_cast<const double*>(data));
123  case typelib_TypeClass_CHAR:
124  return ("U+" + OUString::number((*static_cast<const sal_uInt16*>(data))));
125  case typelib_TypeClass_STRING:
126  return *static_cast<OUString*>(data);
127  case typelib_TypeClass_TYPE:
128  case typelib_TypeClass_SEQUENCE:
129  case typelib_TypeClass_EXCEPTION:
130  case typelib_TypeClass_INTERFACE:
131  return "wtf";
132  case typelib_TypeClass_STRUCT:
133  return struct2string(data, type->pType);
134  case typelib_TypeClass_ENUM:
135  return OUString::number((*static_cast<const sal_Int32*>(data)));
136  default:
137  assert(false); // this cannot happen I hope
138  break;
139  }
140  return "";
141 }
142 
143 static OUString any2string(const uno::Any& any)
144 {
145  return data2string(const_cast<void*>(any.getValue()), any.pType);
146 }
147 
148 // Class SvXMLAutoStylePoolProperties_Impl
149 // ctor class SvXMLAutoStylePoolProperties_Impl
150 
151 XMLAutoStylePoolProperties::XMLAutoStylePoolProperties( XMLAutoStyleFamily& rFamilyData, const vector< XMLPropertyState >& rProperties, OUString const & rParentName )
152 : maProperties( rProperties ),
153  mnPos ( rFamilyData.mnCount )
154 {
155  static bool bHack = (getenv("LIBO_ONEWAY_STABLE_ODF_EXPORT") != nullptr);
156 
157  if (bHack)
158  {
159  OUStringBuffer aStemBuffer(32);
160  aStemBuffer.append( rFamilyData.maStrPrefix );
161 
162  if (!rParentName.isEmpty())
163  {
164  aStemBuffer.append("-");
165  aStemBuffer.append(rParentName);
166  }
167 
168  // Create a name based on the properties used
169  for(XMLPropertyState const & rState : maProperties)
170  {
171  if (rState.mnIndex == -1)
172  continue;
173  OUString sXMLName(rFamilyData.mxMapper->getPropertySetMapper()->GetEntryXMLName(rState.mnIndex));
174  if (sXMLName.isEmpty())
175  continue;
176  aStemBuffer.append("-");
177  aStemBuffer.append(OUString::number(rFamilyData.mxMapper->getPropertySetMapper()->GetEntryNameSpace(rState.mnIndex)));
178  aStemBuffer.append(":");
179  aStemBuffer.append(sXMLName);
180  aStemBuffer.append("=");
181  aStemBuffer.append(any2string(rState.maValue));
182  }
183 
184 #if 0
185  // Finally append an incremental counter in an attempt to make identical
186  // styles always come out in the same order. Will see if this works.
187  aStemBuffer.append("-z");
188  static sal_Int32 nCounter = 0;
189  aStemBuffer.append(OUString::number(nCounter++));
190 #endif
191 
192  // create a name that hasn't been used before. The created name has not
193  // to be added to the array, because it will never tried again
194  OUStringBuffer aTry( aStemBuffer );
195 
196  msName = aTry.makeStringAndClear();
197  bool bWarned = false;
198  while (rFamilyData.maNameSet.find(msName) !=
199  rFamilyData.maNameSet.end())
200  {
201  if (!bWarned)
202  SAL_WARN("xmloff", "Overlapping style name for " << msName);
203  bWarned = true;
204  rFamilyData.mnName++;
205  aTry.append( aStemBuffer );
206  aTry.append( "-" );
207  aTry.append( OUString::number( rFamilyData.mnName ) );
208  msName = aTry.makeStringAndClear();
209  }
210  rFamilyData.maNameSet.insert(msName);
211  }
212  else
213  {
214  // create a name that hasn't been used before. The created name has not
215  // to be added to the array, because it will never tried again
216  OUStringBuffer sBuffer( 7 );
217  do
218  {
219  rFamilyData.mnName++;
220  sBuffer.append( rFamilyData.maStrPrefix );
221  sBuffer.append( OUString::number( rFamilyData.mnName ) );
222  msName = sBuffer.makeStringAndClear();
223  }
224  while (rFamilyData.maNameSet.find(msName) != rFamilyData.maNameSet.end() || rFamilyData.maReservedNameSet.find(msName) != rFamilyData.maReservedNameSet.end());
225  }
226 
227 #if OSL_DEBUG_LEVEL > 0
228  std::set<sal_Int32> DebugProperties;
229  for (XMLPropertyState const & rPropState : maProperties)
230  {
231  sal_Int32 const property(rPropState.mnIndex);
232  // serious bug: will cause duplicate attributes to be exported
233  assert(DebugProperties.find(property) == DebugProperties.end());
234  if (-1 != property)
235  {
236  DebugProperties.insert(property);
237  }
238  }
239 #endif
240 }
241 
243 {
244  return r1.mnFamily < r2.mnFamily;
245 }
246 
247 
249 {
250 }
251 
252 namespace {
253 
254 struct ComparePartial
255 {
256  const XMLAutoStyleFamily& rFamilyData;
257 
258  bool operator()(const vector< XMLPropertyState >& lhs,
259  const std::unique_ptr<XMLAutoStylePoolProperties>& rhs) const
260  {
261  return rFamilyData.mxMapper->LessPartial(lhs, rhs->GetProperties());
262  }
263  bool operator()(const std::unique_ptr<XMLAutoStylePoolProperties>& lhs,
264  const vector< XMLPropertyState >& rhs ) const
265  {
266  return rFamilyData.mxMapper->LessPartial(lhs->GetProperties(), rhs);
267  }
268 };
269 
270 }
271 
272 // Adds an array of XMLPropertyState ( vector< XMLPropertyState > ) to list
273 // if not added, yet.
274 
275 bool XMLAutoStylePoolParent::Add( XMLAutoStyleFamily& rFamilyData, const vector< XMLPropertyState >& rProperties, OUString& rName, bool bDontSeek )
276 {
277  XMLAutoStylePoolProperties *pProperties = nullptr;
278  auto [itBegin, itEnd] = std::equal_range(m_PropertiesList.begin(), m_PropertiesList.end(), rProperties, ComparePartial{rFamilyData});
279  if (!bDontSeek)
280  for (auto it = itBegin; it != itEnd; ++it)
281  if (rFamilyData.mxMapper->Equals((*it)->GetProperties(), rProperties))
282  pProperties = it->get();
283 
284  bool bAdded = false;
285  if( bDontSeek || !pProperties )
286  {
287  pProperties = new XMLAutoStylePoolProperties( rFamilyData, rProperties, msParent );
288  m_PropertiesList.insert(itBegin, std::unique_ptr<XMLAutoStylePoolProperties>(pProperties));
289  bAdded = true;
290  }
291 
292  rName = pProperties->GetName();
293 
294  return bAdded;
295 }
296 
297 
298 // Adds an array of XMLPropertyState ( vector< XMLPropertyState > ) with a given name.
299 // If the name exists already, nothing is done. If a style with a different name and
300 // the same properties exists, a new one is added (like with bDontSeek).
301 
302 
303 bool XMLAutoStylePoolParent::AddNamed( XMLAutoStyleFamily& rFamilyData, const vector< XMLPropertyState >& rProperties, const OUString& rName )
304 {
305  if (rFamilyData.maNameSet.find(rName) != rFamilyData.maNameSet.end())
306  return false;
307 
308  auto it = std::lower_bound(m_PropertiesList.begin(), m_PropertiesList.end(), rProperties, ComparePartial{rFamilyData});
309 
310  std::unique_ptr<XMLAutoStylePoolProperties> pProperties(
311  new XMLAutoStylePoolProperties(rFamilyData, rProperties, msParent));
312  // ignore the generated name
313  pProperties->SetName( rName );
314  m_PropertiesList.insert(it, std::move(pProperties));
315  return true;
316 }
317 
318 
319 // Search for an array of XMLPropertyState ( vector< XMLPropertyState > ) in list
320 
321 
322 OUString XMLAutoStylePoolParent::Find( const XMLAutoStyleFamily& rFamilyData, const vector< XMLPropertyState >& rProperties ) const
323 {
324  OUString sName;
325  auto [itBegin,itEnd] = std::equal_range(m_PropertiesList.begin(), m_PropertiesList.end(), rProperties, ComparePartial{rFamilyData});
326  for (auto it = itBegin; it != itEnd; ++it)
327  if (rFamilyData.mxMapper->Equals((*it)->GetProperties(), rProperties))
328  sName = (*it)->GetName();
329 
330  return sName;
331 }
332 
334 {
335  return msParent < rOther.msParent;
336 }
337 
338 // Class SvXMLAutoStylePool_Impl
339 // ctor/dtor class SvXMLAutoStylePool_Impl
340 
342  : rExport( rExp )
343 {
344 }
345 
347 {
348 }
349 
350 // Adds stylefamily-information to sorted list
351 
353  XmlStyleFamily nFamily,
354  const OUString& rStrName,
356  const OUString& rStrPrefix,
357  bool bAsFamily )
358 {
359  // store family in a list if not already stored
360  SvXMLExportFlags nExportFlags = GetExport().getExportFlags();
361  bool bStylesOnly = (nExportFlags & SvXMLExportFlags::STYLES) && !(nExportFlags & SvXMLExportFlags::CONTENT);
362 
363  OUString aPrefix( rStrPrefix );
364  if( bStylesOnly )
365  {
366  aPrefix = "M" + rStrPrefix;
367  }
368 
369 #if OSL_DEBUG_LEVEL > 0
370  std::unique_ptr<XMLAutoStyleFamily> pTemp(new XMLAutoStyleFamily(nFamily));
371  auto const iter = m_FamilySet.find(pTemp);
372  if (iter != m_FamilySet.end())
373  {
374  // FIXME: do we really intend to replace the previous nFamily
375  // entry in this case ?
376  SAL_WARN_IF( (*iter)->mxMapper != rMapper, "xmloff",
377  "Adding duplicate family " << rStrName <<
378  " with mismatching mapper ! " <<
379  typeid((*iter)->mxMapper.get()).name() << " " <<
380  typeid(*rMapper).name() );
381  }
382 #endif
383 
384  m_FamilySet.insert(std::make_unique<XMLAutoStyleFamily>(nFamily, rStrName, rMapper, aPrefix, bAsFamily));
385 }
386 
388  XmlStyleFamily nFamily,
390 {
391  std::unique_ptr<XMLAutoStyleFamily> pTemp(new XMLAutoStyleFamily(nFamily));
392  auto const iter = m_FamilySet.find(pTemp);
393  if (iter != m_FamilySet.end())
394  (*iter)->mxMapper = rMapper;
395 }
396 
397 // Adds a name to list
398 void SvXMLAutoStylePoolP_Impl::RegisterName( XmlStyleFamily nFamily, const OUString& rName )
399 {
400  std::unique_ptr<XMLAutoStyleFamily> pTemp(new XMLAutoStyleFamily(nFamily));
401  auto const iter = m_FamilySet.find(pTemp);
402  assert(iter != m_FamilySet.end()); // family must be known
403  // SAL_DEBUG("SvXMLAutoStylePoolP_Impl::RegisterName: " << nFamily << ", '" << rName << "'");
404  (*iter)->maNameSet.insert(rName);
405 }
406 
407 // Adds a name to list
408 void SvXMLAutoStylePoolP_Impl::RegisterDefinedName( XmlStyleFamily nFamily, const OUString& rName )
409 {
410  std::unique_ptr<XMLAutoStyleFamily> pTemp(new XMLAutoStyleFamily(nFamily));
411  auto const iter = m_FamilySet.find(pTemp);
412  assert(iter != m_FamilySet.end()); // family must be known
413  (*iter)->maReservedNameSet.insert(rName);
414 }
415 
416 
417 // Retrieve the list of registered names
418 
419 
421  uno::Sequence<sal_Int32>& rFamilies,
422  uno::Sequence<OUString>& rNames )
423 {
424  // collect registered names + families
425  vector<sal_Int32> aFamilies;
426  vector<OUString> aNames;
427 
428  // iterate over families
429  for (auto const& aJ : m_FamilySet)
430  {
431  XMLAutoStyleFamily &rFamily = *aJ;
432 
433  // iterate over names
434  for (const auto& rName : rFamily.maNameSet)
435  {
436  aFamilies.push_back( static_cast<sal_Int32>(rFamily.mnFamily) );
437  aNames.push_back( rName );
438  }
439  }
440 
441  // copy the families + names into the sequence types
442  assert(aFamilies.size() == aNames.size());
443 
444  rFamilies.realloc( aFamilies.size() );
445  std::copy( aFamilies.begin(), aFamilies.end(), rFamilies.getArray() );
446 
447  rNames.realloc( aNames.size() );
448  std::copy( aNames.begin(), aNames.end(), rNames.getArray() );
449 }
450 
451 // Adds an array of XMLPropertyState ( vector< XMLPropertyState > ) to list
452 // if not added, yet.
453 
455  OUString& rName, XmlStyleFamily nFamily, const OUString& rParentName,
456  const ::std::vector< XMLPropertyState >& rProperties, bool bDontSeek )
457 {
458  std::unique_ptr<XMLAutoStyleFamily> pTemp(new XMLAutoStyleFamily(nFamily));
459  auto const iter = m_FamilySet.find(pTemp);
460  assert(iter != m_FamilySet.end()); // family must be known
461 
462  XMLAutoStyleFamily &rFamily = **iter;
463 
464  auto itPair = rFamily.m_ParentSet.insert(std::make_unique<XMLAutoStylePoolParent>(
465  rParentName));
466  XMLAutoStylePoolParent& rParent = **itPair.first;
467 
468  bool bRet = false;
469  if (rParent.Add(rFamily, rProperties, rName, bDontSeek))
470  {
471  rFamily.mnCount++;
472  bRet = true;
473  }
474 
475  return bRet;
476 }
477 
479  const OUString& rName, XmlStyleFamily nFamily, const OUString& rParentName,
480  const ::std::vector< XMLPropertyState >& rProperties )
481 {
482  // get family and parent the same way as in Add()
483 
484  std::unique_ptr<XMLAutoStyleFamily> pTemp(new XMLAutoStyleFamily(nFamily));
485  auto const iter = m_FamilySet.find(pTemp);
486  assert(iter != m_FamilySet.end()); // family must be known
487 
488  XMLAutoStyleFamily &rFamily = **iter;
489 
490  auto itPair = rFamily.m_ParentSet.insert(std::make_unique<XMLAutoStylePoolParent>(
491  rParentName));
492  XMLAutoStylePoolParent& rParent = **itPair.first;
493 
494  bool bRet = false;
495  if (rParent.AddNamed(rFamily, rProperties, rName))
496  {
497  rFamily.mnCount++;
498  bRet = true;
499  }
500 
501  return bRet;
502 }
503 
504 
505 // Search for an array of XMLPropertyState ( vector< XMLPropertyState > ) in list
506 
507 
509  const OUString& rParent,
510  const vector< XMLPropertyState >& rProperties ) const
511 {
512  OUString sName;
513 
514  std::unique_ptr<XMLAutoStyleFamily> pTemp(new XMLAutoStyleFamily(nFamily));
515  auto const iter = m_FamilySet.find(pTemp);
516  assert(iter != m_FamilySet.end()); // family must be known
517 
518  XMLAutoStyleFamily const& rFamily = **iter;
519  std::unique_ptr<XMLAutoStylePoolParent> pTmp(new XMLAutoStylePoolParent(rParent));
520  auto const it2 = rFamily.m_ParentSet.find(pTmp);
521  if (it2 != rFamily.m_ParentSet.end())
522  {
523  sName = (*it2)->Find(rFamily, rProperties);
524  }
525 
526  return sName;
527 }
528 
529 std::vector<xmloff::AutoStyleEntry> SvXMLAutoStylePoolP_Impl::GetAutoStyleEntries() const
530 {
531  std::vector<xmloff::AutoStyleEntry> rReturnVector;
532 
533  for (std::unique_ptr<XMLAutoStyleFamily> const & rFamily : m_FamilySet)
534  {
535  rtl::Reference<XMLPropertySetMapper> aPropertyMapper = rFamily->mxMapper->getPropertySetMapper();
536  for (auto const & rParent : rFamily->m_ParentSet)
537  {
538  for (auto const & rProperty : rParent->GetPropertiesList())
539  {
540  rReturnVector.emplace_back();
541  xmloff::AutoStyleEntry & rEntry = rReturnVector.back();
542  for (XMLPropertyState const & rPropertyState : rProperty->GetProperties())
543  {
544  if (rPropertyState.mnIndex >= 0)
545  {
546  OUString sXmlName = aPropertyMapper->GetEntryXMLName(rPropertyState.mnIndex);
547  rEntry.m_aXmlProperties.emplace_back(sXmlName, rPropertyState.maValue);
548  }
549  }
550  }
551  }
552  }
553  return rReturnVector;
554 }
555 
556 namespace {
557 
558 struct AutoStylePoolExport
559 {
560  const OUString* mpParent;
561  XMLAutoStylePoolProperties* mpProperties;
562 
563  AutoStylePoolExport() : mpParent(nullptr), mpProperties(nullptr) {}
564 };
565 
566 struct StyleComparator
567 {
568  bool operator() (const AutoStylePoolExport& a, const AutoStylePoolExport& b)
569  {
570  return (a.mpProperties->GetName() < b.mpProperties->GetName() ||
571  (a.mpProperties->GetName() == b.mpProperties->GetName() && *a.mpParent < *b.mpParent));
572  }
573 };
574 
575 }
576 
578  XmlStyleFamily nFamily,
579  const SvXMLAutoStylePoolP *pAntiImpl) const
580 {
581  // Get list of parents for current family (nFamily)
582  std::unique_ptr<XMLAutoStyleFamily> pTemp(new XMLAutoStyleFamily(nFamily));
583  auto const iter = m_FamilySet.find(pTemp);
584  assert(iter != m_FamilySet.end()); // family must be known
585 
586  const XMLAutoStyleFamily &rFamily = **iter;
587  sal_uInt32 nCount = rFamily.mnCount;
588 
589  if (!nCount)
590  return;
591 
592  // create, initialize and fill helper-structure (SvXMLAutoStylePoolProperties_Impl)
593  // which contains a parent-name and a SvXMLAutoStylePoolProperties_Impl
594  std::vector<AutoStylePoolExport> aExpStyles(nCount);
595 
596  for (auto const& it : rFamily.m_ParentSet)
597  {
598  XMLAutoStylePoolParent& rParent = *it;
599  size_t nProperties = rParent.GetPropertiesList().size();
600  for( size_t j = 0; j < nProperties; j++ )
601  {
602  XMLAutoStylePoolProperties *const pProperties =
603  rParent.GetPropertiesList()[j].get();
604  sal_uInt32 nPos = pProperties->GetPos();
605  assert(nPos < nCount);
606  assert(!aExpStyles[nPos].mpProperties);
607  aExpStyles[nPos].mpProperties = pProperties;
608  aExpStyles[nPos].mpParent = &rParent.GetParent();
609  }
610  }
611 
612  static bool bHack = (getenv("LIBO_ONEWAY_STABLE_ODF_EXPORT") != nullptr);
613 
614  if (bHack)
615  {
616 
617  std::sort(aExpStyles.begin(), aExpStyles.end(), StyleComparator());
618 
619  for (size_t i = 0; i < nCount; i++)
620  {
621  OUString oldName = aExpStyles[i].mpProperties->GetName();
622  sal_Int32 dashIx = oldName.indexOf('-');
623  OUString newName = (dashIx > 0 ? oldName.copy(0, dashIx) : oldName) + OUString::number(i);
624  // SAL_DEBUG("renaming '" << oldName << "' -> '" << newName << "'");
625  aExpStyles[i].mpProperties->SetName(newName);
626  }
627  }
628 
629 
630  // create string to export for each XML-style. That means for each property-list
631 
632  OUString aStrFamilyName = rFamily.maStrFamilyName;
633 
634  for( size_t i = 0; i < nCount; i++ )
635  {
636  assert(aExpStyles[i].mpProperties);
637 
638  if( aExpStyles[i].mpProperties )
639  {
642  aExpStyles[i].mpProperties->GetName() );
643 
644  bool bExtensionNamespace = false;
645  if( rFamily.mbAsFamily )
646  {
648  XML_NAMESPACE_STYLE, XML_FAMILY, aStrFamilyName );
649  if(aStrFamilyName != "graphic" &&
650  aStrFamilyName != "drawing-page" &&
651  aStrFamilyName != "presentation" &&
652  aStrFamilyName != "chart" )
653  bExtensionNamespace = true;
654  }
655 
656  if( !aExpStyles[i].mpParent->isEmpty() )
657  {
660  GetExport().EncodeStyleName(
661  *aExpStyles[i].mpParent ) );
662  }
663 
664  OUString sName;
665  if( rFamily.mbAsFamily )
666  sName = GetXMLToken(XML_STYLE);
667  else
668  sName = rFamily.maStrFamilyName;
669 
670  pAntiImpl->exportStyleAttributes(GetExport().GetAttrList(), nFamily,
671  aExpStyles[i].mpProperties->GetProperties(),
672  *rFamily.mxMapper, GetExport().GetMM100UnitConverter(),
674 
675  SvXMLElementExport aElem( GetExport(),
676  XML_NAMESPACE_STYLE, sName,
677  true, true );
678 
679  sal_Int32 nStart(-1);
680  sal_Int32 nEnd(-1);
681  if (nFamily == XmlStyleFamily::PAGE_MASTER)
682  {
683  nStart = 0;
684  sal_Int32 nIndex = 0;
686  rFamily.mxMapper->getPropertySetMapper();
687  sal_Int16 nContextID;
688  while(nIndex < aPropMapper->GetEntryCount() && nEnd == -1)
689  {
690  nContextID = aPropMapper->GetEntryContextId( nIndex );
691  if (nContextID && ((nContextID & CTF_PM_FLAGMASK) != XML_PM_CTF_START))
692  nEnd = nIndex;
693  nIndex++;
694  }
695  if (nEnd == -1)
696  nEnd = nIndex;
697  }
698 
699  rFamily.mxMapper->exportXML(
700  GetExport(),
701  aExpStyles[i].mpProperties->GetProperties(),
702  nStart, nEnd, SvXmlExportFlags::IGN_WS, bExtensionNamespace );
703 
704  pAntiImpl->exportStyleContent(GetExport().GetDocHandler(), nFamily,
705  aExpStyles[i].mpProperties->GetProperties(),
706  *rFamily.mxMapper, GetExport().GetMM100UnitConverter(),
708  }
709  }
710 }
711 
713 {
714  for (auto & aI : m_FamilySet)
715  aI->ClearEntries();
716 }
717 
718 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
#define CTF_PM_FLAGMASK
sal_Int32 nIndex
static OUString any2string(const uno::Any &any)
Definition: impastpl.cxx:143
virtual void exportStyleAttributes(SvXMLAttributeList &rAttrList, XmlStyleFamily nFamily, const ::std::vector< XMLPropertyState > &rProperties, const SvXMLExportPropertyMapper &rPropExp, const SvXMLUnitConverter &rUnitConverter, const SvXMLNamespaceMap &rNamespaceMap) const
Definition: xmlaustp.cxx:60
bool operator<(const XMLAutoStyleFamily &r1, const XMLAutoStyleFamily &r2)
Definition: impastpl.cxx:242
sal_Int32 nProperties
SvXMLExport & GetExport() const
Definition: impastpl.hxx:146
std::vector< xmloff::AutoStyleEntry > GetAutoStyleEntries() const
Definition: impastpl.cxx:529
const SvXMLUnitConverter & GetMM100UnitConverter() const
Definition: xmlexp.hxx:394
virtual void exportStyleContent(const css::uno::Reference< css::xml::sax::XDocumentHandler > &rHandler, XmlStyleFamily nFamily, const ::std::vector< XMLPropertyState > &rProperties, const SvXMLExportPropertyMapper &rPropExp, const SvXMLUnitConverter &rUnitConverter, const SvXMLNamespaceMap &rNamespaceMap) const
Definition: xmlaustp.cxx:170
SvXMLExportFlags
Definition: xmlexp.hxx:89
sal_uInt32 GetPos() const
Definition: impastpl.hxx:57
const OUString & GetParent() const
Definition: impastpl.hxx:87
ParentSetType m_ParentSet
Definition: impastpl.hxx:108
OUString newName(const OUString &aNewPrefix, const OUString &aOldPrefix, std::u16string_view old_Name)
FamilySetType m_FamilySet
Definition: impastpl.hxx:139
OUString Find(XmlStyleFamily nFamily, const OUString &rParent, const ::std::vector< XMLPropertyState > &rProperties) const
Definition: impastpl.cxx:508
void exportXML(XmlStyleFamily nFamily, const SvXMLAutoStylePoolP *pAntiImpl) const
Definition: impastpl.cxx:577
bool AddNamed(XMLAutoStyleFamily &rFamilyData, const ::std::vector< XMLPropertyState > &rProperties, const OUString &rName)
Definition: impastpl.cxx:303
XmlStyleFamily
Definition: families.hxx:47
std::set< OUString > maNameSet
Definition: impastpl.hxx:109
const BorderLinePrimitive2D *pCandidateB assert(pCandidateA)
void GetRegisteredNames(css::uno::Sequence< sal_Int32 > &aFamilies, css::uno::Sequence< OUString > &aNames)
Definition: impastpl.cxx:420
int nCount
bool AddNamed(const OUString &rName, XmlStyleFamily nFamily, const OUString &rParentName, const ::std::vector< XMLPropertyState > &rProperties)
Definition: impastpl.cxx:478
void AddAttribute(sal_uInt16 nPrefix, const char *pName, const OUString &rValue)
Definition: xmlexp.cxx:909
bool Add(XMLAutoStyleFamily &rFamilyData, const ::std::vector< XMLPropertyState > &rProperties, OUString &rName, bool bDontSeek)
Definition: impastpl.cxx:275
::std::vector< XMLPropertyState > maProperties
Definition: impastpl.hxx:48
SvGenericNameContainerMapImpl maProperties
#define XML_PM_CTF_START
Definition: contextid.hxx:30
static OUString struct2string(void *data, const typelib_TypeDescription *type)
Definition: impastpl.cxx:68
const char * sName
SvXMLAutoStylePoolP_Impl(SvXMLExport &rExport)
Definition: impastpl.cxx:341
bool Add(OUString &rName, XmlStyleFamily nFamily, const OUString &rParentName, const ::std::vector< XMLPropertyState > &rProperties, bool bDontSeek=false)
Definition: impastpl.cxx:454
OUString maStrPrefix
Definition: impastpl.hxx:113
int i
void AddFamily(XmlStyleFamily nFamily, const OUString &rStrName, const rtl::Reference< SvXMLExportPropertyMapper > &rMapper, const OUString &rStrPrefix, bool bAsFamily)
Definition: impastpl.cxx:352
PropertiesListType & GetPropertiesList()
Definition: impastpl.hxx:89
std::vector< std::pair< OUString, css::uno::Any > > m_aXmlProperties
void RegisterDefinedName(XmlStyleFamily nFamily, const OUString &rName)
Definition: impastpl.cxx:408
unsigned char sal_Bool
XMLAutoStylePoolProperties(XMLAutoStyleFamily &rFamilyData, const ::std::vector< XMLPropertyState > &rProperties, OUString const &rParentname)
Definition: impastpl.cxx:151
void RegisterName(XmlStyleFamily nFamily, const OUString &rName)
Definition: impastpl.cxx:398
std::size_t mnCount
sal_uInt32 mnName
Definition: impastpl.hxx:112
struct _typelib_TypeDescription typelib_TypeDescription
const SvXMLNamespaceMap & GetNamespaceMap() const
Definition: xmlexp.hxx:391
XmlStyleFamily mnFamily
Definition: impastpl.hxx:104
PropertiesListType m_PropertiesList
Definition: impastpl.hxx:70
RegionData_Impl * mpParent
rtl::Reference< SvXMLExportPropertyMapper > mxMapper
Definition: impastpl.hxx:106
#define SAL_WARN_IF(condition, area, stream)
const OUString & GetXMLToken(enum XMLTokenEnum eToken)
return the OUString representation for eToken
Definition: xmltoken.cxx:3405
Handling of tokens in XML:
static OUString data2string(void *data, const typelib_TypeDescriptionReference *type)
Definition: impastpl.cxx:96
const OUString & GetName() const
Definition: impastpl.hxx:55
Smart struct to transport an Any with an index to the appropriate property-name.
Definition: maptype.hxx:122
const char * name
std::set< OUString > maReservedNameSet
Definition: impastpl.hxx:110
Any result
#define SAL_WARN(area, stream)
void SetFamilyPropSetMapper(XmlStyleFamily nFamily, const rtl::Reference< SvXMLExportPropertyMapper > &rMapper)
Definition: impastpl.cxx:387
css::uno::Any const SvXMLExport & rExport
Definition: ImageStyle.hxx:38
bool operator<(const XMLAutoStylePoolParent &rOther) const
Definition: impastpl.cxx:333
XMLAutoStyleFamily(XmlStyleFamily nFamily, const OUString &rStrName, const rtl::Reference< SvXMLExportPropertyMapper > &rMapper, const OUString &rStrPrefix, bool bAsFamily)
Definition: impastpl.cxx:45
SvXMLExportFlags getExportFlags() const
Definition: xmlexp.hxx:476
OUString Find(const XMLAutoStyleFamily &rFamilyData, const ::std::vector< XMLPropertyState > &rProperties) const
Definition: impastpl.cxx:322
constexpr sal_uInt16 XML_NAMESPACE_STYLE
sal_uInt16 nPos