1*63bba73cSAndrew Rist /************************************************************** 2cdf0e10cSrcweir * 3*63bba73cSAndrew Rist * Licensed to the Apache Software Foundation (ASF) under one 4*63bba73cSAndrew Rist * or more contributor license agreements. See the NOTICE file 5*63bba73cSAndrew Rist * distributed with this work for additional information 6*63bba73cSAndrew Rist * regarding copyright ownership. The ASF licenses this file 7*63bba73cSAndrew Rist * to you under the Apache License, Version 2.0 (the 8*63bba73cSAndrew Rist * "License"); you may not use this file except in compliance 9*63bba73cSAndrew Rist * with the License. You may obtain a copy of the License at 10cdf0e10cSrcweir * 11*63bba73cSAndrew Rist * http://www.apache.org/licenses/LICENSE-2.0 12cdf0e10cSrcweir * 13*63bba73cSAndrew Rist * Unless required by applicable law or agreed to in writing, 14*63bba73cSAndrew Rist * software distributed under the License is distributed on an 15*63bba73cSAndrew Rist * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 16*63bba73cSAndrew Rist * KIND, either express or implied. See the License for the 17*63bba73cSAndrew Rist * specific language governing permissions and limitations 18*63bba73cSAndrew Rist * under the License. 19cdf0e10cSrcweir * 20*63bba73cSAndrew Rist *************************************************************/ 21*63bba73cSAndrew Rist 22*63bba73cSAndrew Rist 23cdf0e10cSrcweir 24cdf0e10cSrcweir // MARKER(update_precomp.py): autogen include statement, do not remove 25cdf0e10cSrcweir #include "precompiled_xmloff.hxx" 26cdf0e10cSrcweir 27cdf0e10cSrcweir 28cdf0e10cSrcweir #include <com/sun/star/util/XStringSubstitution.hpp> 29cdf0e10cSrcweir #include <xmloff/DocumentSettingsContext.hxx> 30cdf0e10cSrcweir #include <xmloff/xmlimp.hxx> 31cdf0e10cSrcweir #include <xmloff/xmltoken.hxx> 32cdf0e10cSrcweir #include "xmloff/xmlnmspe.hxx" 33cdf0e10cSrcweir #include <xmloff/nmspmap.hxx> 34cdf0e10cSrcweir #include <xmloff/xmluconv.hxx> 35cdf0e10cSrcweir #include <tools/debug.hxx> 36cdf0e10cSrcweir 37cdf0e10cSrcweir #ifndef __SGI_STL_LIST 38cdf0e10cSrcweir #include <list> 39cdf0e10cSrcweir #endif 40cdf0e10cSrcweir #include <com/sun/star/i18n/XForbiddenCharacters.hpp> 41cdf0e10cSrcweir #include <com/sun/star/container/XIndexContainer.hpp> 42cdf0e10cSrcweir #include <com/sun/star/lang/XMultiServiceFactory.hpp> 43cdf0e10cSrcweir #include <com/sun/star/formula/SymbolDescriptor.hpp> 44cdf0e10cSrcweir #include <comphelper/processfactory.hxx> 45cdf0e10cSrcweir #include <com/sun/star/util/DateTime.hpp> 46cdf0e10cSrcweir #include <com/sun/star/document/XViewDataSupplier.hpp> 47cdf0e10cSrcweir #include <com/sun/star/document/PrinterIndependentLayout.hpp> 48cdf0e10cSrcweir #include <comphelper/configurationhelper.hxx> 49cdf0e10cSrcweir #include <rtl/ustrbuf.hxx> 50cdf0e10cSrcweir #include <xmlenums.hxx> 51cdf0e10cSrcweir 52cdf0e10cSrcweir using namespace com::sun::star; 53cdf0e10cSrcweir using namespace ::xmloff::token; 54cdf0e10cSrcweir 55cdf0e10cSrcweir #define C2U(cChar) ::rtl::OUString::createFromAscii(cChar) 56cdf0e10cSrcweir 57cdf0e10cSrcweir //------------------------------------------------------------------ 58cdf0e10cSrcweir 59cdf0e10cSrcweir class XMLMyList 60cdf0e10cSrcweir { 61cdf0e10cSrcweir std::list<beans::PropertyValue> aProps; 62cdf0e10cSrcweir sal_uInt32 nCount; 63cdf0e10cSrcweir 64cdf0e10cSrcweir // #110680# 65cdf0e10cSrcweir ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory > mxServiceFactory; 66cdf0e10cSrcweir 67cdf0e10cSrcweir public: 68cdf0e10cSrcweir // #110680# 69cdf0e10cSrcweir XMLMyList(const uno::Reference<lang::XMultiServiceFactory>& xServiceFactory); 70cdf0e10cSrcweir ~XMLMyList(); 71cdf0e10cSrcweir 72cdf0e10cSrcweir void push_back(beans::PropertyValue& aProp) { aProps.push_back(aProp); nCount++; } 73cdf0e10cSrcweir uno::Sequence<beans::PropertyValue> GetSequence(); 74cdf0e10cSrcweir uno::Reference<container::XNameContainer> GetNameContainer(); 75cdf0e10cSrcweir uno::Reference<container::XIndexContainer> GetIndexContainer(); 76cdf0e10cSrcweir }; 77cdf0e10cSrcweir 78cdf0e10cSrcweir // #110680# 79cdf0e10cSrcweir XMLMyList::XMLMyList(const uno::Reference<lang::XMultiServiceFactory>& xServiceFactory) 80cdf0e10cSrcweir : nCount(0), 81cdf0e10cSrcweir mxServiceFactory(xServiceFactory) 82cdf0e10cSrcweir { 83cdf0e10cSrcweir DBG_ASSERT( mxServiceFactory.is(), "got no service manager" ); 84cdf0e10cSrcweir } 85cdf0e10cSrcweir 86cdf0e10cSrcweir // #110680# 87cdf0e10cSrcweir XMLMyList::~XMLMyList() 88cdf0e10cSrcweir { 89cdf0e10cSrcweir } 90cdf0e10cSrcweir 91cdf0e10cSrcweir uno::Sequence<beans::PropertyValue> XMLMyList::GetSequence() 92cdf0e10cSrcweir { 93cdf0e10cSrcweir uno::Sequence<beans::PropertyValue> aSeq; 94cdf0e10cSrcweir if(nCount) 95cdf0e10cSrcweir { 96cdf0e10cSrcweir DBG_ASSERT(nCount == aProps.size(), "wrong count of PropertyValue"); 97cdf0e10cSrcweir aSeq.realloc(nCount); 98cdf0e10cSrcweir beans::PropertyValue* pProps = aSeq.getArray(); 99cdf0e10cSrcweir std::list<beans::PropertyValue>::iterator aItr = aProps.begin(); 100cdf0e10cSrcweir while (aItr != aProps.end()) 101cdf0e10cSrcweir { 102cdf0e10cSrcweir *pProps = *aItr; 103cdf0e10cSrcweir pProps++; 104cdf0e10cSrcweir aItr++; 105cdf0e10cSrcweir } 106cdf0e10cSrcweir } 107cdf0e10cSrcweir return aSeq; 108cdf0e10cSrcweir } 109cdf0e10cSrcweir 110cdf0e10cSrcweir uno::Reference<container::XNameContainer> XMLMyList::GetNameContainer() 111cdf0e10cSrcweir { 112cdf0e10cSrcweir uno::Reference<container::XNameContainer> xNameContainer; 113cdf0e10cSrcweir 114cdf0e10cSrcweir // #110680# 115cdf0e10cSrcweir // uno::Reference<lang::XMultiServiceFactory> xServiceFactory = comphelper::getProcessServiceFactory(); 116cdf0e10cSrcweir // DBG_ASSERT( xServiceFactory.is(), "got no service manager" ); 117cdf0e10cSrcweir 118cdf0e10cSrcweir if( mxServiceFactory.is() ) 119cdf0e10cSrcweir { 120cdf0e10cSrcweir rtl::OUString sName(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.document.NamedPropertyValues")); 121cdf0e10cSrcweir xNameContainer = uno::Reference<container::XNameContainer>(mxServiceFactory->createInstance(sName), uno::UNO_QUERY); 122cdf0e10cSrcweir if (xNameContainer.is()) 123cdf0e10cSrcweir { 124cdf0e10cSrcweir std::list<beans::PropertyValue>::iterator aItr = aProps.begin(); 125cdf0e10cSrcweir while (aItr != aProps.end()) 126cdf0e10cSrcweir { 127cdf0e10cSrcweir xNameContainer->insertByName(aItr->Name, aItr->Value); 128cdf0e10cSrcweir aItr++; 129cdf0e10cSrcweir } 130cdf0e10cSrcweir } 131cdf0e10cSrcweir } 132cdf0e10cSrcweir return xNameContainer; 133cdf0e10cSrcweir } 134cdf0e10cSrcweir 135cdf0e10cSrcweir uno::Reference<container::XIndexContainer> XMLMyList::GetIndexContainer() 136cdf0e10cSrcweir { 137cdf0e10cSrcweir uno::Reference<container::XIndexContainer> xIndexContainer; 138cdf0e10cSrcweir // #110680# 139cdf0e10cSrcweir // uno::Reference<lang::XMultiServiceFactory> xServiceFactory = comphelper::getProcessServiceFactory(); 140cdf0e10cSrcweir // DBG_ASSERT( xServiceFactory.is(), "got no service manager" ); 141cdf0e10cSrcweir 142cdf0e10cSrcweir if( mxServiceFactory.is() ) 143cdf0e10cSrcweir { 144cdf0e10cSrcweir rtl::OUString sName(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.document.IndexedPropertyValues")); 145cdf0e10cSrcweir xIndexContainer = uno::Reference<container::XIndexContainer>(mxServiceFactory->createInstance(sName), uno::UNO_QUERY); 146cdf0e10cSrcweir if (xIndexContainer.is()) 147cdf0e10cSrcweir { 148cdf0e10cSrcweir std::list<beans::PropertyValue>::iterator aItr = aProps.begin(); 149cdf0e10cSrcweir sal_uInt32 i(0); 150cdf0e10cSrcweir while (aItr != aProps.end()) 151cdf0e10cSrcweir { 152cdf0e10cSrcweir xIndexContainer->insertByIndex(i, aItr->Value); 153cdf0e10cSrcweir aItr++; 154cdf0e10cSrcweir i++; 155cdf0e10cSrcweir } 156cdf0e10cSrcweir } 157cdf0e10cSrcweir } 158cdf0e10cSrcweir return xIndexContainer; 159cdf0e10cSrcweir } 160cdf0e10cSrcweir 161cdf0e10cSrcweir //============================================================================= 162cdf0e10cSrcweir 163cdf0e10cSrcweir class XMLConfigBaseContext : public SvXMLImportContext 164cdf0e10cSrcweir { 165cdf0e10cSrcweir protected: 166cdf0e10cSrcweir XMLMyList maProps; 167cdf0e10cSrcweir beans::PropertyValue maProp; 168cdf0e10cSrcweir com::sun::star::uno::Any& mrAny; 169cdf0e10cSrcweir XMLConfigBaseContext* mpBaseContext; 170cdf0e10cSrcweir public: 171cdf0e10cSrcweir XMLConfigBaseContext(SvXMLImport& rImport, sal_uInt16 nPrfx, const rtl::OUString& rLName, 172cdf0e10cSrcweir com::sun::star::uno::Any& rAny, 173cdf0e10cSrcweir XMLConfigBaseContext* pBaseContext); 174cdf0e10cSrcweir virtual ~XMLConfigBaseContext(); 175cdf0e10cSrcweir 176cdf0e10cSrcweir void AddPropertyValue() { maProps.push_back(maProp); } 177cdf0e10cSrcweir }; 178cdf0e10cSrcweir 179cdf0e10cSrcweir //============================================================================= 180cdf0e10cSrcweir 181cdf0e10cSrcweir class XMLConfigItemContext : public SvXMLImportContext 182cdf0e10cSrcweir { 183cdf0e10cSrcweir rtl::OUString msType; 184cdf0e10cSrcweir rtl::OUString msValue; 185cdf0e10cSrcweir uno::Sequence<sal_Int8> maDecoded; 186cdf0e10cSrcweir com::sun::star::uno::Any& mrAny; 187cdf0e10cSrcweir const rtl::OUString mrItemName; 188cdf0e10cSrcweir XMLConfigBaseContext* mpBaseContext; 189cdf0e10cSrcweir 190cdf0e10cSrcweir public: 191cdf0e10cSrcweir XMLConfigItemContext(SvXMLImport& rImport, sal_uInt16 nPrfx, const rtl::OUString& rLName, 192cdf0e10cSrcweir const ::com::sun::star::uno::Reference< 193cdf0e10cSrcweir ::com::sun::star::xml::sax::XAttributeList>& xAttrList, 194cdf0e10cSrcweir com::sun::star::uno::Any& rAny, 195cdf0e10cSrcweir const rtl::OUString& rItemName, 196cdf0e10cSrcweir XMLConfigBaseContext* pBaseContext); 197cdf0e10cSrcweir virtual ~XMLConfigItemContext(); 198cdf0e10cSrcweir 199cdf0e10cSrcweir virtual SvXMLImportContext *CreateChildContext( sal_uInt16 nPrefix, 200cdf0e10cSrcweir const rtl::OUString& rLocalName, 201cdf0e10cSrcweir const ::com::sun::star::uno::Reference< 202cdf0e10cSrcweir ::com::sun::star::xml::sax::XAttributeList>& xAttrList ); 203cdf0e10cSrcweir virtual void Characters( const ::rtl::OUString& rChars ); 204cdf0e10cSrcweir 205cdf0e10cSrcweir virtual void EndElement(); 206cdf0e10cSrcweir 207cdf0e10cSrcweir virtual void ManipulateConfigItem(); 208cdf0e10cSrcweir }; 209cdf0e10cSrcweir 210cdf0e10cSrcweir //============================================================================= 211cdf0e10cSrcweir 212cdf0e10cSrcweir class XMLConfigItemSetContext : public XMLConfigBaseContext 213cdf0e10cSrcweir { 214cdf0e10cSrcweir public: 215cdf0e10cSrcweir XMLConfigItemSetContext(SvXMLImport& rImport, sal_uInt16 nPrfx, const rtl::OUString& rLName, 216cdf0e10cSrcweir const ::com::sun::star::uno::Reference< 217cdf0e10cSrcweir ::com::sun::star::xml::sax::XAttributeList>& xAttrList, 218cdf0e10cSrcweir com::sun::star::uno::Any& rAny, 219cdf0e10cSrcweir XMLConfigBaseContext* pBaseContext); 220cdf0e10cSrcweir virtual ~XMLConfigItemSetContext(); 221cdf0e10cSrcweir 222cdf0e10cSrcweir virtual SvXMLImportContext *CreateChildContext( sal_uInt16 nPrefix, 223cdf0e10cSrcweir const rtl::OUString& rLocalName, 224cdf0e10cSrcweir const ::com::sun::star::uno::Reference< 225cdf0e10cSrcweir ::com::sun::star::xml::sax::XAttributeList>& xAttrList ); 226cdf0e10cSrcweir 227cdf0e10cSrcweir virtual void EndElement(); 228cdf0e10cSrcweir }; 229cdf0e10cSrcweir 230cdf0e10cSrcweir //============================================================================= 231cdf0e10cSrcweir 232cdf0e10cSrcweir class XMLConfigItemMapNamedContext : public XMLConfigBaseContext 233cdf0e10cSrcweir { 234cdf0e10cSrcweir public: 235cdf0e10cSrcweir XMLConfigItemMapNamedContext(SvXMLImport& rImport, sal_uInt16 nPrfx, const rtl::OUString& rLName, 236cdf0e10cSrcweir const ::com::sun::star::uno::Reference< 237cdf0e10cSrcweir ::com::sun::star::xml::sax::XAttributeList>& xAttrList, 238cdf0e10cSrcweir com::sun::star::uno::Any& rAny, 239cdf0e10cSrcweir XMLConfigBaseContext* pBaseContext); 240cdf0e10cSrcweir virtual ~XMLConfigItemMapNamedContext(); 241cdf0e10cSrcweir 242cdf0e10cSrcweir virtual SvXMLImportContext *CreateChildContext( sal_uInt16 nPrefix, 243cdf0e10cSrcweir const rtl::OUString& rLocalName, 244cdf0e10cSrcweir const ::com::sun::star::uno::Reference< 245cdf0e10cSrcweir ::com::sun::star::xml::sax::XAttributeList>& xAttrList ); 246cdf0e10cSrcweir 247cdf0e10cSrcweir virtual void EndElement(); 248cdf0e10cSrcweir }; 249cdf0e10cSrcweir 250cdf0e10cSrcweir //============================================================================= 251cdf0e10cSrcweir 252cdf0e10cSrcweir class XMLConfigItemMapIndexedContext : public XMLConfigBaseContext 253cdf0e10cSrcweir { 254cdf0e10cSrcweir private: 255cdf0e10cSrcweir rtl::OUString maConfigItemName; 256cdf0e10cSrcweir 257cdf0e10cSrcweir public: 258cdf0e10cSrcweir XMLConfigItemMapIndexedContext(SvXMLImport& rImport, sal_uInt16 nPrfx, 259cdf0e10cSrcweir const rtl::OUString& rLName, 260cdf0e10cSrcweir const ::com::sun::star::uno::Reference< 261cdf0e10cSrcweir ::com::sun::star::xml::sax::XAttributeList>& xAttrList, 262cdf0e10cSrcweir com::sun::star::uno::Any& rAny, 263cdf0e10cSrcweir const rtl::OUString& rConfigItemName, 264cdf0e10cSrcweir XMLConfigBaseContext* pBaseContext); 265cdf0e10cSrcweir virtual ~XMLConfigItemMapIndexedContext(); 266cdf0e10cSrcweir 267cdf0e10cSrcweir virtual SvXMLImportContext *CreateChildContext( sal_uInt16 nPrefix, 268cdf0e10cSrcweir const rtl::OUString& rLocalName, 269cdf0e10cSrcweir const ::com::sun::star::uno::Reference< 270cdf0e10cSrcweir ::com::sun::star::xml::sax::XAttributeList>& xAttrList ); 271cdf0e10cSrcweir 272cdf0e10cSrcweir virtual void EndElement(); 273cdf0e10cSrcweir }; 274cdf0e10cSrcweir 275cdf0e10cSrcweir //============================================================================= 276cdf0e10cSrcweir 277cdf0e10cSrcweir SvXMLImportContext *CreateSettingsContext(SvXMLImport& rImport, sal_uInt16 p_nPrefix, 278cdf0e10cSrcweir const rtl::OUString& rLocalName, 279cdf0e10cSrcweir const uno::Reference<xml::sax::XAttributeList>& xAttrList, 280cdf0e10cSrcweir beans::PropertyValue& rProp, XMLConfigBaseContext* pBaseContext) 281cdf0e10cSrcweir { 282cdf0e10cSrcweir SvXMLImportContext *pContext = 0; 283cdf0e10cSrcweir 284cdf0e10cSrcweir rProp.Name = rtl::OUString(); 285cdf0e10cSrcweir sal_Int16 nAttrCount = xAttrList.is() ? xAttrList->getLength() : 0; 286cdf0e10cSrcweir for( sal_Int16 i=0; i < nAttrCount; i++ ) 287cdf0e10cSrcweir { 288cdf0e10cSrcweir rtl::OUString sAttrName = xAttrList->getNameByIndex( i ); 289cdf0e10cSrcweir rtl::OUString aLocalName; 290cdf0e10cSrcweir sal_uInt16 nPrefix = rImport.GetNamespaceMap().GetKeyByAttrName( 291cdf0e10cSrcweir sAttrName, &aLocalName ); 292cdf0e10cSrcweir rtl::OUString sValue = xAttrList->getValueByIndex( i ); 293cdf0e10cSrcweir 294cdf0e10cSrcweir if (nPrefix == XML_NAMESPACE_CONFIG) 295cdf0e10cSrcweir { 296cdf0e10cSrcweir if (IsXMLToken(aLocalName, XML_NAME)) 297cdf0e10cSrcweir rProp.Name = sValue; 298cdf0e10cSrcweir } 299cdf0e10cSrcweir } 300cdf0e10cSrcweir 301cdf0e10cSrcweir if (p_nPrefix == XML_NAMESPACE_CONFIG) 302cdf0e10cSrcweir { 303cdf0e10cSrcweir if (IsXMLToken(rLocalName, XML_CONFIG_ITEM)) 304cdf0e10cSrcweir pContext = new XMLConfigItemContext(rImport, p_nPrefix, rLocalName, xAttrList, rProp.Value, rProp.Name, pBaseContext); 305cdf0e10cSrcweir else if((IsXMLToken(rLocalName, XML_CONFIG_ITEM_SET)) || 306cdf0e10cSrcweir (IsXMLToken(rLocalName, XML_CONFIG_ITEM_MAP_ENTRY)) ) 307cdf0e10cSrcweir pContext = new XMLConfigItemSetContext(rImport, p_nPrefix, rLocalName, xAttrList, rProp.Value, pBaseContext); 308cdf0e10cSrcweir else if(IsXMLToken(rLocalName, XML_CONFIG_ITEM_MAP_NAMED)) 309cdf0e10cSrcweir pContext = new XMLConfigItemMapNamedContext(rImport, p_nPrefix, rLocalName, xAttrList, rProp.Value, pBaseContext); 310cdf0e10cSrcweir else if(IsXMLToken(rLocalName, XML_CONFIG_ITEM_MAP_INDEXED)) 311cdf0e10cSrcweir pContext = new XMLConfigItemMapIndexedContext(rImport, p_nPrefix, rLocalName, xAttrList, rProp.Value, rProp.Name, pBaseContext); 312cdf0e10cSrcweir } 313cdf0e10cSrcweir 314cdf0e10cSrcweir if( !pContext ) 315cdf0e10cSrcweir pContext = new SvXMLImportContext( rImport, p_nPrefix, rLocalName ); 316cdf0e10cSrcweir 317cdf0e10cSrcweir return pContext; 318cdf0e10cSrcweir } 319cdf0e10cSrcweir 320cdf0e10cSrcweir //============================================================================= 321cdf0e10cSrcweir namespace 322cdf0e10cSrcweir { 323cdf0e10cSrcweir struct SettingsGroup 324cdf0e10cSrcweir { 325cdf0e10cSrcweir ::rtl::OUString sGroupName; 326cdf0e10cSrcweir uno::Any aSettings; 327cdf0e10cSrcweir 328cdf0e10cSrcweir SettingsGroup() 329cdf0e10cSrcweir :sGroupName() 330cdf0e10cSrcweir ,aSettings() 331cdf0e10cSrcweir { 332cdf0e10cSrcweir } 333cdf0e10cSrcweir 334cdf0e10cSrcweir SettingsGroup( const ::rtl::OUString& _rGroupName, const uno::Any& _rSettings ) 335cdf0e10cSrcweir :sGroupName( _rGroupName ) 336cdf0e10cSrcweir ,aSettings( _rSettings ) 337cdf0e10cSrcweir { 338cdf0e10cSrcweir } 339cdf0e10cSrcweir }; 340cdf0e10cSrcweir } 341cdf0e10cSrcweir 342cdf0e10cSrcweir struct XMLDocumentSettingsContext_Data 343cdf0e10cSrcweir { 344cdf0e10cSrcweir com::sun::star::uno::Any aViewProps; 345cdf0e10cSrcweir com::sun::star::uno::Any aConfigProps; 346cdf0e10cSrcweir ::std::list< SettingsGroup > aDocSpecificSettings; 347cdf0e10cSrcweir }; 348cdf0e10cSrcweir 349cdf0e10cSrcweir //============================================================================= 350cdf0e10cSrcweir 351cdf0e10cSrcweir XMLDocumentSettingsContext::XMLDocumentSettingsContext(SvXMLImport& rImport, sal_uInt16 nPrfx, const rtl::OUString& rLName, 352cdf0e10cSrcweir const uno::Reference<xml::sax::XAttributeList>& ) 353cdf0e10cSrcweir : SvXMLImportContext( rImport, nPrfx, rLName ) 354cdf0e10cSrcweir , m_pData( new XMLDocumentSettingsContext_Data ) 355cdf0e10cSrcweir { 356cdf0e10cSrcweir // here are no attributes 357cdf0e10cSrcweir } 358cdf0e10cSrcweir 359cdf0e10cSrcweir XMLDocumentSettingsContext::~XMLDocumentSettingsContext() 360cdf0e10cSrcweir { 361cdf0e10cSrcweir } 362cdf0e10cSrcweir 363cdf0e10cSrcweir SvXMLImportContext *XMLDocumentSettingsContext::CreateChildContext( sal_uInt16 p_nPrefix, 364cdf0e10cSrcweir const rtl::OUString& rLocalName, 365cdf0e10cSrcweir const ::com::sun::star::uno::Reference< 366cdf0e10cSrcweir ::com::sun::star::xml::sax::XAttributeList>& xAttrList ) 367cdf0e10cSrcweir { 368cdf0e10cSrcweir SvXMLImportContext *pContext = 0; 369cdf0e10cSrcweir rtl::OUString sName; 370cdf0e10cSrcweir 371cdf0e10cSrcweir sal_Int16 nAttrCount = xAttrList.is() ? xAttrList->getLength() : 0; 372cdf0e10cSrcweir for( sal_Int16 i=0; i < nAttrCount; i++ ) 373cdf0e10cSrcweir { 374cdf0e10cSrcweir rtl::OUString sAttrName = xAttrList->getNameByIndex( i ); 375cdf0e10cSrcweir rtl::OUString aLocalName; 376cdf0e10cSrcweir sal_uInt16 nPrefix = GetImport().GetNamespaceMap().GetKeyByAttrName( 377cdf0e10cSrcweir sAttrName, &aLocalName ); 378cdf0e10cSrcweir rtl::OUString sValue = xAttrList->getValueByIndex( i ); 379cdf0e10cSrcweir 380cdf0e10cSrcweir if (nPrefix == XML_NAMESPACE_CONFIG) 381cdf0e10cSrcweir { 382cdf0e10cSrcweir if (IsXMLToken(aLocalName, XML_NAME)) 383cdf0e10cSrcweir sName = sValue; 384cdf0e10cSrcweir } 385cdf0e10cSrcweir } 386cdf0e10cSrcweir 387cdf0e10cSrcweir if (p_nPrefix == XML_NAMESPACE_CONFIG) 388cdf0e10cSrcweir { 389cdf0e10cSrcweir if (IsXMLToken(rLocalName, XML_CONFIG_ITEM_SET)) 390cdf0e10cSrcweir { 391cdf0e10cSrcweir ::rtl::OUString aLocalConfigName; 392cdf0e10cSrcweir sal_uInt16 nConfigPrefix = 393cdf0e10cSrcweir GetImport().GetNamespaceMap().GetKeyByAttrName( 394cdf0e10cSrcweir sName, &aLocalConfigName ); 395cdf0e10cSrcweir 396cdf0e10cSrcweir if( XML_NAMESPACE_OOO == nConfigPrefix ) 397cdf0e10cSrcweir { 398cdf0e10cSrcweir if (IsXMLToken(aLocalConfigName, XML_VIEW_SETTINGS)) 399cdf0e10cSrcweir pContext = new XMLConfigItemSetContext(GetImport(), 400cdf0e10cSrcweir p_nPrefix, rLocalName, xAttrList, 401cdf0e10cSrcweir m_pData->aViewProps, NULL); 402cdf0e10cSrcweir else if (IsXMLToken(aLocalConfigName, 403cdf0e10cSrcweir XML_CONFIGURATION_SETTINGS)) 404cdf0e10cSrcweir pContext = new XMLConfigItemSetContext(GetImport(), 405cdf0e10cSrcweir p_nPrefix, rLocalName, xAttrList, 406cdf0e10cSrcweir m_pData->aConfigProps, NULL); 407cdf0e10cSrcweir else 408cdf0e10cSrcweir { 409cdf0e10cSrcweir m_pData->aDocSpecificSettings.push_back( SettingsGroup( aLocalConfigName, uno::Any() ) ); 410cdf0e10cSrcweir 411cdf0e10cSrcweir ::std::list< SettingsGroup >::reverse_iterator settingsPos = 412cdf0e10cSrcweir m_pData->aDocSpecificSettings.rbegin(); 413cdf0e10cSrcweir 414cdf0e10cSrcweir pContext = new XMLConfigItemSetContext(GetImport(), 415cdf0e10cSrcweir p_nPrefix, rLocalName, xAttrList, 416cdf0e10cSrcweir settingsPos->aSettings, NULL); 417cdf0e10cSrcweir } 418cdf0e10cSrcweir } 419cdf0e10cSrcweir } 420cdf0e10cSrcweir } 421cdf0e10cSrcweir 422cdf0e10cSrcweir if( !pContext ) 423cdf0e10cSrcweir pContext = new SvXMLImportContext( GetImport(), p_nPrefix, rLocalName ); 424cdf0e10cSrcweir 425cdf0e10cSrcweir return pContext; 426cdf0e10cSrcweir } 427cdf0e10cSrcweir 428cdf0e10cSrcweir void XMLDocumentSettingsContext::EndElement() 429cdf0e10cSrcweir { 430cdf0e10cSrcweir uno::Sequence<beans::PropertyValue> aSeqViewProps; 431cdf0e10cSrcweir if (m_pData->aViewProps >>= aSeqViewProps) 432cdf0e10cSrcweir { 433cdf0e10cSrcweir GetImport().SetViewSettings(aSeqViewProps); 434cdf0e10cSrcweir sal_Int32 i(aSeqViewProps.getLength() - 1); 435cdf0e10cSrcweir sal_Bool bFound(sal_False); 436cdf0e10cSrcweir while((i >= 0) && !bFound) 437cdf0e10cSrcweir { 438cdf0e10cSrcweir if (aSeqViewProps[i].Name.compareToAscii("Views") == 0) 439cdf0e10cSrcweir { 440cdf0e10cSrcweir bFound = sal_True; 441cdf0e10cSrcweir uno::Reference<container::XIndexAccess> xIndexAccess; 442cdf0e10cSrcweir if (aSeqViewProps[i].Value >>= xIndexAccess) 443cdf0e10cSrcweir { 444cdf0e10cSrcweir uno::Reference<document::XViewDataSupplier> xViewDataSupplier(GetImport().GetModel(), uno::UNO_QUERY); 445cdf0e10cSrcweir if (xViewDataSupplier.is()) 446cdf0e10cSrcweir xViewDataSupplier->setViewData(xIndexAccess); 447cdf0e10cSrcweir } 448cdf0e10cSrcweir } 449cdf0e10cSrcweir else 450cdf0e10cSrcweir i--; 451cdf0e10cSrcweir } 452cdf0e10cSrcweir } 453cdf0e10cSrcweir 454cdf0e10cSrcweir sal_Bool bLoadDocPrinter( sal_True ); 455cdf0e10cSrcweir ::comphelper::ConfigurationHelper::readDirectKey( 456cdf0e10cSrcweir ::comphelper::getProcessServiceFactory(), 457cdf0e10cSrcweir C2U("org.openoffice.Office.Common/"), C2U("Save/Document"), C2U("LoadPrinter"), 458cdf0e10cSrcweir ::comphelper::ConfigurationHelper::E_READONLY ) >>= bLoadDocPrinter; 459cdf0e10cSrcweir uno::Sequence<beans::PropertyValue> aSeqConfigProps; 460cdf0e10cSrcweir if ( m_pData->aConfigProps >>= aSeqConfigProps ) 461cdf0e10cSrcweir { 462cdf0e10cSrcweir if ( !bLoadDocPrinter ) 463cdf0e10cSrcweir { 464cdf0e10cSrcweir sal_Int32 i = aSeqConfigProps.getLength() - 1; 465cdf0e10cSrcweir int nFound = 0; 466cdf0e10cSrcweir 467cdf0e10cSrcweir while ( ( i >= 0 ) && nFound < 2 ) 468cdf0e10cSrcweir { 469cdf0e10cSrcweir rtl::OUString sProp( aSeqConfigProps[i].Name ); 470cdf0e10cSrcweir 471cdf0e10cSrcweir if ( sProp.compareToAscii("PrinterName") == 0 ) 472cdf0e10cSrcweir { 473cdf0e10cSrcweir rtl::OUString sEmpty; 474cdf0e10cSrcweir aSeqConfigProps[i].Value = uno::makeAny( sEmpty ); 475cdf0e10cSrcweir nFound++; 476cdf0e10cSrcweir } 477cdf0e10cSrcweir else if ( sProp.compareToAscii("PrinterSetup") == 0 ) 478cdf0e10cSrcweir { 479cdf0e10cSrcweir uno::Sequence< sal_Int8 > aEmpty; 480cdf0e10cSrcweir aSeqConfigProps[i].Value = uno::makeAny( aEmpty ); 481cdf0e10cSrcweir nFound++; 482cdf0e10cSrcweir } 483cdf0e10cSrcweir 484cdf0e10cSrcweir i--; 485cdf0e10cSrcweir } 486cdf0e10cSrcweir } 487cdf0e10cSrcweir 488cdf0e10cSrcweir GetImport().SetConfigurationSettings( aSeqConfigProps ); 489cdf0e10cSrcweir } 490cdf0e10cSrcweir 491cdf0e10cSrcweir for ( ::std::list< SettingsGroup >::const_iterator settings = m_pData->aDocSpecificSettings.begin(); 492cdf0e10cSrcweir settings != m_pData->aDocSpecificSettings.end(); 493cdf0e10cSrcweir ++settings 494cdf0e10cSrcweir ) 495cdf0e10cSrcweir { 496cdf0e10cSrcweir uno::Sequence< beans::PropertyValue > aDocSettings; 497cdf0e10cSrcweir OSL_VERIFY( settings->aSettings >>= aDocSettings ); 498cdf0e10cSrcweir GetImport().SetDocumentSpecificSettings( settings->sGroupName, aDocSettings ); 499cdf0e10cSrcweir } 500cdf0e10cSrcweir } 501cdf0e10cSrcweir 502cdf0e10cSrcweir //============================================================================= 503cdf0e10cSrcweir 504cdf0e10cSrcweir XMLConfigBaseContext::XMLConfigBaseContext(SvXMLImport& rImport, sal_uInt16 nPrfx, 505cdf0e10cSrcweir const rtl::OUString& rLName, com::sun::star::uno::Any& rTempAny, 506cdf0e10cSrcweir XMLConfigBaseContext* pTempBaseContext) 507cdf0e10cSrcweir : SvXMLImportContext( rImport, nPrfx, rLName ), 508cdf0e10cSrcweir // #110680# 509cdf0e10cSrcweir maProps(rImport.getServiceFactory()), 510cdf0e10cSrcweir maProp(), 511cdf0e10cSrcweir mrAny(rTempAny), 512cdf0e10cSrcweir mpBaseContext(pTempBaseContext) 513cdf0e10cSrcweir { 514cdf0e10cSrcweir } 515cdf0e10cSrcweir 516cdf0e10cSrcweir XMLConfigBaseContext::~XMLConfigBaseContext() 517cdf0e10cSrcweir { 518cdf0e10cSrcweir } 519cdf0e10cSrcweir 520cdf0e10cSrcweir //============================================================================= 521cdf0e10cSrcweir 522cdf0e10cSrcweir XMLConfigItemSetContext::XMLConfigItemSetContext(SvXMLImport& rImport, sal_uInt16 nPrfx, 523cdf0e10cSrcweir const rtl::OUString& rLName, 524cdf0e10cSrcweir const ::com::sun::star::uno::Reference< 525cdf0e10cSrcweir ::com::sun::star::xml::sax::XAttributeList>&, 526cdf0e10cSrcweir com::sun::star::uno::Any& rAny, 527cdf0e10cSrcweir XMLConfigBaseContext* pBaseContext) 528cdf0e10cSrcweir : XMLConfigBaseContext( rImport, nPrfx, rLName, rAny, pBaseContext ) 529cdf0e10cSrcweir { 530cdf0e10cSrcweir // here are no attributes 531cdf0e10cSrcweir } 532cdf0e10cSrcweir 533cdf0e10cSrcweir XMLConfigItemSetContext::~XMLConfigItemSetContext() 534cdf0e10cSrcweir { 535cdf0e10cSrcweir } 536cdf0e10cSrcweir 537cdf0e10cSrcweir SvXMLImportContext *XMLConfigItemSetContext::CreateChildContext( sal_uInt16 nPrefix, 538cdf0e10cSrcweir const rtl::OUString& rLocalName, 539cdf0e10cSrcweir const ::com::sun::star::uno::Reference< 540cdf0e10cSrcweir ::com::sun::star::xml::sax::XAttributeList>& xAttrList ) 541cdf0e10cSrcweir { 542cdf0e10cSrcweir return CreateSettingsContext(GetImport(), nPrefix, rLocalName, xAttrList, maProp, this); 543cdf0e10cSrcweir } 544cdf0e10cSrcweir 545cdf0e10cSrcweir void XMLConfigItemSetContext::EndElement() 546cdf0e10cSrcweir { 547cdf0e10cSrcweir mrAny <<= maProps.GetSequence(); 548cdf0e10cSrcweir if (mpBaseContext) 549cdf0e10cSrcweir mpBaseContext->AddPropertyValue(); 550cdf0e10cSrcweir } 551cdf0e10cSrcweir 552cdf0e10cSrcweir //============================================================================= 553cdf0e10cSrcweir 554cdf0e10cSrcweir XMLConfigItemContext::XMLConfigItemContext(SvXMLImport& rImport, sal_uInt16 nPrfx, const rtl::OUString& rLName, 555cdf0e10cSrcweir const ::com::sun::star::uno::Reference< 556cdf0e10cSrcweir ::com::sun::star::xml::sax::XAttributeList>& xAttrList, 557cdf0e10cSrcweir com::sun::star::uno::Any& rTempAny, 558cdf0e10cSrcweir const rtl::OUString& rTempItemName, 559cdf0e10cSrcweir XMLConfigBaseContext* pTempBaseContext) 560cdf0e10cSrcweir : SvXMLImportContext(rImport, nPrfx, rLName), 561cdf0e10cSrcweir mrAny(rTempAny), 562cdf0e10cSrcweir mrItemName(rTempItemName), 563cdf0e10cSrcweir mpBaseContext(pTempBaseContext) 564cdf0e10cSrcweir { 565cdf0e10cSrcweir sal_Int16 nAttrCount = xAttrList.is() ? xAttrList->getLength() : 0; 566cdf0e10cSrcweir for( sal_Int16 i=0; i < nAttrCount; i++ ) 567cdf0e10cSrcweir { 568cdf0e10cSrcweir rtl::OUString sAttrName = xAttrList->getNameByIndex( i ); 569cdf0e10cSrcweir rtl::OUString aLocalName; 570cdf0e10cSrcweir sal_uInt16 nPrefix = GetImport().GetNamespaceMap().GetKeyByAttrName( 571cdf0e10cSrcweir sAttrName, &aLocalName ); 572cdf0e10cSrcweir rtl::OUString sValue = xAttrList->getValueByIndex( i ); 573cdf0e10cSrcweir 574cdf0e10cSrcweir if (nPrefix == XML_NAMESPACE_CONFIG) 575cdf0e10cSrcweir { 576cdf0e10cSrcweir if (IsXMLToken(aLocalName, XML_TYPE)) 577cdf0e10cSrcweir msType = sValue; 578cdf0e10cSrcweir } 579cdf0e10cSrcweir } 580cdf0e10cSrcweir } 581cdf0e10cSrcweir 582cdf0e10cSrcweir XMLConfigItemContext::~XMLConfigItemContext() 583cdf0e10cSrcweir { 584cdf0e10cSrcweir } 585cdf0e10cSrcweir 586cdf0e10cSrcweir SvXMLImportContext *XMLConfigItemContext::CreateChildContext( sal_uInt16 nPrefix, 587cdf0e10cSrcweir const rtl::OUString& rLocalName, 588cdf0e10cSrcweir const ::com::sun::star::uno::Reference< 589cdf0e10cSrcweir ::com::sun::star::xml::sax::XAttributeList>& ) 590cdf0e10cSrcweir { 591cdf0e10cSrcweir SvXMLImportContext* pContext = new SvXMLImportContext(GetImport(), nPrefix, rLocalName); 592cdf0e10cSrcweir return pContext; 593cdf0e10cSrcweir } 594cdf0e10cSrcweir 595cdf0e10cSrcweir void XMLConfigItemContext::Characters( const ::rtl::OUString& rChars ) 596cdf0e10cSrcweir { 597cdf0e10cSrcweir if (IsXMLToken(msType, XML_BASE64BINARY)) 598cdf0e10cSrcweir { 599cdf0e10cSrcweir rtl::OUString sTrimmedChars( rChars.trim() ); 600cdf0e10cSrcweir if( sTrimmedChars.getLength() ) 601cdf0e10cSrcweir { 602cdf0e10cSrcweir rtl::OUString sChars; 603cdf0e10cSrcweir if( msValue ) 604cdf0e10cSrcweir { 605cdf0e10cSrcweir sChars = msValue; 606cdf0e10cSrcweir sChars += sTrimmedChars; 607cdf0e10cSrcweir msValue = rtl::OUString(); 608cdf0e10cSrcweir } 609cdf0e10cSrcweir else 610cdf0e10cSrcweir { 611cdf0e10cSrcweir sChars = sTrimmedChars; 612cdf0e10cSrcweir } 613cdf0e10cSrcweir uno::Sequence<sal_Int8> aBuffer((sChars.getLength() / 4) * 3 ); 614cdf0e10cSrcweir sal_Int32 nCharsDecoded = 615cdf0e10cSrcweir GetImport().GetMM100UnitConverter(). 616cdf0e10cSrcweir decodeBase64SomeChars( aBuffer, sChars ); 617cdf0e10cSrcweir sal_uInt32 nStartPos(maDecoded.getLength()); 618cdf0e10cSrcweir sal_uInt32 nCount(aBuffer.getLength()); 619cdf0e10cSrcweir maDecoded.realloc(nStartPos + nCount); 620cdf0e10cSrcweir sal_Int8* pDecoded = maDecoded.getArray(); 621cdf0e10cSrcweir sal_Int8* pBuffer = aBuffer.getArray(); 622cdf0e10cSrcweir for (sal_uInt32 i = 0; i < nCount; i++, pBuffer++) 623cdf0e10cSrcweir pDecoded[nStartPos + i] = *pBuffer; 624cdf0e10cSrcweir if( nCharsDecoded != sChars.getLength() ) 625cdf0e10cSrcweir msValue = sChars.copy( nCharsDecoded ); 626cdf0e10cSrcweir } 627cdf0e10cSrcweir } 628cdf0e10cSrcweir else 629cdf0e10cSrcweir msValue += rChars; 630cdf0e10cSrcweir } 631cdf0e10cSrcweir 632cdf0e10cSrcweir 633cdf0e10cSrcweir void XMLConfigItemContext::EndElement() 634cdf0e10cSrcweir { 635cdf0e10cSrcweir if (mpBaseContext) 636cdf0e10cSrcweir { 637cdf0e10cSrcweir if (IsXMLToken(msType, XML_BOOLEAN)) 638cdf0e10cSrcweir { 639cdf0e10cSrcweir sal_Bool bValue(sal_False); 640cdf0e10cSrcweir if (IsXMLToken(msValue, XML_TRUE)) 641cdf0e10cSrcweir bValue = sal_True; 642cdf0e10cSrcweir mrAny <<= bValue; 643cdf0e10cSrcweir } 644cdf0e10cSrcweir else if (IsXMLToken(msType, XML_BYTE)) 645cdf0e10cSrcweir { 646cdf0e10cSrcweir sal_Int32 nValue(0); 647cdf0e10cSrcweir SvXMLUnitConverter::convertNumber(nValue, msValue); 648cdf0e10cSrcweir mrAny <<= static_cast<sal_Int8>(nValue); 649cdf0e10cSrcweir } 650cdf0e10cSrcweir else if (IsXMLToken(msType, XML_SHORT)) 651cdf0e10cSrcweir { 652cdf0e10cSrcweir sal_Int32 nValue(0); 653cdf0e10cSrcweir SvXMLUnitConverter::convertNumber(nValue, msValue); 654cdf0e10cSrcweir mrAny <<= static_cast<sal_Int16>(nValue); 655cdf0e10cSrcweir } 656cdf0e10cSrcweir else if (IsXMLToken(msType, XML_INT)) 657cdf0e10cSrcweir { 658cdf0e10cSrcweir sal_Int32 nValue(0); 659cdf0e10cSrcweir SvXMLUnitConverter::convertNumber(nValue, msValue); 660cdf0e10cSrcweir mrAny <<= nValue; 661cdf0e10cSrcweir } 662cdf0e10cSrcweir else if (IsXMLToken(msType, XML_LONG)) 663cdf0e10cSrcweir { 664cdf0e10cSrcweir sal_Int64 nValue(msValue.toInt64()); 665cdf0e10cSrcweir mrAny <<= nValue; 666cdf0e10cSrcweir } 667cdf0e10cSrcweir else if (IsXMLToken(msType, XML_DOUBLE)) 668cdf0e10cSrcweir { 669cdf0e10cSrcweir double fValue(0.0); 670cdf0e10cSrcweir SvXMLUnitConverter::convertDouble(fValue, msValue); 671cdf0e10cSrcweir mrAny <<= fValue; 672cdf0e10cSrcweir } 673cdf0e10cSrcweir else if (IsXMLToken(msType, XML_STRING)) 674cdf0e10cSrcweir { 675cdf0e10cSrcweir mrAny <<= msValue; 676cdf0e10cSrcweir } 677cdf0e10cSrcweir else if (IsXMLToken(msType, XML_DATETIME)) 678cdf0e10cSrcweir { 679cdf0e10cSrcweir util::DateTime aDateTime; 680cdf0e10cSrcweir SvXMLUnitConverter::convertDateTime(aDateTime, msValue); 681cdf0e10cSrcweir mrAny <<= aDateTime; 682cdf0e10cSrcweir } 683cdf0e10cSrcweir else if (IsXMLToken(msType, XML_BASE64BINARY)) 684cdf0e10cSrcweir { 685cdf0e10cSrcweir mrAny <<= maDecoded; 686cdf0e10cSrcweir } 687cdf0e10cSrcweir else { 688cdf0e10cSrcweir DBG_ERROR("wrong type"); 689cdf0e10cSrcweir } 690cdf0e10cSrcweir 691cdf0e10cSrcweir ManipulateConfigItem(); 692cdf0e10cSrcweir 693cdf0e10cSrcweir mpBaseContext->AddPropertyValue(); 694cdf0e10cSrcweir } 695cdf0e10cSrcweir else { 696cdf0e10cSrcweir DBG_ERROR("no BaseContext"); 697cdf0e10cSrcweir } 698cdf0e10cSrcweir } 699cdf0e10cSrcweir 700cdf0e10cSrcweir /** There are some instances where there is a mismatch between API and 701cdf0e10cSrcweir * XML mapping of a setting. In this case, this method allows us to 702cdf0e10cSrcweir * manipulate the values accordingly. */ 703cdf0e10cSrcweir void XMLConfigItemContext::ManipulateConfigItem() 704cdf0e10cSrcweir { 705cdf0e10cSrcweir if( mrItemName.equalsAsciiL( 706cdf0e10cSrcweir RTL_CONSTASCII_STRINGPARAM( "PrinterIndependentLayout" ) ) ) 707cdf0e10cSrcweir { 708cdf0e10cSrcweir rtl::OUString sValue; 709cdf0e10cSrcweir mrAny >>= sValue; 710cdf0e10cSrcweir 711cdf0e10cSrcweir sal_Int16 nTmp = document::PrinterIndependentLayout::HIGH_RESOLUTION; 712cdf0e10cSrcweir 713cdf0e10cSrcweir if( sValue.equalsAsciiL(RTL_CONSTASCII_STRINGPARAM("enabled")) || 714cdf0e10cSrcweir sValue.equalsAsciiL(RTL_CONSTASCII_STRINGPARAM("low-resolution")) ) 715cdf0e10cSrcweir { 716cdf0e10cSrcweir nTmp = document::PrinterIndependentLayout::LOW_RESOLUTION; 717cdf0e10cSrcweir } 718cdf0e10cSrcweir else if( sValue.equalsAsciiL(RTL_CONSTASCII_STRINGPARAM("disabled")) ) 719cdf0e10cSrcweir { 720cdf0e10cSrcweir nTmp = document::PrinterIndependentLayout::DISABLED; 721cdf0e10cSrcweir } 722cdf0e10cSrcweir // else: default to high_resolution 723cdf0e10cSrcweir 724cdf0e10cSrcweir mrAny <<= nTmp; 725cdf0e10cSrcweir } 726cdf0e10cSrcweir else if( (mrItemName.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( "ColorTableURL" ) ) ) || 727cdf0e10cSrcweir (mrItemName.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( "LineEndTableURL" ) ) ) || 728cdf0e10cSrcweir (mrItemName.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( "HatchTableURL" ) ) ) || 729cdf0e10cSrcweir (mrItemName.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( "DashTableURL" ) ) ) || 730cdf0e10cSrcweir (mrItemName.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( "GradientTableURL") ) ) || 731cdf0e10cSrcweir (mrItemName.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( "BitmapTableURL" ) ) ) ) 732cdf0e10cSrcweir { 733cdf0e10cSrcweir if( GetImport().getServiceFactory().is() ) try 734cdf0e10cSrcweir { 735cdf0e10cSrcweir uno::Reference< util::XStringSubstitution > xStringSubsitution( 736cdf0e10cSrcweir GetImport().getServiceFactory()-> 737cdf0e10cSrcweir createInstance(::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.util.PathSubstitution" ) ) ), uno::UNO_QUERY ); 738cdf0e10cSrcweir 739cdf0e10cSrcweir if( xStringSubsitution.is() ) 740cdf0e10cSrcweir { 741cdf0e10cSrcweir rtl::OUString aURL; 742cdf0e10cSrcweir mrAny >>= aURL; 743cdf0e10cSrcweir aURL = xStringSubsitution->substituteVariables( aURL, sal_False ); 744cdf0e10cSrcweir mrAny <<= aURL; 745cdf0e10cSrcweir } 746cdf0e10cSrcweir } 747cdf0e10cSrcweir catch( uno::Exception& ) 748cdf0e10cSrcweir { 749cdf0e10cSrcweir } 750cdf0e10cSrcweir } 751cdf0e10cSrcweir } 752cdf0e10cSrcweir 753cdf0e10cSrcweir 754cdf0e10cSrcweir //============================================================================= 755cdf0e10cSrcweir 756cdf0e10cSrcweir XMLConfigItemMapNamedContext::XMLConfigItemMapNamedContext(SvXMLImport& rImport, sal_uInt16 nPrfx, const rtl::OUString& rLName, 757cdf0e10cSrcweir const ::com::sun::star::uno::Reference< 758cdf0e10cSrcweir ::com::sun::star::xml::sax::XAttributeList>&, 759cdf0e10cSrcweir com::sun::star::uno::Any& rAny, 760cdf0e10cSrcweir XMLConfigBaseContext* pBaseContext) 761cdf0e10cSrcweir : XMLConfigBaseContext(rImport, nPrfx, rLName, rAny, pBaseContext) 762cdf0e10cSrcweir { 763cdf0e10cSrcweir } 764cdf0e10cSrcweir 765cdf0e10cSrcweir XMLConfigItemMapNamedContext::~XMLConfigItemMapNamedContext() 766cdf0e10cSrcweir { 767cdf0e10cSrcweir } 768cdf0e10cSrcweir 769cdf0e10cSrcweir SvXMLImportContext *XMLConfigItemMapNamedContext::CreateChildContext( sal_uInt16 nPrefix, 770cdf0e10cSrcweir const rtl::OUString& rLocalName, 771cdf0e10cSrcweir const ::com::sun::star::uno::Reference< 772cdf0e10cSrcweir ::com::sun::star::xml::sax::XAttributeList>& xAttrList ) 773cdf0e10cSrcweir { 774cdf0e10cSrcweir return CreateSettingsContext(GetImport(), nPrefix, rLocalName, xAttrList, maProp, this); 775cdf0e10cSrcweir } 776cdf0e10cSrcweir 777cdf0e10cSrcweir void XMLConfigItemMapNamedContext::EndElement() 778cdf0e10cSrcweir { 779cdf0e10cSrcweir if (mpBaseContext) 780cdf0e10cSrcweir { 781cdf0e10cSrcweir mrAny <<= maProps.GetNameContainer(); 782cdf0e10cSrcweir mpBaseContext->AddPropertyValue(); 783cdf0e10cSrcweir } 784cdf0e10cSrcweir else { 785cdf0e10cSrcweir DBG_ERROR("no BaseContext"); 786cdf0e10cSrcweir } 787cdf0e10cSrcweir } 788cdf0e10cSrcweir 789cdf0e10cSrcweir //============================================================================= 790cdf0e10cSrcweir 791cdf0e10cSrcweir XMLConfigItemMapIndexedContext::XMLConfigItemMapIndexedContext(SvXMLImport& rImport, sal_uInt16 nPrfx, 792cdf0e10cSrcweir const rtl::OUString& rLName, 793cdf0e10cSrcweir const ::com::sun::star::uno::Reference< 794cdf0e10cSrcweir ::com::sun::star::xml::sax::XAttributeList>&, 795cdf0e10cSrcweir com::sun::star::uno::Any& rAny, 796cdf0e10cSrcweir const ::rtl::OUString& rConfigItemName, 797cdf0e10cSrcweir XMLConfigBaseContext* pBaseContext) 798cdf0e10cSrcweir : XMLConfigBaseContext(rImport, nPrfx, rLName, rAny, pBaseContext), 799cdf0e10cSrcweir maConfigItemName( rConfigItemName ) 800cdf0e10cSrcweir { 801cdf0e10cSrcweir } 802cdf0e10cSrcweir 803cdf0e10cSrcweir XMLConfigItemMapIndexedContext::~XMLConfigItemMapIndexedContext() 804cdf0e10cSrcweir { 805cdf0e10cSrcweir } 806cdf0e10cSrcweir 807cdf0e10cSrcweir SvXMLImportContext *XMLConfigItemMapIndexedContext::CreateChildContext( sal_uInt16 nPrefix, 808cdf0e10cSrcweir const rtl::OUString& rLocalName, 809cdf0e10cSrcweir const ::com::sun::star::uno::Reference< 810cdf0e10cSrcweir ::com::sun::star::xml::sax::XAttributeList>& xAttrList ) 811cdf0e10cSrcweir { 812cdf0e10cSrcweir return CreateSettingsContext(GetImport(), nPrefix, rLocalName, xAttrList, maProp, this); 813cdf0e10cSrcweir } 814cdf0e10cSrcweir 815cdf0e10cSrcweir void XMLConfigItemMapIndexedContext::EndElement() 816cdf0e10cSrcweir { 817cdf0e10cSrcweir if (mpBaseContext) 818cdf0e10cSrcweir { 819cdf0e10cSrcweir if( maConfigItemName.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( "ForbiddenCharacters" ) ) ) 820cdf0e10cSrcweir { 821cdf0e10cSrcweir uno::Reference< i18n::XForbiddenCharacters > xForbChars; 822cdf0e10cSrcweir 823cdf0e10cSrcweir // get the forbidden characters from the document 824cdf0e10cSrcweir uno::Reference< lang::XMultiServiceFactory > xFac( GetImport().GetModel(), uno::UNO_QUERY ); 825cdf0e10cSrcweir if( xFac.is() ) 826cdf0e10cSrcweir { 827cdf0e10cSrcweir uno::Reference< beans::XPropertySet > xProps( xFac->createInstance( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.document.Settings" ) ) ), uno::UNO_QUERY ); 828cdf0e10cSrcweir if( xProps.is() && xProps->getPropertySetInfo()->hasPropertyByName( maConfigItemName ) ) 829cdf0e10cSrcweir { 830cdf0e10cSrcweir xProps->getPropertyValue( maConfigItemName ) >>= xForbChars; 831cdf0e10cSrcweir } 832cdf0e10cSrcweir } 833cdf0e10cSrcweir 834cdf0e10cSrcweir if( xForbChars.is() ) 835cdf0e10cSrcweir { 836cdf0e10cSrcweir 837cdf0e10cSrcweir uno::Reference< container::XIndexAccess > xIndex( maProps.GetIndexContainer(), uno::UNO_QUERY ); 838cdf0e10cSrcweir 839cdf0e10cSrcweir const sal_Int32 nCount = xIndex->getCount(); 840cdf0e10cSrcweir uno::Sequence < beans::PropertyValue > aProps; 841cdf0e10cSrcweir for (sal_Int32 i = 0; i < nCount; i++) 842cdf0e10cSrcweir { 843cdf0e10cSrcweir if ((xIndex->getByIndex( i ) >>= aProps) && (aProps.getLength() == XML_FORBIDDEN_CHARACTER_MAX ) ) 844cdf0e10cSrcweir { 845cdf0e10cSrcweir beans::PropertyValue *pForChar = aProps.getArray(); 846cdf0e10cSrcweir i18n::ForbiddenCharacters aForbid; 847cdf0e10cSrcweir lang::Locale aLocale; 848cdf0e10cSrcweir const rtl::OUString sLanguage ( RTL_CONSTASCII_USTRINGPARAM ( "Language" ) ); 849cdf0e10cSrcweir const rtl::OUString sCountry ( RTL_CONSTASCII_USTRINGPARAM ( "Country" ) ); 850cdf0e10cSrcweir const rtl::OUString sVariant ( RTL_CONSTASCII_USTRINGPARAM ( "Variant" ) ); 851cdf0e10cSrcweir const rtl::OUString sBeginLine ( RTL_CONSTASCII_USTRINGPARAM ( "BeginLine" ) ); 852cdf0e10cSrcweir const rtl::OUString sEndLine ( RTL_CONSTASCII_USTRINGPARAM ( "EndLine" ) ); 853cdf0e10cSrcweir sal_Bool bHaveLanguage = sal_False, bHaveCountry = sal_False, bHaveVariant = sal_False, 854cdf0e10cSrcweir bHaveBegin = sal_False, bHaveEnd = sal_False; 855cdf0e10cSrcweir 856cdf0e10cSrcweir for ( sal_Int32 j = 0 ; j < XML_FORBIDDEN_CHARACTER_MAX ; j++ ) 857cdf0e10cSrcweir { 858cdf0e10cSrcweir if (pForChar->Name.equals (sLanguage ) ) 859cdf0e10cSrcweir { 860cdf0e10cSrcweir pForChar->Value >>= aLocale.Language; 861cdf0e10cSrcweir bHaveLanguage = sal_True; 862cdf0e10cSrcweir } 863cdf0e10cSrcweir else if (pForChar->Name.equals (sCountry ) ) 864cdf0e10cSrcweir { 865cdf0e10cSrcweir pForChar->Value >>= aLocale.Country; 866cdf0e10cSrcweir bHaveCountry = sal_True; 867cdf0e10cSrcweir } 868cdf0e10cSrcweir else if (pForChar->Name.equals (sVariant ) ) 869cdf0e10cSrcweir { 870cdf0e10cSrcweir pForChar->Value >>= aLocale.Variant; 871cdf0e10cSrcweir bHaveVariant = sal_True; 872cdf0e10cSrcweir } 873cdf0e10cSrcweir else if (pForChar->Name.equals (sBeginLine ) ) 874cdf0e10cSrcweir { 875cdf0e10cSrcweir pForChar->Value >>= aForbid.beginLine; 876cdf0e10cSrcweir bHaveBegin = sal_True; 877cdf0e10cSrcweir } 878cdf0e10cSrcweir else if (pForChar->Name.equals (sEndLine ) ) 879cdf0e10cSrcweir { 880cdf0e10cSrcweir pForChar->Value >>= aForbid.endLine; 881cdf0e10cSrcweir bHaveEnd = sal_True; 882cdf0e10cSrcweir } 883cdf0e10cSrcweir pForChar++; 884cdf0e10cSrcweir } 885cdf0e10cSrcweir 886cdf0e10cSrcweir if ( bHaveLanguage && bHaveCountry && bHaveVariant && bHaveBegin && bHaveEnd ) 887cdf0e10cSrcweir { 888cdf0e10cSrcweir try 889cdf0e10cSrcweir { 890cdf0e10cSrcweir xForbChars->setForbiddenCharacters( aLocale, aForbid ); 891cdf0e10cSrcweir } 892cdf0e10cSrcweir catch( uno::Exception& ) 893cdf0e10cSrcweir { 894cdf0e10cSrcweir DBG_ERROR( "Exception while importing forbidden characters" ); 895cdf0e10cSrcweir } 896cdf0e10cSrcweir } 897cdf0e10cSrcweir } 898cdf0e10cSrcweir } 899cdf0e10cSrcweir } 900cdf0e10cSrcweir else 901cdf0e10cSrcweir { 902cdf0e10cSrcweir DBG_ERROR( "could not get the XForbiddenCharacters from document!" ); 903cdf0e10cSrcweir mrAny <<= maProps.GetIndexContainer(); 904cdf0e10cSrcweir } 905cdf0e10cSrcweir } 906cdf0e10cSrcweir else if( maConfigItemName.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( "Symbols" ) ) ) 907cdf0e10cSrcweir { 908cdf0e10cSrcweir uno::Reference< container::XIndexAccess > xIndex( maProps.GetIndexContainer(), uno::UNO_QUERY ); 909cdf0e10cSrcweir 910cdf0e10cSrcweir const sal_Int32 nCount = xIndex->getCount(); 911cdf0e10cSrcweir uno::Sequence < beans::PropertyValue > aProps; 912cdf0e10cSrcweir uno::Sequence < formula::SymbolDescriptor > aSymbolList ( nCount ); 913cdf0e10cSrcweir 914cdf0e10cSrcweir formula::SymbolDescriptor *pDescriptor = aSymbolList.getArray(); 915cdf0e10cSrcweir 916cdf0e10cSrcweir const rtl::OUString sName ( RTL_CONSTASCII_USTRINGPARAM ( "Name" ) ); 917cdf0e10cSrcweir const rtl::OUString sExportName ( RTL_CONSTASCII_USTRINGPARAM ( "ExportName" ) ); 918cdf0e10cSrcweir const rtl::OUString sFontName ( RTL_CONSTASCII_USTRINGPARAM ( "FontName" ) ); 919cdf0e10cSrcweir const rtl::OUString sSymbolSet ( RTL_CONSTASCII_USTRINGPARAM ( "SymbolSet" ) ); 920cdf0e10cSrcweir const rtl::OUString sCharacter ( RTL_CONSTASCII_USTRINGPARAM ( "Character" ) ); 921cdf0e10cSrcweir const rtl::OUString sCharSet ( RTL_CONSTASCII_USTRINGPARAM ( "CharSet" ) ); 922cdf0e10cSrcweir const rtl::OUString sFamily ( RTL_CONSTASCII_USTRINGPARAM ( "Family" ) ); 923cdf0e10cSrcweir const rtl::OUString sPitch ( RTL_CONSTASCII_USTRINGPARAM ( "Pitch" ) ); 924cdf0e10cSrcweir const rtl::OUString sWeight ( RTL_CONSTASCII_USTRINGPARAM ( "Weight" ) ); 925cdf0e10cSrcweir const rtl::OUString sItalic ( RTL_CONSTASCII_USTRINGPARAM ( "Italic" ) ); 926cdf0e10cSrcweir sal_Int16 nNumFullEntries = 0; 927cdf0e10cSrcweir 928cdf0e10cSrcweir for ( sal_Int32 i = 0; i < nCount; i++ ) 929cdf0e10cSrcweir { 930cdf0e10cSrcweir if ((xIndex->getByIndex( i ) >>= aProps) && (aProps.getLength() == XML_SYMBOL_DESCRIPTOR_MAX ) ) 931cdf0e10cSrcweir { 932cdf0e10cSrcweir sal_Bool bHaveName = sal_False, bHaveExportName = sal_False, bHaveCharSet = sal_False, 933cdf0e10cSrcweir bHaveFontName = sal_False, bHaveFamily = sal_False, bHavePitch = sal_False, 934cdf0e10cSrcweir bHaveWeight = sal_False, bHaveItalic = sal_False, bHaveSymbolSet = sal_False, 935cdf0e10cSrcweir bHaveCharacter = sal_False; 936cdf0e10cSrcweir beans::PropertyValue *pSymbol = aProps.getArray(); 937cdf0e10cSrcweir 938cdf0e10cSrcweir for ( sal_Int32 j = 0 ; j < XML_SYMBOL_DESCRIPTOR_MAX ; j++ ) 939cdf0e10cSrcweir { 940cdf0e10cSrcweir if (pSymbol->Name.equals ( sName ) ) 941cdf0e10cSrcweir { 942cdf0e10cSrcweir pSymbol->Value >>= pDescriptor[nNumFullEntries].sName; 943cdf0e10cSrcweir bHaveName = sal_True; 944cdf0e10cSrcweir } 945cdf0e10cSrcweir else if (pSymbol->Name.equals (sExportName ) ) 946cdf0e10cSrcweir { 947cdf0e10cSrcweir pSymbol->Value >>= pDescriptor[nNumFullEntries].sExportName; 948cdf0e10cSrcweir bHaveExportName = sal_True; 949cdf0e10cSrcweir } 950cdf0e10cSrcweir else if (pSymbol->Name.equals (sFontName ) ) 951cdf0e10cSrcweir { 952cdf0e10cSrcweir pSymbol->Value >>= pDescriptor[nNumFullEntries].sFontName; 953cdf0e10cSrcweir bHaveFontName = sal_True; 954cdf0e10cSrcweir } 955cdf0e10cSrcweir else if (pSymbol->Name.equals (sCharSet ) ) 956cdf0e10cSrcweir { 957cdf0e10cSrcweir pSymbol->Value >>= pDescriptor[nNumFullEntries].nCharSet; 958cdf0e10cSrcweir bHaveCharSet = sal_True; 959cdf0e10cSrcweir } 960cdf0e10cSrcweir else if (pSymbol->Name.equals (sFamily ) ) 961cdf0e10cSrcweir { 962cdf0e10cSrcweir pSymbol->Value >>= pDescriptor[nNumFullEntries].nFamily; 963cdf0e10cSrcweir bHaveFamily = sal_True; 964cdf0e10cSrcweir } 965cdf0e10cSrcweir else if (pSymbol->Name.equals (sPitch ) ) 966cdf0e10cSrcweir { 967cdf0e10cSrcweir pSymbol->Value >>= pDescriptor[nNumFullEntries].nPitch; 968cdf0e10cSrcweir bHavePitch = sal_True; 969cdf0e10cSrcweir } 970cdf0e10cSrcweir else if (pSymbol->Name.equals (sWeight ) ) 971cdf0e10cSrcweir { 972cdf0e10cSrcweir pSymbol->Value >>= pDescriptor[nNumFullEntries].nWeight; 973cdf0e10cSrcweir bHaveWeight = sal_True; 974cdf0e10cSrcweir } 975cdf0e10cSrcweir else if (pSymbol->Name.equals (sItalic ) ) 976cdf0e10cSrcweir { 977cdf0e10cSrcweir pSymbol->Value >>= pDescriptor[nNumFullEntries].nItalic; 978cdf0e10cSrcweir bHaveItalic = sal_True; 979cdf0e10cSrcweir } 980cdf0e10cSrcweir else if (pSymbol->Name.equals (sSymbolSet ) ) 981cdf0e10cSrcweir { 982cdf0e10cSrcweir pSymbol->Value >>= pDescriptor[nNumFullEntries].sSymbolSet; 983cdf0e10cSrcweir bHaveSymbolSet = sal_True; 984cdf0e10cSrcweir } 985cdf0e10cSrcweir else if (pSymbol->Name.equals (sCharacter ) ) 986cdf0e10cSrcweir { 987cdf0e10cSrcweir pSymbol->Value >>= pDescriptor[nNumFullEntries].nCharacter; 988cdf0e10cSrcweir bHaveCharacter = sal_True; 989cdf0e10cSrcweir } 990cdf0e10cSrcweir pSymbol++; 991cdf0e10cSrcweir } 992cdf0e10cSrcweir if ( bHaveName && bHaveExportName && bHaveCharSet && bHaveFontName && bHaveCharacter 993cdf0e10cSrcweir && bHaveFamily && bHavePitch && bHaveWeight && bHaveItalic && bHaveSymbolSet) 994cdf0e10cSrcweir nNumFullEntries++; 995cdf0e10cSrcweir } 996cdf0e10cSrcweir } 997cdf0e10cSrcweir aSymbolList.realloc (nNumFullEntries); 998cdf0e10cSrcweir mrAny <<= aSymbolList; 999cdf0e10cSrcweir } 1000cdf0e10cSrcweir else 1001cdf0e10cSrcweir { 1002cdf0e10cSrcweir mrAny <<= maProps.GetIndexContainer(); 1003cdf0e10cSrcweir } 1004cdf0e10cSrcweir mpBaseContext->AddPropertyValue(); 1005cdf0e10cSrcweir } 1006cdf0e10cSrcweir else { 1007cdf0e10cSrcweir DBG_ERROR("no BaseContext"); 1008cdf0e10cSrcweir } 1009cdf0e10cSrcweir } 1010cdf0e10cSrcweir 1011