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 "viewcontext.hxx" 27 #include "sdxmlimp_impl.hxx" 28 #include <xmloff/xmltoken.hxx> 29 #include "xmloff/xmlnmspe.hxx" 30 #include <xmloff/nmspmap.hxx> 31 #include "xmloff/VisAreaContext.hxx" 32 33 using namespace com::sun::star; 34 using namespace rtl; 35 using ::xmloff::token::IsXMLToken; 36 37 using ::xmloff::token::XML_EMBEDDED_VISIBLE_AREA; 38 39 //------------------------------------------------------------------ 40 41 SdXMLViewSettingsContext::SdXMLViewSettingsContext( SdXMLImport& rImport, sal_uInt16 nPrfx, const OUString& rLName, const uno::Reference<xml::sax::XAttributeList>& ) : 42 SvXMLImportContext( rImport, nPrfx, rLName ) 43 { 44 } 45 46 SdXMLViewSettingsContext::~SdXMLViewSettingsContext() 47 { 48 } 49 50 SvXMLImportContext *SdXMLViewSettingsContext::CreateChildContext( sal_uInt16 nPrefix, 51 const OUString& rLocalName, 52 const ::com::sun::star::uno::Reference< 53 ::com::sun::star::xml::sax::XAttributeList>& xAttrList ) 54 { 55 SvXMLImportContext *pContext = 0; 56 57 if (nPrefix == XML_NAMESPACE_OFFICE) 58 { 59 if ( IsXMLToken( rLocalName, XML_EMBEDDED_VISIBLE_AREA ) ) 60 { 61 sal_Int16 nMeasureUnit = 0; 62 63 uno::Reference< beans::XPropertySet > xProps( GetImport().GetModel(), uno::UNO_QUERY ); 64 if( xProps.is() ) 65 xProps->getPropertyValue( OUString( RTL_CONSTASCII_USTRINGPARAM( "MapUnit" ) ) ) >>= nMeasureUnit; 66 67 pContext = new XMLVisAreaContext(GetImport(), nPrefix, rLocalName, xAttrList, maVisArea, nMeasureUnit); 68 } 69 } 70 71 if( !pContext ) 72 pContext = new SvXMLImportContext( GetImport(), nPrefix, rLocalName ); 73 74 return pContext; 75 } 76 77 void SdXMLViewSettingsContext::EndElement() 78 { 79 uno::Reference< beans::XPropertySet > xProps( GetImport().GetModel(), uno::UNO_QUERY ); 80 if( xProps.is() ) 81 { 82 uno::Any aAny; 83 aAny <<= maVisArea; 84 85 xProps->setPropertyValue( OUString( RTL_CONSTASCII_USTRINGPARAM( "VisibleArea" ) ), aAny ); 86 } 87 } 88