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 #include <com/sun/star/text/TableColumnSeparator.hpp> 25 #include <resourcemodel/TagLogger.hxx> 26 #include "PropertyMapHelper.hxx" 27 28 namespace writerfilter 29 { 30 namespace dmapper 31 { 32 33 using namespace ::com::sun::star; 34 lcl_TableColumnSeparatorsToTag(const uno::Any & rTableColumnSeparators)35XMLTag::Pointer_t lcl_TableColumnSeparatorsToTag(const uno::Any & rTableColumnSeparators) 36 { 37 uno::Sequence<text::TableColumnSeparator> aSeq; 38 rTableColumnSeparators >>= aSeq; 39 40 XMLTag::Pointer_t pResult(new XMLTag("property.TableColumnSeparators")); 41 42 sal_uInt32 nLength = aSeq.getLength(); 43 for (sal_uInt32 n = 0; n < nLength; ++n) 44 { 45 XMLTag::Pointer_t pTagSeparator(new XMLTag("separator")); 46 47 pTagSeparator->addAttr("position", aSeq[n].Position); 48 pTagSeparator->addAttr("visible", aSeq[n].IsVisible); 49 50 pResult->addTag(pTagSeparator); 51 } 52 53 return pResult; 54 } 55 lcl_PropertyValuesToTag(beans::PropertyValues & rValues)56XMLTag::Pointer_t lcl_PropertyValuesToTag(beans::PropertyValues & rValues) 57 { 58 XMLTag::Pointer_t pResult(new XMLTag("propertyValues")); 59 60 beans::PropertyValue * pValues = rValues.getArray(); 61 62 for (sal_Int32 n = 0; n < rValues.getLength(); ++n) 63 { 64 XMLTag::Pointer_t pTag(new XMLTag("propertyValue")); 65 66 pTag->addAttr("name", pValues[n].Name); 67 68 try 69 { 70 sal_Int32 aInt = 0; 71 pValues[n].Value >>= aInt; 72 pTag->addAttr("value", aInt); 73 } 74 catch (...) 75 { 76 } 77 78 if (pValues[n].Name.equalsAscii("TableColumnSeparators")) 79 { 80 pTag->addTag(lcl_TableColumnSeparatorsToTag(pValues[n].Value)); 81 } 82 83 pResult->addTag(pTag); 84 } 85 86 return pResult; 87 } 88 lcl_PropertyValueSeqToTag(PropertyValueSeq_t & rPropValSeq)89XMLTag::Pointer_t lcl_PropertyValueSeqToTag(PropertyValueSeq_t & rPropValSeq) 90 { 91 XMLTag::Pointer_t pResult(new XMLTag("PropertyValueSeq")); 92 93 beans::PropertyValues * pValues = rPropValSeq.getArray(); 94 95 for (sal_Int32 n = 0; n < rPropValSeq.getLength(); ++n) 96 { 97 XMLTag::Pointer_t pTag(lcl_PropertyValuesToTag(pValues[n])); 98 99 pResult->addTag(pTag); 100 } 101 102 return pResult; 103 } 104 lcl_PropertyValueSeqSeqToTag(PropertyValueSeqSeq_t rPropValSeqSeq)105XMLTag::Pointer_t lcl_PropertyValueSeqSeqToTag(PropertyValueSeqSeq_t rPropValSeqSeq) 106 { 107 XMLTag::Pointer_t pResult(new XMLTag("PropertyValueSeq")); 108 109 PropertyValueSeq_t * pValues = rPropValSeqSeq.getArray(); 110 111 for (sal_Int32 n = 0; n < rPropValSeqSeq.getLength(); ++n) 112 { 113 XMLTag::Pointer_t pTag(lcl_PropertyValueSeqToTag(pValues[n])); 114 115 pResult->addTag(pTag); 116 } 117 118 return pResult; 119 } 120 121 } 122 } 123