1 /************************************************************************* 2 * 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4 * 5 * Copyright 2000, 2010 Oracle and/or its affiliates. 6 * 7 * OpenOffice.org - a multi-platform office productivity suite 8 * 9 * This file is part of OpenOffice.org. 10 * 11 * OpenOffice.org is free software: you can redistribute it and/or modify 12 * it under the terms of the GNU Lesser General Public License version 3 13 * only, as published by the Free Software Foundation. 14 * 15 * OpenOffice.org is distributed in the hope that it will be useful, 16 * but WITHOUT ANY WARRANTY; without even the implied warranty of 17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 18 * GNU Lesser General Public License version 3 for more details 19 * (a copy is included in the LICENSE file that accompanied this code). 20 * 21 * You should have received a copy of the GNU Lesser General Public License 22 * version 3 along with OpenOffice.org. If not, see 23 * <http://www.openoffice.org/license.html> 24 * for a copy of the LGPLv3 License. 25 * 26 ************************************************************************/ 27 28 // MARKER(update_precomp.py): autogen include statement, do not remove 29 #include "precompiled_sw.hxx" 30 31 32 #include <tools/debug.hxx> 33 #include <com/sun/star/uno/Any.hxx> 34 #include <com/sun/star/uno/Sequence.hxx> 35 #include <wrtsh.hxx> 36 #include "barcfg.hxx" 37 38 #include <unomid.h> 39 40 using namespace utl; 41 using rtl::OUString; 42 using namespace com::sun::star::uno; 43 44 #define SEL_TYPE_TABLE_TEXT 0 45 #define SEL_TYPE_LIST_TEXT 1 46 #define SEL_TYPE_TABLE_LIST 2 47 #define SEL_TYPE_BEZIER 3 48 #define SEL_TYPE_GRAPHIC 4 49 50 /* --------------------------------------------------------------------------- 51 52 ---------------------------------------------------------------------------*/ 53 SwToolbarConfigItem::SwToolbarConfigItem( sal_Bool bWeb ) : 54 ConfigItem(bWeb ? C2U("Office.WriterWeb/ObjectBar") : C2U("Office.Writer/ObjectBar"), 55 CONFIG_MODE_DELAYED_UPDATE|CONFIG_MODE_RELEASE_TREE) 56 { 57 for(sal_uInt16 i = 0; i <= SEL_TYPE_GRAPHIC; i++ ) 58 aTbxIdArray[i] = -1; 59 60 Sequence<OUString> aNames = GetPropertyNames(); 61 Sequence<Any> aValues = GetProperties(aNames); 62 const Any* pValues = aValues.getConstArray(); 63 DBG_ASSERT(aValues.getLength() == aNames.getLength(), "GetProperties failed"); 64 if(aValues.getLength() == aNames.getLength()) 65 { 66 for(int nProp = 0; nProp < aNames.getLength(); nProp++) 67 { 68 if(pValues[nProp].hasValue()) 69 { 70 sal_Int32 nVal = 0; 71 pValues[nProp] >>= nVal; 72 aTbxIdArray[nProp] = nVal; 73 } 74 } 75 } 76 } 77 /* --------------------------------------------------------------------------- 78 79 ---------------------------------------------------------------------------*/ 80 SwToolbarConfigItem::~SwToolbarConfigItem() 81 { 82 } 83 /* --------------------------------------------------------------------------- 84 85 ---------------------------------------------------------------------------*/ 86 sal_Int32 lcl_getArrayIndex(int nSelType) 87 { 88 sal_Int32 nRet = -1; 89 if(nSelType & nsSelectionType::SEL_NUM) 90 { 91 if(nSelType & nsSelectionType::SEL_TBL) 92 nRet = SEL_TYPE_TABLE_LIST; 93 else 94 nRet = SEL_TYPE_LIST_TEXT; 95 } 96 else if(nSelType & nsSelectionType::SEL_TBL) 97 nRet = SEL_TYPE_TABLE_TEXT; 98 else if(nSelType & nsSelectionType::SEL_BEZ) 99 nRet = SEL_TYPE_BEZIER; 100 else if(nSelType & nsSelectionType::SEL_GRF) 101 nRet = SEL_TYPE_GRAPHIC; 102 return nRet; 103 } 104 /* -----------------------------10.10.00 14:38-------------------------------- 105 106 ---------------------------------------------------------------------------*/ 107 void SwToolbarConfigItem::SetTopToolbar( sal_Int32 nSelType, sal_Int32 nBarId ) 108 { 109 sal_Int32 nProp = lcl_getArrayIndex(nSelType); 110 if(nProp >= 0) 111 { 112 aTbxIdArray[nProp] = nBarId; 113 SetModified(); 114 } 115 } 116 /* -----------------------------10.10.00 13:33-------------------------------- 117 118 ---------------------------------------------------------------------------*/ 119 Sequence<OUString> SwToolbarConfigItem::GetPropertyNames() 120 { 121 static const char* aPropNames[] = 122 { 123 "Selection/Table", // SEL_TYPE_TABLE_TEXT 124 "Selection/NumberedList", // SEL_TYPE_LIST_TEXT 125 "Selection/NumberedList_InTable", // SEL_TYPE_TABLE_LIST 126 "Selection/BezierObject", // SEL_TYPE_BEZIER 127 "Selection/Graphic" //SEL_TYPE_GRAPHIC 128 }; 129 const int nCount = 5; 130 Sequence<OUString> aNames(nCount); 131 OUString* pNames = aNames.getArray(); 132 for(int i = 0; i < nCount; i++) 133 pNames[i] = OUString::createFromAscii(aPropNames[i]); 134 return aNames; 135 } 136 /* -----------------------------10.10.00 13:36-------------------------------- 137 138 ---------------------------------------------------------------------------*/ 139 void SwToolbarConfigItem::Commit() 140 { 141 Sequence<OUString> aNames = GetPropertyNames(); 142 143 Sequence<Any> aValues(aNames.getLength()); 144 Any* pValues = aValues.getArray(); 145 146 for(int nProp = 0; nProp < aNames.getLength(); nProp++) 147 pValues[nProp] <<= aTbxIdArray[nProp]; 148 PutProperties(aNames, aValues); 149 } 150 151 void SwToolbarConfigItem::Notify( const ::com::sun::star::uno::Sequence< rtl::OUString >& ) {} 152 153