fdo#74697 Add Bluez 5 support for impress remote.
[LibreOffice.git] / xmloff / source / style / impastp3.cxx
blob41693a5d37d12297d1e1c9da69618823f465db35
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 "impastpl.hxx"
21 #include <xmloff/xmlprmap.hxx>
23 using namespace std;
26 //#############################################################################
28 // Class SvXMLAutoStylePoolParent_Impl
31 ///////////////////////////////////////////////////////////////////////////////
33 // dtor class SvXMLAutoStylePoolParent_Impl
36 SvXMLAutoStylePoolParentP_Impl::~SvXMLAutoStylePoolParentP_Impl()
38 for( size_t i = maPropertiesList.size(); i > 0; )
39 delete maPropertiesList[ --i ];
40 maPropertiesList.clear();
43 ///////////////////////////////////////////////////////////////////////////////
45 // Adds a array of XMLPropertyState ( vector< XMLPropertyState > ) to list
46 // if not added, yet.
49 sal_Bool SvXMLAutoStylePoolParentP_Impl::Add( XMLFamilyData_Impl& rFamilyData, const vector< XMLPropertyState >& rProperties, OUString& rName, bool bDontSeek )
51 sal_Bool bAdded = sal_False;
52 SvXMLAutoStylePoolPropertiesP_Impl *pProperties = 0;
53 size_t i = 0;
54 sal_Int32 nProperties = rProperties.size();
55 size_t nCount = maPropertiesList.size();
57 for( i = 0; i < nCount; i++ )
59 SvXMLAutoStylePoolPropertiesP_Impl *pIS = maPropertiesList[ i ];
60 if( nProperties > (sal_Int32)pIS->GetProperties().size() )
62 continue;
64 else if( nProperties < (sal_Int32)pIS->GetProperties().size() )
66 break;
68 else if( !bDontSeek && rFamilyData.mxMapper->Equals( pIS->GetProperties(), rProperties ) )
70 pProperties = pIS;
71 break;
75 if( !pProperties )
77 pProperties = new SvXMLAutoStylePoolPropertiesP_Impl( rFamilyData, rProperties );
78 SvXMLAutoStylePoolPropertiesPList_Impl::iterator it = maPropertiesList.begin();
79 ::std::advance( it, i );
80 maPropertiesList.insert( it, pProperties );
81 bAdded = sal_True;
84 rName = pProperties->GetName();
86 return bAdded;
89 ///////////////////////////////////////////////////////////////////////////////
91 // Adds a array of XMLPropertyState ( vector< XMLPropertyState > ) with a given name.
92 // If the name exists already, nothing is done. If a style with a different name and
93 // the same properties exists, a new one is added (like with bDontSeek).
96 sal_Bool SvXMLAutoStylePoolParentP_Impl::AddNamed( XMLFamilyData_Impl& rFamilyData, const vector< XMLPropertyState >& rProperties, const OUString& rName )
98 sal_Bool bAdded = sal_False;
99 size_t i = 0;
100 sal_Int32 nProperties = rProperties.size();
101 size_t nCount = maPropertiesList.size();
103 for( i = 0; i < nCount; i++ )
105 SvXMLAutoStylePoolPropertiesP_Impl *pIS = maPropertiesList[ i ];
106 if( nProperties > (sal_Int32)pIS->GetProperties().size() )
108 continue;
110 else if( nProperties < (sal_Int32)pIS->GetProperties().size() )
112 break;
116 if(rFamilyData.mpNameList->find(rName) == rFamilyData.mpNameList->end())
118 SvXMLAutoStylePoolPropertiesP_Impl* pProperties =
119 new SvXMLAutoStylePoolPropertiesP_Impl( rFamilyData, rProperties );
120 // ignore the generated name
121 pProperties->SetName( rName );
122 SvXMLAutoStylePoolPropertiesPList_Impl::iterator it = maPropertiesList.begin();
123 ::std::advance( it, i );
124 maPropertiesList.insert( it, pProperties );
125 bAdded = sal_True;
128 return bAdded;
131 ///////////////////////////////////////////////////////////////////////////////
133 // Search for a array of XMLPropertyState ( vector< XMLPropertyState > ) in list
136 OUString SvXMLAutoStylePoolParentP_Impl::Find( const XMLFamilyData_Impl& rFamilyData, const vector< XMLPropertyState >& rProperties ) const
138 OUString sName;
139 vector< XMLPropertyState>::size_type nItems = rProperties.size();
140 size_t nCount = maPropertiesList.size();
141 for( size_t i = 0; i < nCount; i++ )
143 SvXMLAutoStylePoolPropertiesP_Impl *pIS = maPropertiesList[ i ];
144 if( nItems > pIS->GetProperties().size() )
146 continue;
148 else if( nItems < pIS->GetProperties().size() )
150 break;
152 else if( rFamilyData.mxMapper->Equals( pIS->GetProperties(), rProperties ) )
154 sName = pIS->GetName();
155 break;
159 return sName;
162 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */