diff options
Diffstat (limited to 'xmloff/source/text/txtimp.cxx')
-rw-r--r-- | xmloff/source/text/txtimp.cxx | 83 |
1 files changed, 71 insertions, 12 deletions
diff --git a/xmloff/source/text/txtimp.cxx b/xmloff/source/text/txtimp.cxx index a7b7b4cb6782..cd09ba7f646f 100644 --- a/xmloff/source/text/txtimp.cxx +++ b/xmloff/source/text/txtimp.cxx @@ -89,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; @@ -110,6 +112,8 @@ using namespace ::com::sun::star::ucb; using ::comphelper::UStringLess; + + static __FAR_DATA SvXMLTokenMapEntry aTextElemTokenMap[] = { { XML_NAMESPACE_TEXT, XML_P, XML_TOK_TEXT_P }, @@ -444,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, @@ -2277,18 +2345,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(); } } |