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