bump product version to 5.0.4.1
[LibreOffice.git] / xmloff / source / style / impastpl.cxx
blob6717895cdf713dff58bb0776c605e48c0ae9aa43
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3 * This file is part of the LibreOffice project.
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/.
9 * This file incorporates work covered by the following license notice:
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 .
20 #include <algorithm>
22 #include <rtl/ustrbuf.hxx>
23 #include <tools/debug.hxx>
24 #include <tools/solar.h>
25 #include <xmloff/PageMasterStyleMap.hxx>
26 #include <xmloff/attrlist.hxx>
27 #include <xmloff/families.hxx>
28 #include <xmloff/nmspmap.hxx>
29 #include <xmloff/xmlaustp.hxx>
30 #include <xmloff/xmlexp.hxx>
31 #include <xmloff/xmlexppr.hxx>
32 #include <xmloff/xmlnmspe.hxx>
33 #include <xmloff/xmlprmap.hxx>
34 #include <xmloff/xmltoken.hxx>
36 #include "impastpl.hxx"
38 using namespace ::std;
40 using namespace ::com::sun::star;
41 using namespace ::xmloff::token;
43 // Class XMLAutoStyleFamily
44 // ctor/dtor class XMLAutoStyleFamily
46 XMLAutoStyleFamily::XMLAutoStyleFamily(
47 sal_Int32 nFamily,
48 const OUString& rStrName,
49 const rtl::Reference < SvXMLExportPropertyMapper > &rMapper,
50 const OUString& rStrPrefix,
51 bool bAsFamily ) :
52 mnFamily( nFamily ), maStrFamilyName( rStrName), mxMapper( rMapper ),
53 mnCount( 0 ), mnName( 0 ), maStrPrefix( rStrPrefix ), mbAsFamily( bAsFamily )
56 XMLAutoStyleFamily::XMLAutoStyleFamily( sal_Int32 nFamily ) :
57 mnFamily(nFamily), mnCount(0), mnName(0), mbAsFamily(false) {}
59 XMLAutoStyleFamily::~XMLAutoStyleFamily() {}
61 void XMLAutoStyleFamily::ClearEntries()
63 maParentSet.clear();
66 static OUString
67 data2string(void *data,
68 const typelib_TypeDescriptionReference *type);
70 static OUString
71 struct2string(void *data,
72 const typelib_TypeDescription *type)
74 assert(type->eTypeClass == typelib_TypeClass_STRUCT);
76 OUStringBuffer result;
78 result.append("{");
80 const typelib_CompoundTypeDescription *compoundType =
81 &reinterpret_cast<const typelib_StructTypeDescription*>(type)->aBase;
83 for (int i = 0; i < compoundType->nMembers; i++)
85 if (i > 0)
86 result.append(":");
87 result.append(compoundType->ppMemberNames[i]);
88 result.append("=");
89 result.append(data2string(static_cast<char *>(data)+compoundType->pMemberOffsets[i],
90 compoundType->ppTypeRefs[i]));
93 result.append("}");
95 return result.makeStringAndClear();
98 static OUString
99 data2string(void *data,
100 const typelib_TypeDescriptionReference *type)
102 OUStringBuffer result;
104 switch (type->eTypeClass)
106 case typelib_TypeClass_VOID:
107 break;
108 case typelib_TypeClass_BOOLEAN:
109 result.append((*static_cast<const sal_Bool*>(data) == sal_False ) ? OUString("false") : OUString("true"));
110 break;
111 case typelib_TypeClass_BYTE:
112 result.append(OUString::number((*static_cast<const sal_Int8*>(data))));
113 break;
114 case typelib_TypeClass_SHORT:
115 result.append(OUString::number((*static_cast<const sal_Int16*>(data))));
116 break;
117 case typelib_TypeClass_LONG:
118 result.append(OUString::number((*static_cast<const sal_Int32*>(data))));
119 break;
120 case typelib_TypeClass_HYPER:
121 result.append(OUString::number((*static_cast<const sal_Int64*>(data))));
122 break;
123 case typelib_TypeClass_UNSIGNED_SHORT:
124 result.append(OUString::number((*static_cast<const sal_uInt16*>(data))));
125 break;
126 case typelib_TypeClass_UNSIGNED_LONG:
127 result.append(OUString::number((*static_cast<const sal_uInt32*>(data)), 16));
128 break;
129 case typelib_TypeClass_UNSIGNED_HYPER:
130 result.append(OUString::number((*static_cast<const sal_uInt64*>(data)), 16));
131 break;
132 case typelib_TypeClass_FLOAT:
133 result.append(OUString::number((*static_cast<const float*>(data))));
134 break;
135 case typelib_TypeClass_DOUBLE:
136 result.append(OUString::number((*static_cast<const double*>(data))));
137 break;
138 case typelib_TypeClass_CHAR:
139 result.append("U+");
140 result.append(OUString::number((*static_cast<const sal_uInt16*>(data))));
141 break;
142 case typelib_TypeClass_STRING:
143 result.append(*static_cast<OUString*>(data));
144 break;
145 case typelib_TypeClass_TYPE:
146 case typelib_TypeClass_SEQUENCE:
147 case typelib_TypeClass_EXCEPTION:
148 case typelib_TypeClass_INTERFACE:
149 result.append("wtf");
150 break;
151 case typelib_TypeClass_STRUCT:
152 result.append(struct2string(data, type->pType));
153 break;
154 case typelib_TypeClass_ENUM:
155 result.append(OUString::number((*static_cast<const sal_Int32*>(data))));
156 break;
157 default:
158 assert(false); // this cannot happen I hope
159 break;
162 return result.makeStringAndClear();
165 static OUString
166 any2string(uno::Any any)
168 return data2string(const_cast<void*>(any.getValue()), any.pType);
171 // Class SvXMLAutoStylePoolProperties_Impl
172 // ctor class SvXMLAutoStylePoolProperties_Impl
174 XMLAutoStylePoolProperties::XMLAutoStylePoolProperties( XMLAutoStyleFamily& rFamilyData, const vector< XMLPropertyState >& rProperties, OUString& rParentName )
175 : maProperties( rProperties ),
176 mnPos ( rFamilyData.mnCount )
178 static bool bHack = (getenv("LIBO_ONEWAY_STABLE_ODF_EXPORT") != NULL);
180 if (bHack)
182 OUStringBuffer aStemBuffer(32);
183 aStemBuffer.append( rFamilyData.maStrPrefix );
185 if (!rParentName.isEmpty())
187 aStemBuffer.append("-");
188 aStemBuffer.append(rParentName);
191 // Create a name based on the properties used
192 for( size_t i = 0, n = maProperties.size(); i < n; ++i )
194 XMLPropertyState& rState = maProperties[i];
195 if (rState.mnIndex == -1)
196 continue;
197 OUString sXMLName(rFamilyData.mxMapper->getPropertySetMapper()->GetEntryXMLName(rState.mnIndex));
198 if (sXMLName.isEmpty())
199 continue;
200 aStemBuffer.append("-");
201 aStemBuffer.append(OUString::number(rFamilyData.mxMapper->getPropertySetMapper()->GetEntryNameSpace(rState.mnIndex)));
202 aStemBuffer.append(":");
203 aStemBuffer.append(sXMLName);
204 aStemBuffer.append("=");
205 aStemBuffer.append(any2string(rState.maValue));
208 #if 0
209 // Finally append an incremental counter in an attempt to make identical
210 // styles always come out in the same order. Will see if this works.
211 aStemBuffer.append("-z");
212 static sal_Int32 nCounter = 0;
213 aStemBuffer.append(OUString::number(nCounter++));
214 #endif
216 // create a name that hasn't been used before. The created name has not
217 // to be added to the array, because it will never tried again
218 OUStringBuffer aTry( aStemBuffer );
220 msName = aTry.makeStringAndClear();
221 bool bWarned = false;
222 while (rFamilyData.maNameSet.find(msName) !=
223 rFamilyData.maNameSet.end())
225 if (!bWarned)
226 SAL_WARN("xmloff", "Overlapping style name for " << msName);
227 bWarned = true;
228 rFamilyData.mnName++;
229 aTry.append( aStemBuffer );
230 aTry.append( "-" );
231 aTry.append( OUString::number( rFamilyData.mnName ) );
232 msName = aTry.makeStringAndClear();
234 rFamilyData.maNameSet.insert(msName);
236 else
238 // create a name that hasn't been used before. The created name has not
239 // to be added to the array, because it will never tried again
240 OUStringBuffer sBuffer( 7 );
243 rFamilyData.mnName++;
244 sBuffer.append( rFamilyData.maStrPrefix );
245 sBuffer.append( OUString::number( rFamilyData.mnName ) );
246 msName = sBuffer.makeStringAndClear();
248 while (rFamilyData.maNameSet.find(msName) != rFamilyData.maNameSet.end());
251 #if OSL_DEBUG_LEVEL > 0
252 std::set<sal_Int32> DebugProperties;
253 for (size_t i = 0; i < maProperties.size(); ++i)
255 sal_Int32 const property(maProperties[i].mnIndex);
256 // serious bug: will cause duplicate attributes to be exported
257 assert(DebugProperties.find(property) == DebugProperties.end());
258 if (-1 != property)
260 DebugProperties.insert(property);
263 #endif
266 bool operator<( const XMLAutoStyleFamily& r1, const XMLAutoStyleFamily& r2)
268 return r1.mnFamily < r2.mnFamily;
272 XMLAutoStylePoolParent::~XMLAutoStylePoolParent()
276 // Adds a array of XMLPropertyState ( vector< XMLPropertyState > ) to list
277 // if not added, yet.
279 bool XMLAutoStylePoolParent::Add( XMLAutoStyleFamily& rFamilyData, const vector< XMLPropertyState >& rProperties, OUString& rName, bool bDontSeek )
281 bool bAdded = false;
282 XMLAutoStylePoolProperties *pProperties = 0;
283 sal_Int32 nProperties = rProperties.size();
284 size_t i = 0;
285 for (size_t n = maPropertiesList.size(); i < n; ++i)
287 XMLAutoStylePoolProperties* pIS = &maPropertiesList[i];
288 if( nProperties > (sal_Int32)pIS->GetProperties().size() )
290 continue;
292 else if( nProperties < (sal_Int32)pIS->GetProperties().size() )
294 break;
296 else if( !bDontSeek && rFamilyData.mxMapper->Equals( pIS->GetProperties(), rProperties ) )
298 pProperties = pIS;
299 break;
303 if( !pProperties )
305 pProperties = new XMLAutoStylePoolProperties( rFamilyData, rProperties, msParent );
306 PropertiesListType::iterator it = maPropertiesList.begin();
307 ::std::advance( it, i );
308 maPropertiesList.insert( it, pProperties );
309 bAdded = true;
312 rName = pProperties->GetName();
314 return bAdded;
318 // Adds a array of XMLPropertyState ( vector< XMLPropertyState > ) with a given name.
319 // If the name exists already, nothing is done. If a style with a different name and
320 // the same properties exists, a new one is added (like with bDontSeek).
323 bool XMLAutoStylePoolParent::AddNamed( XMLAutoStyleFamily& rFamilyData, const vector< XMLPropertyState >& rProperties, const OUString& rName )
325 bool bAdded = false;
326 sal_Int32 nProperties = rProperties.size();
327 size_t i = 0;
328 for (size_t n = maPropertiesList.size(); i < n; ++i)
330 XMLAutoStylePoolProperties* pIS = &maPropertiesList[i];
331 if( nProperties > (sal_Int32)pIS->GetProperties().size() )
333 continue;
335 else if( nProperties < (sal_Int32)pIS->GetProperties().size() )
337 break;
341 if (rFamilyData.maNameSet.find(rName) == rFamilyData.maNameSet.end())
343 XMLAutoStylePoolProperties* pProperties =
344 new XMLAutoStylePoolProperties( rFamilyData, rProperties, msParent );
345 // ignore the generated name
346 pProperties->SetName( rName );
347 PropertiesListType::iterator it = maPropertiesList.begin();
348 ::std::advance( it, i );
349 maPropertiesList.insert( it, pProperties );
350 bAdded = true;
353 return bAdded;
357 // Search for a array of XMLPropertyState ( vector< XMLPropertyState > ) in list
360 OUString XMLAutoStylePoolParent::Find( const XMLAutoStyleFamily& rFamilyData, const vector< XMLPropertyState >& rProperties ) const
362 OUString sName;
363 vector< XMLPropertyState>::size_type nItems = rProperties.size();
364 for (size_t i = 0, n = maPropertiesList.size(); i < n; ++i)
366 const XMLAutoStylePoolProperties* pIS = &maPropertiesList[i];
367 if( nItems > pIS->GetProperties().size() )
369 continue;
371 else if( nItems < pIS->GetProperties().size() )
373 break;
375 else if( rFamilyData.mxMapper->Equals( pIS->GetProperties(), rProperties ) )
377 sName = pIS->GetName();
378 break;
382 return sName;
385 bool XMLAutoStylePoolParent::operator< (const XMLAutoStylePoolParent& rOther) const
387 return msParent < rOther.msParent;
390 // Class SvXMLAutoStylePool_Impl
391 // ctor/dtor class SvXMLAutoStylePool_Impl
393 SvXMLAutoStylePoolP_Impl::SvXMLAutoStylePoolP_Impl( SvXMLExport& rExp)
394 : rExport( rExp )
398 SvXMLAutoStylePoolP_Impl::~SvXMLAutoStylePoolP_Impl()
402 // Adds stylefamily-information to sorted list
404 void SvXMLAutoStylePoolP_Impl::AddFamily(
405 sal_Int32 nFamily,
406 const OUString& rStrName,
407 const rtl::Reference < SvXMLExportPropertyMapper > & rMapper,
408 const OUString& rStrPrefix,
409 bool bAsFamily )
411 // store family in a list if not already stored
412 SvXMLExportFlags nExportFlags = GetExport().getExportFlags();
413 bool bStylesOnly = (nExportFlags & SvXMLExportFlags::STYLES) && !(nExportFlags & SvXMLExportFlags::CONTENT);
415 OUString aPrefix( rStrPrefix );
416 if( bStylesOnly )
418 aPrefix = "M" + rStrPrefix;
421 #if OSL_DEBUG_LEVEL > 0
422 XMLAutoStyleFamily aTemporary( nFamily );
423 FamilySetType::iterator aFind = maFamilySet.find(aTemporary);
424 if( aFind != maFamilySet.end() )
426 // FIXME: do we really intend to replace the previous nFamily
427 // entry in this case ?
428 SAL_WARN_IF( aFind->mxMapper != rMapper, "xmloff",
429 "Adding duplicate family " << rStrName <<
430 " with mismatching mapper ! " <<
431 typeid(*aFind->mxMapper.get()).name() << " " <<
432 typeid(*rMapper.get()).name() );
434 #endif
436 XMLAutoStyleFamily *pFamily = new XMLAutoStyleFamily( nFamily, rStrName, rMapper, aPrefix, bAsFamily );
437 maFamilySet.insert(pFamily);
440 void SvXMLAutoStylePoolP_Impl::SetFamilyPropSetMapper(
441 sal_Int32 nFamily,
442 const rtl::Reference < SvXMLExportPropertyMapper > & rMapper )
445 XMLAutoStyleFamily aTemporary( nFamily );
446 FamilySetType::iterator aFind = maFamilySet.find(aTemporary);
447 if (aFind != maFamilySet.end())
448 aFind->mxMapper = rMapper;
451 // Adds a name to list
452 void SvXMLAutoStylePoolP_Impl::RegisterName( sal_Int32 nFamily, const OUString& rName )
454 XMLAutoStyleFamily aTmp( nFamily );
455 FamilySetType::iterator aFind = maFamilySet.find(aTmp);
456 assert(aFind != maFamilySet.end()); // family must be known
457 // SAL_DEBUG("SvXMLAutoStylePoolP_Impl::RegisterName: " << nFamily << ", '" << rName << "'");
458 aFind->maNameSet.insert(rName);
462 // Retrieve the list of registered names
465 void SvXMLAutoStylePoolP_Impl::GetRegisteredNames(
466 uno::Sequence<sal_Int32>& rFamilies,
467 uno::Sequence<OUString>& rNames )
469 // collect registered names + families
470 vector<sal_Int32> aFamilies;
471 vector<OUString> aNames;
473 // iterate over families
474 for (FamilySetType::iterator aJ = maFamilySet.begin(); aJ != maFamilySet.end(); ++aJ)
476 XMLAutoStyleFamily &rFamily = *aJ;
478 // iterate over names
479 for (XMLAutoStyleFamily::NameSetType::const_iterator aI = rFamily.maNameSet.begin(); aI != rFamily.maNameSet.end(); ++aI)
481 aFamilies.push_back( rFamily.mnFamily );
482 aNames.push_back( *aI );
486 // copy the families + names into the sequence types
487 assert(aFamilies.size() == aNames.size());
489 rFamilies.realloc( aFamilies.size() );
490 std::copy( aFamilies.begin(), aFamilies.end(), rFamilies.getArray() );
492 rNames.realloc( aNames.size() );
493 std::copy( aNames.begin(), aNames.end(), rNames.getArray() );
496 // Adds a array of XMLPropertyState ( vector< XMLPropertyState > ) to list
497 // if not added, yet.
499 bool SvXMLAutoStylePoolP_Impl::Add(
500 OUString& rName, sal_Int32 nFamily, const OUString& rParentName,
501 const ::std::vector< XMLPropertyState >& rProperties, bool bDontSeek )
503 XMLAutoStyleFamily aTemporary( nFamily );
504 FamilySetType::iterator aFind = maFamilySet.find(aTemporary);
505 assert(aFind != maFamilySet.end()); // family must be known
507 XMLAutoStyleFamily &rFamily = *aFind;
509 XMLAutoStylePoolParent aTmp(rParentName);
510 XMLAutoStyleFamily::ParentSetType::iterator it2 = rFamily.maParentSet.find(aTmp);
511 if (it2 == rFamily.maParentSet.end())
513 std::pair<XMLAutoStyleFamily::ParentSetType::iterator,bool> r =
514 rFamily.maParentSet.insert(new XMLAutoStylePoolParent(rParentName));
515 it2 = r.first;
518 XMLAutoStylePoolParent& rParent = *it2;
520 bool bRet = false;
521 if (rParent.Add(rFamily, rProperties, rName, bDontSeek))
523 rFamily.mnCount++;
524 bRet = true;
527 return bRet;
530 bool SvXMLAutoStylePoolP_Impl::AddNamed(
531 const OUString& rName, sal_Int32 nFamily, const OUString& rParentName,
532 const ::std::vector< XMLPropertyState >& rProperties )
534 // get family and parent the same way as in Add()
536 XMLAutoStyleFamily aTemporary( nFamily );
537 FamilySetType::iterator aFind = maFamilySet.find(aTemporary);
538 assert(aFind != maFamilySet.end()); // family must be known
540 XMLAutoStyleFamily &rFamily = *aFind;
542 XMLAutoStylePoolParent aTmp(rParentName);
543 XMLAutoStyleFamily::ParentSetType::iterator it2 = rFamily.maParentSet.find(aTmp);
544 if (it2 == rFamily.maParentSet.end())
546 std::pair<XMLAutoStyleFamily::ParentSetType::iterator,bool> r =
547 rFamily.maParentSet.insert(new XMLAutoStylePoolParent(rParentName));
548 it2 = r.first;
551 XMLAutoStylePoolParent& rParent = *it2;
553 bool bRet = false;
554 if (rParent.AddNamed(rFamily, rProperties, rName))
556 rFamily.mnCount++;
557 bRet = true;
560 return bRet;
564 // Search for a array of XMLPropertyState ( vector< XMLPropertyState > ) in list
567 OUString SvXMLAutoStylePoolP_Impl::Find( sal_Int32 nFamily,
568 const OUString& rParent,
569 const vector< XMLPropertyState >& rProperties ) const
571 OUString sName;
573 XMLAutoStyleFamily aTemporary( nFamily );
574 FamilySetType::const_iterator const iter = maFamilySet.find(aTemporary);
575 assert(iter != maFamilySet.end()); // family must be known
577 XMLAutoStyleFamily const& rFamily = *iter;
578 XMLAutoStylePoolParent aTmp( rParent );
579 XMLAutoStyleFamily::ParentSetType::const_iterator it2 = rFamily.maParentSet.find(aTmp);
580 if (it2 != rFamily.maParentSet.end())
582 sName = it2->Find(rFamily, rProperties);
585 return sName;
588 namespace {
590 struct AutoStylePoolExport
592 const OUString* mpParent;
593 XMLAutoStylePoolProperties* mpProperties;
595 AutoStylePoolExport() : mpParent(NULL), mpProperties(NULL) {}
598 struct StyleComparator
600 bool operator() (const AutoStylePoolExport& a, const AutoStylePoolExport& b)
602 return (a.mpProperties->GetName() < b.mpProperties->GetName() ||
603 (a.mpProperties->GetName() == b.mpProperties->GetName() && *a.mpParent < *b.mpParent));
609 void SvXMLAutoStylePoolP_Impl::exportXML(
610 sal_Int32 nFamily,
611 const uno::Reference< ::com::sun::star::xml::sax::XDocumentHandler > &,
612 const SvXMLUnitConverter&,
613 const SvXMLNamespaceMap&,
614 const SvXMLAutoStylePoolP *pAntiImpl) const
616 // Get list of parents for current family (nFamily)
617 XMLAutoStyleFamily aTmp( nFamily );
618 FamilySetType::const_iterator aFind = maFamilySet.find(aTmp);
619 assert(aFind != maFamilySet.end()); // family must be known
621 const XMLAutoStyleFamily &rFamily = *aFind;
622 sal_uInt32 nCount = rFamily.mnCount;
624 if (!nCount)
625 return;
627 // create, initialize and fill helper-structure (SvXMLAutoStylePoolProperties_Impl)
628 // which contains a parent-name and a SvXMLAutoStylePoolProperties_Impl
629 std::vector<AutoStylePoolExport> aExpStyles(nCount);
631 XMLAutoStyleFamily::ParentSetType::iterator it = rFamily.maParentSet.begin(), itEnd = rFamily.maParentSet.end();
632 for (; it != itEnd; ++it)
634 XMLAutoStylePoolParent& rParent = *it;
635 size_t nProperties = rParent.GetPropertiesList().size();
636 for( size_t j = 0; j < nProperties; j++ )
638 XMLAutoStylePoolProperties* pProperties =
639 &rParent.GetPropertiesList()[j];
640 sal_uLong nPos = pProperties->GetPos();
641 assert(nPos < nCount);
642 assert(!aExpStyles[nPos].mpProperties);
643 aExpStyles[nPos].mpProperties = pProperties;
644 aExpStyles[nPos].mpParent = &rParent.GetParent();
648 static bool bHack = (getenv("LIBO_ONEWAY_STABLE_ODF_EXPORT") != NULL);
650 if (bHack)
653 std::sort(aExpStyles.begin(), aExpStyles.end(), StyleComparator());
655 for (size_t i = 0; i < nCount; i++)
657 OUString oldName = aExpStyles[i].mpProperties->GetName();
658 sal_Int32 dashIx = oldName.indexOf('-');
659 OUString newName = (dashIx > 0 ? oldName.copy(0, dashIx) : oldName) + OUString::number(i);
660 // SAL_DEBUG("renaming '" << oldName << "' -> '" << newName << "'");
661 aExpStyles[i].mpProperties->SetName(newName);
666 // create string to export for each XML-style. That means for each property-list
668 OUString aStrFamilyName = rFamily.maStrFamilyName;
670 for( size_t i = 0; i < nCount; i++ )
672 assert(aExpStyles[i].mpProperties);
674 if( aExpStyles[i].mpProperties )
676 GetExport().AddAttribute(
677 XML_NAMESPACE_STYLE, XML_NAME,
678 aExpStyles[i].mpProperties->GetName() );
680 bool bExtensionNamespace = false;
681 if( rFamily.mbAsFamily )
683 GetExport().AddAttribute(
684 XML_NAMESPACE_STYLE, XML_FAMILY, aStrFamilyName );
685 if(aStrFamilyName != "graphic" &&
686 aStrFamilyName != "drawing-page" &&
687 aStrFamilyName != "presentation" &&
688 aStrFamilyName != "chart" )
689 bExtensionNamespace = true;
692 if( !aExpStyles[i].mpParent->isEmpty() )
694 GetExport().AddAttribute(
695 XML_NAMESPACE_STYLE, XML_PARENT_STYLE_NAME,
696 GetExport().EncodeStyleName(
697 *aExpStyles[i].mpParent ) );
700 OUString sName;
701 if( rFamily.mbAsFamily )
702 sName = GetXMLToken(XML_STYLE);
703 else
704 sName = rFamily.maStrFamilyName;
706 pAntiImpl->exportStyleAttributes(
707 GetExport().GetAttrList(),
708 nFamily,
709 aExpStyles[i].mpProperties->GetProperties(),
710 *rFamily.mxMapper.get()
711 , GetExport().GetMM100UnitConverter(),
712 GetExport().GetNamespaceMap()
715 SvXMLElementExport aElem( GetExport(),
716 XML_NAMESPACE_STYLE, sName,
717 true, true );
719 sal_Int32 nStart(-1);
720 sal_Int32 nEnd(-1);
721 if (nFamily == XML_STYLE_FAMILY_PAGE_MASTER)
723 nStart = 0;
724 sal_Int32 nIndex = 0;
725 rtl::Reference< XMLPropertySetMapper > aPropMapper =
726 rFamily.mxMapper->getPropertySetMapper();
727 sal_Int16 nContextID;
728 while(nIndex < aPropMapper->GetEntryCount() && nEnd == -1)
730 nContextID = aPropMapper->GetEntryContextId( nIndex );
731 if (nContextID && ((nContextID & CTF_PM_FLAGMASK) != XML_PM_CTF_START))
732 nEnd = nIndex;
733 nIndex++;
735 if (nEnd == -1)
736 nEnd = nIndex;
739 rFamily.mxMapper->exportXML(
740 GetExport(),
741 aExpStyles[i].mpProperties->GetProperties(),
742 nStart, nEnd, SvXmlExportFlags::IGN_WS, bExtensionNamespace );
744 pAntiImpl->exportStyleContent(
745 GetExport().GetDocHandler(),
746 nFamily,
747 aExpStyles[i].mpProperties->GetProperties(),
748 *rFamily.mxMapper.get(),
749 GetExport().GetMM100UnitConverter(),
750 GetExport().GetNamespaceMap()
756 void SvXMLAutoStylePoolP_Impl::ClearEntries()
758 for (FamilySetType::iterator aI = maFamilySet.begin(); aI != maFamilySet.end(); ++aI)
759 aI->ClearEntries();
762 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */