1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3  * This file is part of the LibreOffice project.
4  *
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/.
8  *
9  * This file incorporates work covered by the following license notice:
10  *
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 .
18  */
19 
20 #include <xmloff/xmlimp.hxx>
21 #include <xmloff/WordWrapPropertyHdl.hxx>
22 #include <xmloff/xmltoken.hxx>
23 #include <xmloff/xmluconv.hxx>
24 #include <comphelper/extract.hxx>
25 #include <rtl/ustring.hxx>
26 #include <com/sun/star/uno/Any.hxx>
27 
28 using namespace ::com::sun::star::uno;
29 
30 
31 // class XMLWordWrapPropertyHdl
32 
33 
XMLWordWrapPropertyHdl(SvXMLImport * pImport)34 XMLWordWrapPropertyHdl::XMLWordWrapPropertyHdl( SvXMLImport* pImport )
35 : mpImport( pImport )
36 {
37 }
38 
~XMLWordWrapPropertyHdl()39 XMLWordWrapPropertyHdl::~XMLWordWrapPropertyHdl()
40 {
41     // Nothing to do
42 }
43 
importXML(const OUString & rStrImpValue,Any & rValue,const SvXMLUnitConverter &) const44 bool XMLWordWrapPropertyHdl::importXML( const OUString& rStrImpValue, Any& rValue, const SvXMLUnitConverter& ) const
45 {
46     bool bRetValue = false;
47     bool bValue = false;
48     if( rStrImpValue == GetXMLToken( xmloff::token::XML_WRAP ) )
49     {
50         bValue = true;
51         bRetValue = true;
52     }
53     if( rStrImpValue == GetXMLToken( xmloff::token::XML_NO_WRAP ) )
54     {
55         bValue = false;
56         bRetValue = true;
57     }
58     if ( bRetValue && mpImport )
59     {
60         sal_Int32 nUPD, nBuildId;
61         if( mpImport->getBuildIds( nUPD, nBuildId ) )
62         {
63             if( nUPD == 300 )
64             {
65                 if( ( nBuildId > 0 ) && (nBuildId < 9316 ) )
66                     bValue = !bValue;     // treat OOo 3.0 beta1 as OOo 2.x
67             }
68             else if( ( nUPD == 680 ) || ( nUPD >= 640 && nUPD <= 645 ) )
69                 bValue = !bValue;
70         }
71         rValue <<= bValue;
72     }
73     return bRetValue;
74 }
75 
exportXML(OUString & rStrExpValue,const Any & rValue,const SvXMLUnitConverter &) const76 bool XMLWordWrapPropertyHdl::exportXML( OUString& rStrExpValue, const Any& rValue, const SvXMLUnitConverter& ) const
77 {
78     if( ::cppu::any2bool( rValue ) )
79     {
80         rStrExpValue = GetXMLToken( xmloff::token::XML_WRAP );
81     }
82     else
83     {
84         rStrExpValue = GetXMLToken( xmloff::token::XML_NO_WRAP );
85     }
86     return true;
87 }
88 
89 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
90