LibreOffice Module sw (master)  1
vbafilterpropsfromformat.hxx
Go to the documentation of this file.
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 #ifndef INCLUDED_SW_SOURCE_UI_VBA_VBAFILTERPROPSFROMFORMAT_HXX
20 #define INCLUDED_SW_SOURCE_UI_VBA_VBAFILTERPROPSFROMFORMAT_HXX
21 
22 #include <sal/config.h>
23 
24 #include <com/sun/star/beans/PropertyValue.hpp>
25 #include <com/sun/star/uno/Sequence.hxx>
26 #include <rtl/ustring.hxx>
27 #include <ooo/vba/word/WdSaveFormat.hpp>
28 
29 namespace
30 {
31 inline bool setFilterPropsFromFormat(sal_Int32 nFormat,
32  css::uno::Sequence<css::beans::PropertyValue>& rProps)
33 {
34  auto pProp
35  = std::find_if(rProps.begin(), rProps.end(), [](const css::beans::PropertyValue& rProp) {
36  return rProp.Name == "FilterName";
37  });
38  if (pProp != rProps.end())
39  {
40  switch (nFormat)
41  {
42  case ooo::vba::word::WdSaveFormat::wdFormatDocument:
43  pProp->Value <<= OUString("MS Word 97");
44  break;
45  // Just save all the text formats as "Text"
46  case ooo::vba::word::WdSaveFormat::wdFormatDOSText:
47  case ooo::vba::word::WdSaveFormat::wdFormatDOSTextLineBreaks:
48  case ooo::vba::word::WdSaveFormat::wdFormatEncodedText:
49  case ooo::vba::word::WdSaveFormat::wdFormatText:
50  case ooo::vba::word::WdSaveFormat::wdFormatTextLineBreaks:
51  pProp->Value <<= OUString("Text");
52  break;
53  case ooo::vba::word::WdSaveFormat::wdFormatFilteredHTML:
54  case ooo::vba::word::WdSaveFormat::wdFormatHTML:
55  pProp->Value <<= OUString("HTML");
56  break;
57  case ooo::vba::word::WdSaveFormat::wdFormatRTF:
58  pProp->Value <<= OUString("Rich Text Format");
59  break;
60  case ooo::vba::word::WdSaveFormat::wdFormatTemplate:
61  pProp->Value <<= OUString("MS Word 97 Vorlage");
62  break;
63 
64  // Default to "MS Word 97"
65  default:
66  pProp->Value <<= OUString("MS Word 97");
67  break;
68  }
69  return true;
70  }
71  return false;
72 }
73 }
74 
75 #endif