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 <xmloff/xmlimp.hxx>
31 #include <xmloff/WordWrapPropertyHdl.hxx>
32 #include <xmloff/xmltoken.hxx>
33 #include <xmloff/xmluconv.hxx>
34 #include <comphelper/extract.hxx>
35 #include <rtl/ustring.hxx>
36 #include <rtl/ustrbuf.hxx>
37 #include <com/sun/star/uno/Any.hxx>
38 
39 using ::rtl::OUString;
40 using ::rtl::OUStringBuffer;
41 
42 using namespace ::com::sun::star::uno;
43 
44 ///////////////////////////////////////////////////////////////////////////////
45 //
46 // class XMLWordWrapPropertyHdl
47 //
48 
49 XMLWordWrapPropertyHdl::XMLWordWrapPropertyHdl( SvXMLImport* pImport )
50 : mpImport( pImport )
51 {
52 }
53 
54 XMLWordWrapPropertyHdl::~XMLWordWrapPropertyHdl()
55 {
56 	// Nothing to do
57 }
58 
59 sal_Bool XMLWordWrapPropertyHdl::importXML( const OUString& rStrImpValue, Any& rValue, const SvXMLUnitConverter& ) const
60 {
61 	sal_Bool bValue = sal_False, bRetValue = sal_False;
62 	if( rStrImpValue == GetXMLToken( xmloff::token::XML_WRAP ) )
63 	{
64 		bValue = sal_True;
65 		bRetValue = sal_True;
66 	}
67 	if( rStrImpValue == GetXMLToken( xmloff::token::XML_NO_WRAP ) )
68 	{
69 		bValue = sal_False;
70 		bRetValue = sal_True;
71 	}
72 	if ( bRetValue && mpImport )
73 	{
74 		sal_Int32 nUPD, nBuildId;
75 		if( mpImport->getBuildIds( nUPD, nBuildId ) )
76 		{
77 		    if( nUPD == 300 )
78 		    {
79 			    if( ( nBuildId > 0 ) && (nBuildId < 9316 ) )
80 					bValue = bValue ? sal_False : sal_True;		// treat OOo 3.0 beta1 as OOo 2.x
81 		    }
82             else if( ( nUPD == 680 ) || ( nUPD >= 640 && nUPD <= 645 ) )
83 				bValue = bValue ? sal_False : sal_True;
84 		}
85 		rValue <<= bValue;
86 	}
87 	return bRetValue;
88 }
89 
90 sal_Bool XMLWordWrapPropertyHdl::exportXML( OUString& rStrExpValue, const Any& rValue, const SvXMLUnitConverter& ) const
91 {
92 	if( ::cppu::any2bool( rValue ) )
93 	{
94 		rStrExpValue = GetXMLToken( xmloff::token::XML_WRAP );
95 	}
96 	else
97 	{
98 		rStrExpValue = GetXMLToken( xmloff::token::XML_NO_WRAP );
99 	}
100 	return sal_True;
101 }
102 
103