Branch data Line data Source code
1 : : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 : : /*************************************************************************
3 : : *
4 : : * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 : : *
6 : : * Copyright 2000, 2010 Oracle and/or its affiliates.
7 : : *
8 : : * OpenOffice.org - a multi-platform office productivity suite
9 : : *
10 : : * This file is part of OpenOffice.org.
11 : : *
12 : : * OpenOffice.org is free software: you can redistribute it and/or modify
13 : : * it under the terms of the GNU Lesser General Public License version 3
14 : : * only, as published by the Free Software Foundation.
15 : : *
16 : : * OpenOffice.org is distributed in the hope that it will be useful,
17 : : * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 : : * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 : : * GNU Lesser General Public License version 3 for more details
20 : : * (a copy is included in the LICENSE file that accompanied this code).
21 : : *
22 : : * You should have received a copy of the GNU Lesser General Public License
23 : : * version 3 along with OpenOffice.org. If not, see
24 : : * <http://www.openoffice.org/license.html>
25 : : * for a copy of the LGPLv3 License.
26 : : *
27 : : ************************************************************************/
28 : :
29 : : #include <com/sun/star/geometry/RealPoint2D.hpp>
30 : : #include <com/sun/star/text/XTextCursor.hpp>
31 : : #include <com/sun/star/util/DateTime.hpp>
32 : : #include <cppuhelper/implbase1.hxx>
33 : : #include <sax/tools/converter.hxx>
34 : : #include "XMLNumberStylesImport.hxx"
35 : : #include <xmloff/xmlstyle.hxx>
36 : : #include <xmloff/xmltoken.hxx>
37 : : #include "xmloff/xmlnmspe.hxx"
38 : : #include "ximppage.hxx"
39 : : #include "ximpshap.hxx"
40 : : #include "animimp.hxx"
41 : : #include "XMLStringBufferImportContext.hxx"
42 : : #include <xmloff/xmlictxt.hxx>
43 : : #include "ximpstyl.hxx"
44 : : #include <xmloff/prstylei.hxx>
45 : : #include "PropertySetMerger.hxx"
46 : :
47 : : #include <xmloff/unointerfacetouniqueidentifiermapper.hxx>
48 : : #include <xmloff/xmluconv.hxx>
49 : :
50 : : using ::rtl::OUString;
51 : : using ::rtl::OUStringBuffer;
52 : :
53 : : using namespace ::com::sun::star;
54 : : using namespace ::xmloff::token;
55 : : using namespace ::com::sun::star::uno;
56 : : using namespace ::com::sun::star::lang;
57 : : using namespace ::com::sun::star::text;
58 : : using namespace ::com::sun::star::util;
59 : : using namespace ::com::sun::star::beans;
60 : : using namespace ::com::sun::star::drawing;
61 : : using namespace ::com::sun::star::container;
62 : : using namespace ::com::sun::star::office;
63 : : using namespace ::com::sun::star::xml::sax;
64 : : using namespace ::com::sun::star::geometry;
65 : :
66 : :
67 : : //////////////////////////////////////////////////////////////////////////////
68 : :
69 [ # # ]: 0 : class DrawAnnotationContext : public SvXMLImportContext
70 : : {
71 : :
72 : : public:
73 : : DrawAnnotationContext( SvXMLImport& rImport, sal_uInt16 nPrfx, const OUString& rLocalName,const Reference< xml::sax::XAttributeList>& xAttrList, const Reference< XAnnotationAccess >& xAnnotationAccess );
74 : :
75 : : virtual SvXMLImportContext * CreateChildContext( sal_uInt16 nPrefix, const ::rtl::OUString& rLocalName, const com::sun::star::uno::Reference< com::sun::star::xml::sax::XAttributeList>& xAttrList );
76 : : virtual void EndElement();
77 : :
78 : : private:
79 : : Reference< XAnnotation > mxAnnotation;
80 : : Reference< XTextCursor > mxCursor;
81 : :
82 : : OUStringBuffer maAuthorBuffer;
83 : : OUStringBuffer maDateBuffer;
84 : : };
85 : :
86 : 0 : DrawAnnotationContext::DrawAnnotationContext( SvXMLImport& rImport, sal_uInt16 nPrfx, const OUString& rLocalName,const Reference< xml::sax::XAttributeList>& xAttrList, const Reference< XAnnotationAccess >& xAnnotationAccess )
87 : : : SvXMLImportContext( rImport, nPrfx, rLocalName )
88 [ # # ][ # # ]: 0 : , mxAnnotation( xAnnotationAccess->createAndInsertAnnotation() )
89 : : {
90 [ # # ]: 0 : if( mxAnnotation.is() )
91 : : {
92 [ # # ][ # # ]: 0 : sal_Int16 nAttrCount = xAttrList.is() ? xAttrList->getLength() : 0;
[ # # ]
93 : :
94 : 0 : RealPoint2D aPosition;
95 : 0 : RealSize2D aSize;
96 : :
97 [ # # ]: 0 : for(sal_Int16 i=0; i < nAttrCount; i++)
98 : : {
99 [ # # ][ # # ]: 0 : OUString sValue( xAttrList->getValueByIndex( i ) );
100 [ # # ][ # # ]: 0 : OUString sAttrName( xAttrList->getNameByIndex( i ) );
101 : 0 : OUString aLocalName;
102 [ # # ][ # # ]: 0 : switch( GetImport().GetNamespaceMap().GetKeyByAttrName( sAttrName, &aLocalName ) )
103 : : {
104 : : case XML_NAMESPACE_SVG:
105 [ # # ][ # # ]: 0 : if( IsXMLToken( aLocalName, XML_X ) )
106 : : {
107 : : sal_Int32 x;
108 : 0 : GetImport().GetMM100UnitConverter().convertMeasureToCore(
109 [ # # ]: 0 : x, sValue);
110 : 0 : aPosition.X = static_cast<double>(x) / 100.0;
111 : : }
112 [ # # ][ # # ]: 0 : else if( IsXMLToken( aLocalName, XML_Y ) )
113 : : {
114 : : sal_Int32 y;
115 : 0 : GetImport().GetMM100UnitConverter().convertMeasureToCore(
116 [ # # ]: 0 : y, sValue);
117 : 0 : aPosition.Y = static_cast<double>(y) / 100.0;
118 : : }
119 [ # # ][ # # ]: 0 : else if( IsXMLToken( aLocalName, XML_WIDTH ) )
120 : : {
121 : : sal_Int32 w;
122 : 0 : GetImport().GetMM100UnitConverter().convertMeasureToCore(
123 [ # # ]: 0 : w, sValue);
124 : 0 : aSize.Width = static_cast<double>(w) / 100.0;
125 : : }
126 [ # # ][ # # ]: 0 : else if( IsXMLToken( aLocalName, XML_HEIGHT ) )
127 : : {
128 : : sal_Int32 h;
129 : 0 : GetImport().GetMM100UnitConverter().convertMeasureToCore(
130 [ # # ]: 0 : h, sValue);
131 : 0 : aSize.Height = static_cast<double>(h) / 100.0;
132 : : }
133 : 0 : break;
134 : : default:
135 : 0 : break;
136 : : }
137 : 0 : }
138 : :
139 [ # # ][ # # ]: 0 : mxAnnotation->setPosition( aPosition );
140 [ # # ][ # # ]: 0 : mxAnnotation->setSize( aSize );
141 : : }
142 : 0 : }
143 : :
144 : 0 : SvXMLImportContext * DrawAnnotationContext::CreateChildContext( sal_uInt16 nPrefix, const OUString& rLocalName, const Reference< XAttributeList >& xAttrList )
145 : : {
146 : 0 : SvXMLImportContext * pContext = NULL;
147 : :
148 [ # # ]: 0 : if( mxAnnotation.is() )
149 : : {
150 [ # # ]: 0 : if( XML_NAMESPACE_DC == nPrefix )
151 : : {
152 [ # # ]: 0 : if( IsXMLToken( rLocalName, XML_CREATOR ) )
153 [ # # ]: 0 : pContext = new XMLStringBufferImportContext(GetImport(), nPrefix, rLocalName, maAuthorBuffer);
154 [ # # ]: 0 : else if( IsXMLToken( rLocalName, XML_DATE ) )
155 [ # # ]: 0 : pContext = new XMLStringBufferImportContext(GetImport(), nPrefix, rLocalName, maDateBuffer);
156 : : }
157 : : else
158 : : {
159 : : // create text cursor on demand
160 [ # # ]: 0 : if( !mxCursor.is() )
161 : : {
162 [ # # ][ # # ]: 0 : uno::Reference< text::XText > xText( mxAnnotation->getTextRange() );
163 [ # # ]: 0 : if( xText.is() )
164 : : {
165 [ # # ]: 0 : UniReference < XMLTextImportHelper > xTxtImport = GetImport().GetTextImport();
166 [ # # ][ # # ]: 0 : mxCursor = xText->createTextCursor();
[ # # ]
167 [ # # ]: 0 : if( mxCursor.is() )
168 [ # # ][ # # ]: 0 : xTxtImport->SetCursor( mxCursor );
[ # # ]
169 : 0 : }
170 : : }
171 : :
172 : : // if we have a text cursor, lets try to import some text
173 [ # # ]: 0 : if( mxCursor.is() )
174 : : {
175 [ # # ][ # # ]: 0 : pContext = GetImport().GetTextImport()->CreateTextChildContext( GetImport(), nPrefix, rLocalName, xAttrList );
176 : : }
177 : : }
178 : : }
179 : :
180 : : // call parent for content
181 [ # # ]: 0 : if(!pContext)
182 : 0 : pContext = SvXMLImportContext::CreateChildContext( nPrefix, rLocalName, xAttrList );
183 : :
184 : 0 : return pContext;
185 : : }
186 : :
187 : 0 : void DrawAnnotationContext::EndElement()
188 : : {
189 [ # # ]: 0 : if(mxCursor.is())
190 : : {
191 : : // delete addition newline
192 : 0 : const OUString aEmpty;
193 [ # # ][ # # ]: 0 : mxCursor->gotoEnd( sal_False );
194 [ # # ][ # # ]: 0 : mxCursor->goLeft( 1, sal_True );
195 [ # # ][ # # ]: 0 : mxCursor->setString( aEmpty );
196 : :
197 : : // reset cursor
198 [ # # ][ # # ]: 0 : GetImport().GetTextImport()->ResetCursor();
[ # # ][ # # ]
199 : : }
200 : :
201 [ # # ]: 0 : if( mxAnnotation.is() )
202 : : {
203 [ # # ][ # # ]: 0 : mxAnnotation->setAuthor( maAuthorBuffer.makeStringAndClear() );
[ # # ]
204 : :
205 : 0 : DateTime aDateTime;
206 [ # # # # ]: 0 : if (::sax::Converter::convertDateTime(aDateTime,
207 [ # # ]: 0 : maDateBuffer.makeStringAndClear()))
208 : : {
209 [ # # ][ # # ]: 0 : mxAnnotation->setDateTime(aDateTime);
210 : : }
211 : : }
212 : 0 : }
213 : :
214 : : //////////////////////////////////////////////////////////////////////////////
215 : :
216 [ # # ][ # # ]: 0 : TYPEINIT1( SdXMLGenericPageContext, SvXMLImportContext );
217 : :
218 : 85 : SdXMLGenericPageContext::SdXMLGenericPageContext(
219 : : SvXMLImport& rImport,
220 : : sal_uInt16 nPrfx, const OUString& rLocalName,
221 : : const Reference< xml::sax::XAttributeList>& xAttrList,
222 : : Reference< drawing::XShapes >& rShapes)
223 : : : SvXMLImportContext( rImport, nPrfx, rLocalName )
224 : : , mxShapes( rShapes )
225 [ + - ]: 85 : , mxAnnotationAccess( rShapes, UNO_QUERY )
226 : : {
227 [ + - ][ + - ]: 85 : sal_Int16 nAttrCount = xAttrList.is() ? xAttrList->getLength() : 0;
[ + - ]
228 : :
229 [ + + ]: 298 : for(sal_Int16 i=0; i < nAttrCount; i++)
230 : : {
231 [ + - ][ + - ]: 213 : OUString sAttrName = xAttrList->getNameByIndex( i );
232 : 213 : OUString aLocalName;
233 [ + - ]: 213 : sal_uInt16 nPrefix = GetSdImport().GetNamespaceMap().GetKeyByAttrName( sAttrName, &aLocalName );
234 [ + + ][ + - ]: 213 : if( (nPrefix == XML_NAMESPACE_DRAW) && IsXMLToken( aLocalName, XML_NAV_ORDER ) )
[ - + ][ - + ]
235 : : {
236 [ # # ][ # # ]: 213 : msNavOrder = xAttrList->getValueByIndex( i );
237 : : break;
238 : : }
239 [ - + ][ + - ]: 213 : }
240 : 85 : }
241 : :
242 : : //////////////////////////////////////////////////////////////////////////////
243 : :
244 : 85 : SdXMLGenericPageContext::~SdXMLGenericPageContext()
245 : : {
246 [ - + ]: 85 : }
247 : :
248 : : //////////////////////////////////////////////////////////////////////////////
249 : :
250 : 85 : void SdXMLGenericPageContext::StartElement( const Reference< ::com::sun::star::xml::sax::XAttributeList >& )
251 : : {
252 [ + - ][ + - ]: 85 : GetImport().GetShapeImport()->pushGroupForSorting( mxShapes );
253 : :
254 [ + - ]: 85 : if( GetImport().IsFormsSupported() )
255 [ + - ][ + - ]: 85 : GetImport().GetFormImport()->startPage( Reference< drawing::XDrawPage >::query( mxShapes ) );
[ + - ][ + - ]
256 : 85 : }
257 : :
258 : : //////////////////////////////////////////////////////////////////////////////
259 : :
260 : 414 : SvXMLImportContext* SdXMLGenericPageContext::CreateChildContext( sal_uInt16 nPrefix,
261 : : const OUString& rLocalName,
262 : : const Reference< xml::sax::XAttributeList>& xAttrList )
263 : : {
264 : 414 : SvXMLImportContext* pContext = 0L;
265 : :
266 [ - + ][ # # ]: 414 : if( nPrefix == XML_NAMESPACE_PRESENTATION && IsXMLToken( rLocalName, XML_ANIMATIONS ) )
[ - + ]
267 : : {
268 [ # # ]: 0 : pContext = new XMLAnimationsContext( GetImport(), nPrefix, rLocalName, xAttrList );
269 : : }
270 [ - + ][ # # ]: 414 : else if( nPrefix == XML_NAMESPACE_OFFICE && IsXMLToken( rLocalName, XML_FORMS ) )
[ - + ]
271 : : {
272 [ # # ]: 0 : if( GetImport().IsFormsSupported() )
273 [ # # ][ # # ]: 0 : pContext = GetImport().GetFormImport()->createOfficeFormsContext( GetImport(), nPrefix, rLocalName );
274 : : }
275 [ + - ][ - + ]: 414 : else if( ((nPrefix == XML_NAMESPACE_OFFICE) || (nPrefix == XML_NAMESPACE_OFFICE_EXT)) && IsXMLToken( rLocalName, XML_ANNOTATION ) )
[ # # ][ - + ]
276 : : {
277 [ # # ]: 0 : if( mxAnnotationAccess.is() )
278 [ # # ]: 0 : pContext = new DrawAnnotationContext( GetImport(), nPrefix, rLocalName, xAttrList, mxAnnotationAccess );
279 : : }
280 : : else
281 : : {
282 : : // call GroupChildContext function at common ShapeImport
283 : 414 : pContext = GetImport().GetShapeImport()->CreateGroupChildContext(
284 [ + - ][ + - ]: 828 : GetImport(), nPrefix, rLocalName, xAttrList, mxShapes);
285 : : }
286 : :
287 : : // call parent when no own context was created
288 [ - + ]: 414 : if(!pContext)
289 : 0 : pContext = SvXMLImportContext::CreateChildContext(nPrefix, rLocalName, xAttrList);
290 : :
291 : 414 : return pContext;
292 : : }
293 : :
294 : : //////////////////////////////////////////////////////////////////////////////
295 : :
296 : 85 : void SdXMLGenericPageContext::EndElement()
297 : : {
298 [ + - ][ + - ]: 85 : GetImport().GetShapeImport()->popGroupAndSort();
299 : :
300 [ + - ]: 85 : if( GetImport().IsFormsSupported() )
301 [ + - ][ + - ]: 85 : GetImport().GetFormImport()->endPage();
302 : :
303 [ + - ][ + - ]: 85 : if( !maUseHeaderDeclName.isEmpty() || !maUseFooterDeclName.isEmpty() || !maUseDateTimeDeclName.isEmpty() )
[ - + ][ - + ]
304 : : {
305 : : try
306 : : {
307 [ # # ]: 0 : Reference <beans::XPropertySet> xSet(mxShapes, uno::UNO_QUERY_THROW );
308 [ # # ][ # # ]: 0 : Reference< beans::XPropertySetInfo > xInfo( xSet->getPropertySetInfo() );
309 : :
310 [ # # ]: 0 : if( !maUseHeaderDeclName.isEmpty() )
311 : : {
312 [ # # ]: 0 : const OUString aStrHeaderTextProp( RTL_CONSTASCII_USTRINGPARAM( "HeaderText" ) );
313 [ # # ][ # # ]: 0 : if( xInfo->hasPropertyByName( aStrHeaderTextProp ) )
[ # # ]
314 [ # # ]: 0 : xSet->setPropertyValue( aStrHeaderTextProp,
315 [ # # ][ # # ]: 0 : makeAny( GetSdImport().GetHeaderDecl( maUseHeaderDeclName ) ) );
[ # # ]
316 : : }
317 : :
318 [ # # ]: 0 : if( !maUseFooterDeclName.isEmpty() )
319 : : {
320 [ # # ]: 0 : const OUString aStrFooterTextProp( RTL_CONSTASCII_USTRINGPARAM( "FooterText" ) );
321 [ # # ][ # # ]: 0 : if( xInfo->hasPropertyByName( aStrFooterTextProp ) )
[ # # ]
322 [ # # ]: 0 : xSet->setPropertyValue( aStrFooterTextProp,
323 [ # # ][ # # ]: 0 : makeAny( GetSdImport().GetFooterDecl( maUseFooterDeclName ) ) );
[ # # ]
324 : : }
325 : :
326 [ # # ]: 0 : if( !maUseDateTimeDeclName.isEmpty() )
327 : : {
328 [ # # ]: 0 : const OUString aStrDateTimeTextProp( RTL_CONSTASCII_USTRINGPARAM( "DateTimeText" ) );
329 [ # # ][ # # ]: 0 : if( xInfo->hasPropertyByName( aStrDateTimeTextProp ) )
[ # # ]
330 : : {
331 : : sal_Bool bFixed;
332 : 0 : OUString aDateTimeFormat;
333 [ # # ]: 0 : const OUString aText( GetSdImport().GetDateTimeDecl( maUseDateTimeDeclName, bFixed, aDateTimeFormat ) );
334 : :
335 [ # # ]: 0 : xSet->setPropertyValue( OUString( RTL_CONSTASCII_USTRINGPARAM("IsDateTimeFixed") ),
336 [ # # ][ # # ]: 0 : makeAny( bFixed ) );
[ # # ]
337 : :
338 [ # # ]: 0 : if( bFixed )
339 : : {
340 [ # # ][ # # ]: 0 : xSet->setPropertyValue( aStrDateTimeTextProp, makeAny( aText ) );
[ # # ]
341 : : }
342 [ # # ]: 0 : else if( !aDateTimeFormat.isEmpty() )
343 : : {
344 [ # # ][ # # ]: 0 : const SdXMLStylesContext* pStyles = dynamic_cast< const SdXMLStylesContext* >( GetSdImport().GetShapeImport()->GetStylesContext() );
[ # # ][ # # ]
345 [ # # ]: 0 : if( !pStyles )
346 [ # # ][ # # ]: 0 : pStyles = dynamic_cast< const SdXMLStylesContext* >( GetSdImport().GetShapeImport()->GetAutoStylesContext() );
[ # # ][ # # ]
347 : :
348 [ # # ]: 0 : if( pStyles )
349 : : {
350 : : const SdXMLNumberFormatImportContext* pSdNumStyle =
351 [ # # ][ # # ]: 0 : dynamic_cast< const SdXMLNumberFormatImportContext* >( pStyles->FindStyleChildContext( XML_STYLE_FAMILY_DATA_STYLE, aDateTimeFormat, sal_True ) );
352 : :
353 [ # # ]: 0 : if( pSdNumStyle )
354 : : {
355 [ # # ]: 0 : xSet->setPropertyValue( OUString( RTL_CONSTASCII_USTRINGPARAM("DateTimeFormat") ),
356 [ # # ][ # # ]: 0 : makeAny( pSdNumStyle->GetDrawKey() ) );
[ # # ]
357 : : }
358 : : }
359 : 0 : }
360 : 0 : }
361 [ # # ]: 0 : }
362 : : }
363 : 0 : catch(const uno::Exception&)
364 : : {
365 : : OSL_FAIL("xmloff::SdXMLGenericPageContext::EndElement(), unexpected exception cought!");
366 : : }
367 : : }
368 : :
369 : 85 : SetNavigationOrder();
370 : 85 : }
371 : :
372 : 85 : void SdXMLGenericPageContext::SetStyle( rtl::OUString& rStyleName )
373 : : {
374 : : // set PageProperties?
375 [ + + ]: 85 : if(!rStyleName.isEmpty())
376 : : {
377 : : try
378 : : {
379 [ + - ][ + - ]: 78 : const SvXMLImportContext* pContext = GetSdImport().GetShapeImport()->GetAutoStylesContext();
[ + - ]
380 : :
381 [ + - ][ + - ]: 78 : if( pContext && pContext->ISA( SvXMLStyleContext ) )
[ + - ][ + - ]
[ + - ]
382 : : {
383 : 78 : const SdXMLStylesContext* pStyles = (SdXMLStylesContext*)pContext;
384 [ + - ]: 78 : if(pStyles)
385 : : {
386 : : const SvXMLStyleContext* pStyle = pStyles->FindStyleChildContext(
387 [ + - ]: 78 : XML_STYLE_FAMILY_SD_DRAWINGPAGE_ID, rStyleName);
388 : :
389 [ + - ][ + - ]: 78 : if(pStyle && pStyle->ISA(XMLPropStyleContext))
[ + - ][ + - ]
[ + - ]
390 : : {
391 : 78 : XMLPropStyleContext* pPropStyle = (XMLPropStyleContext*)pStyle;
392 : :
393 [ + - ]: 78 : Reference <beans::XPropertySet> xPropSet1(mxShapes, uno::UNO_QUERY);
394 [ + - ]: 78 : if(xPropSet1.is())
395 : : {
396 : 78 : Reference< beans::XPropertySet > xPropSet( xPropSet1 );
397 : 78 : Reference< beans::XPropertySet > xBackgroundSet;
398 : :
399 [ + - ]: 78 : const OUString aBackground(RTL_CONSTASCII_USTRINGPARAM("Background"));
400 [ + - ][ + - ]: 78 : if( xPropSet1->getPropertySetInfo()->hasPropertyByName( aBackground ) )
[ + - ][ + - ]
[ + + ]
401 : : {
402 [ + - ][ + - ]: 43 : Reference< beans::XPropertySetInfo > xInfo( xPropSet1->getPropertySetInfo() );
403 [ + - ][ + - ]: 43 : if( xInfo.is() && xInfo->hasPropertyByName( aBackground ) )
[ + - ][ + - ]
[ + - ]
404 : : {
405 [ + - ]: 43 : Reference< lang::XMultiServiceFactory > xServiceFact(GetSdImport().GetModel(), uno::UNO_QUERY);
406 [ + - ]: 43 : if(xServiceFact.is())
407 : : {
408 : : xBackgroundSet = Reference< beans::XPropertySet >::query(
409 [ + - ]: 43 : xServiceFact->createInstance(
410 [ + - ][ + - ]: 43 : OUString(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.drawing.Background"))));
[ + - ][ + - ]
411 : 43 : }
412 : : }
413 : :
414 [ + - ]: 43 : if( xBackgroundSet.is() )
415 [ + - ]: 43 : xPropSet = PropertySetMerger_CreateInstance( xPropSet1, xBackgroundSet );
416 : : }
417 : :
418 [ + - ]: 78 : if(xPropSet.is())
419 : : {
420 [ + - ]: 78 : pPropStyle->FillPropertySet(xPropSet);
421 : :
422 [ + + ]: 78 : if( xBackgroundSet.is() )
423 [ + - ][ + - ]: 43 : xPropSet1->setPropertyValue( aBackground, uno::makeAny( xBackgroundSet ) );
[ + - ]
424 : 78 : }
425 [ # # ]: 78 : }
426 : : }
427 : : }
428 : : }
429 : : }
430 : 0 : catch (const uno::Exception&)
431 : : {
432 : : OSL_FAIL( "SdXMLGenericPageContext::SetStyle(): uno::Exception caught!" );
433 : : }
434 : : }
435 : 85 : }
436 : :
437 : 50 : void SdXMLGenericPageContext::SetLayout()
438 : : {
439 : : // set PresentationPageLayout?
440 [ + + ][ + + ]: 50 : if(GetSdImport().IsImpress() && !maPageLayoutName.isEmpty())
[ + + ]
441 : : {
442 : 35 : sal_Int32 nType = -1;
443 : :
444 [ + - ][ + - ]: 35 : const SvXMLImportContext* pContext = GetSdImport().GetShapeImport()->GetStylesContext();
[ + - ]
445 : :
446 [ + + ][ + - ]: 35 : if( pContext && pContext->ISA( SvXMLStyleContext ) )
[ + - ][ + - ]
[ + + ]
447 : : {
448 : 7 : const SdXMLStylesContext* pStyles = (SdXMLStylesContext*)pContext;
449 [ + - ]: 7 : if(pStyles)
450 : : {
451 [ + - ]: 7 : const SvXMLStyleContext* pStyle = pStyles->FindStyleChildContext( XML_STYLE_FAMILY_SD_PRESENTATIONPAGELAYOUT_ID, maPageLayoutName);
452 : :
453 [ + - ][ + - ]: 7 : if(pStyle && pStyle->ISA(SdXMLPresentationPageLayoutContext))
[ + - ][ + - ]
[ + - ]
454 : : {
455 : 7 : SdXMLPresentationPageLayoutContext* pLayout = (SdXMLPresentationPageLayoutContext*)pStyle;
456 : 7 : nType = pLayout->GetTypeId();
457 : : }
458 : : }
459 : :
460 : : }
461 [ + + ]: 35 : if( -1 == nType )
462 : : {
463 [ + - ]: 28 : Reference< container::XNameAccess > xPageLayouts( GetSdImport().getPageLayouts() );
464 [ + - ]: 28 : if( xPageLayouts.is() )
465 : : {
466 [ + - ][ + - ]: 28 : if( xPageLayouts->hasByName( maPageLayoutName ) )
[ + - ]
467 [ + - ][ + - ]: 28 : xPageLayouts->getByName( maPageLayoutName ) >>= nType;
468 : 28 : }
469 : :
470 : : }
471 : :
472 [ + - ]: 35 : if( -1 != nType )
473 : : {
474 [ + - ]: 35 : Reference <beans::XPropertySet> xPropSet(mxShapes, uno::UNO_QUERY);
475 [ + - ]: 35 : if(xPropSet.is())
476 : : {
477 [ + - ]: 35 : OUString aPropName(RTL_CONSTASCII_USTRINGPARAM("Layout"));
478 [ + - ][ + - ]: 35 : Reference< beans::XPropertySetInfo > xInfo( xPropSet->getPropertySetInfo() );
479 [ + - ][ + - ]: 35 : if( xInfo.is() && xInfo->hasPropertyByName( aPropName ) )
[ + - ][ + - ]
[ + - ]
480 [ + - ][ + - ]: 35 : xPropSet->setPropertyValue(aPropName, uno::makeAny( (sal_Int16)nType ) );
[ + - ]
481 : 35 : }
482 : : }
483 : : }
484 : 50 : }
485 : :
486 : 50 : void SdXMLGenericPageContext::DeleteAllShapes()
487 : : {
488 : : // now delete all up-to-now contained shapes; they have been created
489 : : // when setting the presentation page layout.
490 [ + + ]: 211 : while(mxShapes->getCount())
491 : : {
492 : 161 : Reference< drawing::XShape > xShape;
493 [ + - ][ + - ]: 161 : uno::Any aAny(mxShapes->getByIndex(0L));
494 : :
495 [ + - ]: 161 : aAny >>= xShape;
496 : :
497 [ + - ]: 161 : if(xShape.is())
498 : : {
499 [ + - ][ + - ]: 161 : mxShapes->remove(xShape);
500 : : }
501 : 161 : }
502 : 50 : }
503 : :
504 : 25 : void SdXMLGenericPageContext::SetPageMaster( OUString& rsPageMasterName )
505 : : {
506 [ + - ][ + - ]: 25 : if( GetSdImport().GetShapeImport()->GetStylesContext() )
507 : : {
508 : : // look for PageMaster with this name
509 : :
510 : : // #80012# GetStylesContext() replaced with GetAutoStylesContext()
511 [ + - ]: 25 : const SvXMLStylesContext* pAutoStyles = GetSdImport().GetShapeImport()->GetAutoStylesContext();
512 : :
513 [ + - ]: 25 : const SvXMLStyleContext* pStyle = pAutoStyles ? pAutoStyles->FindStyleChildContext(XML_STYLE_FAMILY_SD_PAGEMASTERCONEXT_ID, rsPageMasterName) : NULL;
514 : :
515 [ + - ][ + - ]: 25 : if(pStyle && pStyle->ISA(SdXMLPageMasterContext))
[ + - ]
516 : : {
517 : 25 : const SdXMLPageMasterContext* pPageMaster = (SdXMLPageMasterContext*)pStyle;
518 : 25 : const SdXMLPageMasterStyleContext* pPageMasterContext = pPageMaster->GetPageMasterStyle();
519 : :
520 [ + - ]: 25 : if(pPageMasterContext)
521 : : {
522 [ + - ]: 25 : Reference< drawing::XDrawPage > xMasterPage(GetLocalShapesContext(), uno::UNO_QUERY);
523 [ + - ]: 25 : if(xMasterPage.is())
524 : : {
525 : : // set sizes for this masterpage
526 [ + - ]: 25 : Reference <beans::XPropertySet> xPropSet(xMasterPage, uno::UNO_QUERY);
527 [ + - ]: 25 : if(xPropSet.is())
528 : : {
529 : 25 : uno::Any aAny;
530 : :
531 [ + - ]: 25 : aAny <<= pPageMasterContext->GetBorderBottom();
532 [ + - ]: 25 : xPropSet->setPropertyValue(
533 [ + - ][ + - ]: 25 : OUString(RTL_CONSTASCII_USTRINGPARAM("BorderBottom")), aAny);
534 : :
535 [ + - ]: 25 : aAny <<= pPageMasterContext->GetBorderLeft();
536 [ + - ]: 25 : xPropSet->setPropertyValue(
537 [ + - ][ + - ]: 25 : OUString(RTL_CONSTASCII_USTRINGPARAM("BorderLeft")), aAny);
538 : :
539 [ + - ]: 25 : aAny <<= pPageMasterContext->GetBorderRight();
540 [ + - ]: 25 : xPropSet->setPropertyValue(
541 [ + - ][ + - ]: 25 : OUString(RTL_CONSTASCII_USTRINGPARAM("BorderRight")), aAny);
542 : :
543 [ + - ]: 25 : aAny <<= pPageMasterContext->GetBorderTop();
544 [ + - ]: 25 : xPropSet->setPropertyValue(
545 [ + - ][ + - ]: 25 : OUString(RTL_CONSTASCII_USTRINGPARAM("BorderTop")), aAny);
546 : :
547 [ + - ]: 25 : aAny <<= pPageMasterContext->GetWidth();
548 [ + - ]: 25 : xPropSet->setPropertyValue(
549 [ + - ][ + - ]: 25 : OUString(RTL_CONSTASCII_USTRINGPARAM("Width")), aAny);
550 : :
551 [ + - ]: 25 : aAny <<= pPageMasterContext->GetHeight();
552 [ + - ]: 25 : xPropSet->setPropertyValue(
553 [ + - ][ + - ]: 25 : OUString(RTL_CONSTASCII_USTRINGPARAM("Height")), aAny);
554 : :
555 [ + - ]: 25 : aAny <<= pPageMasterContext->GetOrientation();
556 [ + - ]: 25 : xPropSet->setPropertyValue(
557 [ + - ][ + - ]: 25 : OUString(RTL_CONSTASCII_USTRINGPARAM("Orientation")), aAny);
558 : 25 : }
559 : 25 : }
560 : : }
561 : : }
562 : :
563 : : }
564 : 25 : }
565 : :
566 [ # # ]: 0 : class NavigationOrderAccess : public ::cppu::WeakImplHelper1< XIndexAccess >
567 : : {
568 : : public:
569 : : NavigationOrderAccess( std::vector< Reference< XShape > >& rShapes );
570 : :
571 : : // XIndexAccess
572 : : virtual sal_Int32 SAL_CALL getCount( ) throw (RuntimeException);
573 : : virtual Any SAL_CALL getByIndex( sal_Int32 Index ) throw (IndexOutOfBoundsException, WrappedTargetException, RuntimeException);
574 : :
575 : : // XElementAccess
576 : : virtual Type SAL_CALL getElementType( ) throw (RuntimeException);
577 : : virtual sal_Bool SAL_CALL hasElements( ) throw (RuntimeException);
578 : :
579 : : private:
580 : : std::vector< Reference< XShape > > maShapes;
581 : : };
582 : :
583 [ # # ]: 0 : NavigationOrderAccess::NavigationOrderAccess( std::vector< Reference< XShape > >& rShapes )
584 : : {
585 : 0 : maShapes.swap( rShapes );
586 : 0 : }
587 : :
588 : : // XIndexAccess
589 : 0 : sal_Int32 SAL_CALL NavigationOrderAccess::getCount( ) throw (RuntimeException)
590 : : {
591 : 0 : return static_cast< sal_Int32 >( maShapes.size() );
592 : : }
593 : :
594 : 0 : Any SAL_CALL NavigationOrderAccess::getByIndex( sal_Int32 Index ) throw (IndexOutOfBoundsException, WrappedTargetException, RuntimeException)
595 : : {
596 [ # # ][ # # ]: 0 : if( (Index < 0) || (Index > getCount()) )
[ # # ]
597 [ # # ]: 0 : throw IndexOutOfBoundsException();
598 : :
599 : 0 : return Any( maShapes[Index] );
600 : : }
601 : :
602 : : // XElementAccess
603 : 0 : Type SAL_CALL NavigationOrderAccess::getElementType( ) throw (RuntimeException)
604 : : {
605 : 0 : return XShape::static_type();
606 : : }
607 : :
608 : 0 : sal_Bool SAL_CALL NavigationOrderAccess::hasElements( ) throw (RuntimeException)
609 : : {
610 [ # # ]: 0 : return maShapes.empty() ? sal_False : sal_True;
611 : : }
612 : :
613 : 85 : void SdXMLGenericPageContext::SetNavigationOrder()
614 : : {
615 [ - + ]: 85 : if( !msNavOrder.isEmpty() ) try
616 : : {
617 : : sal_uInt32 nIndex;
618 [ # # ][ # # ]: 0 : const sal_uInt32 nCount = static_cast< sal_uInt32 >( mxShapes->getCount() );
619 [ # # ]: 0 : std::vector< Reference< XShape > > aShapes( nCount );
620 : :
621 [ # # ]: 0 : ::comphelper::UnoInterfaceToUniqueIdentifierMapper& rIdMapper = GetSdImport().getInterfaceToIdentifierMapper();
622 [ # # ]: 0 : SvXMLTokenEnumerator aEnumerator( msNavOrder );
623 : 0 : OUString sId;
624 [ # # ]: 0 : for( nIndex = 0; nIndex < nCount; ++nIndex )
625 : : {
626 [ # # ][ # # ]: 0 : if( !aEnumerator.getNextToken(sId) )
627 : 0 : break;
628 : :
629 [ # # ][ # # ]: 0 : aShapes[nIndex] = Reference< XShape >( rIdMapper.getReference( sId ), UNO_QUERY );
[ # # ]
630 : : }
631 : :
632 [ # # ]: 0 : for( nIndex = 0; nIndex < nCount; ++nIndex )
633 : : {
634 [ # # ]: 0 : if( !aShapes[nIndex].is() )
635 : : {
636 : : OSL_FAIL("xmloff::SdXMLGenericPageContext::SetNavigationOrder(), draw:nav-order attribute incomplete!");
637 : : // todo: warning?
638 : 85 : return;
639 : : }
640 : : }
641 : :
642 [ # # ]: 0 : Reference< XPropertySet > xSet( mxShapes, UNO_QUERY_THROW );
643 [ # # ][ # # ]: 0 : xSet->setPropertyValue( OUString( RTL_CONSTASCII_USTRINGPARAM( "NavigationOrder" ) ), Any( Reference< XIndexAccess >( new NavigationOrderAccess( aShapes ) ) ) );
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ][ # # ]
644 : : }
645 : 0 : catch(const uno::Exception&)
646 : : {
647 : : OSL_FAIL("xmloff::SdXMLGenericPageContext::SetNavigationOrder(), unexpected exception cought while importing shape navigation order!");
648 : : }
649 : : }
650 : :
651 : : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|