/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ /* * This file is part of the LibreOffice project. * * This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at http://mozilla.org/MPL/2.0/. * * This file incorporates work covered by the following license notice: * * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed * with this work for additional information regarding copyright * ownership. The ASF licenses this file to you under the Apache * License, Version 2.0 (the "License"); you may not use this file * except in compliance with the License. You may obtain a copy of * the License at http://www.apache.org/licenses/LICENSE-2.0 . */ #include "impastpl.hxx" namespace binfilter { using namespace std; using ::rtl::OUString; //############################################################################# // // Class SvXMLAutoStylePoolParent_Impl // /////////////////////////////////////////////////////////////////////////////// // // dtor class SvXMLAutoStylePoolParent_Impl // SvXMLAutoStylePoolParentP_Impl::~SvXMLAutoStylePoolParentP_Impl() { for( size_t i = maPropertiesList.size(); i > 0; ) delete maPropertiesList[ --i ]; maPropertiesList.clear(); } /////////////////////////////////////////////////////////////////////////////// // // Adds a array of XMLPropertyState ( vector< XMLPropertyState > ) to list // if not added, yet. // sal_Bool SvXMLAutoStylePoolParentP_Impl::Add( XMLFamilyData_Impl* pFamilyData, const vector< XMLPropertyState >& rProperties, OUString& rName ) { sal_Bool bAdded = sal_False; size_t nProperties = rProperties.size(); size_t nCount = maPropertiesList.size(); SvXMLAutoStylePoolPropertiesP_Impl *pProperties = 0; size_t i; for( i=0; i < nCount; i++ ) { SvXMLAutoStylePoolPropertiesP_Impl *pIS = maPropertiesList[ i ]; if( nProperties > pIS->GetProperties().size() ) { continue; } else if( nProperties < pIS->GetProperties().size() ) { break; } else if( pFamilyData->mxMapper->Equals( pIS->GetProperties(), rProperties ) ) { pProperties = pIS; break; } } if( !pProperties ) { pProperties = new SvXMLAutoStylePoolPropertiesP_Impl( pFamilyData, rProperties ); if ( i < maPropertiesList.size() ) { SvXMLAutoStylePoolPropertiesPList_Impl::iterator it = maPropertiesList.begin(); ::std::advance( it, i ); maPropertiesList.insert( it, pProperties ); } else maPropertiesList.push_back( pProperties ); bAdded = sal_True; } rName = pProperties->GetName(); return bAdded; } /////////////////////////////////////////////////////////////////////////////// // // Search for a array of XMLPropertyState ( vector< XMLPropertyState > ) in list // OUString SvXMLAutoStylePoolParentP_Impl::Find( const XMLFamilyData_Impl* pFamilyData, const vector< XMLPropertyState >& rProperties ) const { OUString sName; sal_uInt16 nItems = rProperties.size(); size_t nCount = maPropertiesList.size(); for( size_t i=0; i < nCount; i++ ) { SvXMLAutoStylePoolPropertiesP_Impl *pIS = maPropertiesList[ i ]; if( nItems > pIS->GetProperties().size() ) { continue; } else if( nItems < pIS->GetProperties().size() ) { break; } else if( pFamilyData->mxMapper->Equals( pIS->GetProperties(), rProperties ) ) { sName = pIS->GetName(); break; } } return sName; } /////////////////////////////////////////////////////////////////////////////// // // Sort-function for sorted list of SvXMLAutoStylePoolParent_Impl-elements // int SvXMLAutoStylePoolParentPCmp_Impl( const SvXMLAutoStylePoolParentP_Impl& r1, const SvXMLAutoStylePoolParentP_Impl& r2) { return (int)r1.GetParent().compareTo( r2.GetParent() ); } /////////////////////////////////////////////////////////////////////////////// // // Implementation of sorted list of SvXMLAutoStylePoolParent_Impl-elements // IMPL_CONTAINER_SORT( SvXMLAutoStylePoolParentsP_Impl, SvXMLAutoStylePoolParentP_Impl, SvXMLAutoStylePoolParentPCmp_Impl ) }//end of namespace binfilter /* vim:set shiftwidth=4 softtabstop=4 expandtab: */