1 /**************************************************************
2  *
3  * Licensed to the Apache Software Foundation (ASF) under one
4  * or more contributor license agreements.  See the NOTICE file
5  * distributed with this work for additional information
6  * regarding copyright ownership.  The ASF licenses this file
7  * to you under the Apache License, Version 2.0 (the
8  * "License"); you may not use this file except in compliance
9  * with the License.  You may obtain a copy of the License at
10  *
11  *   http://www.apache.org/licenses/LICENSE-2.0
12  *
13  * Unless required by applicable law or agreed to in writing,
14  * software distributed under the License is distributed on an
15  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16  * KIND, either express or implied.  See the License for the
17  * specific language governing permissions and limitations
18  * under the License.
19  *
20  *************************************************************/
21 
22 
23 
24 // MARKER(update_precomp.py): autogen include statement, do not remove
25 #include "precompiled_xmloff.hxx"
26 #include <com/sun/star/container/XNameContainer.hpp>
27 #include <com/sun/star/xml/AttributeData.hpp>
28 #include <com/sun/star/uno/Any.hxx>
29 #include <rtl/ustrbuf.hxx>
30 #include <com/sun/star/text/GraphicCrop.hpp>
31 
32 #include "AttributeContainerHandler.hxx"
33 
34 using ::rtl::OUString;
35 using ::rtl::OUStringBuffer;
36 
37 using namespace ::com::sun::star;
38 using namespace ::com::sun::star::uno;
39 using namespace ::com::sun::star::container;
40 
41 ///////////////////////////////////////////////////////////////////////////////
42 //
43 // class XMLAttributeContainerHandler
44 //
45 
~XMLAttributeContainerHandler()46 XMLAttributeContainerHandler::~XMLAttributeContainerHandler()
47 {
48 	// nothing to do
49 }
50 
equals(const Any & r1,const Any & r2) const51 bool XMLAttributeContainerHandler::equals(
52 		const Any& r1,
53 		const Any& r2 ) const
54 {
55 	Reference< XNameContainer > xContainer1;
56 	Reference< XNameContainer > xContainer2;
57 
58 	if( ( r1 >>= xContainer1 ) && ( r2 >>= xContainer2 ) )
59 	{
60 		uno::Sequence< OUString > aAttribNames1( xContainer1->getElementNames() );
61 		uno::Sequence< OUString > aAttribNames2( xContainer2->getElementNames() );
62 		const sal_Int32 nCount = aAttribNames1.getLength();
63 
64 		if( aAttribNames2.getLength() == nCount )
65 		{
66 			const OUString* pAttribName = aAttribNames1.getConstArray();
67 
68 			xml::AttributeData aData1;
69 			xml::AttributeData aData2;
70 
71 			for( sal_Int32 i=0; i < nCount; i++, pAttribName++ )
72 			{
73 				if( !xContainer2->hasByName( *pAttribName ) )
74 					return sal_False;
75 
76 				xContainer1->getByName( *pAttribName ) >>= aData1;
77 				xContainer2->getByName( *pAttribName ) >>= aData2;
78 
79 				if( ( aData1.Namespace != aData2.Namespace ) ||
80 					( aData1.Type      != aData2.Type      ) ||
81 					( aData1.Value     != aData2.Value     ) )
82 					return sal_False;
83 			}
84 
85 			return sal_True;
86 		}
87 	}
88 
89 	return sal_False;
90 }
91 
importXML(const OUString &,Any &,const SvXMLUnitConverter &) const92 sal_Bool XMLAttributeContainerHandler::importXML( const OUString& /*rStrImpValue*/, Any& /*rValue*/, const SvXMLUnitConverter& /*rUnitConverter*/ ) const
93 {
94 	return sal_True;
95 }
96 
exportXML(OUString &,const Any &,const SvXMLUnitConverter &) const97 sal_Bool XMLAttributeContainerHandler::exportXML( OUString& /*rStrExpValue*/, const Any& /*rValue*/, const SvXMLUnitConverter& /*rUnitConverter*/ ) const
98 {
99 	return sal_True;
100 }
101