diff options
author | os <os@openoffice.org> | 2010-04-21 08:33:47 +0200 |
---|---|---|
committer | os <os@openoffice.org> | 2010-04-21 08:33:47 +0200 |
commit | 1c4ec00e55e5dbfef9de6ff4fb17fa1cd4216ec2 (patch) | |
tree | 3191f471bcea32fe7f3b1a6959ec365edc4cb9fd /xmloff/source/text/txtimp.cxx | |
parent | 45416c690f87e05fe7e67bb79e1acfd0017a66a2 (diff) | |
parent | a001605a190749900d3e09aa864ce56925ff848e (diff) |
rebase to m76
Diffstat (limited to 'xmloff/source/text/txtimp.cxx')
-rw-r--r-- | xmloff/source/text/txtimp.cxx | 88 |
1 files changed, 72 insertions, 16 deletions
diff --git a/xmloff/source/text/txtimp.cxx b/xmloff/source/text/txtimp.cxx index dc33bd4299f0..7ffbe6b81d71 100644 --- a/xmloff/source/text/txtimp.cxx +++ b/xmloff/source/text/txtimp.cxx @@ -2,13 +2,10 @@ * * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * - * Copyright 2008 by Sun Microsystems, Inc. + * Copyright 2000, 2010 Oracle and/or its affiliates. * * OpenOffice.org - a multi-platform office productivity suite * - * $RCSfile: txtimp.cxx,v $ - * $Revision: 1.143.2.3 $ - * * This file is part of OpenOffice.org. * * OpenOffice.org is free software: you can redistribute it and/or modify @@ -92,6 +89,8 @@ // --> OD 2008-04-25 #refactorlists# #include <txtlists.hxx> // <-- +#include <xmloff/odffields.hxx> +#include <comphelper/stlunosequence.hxx> using ::rtl::OUString; using ::rtl::OUStringBuffer; @@ -113,6 +112,8 @@ using namespace ::com::sun::star::ucb; using namespace ::com::sun::star; using ::comphelper::UStringLess; + + static __FAR_DATA SvXMLTokenMapEntry aTextElemTokenMap[] = { { XML_NAMESPACE_TEXT, XML_P, XML_TOK_TEXT_P }, @@ -447,6 +448,70 @@ static __FAR_DATA SvXMLTokenMapEntry aTextMasterPageElemTokenMap[] = #define MAX_COMBINED_CHARACTERS 6 +namespace +{ + class FieldParamImporter + { + public: + typedef pair<OUString,OUString> field_param_t; + typedef vector<field_param_t> field_params_t; + FieldParamImporter(const field_params_t* const pInParams, Reference<XNameContainer> xOutParams) + : m_pInParams(pInParams) + , m_xOutParams(xOutParams) + { }; + void Import(); + + private: + const field_params_t* const m_pInParams; + Reference<XNameContainer> m_xOutParams; + }; + + void FieldParamImporter::Import() + { + ::std::vector<OUString> vListEntries; + ::std::map<OUString, Any> vOutParams; + for(field_params_t::const_iterator pCurrent = m_pInParams->begin(); + pCurrent != m_pInParams->end(); + ++pCurrent) + { + if(pCurrent->first.equalsAscii(ODF_FORMDROPDOWN_RESULT)) + { + // sal_Int32 + vOutParams[pCurrent->first] = makeAny(pCurrent->second.toInt32()); + } + else if(pCurrent->first.equalsAscii(ODF_FORMCHECKBOX_RESULT)) + { + // bool + vOutParams[pCurrent->first] = makeAny(pCurrent->second.toBoolean()); + } + else if(pCurrent->first.equalsAscii(ODF_FORMDROPDOWN_LISTENTRY)) + { + // sequence + vListEntries.push_back(pCurrent->second); + } + else + vOutParams[pCurrent->first] = makeAny(pCurrent->second); + } + if(!vListEntries.empty()) + { + Sequence<OUString> vListEntriesSeq(vListEntries.size()); + copy(vListEntries.begin(), vListEntries.end(), ::comphelper::stl_begin(vListEntriesSeq)); + vOutParams[OUString::createFromAscii(ODF_FORMDROPDOWN_LISTENTRY)] = makeAny(vListEntriesSeq); + } + for(::std::map<OUString, Any>::const_iterator pCurrent = vOutParams.begin(); + pCurrent != vOutParams.end(); + ++pCurrent) + { + try + { + m_xOutParams->insertByName(pCurrent->first, pCurrent->second); + } + catch(ElementExistException) + { } + } + } +} + XMLTextImportHelper::XMLTextImportHelper( const Reference < XModel >& rModel, SvXMLImport& rImport, @@ -2301,18 +2366,9 @@ bool XMLTextImportHelper::hasCurrentFieldCtx() void XMLTextImportHelper::setCurrentFieldParamsTo(::com::sun::star::uno::Reference< ::com::sun::star::text::XFormField> &xFormField) { DBG_ASSERT(!aFieldStack.empty(), "stack is empty: not good! Do a pushFieldCtx before..."); - if (!aFieldStack.empty() && xFormField.is()) { - field_params_t ¶ms=aFieldStack.top().second; - for (field_params_t::iterator i=params.begin();i!=params.end();i++) { - rtl::OUString name=i->first; - rtl::OUString value=i->second; - if (name.compareToAscii("Description")==0){ - xFormField->setDescription(value); - } else if (name.compareToAscii("Result")==0){ - xFormField->setRes((sal_Int16)value.toInt32()); - } - - } + if (!aFieldStack.empty() && xFormField.is()) + { + FieldParamImporter(&aFieldStack.top().second, xFormField->getParameters()).Import(); } } |