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 <vcl/wmfexternal.hxx>
21 #include <com/sun/star/beans/PropertyValue.hpp>
22 
23 // formally known as WMF_EXTERNALHEADER
WmfExternal()24 WmfExternal::WmfExternal() :
25     xExt(0),
26     yExt(0),
27     mapMode(0)
28 {
29 }
30 
getSequence() const31 css::uno::Sequence< css::beans::PropertyValue > WmfExternal::getSequence() const
32 {
33     css::uno::Sequence< css::beans::PropertyValue > aSequence;
34 
35     if (0 != xExt || 0 != yExt || 0 != mapMode)
36     {
37         aSequence.realloc(3);
38         aSequence[0].Name = "Width";
39         aSequence[0].Value <<= static_cast<sal_Int16>(xExt);
40         aSequence[1].Name = "Height";
41         aSequence[1].Value <<= static_cast<sal_Int16>(yExt);
42         aSequence[2].Name = "MapMode";
43         aSequence[2].Value <<= static_cast<sal_Int16>(mapMode);
44     }
45 
46     return aSequence;
47 }
48 
setSequence(const css::uno::Sequence<css::beans::PropertyValue> & rSequence)49 bool WmfExternal::setSequence(const css::uno::Sequence< css::beans::PropertyValue >& rSequence)
50 {
51     bool bRetval(false);
52 
53     for (const auto& rPropVal : rSequence)
54     {
55         const OUString aName(rPropVal.Name);
56 
57         if (aName == "Width")
58         {
59             rPropVal.Value >>= xExt;
60             bRetval = true;
61         }
62         else if (aName == "Height")
63         {
64             rPropVal.Value >>= yExt;
65             bRetval = true;
66         }
67         else if (aName == "MapMode")
68         {
69             rPropVal.Value >>= mapMode;
70             bRetval = true;
71         }
72     }
73 
74     return bRetval;
75 }
76 
77 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
78