fdo#74697 Add Bluez 5 support for impress remote.
[LibreOffice.git] / xmloff / source / text / XMLTextShapeStyleContext.cxx
blob9296c3f45db455769607d131076b9ed32bd76281
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3 * This file is part of the LibreOffice project.
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/.
9 * This file incorporates work covered by the following license notice:
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 .
20 #include <tools/debug.hxx>
21 #include <com/sun/star/document/XEventsSupplier.hpp>
22 #include "xmloff/xmlnmspe.hxx"
23 #include <xmloff/xmltoken.hxx>
24 #include "XMLTextPropertySetContext.hxx"
25 #include <xmloff/xmlimp.hxx>
26 #include <xmloff/XMLEventsImportContext.hxx>
27 #include "XMLShapePropertySetContext.hxx"
28 #include "XMLTextColumnsContext.hxx"
29 #include "XMLBackgroundImageContext.hxx"
30 #include <xmloff/txtprmap.hxx>
32 #include <xmloff/XMLTextShapeStyleContext.hxx>
35 using namespace ::com::sun::star::document;
36 using namespace ::com::sun::star::uno;
37 using namespace ::com::sun::star::xml::sax;
38 using namespace ::com::sun::star::style;
39 using namespace ::com::sun::star::beans;
40 using namespace ::xmloff::token;
42 class XMLTextShapePropertySetContext_Impl : public XMLShapePropertySetContext
44 public:
45 XMLTextShapePropertySetContext_Impl( SvXMLImport& rImport, sal_uInt16 nPrfx,
46 const OUString& rLName,
47 const Reference< XAttributeList >& xAttrList,
48 sal_uInt32 nFamily,
49 ::std::vector< XMLPropertyState > &rProps,
50 const UniReference < SvXMLImportPropertyMapper > &rMap );
52 virtual ~XMLTextShapePropertySetContext_Impl();
54 using SvXMLPropertySetContext::CreateChildContext;
55 virtual SvXMLImportContext *CreateChildContext( sal_uInt16 nPrefix,
56 const OUString& rLocalName,
57 const Reference< XAttributeList >& xAttrList,
58 ::std::vector< XMLPropertyState > &rProperties,
59 const XMLPropertyState& rProp);
62 XMLTextShapePropertySetContext_Impl::XMLTextShapePropertySetContext_Impl(
63 SvXMLImport& rImport, sal_uInt16 nPrfx,
64 const OUString& rLName,
65 const Reference< XAttributeList > & xAttrList,
66 sal_uInt32 nFamily,
67 ::std::vector< XMLPropertyState > &rProps,
68 const UniReference < SvXMLImportPropertyMapper > &rMap ) :
69 XMLShapePropertySetContext( rImport, nPrfx, rLName, xAttrList, nFamily,
70 rProps, rMap )
74 XMLTextShapePropertySetContext_Impl::~XMLTextShapePropertySetContext_Impl()
78 SvXMLImportContext *XMLTextShapePropertySetContext_Impl::CreateChildContext(
79 sal_uInt16 nPrefix,
80 const OUString& rLocalName,
81 const Reference< XAttributeList > & xAttrList,
82 ::std::vector< XMLPropertyState > &rProperties,
83 const XMLPropertyState& rProp )
85 SvXMLImportContext *pContext = 0;
87 switch( mxMapper->getPropertySetMapper()
88 ->GetEntryContextId( rProp.mnIndex ) )
90 case CTF_TEXTCOLUMNS:
91 pContext = new XMLTextColumnsContext( GetImport(), nPrefix,
92 rLocalName, xAttrList, rProp,
93 rProperties );
94 break;
96 case CTF_BACKGROUND_URL:
97 DBG_ASSERT( rProp.mnIndex >= 3 &&
98 CTF_BACKGROUND_TRANSPARENCY ==
99 mxMapper->getPropertySetMapper()
100 ->GetEntryContextId( rProp.mnIndex-3 ) &&
101 CTF_BACKGROUND_POS == mxMapper->getPropertySetMapper()
102 ->GetEntryContextId( rProp.mnIndex-2 ) &&
103 CTF_BACKGROUND_FILTER == mxMapper->getPropertySetMapper()
104 ->GetEntryContextId( rProp.mnIndex-1 ),
105 "invalid property map!");
106 pContext =
107 new XMLBackgroundImageContext( GetImport(), nPrefix,
108 rLocalName, xAttrList,
109 rProp,
110 rProp.mnIndex-2,
111 rProp.mnIndex-1,
112 rProp.mnIndex-3,
113 rProperties );
114 break;
117 if( !pContext )
118 pContext = XMLShapePropertySetContext::CreateChildContext(
119 nPrefix, rLocalName, xAttrList, rProperties, rProp );
121 return pContext;
124 //-----------------------------------------------------------------------------
126 void XMLTextShapeStyleContext::SetAttribute( sal_uInt16 nPrefixKey,
127 const OUString& rLocalName,
128 const OUString& rValue )
130 if( XML_NAMESPACE_STYLE == nPrefixKey &&
131 IsXMLToken( rLocalName, XML_AUTO_UPDATE ) )
133 if( IsXMLToken( rValue, XML_TRUE ) )
134 bAutoUpdate = sal_True;
136 else
138 XMLShapeStyleContext::SetAttribute( nPrefixKey, rLocalName, rValue );
142 TYPEINIT1( XMLTextShapeStyleContext, XMLShapeStyleContext );
144 XMLTextShapeStyleContext::XMLTextShapeStyleContext( SvXMLImport& rImport,
145 sal_uInt16 nPrfx, const OUString& rLName,
146 const Reference< XAttributeList > & xAttrList,
147 SvXMLStylesContext& rStyles, sal_uInt16 nFamily,
148 sal_Bool /*bDefaultStyle*/ ) :
149 XMLShapeStyleContext( rImport, nPrfx, rLName, xAttrList, rStyles,
150 nFamily ),
151 sIsAutoUpdate( "IsAutoUpdate" ),
152 bAutoUpdate( sal_False )
156 XMLTextShapeStyleContext::~XMLTextShapeStyleContext()
160 SvXMLImportContext *XMLTextShapeStyleContext::CreateChildContext(
161 sal_uInt16 nPrefix,
162 const OUString& rLocalName,
163 const Reference< XAttributeList > & xAttrList )
165 SvXMLImportContext *pContext = 0;
167 if( XML_NAMESPACE_STYLE == nPrefix )
169 sal_uInt32 nFamily = 0;
170 if( IsXMLToken( rLocalName, XML_TEXT_PROPERTIES ) )
171 nFamily = XML_TYPE_PROP_TEXT;
172 else if( IsXMLToken( rLocalName, XML_PARAGRAPH_PROPERTIES ) )
173 nFamily = XML_TYPE_PROP_PARAGRAPH;
174 else if( IsXMLToken( rLocalName, XML_GRAPHIC_PROPERTIES ) )
175 nFamily = XML_TYPE_PROP_GRAPHIC;
176 if( nFamily )
178 UniReference < SvXMLImportPropertyMapper > xImpPrMap =
179 GetStyles()->GetImportPropertyMapper( GetFamily() );
180 if( xImpPrMap.is() )
182 pContext = new XMLTextShapePropertySetContext_Impl(
183 GetImport(), nPrefix, rLocalName, xAttrList, nFamily,
184 GetProperties(), xImpPrMap );
188 else if ( (XML_NAMESPACE_OFFICE == nPrefix) &&
189 IsXMLToken( rLocalName, XML_EVENT_LISTENERS ) )
191 // create and remember events import context
192 // (for delayed processing of events)
193 pContext = new XMLEventsImportContext( GetImport(), nPrefix,
194 rLocalName);
195 xEventContext = pContext;
198 if( !pContext )
199 pContext = XMLShapeStyleContext::CreateChildContext( nPrefix, rLocalName,
200 xAttrList );
202 return pContext;
205 void XMLTextShapeStyleContext::CreateAndInsert( sal_Bool bOverwrite )
207 XMLShapeStyleContext::CreateAndInsert( bOverwrite );
208 Reference < XStyle > xStyle = GetStyle();
209 if( !xStyle.is() || !(bOverwrite || IsNew()) )
210 return;
212 Reference < XPropertySet > xPropSet( xStyle, UNO_QUERY );
213 Reference< XPropertySetInfo > xPropSetInfo =
214 xPropSet->getPropertySetInfo();
215 if( xPropSetInfo->hasPropertyByName( sIsAutoUpdate ) )
217 Any aAny;
218 sal_Bool bTmp = bAutoUpdate;
219 aAny.setValue( &bTmp, ::getBooleanCppuType() );
220 xPropSet->setPropertyValue( sIsAutoUpdate, aAny );
223 // tell the style about it's events (if applicable)
224 if( xEventContext.Is() )
226 // set event suppplier and release reference to context
227 Reference<XEventsSupplier> xEventsSupplier(xStyle, UNO_QUERY);
228 ((XMLEventsImportContext *)&xEventContext)->SetEvents(xEventsSupplier);
229 xEventContext = 0;
234 void XMLTextShapeStyleContext::Finish( sal_Bool bOverwrite )
236 XMLPropStyleContext::Finish( bOverwrite );
239 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */