Branch data Line data Source code
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 <com/sun/star/lang/XMultiServiceFactory.hpp>
21 : : #include <xmloff/xmlimp.hxx>
22 : : #include <xmloff/nmspmap.hxx>
23 : : #include "xmloff/xmlnmspe.hxx"
24 : : #include <xmloff/xmltoken.hxx>
25 : :
26 : : #include <xmloff/families.hxx>
27 : : #include "XMLShapePropertySetContext.hxx"
28 : : #include <xmloff/XMLGraphicsDefaultStyle.hxx>
29 : :
30 : : using ::rtl::OUString;
31 : : using ::rtl::OUStringBuffer;
32 : :
33 : : using namespace ::com::sun::star;
34 : : using namespace ::com::sun::star::uno;
35 : : using namespace ::com::sun::star::lang;
36 : : using namespace ::com::sun::star::beans;
37 : : using namespace ::com::sun::star::xml::sax;
38 : :
39 : : using ::xmloff::token::IsXMLToken;
40 : : using ::xmloff::token::XML_TEXT_PROPERTIES;
41 : : using ::xmloff::token::XML_GRAPHIC_PROPERTIES;
42 : : using ::xmloff::token::XML_PARAGRAPH_PROPERTIES;
43 : :
44 : : // ---------------------------------------------------------------------
45 : :
46 [ - + ][ - + ]: 33 : TYPEINIT1( XMLGraphicsDefaultStyle, XMLPropStyleContext );
47 : :
48 : 83 : XMLGraphicsDefaultStyle::XMLGraphicsDefaultStyle( SvXMLImport& rImport, sal_uInt16 nPrfx, const OUString& rLName, const Reference< XAttributeList >& xAttrList, SvXMLStylesContext& rStyles )
49 : 83 : : XMLPropStyleContext( rImport, nPrfx, rLName, xAttrList, rStyles, XML_STYLE_FAMILY_SD_GRAPHICS_ID, sal_True )
50 : : {
51 : 83 : }
52 : :
53 : 83 : XMLGraphicsDefaultStyle::~XMLGraphicsDefaultStyle()
54 : : {
55 [ - + ]: 166 : }
56 : :
57 : 249 : SvXMLImportContext *XMLGraphicsDefaultStyle::CreateChildContext( sal_uInt16 nPrefix, const OUString& rLocalName, const Reference< XAttributeList > & xAttrList )
58 : : {
59 : 249 : SvXMLImportContext *pContext = 0;
60 : :
61 [ + - ]: 249 : if( XML_NAMESPACE_STYLE == nPrefix )
62 : : {
63 : 249 : sal_uInt32 nFamily = 0;
64 [ + + ]: 249 : if( IsXMLToken( rLocalName, XML_TEXT_PROPERTIES ) )
65 : 83 : nFamily = XML_TYPE_PROP_TEXT;
66 [ + + ]: 166 : else if( IsXMLToken( rLocalName, XML_PARAGRAPH_PROPERTIES ) )
67 : 83 : nFamily = XML_TYPE_PROP_PARAGRAPH;
68 [ + - ]: 83 : else if( IsXMLToken( rLocalName, XML_GRAPHIC_PROPERTIES ) )
69 : 83 : nFamily = XML_TYPE_PROP_GRAPHIC;
70 [ + - ]: 249 : if( nFamily )
71 : : {
72 [ + - ]: 249 : UniReference < SvXMLImportPropertyMapper > xImpPrMap = GetStyles()->GetImportPropertyMapper( GetFamily() );
73 [ + - ]: 249 : if( xImpPrMap.is() )
74 [ + - ][ + - ]: 249 : pContext = new XMLShapePropertySetContext( GetImport(), nPrefix, rLocalName, xAttrList, nFamily, GetProperties(), xImpPrMap );
[ + - ]
75 : : }
76 : : }
77 : :
78 [ - + ]: 249 : if( !pContext )
79 : 0 : pContext = XMLPropStyleContext::CreateChildContext( nPrefix, rLocalName, xAttrList );
80 : :
81 : 249 : return pContext;
82 : : }
83 : :
84 : : // This method is called for every default style
85 : 83 : void XMLGraphicsDefaultStyle::SetDefaults()
86 : : {
87 [ + - ]: 83 : Reference< XMultiServiceFactory > xFact( GetImport().GetModel(), UNO_QUERY );
88 [ - + ]: 83 : if( !xFact.is() )
89 : : return;
90 : :
91 [ + - ][ + - ]: 83 : Reference< XPropertySet > xDefaults( xFact->createInstance( "com.sun.star.drawing.Defaults" ), UNO_QUERY );
[ + - ]
92 [ - + ]: 83 : if( !xDefaults.is() )
93 : : return;
94 : : // SJ: #i114750#
95 : 83 : sal_Bool bWordWrapDefault = sal_True; // initializing with correct odf fo:wrap-option default
96 : 83 : sal_Int32 nUPD( 0 );
97 : 83 : sal_Int32 nBuild( 0 );
98 [ + - ]: 83 : const bool bBuildIdFound = GetImport().getBuildIds( nUPD, nBuild );
99 [ + + ][ + + ]: 83 : if ( bBuildIdFound && (
[ - + ][ + + ]
[ - + ][ + - ]
[ + + ]
100 : : ((nUPD >= 600) && (nUPD < 700))
101 : : ||
102 : : ((nUPD == 300) && (nBuild <= 9535))
103 : : ||
104 : : ((nUPD > 300) && (nUPD <= 330))
105 : : ) )
106 : 18 : bWordWrapDefault = sal_False;
107 : :
108 : 83 : const OUString sTextWordWrap( "TextWordWrap" );
109 [ + - ][ + - ]: 83 : Reference< XPropertySetInfo > xInfo( xDefaults->getPropertySetInfo() );
110 [ + - ][ + - ]: 83 : if ( xInfo->hasPropertyByName( sTextWordWrap ) )
[ + - ]
111 [ + - ][ + - ]: 83 : xDefaults->setPropertyValue( sTextWordWrap, Any( bWordWrapDefault ) );
[ + - ]
112 : :
113 [ + - ][ - + ]: 83 : FillPropertySet( xDefaults );
[ + - ]
114 : : }
115 : :
116 : :
117 : : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|