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, vector< XMLPropertyState >&& rProperties, OUString const & rParentName )
152 : maProperties( std::move(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(static_cast<sal_Int32>(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(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( static_cast<sal_Int64>(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( static_cast<sal_Int64>(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, 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, std::move(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, 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, std::move(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  XMLAutoStyleFamily aTemp(nFamily);
371  auto const iter = m_FamilySet.find(aTemp);
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  XMLAutoStyleFamily aTemp(nFamily);
392  auto const iter = m_FamilySet.find(aTemp);
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  XMLAutoStyleFamily aTemp(nFamily);
401  auto const iter = m_FamilySet.find(aTemp);
402  assert(iter != m_FamilySet.end()); // family must be known
403  (*iter)->maNameSet.insert(rName);
404 }
405 
406 // Adds a name to list
407 void SvXMLAutoStylePoolP_Impl::RegisterDefinedName( XmlStyleFamily nFamily, const OUString& rName )
408 {
409  XMLAutoStyleFamily aTemp(nFamily);
410  auto const iter = m_FamilySet.find(aTemp);
411  assert(iter != m_FamilySet.end()); // family must be known
412  (*iter)->maReservedNameSet.insert(rName);
413 }
414 
415 
416 // Retrieve the list of registered names
417 
418 
420  uno::Sequence<sal_Int32>& rFamilies,
421  uno::Sequence<OUString>& rNames )
422 {
423  // collect registered names + families
424  vector<sal_Int32> aFamilies;
425  vector<OUString> aNames;
426 
427  // iterate over families
428  for (auto const& aJ : m_FamilySet)
429  {
430  XMLAutoStyleFamily &rFamily = *aJ;
431 
432  // iterate over names
433  for (const auto& rName : rFamily.maNameSet)
434  {
435  aFamilies.push_back( static_cast<sal_Int32>(rFamily.mnFamily) );
436  aNames.push_back( rName );
437  }
438  }
439 
440  // copy the families + names into the sequence types
441  assert(aFamilies.size() == aNames.size());
442 
443  rFamilies.realloc( aFamilies.size() );
444  std::copy( aFamilies.begin(), aFamilies.end(), rFamilies.getArray() );
445 
446  rNames.realloc( aNames.size() );
447  std::copy( aNames.begin(), aNames.end(), rNames.getArray() );
448 }
449 
450 // Adds an array of XMLPropertyState ( vector< XMLPropertyState > ) to list
451 // if not added, yet.
452 
454  OUString& rName, XmlStyleFamily nFamily, const OUString& rParentName,
455  ::std::vector< XMLPropertyState >&& rProperties, bool bDontSeek )
456 {
457  XMLAutoStyleFamily aTemp(nFamily);
458  auto const iter = m_FamilySet.find(aTemp);
459  assert(iter != m_FamilySet.end()); // family must be known
460 
461  XMLAutoStyleFamily &rFamily = **iter;
462 
463  auto itPair = rFamily.m_ParentSet.insert(std::make_unique<XMLAutoStylePoolParent>(
464  rParentName));
465  XMLAutoStylePoolParent& rParent = **itPair.first;
466 
467  bool bRet = false;
468  if (rParent.Add(rFamily, std::move(rProperties), rName, bDontSeek))
469  {
470  rFamily.mnCount++;
471  bRet = true;
472  }
473 
474  return bRet;
475 }
476 
478  const OUString& rName, XmlStyleFamily nFamily, const OUString& rParentName,
479  std::vector< XMLPropertyState >&& rProperties )
480 {
481  // get family and parent the same way as in Add()
482 
483  XMLAutoStyleFamily aTemp(nFamily);
484  auto const iter = m_FamilySet.find(aTemp);
485  assert(iter != m_FamilySet.end()); // family must be known
486 
487  XMLAutoStyleFamily &rFamily = **iter;
488 
489  auto itPair = rFamily.m_ParentSet.insert(std::make_unique<XMLAutoStylePoolParent>(
490  rParentName));
491  XMLAutoStylePoolParent& rParent = **itPair.first;
492 
493  bool bRet = false;
494  if (rParent.AddNamed(rFamily, std::move(rProperties), rName))
495  {
496  rFamily.mnCount++;
497  bRet = true;
498  }
499 
500  return bRet;
501 }
502 
503 
504 // Search for an array of XMLPropertyState ( vector< XMLPropertyState > ) in list
505 
506 
508  const OUString& rParent,
509  const vector< XMLPropertyState >& rProperties ) const
510 {
511  OUString sName;
512 
513  XMLAutoStyleFamily aTemp(nFamily);
514  auto const iter = m_FamilySet.find(aTemp);
515  assert(iter != m_FamilySet.end()); // family must be known
516 
517  XMLAutoStyleFamily const& rFamily = **iter;
518  XMLAutoStylePoolParent aTmp(rParent);
519  auto const it2 = rFamily.m_ParentSet.find(aTmp);
520  if (it2 != rFamily.m_ParentSet.end())
521  {
522  sName = (*it2)->Find(rFamily, rProperties);
523  }
524 
525  return sName;
526 }
527 
528 std::vector<xmloff::AutoStyleEntry> SvXMLAutoStylePoolP_Impl::GetAutoStyleEntries() const
529 {
530  std::vector<xmloff::AutoStyleEntry> rReturnVector;
531 
532  for (std::unique_ptr<XMLAutoStyleFamily> const & rFamily : m_FamilySet)
533  {
534  rtl::Reference<XMLPropertySetMapper> aPropertyMapper = rFamily->mxMapper->getPropertySetMapper();
535  for (auto const & rParent : rFamily->m_ParentSet)
536  {
537  for (auto const & rProperty : rParent->GetPropertiesList())
538  {
539  rReturnVector.emplace_back();
540  xmloff::AutoStyleEntry & rEntry = rReturnVector.back();
541  for (XMLPropertyState const & rPropertyState : rProperty->GetProperties())
542  {
543  if (rPropertyState.mnIndex >= 0)
544  {
545  OUString sXmlName = aPropertyMapper->GetEntryXMLName(rPropertyState.mnIndex);
546  rEntry.m_aXmlProperties.emplace_back(sXmlName, rPropertyState.maValue);
547  }
548  }
549  }
550  }
551  }
552  return rReturnVector;
553 }
554 
555 namespace {
556 
557 struct AutoStylePoolExport
558 {
559  const OUString* mpParent;
560  XMLAutoStylePoolProperties* mpProperties;
561 
562  AutoStylePoolExport() : mpParent(nullptr), mpProperties(nullptr) {}
563 };
564 
565 struct StyleComparator
566 {
567  bool operator() (const AutoStylePoolExport& a, const AutoStylePoolExport& b)
568  {
569  return (a.mpProperties->GetName() < b.mpProperties->GetName() ||
570  (a.mpProperties->GetName() == b.mpProperties->GetName() && *a.mpParent < *b.mpParent));
571  }
572 };
573 
574 }
575 
577  XmlStyleFamily nFamily,
578  const SvXMLAutoStylePoolP *pAntiImpl) const
579 {
580  // Get list of parents for current family (nFamily)
581  XMLAutoStyleFamily aTemp(nFamily);
582  auto const iter = m_FamilySet.find(aTemp);
583  assert(iter != m_FamilySet.end()); // family must be known
584 
585  const XMLAutoStyleFamily &rFamily = **iter;
586  sal_uInt32 nCount = rFamily.mnCount;
587 
588  if (!nCount)
589  return;
590 
591  // create, initialize and fill helper-structure (SvXMLAutoStylePoolProperties_Impl)
592  // which contains a parent-name and a SvXMLAutoStylePoolProperties_Impl
593  std::vector<AutoStylePoolExport> aExpStyles(nCount);
594 
595  for (auto const& it : rFamily.m_ParentSet)
596  {
597  XMLAutoStylePoolParent& rParent = *it;
598  size_t nProperties = rParent.GetPropertiesList().size();
599  for( size_t j = 0; j < nProperties; j++ )
600  {
601  XMLAutoStylePoolProperties *const pProperties =
602  rParent.GetPropertiesList()[j].get();
603  sal_uInt32 nPos = pProperties->GetPos();
604  assert(nPos < nCount);
605  assert(!aExpStyles[nPos].mpProperties);
606  aExpStyles[nPos].mpProperties = pProperties;
607  aExpStyles[nPos].mpParent = &rParent.GetParent();
608  }
609  }
610 
611  static bool bHack = (getenv("LIBO_ONEWAY_STABLE_ODF_EXPORT") != nullptr);
612 
613  if (bHack)
614  {
615 
616  std::sort(aExpStyles.begin(), aExpStyles.end(), StyleComparator());
617 
618  for (size_t i = 0; i < nCount; i++)
619  {
620  OUString oldName = aExpStyles[i].mpProperties->GetName();
621  sal_Int32 dashIx = oldName.indexOf('-');
622  OUString newName = (dashIx > 0 ? oldName.copy(0, dashIx) : oldName) + OUString::number(i);
623  aExpStyles[i].mpProperties->SetName(newName);
624  }
625  }
626 
627 
628  // create string to export for each XML-style. That means for each property-list
629 
630  OUString aStrFamilyName = rFamily.maStrFamilyName;
631 
632  for( size_t i = 0; i < nCount; i++ )
633  {
634  assert(aExpStyles[i].mpProperties);
635 
636  if( aExpStyles[i].mpProperties )
637  {
640  aExpStyles[i].mpProperties->GetName() );
641 
642  bool bExtensionNamespace = false;
643  if( rFamily.mbAsFamily )
644  {
646  XML_NAMESPACE_STYLE, XML_FAMILY, aStrFamilyName );
647  if(aStrFamilyName != "graphic" &&
648  aStrFamilyName != "drawing-page" &&
649  aStrFamilyName != "presentation" &&
650  aStrFamilyName != "chart" )
651  bExtensionNamespace = true;
652  }
653 
654  if( !aExpStyles[i].mpParent->isEmpty() )
655  {
658  GetExport().EncodeStyleName(
659  *aExpStyles[i].mpParent ) );
660  }
661 
662  OUString sName;
663  if( rFamily.mbAsFamily )
664  sName = GetXMLToken(XML_STYLE);
665  else
666  sName = rFamily.maStrFamilyName;
667 
668  pAntiImpl->exportStyleAttributes(GetExport().GetAttrList(), nFamily,
669  aExpStyles[i].mpProperties->GetProperties(),
670  *rFamily.mxMapper, GetExport().GetMM100UnitConverter(),
672 
673  SvXMLElementExport aElem( GetExport(),
674  XML_NAMESPACE_STYLE, sName,
675  true, true );
676 
677  sal_Int32 nStart(-1);
678  sal_Int32 nEnd(-1);
679  if (nFamily == XmlStyleFamily::PAGE_MASTER)
680  {
681  nStart = 0;
682  sal_Int32 nIndex = 0;
684  rFamily.mxMapper->getPropertySetMapper();
685  sal_Int16 nContextID;
686  while(nIndex < aPropMapper->GetEntryCount() && nEnd == -1)
687  {
688  nContextID = aPropMapper->GetEntryContextId( nIndex );
689  if (nContextID && ((nContextID & CTF_PM_FLAGMASK) != XML_PM_CTF_START))
690  nEnd = nIndex;
691  nIndex++;
692  }
693  if (nEnd == -1)
694  nEnd = nIndex;
695  }
696 
697  rFamily.mxMapper->exportXML(
698  GetExport(),
699  aExpStyles[i].mpProperties->GetProperties(),
700  nStart, nEnd, SvXmlExportFlags::IGN_WS, bExtensionNamespace );
701 
702  pAntiImpl->exportStyleContent(GetExport().GetDocHandler(), nFamily,
703  aExpStyles[i].mpProperties->GetProperties(),
704  *rFamily.mxMapper, GetExport().GetMM100UnitConverter(),
706  }
707  }
708 }
709 
711 {
712  for (auto & aI : m_FamilySet)
713  aI->ClearEntries();
714 }
715 
716 /* 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:145
std::vector< xmloff::AutoStyleEntry > GetAutoStyleEntries() const
Definition: impastpl.cxx:528
const SvXMLUnitConverter & GetMM100UnitConverter() const
Definition: xmlexp.hxx:396
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:91
sal_uInt32 GetPos() const
Definition: impastpl.hxx:56
const OUString & GetParent() const
Definition: impastpl.hxx:86
OUString newName(std::u16string_view aNewPrefix, const OUString &aOldPrefix, std::u16string_view old_Name)
ParentSetType m_ParentSet
Definition: impastpl.hxx:107
FamilySetType m_FamilySet
Definition: impastpl.hxx:138
OUString Find(XmlStyleFamily nFamily, const OUString &rParent, const ::std::vector< XMLPropertyState > &rProperties) const
Definition: impastpl.cxx:507
void exportXML(XmlStyleFamily nFamily, const SvXMLAutoStylePoolP *pAntiImpl) const
Definition: impastpl.cxx:576
XmlStyleFamily
Definition: families.hxx:49
std::set< OUString > maNameSet
Definition: impastpl.hxx:108
void GetRegisteredNames(css::uno::Sequence< sal_Int32 > &aFamilies, css::uno::Sequence< OUString > &aNames)
Definition: impastpl.cxx:419
int nCount
void AddAttribute(sal_uInt16 nPrefix, const OUString &rName, const OUString &rValue)
Definition: xmlexp.cxx:911
::std::vector< XMLPropertyState > maProperties
Definition: impastpl.hxx:47
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
OUString maStrPrefix
Definition: impastpl.hxx:112
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:88
std::vector< std::pair< OUString, css::uno::Any > > m_aXmlProperties
void RegisterDefinedName(XmlStyleFamily nFamily, const OUString &rName)
Definition: impastpl.cxx:407
unsigned char sal_Bool
void RegisterName(XmlStyleFamily nFamily, const OUString &rName)
Definition: impastpl.cxx:398
std::size_t mnCount
sal_uInt32 mnName
Definition: impastpl.hxx:111
struct _typelib_TypeDescription typelib_TypeDescription
const SvXMLNamespaceMap & GetNamespaceMap() const
Definition: xmlexp.hxx:390
XmlStyleFamily mnFamily
Definition: impastpl.hxx:103
PropertiesListType m_PropertiesList
Definition: impastpl.hxx:69
RegionData_Impl * mpParent
bool Add(OUString &rName, XmlStyleFamily nFamily, const OUString &rParentName, std::vector< XMLPropertyState > &&rProperties, bool bDontSeek=false)
Definition: impastpl.cxx:453
rtl::Reference< SvXMLExportPropertyMapper > mxMapper
Definition: impastpl.hxx:105
bool AddNamed(const OUString &rName, XmlStyleFamily nFamily, const OUString &rParentName, std::vector< XMLPropertyState > &&rProperties)
Definition: impastpl.cxx:477
#define SAL_WARN_IF(condition, area, stream)
const OUString & GetXMLToken(enum XMLTokenEnum eToken)
return the OUString representation for eToken
Definition: xmltoken.cxx:3510
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:54
bool Add(XMLAutoStyleFamily &rFamilyData, std::vector< XMLPropertyState > &&rProperties, OUString &rName, bool bDontSeek)
Definition: impastpl.cxx:275
Smart struct to transport an Any with an index to the appropriate property-name.
Definition: maptype.hxx:139
const char * name
std::set< OUString > maReservedNameSet
Definition: impastpl.hxx:109
Any result
#define SAL_WARN(area, stream)
void SetFamilyPropSetMapper(XmlStyleFamily nFamily, const rtl::Reference< SvXMLExportPropertyMapper > &rMapper)
Definition: impastpl.cxx:387
bool AddNamed(XMLAutoStyleFamily &rFamilyData, std::vector< XMLPropertyState > &&rProperties, const OUString &rName)
Definition: impastpl.cxx:303
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:478
OUString Find(const XMLAutoStyleFamily &rFamilyData, const ::std::vector< XMLPropertyState > &rProperties) const
Definition: impastpl.cxx:322
constexpr sal_uInt16 XML_NAMESPACE_STYLE
XMLAutoStylePoolProperties(XMLAutoStyleFamily &rFamilyData, std::vector< XMLPropertyState > &&rProperties, OUString const &rParentname)
Definition: impastpl.cxx:151
sal_uInt16 nPos
bool m_bDetectedRangeSegmentation false