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 :
31 : using namespace ::com::sun::star;
32 : using namespace ::com::sun::star::uno;
33 : using namespace ::com::sun::star::lang;
34 : using namespace ::com::sun::star::beans;
35 : using namespace ::com::sun::star::xml::sax;
36 :
37 : using ::xmloff::token::IsXMLToken;
38 : using ::xmloff::token::XML_TEXT_PROPERTIES;
39 : using ::xmloff::token::XML_GRAPHIC_PROPERTIES;
40 : using ::xmloff::token::XML_PARAGRAPH_PROPERTIES;
41 :
42 : // ---------------------------------------------------------------------
43 :
44 21 : TYPEINIT1( XMLGraphicsDefaultStyle, XMLPropStyleContext );
45 :
46 75 : XMLGraphicsDefaultStyle::XMLGraphicsDefaultStyle( SvXMLImport& rImport, sal_uInt16 nPrfx, const OUString& rLName, const Reference< XAttributeList >& xAttrList, SvXMLStylesContext& rStyles )
47 75 : : XMLPropStyleContext( rImport, nPrfx, rLName, xAttrList, rStyles, XML_STYLE_FAMILY_SD_GRAPHICS_ID, sal_True )
48 : {
49 75 : }
50 :
51 150 : XMLGraphicsDefaultStyle::~XMLGraphicsDefaultStyle()
52 : {
53 150 : }
54 :
55 224 : SvXMLImportContext *XMLGraphicsDefaultStyle::CreateChildContext( sal_uInt16 nPrefix, const OUString& rLocalName, const Reference< XAttributeList > & xAttrList )
56 : {
57 224 : SvXMLImportContext *pContext = 0;
58 :
59 224 : if( XML_NAMESPACE_STYLE == nPrefix )
60 : {
61 224 : sal_uInt32 nFamily = 0;
62 224 : if( IsXMLToken( rLocalName, XML_TEXT_PROPERTIES ) )
63 75 : nFamily = XML_TYPE_PROP_TEXT;
64 149 : else if( IsXMLToken( rLocalName, XML_PARAGRAPH_PROPERTIES ) )
65 75 : nFamily = XML_TYPE_PROP_PARAGRAPH;
66 74 : else if( IsXMLToken( rLocalName, XML_GRAPHIC_PROPERTIES ) )
67 74 : nFamily = XML_TYPE_PROP_GRAPHIC;
68 224 : if( nFamily )
69 : {
70 224 : UniReference < SvXMLImportPropertyMapper > xImpPrMap = GetStyles()->GetImportPropertyMapper( GetFamily() );
71 224 : if( xImpPrMap.is() )
72 224 : pContext = new XMLShapePropertySetContext( GetImport(), nPrefix, rLocalName, xAttrList, nFamily, GetProperties(), xImpPrMap );
73 : }
74 : }
75 :
76 224 : if( !pContext )
77 0 : pContext = XMLPropStyleContext::CreateChildContext( nPrefix, rLocalName, xAttrList );
78 :
79 224 : return pContext;
80 : }
81 :
82 : // This method is called for every default style
83 75 : void XMLGraphicsDefaultStyle::SetDefaults()
84 : {
85 75 : Reference< XMultiServiceFactory > xFact( GetImport().GetModel(), UNO_QUERY );
86 75 : if( !xFact.is() )
87 0 : return;
88 :
89 150 : Reference< XPropertySet > xDefaults( xFact->createInstance( "com.sun.star.drawing.Defaults" ), UNO_QUERY );
90 75 : if( !xDefaults.is() )
91 0 : return;
92 : // SJ: #i114750#
93 75 : sal_Bool bWordWrapDefault = sal_True; // initializing with correct ODF fo:wrap-option default
94 75 : sal_Int32 nUPD( 0 );
95 75 : sal_Int32 nBuild( 0 );
96 75 : const bool bBuildIdFound = GetImport().getBuildIds( nUPD, nBuild );
97 94 : if ( bBuildIdFound && (
98 20 : ((nUPD >= 600) && (nUPD < 700))
99 18 : ||
100 25 : ((nUPD == 300) && (nBuild <= 9535))
101 11 : ||
102 22 : ((nUPD > 300) && (nUPD <= 330))
103 : ) )
104 15 : bWordWrapDefault = sal_False;
105 :
106 150 : const OUString sTextWordWrap( "TextWordWrap" );
107 150 : Reference< XPropertySetInfo > xInfo( xDefaults->getPropertySetInfo() );
108 75 : if ( xInfo->hasPropertyByName( sTextWordWrap ) )
109 75 : xDefaults->setPropertyValue( sTextWordWrap, Any( bWordWrapDefault ) );
110 :
111 290 : if (GetImport().IsOOoXML()
112 235 : && xInfo->hasPropertyByName("IsFollowingTextFlow"))
113 : {
114 : // OOo 1.x only supported "true" so that is the more appropriate
115 : // default for OOoXML format documents.
116 3 : xDefaults->setPropertyValue("IsFollowingTextFlow", uno::makeAny(true));
117 : }
118 :
119 150 : FillPropertySet( xDefaults );
120 : }
121 :
122 :
123 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|