LibreOffice Module sw (master)  1
barcfg.cxx
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 
20 #include <osl/diagnose.h>
21 #include <com/sun/star/uno/Sequence.hxx>
22 #include <wrtsh.hxx>
23 #include <barcfg.hxx>
24 
25 #include <unomid.h>
26 
27 using namespace utl;
28 using namespace com::sun::star::uno;
29 
30 #define SEL_TYPE_TABLE_TEXT 0
31 #define SEL_TYPE_LIST_TEXT 1
32 #define SEL_TYPE_TABLE_LIST 2
33 #define SEL_TYPE_BEZIER 3
34 #define SEL_TYPE_GRAPHIC 4
35 
37  ConfigItem(bWeb ? OUString("Office.WriterWeb/ObjectBar") : OUString("Office.Writer/ObjectBar"),
39 {
40  for(int i = 0; i <= SEL_TYPE_GRAPHIC; ++i)
41  aTbxIdArray[i] = -1;
42 
44  Sequence<Any> aValues = GetProperties(aNames);
45  const Any* pValues = aValues.getConstArray();
46  OSL_ENSURE(aValues.getLength() == aNames.getLength(), "GetProperties failed");
47  if(aValues.getLength() == aNames.getLength())
48  {
49  for(int nProp = 0; nProp < aNames.getLength(); nProp++)
50  {
51  if(pValues[nProp].hasValue())
52  {
53  sal_Int32 nVal = 0;
54  pValues[nProp] >>= nVal;
55  aTbxIdArray[nProp] = nVal;
56  }
57  }
58  }
59 }
60 
62 {
63 }
64 
65 static sal_Int32 lcl_getArrayIndex(SelectionType nSelType)
66 {
67  sal_Int32 nRet = -1;
68  if(nSelType & SelectionType::NumberList)
69  {
70  if(nSelType & SelectionType::Table)
71  nRet = SEL_TYPE_TABLE_LIST;
72  else
73  nRet = SEL_TYPE_LIST_TEXT;
74  }
75  else if(nSelType & SelectionType::Table)
76  nRet = SEL_TYPE_TABLE_TEXT;
77  else if(nSelType & SelectionType::Ornament)
78  nRet = SEL_TYPE_BEZIER;
79  else if(nSelType & SelectionType::Graphic)
80  nRet = SEL_TYPE_GRAPHIC;
81  return nRet;
82 }
83 
85 {
86  sal_Int32 nProp = lcl_getArrayIndex(nSelType);
87  if(nProp >= 0)
88  {
89  aTbxIdArray[nProp] = static_cast<sal_Int32>(eBarId);
90  SetModified();
91  }
92 }
93 
95 {
96  static const char* aPropNames[] =
97  {
98  "Selection/Table", // SEL_TYPE_TABLE_TEXT
99  "Selection/NumberedList", // SEL_TYPE_LIST_TEXT
100  "Selection/NumberedList_InTable", // SEL_TYPE_TABLE_LIST
101  "Selection/BezierObject", // SEL_TYPE_BEZIER
102  "Selection/Graphic" //SEL_TYPE_GRAPHIC
103  };
104  const int nCount = 5;
105  Sequence<OUString> aNames(nCount);
106  OUString* pNames = aNames.getArray();
107  for(int i = 0; i < nCount; i++)
108  pNames[i] = OUString::createFromAscii(aPropNames[i]);
109  return aNames;
110 }
111 
113 {
115 
116  Sequence<Any> aValues(aNames.getLength());
117  Any* pValues = aValues.getArray();
118 
119  for(int nProp = 0; nProp < aNames.getLength(); nProp++)
120  pValues[nProp] <<= aTbxIdArray[nProp];
121  PutProperties(aNames, aValues);
122 }
123 
124 void SwToolbarConfigItem::Notify( const css::uno::Sequence< OUString >& ) {}
125 
126 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
#define SEL_TYPE_LIST_TEXT
Definition: barcfg.cxx:31
void SetTopToolbar(SelectionType nSelType, ToolbarId eBarId)
Definition: barcfg.cxx:84
sal_Int32 aTbxIdArray[5]
Definition: barcfg.hxx:29
ConfigItemMode
SwToolbarConfigItem(bool bWeb)
Definition: barcfg.cxx:36
static css::uno::Sequence< OUString > GetPropertyNames()
Definition: barcfg.cxx:94
#define SEL_TYPE_BEZIER
Definition: barcfg.cxx:33
bool PutProperties(const css::uno::Sequence< OUString > &rNames, const css::uno::Sequence< css::uno::Any > &rValues)
virtual void Notify(const css::uno::Sequence< OUString > &aPropertyNames) override
Definition: barcfg.cxx:124
int i
css::uno::Sequence< css::uno::Any > GetProperties(const css::uno::Sequence< OUString > &rNames)
#define SEL_TYPE_TABLE_TEXT
Definition: barcfg.cxx:30
SelectionType
Definition: wrtsh.hxx:56
ToolbarId
#define SEL_TYPE_TABLE_LIST
Definition: barcfg.cxx:32
#define SEL_TYPE_GRAPHIC
Definition: barcfg.cxx:34
static sal_Int32 lcl_getArrayIndex(SelectionType nSelType)
Definition: barcfg.cxx:65
virtual ~SwToolbarConfigItem() override
Definition: barcfg.cxx:61
virtual void ImplCommit() override
Definition: barcfg.cxx:112