Branch data Line data Source code
1 : : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 : : /*************************************************************************
3 : : *
4 : : * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 : : *
6 : : * Copyright 2000, 2010 Oracle and/or its affiliates.
7 : : *
8 : : * OpenOffice.org - a multi-platform office productivity suite
9 : : *
10 : : * This file is part of OpenOffice.org.
11 : : *
12 : : * OpenOffice.org is free software: you can redistribute it and/or modify
13 : : * it under the terms of the GNU Lesser General Public License version 3
14 : : * only, as published by the Free Software Foundation.
15 : : *
16 : : * OpenOffice.org is distributed in the hope that it will be useful,
17 : : * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 : : * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 : : * GNU Lesser General Public License version 3 for more details
20 : : * (a copy is included in the LICENSE file that accompanied this code).
21 : : *
22 : : * You should have received a copy of the GNU Lesser General Public License
23 : : * version 3 along with OpenOffice.org. If not, see
24 : : * <http://www.openoffice.org/license.html>
25 : : * for a copy of the LGPLv3 License.
26 : : *
27 : : ************************************************************************/
28 : :
29 : : #include "scitems.hxx"
30 : : #include <editeng/memberids.hrc>
31 : : #include <tools/shl.hxx>
32 : : #include <svl/poolitem.hxx>
33 : : #include <vcl/svapp.hxx>
34 : : #include <svx/unomid.hxx>
35 : : #include "unowids.hxx"
36 : : #include <comphelper/servicehelper.hxx>
37 : : #include <com/sun/star/table/BorderLine.hpp>
38 : : #include <com/sun/star/table/CellVertJustify2.hpp>
39 : : #include <com/sun/star/table/ShadowLocation.hpp>
40 : : #include <com/sun/star/table/TableBorder.hpp>
41 : : #include <com/sun/star/table/ShadowFormat.hpp>
42 : : #include <com/sun/star/table/CellRangeAddress.hpp>
43 : : #include <com/sun/star/table/CellContentType.hpp>
44 : : #include <com/sun/star/table/TableOrientation.hpp>
45 : : #include <com/sun/star/table/CellHoriJustify.hpp>
46 : : #include <com/sun/star/util/SortField.hpp>
47 : : #include <com/sun/star/util/SortFieldType.hpp>
48 : : #include <com/sun/star/table/CellOrientation.hpp>
49 : : #include <com/sun/star/table/CellAddress.hpp>
50 : : #include <com/sun/star/awt/SimpleFontMetric.hpp>
51 : : #include <com/sun/star/awt/FontWeight.hpp>
52 : : #include <com/sun/star/awt/FontSlant.hpp>
53 : : #include <com/sun/star/awt/CharSet.hpp>
54 : : #include <com/sun/star/awt/FontDescriptor.hpp>
55 : : #include <com/sun/star/awt/FontWidth.hpp>
56 : : #include <com/sun/star/awt/XFont.hpp>
57 : : #include <com/sun/star/awt/FontType.hpp>
58 : : #include <com/sun/star/awt/FontUnderline.hpp>
59 : : #include <com/sun/star/awt/FontStrikeout.hpp>
60 : : #include <com/sun/star/awt/FontFamily.hpp>
61 : : #include <com/sun/star/awt/FontPitch.hpp>
62 : :
63 : : #include "afmtuno.hxx"
64 : : #include "miscuno.hxx"
65 : : #include "autoform.hxx"
66 : : #include "scdll.hxx"
67 : : #include "unonames.hxx"
68 : : #include "cellsuno.hxx"
69 : :
70 : : using namespace ::com::sun::star;
71 : :
72 : : //------------------------------------------------------------------------
73 : :
74 : : // ein AutoFormat hat immer 16 Eintraege
75 : : #define SC_AF_FIELD_COUNT 16
76 : :
77 : : //------------------------------------------------------------------------
78 : :
79 : : // AutoFormat-Map nur fuer PropertySetInfo, ohne Which-IDs
80 : :
81 : 27 : const SfxItemPropertyMapEntry* lcl_GetAutoFormatMap()
82 : : {
83 : : static SfxItemPropertyMapEntry aAutoFormatMap_Impl[] =
84 : : {
85 [ + - ]: 1 : {MAP_CHAR_LEN(SC_UNONAME_INCBACK), 0, &::getBooleanCppuType(), 0, 0 },
86 [ + - ]: 1 : {MAP_CHAR_LEN(SC_UNONAME_INCBORD), 0, &::getBooleanCppuType(), 0, 0 },
87 [ + - ]: 1 : {MAP_CHAR_LEN(SC_UNONAME_INCFONT), 0, &::getBooleanCppuType(), 0, 0 },
88 [ + - ]: 1 : {MAP_CHAR_LEN(SC_UNONAME_INCJUST), 0, &::getBooleanCppuType(), 0, 0 },
89 [ + - ]: 1 : {MAP_CHAR_LEN(SC_UNONAME_INCNUM), 0, &::getBooleanCppuType(), 0, 0 },
90 [ + - ]: 1 : {MAP_CHAR_LEN(SC_UNONAME_INCWIDTH), 0, &::getBooleanCppuType(), 0, 0 },
91 : : {0,0,0,0,0,0}
92 [ + + ][ + - ]: 28 : };
[ # # ]
93 : 27 : return aAutoFormatMap_Impl;
94 : : }
95 : :
96 : : //! Zahlformat (String/Language) ??? (in XNumberFormat nur ReadOnly)
97 : : //! table::TableBorder ??!?
98 : :
99 : 4 : const SfxItemPropertyMapEntry* lcl_GetAutoFieldMap()
100 : : {
101 : : static SfxItemPropertyMapEntry aAutoFieldMap_Impl[] =
102 : : {
103 [ + - ]: 1 : {MAP_CHAR_LEN(SC_UNONAME_CELLBACK), ATTR_BACKGROUND, &::getCppuType((const sal_Int32*)0), 0, MID_BACK_COLOR },
104 [ + - ]: 1 : {MAP_CHAR_LEN(SC_UNONAME_CCOLOR), ATTR_FONT_COLOR, &::getCppuType((const sal_Int32*)0), 0, 0 },
105 [ + - ]: 1 : {MAP_CHAR_LEN(SC_UNONAME_COUTL), ATTR_FONT_CONTOUR, &::getBooleanCppuType(), 0, 0 },
106 [ + - ]: 1 : {MAP_CHAR_LEN(SC_UNONAME_CCROSS), ATTR_FONT_CROSSEDOUT, &::getBooleanCppuType(), 0, MID_CROSSED_OUT },
107 [ + - ]: 1 : {MAP_CHAR_LEN(SC_UNONAME_CFONT), ATTR_FONT, &::getCppuType((const sal_Int16*)0), 0, MID_FONT_FAMILY },
108 [ + - ]: 1 : {MAP_CHAR_LEN(SC_UNONAME_CFCHARS), ATTR_FONT, &::getCppuType((sal_Int16*)0), 0, MID_FONT_CHAR_SET },
109 [ + - ]: 1 : {MAP_CHAR_LEN(SC_UNO_CJK_CFCHARS), ATTR_CJK_FONT, &::getCppuType((sal_Int16*)0), 0, MID_FONT_CHAR_SET },
110 [ + - ]: 1 : {MAP_CHAR_LEN(SC_UNO_CTL_CFCHARS), ATTR_CTL_FONT, &::getCppuType((sal_Int16*)0), 0, MID_FONT_CHAR_SET },
111 [ + - ]: 1 : {MAP_CHAR_LEN(SC_UNONAME_CFFAMIL), ATTR_FONT, &::getCppuType((sal_Int16*)0), 0, MID_FONT_FAMILY },
112 [ + - ]: 1 : {MAP_CHAR_LEN(SC_UNO_CJK_CFFAMIL), ATTR_CJK_FONT, &::getCppuType((sal_Int16*)0), 0, MID_FONT_FAMILY },
113 [ + - ]: 1 : {MAP_CHAR_LEN(SC_UNO_CTL_CFFAMIL), ATTR_CTL_FONT, &::getCppuType((sal_Int16*)0), 0, MID_FONT_FAMILY },
114 [ + - ]: 1 : {MAP_CHAR_LEN(SC_UNONAME_CFNAME), ATTR_FONT, &::getCppuType((rtl::OUString*)0), 0, MID_FONT_FAMILY_NAME },
115 [ + - ]: 1 : {MAP_CHAR_LEN(SC_UNO_CJK_CFNAME), ATTR_CJK_FONT, &::getCppuType((rtl::OUString*)0), 0, MID_FONT_FAMILY_NAME },
116 [ + - ]: 1 : {MAP_CHAR_LEN(SC_UNO_CTL_CFNAME), ATTR_CTL_FONT, &::getCppuType((rtl::OUString*)0), 0, MID_FONT_FAMILY_NAME },
117 [ + - ]: 1 : {MAP_CHAR_LEN(SC_UNONAME_CFPITCH), ATTR_FONT, &::getCppuType((sal_Int16*)0), 0, MID_FONT_PITCH },
118 [ + - ]: 1 : {MAP_CHAR_LEN(SC_UNO_CJK_CFPITCH), ATTR_CJK_FONT, &::getCppuType((sal_Int16*)0), 0, MID_FONT_PITCH },
119 [ + - ]: 1 : {MAP_CHAR_LEN(SC_UNO_CTL_CFPITCH), ATTR_CTL_FONT, &::getCppuType((sal_Int16*)0), 0, MID_FONT_PITCH },
120 [ + - ]: 1 : {MAP_CHAR_LEN(SC_UNONAME_CFSTYLE), ATTR_FONT, &::getCppuType((rtl::OUString*)0), 0, MID_FONT_STYLE_NAME },
121 [ + - ]: 1 : {MAP_CHAR_LEN(SC_UNO_CJK_CFSTYLE), ATTR_CJK_FONT, &::getCppuType((rtl::OUString*)0), 0, MID_FONT_STYLE_NAME },
122 [ + - ]: 1 : {MAP_CHAR_LEN(SC_UNO_CTL_CFSTYLE), ATTR_CTL_FONT, &::getCppuType((rtl::OUString*)0), 0, MID_FONT_STYLE_NAME },
123 [ + - ]: 1 : {MAP_CHAR_LEN(SC_UNONAME_CHEIGHT), ATTR_FONT_HEIGHT, &::getCppuType((float*)0), 0, MID_FONTHEIGHT | CONVERT_TWIPS },
124 [ + - ]: 1 : {MAP_CHAR_LEN(SC_UNO_CJK_CHEIGHT), ATTR_CJK_FONT_HEIGHT, &::getCppuType((float*)0), 0, MID_FONTHEIGHT | CONVERT_TWIPS },
125 [ + - ]: 1 : {MAP_CHAR_LEN(SC_UNO_CTL_CHEIGHT), ATTR_CTL_FONT_HEIGHT, &::getCppuType((float*)0), 0, MID_FONTHEIGHT | CONVERT_TWIPS },
126 [ + - ]: 1 : {MAP_CHAR_LEN(SC_UNONAME_COVER), ATTR_FONT_OVERLINE, &::getCppuType((const sal_Int16*)0), 0, MID_TL_STYLE },
127 [ + - ]: 1 : {MAP_CHAR_LEN(SC_UNONAME_CPOST), ATTR_FONT_POSTURE, &::getCppuType((awt::FontSlant*)0), 0, MID_POSTURE },
128 [ + - ]: 1 : {MAP_CHAR_LEN(SC_UNO_CJK_CPOST), ATTR_CJK_FONT_POSTURE, &::getCppuType((awt::FontSlant*)0), 0, MID_POSTURE },
129 [ + - ]: 1 : {MAP_CHAR_LEN(SC_UNO_CTL_CPOST), ATTR_CTL_FONT_POSTURE, &::getCppuType((awt::FontSlant*)0), 0, MID_POSTURE },
130 [ + - ]: 1 : {MAP_CHAR_LEN(SC_UNONAME_CSHADD), ATTR_FONT_SHADOWED, &::getBooleanCppuType(), 0, 0 },
131 [ + - ]: 1 : {MAP_CHAR_LEN(SC_UNONAME_TBLBORD), SC_WID_UNO_TBLBORD, &::getCppuType((table::TableBorder*)0), 0, 0 | CONVERT_TWIPS },
132 [ + - ]: 1 : {MAP_CHAR_LEN(SC_UNONAME_TBLBORD2), SC_WID_UNO_TBLBORD2, &::getCppuType((table::TableBorder2*)0), 0, 0 | CONVERT_TWIPS },
133 [ + - ]: 1 : {MAP_CHAR_LEN(SC_UNONAME_CUNDER), ATTR_FONT_UNDERLINE, &::getCppuType((const sal_Int16*)0), 0, MID_TL_STYLE },
134 [ + - ]: 1 : {MAP_CHAR_LEN(SC_UNONAME_CWEIGHT), ATTR_FONT_WEIGHT, &::getCppuType((float*)0), 0, MID_WEIGHT },
135 [ + - ]: 1 : {MAP_CHAR_LEN(SC_UNO_CJK_CWEIGHT), ATTR_CJK_FONT_WEIGHT, &::getCppuType((float*)0), 0, MID_WEIGHT },
136 [ + - ]: 1 : {MAP_CHAR_LEN(SC_UNO_CTL_CWEIGHT), ATTR_CTL_FONT_WEIGHT, &::getCppuType((float*)0), 0, MID_WEIGHT },
137 [ + - ]: 1 : {MAP_CHAR_LEN(SC_UNONAME_CELLHJUS), ATTR_HOR_JUSTIFY, &::getCppuType((const table::CellHoriJustify*)0), 0, 0 },
138 [ + - ]: 1 : {MAP_CHAR_LEN(SC_UNONAME_CELLHJUS_METHOD), ATTR_HOR_JUSTIFY_METHOD, &::getCppuType((const sal_Int32*)0), 0, 0 },
139 [ + - ]: 1 : {MAP_CHAR_LEN(SC_UNONAME_CELLTRAN), ATTR_BACKGROUND, &::getBooleanCppuType(), 0, MID_GRAPHIC_TRANSPARENT },
140 [ + - ]: 1 : {MAP_CHAR_LEN(SC_UNONAME_WRAP), ATTR_LINEBREAK, &::getBooleanCppuType(), 0, 0 },
141 [ + - ]: 1 : {MAP_CHAR_LEN(SC_UNONAME_CELLORI), ATTR_STACKED, &::getCppuType((const table::CellOrientation*)0), 0, 0 },
142 [ + - ]: 1 : {MAP_CHAR_LEN(SC_UNONAME_PBMARGIN), ATTR_MARGIN, &::getCppuType((const sal_Int32*)0), 0, MID_MARGIN_LO_MARGIN | CONVERT_TWIPS },
143 [ + - ]: 1 : {MAP_CHAR_LEN(SC_UNONAME_PLMARGIN), ATTR_MARGIN, &::getCppuType((const sal_Int32*)0), 0, MID_MARGIN_L_MARGIN | CONVERT_TWIPS },
144 [ + - ]: 1 : {MAP_CHAR_LEN(SC_UNONAME_PRMARGIN), ATTR_MARGIN, &::getCppuType((const sal_Int32*)0), 0, MID_MARGIN_R_MARGIN | CONVERT_TWIPS },
145 [ + - ]: 1 : {MAP_CHAR_LEN(SC_UNONAME_PTMARGIN), ATTR_MARGIN, &::getCppuType((const sal_Int32*)0), 0, MID_MARGIN_UP_MARGIN | CONVERT_TWIPS },
146 [ + - ]: 1 : {MAP_CHAR_LEN(SC_UNONAME_ROTANG), ATTR_ROTATE_VALUE, &::getCppuType((const sal_Int32*)0), 0, 0 },
147 [ + - ]: 1 : {MAP_CHAR_LEN(SC_UNONAME_ROTREF), ATTR_ROTATE_MODE, &::getCppuType((const sal_Int32*)0), 0, 0 },
148 [ + - ]: 1 : {MAP_CHAR_LEN(SC_UNONAME_CELLVJUS), ATTR_VER_JUSTIFY, &::getCppuType((const sal_Int32*)0), 0, 0 },
149 [ + - ]: 1 : {MAP_CHAR_LEN(SC_UNONAME_CELLVJUS_METHOD), ATTR_VER_JUSTIFY_METHOD, &::getCppuType((const sal_Int32*)0), 0, 0 },
150 : : {0,0,0,0,0,0}
151 [ + + ][ + - ]: 5 : };
[ # # ]
152 : 4 : return aAutoFieldMap_Impl;
153 : : }
154 : :
155 : : //------------------------------------------------------------------------
156 : :
157 : : #define SCAUTOFORMATSOBJ_SERVICE "com.sun.star.sheet.TableAutoFormats"
158 : :
159 [ # # ]: 0 : SC_SIMPLE_SERVICE_INFO( ScAutoFormatFieldObj, "ScAutoFormatFieldObj", "com.sun.star.sheet.TableAutoFormatField" )
160 [ # # ]: 1 : SC_SIMPLE_SERVICE_INFO( ScAutoFormatObj, "ScAutoFormatObj", "com.sun.star.sheet.TableAutoFormat" )
161 [ # # ]: 0 : SC_SIMPLE_SERVICE_INFO( ScAutoFormatsObj, "ScAutoFormatsObj", SCAUTOFORMATSOBJ_SERVICE )
162 : :
163 : : //------------------------------------------------------------------------
164 : :
165 : 11 : bool lcl_FindAutoFormatIndex( const ScAutoFormat& rFormats, const rtl::OUString& rName, sal_uInt16& rOutIndex )
166 : : {
167 [ + - ][ + - ]: 11 : ScAutoFormat::const_iterator itBeg = rFormats.begin(), itEnd = rFormats.end();
168 [ + - ][ + - ]: 161 : for (ScAutoFormat::const_iterator it = itBeg; it != itEnd; ++it)
[ + + ]
169 : : {
170 [ + - ]: 155 : const ScAutoFormatData* pEntry = it->second;
171 : 155 : const rtl::OUString& aEntryName = pEntry->GetName();
172 [ + + ]: 155 : if ( aEntryName.equals(rName) )
173 : : {
174 [ + - ]: 5 : size_t nPos = std::distance(itBeg, it);
175 : 5 : rOutIndex = nPos;
176 : 5 : return true;
177 : : }
178 : : }
179 : 11 : return false; // is nich
180 : : }
181 : :
182 : : //------------------------------------------------------------------------
183 : :
184 : 1 : ScAutoFormatsObj::ScAutoFormatsObj()
185 : : {
186 : : //! Dieses Objekt darf es nur einmal geben, und es muss an den Auto-Format-Daten
187 : : //! bekannt sein, damit Aenderungen gebroadcasted werden koennen
188 : 1 : }
189 : :
190 : 1 : ScAutoFormatsObj::~ScAutoFormatsObj()
191 : : {
192 [ - + ]: 2 : }
193 : :
194 : : // stuff for exService_...
195 : :
196 : 1 : uno::Reference<uno::XInterface> SAL_CALL ScAutoFormatsObj_CreateInstance(
197 : : const uno::Reference<lang::XMultiServiceFactory>& )
198 : : {
199 [ + - ]: 1 : SolarMutexGuard aGuard;
200 [ + - ]: 1 : ScDLL::Init();
201 [ + - ][ + - ]: 1 : static uno::Reference< uno::XInterface > xInst((::cppu::OWeakObject*) new ScAutoFormatsObj);
[ + - ][ + - ]
[ # # ]
202 [ + - ]: 1 : return xInst;
203 : : }
204 : :
205 : 182 : rtl::OUString ScAutoFormatsObj::getImplementationName_Static()
206 : : {
207 : 182 : return rtl::OUString(RTL_CONSTASCII_USTRINGPARAM( "stardiv.StarCalc.ScAutoFormatsObj" ));
208 : : }
209 : :
210 : 1 : uno::Sequence<rtl::OUString> ScAutoFormatsObj::getSupportedServiceNames_Static()
211 : : {
212 : 1 : uno::Sequence<rtl::OUString> aRet(1);
213 [ + - ]: 1 : rtl::OUString* pArray = aRet.getArray();
214 [ + - ]: 1 : pArray[0] = rtl::OUString(RTL_CONSTASCII_USTRINGPARAM( SCAUTOFORMATSOBJ_SERVICE ));
215 : 1 : return aRet;
216 : : }
217 : :
218 : : // XTableAutoFormats
219 : :
220 : 26 : ScAutoFormatObj* ScAutoFormatsObj::GetObjectByIndex_Impl(sal_uInt16 nIndex)
221 : : {
222 [ + + ]: 26 : if (nIndex < ScGlobal::GetOrCreateAutoFormat()->size())
223 [ + - ]: 24 : return new ScAutoFormatObj(nIndex);
224 : :
225 : 26 : return NULL; // falscher Index
226 : : }
227 : :
228 : 2 : ScAutoFormatObj* ScAutoFormatsObj::GetObjectByName_Impl(const rtl::OUString& aName)
229 : : {
230 [ + - ]: 2 : String aString(aName);
231 : : sal_uInt16 nIndex;
232 [ + - + + ]: 4 : if (lcl_FindAutoFormatIndex(
233 [ + - ][ + - ]: 4 : *ScGlobal::GetOrCreateAutoFormat(), aString, nIndex ))
234 [ + - ]: 1 : return GetObjectByIndex_Impl(nIndex);
235 [ + - ]: 2 : return NULL;
236 : : }
237 : :
238 : : // container::XNameContainer
239 : :
240 : 3 : void SAL_CALL ScAutoFormatsObj::insertByName( const rtl::OUString& aName, const uno::Any& aElement )
241 : : throw(lang::IllegalArgumentException, container::ElementExistException,
242 : : lang::WrappedTargetException, uno::RuntimeException)
243 : : {
244 [ + - ]: 3 : SolarMutexGuard aGuard;
245 : 3 : sal_Bool bDone = false;
246 : : // Reflection muss nicht uno::XInterface sein, kann auch irgendein Interface sein...
247 [ + - ]: 3 : uno::Reference< uno::XInterface > xInterface(aElement, uno::UNO_QUERY);
248 [ + + ]: 3 : if ( xInterface.is() )
249 : : {
250 [ + - ]: 2 : ScAutoFormatObj* pFormatObj = ScAutoFormatObj::getImplementation( xInterface );
251 [ + - ][ + - ]: 2 : if ( pFormatObj && !pFormatObj->IsInserted() ) // noch nicht eingefuegt?
[ + - ]
252 : : {
253 [ + - ]: 2 : String aNameStr(aName);
254 [ + - ]: 2 : ScAutoFormat* pFormats = ScGlobal::GetOrCreateAutoFormat();
255 : :
256 : : sal_uInt16 nDummy;
257 [ + - ][ + - ]: 2 : if (!lcl_FindAutoFormatIndex( *pFormats, aNameStr, nDummy ))
[ + + ]
258 : : {
259 [ + - ][ + - ]: 1 : ScAutoFormatData* pNew = new ScAutoFormatData();
260 [ + - ]: 1 : pNew->SetName( aNameStr );
261 : :
262 [ + - ][ + - ]: 1 : if (pFormats->insert(pNew))
263 : : {
264 : : //! Notify fuer andere Objekte
265 [ + - ]: 1 : pFormats->Save(); // sofort speichern
266 : :
267 : : sal_uInt16 nNewIndex;
268 [ + - ][ + - ]: 1 : if (lcl_FindAutoFormatIndex( *pFormats, aNameStr, nNewIndex ))
[ + - ]
269 : : {
270 : 1 : pFormatObj->InitFormat( nNewIndex ); // kann jetzt benutzt werden
271 : 1 : bDone = sal_True;
272 : : }
273 : : }
274 : : else
275 : : {
276 : : OSL_FAIL("AutoFormat konnte nicht eingefuegt werden");
277 [ # # ]: 0 : throw uno::RuntimeException();
278 : : }
279 : : }
280 : : else
281 : : {
282 [ + - ]: 2 : throw container::ElementExistException();
283 [ + - ]: 2 : }
284 : : }
285 : : }
286 : :
287 [ + + ]: 2 : if (!bDone)
288 : : {
289 : : // other errors are handled above
290 [ + - ]: 1 : throw lang::IllegalArgumentException();
291 [ + - ]: 3 : }
292 : 1 : }
293 : :
294 : 0 : void SAL_CALL ScAutoFormatsObj::replaceByName( const rtl::OUString& aName, const uno::Any& aElement )
295 : : throw(lang::IllegalArgumentException, container::NoSuchElementException,
296 : : lang::WrappedTargetException, uno::RuntimeException)
297 : : {
298 [ # # ]: 0 : SolarMutexGuard aGuard;
299 : : //! zusammenfassen?
300 [ # # ]: 0 : removeByName( aName );
301 [ # # ][ # # ]: 0 : insertByName( aName, aElement );
302 : 0 : }
303 : :
304 : 2 : void SAL_CALL ScAutoFormatsObj::removeByName( const rtl::OUString& aName )
305 : : throw(container::NoSuchElementException,
306 : : lang::WrappedTargetException, uno::RuntimeException)
307 : : {
308 [ + - ]: 2 : SolarMutexGuard aGuard;
309 [ + - ]: 2 : String aNameStr(aName);
310 [ + - ]: 2 : ScAutoFormat* pFormats = ScGlobal::GetOrCreateAutoFormat();
311 : :
312 [ + - ]: 2 : ScAutoFormat::iterator it = pFormats->find(aName);
313 [ + - ][ + - ]: 2 : if (it != pFormats->end())
[ + + ]
314 : : {
315 [ + - ]: 1 : pFormats->erase(it);
316 : :
317 : : //! Notify fuer andere Objekte
318 [ + - ]: 1 : pFormats->Save(); // sofort speichern
319 : : }
320 : : else
321 : : {
322 [ + - ]: 1 : throw container::NoSuchElementException();
323 [ + - ][ + - ]: 2 : }
324 : 1 : }
325 : :
326 : : // container::XEnumerationAccess
327 : :
328 : 2 : uno::Reference<container::XEnumeration> SAL_CALL ScAutoFormatsObj::createEnumeration()
329 : : throw(uno::RuntimeException)
330 : : {
331 [ + - ]: 2 : SolarMutexGuard aGuard;
332 [ + - ][ + - ]: 2 : return new ScIndexEnumeration(this, rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.sheet.TableAutoFormatEnumeration")));
[ + - ][ + - ]
[ + - ][ + - ]
333 : : }
334 : :
335 : : // container::XIndexAccess
336 : :
337 : 22 : sal_Int32 SAL_CALL ScAutoFormatsObj::getCount() throw(uno::RuntimeException)
338 : : {
339 [ + - ]: 22 : SolarMutexGuard aGuard;
340 [ + - ][ + - ]: 22 : return ScGlobal::GetOrCreateAutoFormat()->size();
[ + - ]
341 : : }
342 : :
343 : 25 : uno::Any SAL_CALL ScAutoFormatsObj::getByIndex( sal_Int32 nIndex )
344 : : throw(lang::IndexOutOfBoundsException,
345 : : lang::WrappedTargetException, uno::RuntimeException)
346 : : {
347 [ + - ]: 25 : SolarMutexGuard aGuard;
348 [ + - ][ + + ]: 25 : uno::Reference< container::XNamed > xFormat(GetObjectByIndex_Impl((sal_uInt16)nIndex));
[ + - ]
349 [ + + ]: 25 : if (!xFormat.is())
350 [ + - ]: 2 : throw lang::IndexOutOfBoundsException();
351 [ + - ][ + - ]: 25 : return uno::makeAny(xFormat);
352 : : }
353 : :
354 : 1 : uno::Type SAL_CALL ScAutoFormatsObj::getElementType() throw(uno::RuntimeException)
355 : : {
356 [ + - ]: 1 : SolarMutexGuard aGuard;
357 [ + - ][ + - ]: 1 : return ::getCppuType((const uno::Reference< container::XNamed >*)0); // muss zu getByIndex passen
358 : : }
359 : :
360 : 1 : sal_Bool SAL_CALL ScAutoFormatsObj::hasElements() throw(uno::RuntimeException)
361 : : {
362 [ + - ]: 1 : SolarMutexGuard aGuard;
363 [ + - ][ + - ]: 1 : return ( getCount() != 0 );
364 : : }
365 : :
366 : : // container::XNameAccess
367 : :
368 : 2 : uno::Any SAL_CALL ScAutoFormatsObj::getByName( const rtl::OUString& aName )
369 : : throw(container::NoSuchElementException,
370 : : lang::WrappedTargetException, uno::RuntimeException)
371 : : {
372 [ + - ]: 2 : SolarMutexGuard aGuard;
373 [ + - ][ + + ]: 2 : uno::Reference< container::XNamed > xFormat(GetObjectByName_Impl(aName));
[ + - ]
374 [ + + ]: 2 : if (!xFormat.is())
375 [ + - ]: 1 : throw container::NoSuchElementException();
376 [ + - ][ + - ]: 2 : return uno::makeAny(xFormat);
377 : : }
378 : :
379 : 4 : uno::Sequence<rtl::OUString> SAL_CALL ScAutoFormatsObj::getElementNames()
380 : : throw(uno::RuntimeException)
381 : : {
382 [ + - ]: 4 : SolarMutexGuard aGuard;
383 [ + - ]: 4 : ScAutoFormat* pFormats = ScGlobal::GetOrCreateAutoFormat();
384 [ + - ]: 4 : String aName;
385 [ + - ][ + - ]: 4 : uno::Sequence<rtl::OUString> aSeq(pFormats->size());
386 [ + - ]: 4 : rtl::OUString* pAry = aSeq.getArray();
387 [ + - ][ + - ]: 4 : ScAutoFormat::const_iterator it = pFormats->begin(), itEnd = pFormats->end();
[ + - ][ + - ]
388 [ + - ][ + - ]: 74 : for (size_t i = 0; it != itEnd; ++it, ++i)
[ + + ]
389 : : {
390 [ + - ]: 70 : pAry[i] = it->second->GetName();
391 : : }
392 [ + - ][ + - ]: 4 : return aSeq;
393 : : }
394 : :
395 : 4 : sal_Bool SAL_CALL ScAutoFormatsObj::hasByName( const rtl::OUString& aName )
396 : : throw(uno::RuntimeException)
397 : : {
398 [ + - ]: 4 : SolarMutexGuard aGuard;
399 [ + - ]: 4 : String aString(aName);
400 : : sal_uInt16 nDummy;
401 : : return lcl_FindAutoFormatIndex(
402 [ + - ][ + - ]: 4 : *ScGlobal::GetOrCreateAutoFormat(), aString, nDummy );
[ + - ][ + - ]
[ + - ]
403 : : }
404 : :
405 : : //------------------------------------------------------------------------
406 : :
407 : 27 : ScAutoFormatObj::ScAutoFormatObj(sal_uInt16 nIndex) :
408 : : aPropSet( lcl_GetAutoFormatMap() ),
409 [ + - ][ + - ]: 27 : nFormatIndex( nIndex )
[ + - ]
410 : : {
411 : : //! Listening !!!
412 : 27 : }
413 : :
414 [ + - ][ + - ]: 27 : ScAutoFormatObj::~ScAutoFormatObj()
415 : : {
416 : : // Wenn ein AutoFormat-Objekt losgelassen wird, werden eventuelle Aenderungen
417 : : // gespeichert, damit sie z.B. im Writer sichtbar sind
418 : :
419 [ + + ]: 27 : if (IsInserted())
420 : : {
421 [ + - ]: 25 : ScAutoFormat* pFormats = ScGlobal::GetAutoFormat();
422 [ - + ][ # # ]: 25 : if ( pFormats && pFormats->IsSaveLater() )
[ - + ]
423 [ # # ]: 0 : pFormats->Save();
424 : :
425 : : // Save() setzt SaveLater Flag zurueck
426 : : }
427 [ - + ]: 54 : }
428 : :
429 : 1 : void ScAutoFormatObj::InitFormat( sal_uInt16 nNewIndex )
430 : : {
431 : : OSL_ENSURE( nFormatIndex == SC_AFMTOBJ_INVALID, "ScAutoFormatObj::InitFormat mehrfach" );
432 : 1 : nFormatIndex = nNewIndex;
433 : : //! Listening !!!
434 : 1 : }
435 : :
436 : : // XUnoTunnel
437 : :
438 : 2 : sal_Int64 SAL_CALL ScAutoFormatObj::getSomething(
439 : : const uno::Sequence<sal_Int8 >& rId ) throw(uno::RuntimeException)
440 : : {
441 [ + - + - ]: 4 : if ( rId.getLength() == 16 &&
[ + - ]
442 : 2 : 0 == memcmp( getUnoTunnelId().getConstArray(),
443 : 2 : rId.getConstArray(), 16 ) )
444 : : {
445 : 2 : return sal::static_int_cast<sal_Int64>(reinterpret_cast<sal_IntPtr>(this));
446 : : }
447 : 2 : return 0;
448 : : }
449 : :
450 : : namespace
451 : : {
452 : : class theScAutoFormatObjUnoTunnelId : public rtl::Static< UnoTunnelIdInit, theScAutoFormatObjUnoTunnelId> {};
453 : : }
454 : :
455 : 4 : const uno::Sequence<sal_Int8>& ScAutoFormatObj::getUnoTunnelId()
456 : : {
457 : 4 : return theScAutoFormatObjUnoTunnelId::get().getSeq();
458 : : }
459 : :
460 : 2 : ScAutoFormatObj* ScAutoFormatObj::getImplementation(
461 : : const uno::Reference<uno::XInterface> xObj )
462 : : {
463 : 2 : ScAutoFormatObj* pRet = NULL;
464 [ + - ]: 2 : uno::Reference<lang::XUnoTunnel> xUT( xObj, uno::UNO_QUERY );
465 [ + - ]: 2 : if (xUT.is())
466 [ + - ][ + - ]: 2 : pRet = reinterpret_cast<ScAutoFormatObj*>(sal::static_int_cast<sal_IntPtr>(xUT->getSomething(getUnoTunnelId())));
[ + - ]
467 : 2 : return pRet;
468 : : }
469 : :
470 : 0 : void ScAutoFormatObj::Notify( SfxBroadcaster& /* rBC */, const SfxHint& /* rHint */ )
471 : : {
472 : : // spaeter...
473 : 0 : }
474 : :
475 : : // XTableAutoFormat
476 : :
477 : 4 : ScAutoFormatFieldObj* ScAutoFormatObj::GetObjectByIndex_Impl(sal_uInt16 nIndex)
478 : : {
479 [ + - ][ + - ]: 4 : if ( IsInserted() && nIndex < SC_AF_FIELD_COUNT )
[ + - ]
480 [ + - ]: 4 : return new ScAutoFormatFieldObj( nFormatIndex, nIndex );
481 : :
482 : 4 : return NULL;
483 : : }
484 : :
485 : : // container::XEnumerationAccess
486 : :
487 : 1 : uno::Reference<container::XEnumeration> SAL_CALL ScAutoFormatObj::createEnumeration()
488 : : throw(uno::RuntimeException)
489 : : {
490 [ + - ]: 1 : SolarMutexGuard aGuard;
491 [ + - ][ + - ]: 1 : return new ScIndexEnumeration(this, rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.sheet.TableAutoFormatEnumeration")));
[ + - ][ + - ]
[ + - ][ + - ]
492 : : }
493 : :
494 : : // container::XIndexAccess
495 : :
496 : 7 : sal_Int32 SAL_CALL ScAutoFormatObj::getCount() throw(uno::RuntimeException)
497 : : {
498 [ + - ]: 7 : SolarMutexGuard aGuard;
499 [ + - ]: 7 : if (IsInserted())
500 : 7 : return SC_AF_FIELD_COUNT; // immer 16 Elemente
501 : : else
502 [ + - ]: 7 : return 0;
503 : : }
504 : :
505 : 5 : uno::Any SAL_CALL ScAutoFormatObj::getByIndex( sal_Int32 nIndex )
506 : : throw(lang::IndexOutOfBoundsException,
507 : : lang::WrappedTargetException, uno::RuntimeException)
508 : : {
509 [ + - ]: 5 : SolarMutexGuard aGuard;
510 : :
511 [ + - ][ + - ]: 5 : if ( nIndex < 0 || nIndex >= getCount() )
[ + + ][ + + ]
512 [ + - ]: 1 : throw lang::IndexOutOfBoundsException();
513 : :
514 [ + - ]: 4 : if (IsInserted())
515 [ + - ][ + - ]: 4 : return uno::makeAny(uno::Reference< beans::XPropertySet >(GetObjectByIndex_Impl((sal_uInt16)nIndex)));
[ + - ][ + - ]
516 [ + - ]: 5 : return uno::Any();
517 : : }
518 : :
519 : 1 : uno::Type SAL_CALL ScAutoFormatObj::getElementType() throw(uno::RuntimeException)
520 : : {
521 [ + - ]: 1 : SolarMutexGuard aGuard;
522 [ + - ][ + - ]: 1 : return ::getCppuType((const uno::Reference< beans::XPropertySet >*)0); // muss zu getByIndex passen
523 : : }
524 : :
525 : 1 : sal_Bool SAL_CALL ScAutoFormatObj::hasElements() throw(uno::RuntimeException)
526 : : {
527 [ + - ]: 1 : SolarMutexGuard aGuard;
528 [ + - ][ + - ]: 1 : return ( getCount() != 0 );
529 : : }
530 : :
531 : : // container::XNamed
532 : :
533 : 5 : rtl::OUString SAL_CALL ScAutoFormatObj::getName() throw(uno::RuntimeException)
534 : : {
535 [ + - ]: 5 : SolarMutexGuard aGuard;
536 [ + - ]: 5 : ScAutoFormat* pFormats = ScGlobal::GetOrCreateAutoFormat();
537 [ + - ][ + - ]: 5 : if (IsInserted() && nFormatIndex < pFormats->size())
[ + - ][ + - ]
538 [ + - ]: 5 : return pFormats->findByIndex(nFormatIndex)->GetName();
539 : :
540 [ + - ]: 5 : return rtl::OUString();
541 : : }
542 : :
543 : 2 : void SAL_CALL ScAutoFormatObj::setName( const rtl::OUString& aNewName )
544 : : throw(uno::RuntimeException)
545 : : {
546 [ + - ]: 2 : SolarMutexGuard aGuard;
547 [ + - ]: 2 : String aNewString(aNewName);
548 [ + - ]: 2 : ScAutoFormat* pFormats = ScGlobal::GetOrCreateAutoFormat();
549 : :
550 : : sal_uInt16 nDummy;
551 [ + - ][ + - ]: 4 : if (IsInserted() && nFormatIndex < pFormats->size() &&
[ + - ][ + - ]
[ + - ]
552 [ + - ]: 2 : !lcl_FindAutoFormatIndex( *pFormats, aNewName, nDummy ))
553 : : {
554 [ + - ]: 2 : ScAutoFormat::iterator it = pFormats->begin();
555 [ + - ]: 2 : std::advance(it, nFormatIndex);
556 [ + - ]: 2 : ScAutoFormatData* pData = it->second;
557 : : OSL_ENSURE(pData,"AutoFormat Daten nicht da");
558 : :
559 [ + - ][ + - ]: 2 : ScAutoFormatData* pNew = new ScAutoFormatData(*pData);
560 [ + - ]: 2 : pNew->SetName( aNewString );
561 : :
562 [ + - ]: 2 : pFormats->erase(it);
563 [ + - ][ + - ]: 2 : if (pFormats->insert(pNew))
564 : : {
565 [ + - ]: 2 : it = pFormats->find(pNew);
566 [ + - ]: 2 : ScAutoFormat::iterator itBeg = pFormats->begin();
567 [ + - ]: 2 : nFormatIndex = std::distance(itBeg, it);
568 : :
569 : : //! Notify fuer andere Objekte
570 [ + - ]: 2 : pFormats->SetSaveLater(true);
571 : : }
572 : : else
573 : : {
574 : : OSL_FAIL("AutoFormat konnte nicht eingefuegt werden");
575 : 0 : nFormatIndex = 0; //! alter Index ist ungueltig
576 : : }
577 : : }
578 : : else
579 : : {
580 : : // not inserted or name exists
581 [ # # ]: 0 : throw uno::RuntimeException();
582 [ + - ][ + - ]: 2 : }
583 : 2 : }
584 : :
585 : : // beans::XPropertySet
586 : :
587 : 13 : uno::Reference<beans::XPropertySetInfo> SAL_CALL ScAutoFormatObj::getPropertySetInfo()
588 : : throw(uno::RuntimeException)
589 : : {
590 [ + - ]: 13 : SolarMutexGuard aGuard;
591 [ + + ][ + - ]: 13 : static uno::Reference< beans::XPropertySetInfo > aRef(new SfxItemPropertySetInfo( aPropSet.getPropertyMap() ));
[ + - ][ + - ]
[ + - ][ # # ]
592 [ + - ]: 13 : return aRef;
593 : : }
594 : :
595 : 18 : void SAL_CALL ScAutoFormatObj::setPropertyValue(
596 : : const rtl::OUString& aPropertyName, const uno::Any& aValue )
597 : : throw(beans::UnknownPropertyException, beans::PropertyVetoException,
598 : : lang::IllegalArgumentException, lang::WrappedTargetException,
599 : : uno::RuntimeException)
600 : : {
601 [ + - ]: 18 : SolarMutexGuard aGuard;
602 [ + - ]: 18 : ScAutoFormat* pFormats = ScGlobal::GetOrCreateAutoFormat();
603 [ + - ][ + - ]: 18 : if (IsInserted() && nFormatIndex < pFormats->size())
[ + - ][ + - ]
604 : : {
605 [ + - ]: 18 : ScAutoFormatData* pData = pFormats->findByIndex(nFormatIndex);
606 : : OSL_ENSURE(pData,"AutoFormat Daten nicht da");
607 : :
608 [ + - ]: 18 : String aPropString(aPropertyName);
609 : 18 : sal_Bool bBool = sal_Bool();
610 [ + - ][ + + ]: 18 : if (aPropString.EqualsAscii( SC_UNONAME_INCBACK ) && (aValue >>= bBool))
[ + - ][ + + ]
611 : 3 : pData->SetIncludeBackground( bBool );
612 [ + - ][ + + ]: 15 : else if (aPropString.EqualsAscii( SC_UNONAME_INCBORD ) && (aValue >>= bBool))
[ + - ][ + + ]
613 : 3 : pData->SetIncludeFrame( bBool );
614 [ + - ][ + + ]: 12 : else if (aPropString.EqualsAscii( SC_UNONAME_INCFONT ) && (aValue >>= bBool))
[ + - ][ + + ]
615 : 3 : pData->SetIncludeFont( bBool );
616 [ + - ][ + + ]: 9 : else if (aPropString.EqualsAscii( SC_UNONAME_INCJUST ) && (aValue >>= bBool))
[ + - ][ + + ]
617 : 3 : pData->SetIncludeJustify( bBool );
618 [ + - ][ + + ]: 6 : else if (aPropString.EqualsAscii( SC_UNONAME_INCNUM ) && (aValue >>= bBool))
[ + - ][ + + ]
619 : 3 : pData->SetIncludeValueFormat( bBool );
620 [ + - ][ + - ]: 3 : else if (aPropString.EqualsAscii( SC_UNONAME_INCWIDTH ) && (aValue >>= bBool))
[ + - ][ + - ]
621 : 3 : pData->SetIncludeWidthHeight( bBool );
622 : :
623 : : // else Fehler
624 : :
625 : : //! Notify fuer andere Objekte
626 [ + - ][ + - ]: 18 : pFormats->SetSaveLater(sal_True);
627 [ + - ]: 18 : }
628 : 18 : }
629 : :
630 : 42 : uno::Any SAL_CALL ScAutoFormatObj::getPropertyValue( const rtl::OUString& aPropertyName )
631 : : throw(beans::UnknownPropertyException, lang::WrappedTargetException,
632 : : uno::RuntimeException)
633 : : {
634 [ + - ]: 42 : SolarMutexGuard aGuard;
635 : 42 : uno::Any aAny;
636 : :
637 [ + - ]: 42 : ScAutoFormat* pFormats = ScGlobal::GetOrCreateAutoFormat();
638 [ + - ][ + - ]: 42 : if (IsInserted() && nFormatIndex < pFormats->size())
[ + - ][ + - ]
639 : : {
640 [ + - ]: 42 : ScAutoFormatData* pData = pFormats->findByIndex(nFormatIndex);
641 : : OSL_ENSURE(pData,"AutoFormat Daten nicht da");
642 : :
643 : : sal_Bool bValue;
644 : 42 : sal_Bool bError = false;
645 : :
646 [ + - ]: 42 : String aPropString(aPropertyName);
647 [ + - ][ + + ]: 42 : if (aPropString.EqualsAscii( SC_UNONAME_INCBACK ))
648 : 7 : bValue = pData->GetIncludeBackground();
649 [ + - ][ + + ]: 35 : else if (aPropString.EqualsAscii( SC_UNONAME_INCBORD ))
650 : 7 : bValue = pData->GetIncludeFrame();
651 [ + - ][ + + ]: 28 : else if (aPropString.EqualsAscii( SC_UNONAME_INCFONT ))
652 : 7 : bValue = pData->GetIncludeFont();
653 [ + - ][ + + ]: 21 : else if (aPropString.EqualsAscii( SC_UNONAME_INCJUST ))
654 : 7 : bValue = pData->GetIncludeJustify();
655 [ + - ][ + + ]: 14 : else if (aPropString.EqualsAscii( SC_UNONAME_INCNUM ))
656 : 7 : bValue = pData->GetIncludeValueFormat();
657 [ + - ][ + - ]: 7 : else if (aPropString.EqualsAscii( SC_UNONAME_INCWIDTH ))
658 : 7 : bValue = pData->GetIncludeWidthHeight();
659 : : else
660 : 0 : bError = sal_True; // unbekannte Property
661 : :
662 [ + - ]: 42 : if (!bError)
663 [ + - ][ + - ]: 42 : aAny <<= bValue;
664 : : }
665 : :
666 [ + - ]: 42 : return aAny;
667 : : }
668 : :
669 : 0 : SC_IMPL_DUMMY_PROPERTY_LISTENER( ScAutoFormatObj )
670 : :
671 : : //------------------------------------------------------------------------
672 : :
673 : 4 : ScAutoFormatFieldObj::ScAutoFormatFieldObj(sal_uInt16 nFormat, sal_uInt16 nField) :
674 : : aPropSet( lcl_GetAutoFieldMap() ),
675 : : nFormatIndex( nFormat ),
676 [ + - ][ + - ]: 4 : nFieldIndex( nField )
[ + - ]
677 : : {
678 : : //! Listening !!!
679 : 4 : }
680 : :
681 [ + - ][ + - ]: 4 : ScAutoFormatFieldObj::~ScAutoFormatFieldObj()
682 : : {
683 [ - + ]: 8 : }
684 : :
685 : 0 : void ScAutoFormatFieldObj::Notify( SfxBroadcaster& /* rBC */, const SfxHint& /* rHint */ )
686 : : {
687 : : // spaeter...
688 : 0 : }
689 : :
690 : : // beans::XPropertySet
691 : :
692 : 1 : uno::Reference<beans::XPropertySetInfo> SAL_CALL ScAutoFormatFieldObj::getPropertySetInfo()
693 : : throw(uno::RuntimeException)
694 : : {
695 [ + - ]: 1 : SolarMutexGuard aGuard;
696 [ + - ][ + - ]: 1 : static uno::Reference< beans::XPropertySetInfo > aRef(new SfxItemPropertySetInfo( aPropSet.getPropertyMap() ));
[ + - ][ + - ]
[ + - ][ # # ]
697 [ + - ]: 1 : return aRef;
698 : : }
699 : :
700 : 86 : void SAL_CALL ScAutoFormatFieldObj::setPropertyValue(
701 : : const rtl::OUString& aPropertyName, const uno::Any& aValue )
702 : : throw(beans::UnknownPropertyException, beans::PropertyVetoException,
703 : : lang::IllegalArgumentException, lang::WrappedTargetException,
704 : : uno::RuntimeException)
705 : : {
706 [ + - ]: 86 : SolarMutexGuard aGuard;
707 [ + - ]: 86 : ScAutoFormat* pFormats = ScGlobal::GetOrCreateAutoFormat();
708 : : const SfxItemPropertySimpleEntry* pEntry =
709 [ + - ]: 86 : aPropSet.getPropertyMap().getByName( aPropertyName );
710 : :
711 [ + - ][ + - ]: 86 : if ( pEntry && pEntry->nWID && nFormatIndex < pFormats->size() )
[ + - ][ + - ]
[ + - ]
712 : : {
713 [ + - ]: 86 : ScAutoFormatData* pData = pFormats->findByIndex(nFormatIndex);
714 : :
715 [ + + ]: 86 : if ( IsScItemWid( pEntry->nWID ) )
716 : : {
717 [ + - ][ + - ]: 84 : if( const SfxPoolItem* pItem = pData->GetItem( nFieldIndex, pEntry->nWID ) )
718 : : {
719 : 84 : sal_Bool bDone = false;
720 : :
721 [ + + ]: 84 : switch( pEntry->nWID )
722 : : {
723 : : case ATTR_STACKED:
724 : : {
725 : : table::CellOrientation eOrient;
726 [ + - ][ + - ]: 2 : if( aValue >>= eOrient )
727 : : {
728 [ - + - - : 2 : switch( eOrient )
- ]
729 : : {
730 : : case table::CellOrientation_STANDARD:
731 [ # # ][ # # ]: 0 : pData->PutItem( nFieldIndex, SfxBoolItem( ATTR_STACKED, false ) );
[ # # ]
732 : 0 : break;
733 : : case table::CellOrientation_TOPBOTTOM:
734 [ + - ][ + - ]: 2 : pData->PutItem( nFieldIndex, SfxBoolItem( ATTR_STACKED, false ) );
[ + - ]
735 [ + - ][ + - ]: 2 : pData->PutItem( nFieldIndex, SfxInt32Item( ATTR_ROTATE_VALUE, 27000 ) );
[ + - ]
736 : 2 : break;
737 : : case table::CellOrientation_BOTTOMTOP:
738 [ # # ][ # # ]: 0 : pData->PutItem( nFieldIndex, SfxBoolItem( ATTR_STACKED, false ) );
[ # # ]
739 [ # # ][ # # ]: 0 : pData->PutItem( nFieldIndex, SfxInt32Item( ATTR_ROTATE_VALUE, 9000 ) );
[ # # ]
740 : 0 : break;
741 : : case table::CellOrientation_STACKED:
742 [ # # ][ # # ]: 0 : pData->PutItem( nFieldIndex, SfxBoolItem( ATTR_STACKED, sal_True ) );
[ # # ]
743 : 0 : break;
744 : : default:
745 : : {
746 : : // added to avoid warnings
747 : : }
748 : : }
749 : 2 : bDone = sal_True;
750 : : }
751 : : }
752 : 2 : break;
753 : : default:
754 [ + - ]: 82 : SfxPoolItem* pNewItem = pItem->Clone();
755 [ + - ]: 82 : bDone = pNewItem->PutValue( aValue, pEntry->nMemberId );
756 [ + - ]: 82 : if (bDone)
757 [ + - ]: 82 : pData->PutItem( nFieldIndex, *pNewItem );
758 [ + - ][ + - ]: 82 : delete pNewItem;
759 : : }
760 : :
761 [ + - ]: 84 : if (bDone)
762 : : //! Notify fuer andere Objekte?
763 [ + - ]: 84 : pFormats->SetSaveLater(sal_True);
764 : : }
765 : : }
766 : : else
767 : : {
768 [ + - - ]: 2 : switch (pEntry->nWID)
769 : : {
770 : : case SC_WID_UNO_TBLBORD:
771 : : {
772 : 2 : table::TableBorder aBorder;
773 [ + - ][ + - ]: 2 : if ( aValue >>= aBorder ) // empty = nothing to do
774 : : {
775 [ + - ]: 2 : SvxBoxItem aOuter(ATTR_BORDER);
776 [ + - ]: 2 : SvxBoxInfoItem aInner(ATTR_BORDER_INNER);
777 [ + - ]: 2 : ScHelperFunctions::FillBoxItems( aOuter, aInner, aBorder );
778 [ + - ]: 2 : pData->PutItem( nFieldIndex, aOuter );
779 : :
780 : : //! Notify for other objects?
781 [ + - ][ + - ]: 2 : pFormats->SetSaveLater(sal_True);
[ + - ]
782 : : }
783 : : }
784 : 2 : break;
785 : : case SC_WID_UNO_TBLBORD2:
786 : : {
787 : 0 : table::TableBorder2 aBorder2;
788 [ # # ][ # # ]: 0 : if ( aValue >>= aBorder2 ) // empty = nothing to do
789 : : {
790 [ # # ]: 0 : SvxBoxItem aOuter(ATTR_BORDER);
791 [ # # ]: 0 : SvxBoxInfoItem aInner(ATTR_BORDER_INNER);
792 [ # # ]: 0 : ScHelperFunctions::FillBoxItems( aOuter, aInner, aBorder2 );
793 [ # # ]: 0 : pData->PutItem( nFieldIndex, aOuter );
794 : :
795 : : //! Notify for other objects?
796 [ # # ][ # # ]: 0 : pFormats->SetSaveLater(sal_True);
[ # # ]
797 : : }
798 : : }
799 : 86 : break;
800 : : }
801 : : }
802 [ + - ]: 86 : }
803 : 86 : }
804 : :
805 : 217 : uno::Any SAL_CALL ScAutoFormatFieldObj::getPropertyValue( const rtl::OUString& aPropertyName )
806 : : throw(beans::UnknownPropertyException, lang::WrappedTargetException,
807 : : uno::RuntimeException)
808 : : {
809 [ + - ]: 217 : SolarMutexGuard aGuard;
810 : 217 : uno::Any aVal;
811 : :
812 [ + - ]: 217 : ScAutoFormat* pFormats = ScGlobal::GetOrCreateAutoFormat();
813 : : const SfxItemPropertySimpleEntry* pEntry =
814 [ + - ]: 217 : aPropSet.getPropertyMap().getByName( aPropertyName );
815 : :
816 [ + - ][ + - ]: 217 : if ( pEntry && pEntry->nWID && nFormatIndex < pFormats->size() )
[ + - ][ + - ]
[ + - ]
817 : : {
818 [ + - ]: 217 : const ScAutoFormatData* pData = pFormats->findByIndex(nFormatIndex);
819 : :
820 [ + + ]: 217 : if ( IsScItemWid( pEntry->nWID ) )
821 : : {
822 [ + - ][ + + ]: 211 : if( const SfxPoolItem* pItem = pData->GetItem( nFieldIndex, pEntry->nWID ) )
823 : : {
824 [ + + ]: 209 : switch( pEntry->nWID )
825 : : {
826 : : case ATTR_STACKED:
827 : : {
828 [ + - ]: 5 : const SfxInt32Item* pRotItem = (const SfxInt32Item*)pData->GetItem( nFieldIndex, ATTR_ROTATE_VALUE );
829 [ + - ]: 5 : sal_Int32 nRot = pRotItem ? pRotItem->GetValue() : 0;
830 : 5 : sal_Bool bStacked = ((const SfxBoolItem*)pItem)->GetValue();
831 [ + - ][ + - ]: 5 : SvxOrientationItem( nRot, bStacked, 0 ).QueryValue( aVal );
[ + - ]
832 : : }
833 : 5 : break;
834 : : default:
835 [ + - ]: 209 : pItem->QueryValue( aVal, pEntry->nMemberId );
836 : : }
837 : : }
838 : : }
839 : : else
840 : : {
841 [ + - ]: 6 : switch (pEntry->nWID)
842 : : {
843 : : case SC_WID_UNO_TBLBORD:
844 : : case SC_WID_UNO_TBLBORD2:
845 : : {
846 [ + - ]: 6 : const SfxPoolItem* pItem = pData->GetItem(nFieldIndex, ATTR_BORDER);
847 [ + - ]: 6 : if (pItem)
848 : : {
849 [ + - ]: 6 : SvxBoxItem aOuter(*(static_cast<const SvxBoxItem*>(pItem)));
850 [ + - ]: 6 : SvxBoxInfoItem aInner(ATTR_BORDER_INNER);
851 : :
852 [ + + ]: 6 : if (pEntry->nWID == SC_WID_UNO_TBLBORD2)
853 [ + - ]: 1 : ScHelperFunctions::AssignTableBorder2ToAny( aVal, aOuter, aInner);
854 : : else
855 [ + - ][ + - ]: 6 : ScHelperFunctions::AssignTableBorderToAny( aVal, aOuter, aInner);
[ + - ]
856 : : }
857 : : }
858 : 217 : break;
859 : : }
860 : : }
861 : : }
862 : :
863 [ + - ]: 217 : return aVal;
864 : : }
865 : :
866 : 0 : SC_IMPL_DUMMY_PROPERTY_LISTENER( ScAutoFormatFieldObj )
867 : :
868 : : //------------------------------------------------------------------------
869 : :
870 : :
871 : :
872 : : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|