1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ 2 /* 3 * This file is part of the LibreOffice project. 4 * 5 * This Source Code Form is subject to the terms of the Mozilla Public 6 * License, v. 2.0. If a copy of the MPL was not distributed with this 7 * file, You can obtain one at http://mozilla.org/MPL/2.0/. 8 * 9 * This file incorporates work covered by the following license notice: 10 * 11 * Licensed to the Apache Software Foundation (ASF) under one or more 12 * contributor license agreements. See the NOTICE file distributed 13 * with this work for additional information regarding copyright 14 * ownership. The ASF licenses this file to you under the Apache 15 * License, Version 2.0 (the "License"); you may not use this file 16 * except in compliance with the License. You may obtain a copy of 17 * the License at http://www.apache.org/licenses/LICENSE-2.0 . 18 */ 19 20 #include <MediaDescriptorHelper.hxx> 21 #include <com/sun/star/beans/PropertyValue.hpp> 22 #include <com/sun/star/embed/XStorage.hpp> 23 #include <com/sun/star/uno/Sequence.hxx> 24 #include <com/sun/star/uno/Any.hxx> 25 #include <com/sun/star/uno/Reference.hxx> 26 27 using namespace ::com::sun::star; 28 29 namespace apphelper 30 { 31 MediaDescriptorHelper(const uno::Sequence<beans::PropertyValue> & rMediaDescriptor)32MediaDescriptorHelper::MediaDescriptorHelper( const uno::Sequence< 33 beans::PropertyValue > & rMediaDescriptor ) 34 : m_aModelProperties(rMediaDescriptor.getLength()) 35 { 36 css::uno::Sequence< css::beans::PropertyValue > 37 aRegularProperties(rMediaDescriptor.getLength()); //these are the properties which are described in service com.sun.star.document.MediaDescriptor and not marked as deprecated 38 impl_init(); 39 sal_Int32 nRegularCount = 0; 40 sal_Int32 nModelCount = 0; 41 42 auto addRegularProp = [&aRegularProperties, &nRegularCount](const beans::PropertyValue& rRegularProp) 43 { 44 aRegularProperties[nRegularCount] = rRegularProp; 45 ++nRegularCount; 46 }; 47 auto addModelProp = [this, &nModelCount, &addRegularProp](const beans::PropertyValue& rModelProp) 48 { 49 addRegularProp(rModelProp); 50 m_aModelProperties[nModelCount] = rModelProp; 51 ++nModelCount; 52 }; 53 54 //read given rMediaDescriptor and store in internal structures: 55 for( const beans::PropertyValue& rProp : rMediaDescriptor) 56 { 57 if (rProp.Name == "AsTemplate") 58 { 59 addModelProp(rProp); 60 } 61 else if (rProp.Name == "Author") 62 { 63 addModelProp(rProp); 64 } 65 else if (rProp.Name == "CharacterSet") 66 { 67 addModelProp(rProp); 68 } 69 else if (rProp.Name == "Comment") 70 { 71 addModelProp(rProp); 72 } 73 else if (rProp.Name == "ComponentData") 74 { 75 addModelProp(rProp); 76 } 77 else if (rProp.Name == "FilterData") 78 { 79 addModelProp(rProp); 80 } 81 else if (rProp.Name == "FilterName") 82 { 83 ISSET_FilterName = rProp.Value >>= FilterName; 84 addModelProp(rProp); 85 } 86 else if (rProp.Name == "FilterOptions") 87 { 88 addModelProp(rProp); 89 } 90 else if (rProp.Name == "FrameName") 91 { 92 addModelProp(rProp); 93 } 94 else if (rProp.Name == "Hidden") 95 { 96 addModelProp(rProp); 97 } 98 else if (rProp.Name == "HierarchicalDocumentName") 99 { 100 rProp.Value >>= HierarchicalDocumentName; 101 addModelProp(rProp); 102 } 103 else if (rProp.Name == "OutputStream") 104 { 105 ISSET_OutputStream = rProp.Value >>= OutputStream; 106 addRegularProp(rProp); 107 } 108 else if (rProp.Name == "InputStream") 109 { 110 ISSET_InputStream = rProp.Value >>= InputStream; 111 addRegularProp(rProp); 112 } 113 else if (rProp.Name == "InteractionHandler") 114 { 115 addRegularProp(rProp); 116 } 117 else if (rProp.Name == "JumpMark") 118 { 119 addRegularProp(rProp); 120 } 121 else if (rProp.Name == "MediaType") 122 { 123 addModelProp(rProp); 124 } 125 else if (rProp.Name == "OpenNewView") 126 { 127 addRegularProp(rProp); 128 } 129 else if (rProp.Name == "Overwrite") 130 { 131 addModelProp(rProp); 132 } 133 else if (rProp.Name == "Password") 134 { 135 addModelProp(rProp); 136 } 137 else if (rProp.Name == "PosSize") 138 { 139 addRegularProp(rProp); 140 } 141 else if (rProp.Name == "PostData") 142 { 143 addRegularProp(rProp); 144 } 145 else if (rProp.Name == "Preview") 146 { 147 addModelProp(rProp); 148 } 149 else if (rProp.Name == "ReadOnly") 150 { 151 rProp.Value >>= ReadOnly; 152 addRegularProp(rProp); 153 } 154 else if (rProp.Name == "Referer") 155 { 156 addModelProp(rProp); 157 } 158 else if (rProp.Name == "SetEmbedded") 159 { 160 addRegularProp(rProp); 161 } 162 else if (rProp.Name == "Silent") 163 { 164 addRegularProp(rProp); 165 } 166 else if (rProp.Name == "StatusIndicator") 167 { 168 addRegularProp(rProp); 169 } 170 else if (rProp.Name == "Storage") 171 { 172 ISSET_Storage = rProp.Value >>= Storage; 173 addModelProp(rProp); 174 } 175 else if (rProp.Name == "Stream") 176 { 177 ISSET_Stream = rProp.Value >>= Stream; 178 addModelProp(rProp); 179 } 180 else if (rProp.Name == "Unpacked") 181 { 182 addModelProp(rProp); 183 } 184 else if (rProp.Name == "URL") 185 { 186 ISSET_URL = rProp.Value >>= URL; 187 addModelProp(rProp); 188 } 189 else if (rProp.Name == "Version") 190 { 191 addModelProp(rProp); 192 } 193 else if (rProp.Name == "ViewData") 194 { 195 addModelProp(rProp); 196 } 197 else if (rProp.Name == "ViewId") 198 { 199 addModelProp(rProp); 200 } 201 } 202 203 aRegularProperties.realloc(nRegularCount); 204 m_aModelProperties.realloc(nModelCount); 205 } 206 impl_init()207void MediaDescriptorHelper::impl_init() 208 { 209 ISSET_FilterName = false; 210 211 ISSET_OutputStream = false; 212 ISSET_InputStream = false; 213 214 ReadOnly = false; 215 ISSET_URL = false; 216 217 ISSET_Storage = false; 218 ISSET_Stream = false; 219 } 220 221 } 222 223 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ 224