1 /*************************************************************************
2  *
3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4  *
5  * Copyright 2000, 2010 Oracle and/or its affiliates.
6  *
7  * OpenOffice.org - a multi-platform office productivity suite
8  *
9  * This file is part of OpenOffice.org.
10  *
11  * OpenOffice.org is free software: you can redistribute it and/or modify
12  * it under the terms of the GNU Lesser General Public License version 3
13  * only, as published by the Free Software Foundation.
14  *
15  * OpenOffice.org is distributed in the hope that it will be useful,
16  * but WITHOUT ANY WARRANTY; without even the implied warranty of
17  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18  * GNU Lesser General Public License version 3 for more details
19  * (a copy is included in the LICENSE file that accompanied this code).
20  *
21  * You should have received a copy of the GNU Lesser General Public License
22  * version 3 along with OpenOffice.org.  If not, see
23  * <http://www.openoffice.org/license.html>
24  * for a copy of the LGPLv3 License.
25  *
26  ************************************************************************/
27 
28 // MARKER(update_precomp.py): autogen include statement, do not remove
29 #include "precompiled_xmloff.hxx"
30 #include <com/sun/star/container/XNameContainer.hpp>
31 #include <com/sun/star/xml/AttributeData.hpp>
32 #include <com/sun/star/uno/Any.hxx>
33 #include <rtl/ustrbuf.hxx>
34 #include <com/sun/star/text/GraphicCrop.hpp>
35 
36 #include "AttributeContainerHandler.hxx"
37 
38 using ::rtl::OUString;
39 using ::rtl::OUStringBuffer;
40 
41 using namespace ::com::sun::star;
42 using namespace ::com::sun::star::uno;
43 using namespace ::com::sun::star::container;
44 
45 ///////////////////////////////////////////////////////////////////////////////
46 //
47 // class XMLAttributeContainerHandler
48 //
49 
50 XMLAttributeContainerHandler::~XMLAttributeContainerHandler()
51 {
52 	// nothing to do
53 }
54 
55 bool XMLAttributeContainerHandler::equals(
56 		const Any& r1,
57 		const Any& r2 ) const
58 {
59 	Reference< XNameContainer > xContainer1;
60 	Reference< XNameContainer > xContainer2;
61 
62 	if( ( r1 >>= xContainer1 ) && ( r2 >>= xContainer2 ) )
63 	{
64 		uno::Sequence< OUString > aAttribNames1( xContainer1->getElementNames() );
65 		uno::Sequence< OUString > aAttribNames2( xContainer2->getElementNames() );
66 		const sal_Int32 nCount = aAttribNames1.getLength();
67 
68 		if( aAttribNames2.getLength() == nCount )
69 		{
70 			const OUString* pAttribName = aAttribNames1.getConstArray();
71 
72 			xml::AttributeData aData1;
73 			xml::AttributeData aData2;
74 
75 			for( sal_Int32 i=0; i < nCount; i++, pAttribName++ )
76 			{
77 				if( !xContainer2->hasByName( *pAttribName ) )
78 					return sal_False;
79 
80 				xContainer1->getByName( *pAttribName ) >>= aData1;
81 				xContainer2->getByName( *pAttribName ) >>= aData2;
82 
83 				if( ( aData1.Namespace != aData2.Namespace ) ||
84 					( aData1.Type      != aData2.Type      ) ||
85 					( aData1.Value     != aData2.Value     ) )
86 					return sal_False;
87 			}
88 
89 			return sal_True;
90 		}
91 	}
92 
93 	return sal_False;
94 }
95 
96 sal_Bool XMLAttributeContainerHandler::importXML( const OUString& /*rStrImpValue*/, Any& /*rValue*/, const SvXMLUnitConverter& /*rUnitConverter*/ ) const
97 {
98 	return sal_True;
99 }
100 
101 sal_Bool XMLAttributeContainerHandler::exportXML( OUString& /*rStrExpValue*/, const Any& /*rValue*/, const SvXMLUnitConverter& /*rUnitConverter*/ ) const
102 {
103 	return sal_True;
104 }
105