Stop leaking all ScPostIt instances.
[LibreOffice.git] / sc / source / ui / unoobj / cellsuno.cxx
blob8da119885af979a26288c79bd80027f077761098
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3 * This file is part of the LibreOffice project.
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/.
9 * This file incorporates work covered by the following license notice:
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 .
20 #include "scitems.hxx"
21 #include <editeng/eeitem.hxx>
22 #include <svx/svdpool.hxx>
24 #include <svx/algitem.hxx>
25 #include <editeng/boxitem.hxx>
26 #include <editeng/brushitem.hxx>
27 #include <editeng/editeng.hxx>
28 #include <editeng/flditem.hxx>
29 #include <editeng/justifyitem.hxx>
30 #include "editeng/editobj.hxx"
31 #include <svx/fmdpage.hxx>
32 #include <editeng/langitem.hxx>
33 #include <sfx2/linkmgr.hxx>
34 #include <svl/srchitem.hxx>
35 #include "svl/sharedstringpool.hxx"
36 #include <svx/unomid.hxx>
37 #include <editeng/unoprnms.hxx>
38 #include <editeng/unotext.hxx>
39 #include <svx/svdpage.hxx>
40 #include <sfx2/bindings.hxx>
41 #include <svl/zforlist.hxx>
42 #include <svl/zformat.hxx>
43 #include <comphelper/servicehelper.hxx>
44 #include <float.h>
46 #include <com/sun/star/awt/XBitmap.hpp>
47 #include <com/sun/star/util/CellProtection.hpp>
48 #include <com/sun/star/table/CellHoriJustify.hpp>
49 #include <com/sun/star/table/CellOrientation.hpp>
50 #include <com/sun/star/table/CellVertJustify2.hpp>
51 #include <com/sun/star/table/ShadowFormat.hpp>
52 #include <com/sun/star/table/TableBorder.hpp>
53 #include <com/sun/star/table/BorderLineStyle.hpp>
54 #include <com/sun/star/sheet/CellFlags.hpp>
55 #include <com/sun/star/sheet/FormulaResult.hpp>
56 #include <com/sun/star/beans/PropertyAttribute.hpp>
57 #include <com/sun/star/lang/Locale.hpp>
58 #include <com/sun/star/beans/TolerantPropertySetResultType.hpp>
59 #include <com/sun/star/beans/SetPropertyTolerantFailed.hpp>
60 #include <com/sun/star/text/WritingMode2.hpp>
61 #include <com/sun/star/text/textfield/Type.hpp>
63 #include "autoform.hxx"
64 #include "cellmergeoption.hxx"
65 #include "cellsuno.hxx"
66 #include "cursuno.hxx"
67 #include "textuno.hxx"
68 #include "editsrc.hxx"
69 #include "notesuno.hxx"
70 #include "fielduno.hxx"
71 #include "docuno.hxx"
72 #include "datauno.hxx"
73 #include "dapiuno.hxx"
74 #include "chartuno.hxx"
75 #include "fmtuno.hxx"
76 #include "miscuno.hxx"
77 #include "convuno.hxx"
78 #include "srchuno.hxx"
79 #include "nameuno.hxx"
80 #include "targuno.hxx"
81 #include "tokenuno.hxx"
82 #include "eventuno.hxx"
83 #include "docsh.hxx"
84 #include "markdata.hxx"
85 #include "patattr.hxx"
86 #include "docpool.hxx"
87 #include "docfunc.hxx"
88 #include "dbdocfun.hxx"
89 #include "olinefun.hxx"
90 #include "hints.hxx"
91 #include "formulacell.hxx"
92 #include "undocell.hxx"
93 #include "undotab.hxx"
94 #include "undoblk.hxx"
95 #include "stlsheet.hxx"
96 #include "dbdata.hxx"
97 #include "attrib.hxx"
98 #include "chartarr.hxx"
99 #include "chartlis.hxx"
100 #include "drwlayer.hxx"
101 #include "printfun.hxx"
102 #include "prnsave.hxx"
103 #include "tablink.hxx"
104 #include "dociter.hxx"
105 #include "rangeutl.hxx"
106 #include "conditio.hxx"
107 #include "validat.hxx"
108 #include "sc.hrc"
109 #include "brdcst.hxx"
110 #include "cellform.hxx"
111 #include "globstr.hrc"
112 #include "unonames.hxx"
113 #include "styleuno.hxx"
114 #include "rangeseq.hxx"
115 #include "unowids.hxx"
116 #include "paramisc.hxx"
117 #include "queryentry.hxx"
118 #include "formula/errorcodes.hxx"
119 #include "unoreflist.hxx"
120 #include "formula/grammar.hxx"
121 #include "editeng/escapementitem.hxx"
122 #include "stringutil.hxx"
123 #include "formulaiter.hxx"
124 #include "tokenarray.hxx"
125 #include "stylehelper.hxx"
126 #include "dputil.hxx"
128 #include <list>
129 #include <boost/scoped_ptr.hpp>
131 using namespace com::sun::star;
133 //------------------------------------------------------------------------
135 class ScNamedEntry
137 OUString aName;
138 ScRange aRange;
140 public:
141 ScNamedEntry(const OUString& rN, const ScRange& rR) :
142 aName(rN), aRange(rR) {}
144 const OUString& GetName() const { return aName; }
145 const ScRange& GetRange() const { return aRange; }
148 //------------------------------------------------------------------------
150 // The names in the maps must be sorted according to strcmp!
151 //! Instead of Which-ID 0 use special IDs and do not compare via names!
153 // Left/Right/Top/BottomBorder are mapped directly to the core items,
154 // not collected/applied to the borders of a range -> ATTR_BORDER can be used directly
156 static const SfxItemPropertySet* lcl_GetCellsPropertySet()
158 static const SfxItemPropertyMapEntry aCellsPropertyMap_Impl[] =
160 {MAP_CHAR_LEN(SC_UNONAME_ABSNAME), SC_WID_UNO_ABSNAME, &getCppuType((OUString*)0), 0 | beans::PropertyAttribute::READONLY, 0 },
161 {MAP_CHAR_LEN(SC_UNONAME_ASIANVERT),ATTR_VERTICAL_ASIAN,&getBooleanCppuType(), 0, 0 },
162 {MAP_CHAR_LEN(SC_UNONAME_BOTTBORDER),ATTR_BORDER, &::getCppuType((const table::BorderLine*)0), 0, BOTTOM_BORDER | CONVERT_TWIPS },
163 {MAP_CHAR_LEN(SC_UNONAME_BOTTBORDER2),ATTR_BORDER, &::getCppuType((const table::BorderLine2*)0), 0, BOTTOM_BORDER | CONVERT_TWIPS },
164 {MAP_CHAR_LEN(SC_UNONAME_CELLBACK), ATTR_BACKGROUND, &getCppuType((sal_Int32*)0), 0, MID_BACK_COLOR },
165 {MAP_CHAR_LEN(SC_UNONAME_CELLPRO), ATTR_PROTECTION, &getCppuType((util::CellProtection*)0), 0, 0 },
166 {MAP_CHAR_LEN(SC_UNONAME_CELLSTYL), SC_WID_UNO_CELLSTYL,&getCppuType((OUString*)0), 0, 0 },
167 {MAP_CHAR_LEN(SC_UNONAME_CCOLOR), ATTR_FONT_COLOR, &getCppuType((sal_Int32*)0), 0, 0 },
168 {MAP_CHAR_LEN(SC_UNONAME_COUTL), ATTR_FONT_CONTOUR, &getBooleanCppuType(), 0, 0 },
169 {MAP_CHAR_LEN(SC_UNONAME_CCROSS), ATTR_FONT_CROSSEDOUT,&getBooleanCppuType(), 0, MID_CROSSED_OUT },
170 {MAP_CHAR_LEN(SC_UNONAME_CEMPHAS), ATTR_FONT_EMPHASISMARK,&getCppuType((sal_Int16*)0), 0, MID_EMPHASIS },
171 {MAP_CHAR_LEN(SC_UNONAME_CFONT), ATTR_FONT, &getCppuType((sal_Int16*)0), 0, MID_FONT_FAMILY },
172 {MAP_CHAR_LEN(SC_UNONAME_CFCHARS), ATTR_FONT, &getCppuType((sal_Int16*)0), 0, MID_FONT_CHAR_SET },
173 {MAP_CHAR_LEN(SC_UNO_CJK_CFCHARS), ATTR_CJK_FONT, &getCppuType((sal_Int16*)0), 0, MID_FONT_CHAR_SET },
174 {MAP_CHAR_LEN(SC_UNO_CTL_CFCHARS), ATTR_CTL_FONT, &getCppuType((sal_Int16*)0), 0, MID_FONT_CHAR_SET },
175 {MAP_CHAR_LEN(SC_UNONAME_CFFAMIL), ATTR_FONT, &getCppuType((sal_Int16*)0), 0, MID_FONT_FAMILY },
176 {MAP_CHAR_LEN(SC_UNO_CJK_CFFAMIL), ATTR_CJK_FONT, &getCppuType((sal_Int16*)0), 0, MID_FONT_FAMILY },
177 {MAP_CHAR_LEN(SC_UNO_CTL_CFFAMIL), ATTR_CTL_FONT, &getCppuType((sal_Int16*)0), 0, MID_FONT_FAMILY },
178 {MAP_CHAR_LEN(SC_UNONAME_CFNAME), ATTR_FONT, &getCppuType((OUString*)0), 0, MID_FONT_FAMILY_NAME },
179 {MAP_CHAR_LEN(SC_UNO_CJK_CFNAME), ATTR_CJK_FONT, &getCppuType((OUString*)0), 0, MID_FONT_FAMILY_NAME },
180 {MAP_CHAR_LEN(SC_UNO_CTL_CFNAME), ATTR_CTL_FONT, &getCppuType((OUString*)0), 0, MID_FONT_FAMILY_NAME },
181 {MAP_CHAR_LEN(SC_UNONAME_CFPITCH), ATTR_FONT, &getCppuType((sal_Int16*)0), 0, MID_FONT_PITCH },
182 {MAP_CHAR_LEN(SC_UNO_CJK_CFPITCH), ATTR_CJK_FONT, &getCppuType((sal_Int16*)0), 0, MID_FONT_PITCH },
183 {MAP_CHAR_LEN(SC_UNO_CTL_CFPITCH), ATTR_CTL_FONT, &getCppuType((sal_Int16*)0), 0, MID_FONT_PITCH },
184 {MAP_CHAR_LEN(SC_UNONAME_CFSTYLE), ATTR_FONT, &getCppuType((OUString*)0), 0, MID_FONT_STYLE_NAME },
185 {MAP_CHAR_LEN(SC_UNO_CJK_CFSTYLE), ATTR_CJK_FONT, &getCppuType((OUString*)0), 0, MID_FONT_STYLE_NAME },
186 {MAP_CHAR_LEN(SC_UNO_CTL_CFSTYLE), ATTR_CTL_FONT, &getCppuType((OUString*)0), 0, MID_FONT_STYLE_NAME },
187 {MAP_CHAR_LEN(SC_UNONAME_CHEIGHT), ATTR_FONT_HEIGHT, &getCppuType((float*)0), 0, MID_FONTHEIGHT | CONVERT_TWIPS },
188 {MAP_CHAR_LEN(SC_UNO_CJK_CHEIGHT), ATTR_CJK_FONT_HEIGHT,&getCppuType((float*)0), 0, MID_FONTHEIGHT | CONVERT_TWIPS },
189 {MAP_CHAR_LEN(SC_UNO_CTL_CHEIGHT), ATTR_CTL_FONT_HEIGHT,&getCppuType((float*)0), 0, MID_FONTHEIGHT | CONVERT_TWIPS },
190 {MAP_CHAR_LEN(SC_UNONAME_CLOCAL), ATTR_FONT_LANGUAGE, &getCppuType((lang::Locale*)0), 0, MID_LANG_LOCALE },
191 {MAP_CHAR_LEN(SC_UNO_CJK_CLOCAL), ATTR_CJK_FONT_LANGUAGE,&getCppuType((lang::Locale*)0), 0, MID_LANG_LOCALE },
192 {MAP_CHAR_LEN(SC_UNO_CTL_CLOCAL), ATTR_CTL_FONT_LANGUAGE,&getCppuType((lang::Locale*)0), 0, MID_LANG_LOCALE },
193 {MAP_CHAR_LEN(SC_UNONAME_COVER), ATTR_FONT_OVERLINE, &getCppuType((sal_Int16*)0), 0, MID_TL_STYLE },
194 {MAP_CHAR_LEN(SC_UNONAME_COVRLCOL), ATTR_FONT_OVERLINE, &getCppuType((sal_Int32*)0), 0, MID_TL_COLOR },
195 {MAP_CHAR_LEN(SC_UNONAME_COVRLHAS), ATTR_FONT_OVERLINE, &getBooleanCppuType(), 0, MID_TL_HASCOLOR },
196 {MAP_CHAR_LEN(SC_UNONAME_CPOST), ATTR_FONT_POSTURE, &getCppuType((awt::FontSlant*)0), 0, MID_POSTURE },
197 {MAP_CHAR_LEN(SC_UNO_CJK_CPOST), ATTR_CJK_FONT_POSTURE,&getCppuType((awt::FontSlant*)0), 0, MID_POSTURE },
198 {MAP_CHAR_LEN(SC_UNO_CTL_CPOST), ATTR_CTL_FONT_POSTURE,&getCppuType((awt::FontSlant*)0), 0, MID_POSTURE },
199 {MAP_CHAR_LEN(SC_UNONAME_CRELIEF), ATTR_FONT_RELIEF, &getCppuType((sal_Int16*)0), 0, MID_RELIEF },
200 {MAP_CHAR_LEN(SC_UNONAME_CSHADD), ATTR_FONT_SHADOWED, &getBooleanCppuType(), 0, 0 },
201 {MAP_CHAR_LEN(SC_UNONAME_CSTRIKE), ATTR_FONT_CROSSEDOUT,&getCppuType((sal_Int16*)0), 0, MID_CROSS_OUT },
202 {MAP_CHAR_LEN(SC_UNONAME_CUNDER), ATTR_FONT_UNDERLINE,&getCppuType((sal_Int16*)0), 0, MID_TL_STYLE },
203 {MAP_CHAR_LEN(SC_UNONAME_CUNDLCOL), ATTR_FONT_UNDERLINE,&getCppuType((sal_Int32*)0), 0, MID_TL_COLOR },
204 {MAP_CHAR_LEN(SC_UNONAME_CUNDLHAS), ATTR_FONT_UNDERLINE,&getBooleanCppuType(), 0, MID_TL_HASCOLOR },
205 {MAP_CHAR_LEN(SC_UNONAME_CWEIGHT), ATTR_FONT_WEIGHT, &getCppuType((float*)0), 0, MID_WEIGHT },
206 {MAP_CHAR_LEN(SC_UNO_CJK_CWEIGHT), ATTR_CJK_FONT_WEIGHT,&getCppuType((float*)0), 0, MID_WEIGHT },
207 {MAP_CHAR_LEN(SC_UNO_CTL_CWEIGHT), ATTR_CTL_FONT_WEIGHT,&getCppuType((float*)0), 0, MID_WEIGHT },
208 {MAP_CHAR_LEN(SC_UNONAME_CWORDMOD), ATTR_FONT_WORDLINE, &getBooleanCppuType(), 0, 0 },
209 {MAP_CHAR_LEN(SC_UNONAME_CHCOLHDR), SC_WID_UNO_CHCOLHDR,&getBooleanCppuType(), 0, 0 },
210 {MAP_CHAR_LEN(SC_UNONAME_CHROWHDR), SC_WID_UNO_CHROWHDR,&getBooleanCppuType(), 0, 0 },
211 {MAP_CHAR_LEN(SC_UNONAME_CONDFMT), SC_WID_UNO_CONDFMT, &getCppuType((uno::Reference<sheet::XSheetConditionalEntries>*)0), 0, 0 },
212 {MAP_CHAR_LEN(SC_UNONAME_CONDLOC), SC_WID_UNO_CONDLOC, &getCppuType((uno::Reference<sheet::XSheetConditionalEntries>*)0), 0, 0 },
213 {MAP_CHAR_LEN(SC_UNONAME_CONDXML), SC_WID_UNO_CONDXML, &getCppuType((uno::Reference<sheet::XSheetConditionalEntries>*)0), 0, 0 },
214 {MAP_CHAR_LEN(SC_UNONAME_DIAGONAL_BLTR), ATTR_BORDER_BLTR, &::getCppuType((const table::BorderLine*)0), 0, 0 | CONVERT_TWIPS },
215 {MAP_CHAR_LEN(SC_UNONAME_DIAGONAL_BLTR2), ATTR_BORDER_BLTR, &::getCppuType((const table::BorderLine2*)0), 0, 0 | CONVERT_TWIPS },
216 {MAP_CHAR_LEN(SC_UNONAME_DIAGONAL_TLBR), ATTR_BORDER_TLBR, &::getCppuType((const table::BorderLine*)0), 0, 0 | CONVERT_TWIPS },
217 {MAP_CHAR_LEN(SC_UNONAME_DIAGONAL_TLBR2), ATTR_BORDER_TLBR, &::getCppuType((const table::BorderLine2*)0), 0, 0 | CONVERT_TWIPS },
218 {MAP_CHAR_LEN(SC_UNONAME_CELLHJUS), ATTR_HOR_JUSTIFY, &getCppuType((table::CellHoriJustify*)0), 0, MID_HORJUST_HORJUST },
219 {MAP_CHAR_LEN(SC_UNONAME_CELLHJUS_METHOD), ATTR_HOR_JUSTIFY_METHOD, &::getCppuType((const sal_Int32*)0), 0, 0 },
220 {MAP_CHAR_LEN(SC_UNONAME_CELLTRAN), ATTR_BACKGROUND, &getBooleanCppuType(), 0, MID_GRAPHIC_TRANSPARENT },
221 {MAP_CHAR_LEN(SC_UNONAME_WRAP), ATTR_LINEBREAK, &getBooleanCppuType(), 0, 0 },
222 {MAP_CHAR_LEN(SC_UNONAME_LEFTBORDER),ATTR_BORDER, &::getCppuType((const table::BorderLine*)0), 0, LEFT_BORDER | CONVERT_TWIPS },
223 {MAP_CHAR_LEN(SC_UNONAME_LEFTBORDER2),ATTR_BORDER, &::getCppuType((const table::BorderLine2*)0), 0, LEFT_BORDER | CONVERT_TWIPS },
224 {MAP_CHAR_LEN(SC_UNONAME_NUMFMT), ATTR_VALUE_FORMAT, &getCppuType((sal_Int32*)0), 0, 0 },
225 {MAP_CHAR_LEN(SC_UNONAME_NUMRULES), SC_WID_UNO_NUMRULES,&getCppuType((const uno::Reference<container::XIndexReplace>*)0), 0, 0 },
226 {MAP_CHAR_LEN(SC_UNONAME_CELLORI), ATTR_STACKED, &getCppuType((table::CellOrientation*)0), 0, 0 },
227 {MAP_CHAR_LEN(SC_UNONAME_PADJUST), ATTR_HOR_JUSTIFY, &::getCppuType((const sal_Int16*)0), 0, MID_HORJUST_ADJUST },
228 {MAP_CHAR_LEN(SC_UNONAME_PBMARGIN), ATTR_MARGIN, &getCppuType((sal_Int32*)0), 0, MID_MARGIN_LO_MARGIN | CONVERT_TWIPS },
229 {MAP_CHAR_LEN(SC_UNONAME_PINDENT), ATTR_INDENT, &getCppuType((sal_Int16*)0), 0, 0 }, //! CONVERT_TWIPS
230 {MAP_CHAR_LEN(SC_UNONAME_PISCHDIST),ATTR_SCRIPTSPACE, &getBooleanCppuType(), 0, 0 },
231 {MAP_CHAR_LEN(SC_UNONAME_PISFORBID),ATTR_FORBIDDEN_RULES,&getBooleanCppuType(), 0, 0 },
232 {MAP_CHAR_LEN(SC_UNONAME_PISHANG), ATTR_HANGPUNCTUATION,&getBooleanCppuType(), 0, 0 },
233 {MAP_CHAR_LEN(SC_UNONAME_PISHYPHEN),ATTR_HYPHENATE, &getBooleanCppuType(), 0, 0 },
234 {MAP_CHAR_LEN(SC_UNONAME_PLASTADJ), ATTR_HOR_JUSTIFY, &::getCppuType((const sal_Int16*)0), 0, MID_HORJUST_ADJUST },
235 {MAP_CHAR_LEN(SC_UNONAME_PLMARGIN), ATTR_MARGIN, &getCppuType((sal_Int32*)0), 0, MID_MARGIN_L_MARGIN | CONVERT_TWIPS },
236 {MAP_CHAR_LEN(SC_UNONAME_PRMARGIN), ATTR_MARGIN, &getCppuType((sal_Int32*)0), 0, MID_MARGIN_R_MARGIN | CONVERT_TWIPS },
237 {MAP_CHAR_LEN(SC_UNONAME_PTMARGIN), ATTR_MARGIN, &getCppuType((sal_Int32*)0), 0, MID_MARGIN_UP_MARGIN | CONVERT_TWIPS },
238 {MAP_CHAR_LEN(SC_UNONAME_RIGHTBORDER),ATTR_BORDER, &::getCppuType((const table::BorderLine*)0), 0, RIGHT_BORDER | CONVERT_TWIPS },
239 {MAP_CHAR_LEN(SC_UNONAME_RIGHTBORDER2),ATTR_BORDER, &::getCppuType((const table::BorderLine2*)0), 0, RIGHT_BORDER | CONVERT_TWIPS },
240 {MAP_CHAR_LEN(SC_UNONAME_ROTANG), ATTR_ROTATE_VALUE, &getCppuType((sal_Int32*)0), 0, 0 },
241 {MAP_CHAR_LEN(SC_UNONAME_ROTREF), ATTR_ROTATE_MODE, &getCppuType((sal_Int32*)0), 0, 0 },
242 {MAP_CHAR_LEN(SC_UNONAME_SHADOW), ATTR_SHADOW, &getCppuType((table::ShadowFormat*)0), 0, 0 | CONVERT_TWIPS },
243 {MAP_CHAR_LEN(SC_UNONAME_SHRINK_TO_FIT), ATTR_SHRINKTOFIT, &getBooleanCppuType(), 0, 0 },
244 {MAP_CHAR_LEN(SC_UNONAME_TBLBORD), SC_WID_UNO_TBLBORD, &getCppuType((table::TableBorder*)0), 0, 0 | CONVERT_TWIPS },
245 {MAP_CHAR_LEN(SC_UNONAME_TBLBORD2), SC_WID_UNO_TBLBORD2, &getCppuType((table::TableBorder2*)0), 0, 0 | CONVERT_TWIPS },
246 {MAP_CHAR_LEN(SC_UNONAME_TOPBORDER),ATTR_BORDER, &::getCppuType((const table::BorderLine*)0), 0, TOP_BORDER | CONVERT_TWIPS },
247 {MAP_CHAR_LEN(SC_UNONAME_TOPBORDER2),ATTR_BORDER, &::getCppuType((const table::BorderLine2*)0), 0, TOP_BORDER | CONVERT_TWIPS },
248 {MAP_CHAR_LEN(SC_UNONAME_USERDEF), ATTR_USERDEF, &getCppuType((uno::Reference<container::XNameContainer>*)0), 0, 0 },
249 {MAP_CHAR_LEN(SC_UNONAME_VALIDAT), SC_WID_UNO_VALIDAT, &getCppuType((uno::Reference<beans::XPropertySet>*)0), 0, 0 },
250 {MAP_CHAR_LEN(SC_UNONAME_VALILOC), SC_WID_UNO_VALILOC, &getCppuType((uno::Reference<beans::XPropertySet>*)0), 0, 0 },
251 {MAP_CHAR_LEN(SC_UNONAME_VALIXML), SC_WID_UNO_VALIXML, &getCppuType((uno::Reference<beans::XPropertySet>*)0), 0, 0 },
252 {MAP_CHAR_LEN(SC_UNONAME_CELLVJUS), ATTR_VER_JUSTIFY, &getCppuType((sal_Int32*)0), 0, 0 },
253 {MAP_CHAR_LEN(SC_UNONAME_CELLVJUS_METHOD), ATTR_VER_JUSTIFY_METHOD, &::getCppuType((const sal_Int32*)0), 0, 0 },
254 {MAP_CHAR_LEN(SC_UNONAME_WRITING), ATTR_WRITINGDIR, &getCppuType((sal_Int16*)0), 0, 0 },
255 {MAP_CHAR_LEN(SC_UNONAME_HYPERLINK), ATTR_HYPERLINK, &getCppuType((OUString*)0), 0, 0 },
256 {0,0,0,0,0,0}
258 static SfxItemPropertySet aCellsPropertySet( aCellsPropertyMap_Impl );
259 return &aCellsPropertySet;
262 // CellRange enthaelt alle Eintraege von Cells, zusaetzlich eigene Eintraege
263 // mit Which-ID 0 (werden nur fuer getPropertySetInfo benoetigt).
265 static const SfxItemPropertySet* lcl_GetRangePropertySet()
267 static const SfxItemPropertyMapEntry aRangePropertyMap_Impl[] =
269 {MAP_CHAR_LEN(SC_UNONAME_ABSNAME), SC_WID_UNO_ABSNAME, &getCppuType((OUString*)0), 0 | beans::PropertyAttribute::READONLY, 0 },
270 {MAP_CHAR_LEN(SC_UNONAME_ASIANVERT),ATTR_VERTICAL_ASIAN,&getBooleanCppuType(), 0, 0 },
271 {MAP_CHAR_LEN(SC_UNONAME_BOTTBORDER),ATTR_BORDER, &::getCppuType((const table::BorderLine*)0), 0, BOTTOM_BORDER | CONVERT_TWIPS },
272 {MAP_CHAR_LEN(SC_UNONAME_BOTTBORDER2),ATTR_BORDER, &::getCppuType((const table::BorderLine2*)0), 0, BOTTOM_BORDER | CONVERT_TWIPS },
273 {MAP_CHAR_LEN(SC_UNONAME_CELLBACK), ATTR_BACKGROUND, &getCppuType((sal_Int32*)0), 0, MID_BACK_COLOR },
274 {MAP_CHAR_LEN(SC_UNONAME_CELLPRO), ATTR_PROTECTION, &getCppuType((util::CellProtection*)0), 0, 0 },
275 {MAP_CHAR_LEN(SC_UNONAME_CELLSTYL), SC_WID_UNO_CELLSTYL,&getCppuType((OUString*)0), 0, 0 },
276 {MAP_CHAR_LEN(SC_UNONAME_CCOLOR), ATTR_FONT_COLOR, &getCppuType((sal_Int32*)0), 0, 0 },
277 {MAP_CHAR_LEN(SC_UNONAME_COUTL), ATTR_FONT_CONTOUR, &getBooleanCppuType(), 0, 0 },
278 {MAP_CHAR_LEN(SC_UNONAME_CCROSS), ATTR_FONT_CROSSEDOUT,&getBooleanCppuType(), 0, MID_CROSSED_OUT },
279 {MAP_CHAR_LEN(SC_UNONAME_CEMPHAS), ATTR_FONT_EMPHASISMARK,&getCppuType((sal_Int16*)0), 0, MID_EMPHASIS },
280 {MAP_CHAR_LEN(SC_UNONAME_CFONT), ATTR_FONT, &getCppuType((sal_Int16*)0), 0, MID_FONT_FAMILY },
281 {MAP_CHAR_LEN(SC_UNONAME_CFCHARS), ATTR_FONT, &getCppuType((sal_Int16*)0), 0, MID_FONT_CHAR_SET },
282 {MAP_CHAR_LEN(SC_UNO_CJK_CFCHARS), ATTR_CJK_FONT, &getCppuType((sal_Int16*)0), 0, MID_FONT_CHAR_SET },
283 {MAP_CHAR_LEN(SC_UNO_CTL_CFCHARS), ATTR_CTL_FONT, &getCppuType((sal_Int16*)0), 0, MID_FONT_CHAR_SET },
284 {MAP_CHAR_LEN(SC_UNONAME_CFFAMIL), ATTR_FONT, &getCppuType((sal_Int16*)0), 0, MID_FONT_FAMILY },
285 {MAP_CHAR_LEN(SC_UNO_CJK_CFFAMIL), ATTR_CJK_FONT, &getCppuType((sal_Int16*)0), 0, MID_FONT_FAMILY },
286 {MAP_CHAR_LEN(SC_UNO_CTL_CFFAMIL), ATTR_CTL_FONT, &getCppuType((sal_Int16*)0), 0, MID_FONT_FAMILY },
287 {MAP_CHAR_LEN(SC_UNONAME_CFNAME), ATTR_FONT, &getCppuType((OUString*)0), 0, MID_FONT_FAMILY_NAME },
288 {MAP_CHAR_LEN(SC_UNO_CJK_CFNAME), ATTR_CJK_FONT, &getCppuType((OUString*)0), 0, MID_FONT_FAMILY_NAME },
289 {MAP_CHAR_LEN(SC_UNO_CTL_CFNAME), ATTR_CTL_FONT, &getCppuType((OUString*)0), 0, MID_FONT_FAMILY_NAME },
290 {MAP_CHAR_LEN(SC_UNONAME_CFPITCH), ATTR_FONT, &getCppuType((sal_Int16*)0), 0, MID_FONT_PITCH },
291 {MAP_CHAR_LEN(SC_UNO_CJK_CFPITCH), ATTR_CJK_FONT, &getCppuType((sal_Int16*)0), 0, MID_FONT_PITCH },
292 {MAP_CHAR_LEN(SC_UNO_CTL_CFPITCH), ATTR_CTL_FONT, &getCppuType((sal_Int16*)0), 0, MID_FONT_PITCH },
293 {MAP_CHAR_LEN(SC_UNONAME_CFSTYLE), ATTR_FONT, &getCppuType((OUString*)0), 0, MID_FONT_STYLE_NAME },
294 {MAP_CHAR_LEN(SC_UNO_CJK_CFSTYLE), ATTR_CJK_FONT, &getCppuType((OUString*)0), 0, MID_FONT_STYLE_NAME },
295 {MAP_CHAR_LEN(SC_UNO_CTL_CFSTYLE), ATTR_CTL_FONT, &getCppuType((OUString*)0), 0, MID_FONT_STYLE_NAME },
296 {MAP_CHAR_LEN(SC_UNONAME_CHEIGHT), ATTR_FONT_HEIGHT, &getCppuType((float*)0), 0, MID_FONTHEIGHT | CONVERT_TWIPS },
297 {MAP_CHAR_LEN(SC_UNO_CJK_CHEIGHT), ATTR_CJK_FONT_HEIGHT,&getCppuType((float*)0), 0, MID_FONTHEIGHT | CONVERT_TWIPS },
298 {MAP_CHAR_LEN(SC_UNO_CTL_CHEIGHT), ATTR_CTL_FONT_HEIGHT,&getCppuType((float*)0), 0, MID_FONTHEIGHT | CONVERT_TWIPS },
299 {MAP_CHAR_LEN(SC_UNONAME_CLOCAL), ATTR_FONT_LANGUAGE, &getCppuType((lang::Locale*)0), 0, MID_LANG_LOCALE },
300 {MAP_CHAR_LEN(SC_UNO_CJK_CLOCAL), ATTR_CJK_FONT_LANGUAGE,&getCppuType((lang::Locale*)0), 0, MID_LANG_LOCALE },
301 {MAP_CHAR_LEN(SC_UNO_CTL_CLOCAL), ATTR_CTL_FONT_LANGUAGE,&getCppuType((lang::Locale*)0), 0, MID_LANG_LOCALE },
302 {MAP_CHAR_LEN(SC_UNONAME_COVER), ATTR_FONT_OVERLINE, &getCppuType((sal_Int16*)0), 0, MID_TL_STYLE },
303 {MAP_CHAR_LEN(SC_UNONAME_COVRLCOL), ATTR_FONT_OVERLINE, &getCppuType((sal_Int32*)0), 0, MID_TL_COLOR },
304 {MAP_CHAR_LEN(SC_UNONAME_COVRLHAS), ATTR_FONT_OVERLINE, &getBooleanCppuType(), 0, MID_TL_HASCOLOR },
305 {MAP_CHAR_LEN(SC_UNONAME_CPOST), ATTR_FONT_POSTURE, &getCppuType((awt::FontSlant*)0), 0, MID_POSTURE },
306 {MAP_CHAR_LEN(SC_UNO_CJK_CPOST), ATTR_CJK_FONT_POSTURE,&getCppuType((awt::FontSlant*)0), 0, MID_POSTURE },
307 {MAP_CHAR_LEN(SC_UNO_CTL_CPOST), ATTR_CTL_FONT_POSTURE,&getCppuType((awt::FontSlant*)0), 0, MID_POSTURE },
308 {MAP_CHAR_LEN(SC_UNONAME_CRELIEF), ATTR_FONT_RELIEF, &getCppuType((sal_Int16*)0), 0, MID_RELIEF },
309 {MAP_CHAR_LEN(SC_UNONAME_CSHADD), ATTR_FONT_SHADOWED, &getBooleanCppuType(), 0, 0 },
310 {MAP_CHAR_LEN(SC_UNONAME_CSTRIKE), ATTR_FONT_CROSSEDOUT,&getCppuType((sal_Int16*)0), 0, MID_CROSS_OUT },
311 {MAP_CHAR_LEN(SC_UNONAME_CUNDER), ATTR_FONT_UNDERLINE,&getCppuType((sal_Int16*)0), 0, MID_TL_STYLE },
312 {MAP_CHAR_LEN(SC_UNONAME_CUNDLCOL), ATTR_FONT_UNDERLINE,&getCppuType((sal_Int32*)0), 0, MID_TL_COLOR },
313 {MAP_CHAR_LEN(SC_UNONAME_CUNDLHAS), ATTR_FONT_UNDERLINE,&getBooleanCppuType(), 0, MID_TL_HASCOLOR },
314 {MAP_CHAR_LEN(SC_UNONAME_CWEIGHT), ATTR_FONT_WEIGHT, &getCppuType((float*)0), 0, MID_WEIGHT },
315 {MAP_CHAR_LEN(SC_UNO_CJK_CWEIGHT), ATTR_CJK_FONT_WEIGHT,&getCppuType((float*)0), 0, MID_WEIGHT },
316 {MAP_CHAR_LEN(SC_UNO_CTL_CWEIGHT), ATTR_CTL_FONT_WEIGHT,&getCppuType((float*)0), 0, MID_WEIGHT },
317 {MAP_CHAR_LEN(SC_UNONAME_CWORDMOD), ATTR_FONT_WORDLINE, &getBooleanCppuType(), 0, 0 },
318 {MAP_CHAR_LEN(SC_UNONAME_CHCOLHDR), SC_WID_UNO_CHCOLHDR,&getBooleanCppuType(), 0, 0 },
319 {MAP_CHAR_LEN(SC_UNONAME_CHROWHDR), SC_WID_UNO_CHROWHDR,&getBooleanCppuType(), 0, 0 },
320 {MAP_CHAR_LEN(SC_UNONAME_CONDFMT), SC_WID_UNO_CONDFMT, &getCppuType((uno::Reference<sheet::XSheetConditionalEntries>*)0), 0, 0 },
321 {MAP_CHAR_LEN(SC_UNONAME_CONDLOC), SC_WID_UNO_CONDLOC, &getCppuType((uno::Reference<sheet::XSheetConditionalEntries>*)0), 0, 0 },
322 {MAP_CHAR_LEN(SC_UNONAME_CONDXML), SC_WID_UNO_CONDXML, &getCppuType((uno::Reference<sheet::XSheetConditionalEntries>*)0), 0, 0 },
323 {MAP_CHAR_LEN(SC_UNONAME_DIAGONAL_BLTR), ATTR_BORDER_BLTR, &::getCppuType((const table::BorderLine*)0), 0, 0 | CONVERT_TWIPS },
324 {MAP_CHAR_LEN(SC_UNONAME_DIAGONAL_BLTR2), ATTR_BORDER_BLTR, &::getCppuType((const table::BorderLine2*)0), 0, 0 | CONVERT_TWIPS },
325 {MAP_CHAR_LEN(SC_UNONAME_DIAGONAL_TLBR), ATTR_BORDER_TLBR, &::getCppuType((const table::BorderLine*)0), 0, 0 | CONVERT_TWIPS },
326 {MAP_CHAR_LEN(SC_UNONAME_DIAGONAL_TLBR2), ATTR_BORDER_TLBR, &::getCppuType((const table::BorderLine2*)0), 0, 0 | CONVERT_TWIPS },
327 {MAP_CHAR_LEN(SC_UNONAME_CELLHJUS), ATTR_HOR_JUSTIFY, &getCppuType((table::CellHoriJustify*)0), 0, MID_HORJUST_HORJUST },
328 {MAP_CHAR_LEN(SC_UNONAME_CELLHJUS_METHOD), ATTR_HOR_JUSTIFY_METHOD, &::getCppuType((const sal_Int32*)0), 0, 0 },
329 {MAP_CHAR_LEN(SC_UNONAME_CELLTRAN), ATTR_BACKGROUND, &getBooleanCppuType(), 0, MID_GRAPHIC_TRANSPARENT },
330 {MAP_CHAR_LEN(SC_UNONAME_WRAP), ATTR_LINEBREAK, &getBooleanCppuType(), 0, 0 },
331 {MAP_CHAR_LEN(SC_UNONAME_LEFTBORDER),ATTR_BORDER, &::getCppuType((const table::BorderLine*)0), 0, LEFT_BORDER | CONVERT_TWIPS },
332 {MAP_CHAR_LEN(SC_UNONAME_LEFTBORDER2),ATTR_BORDER, &::getCppuType((const table::BorderLine2*)0), 0, LEFT_BORDER | CONVERT_TWIPS },
333 {MAP_CHAR_LEN(SC_UNONAME_NUMFMT), ATTR_VALUE_FORMAT, &getCppuType((sal_Int32*)0), 0, 0 },
334 {MAP_CHAR_LEN(SC_UNONAME_NUMRULES), SC_WID_UNO_NUMRULES,&getCppuType((const uno::Reference<container::XIndexReplace>*)0), 0, 0 },
335 {MAP_CHAR_LEN(SC_UNONAME_CELLORI), ATTR_STACKED, &getCppuType((table::CellOrientation*)0), 0, 0 },
336 {MAP_CHAR_LEN(SC_UNONAME_PADJUST), ATTR_HOR_JUSTIFY, &::getCppuType((const sal_Int16*)0), 0, MID_HORJUST_ADJUST },
337 {MAP_CHAR_LEN(SC_UNONAME_PBMARGIN), ATTR_MARGIN, &getCppuType((sal_Int32*)0), 0, MID_MARGIN_LO_MARGIN | CONVERT_TWIPS },
338 {MAP_CHAR_LEN(SC_UNONAME_PINDENT), ATTR_INDENT, &getCppuType((sal_Int16*)0), 0, 0 }, //! CONVERT_TWIPS
339 {MAP_CHAR_LEN(SC_UNONAME_PISCHDIST),ATTR_SCRIPTSPACE, &getBooleanCppuType(), 0, 0 },
340 {MAP_CHAR_LEN(SC_UNONAME_PISFORBID),ATTR_FORBIDDEN_RULES,&getBooleanCppuType(), 0, 0 },
341 {MAP_CHAR_LEN(SC_UNONAME_PISHANG), ATTR_HANGPUNCTUATION,&getBooleanCppuType(), 0, 0 },
342 {MAP_CHAR_LEN(SC_UNONAME_PISHYPHEN),ATTR_HYPHENATE, &getBooleanCppuType(), 0, 0 },
343 {MAP_CHAR_LEN(SC_UNONAME_PLASTADJ), ATTR_HOR_JUSTIFY, &::getCppuType((const sal_Int16*)0), 0, MID_HORJUST_ADJUST },
344 {MAP_CHAR_LEN(SC_UNONAME_PLMARGIN), ATTR_MARGIN, &getCppuType((sal_Int32*)0), 0, MID_MARGIN_L_MARGIN | CONVERT_TWIPS },
345 {MAP_CHAR_LEN(SC_UNONAME_PRMARGIN), ATTR_MARGIN, &getCppuType((sal_Int32*)0), 0, MID_MARGIN_R_MARGIN | CONVERT_TWIPS },
346 {MAP_CHAR_LEN(SC_UNONAME_PTMARGIN), ATTR_MARGIN, &getCppuType((sal_Int32*)0), 0, MID_MARGIN_UP_MARGIN | CONVERT_TWIPS },
347 {MAP_CHAR_LEN(SC_UNONAME_POS), SC_WID_UNO_POS, &getCppuType((awt::Point*)0), 0 | beans::PropertyAttribute::READONLY, 0 },
348 {MAP_CHAR_LEN(SC_UNONAME_RIGHTBORDER),ATTR_BORDER, &::getCppuType((const table::BorderLine*)0), 0, RIGHT_BORDER | CONVERT_TWIPS },
349 {MAP_CHAR_LEN(SC_UNONAME_RIGHTBORDER2),ATTR_BORDER, &::getCppuType((const table::BorderLine2*)0), 0, RIGHT_BORDER | CONVERT_TWIPS },
350 {MAP_CHAR_LEN(SC_UNONAME_ROTANG), ATTR_ROTATE_VALUE, &getCppuType((sal_Int32*)0), 0, 0 },
351 {MAP_CHAR_LEN(SC_UNONAME_ROTREF), ATTR_ROTATE_MODE, &getCppuType((sal_Int32*)0), 0, 0 },
352 {MAP_CHAR_LEN(SC_UNONAME_SHADOW), ATTR_SHADOW, &getCppuType((table::ShadowFormat*)0), 0, 0 | CONVERT_TWIPS },
353 {MAP_CHAR_LEN(SC_UNONAME_SHRINK_TO_FIT), ATTR_SHRINKTOFIT, &getBooleanCppuType(), 0, 0 },
354 {MAP_CHAR_LEN(SC_UNONAME_SIZE), SC_WID_UNO_SIZE, &getCppuType((awt::Size*)0), 0 | beans::PropertyAttribute::READONLY, 0 },
355 {MAP_CHAR_LEN(SC_UNONAME_TBLBORD), SC_WID_UNO_TBLBORD, &getCppuType((table::TableBorder*)0), 0, 0 | CONVERT_TWIPS },
356 {MAP_CHAR_LEN(SC_UNONAME_TBLBORD2), SC_WID_UNO_TBLBORD2, &getCppuType((table::TableBorder2*)0), 0, 0 | CONVERT_TWIPS },
357 {MAP_CHAR_LEN(SC_UNONAME_TOPBORDER),ATTR_BORDER, &::getCppuType((const table::BorderLine*)0), 0, TOP_BORDER | CONVERT_TWIPS },
358 {MAP_CHAR_LEN(SC_UNONAME_TOPBORDER2),ATTR_BORDER, &::getCppuType((const table::BorderLine2*)0), 0, TOP_BORDER | CONVERT_TWIPS },
359 {MAP_CHAR_LEN(SC_UNONAME_USERDEF), ATTR_USERDEF, &getCppuType((uno::Reference<container::XNameContainer>*)0), 0, 0 },
360 {MAP_CHAR_LEN(SC_UNONAME_VALIDAT), SC_WID_UNO_VALIDAT, &getCppuType((uno::Reference<beans::XPropertySet>*)0), 0, 0 },
361 {MAP_CHAR_LEN(SC_UNONAME_VALILOC), SC_WID_UNO_VALILOC, &getCppuType((uno::Reference<beans::XPropertySet>*)0), 0, 0 },
362 {MAP_CHAR_LEN(SC_UNONAME_VALIXML), SC_WID_UNO_VALIXML, &getCppuType((uno::Reference<beans::XPropertySet>*)0), 0, 0 },
363 {MAP_CHAR_LEN(SC_UNONAME_CELLVJUS), ATTR_VER_JUSTIFY, &getCppuType((sal_Int32*)0), 0, 0 },
364 {MAP_CHAR_LEN(SC_UNONAME_CELLVJUS_METHOD), ATTR_VER_JUSTIFY_METHOD, &::getCppuType((const sal_Int32*)0), 0, 0 },
365 {MAP_CHAR_LEN(SC_UNONAME_WRITING), ATTR_WRITINGDIR, &getCppuType((sal_Int16*)0), 0, 0 },
366 {0,0,0,0,0,0}
368 static SfxItemPropertySet aRangePropertySet( aRangePropertyMap_Impl );
369 return &aRangePropertySet;
372 // Cell enthaelt alle Eintraege von CellRange, zusaetzlich eigene Eintraege
373 // mit Which-ID 0 (werden nur fuer getPropertySetInfo benoetigt).
375 static const SfxItemPropertySet* lcl_GetCellPropertySet()
377 static const SfxItemPropertyMapEntry aCellPropertyMap_Impl[] =
379 {MAP_CHAR_LEN(SC_UNONAME_ABSNAME), SC_WID_UNO_ABSNAME, &getCppuType((OUString*)0), 0 | beans::PropertyAttribute::READONLY, 0 },
380 {MAP_CHAR_LEN(SC_UNONAME_ASIANVERT),ATTR_VERTICAL_ASIAN,&getBooleanCppuType(), 0, 0 },
381 {MAP_CHAR_LEN(SC_UNONAME_BOTTBORDER),ATTR_BORDER, &::getCppuType((const table::BorderLine*)0), 0, BOTTOM_BORDER | CONVERT_TWIPS },
382 {MAP_CHAR_LEN(SC_UNONAME_BOTTBORDER2),ATTR_BORDER, &::getCppuType((const table::BorderLine2*)0), 0, BOTTOM_BORDER | CONVERT_TWIPS },
383 {MAP_CHAR_LEN(SC_UNONAME_CELLBACK), ATTR_BACKGROUND, &getCppuType((sal_Int32*)0), 0, MID_BACK_COLOR },
384 {MAP_CHAR_LEN(SC_UNONAME_CELLPRO), ATTR_PROTECTION, &getCppuType((util::CellProtection*)0), 0, 0 },
385 {MAP_CHAR_LEN(SC_UNONAME_CELLSTYL), SC_WID_UNO_CELLSTYL,&getCppuType((OUString*)0), 0, 0 },
386 {MAP_CHAR_LEN(SC_UNONAME_CCOLOR), ATTR_FONT_COLOR, &getCppuType((sal_Int32*)0), 0, 0 },
387 {MAP_CHAR_LEN(SC_UNONAME_COUTL), ATTR_FONT_CONTOUR, &getBooleanCppuType(), 0, 0 },
388 {MAP_CHAR_LEN(SC_UNONAME_CCROSS), ATTR_FONT_CROSSEDOUT,&getBooleanCppuType(), 0, MID_CROSSED_OUT },
389 {MAP_CHAR_LEN(SC_UNONAME_CEMPHAS), ATTR_FONT_EMPHASISMARK,&getCppuType((sal_Int16*)0), 0, MID_EMPHASIS },
390 {MAP_CHAR_LEN(SC_UNONAME_CFONT), ATTR_FONT, &getCppuType((sal_Int16*)0), 0, MID_FONT_FAMILY },
391 {MAP_CHAR_LEN(SC_UNONAME_CFCHARS), ATTR_FONT, &getCppuType((sal_Int16*)0), 0, MID_FONT_CHAR_SET },
392 {MAP_CHAR_LEN(SC_UNO_CJK_CFCHARS), ATTR_CJK_FONT, &getCppuType((sal_Int16*)0), 0, MID_FONT_CHAR_SET },
393 {MAP_CHAR_LEN(SC_UNO_CTL_CFCHARS), ATTR_CTL_FONT, &getCppuType((sal_Int16*)0), 0, MID_FONT_CHAR_SET },
394 {MAP_CHAR_LEN(SC_UNONAME_CFFAMIL), ATTR_FONT, &getCppuType((sal_Int16*)0), 0, MID_FONT_FAMILY },
395 {MAP_CHAR_LEN(SC_UNO_CJK_CFFAMIL), ATTR_CJK_FONT, &getCppuType((sal_Int16*)0), 0, MID_FONT_FAMILY },
396 {MAP_CHAR_LEN(SC_UNO_CTL_CFFAMIL), ATTR_CTL_FONT, &getCppuType((sal_Int16*)0), 0, MID_FONT_FAMILY },
397 {MAP_CHAR_LEN(SC_UNONAME_CFNAME), ATTR_FONT, &getCppuType((OUString*)0), 0, MID_FONT_FAMILY_NAME },
398 {MAP_CHAR_LEN(SC_UNO_CJK_CFNAME), ATTR_CJK_FONT, &getCppuType((OUString*)0), 0, MID_FONT_FAMILY_NAME },
399 {MAP_CHAR_LEN(SC_UNO_CTL_CFNAME), ATTR_CTL_FONT, &getCppuType((OUString*)0), 0, MID_FONT_FAMILY_NAME },
400 {MAP_CHAR_LEN(SC_UNONAME_CFPITCH), ATTR_FONT, &getCppuType((sal_Int16*)0), 0, MID_FONT_PITCH },
401 {MAP_CHAR_LEN(SC_UNO_CJK_CFPITCH), ATTR_CJK_FONT, &getCppuType((sal_Int16*)0), 0, MID_FONT_PITCH },
402 {MAP_CHAR_LEN(SC_UNO_CTL_CFPITCH), ATTR_CTL_FONT, &getCppuType((sal_Int16*)0), 0, MID_FONT_PITCH },
403 {MAP_CHAR_LEN(SC_UNONAME_CFSTYLE), ATTR_FONT, &getCppuType((OUString*)0), 0, MID_FONT_STYLE_NAME },
404 {MAP_CHAR_LEN(SC_UNO_CJK_CFSTYLE), ATTR_CJK_FONT, &getCppuType((OUString*)0), 0, MID_FONT_STYLE_NAME },
405 {MAP_CHAR_LEN(SC_UNO_CTL_CFSTYLE), ATTR_CTL_FONT, &getCppuType((OUString*)0), 0, MID_FONT_STYLE_NAME },
406 {MAP_CHAR_LEN(SC_UNONAME_CHEIGHT), ATTR_FONT_HEIGHT, &getCppuType((float*)0), 0, MID_FONTHEIGHT | CONVERT_TWIPS },
407 {MAP_CHAR_LEN(SC_UNO_CJK_CHEIGHT), ATTR_CJK_FONT_HEIGHT,&getCppuType((float*)0), 0, MID_FONTHEIGHT | CONVERT_TWIPS },
408 {MAP_CHAR_LEN(SC_UNO_CTL_CHEIGHT), ATTR_CTL_FONT_HEIGHT,&getCppuType((float*)0), 0, MID_FONTHEIGHT | CONVERT_TWIPS },
409 {MAP_CHAR_LEN(SC_UNONAME_CLOCAL), ATTR_FONT_LANGUAGE, &getCppuType((lang::Locale*)0), 0, MID_LANG_LOCALE },
410 {MAP_CHAR_LEN(SC_UNO_CJK_CLOCAL), ATTR_CJK_FONT_LANGUAGE,&getCppuType((lang::Locale*)0), 0, MID_LANG_LOCALE },
411 {MAP_CHAR_LEN(SC_UNO_CTL_CLOCAL), ATTR_CTL_FONT_LANGUAGE,&getCppuType((lang::Locale*)0), 0, MID_LANG_LOCALE },
412 {MAP_CHAR_LEN(SC_UNONAME_COVER), ATTR_FONT_OVERLINE, &getCppuType((sal_Int16*)0), 0, MID_TL_STYLE },
413 {MAP_CHAR_LEN(SC_UNONAME_COVRLCOL), ATTR_FONT_OVERLINE, &getCppuType((sal_Int32*)0), 0, MID_TL_COLOR },
414 {MAP_CHAR_LEN(SC_UNONAME_COVRLHAS), ATTR_FONT_OVERLINE, &getBooleanCppuType(), 0, MID_TL_HASCOLOR },
415 {MAP_CHAR_LEN(SC_UNONAME_CPOST), ATTR_FONT_POSTURE, &getCppuType((awt::FontSlant*)0), 0, MID_POSTURE },
416 {MAP_CHAR_LEN(SC_UNO_CJK_CPOST), ATTR_CJK_FONT_POSTURE,&getCppuType((awt::FontSlant*)0), 0, MID_POSTURE },
417 {MAP_CHAR_LEN(SC_UNO_CTL_CPOST), ATTR_CTL_FONT_POSTURE,&getCppuType((awt::FontSlant*)0), 0, MID_POSTURE },
418 {MAP_CHAR_LEN(SC_UNONAME_CRELIEF), ATTR_FONT_RELIEF, &getCppuType((sal_Int16*)0), 0, MID_RELIEF },
419 {MAP_CHAR_LEN(SC_UNONAME_CSHADD), ATTR_FONT_SHADOWED, &getBooleanCppuType(), 0, 0 },
420 {MAP_CHAR_LEN(SC_UNONAME_CSTRIKE), ATTR_FONT_CROSSEDOUT,&getCppuType((sal_Int16*)0), 0, MID_CROSS_OUT },
421 {MAP_CHAR_LEN(SC_UNONAME_CUNDER), ATTR_FONT_UNDERLINE,&getCppuType((sal_Int16*)0), 0, MID_TL_STYLE },
422 {MAP_CHAR_LEN(SC_UNONAME_CUNDLCOL), ATTR_FONT_UNDERLINE,&getCppuType((sal_Int32*)0), 0, MID_TL_COLOR },
423 {MAP_CHAR_LEN(SC_UNONAME_CUNDLHAS), ATTR_FONT_UNDERLINE,&getBooleanCppuType(), 0, MID_TL_HASCOLOR },
424 {MAP_CHAR_LEN(SC_UNONAME_CWEIGHT), ATTR_FONT_WEIGHT, &getCppuType((float*)0), 0, MID_WEIGHT },
425 {MAP_CHAR_LEN(SC_UNO_CJK_CWEIGHT), ATTR_CJK_FONT_WEIGHT,&getCppuType((float*)0), 0, MID_WEIGHT },
426 {MAP_CHAR_LEN(SC_UNO_CTL_CWEIGHT), ATTR_CTL_FONT_WEIGHT,&getCppuType((float*)0), 0, MID_WEIGHT },
427 {MAP_CHAR_LEN(SC_UNONAME_CWORDMOD), ATTR_FONT_WORDLINE, &getBooleanCppuType(), 0, 0 },
428 {MAP_CHAR_LEN(SC_UNONAME_CHCOLHDR), SC_WID_UNO_CHCOLHDR,&getBooleanCppuType(), 0, 0 },
429 {MAP_CHAR_LEN(SC_UNONAME_CHROWHDR), SC_WID_UNO_CHROWHDR,&getBooleanCppuType(), 0, 0 },
430 {MAP_CHAR_LEN(SC_UNONAME_CONDFMT), SC_WID_UNO_CONDFMT, &getCppuType((uno::Reference<sheet::XSheetConditionalEntries>*)0), 0, 0 },
431 {MAP_CHAR_LEN(SC_UNONAME_CONDLOC), SC_WID_UNO_CONDLOC, &getCppuType((uno::Reference<sheet::XSheetConditionalEntries>*)0), 0, 0 },
432 {MAP_CHAR_LEN(SC_UNONAME_CONDXML), SC_WID_UNO_CONDXML, &getCppuType((uno::Reference<sheet::XSheetConditionalEntries>*)0), 0, 0 },
433 {MAP_CHAR_LEN(SC_UNONAME_DIAGONAL_BLTR), ATTR_BORDER_BLTR, &::getCppuType((const table::BorderLine*)0), 0, 0 | CONVERT_TWIPS },
434 {MAP_CHAR_LEN(SC_UNONAME_DIAGONAL_BLTR2), ATTR_BORDER_BLTR, &::getCppuType((const table::BorderLine2*)0), 0, 0 | CONVERT_TWIPS },
435 {MAP_CHAR_LEN(SC_UNONAME_DIAGONAL_TLBR), ATTR_BORDER_TLBR, &::getCppuType((const table::BorderLine*)0), 0, 0 | CONVERT_TWIPS },
436 {MAP_CHAR_LEN(SC_UNONAME_DIAGONAL_TLBR2), ATTR_BORDER_TLBR, &::getCppuType((const table::BorderLine2*)0), 0, 0 | CONVERT_TWIPS },
437 {MAP_CHAR_LEN(SC_UNONAME_FORMLOC), SC_WID_UNO_FORMLOC, &getCppuType((OUString*)0), 0, 0 },
438 {MAP_CHAR_LEN(SC_UNONAME_FORMRT), SC_WID_UNO_FORMRT, &getCppuType((table::CellContentType*)0), 0 | beans::PropertyAttribute::READONLY, 0 },
439 {MAP_CHAR_LEN(SC_UNONAME_CELLHJUS), ATTR_HOR_JUSTIFY, &getCppuType((table::CellHoriJustify*)0), 0, MID_HORJUST_HORJUST },
440 {MAP_CHAR_LEN(SC_UNONAME_CELLHJUS_METHOD), ATTR_HOR_JUSTIFY_METHOD, &::getCppuType((const sal_Int32*)0), 0, 0 },
441 {MAP_CHAR_LEN(SC_UNONAME_CELLTRAN), ATTR_BACKGROUND, &getBooleanCppuType(), 0, MID_GRAPHIC_TRANSPARENT },
442 {MAP_CHAR_LEN(SC_UNONAME_WRAP), ATTR_LINEBREAK, &getBooleanCppuType(), 0, 0 },
443 {MAP_CHAR_LEN(SC_UNONAME_LEFTBORDER),ATTR_BORDER, &::getCppuType((const table::BorderLine*)0), 0, LEFT_BORDER | CONVERT_TWIPS },
444 {MAP_CHAR_LEN(SC_UNONAME_LEFTBORDER2),ATTR_BORDER, &::getCppuType((const table::BorderLine2*)0), 0, LEFT_BORDER | CONVERT_TWIPS },
445 {MAP_CHAR_LEN(SC_UNONAME_NUMFMT), ATTR_VALUE_FORMAT, &getCppuType((sal_Int32*)0), 0, 0 },
446 {MAP_CHAR_LEN(SC_UNONAME_NUMRULES), SC_WID_UNO_NUMRULES,&getCppuType((const uno::Reference<container::XIndexReplace>*)0), 0, 0 },
447 {MAP_CHAR_LEN(SC_UNONAME_CELLORI), ATTR_STACKED, &getCppuType((table::CellOrientation*)0), 0, 0 },
448 {MAP_CHAR_LEN(SC_UNONAME_PADJUST), ATTR_HOR_JUSTIFY, &::getCppuType((const sal_Int16*)0), 0, MID_HORJUST_ADJUST },
449 {MAP_CHAR_LEN(SC_UNONAME_PBMARGIN), ATTR_MARGIN, &getCppuType((sal_Int32*)0), 0, MID_MARGIN_LO_MARGIN | CONVERT_TWIPS },
450 {MAP_CHAR_LEN(SC_UNONAME_PINDENT), ATTR_INDENT, &getCppuType((sal_Int16*)0), 0, 0 }, //! CONVERT_TWIPS
451 {MAP_CHAR_LEN(SC_UNONAME_PISCHDIST),ATTR_SCRIPTSPACE, &getBooleanCppuType(), 0, 0 },
452 {MAP_CHAR_LEN(SC_UNONAME_PISFORBID),ATTR_FORBIDDEN_RULES,&getBooleanCppuType(), 0, 0 },
453 {MAP_CHAR_LEN(SC_UNONAME_PISHANG), ATTR_HANGPUNCTUATION,&getBooleanCppuType(), 0, 0 },
454 {MAP_CHAR_LEN(SC_UNONAME_PISHYPHEN),ATTR_HYPHENATE, &getBooleanCppuType(), 0, 0 },
455 {MAP_CHAR_LEN(SC_UNONAME_PLASTADJ), ATTR_HOR_JUSTIFY, &::getCppuType((const sal_Int16*)0), 0, MID_HORJUST_ADJUST },
456 {MAP_CHAR_LEN(SC_UNONAME_PLMARGIN), ATTR_MARGIN, &getCppuType((sal_Int32*)0), 0, MID_MARGIN_L_MARGIN | CONVERT_TWIPS },
457 {MAP_CHAR_LEN(SC_UNONAME_PRMARGIN), ATTR_MARGIN, &getCppuType((sal_Int32*)0), 0, MID_MARGIN_R_MARGIN | CONVERT_TWIPS },
458 {MAP_CHAR_LEN(SC_UNONAME_PTMARGIN), ATTR_MARGIN, &getCppuType((sal_Int32*)0), 0, MID_MARGIN_UP_MARGIN | CONVERT_TWIPS },
459 {MAP_CHAR_LEN(SC_UNONAME_POS), SC_WID_UNO_POS, &getCppuType((awt::Point*)0), 0 | beans::PropertyAttribute::READONLY, 0 },
460 {MAP_CHAR_LEN(SC_UNONAME_RIGHTBORDER),ATTR_BORDER, &::getCppuType((const table::BorderLine*)0), 0, RIGHT_BORDER | CONVERT_TWIPS },
461 {MAP_CHAR_LEN(SC_UNONAME_RIGHTBORDER2),ATTR_BORDER, &::getCppuType((const table::BorderLine2*)0), 0, RIGHT_BORDER | CONVERT_TWIPS },
462 {MAP_CHAR_LEN(SC_UNONAME_ROTANG), ATTR_ROTATE_VALUE, &getCppuType((sal_Int32*)0), 0, 0 },
463 {MAP_CHAR_LEN(SC_UNONAME_ROTREF), ATTR_ROTATE_MODE, &getCppuType((sal_Int32*)0), 0, 0 },
464 {MAP_CHAR_LEN(SC_UNONAME_SHADOW), ATTR_SHADOW, &getCppuType((table::ShadowFormat*)0), 0, 0 | CONVERT_TWIPS },
465 {MAP_CHAR_LEN(SC_UNONAME_SHRINK_TO_FIT), ATTR_SHRINKTOFIT, &getBooleanCppuType(), 0, 0 },
466 {MAP_CHAR_LEN(SC_UNONAME_SIZE), SC_WID_UNO_SIZE, &getCppuType((awt::Size*)0), 0 | beans::PropertyAttribute::READONLY, 0 },
467 {MAP_CHAR_LEN(SC_UNONAME_TBLBORD), SC_WID_UNO_TBLBORD, &getCppuType((table::TableBorder*)0), 0, 0 | CONVERT_TWIPS },
468 {MAP_CHAR_LEN(SC_UNONAME_TBLBORD2), SC_WID_UNO_TBLBORD2, &getCppuType((table::TableBorder2*)0), 0, 0 | CONVERT_TWIPS },
469 {MAP_CHAR_LEN(SC_UNONAME_TOPBORDER),ATTR_BORDER, &::getCppuType((const table::BorderLine*)0), 0, TOP_BORDER | CONVERT_TWIPS },
470 {MAP_CHAR_LEN(SC_UNONAME_TOPBORDER2),ATTR_BORDER, &::getCppuType((const table::BorderLine2*)0), 0, TOP_BORDER | CONVERT_TWIPS },
471 {MAP_CHAR_LEN(SC_UNONAME_USERDEF), ATTR_USERDEF, &getCppuType((uno::Reference<container::XNameContainer>*)0), 0, 0 },
472 {MAP_CHAR_LEN(SC_UNONAME_VALIDAT), SC_WID_UNO_VALIDAT, &getCppuType((uno::Reference<beans::XPropertySet>*)0), 0, 0 },
473 {MAP_CHAR_LEN(SC_UNONAME_VALILOC), SC_WID_UNO_VALILOC, &getCppuType((uno::Reference<beans::XPropertySet>*)0), 0, 0 },
474 {MAP_CHAR_LEN(SC_UNONAME_VALIXML), SC_WID_UNO_VALIXML, &getCppuType((uno::Reference<beans::XPropertySet>*)0), 0, 0 },
475 {MAP_CHAR_LEN(SC_UNONAME_CELLVJUS), ATTR_VER_JUSTIFY, &getCppuType((sal_Int32*)0), 0, 0 },
476 {MAP_CHAR_LEN(SC_UNONAME_CELLVJUS_METHOD), ATTR_VER_JUSTIFY_METHOD, &::getCppuType((const sal_Int32*)0), 0, 0 },
477 {MAP_CHAR_LEN(SC_UNONAME_WRITING), ATTR_WRITINGDIR, &getCppuType((sal_Int16*)0), 0, 0 },
478 {MAP_CHAR_LEN(UNO_NAME_EDIT_CHAR_ESCAPEMENT), EE_CHAR_ESCAPEMENT, &getCppuType((sal_Int32*)0), 0, 0 },
479 {MAP_CHAR_LEN(SC_UNONAME_HYPERLINK), ATTR_HYPERLINK, &getCppuType((OUString*)0), 0, 0 },
480 {0,0,0,0,0,0}
482 static SfxItemPropertySet aCellPropertySet( aCellPropertyMap_Impl );
483 return &aCellPropertySet;
486 // Column und Row enthalten alle Eintraege von CellRange, zusaetzlich eigene Eintraege
487 // mit Which-ID 0 (werden nur fuer getPropertySetInfo benoetigt).
489 static const SfxItemPropertySet* lcl_GetColumnPropertySet()
491 static const SfxItemPropertyMapEntry aColumnPropertyMap_Impl[] =
493 {MAP_CHAR_LEN(SC_UNONAME_ABSNAME), SC_WID_UNO_ABSNAME, &getCppuType((OUString*)0), 0 | beans::PropertyAttribute::READONLY, 0 },
494 {MAP_CHAR_LEN(SC_UNONAME_ASIANVERT),ATTR_VERTICAL_ASIAN,&getBooleanCppuType(), 0, 0 },
495 {MAP_CHAR_LEN(SC_UNONAME_BOTTBORDER),ATTR_BORDER, &::getCppuType((const table::BorderLine*)0), 0, BOTTOM_BORDER | CONVERT_TWIPS },
496 {MAP_CHAR_LEN(SC_UNONAME_BOTTBORDER2),ATTR_BORDER, &::getCppuType((const table::BorderLine2*)0), 0, BOTTOM_BORDER | CONVERT_TWIPS },
497 {MAP_CHAR_LEN(SC_UNONAME_CELLBACK), ATTR_BACKGROUND, &getCppuType((sal_Int32*)0), 0, MID_BACK_COLOR },
498 {MAP_CHAR_LEN(SC_UNONAME_CELLPRO), ATTR_PROTECTION, &getCppuType((util::CellProtection*)0), 0, 0 },
499 {MAP_CHAR_LEN(SC_UNONAME_CELLSTYL), SC_WID_UNO_CELLSTYL,&getCppuType((OUString*)0), 0, 0 },
500 {MAP_CHAR_LEN(SC_UNONAME_CCOLOR), ATTR_FONT_COLOR, &getCppuType((sal_Int32*)0), 0, 0 },
501 {MAP_CHAR_LEN(SC_UNONAME_COUTL), ATTR_FONT_CONTOUR, &getBooleanCppuType(), 0, 0 },
502 {MAP_CHAR_LEN(SC_UNONAME_CCROSS), ATTR_FONT_CROSSEDOUT,&getBooleanCppuType(), 0, MID_CROSSED_OUT },
503 {MAP_CHAR_LEN(SC_UNONAME_CEMPHAS), ATTR_FONT_EMPHASISMARK,&getCppuType((sal_Int16*)0), 0, MID_EMPHASIS },
504 {MAP_CHAR_LEN(SC_UNONAME_CFONT), ATTR_FONT, &getCppuType((sal_Int16*)0), 0, MID_FONT_FAMILY },
505 {MAP_CHAR_LEN(SC_UNONAME_CFCHARS), ATTR_FONT, &getCppuType((sal_Int16*)0), 0, MID_FONT_CHAR_SET },
506 {MAP_CHAR_LEN(SC_UNO_CJK_CFCHARS), ATTR_CJK_FONT, &getCppuType((sal_Int16*)0), 0, MID_FONT_CHAR_SET },
507 {MAP_CHAR_LEN(SC_UNO_CTL_CFCHARS), ATTR_CTL_FONT, &getCppuType((sal_Int16*)0), 0, MID_FONT_CHAR_SET },
508 {MAP_CHAR_LEN(SC_UNONAME_CFFAMIL), ATTR_FONT, &getCppuType((sal_Int16*)0), 0, MID_FONT_FAMILY },
509 {MAP_CHAR_LEN(SC_UNO_CJK_CFFAMIL), ATTR_CJK_FONT, &getCppuType((sal_Int16*)0), 0, MID_FONT_FAMILY },
510 {MAP_CHAR_LEN(SC_UNO_CTL_CFFAMIL), ATTR_CTL_FONT, &getCppuType((sal_Int16*)0), 0, MID_FONT_FAMILY },
511 {MAP_CHAR_LEN(SC_UNONAME_CFNAME), ATTR_FONT, &getCppuType((OUString*)0), 0, MID_FONT_FAMILY_NAME },
512 {MAP_CHAR_LEN(SC_UNO_CJK_CFNAME), ATTR_CJK_FONT, &getCppuType((OUString*)0), 0, MID_FONT_FAMILY_NAME },
513 {MAP_CHAR_LEN(SC_UNO_CTL_CFNAME), ATTR_CTL_FONT, &getCppuType((OUString*)0), 0, MID_FONT_FAMILY_NAME },
514 {MAP_CHAR_LEN(SC_UNONAME_CFPITCH), ATTR_FONT, &getCppuType((sal_Int16*)0), 0, MID_FONT_PITCH },
515 {MAP_CHAR_LEN(SC_UNO_CJK_CFPITCH), ATTR_CJK_FONT, &getCppuType((sal_Int16*)0), 0, MID_FONT_PITCH },
516 {MAP_CHAR_LEN(SC_UNO_CTL_CFPITCH), ATTR_CTL_FONT, &getCppuType((sal_Int16*)0), 0, MID_FONT_PITCH },
517 {MAP_CHAR_LEN(SC_UNONAME_CFSTYLE), ATTR_FONT, &getCppuType((OUString*)0), 0, MID_FONT_STYLE_NAME },
518 {MAP_CHAR_LEN(SC_UNO_CJK_CFSTYLE), ATTR_CJK_FONT, &getCppuType((OUString*)0), 0, MID_FONT_STYLE_NAME },
519 {MAP_CHAR_LEN(SC_UNO_CTL_CFSTYLE), ATTR_CTL_FONT, &getCppuType((OUString*)0), 0, MID_FONT_STYLE_NAME },
520 {MAP_CHAR_LEN(SC_UNONAME_CHEIGHT), ATTR_FONT_HEIGHT, &getCppuType((float*)0), 0, MID_FONTHEIGHT | CONVERT_TWIPS },
521 {MAP_CHAR_LEN(SC_UNO_CJK_CHEIGHT), ATTR_CJK_FONT_HEIGHT,&getCppuType((float*)0), 0, MID_FONTHEIGHT | CONVERT_TWIPS },
522 {MAP_CHAR_LEN(SC_UNO_CTL_CHEIGHT), ATTR_CTL_FONT_HEIGHT,&getCppuType((float*)0), 0, MID_FONTHEIGHT | CONVERT_TWIPS },
523 {MAP_CHAR_LEN(SC_UNONAME_CLOCAL), ATTR_FONT_LANGUAGE, &getCppuType((lang::Locale*)0), 0, MID_LANG_LOCALE },
524 {MAP_CHAR_LEN(SC_UNO_CJK_CLOCAL), ATTR_CJK_FONT_LANGUAGE,&getCppuType((lang::Locale*)0), 0, MID_LANG_LOCALE },
525 {MAP_CHAR_LEN(SC_UNO_CTL_CLOCAL), ATTR_CTL_FONT_LANGUAGE,&getCppuType((lang::Locale*)0), 0, MID_LANG_LOCALE },
526 {MAP_CHAR_LEN(SC_UNONAME_COVER), ATTR_FONT_OVERLINE, &getCppuType((sal_Int16*)0), 0, MID_TL_STYLE },
527 {MAP_CHAR_LEN(SC_UNONAME_COVRLCOL), ATTR_FONT_OVERLINE, &getCppuType((sal_Int32*)0), 0, MID_TL_COLOR },
528 {MAP_CHAR_LEN(SC_UNONAME_COVRLHAS), ATTR_FONT_OVERLINE, &getBooleanCppuType(), 0, MID_TL_HASCOLOR },
529 {MAP_CHAR_LEN(SC_UNONAME_CPOST), ATTR_FONT_POSTURE, &getCppuType((awt::FontSlant*)0), 0, MID_POSTURE },
530 {MAP_CHAR_LEN(SC_UNO_CJK_CPOST), ATTR_CJK_FONT_POSTURE,&getCppuType((awt::FontSlant*)0), 0, MID_POSTURE },
531 {MAP_CHAR_LEN(SC_UNO_CTL_CPOST), ATTR_CTL_FONT_POSTURE,&getCppuType((awt::FontSlant*)0), 0, MID_POSTURE },
532 {MAP_CHAR_LEN(SC_UNONAME_CRELIEF), ATTR_FONT_RELIEF, &getCppuType((sal_Int16*)0), 0, MID_RELIEF },
533 {MAP_CHAR_LEN(SC_UNONAME_CSHADD), ATTR_FONT_SHADOWED, &getBooleanCppuType(), 0, 0 },
534 {MAP_CHAR_LEN(SC_UNONAME_CSTRIKE), ATTR_FONT_CROSSEDOUT,&getCppuType((sal_Int16*)0), 0, MID_CROSS_OUT },
535 {MAP_CHAR_LEN(SC_UNONAME_CUNDER), ATTR_FONT_UNDERLINE,&getCppuType((sal_Int16*)0), 0, MID_TL_STYLE },
536 {MAP_CHAR_LEN(SC_UNONAME_CUNDLCOL), ATTR_FONT_UNDERLINE,&getCppuType((sal_Int32*)0), 0, MID_TL_COLOR },
537 {MAP_CHAR_LEN(SC_UNONAME_CUNDLHAS), ATTR_FONT_UNDERLINE,&getBooleanCppuType(), 0, MID_TL_HASCOLOR },
538 {MAP_CHAR_LEN(SC_UNONAME_CWEIGHT), ATTR_FONT_WEIGHT, &getCppuType((float*)0), 0, MID_WEIGHT },
539 {MAP_CHAR_LEN(SC_UNO_CJK_CWEIGHT), ATTR_CJK_FONT_WEIGHT,&getCppuType((float*)0), 0, MID_WEIGHT },
540 {MAP_CHAR_LEN(SC_UNO_CTL_CWEIGHT), ATTR_CTL_FONT_WEIGHT,&getCppuType((float*)0), 0, MID_WEIGHT },
541 {MAP_CHAR_LEN(SC_UNONAME_CWORDMOD), ATTR_FONT_WORDLINE, &getBooleanCppuType(), 0, 0 },
542 {MAP_CHAR_LEN(SC_UNONAME_CHCOLHDR), SC_WID_UNO_CHCOLHDR,&getBooleanCppuType(), 0, 0 },
543 {MAP_CHAR_LEN(SC_UNONAME_CHROWHDR), SC_WID_UNO_CHROWHDR,&getBooleanCppuType(), 0, 0 },
544 {MAP_CHAR_LEN(SC_UNONAME_CONDFMT), SC_WID_UNO_CONDFMT, &getCppuType((uno::Reference<sheet::XSheetConditionalEntries>*)0), 0, 0 },
545 {MAP_CHAR_LEN(SC_UNONAME_CONDLOC), SC_WID_UNO_CONDLOC, &getCppuType((uno::Reference<sheet::XSheetConditionalEntries>*)0), 0, 0 },
546 {MAP_CHAR_LEN(SC_UNONAME_CONDXML), SC_WID_UNO_CONDXML, &getCppuType((uno::Reference<sheet::XSheetConditionalEntries>*)0), 0, 0 },
547 {MAP_CHAR_LEN(SC_UNONAME_DIAGONAL_BLTR), ATTR_BORDER_BLTR, &::getCppuType((const table::BorderLine*)0), 0, 0 | CONVERT_TWIPS },
548 {MAP_CHAR_LEN(SC_UNONAME_DIAGONAL_BLTR2), ATTR_BORDER_BLTR, &::getCppuType((const table::BorderLine2*)0), 0, 0 | CONVERT_TWIPS },
549 {MAP_CHAR_LEN(SC_UNONAME_DIAGONAL_TLBR), ATTR_BORDER_TLBR, &::getCppuType((const table::BorderLine*)0), 0, 0 | CONVERT_TWIPS },
550 {MAP_CHAR_LEN(SC_UNONAME_DIAGONAL_TLBR2), ATTR_BORDER_TLBR, &::getCppuType((const table::BorderLine2*)0), 0, 0 | CONVERT_TWIPS },
551 {MAP_CHAR_LEN(SC_UNONAME_CELLHJUS), ATTR_HOR_JUSTIFY, &getCppuType((table::CellHoriJustify*)0), 0, MID_HORJUST_HORJUST },
552 {MAP_CHAR_LEN(SC_UNONAME_CELLHJUS_METHOD), ATTR_HOR_JUSTIFY_METHOD, &::getCppuType((const sal_Int32*)0), 0, 0 },
553 {MAP_CHAR_LEN(SC_UNONAME_CELLTRAN), ATTR_BACKGROUND, &getBooleanCppuType(), 0, MID_GRAPHIC_TRANSPARENT },
554 {MAP_CHAR_LEN(SC_UNONAME_MANPAGE), SC_WID_UNO_MANPAGE, &getBooleanCppuType(), 0, 0 },
555 {MAP_CHAR_LEN(SC_UNONAME_NEWPAGE), SC_WID_UNO_NEWPAGE, &getBooleanCppuType(), 0, 0 },
556 {MAP_CHAR_LEN(SC_UNONAME_WRAP), ATTR_LINEBREAK, &getBooleanCppuType(), 0, 0 },
557 {MAP_CHAR_LEN(SC_UNONAME_CELLVIS), SC_WID_UNO_CELLVIS, &getBooleanCppuType(), 0, 0 },
558 {MAP_CHAR_LEN(SC_UNONAME_LEFTBORDER),ATTR_BORDER, &::getCppuType((const table::BorderLine*)0), 0, LEFT_BORDER | CONVERT_TWIPS },
559 {MAP_CHAR_LEN(SC_UNONAME_LEFTBORDER2),ATTR_BORDER, &::getCppuType((const table::BorderLine2*)0), 0, LEFT_BORDER | CONVERT_TWIPS },
560 {MAP_CHAR_LEN(SC_UNONAME_NUMFMT), ATTR_VALUE_FORMAT, &getCppuType((sal_Int32*)0), 0, 0 },
561 {MAP_CHAR_LEN(SC_UNONAME_NUMRULES), SC_WID_UNO_NUMRULES,&getCppuType((const uno::Reference<container::XIndexReplace>*)0), 0, 0 },
562 {MAP_CHAR_LEN(SC_UNONAME_OWIDTH), SC_WID_UNO_OWIDTH, &getBooleanCppuType(), 0, 0 },
563 {MAP_CHAR_LEN(SC_UNONAME_CELLORI), ATTR_STACKED, &getCppuType((table::CellOrientation*)0), 0, 0 },
564 {MAP_CHAR_LEN(SC_UNONAME_PADJUST), ATTR_HOR_JUSTIFY, &::getCppuType((const sal_Int16*)0), 0, MID_HORJUST_ADJUST },
565 {MAP_CHAR_LEN(SC_UNONAME_PBMARGIN), ATTR_MARGIN, &getCppuType((sal_Int32*)0), 0, MID_MARGIN_LO_MARGIN | CONVERT_TWIPS },
566 {MAP_CHAR_LEN(SC_UNONAME_PINDENT), ATTR_INDENT, &getCppuType((sal_Int16*)0), 0, 0 }, //! CONVERT_TWIPS
567 {MAP_CHAR_LEN(SC_UNONAME_PISCHDIST),ATTR_SCRIPTSPACE, &getBooleanCppuType(), 0, 0 },
568 {MAP_CHAR_LEN(SC_UNONAME_PISFORBID),ATTR_FORBIDDEN_RULES,&getBooleanCppuType(), 0, 0 },
569 {MAP_CHAR_LEN(SC_UNONAME_PISHANG), ATTR_HANGPUNCTUATION,&getBooleanCppuType(), 0, 0 },
570 {MAP_CHAR_LEN(SC_UNONAME_PISHYPHEN),ATTR_HYPHENATE, &getBooleanCppuType(), 0, 0 },
571 {MAP_CHAR_LEN(SC_UNONAME_PLASTADJ), ATTR_HOR_JUSTIFY, &::getCppuType((const sal_Int16*)0), 0, MID_HORJUST_ADJUST },
572 {MAP_CHAR_LEN(SC_UNONAME_PLMARGIN), ATTR_MARGIN, &getCppuType((sal_Int32*)0), 0, MID_MARGIN_L_MARGIN | CONVERT_TWIPS },
573 {MAP_CHAR_LEN(SC_UNONAME_PRMARGIN), ATTR_MARGIN, &getCppuType((sal_Int32*)0), 0, MID_MARGIN_R_MARGIN | CONVERT_TWIPS },
574 {MAP_CHAR_LEN(SC_UNONAME_PTMARGIN), ATTR_MARGIN, &getCppuType((sal_Int32*)0), 0, MID_MARGIN_UP_MARGIN | CONVERT_TWIPS },
575 {MAP_CHAR_LEN(SC_UNONAME_POS), SC_WID_UNO_POS, &getCppuType((awt::Point*)0), 0 | beans::PropertyAttribute::READONLY, 0 },
576 {MAP_CHAR_LEN(SC_UNONAME_RIGHTBORDER),ATTR_BORDER, &::getCppuType((const table::BorderLine*)0), 0, RIGHT_BORDER | CONVERT_TWIPS },
577 {MAP_CHAR_LEN(SC_UNONAME_RIGHTBORDER2),ATTR_BORDER, &::getCppuType((const table::BorderLine2*)0), 0, RIGHT_BORDER | CONVERT_TWIPS },
578 {MAP_CHAR_LEN(SC_UNONAME_ROTANG), ATTR_ROTATE_VALUE, &getCppuType((sal_Int32*)0), 0, 0 },
579 {MAP_CHAR_LEN(SC_UNONAME_ROTREF), ATTR_ROTATE_MODE, &getCppuType((sal_Int32*)0), 0, 0 },
580 {MAP_CHAR_LEN(SC_UNONAME_SHADOW), ATTR_SHADOW, &getCppuType((table::ShadowFormat*)0), 0, 0 | CONVERT_TWIPS },
581 {MAP_CHAR_LEN(SC_UNONAME_SHRINK_TO_FIT), ATTR_SHRINKTOFIT, &getBooleanCppuType(), 0, 0 },
582 {MAP_CHAR_LEN(SC_UNONAME_SIZE), SC_WID_UNO_SIZE, &getCppuType((awt::Size*)0), 0 | beans::PropertyAttribute::READONLY, 0 },
583 {MAP_CHAR_LEN(SC_UNONAME_TBLBORD), SC_WID_UNO_TBLBORD, &getCppuType((table::TableBorder*)0), 0, 0 | CONVERT_TWIPS },
584 {MAP_CHAR_LEN(SC_UNONAME_TBLBORD2), SC_WID_UNO_TBLBORD2, &getCppuType((table::TableBorder2*)0), 0, 0 | CONVERT_TWIPS },
585 {MAP_CHAR_LEN(SC_UNONAME_TOPBORDER),ATTR_BORDER, &::getCppuType((const table::BorderLine*)0), 0, TOP_BORDER | CONVERT_TWIPS },
586 {MAP_CHAR_LEN(SC_UNONAME_TOPBORDER2),ATTR_BORDER, &::getCppuType((const table::BorderLine2*)0), 0, TOP_BORDER | CONVERT_TWIPS },
587 {MAP_CHAR_LEN(SC_UNONAME_USERDEF), ATTR_USERDEF, &getCppuType((uno::Reference<container::XNameContainer>*)0), 0, 0 },
588 {MAP_CHAR_LEN(SC_UNONAME_VALIDAT), SC_WID_UNO_VALIDAT, &getCppuType((uno::Reference<beans::XPropertySet>*)0), 0, 0 },
589 {MAP_CHAR_LEN(SC_UNONAME_VALILOC), SC_WID_UNO_VALILOC, &getCppuType((uno::Reference<beans::XPropertySet>*)0), 0, 0 },
590 {MAP_CHAR_LEN(SC_UNONAME_VALIXML), SC_WID_UNO_VALIXML, &getCppuType((uno::Reference<beans::XPropertySet>*)0), 0, 0 },
591 {MAP_CHAR_LEN(SC_UNONAME_CELLVJUS), ATTR_VER_JUSTIFY, &getCppuType((sal_Int32*)0), 0, 0 },
592 {MAP_CHAR_LEN(SC_UNONAME_CELLVJUS_METHOD), ATTR_VER_JUSTIFY_METHOD, &::getCppuType((const sal_Int32*)0), 0, 0 },
593 {MAP_CHAR_LEN(SC_UNONAME_CELLWID), SC_WID_UNO_CELLWID, &getCppuType((sal_Int32*)0), 0, 0 },
594 {MAP_CHAR_LEN(SC_UNONAME_WRITING), ATTR_WRITINGDIR, &getCppuType((sal_Int16*)0), 0, 0 },
595 {0,0,0,0,0,0}
597 static SfxItemPropertySet aColumnPropertySet( aColumnPropertyMap_Impl );
598 return &aColumnPropertySet;
601 static const SfxItemPropertySet* lcl_GetRowPropertySet()
603 static const SfxItemPropertyMapEntry aRowPropertyMap_Impl[] =
605 {MAP_CHAR_LEN(SC_UNONAME_ABSNAME), SC_WID_UNO_ABSNAME, &getCppuType((OUString*)0), 0 | beans::PropertyAttribute::READONLY, 0 },
606 {MAP_CHAR_LEN(SC_UNONAME_ASIANVERT),ATTR_VERTICAL_ASIAN,&getBooleanCppuType(), 0, 0 },
607 {MAP_CHAR_LEN(SC_UNONAME_BOTTBORDER),ATTR_BORDER, &::getCppuType((const table::BorderLine*)0), 0, BOTTOM_BORDER | CONVERT_TWIPS },
608 {MAP_CHAR_LEN(SC_UNONAME_BOTTBORDER2),ATTR_BORDER, &::getCppuType((const table::BorderLine2*)0), 0, BOTTOM_BORDER | CONVERT_TWIPS },
609 {MAP_CHAR_LEN(SC_UNONAME_CELLBACK), ATTR_BACKGROUND, &getCppuType((sal_Int32*)0), 0, MID_BACK_COLOR },
610 {MAP_CHAR_LEN(SC_UNONAME_CELLPRO), ATTR_PROTECTION, &getCppuType((util::CellProtection*)0), 0, 0 },
611 {MAP_CHAR_LEN(SC_UNONAME_CELLSTYL), SC_WID_UNO_CELLSTYL,&getCppuType((OUString*)0), 0, 0 },
612 {MAP_CHAR_LEN(SC_UNONAME_CCOLOR), ATTR_FONT_COLOR, &getCppuType((sal_Int32*)0), 0, 0 },
613 {MAP_CHAR_LEN(SC_UNONAME_COUTL), ATTR_FONT_CONTOUR, &getBooleanCppuType(), 0, 0 },
614 {MAP_CHAR_LEN(SC_UNONAME_CCROSS), ATTR_FONT_CROSSEDOUT,&getBooleanCppuType(), 0, MID_CROSSED_OUT },
615 {MAP_CHAR_LEN(SC_UNONAME_CEMPHAS), ATTR_FONT_EMPHASISMARK,&getCppuType((sal_Int16*)0), 0, MID_EMPHASIS },
616 {MAP_CHAR_LEN(SC_UNONAME_CFONT), ATTR_FONT, &getCppuType((sal_Int16*)0), 0, MID_FONT_FAMILY },
617 {MAP_CHAR_LEN(SC_UNONAME_CFCHARS), ATTR_FONT, &getCppuType((sal_Int16*)0), 0, MID_FONT_CHAR_SET },
618 {MAP_CHAR_LEN(SC_UNO_CJK_CFCHARS), ATTR_CJK_FONT, &getCppuType((sal_Int16*)0), 0, MID_FONT_CHAR_SET },
619 {MAP_CHAR_LEN(SC_UNO_CTL_CFCHARS), ATTR_CTL_FONT, &getCppuType((sal_Int16*)0), 0, MID_FONT_CHAR_SET },
620 {MAP_CHAR_LEN(SC_UNONAME_CFFAMIL), ATTR_FONT, &getCppuType((sal_Int16*)0), 0, MID_FONT_FAMILY },
621 {MAP_CHAR_LEN(SC_UNO_CJK_CFFAMIL), ATTR_CJK_FONT, &getCppuType((sal_Int16*)0), 0, MID_FONT_FAMILY },
622 {MAP_CHAR_LEN(SC_UNO_CTL_CFFAMIL), ATTR_CTL_FONT, &getCppuType((sal_Int16*)0), 0, MID_FONT_FAMILY },
623 {MAP_CHAR_LEN(SC_UNONAME_CFNAME), ATTR_FONT, &getCppuType((OUString*)0), 0, MID_FONT_FAMILY_NAME },
624 {MAP_CHAR_LEN(SC_UNO_CJK_CFNAME), ATTR_CJK_FONT, &getCppuType((OUString*)0), 0, MID_FONT_FAMILY_NAME },
625 {MAP_CHAR_LEN(SC_UNO_CTL_CFNAME), ATTR_CTL_FONT, &getCppuType((OUString*)0), 0, MID_FONT_FAMILY_NAME },
626 {MAP_CHAR_LEN(SC_UNONAME_CFPITCH), ATTR_FONT, &getCppuType((sal_Int16*)0), 0, MID_FONT_PITCH },
627 {MAP_CHAR_LEN(SC_UNO_CJK_CFPITCH), ATTR_CJK_FONT, &getCppuType((sal_Int16*)0), 0, MID_FONT_PITCH },
628 {MAP_CHAR_LEN(SC_UNO_CTL_CFPITCH), ATTR_CTL_FONT, &getCppuType((sal_Int16*)0), 0, MID_FONT_PITCH },
629 {MAP_CHAR_LEN(SC_UNONAME_CFSTYLE), ATTR_FONT, &getCppuType((OUString*)0), 0, MID_FONT_STYLE_NAME },
630 {MAP_CHAR_LEN(SC_UNO_CJK_CFSTYLE), ATTR_CJK_FONT, &getCppuType((OUString*)0), 0, MID_FONT_STYLE_NAME },
631 {MAP_CHAR_LEN(SC_UNO_CTL_CFSTYLE), ATTR_CTL_FONT, &getCppuType((OUString*)0), 0, MID_FONT_STYLE_NAME },
632 {MAP_CHAR_LEN(SC_UNONAME_CHEIGHT), ATTR_FONT_HEIGHT, &getCppuType((float*)0), 0, MID_FONTHEIGHT | CONVERT_TWIPS },
633 {MAP_CHAR_LEN(SC_UNO_CJK_CHEIGHT), ATTR_CJK_FONT_HEIGHT,&getCppuType((float*)0), 0, MID_FONTHEIGHT | CONVERT_TWIPS },
634 {MAP_CHAR_LEN(SC_UNO_CTL_CHEIGHT), ATTR_CTL_FONT_HEIGHT,&getCppuType((float*)0), 0, MID_FONTHEIGHT | CONVERT_TWIPS },
635 {MAP_CHAR_LEN(SC_UNONAME_CLOCAL), ATTR_FONT_LANGUAGE, &getCppuType((lang::Locale*)0), 0, MID_LANG_LOCALE },
636 {MAP_CHAR_LEN(SC_UNO_CJK_CLOCAL), ATTR_CJK_FONT_LANGUAGE,&getCppuType((lang::Locale*)0), 0, MID_LANG_LOCALE },
637 {MAP_CHAR_LEN(SC_UNO_CTL_CLOCAL), ATTR_CTL_FONT_LANGUAGE,&getCppuType((lang::Locale*)0), 0, MID_LANG_LOCALE },
638 {MAP_CHAR_LEN(SC_UNONAME_COVER), ATTR_FONT_OVERLINE, &getCppuType((sal_Int16*)0), 0, MID_TL_STYLE },
639 {MAP_CHAR_LEN(SC_UNONAME_COVRLCOL), ATTR_FONT_OVERLINE, &getCppuType((sal_Int32*)0), 0, MID_TL_COLOR },
640 {MAP_CHAR_LEN(SC_UNONAME_COVRLHAS), ATTR_FONT_OVERLINE, &getBooleanCppuType(), 0, MID_TL_HASCOLOR },
641 {MAP_CHAR_LEN(SC_UNONAME_CPOST), ATTR_FONT_POSTURE, &getCppuType((awt::FontSlant*)0), 0, MID_POSTURE },
642 {MAP_CHAR_LEN(SC_UNO_CJK_CPOST), ATTR_CJK_FONT_POSTURE,&getCppuType((awt::FontSlant*)0), 0, MID_POSTURE },
643 {MAP_CHAR_LEN(SC_UNO_CTL_CPOST), ATTR_CTL_FONT_POSTURE,&getCppuType((awt::FontSlant*)0), 0, MID_POSTURE },
644 {MAP_CHAR_LEN(SC_UNONAME_CRELIEF), ATTR_FONT_RELIEF, &getCppuType((sal_Int16*)0), 0, MID_RELIEF },
645 {MAP_CHAR_LEN(SC_UNONAME_CSHADD), ATTR_FONT_SHADOWED, &getBooleanCppuType(), 0, 0 },
646 {MAP_CHAR_LEN(SC_UNONAME_CSTRIKE), ATTR_FONT_CROSSEDOUT,&getCppuType((sal_Int16*)0), 0, MID_CROSS_OUT },
647 {MAP_CHAR_LEN(SC_UNONAME_CUNDER), ATTR_FONT_UNDERLINE,&getCppuType((sal_Int16*)0), 0, MID_TL_STYLE },
648 {MAP_CHAR_LEN(SC_UNONAME_CUNDLCOL), ATTR_FONT_UNDERLINE,&getCppuType((sal_Int32*)0), 0, MID_TL_COLOR },
649 {MAP_CHAR_LEN(SC_UNONAME_CUNDLHAS), ATTR_FONT_UNDERLINE,&getBooleanCppuType(), 0, MID_TL_HASCOLOR },
650 {MAP_CHAR_LEN(SC_UNONAME_CWEIGHT), ATTR_FONT_WEIGHT, &getCppuType((float*)0), 0, MID_WEIGHT },
651 {MAP_CHAR_LEN(SC_UNO_CJK_CWEIGHT), ATTR_CJK_FONT_WEIGHT,&getCppuType((float*)0), 0, MID_WEIGHT },
652 {MAP_CHAR_LEN(SC_UNO_CTL_CWEIGHT), ATTR_CTL_FONT_WEIGHT,&getCppuType((float*)0), 0, MID_WEIGHT },
653 {MAP_CHAR_LEN(SC_UNONAME_CWORDMOD), ATTR_FONT_WORDLINE, &getBooleanCppuType(), 0, 0 },
654 {MAP_CHAR_LEN(SC_UNONAME_CHCOLHDR), SC_WID_UNO_CHCOLHDR,&getBooleanCppuType(), 0, 0 },
655 {MAP_CHAR_LEN(SC_UNONAME_CHROWHDR), SC_WID_UNO_CHROWHDR,&getBooleanCppuType(), 0, 0 },
656 {MAP_CHAR_LEN(SC_UNONAME_CONDFMT), SC_WID_UNO_CONDFMT, &getCppuType((uno::Reference<sheet::XSheetConditionalEntries>*)0), 0, 0 },
657 {MAP_CHAR_LEN(SC_UNONAME_CONDLOC), SC_WID_UNO_CONDLOC, &getCppuType((uno::Reference<sheet::XSheetConditionalEntries>*)0), 0, 0 },
658 {MAP_CHAR_LEN(SC_UNONAME_CONDXML), SC_WID_UNO_CONDXML, &getCppuType((uno::Reference<sheet::XSheetConditionalEntries>*)0), 0, 0 },
659 {MAP_CHAR_LEN(SC_UNONAME_DIAGONAL_BLTR), ATTR_BORDER_BLTR, &::getCppuType((const table::BorderLine*)0), 0, 0 | CONVERT_TWIPS },
660 {MAP_CHAR_LEN(SC_UNONAME_DIAGONAL_BLTR2), ATTR_BORDER_BLTR, &::getCppuType((const table::BorderLine2*)0), 0, 0 | CONVERT_TWIPS },
661 {MAP_CHAR_LEN(SC_UNONAME_DIAGONAL_TLBR), ATTR_BORDER_TLBR, &::getCppuType((const table::BorderLine*)0), 0, 0 | CONVERT_TWIPS },
662 {MAP_CHAR_LEN(SC_UNONAME_DIAGONAL_TLBR2), ATTR_BORDER_TLBR, &::getCppuType((const table::BorderLine2*)0), 0, 0 | CONVERT_TWIPS },
663 {MAP_CHAR_LEN(SC_UNONAME_CELLHGT), SC_WID_UNO_CELLHGT, &getCppuType((sal_Int32*)0), 0, 0 },
664 {MAP_CHAR_LEN(SC_UNONAME_CELLHJUS), ATTR_HOR_JUSTIFY, &getCppuType((table::CellHoriJustify*)0), 0, MID_HORJUST_HORJUST },
665 {MAP_CHAR_LEN(SC_UNONAME_CELLHJUS_METHOD), ATTR_HOR_JUSTIFY_METHOD, &::getCppuType((const sal_Int32*)0), 0, 0 },
666 {MAP_CHAR_LEN(SC_UNONAME_CELLTRAN), ATTR_BACKGROUND, &getBooleanCppuType(), 0, MID_GRAPHIC_TRANSPARENT },
667 {MAP_CHAR_LEN(SC_UNONAME_CELLFILT), SC_WID_UNO_CELLFILT,&getBooleanCppuType(), 0, 0 },
668 {MAP_CHAR_LEN(SC_UNONAME_MANPAGE), SC_WID_UNO_MANPAGE, &getBooleanCppuType(), 0, 0 },
669 {MAP_CHAR_LEN(SC_UNONAME_NEWPAGE), SC_WID_UNO_NEWPAGE, &getBooleanCppuType(), 0, 0 },
670 {MAP_CHAR_LEN(SC_UNONAME_WRAP), ATTR_LINEBREAK, &getBooleanCppuType(), 0, 0 },
671 {MAP_CHAR_LEN(SC_UNONAME_CELLVIS), SC_WID_UNO_CELLVIS, &getBooleanCppuType(), 0, 0 },
672 {MAP_CHAR_LEN(SC_UNONAME_LEFTBORDER),ATTR_BORDER, &::getCppuType((const table::BorderLine*)0), 0, LEFT_BORDER | CONVERT_TWIPS },
673 {MAP_CHAR_LEN(SC_UNONAME_LEFTBORDER2),ATTR_BORDER, &::getCppuType((const table::BorderLine2*)0), 0, LEFT_BORDER | CONVERT_TWIPS },
674 {MAP_CHAR_LEN(SC_UNONAME_NUMFMT), ATTR_VALUE_FORMAT, &getCppuType((sal_Int32*)0), 0, 0 },
675 {MAP_CHAR_LEN(SC_UNONAME_NUMRULES), SC_WID_UNO_NUMRULES,&getCppuType((const uno::Reference<container::XIndexReplace>*)0), 0, 0 },
676 {MAP_CHAR_LEN(SC_UNONAME_OHEIGHT), SC_WID_UNO_OHEIGHT, &getBooleanCppuType(), 0, 0 },
677 {MAP_CHAR_LEN(SC_UNONAME_CELLORI), ATTR_STACKED, &getCppuType((table::CellOrientation*)0), 0, 0 },
678 {MAP_CHAR_LEN(SC_UNONAME_PADJUST), ATTR_HOR_JUSTIFY, &::getCppuType((const sal_Int16*)0), 0, MID_HORJUST_ADJUST },
679 {MAP_CHAR_LEN(SC_UNONAME_PBMARGIN), ATTR_MARGIN, &getCppuType((sal_Int32*)0), 0, MID_MARGIN_LO_MARGIN | CONVERT_TWIPS },
680 {MAP_CHAR_LEN(SC_UNONAME_PINDENT), ATTR_INDENT, &getCppuType((sal_Int16*)0), 0, 0 }, //! CONVERT_TWIPS
681 {MAP_CHAR_LEN(SC_UNONAME_PISCHDIST),ATTR_SCRIPTSPACE, &getBooleanCppuType(), 0, 0 },
682 {MAP_CHAR_LEN(SC_UNONAME_PISFORBID),ATTR_FORBIDDEN_RULES,&getBooleanCppuType(), 0, 0 },
683 {MAP_CHAR_LEN(SC_UNONAME_PISHANG), ATTR_HANGPUNCTUATION,&getBooleanCppuType(), 0, 0 },
684 {MAP_CHAR_LEN(SC_UNONAME_PISHYPHEN),ATTR_HYPHENATE, &getBooleanCppuType(), 0, 0 },
685 {MAP_CHAR_LEN(SC_UNONAME_PLASTADJ), ATTR_HOR_JUSTIFY, &::getCppuType((const sal_Int16*)0), 0, MID_HORJUST_ADJUST },
686 {MAP_CHAR_LEN(SC_UNONAME_PLMARGIN), ATTR_MARGIN, &getCppuType((sal_Int32*)0), 0, MID_MARGIN_L_MARGIN | CONVERT_TWIPS },
687 {MAP_CHAR_LEN(SC_UNONAME_PRMARGIN), ATTR_MARGIN, &getCppuType((sal_Int32*)0), 0, MID_MARGIN_R_MARGIN | CONVERT_TWIPS },
688 {MAP_CHAR_LEN(SC_UNONAME_PTMARGIN), ATTR_MARGIN, &getCppuType((sal_Int32*)0), 0, MID_MARGIN_UP_MARGIN | CONVERT_TWIPS },
689 {MAP_CHAR_LEN(SC_UNONAME_POS), SC_WID_UNO_POS, &getCppuType((awt::Point*)0), 0 | beans::PropertyAttribute::READONLY, 0 },
690 {MAP_CHAR_LEN(SC_UNONAME_RIGHTBORDER),ATTR_BORDER, &::getCppuType((const table::BorderLine*)0), 0, RIGHT_BORDER | CONVERT_TWIPS },
691 {MAP_CHAR_LEN(SC_UNONAME_RIGHTBORDER2),ATTR_BORDER, &::getCppuType((const table::BorderLine2*)0), 0, RIGHT_BORDER | CONVERT_TWIPS },
692 {MAP_CHAR_LEN(SC_UNONAME_ROTANG), ATTR_ROTATE_VALUE, &getCppuType((sal_Int32*)0), 0, 0 },
693 {MAP_CHAR_LEN(SC_UNONAME_ROTREF), ATTR_ROTATE_MODE, &getCppuType((sal_Int32*)0), 0, 0 },
694 {MAP_CHAR_LEN(SC_UNONAME_SHADOW), ATTR_SHADOW, &getCppuType((table::ShadowFormat*)0), 0, 0 | CONVERT_TWIPS },
695 {MAP_CHAR_LEN(SC_UNONAME_SHRINK_TO_FIT), ATTR_SHRINKTOFIT, &getBooleanCppuType(), 0, 0 },
696 {MAP_CHAR_LEN(SC_UNONAME_SIZE), SC_WID_UNO_SIZE, &getCppuType((awt::Size*)0), 0 | beans::PropertyAttribute::READONLY, 0 },
697 {MAP_CHAR_LEN(SC_UNONAME_TBLBORD), SC_WID_UNO_TBLBORD, &getCppuType((table::TableBorder*)0), 0, 0 | CONVERT_TWIPS },
698 {MAP_CHAR_LEN(SC_UNONAME_TBLBORD2), SC_WID_UNO_TBLBORD2, &getCppuType((table::TableBorder2*)0), 0, 0 | CONVERT_TWIPS },
699 {MAP_CHAR_LEN(SC_UNONAME_TOPBORDER),ATTR_BORDER, &::getCppuType((const table::BorderLine*)0), 0, TOP_BORDER | CONVERT_TWIPS },
700 {MAP_CHAR_LEN(SC_UNONAME_TOPBORDER2),ATTR_BORDER, &::getCppuType((const table::BorderLine2*)0), 0, TOP_BORDER | CONVERT_TWIPS },
701 {MAP_CHAR_LEN(SC_UNONAME_USERDEF), ATTR_USERDEF, &getCppuType((uno::Reference<container::XNameContainer>*)0), 0, 0 },
702 {MAP_CHAR_LEN(SC_UNONAME_VALIDAT), SC_WID_UNO_VALIDAT, &getCppuType((uno::Reference<beans::XPropertySet>*)0), 0, 0 },
703 {MAP_CHAR_LEN(SC_UNONAME_VALILOC), SC_WID_UNO_VALILOC, &getCppuType((uno::Reference<beans::XPropertySet>*)0), 0, 0 },
704 {MAP_CHAR_LEN(SC_UNONAME_VALIXML), SC_WID_UNO_VALIXML, &getCppuType((uno::Reference<beans::XPropertySet>*)0), 0, 0 },
705 {MAP_CHAR_LEN(SC_UNONAME_CELLVJUS), ATTR_VER_JUSTIFY, &getCppuType((sal_Int32*)0), 0, 0 },
706 {MAP_CHAR_LEN(SC_UNONAME_CELLVJUS_METHOD), ATTR_VER_JUSTIFY_METHOD, &::getCppuType((const sal_Int32*)0), 0, 0 },
707 {MAP_CHAR_LEN(SC_UNONAME_WRITING), ATTR_WRITINGDIR, &getCppuType((sal_Int16*)0), 0, 0 },
708 {0,0,0,0,0,0}
710 static SfxItemPropertySet aRowPropertySet( aRowPropertyMap_Impl );
711 return &aRowPropertySet;
714 static const SfxItemPropertySet* lcl_GetSheetPropertySet()
716 static const SfxItemPropertyMapEntry aSheetPropertyMap_Impl[] =
718 {MAP_CHAR_LEN(SC_UNONAME_ABSNAME), SC_WID_UNO_ABSNAME, &getCppuType((OUString*)0), 0 | beans::PropertyAttribute::READONLY, 0 },
719 {MAP_CHAR_LEN(SC_UNONAME_ASIANVERT),ATTR_VERTICAL_ASIAN,&getBooleanCppuType(), 0, 0 },
720 {MAP_CHAR_LEN(SC_UNONAME_AUTOPRINT),SC_WID_UNO_AUTOPRINT,&getBooleanCppuType(), 0, 0 },
721 {MAP_CHAR_LEN(SC_UNONAME_BORDCOL), SC_WID_UNO_BORDCOL, &getCppuType((sal_Int32*)0), 0, 0 },
722 {MAP_CHAR_LEN(SC_UNONAME_BOTTBORDER),ATTR_BORDER, &::getCppuType((const table::BorderLine*)0), 0, BOTTOM_BORDER | CONVERT_TWIPS },
723 {MAP_CHAR_LEN(SC_UNONAME_BOTTBORDER2),ATTR_BORDER, &::getCppuType((const table::BorderLine2*)0), 0, BOTTOM_BORDER | CONVERT_TWIPS },
724 {MAP_CHAR_LEN(SC_UNONAME_CELLBACK), ATTR_BACKGROUND, &getCppuType((sal_Int32*)0), 0, MID_BACK_COLOR },
725 {MAP_CHAR_LEN(SC_UNONAME_CELLPRO), ATTR_PROTECTION, &getCppuType((util::CellProtection*)0), 0, 0 },
726 {MAP_CHAR_LEN(SC_UNONAME_CELLSTYL), SC_WID_UNO_CELLSTYL,&getCppuType((OUString*)0), 0, 0 },
727 {MAP_CHAR_LEN(SC_UNONAME_CCOLOR), ATTR_FONT_COLOR, &getCppuType((sal_Int32*)0), 0, 0 },
728 {MAP_CHAR_LEN(SC_UNONAME_COUTL), ATTR_FONT_CONTOUR, &getBooleanCppuType(), 0, 0 },
729 {MAP_CHAR_LEN(SC_UNONAME_CCROSS), ATTR_FONT_CROSSEDOUT,&getBooleanCppuType(), 0, MID_CROSSED_OUT },
730 {MAP_CHAR_LEN(SC_UNONAME_CEMPHAS), ATTR_FONT_EMPHASISMARK,&getCppuType((sal_Int16*)0), 0, MID_EMPHASIS },
731 {MAP_CHAR_LEN(SC_UNONAME_CFONT), ATTR_FONT, &getCppuType((sal_Int16*)0), 0, MID_FONT_FAMILY },
732 {MAP_CHAR_LEN(SC_UNONAME_CFCHARS), ATTR_FONT, &getCppuType((sal_Int16*)0), 0, MID_FONT_CHAR_SET },
733 {MAP_CHAR_LEN(SC_UNO_CJK_CFCHARS), ATTR_CJK_FONT, &getCppuType((sal_Int16*)0), 0, MID_FONT_CHAR_SET },
734 {MAP_CHAR_LEN(SC_UNO_CTL_CFCHARS), ATTR_CTL_FONT, &getCppuType((sal_Int16*)0), 0, MID_FONT_CHAR_SET },
735 {MAP_CHAR_LEN(SC_UNONAME_CFFAMIL), ATTR_FONT, &getCppuType((sal_Int16*)0), 0, MID_FONT_FAMILY },
736 {MAP_CHAR_LEN(SC_UNO_CJK_CFFAMIL), ATTR_CJK_FONT, &getCppuType((sal_Int16*)0), 0, MID_FONT_FAMILY },
737 {MAP_CHAR_LEN(SC_UNO_CTL_CFFAMIL), ATTR_CTL_FONT, &getCppuType((sal_Int16*)0), 0, MID_FONT_FAMILY },
738 {MAP_CHAR_LEN(SC_UNONAME_CFNAME), ATTR_FONT, &getCppuType((OUString*)0), 0, MID_FONT_FAMILY_NAME },
739 {MAP_CHAR_LEN(SC_UNO_CJK_CFNAME), ATTR_CJK_FONT, &getCppuType((OUString*)0), 0, MID_FONT_FAMILY_NAME },
740 {MAP_CHAR_LEN(SC_UNO_CTL_CFNAME), ATTR_CTL_FONT, &getCppuType((OUString*)0), 0, MID_FONT_FAMILY_NAME },
741 {MAP_CHAR_LEN(SC_UNONAME_CFPITCH), ATTR_FONT, &getCppuType((sal_Int16*)0), 0, MID_FONT_PITCH },
742 {MAP_CHAR_LEN(SC_UNO_CJK_CFPITCH), ATTR_CJK_FONT, &getCppuType((sal_Int16*)0), 0, MID_FONT_PITCH },
743 {MAP_CHAR_LEN(SC_UNO_CTL_CFPITCH), ATTR_CTL_FONT, &getCppuType((sal_Int16*)0), 0, MID_FONT_PITCH },
744 {MAP_CHAR_LEN(SC_UNONAME_CFSTYLE), ATTR_FONT, &getCppuType((OUString*)0), 0, MID_FONT_STYLE_NAME },
745 {MAP_CHAR_LEN(SC_UNO_CJK_CFSTYLE), ATTR_CJK_FONT, &getCppuType((OUString*)0), 0, MID_FONT_STYLE_NAME },
746 {MAP_CHAR_LEN(SC_UNO_CTL_CFSTYLE), ATTR_CTL_FONT, &getCppuType((OUString*)0), 0, MID_FONT_STYLE_NAME },
747 {MAP_CHAR_LEN(SC_UNONAME_CHEIGHT), ATTR_FONT_HEIGHT, &getCppuType((float*)0), 0, MID_FONTHEIGHT | CONVERT_TWIPS },
748 {MAP_CHAR_LEN(SC_UNO_CJK_CHEIGHT), ATTR_CJK_FONT_HEIGHT,&getCppuType((float*)0), 0, MID_FONTHEIGHT | CONVERT_TWIPS },
749 {MAP_CHAR_LEN(SC_UNO_CTL_CHEIGHT), ATTR_CTL_FONT_HEIGHT,&getCppuType((float*)0), 0, MID_FONTHEIGHT | CONVERT_TWIPS },
750 {MAP_CHAR_LEN(SC_UNONAME_CLOCAL), ATTR_FONT_LANGUAGE, &getCppuType((lang::Locale*)0), 0, MID_LANG_LOCALE },
751 {MAP_CHAR_LEN(SC_UNO_CJK_CLOCAL), ATTR_CJK_FONT_LANGUAGE,&getCppuType((lang::Locale*)0), 0, MID_LANG_LOCALE },
752 {MAP_CHAR_LEN(SC_UNO_CTL_CLOCAL), ATTR_CTL_FONT_LANGUAGE,&getCppuType((lang::Locale*)0), 0, MID_LANG_LOCALE },
753 {MAP_CHAR_LEN(SC_UNONAME_COVER), ATTR_FONT_OVERLINE, &getCppuType((sal_Int16*)0), 0, MID_TL_STYLE },
754 {MAP_CHAR_LEN(SC_UNONAME_COVRLCOL), ATTR_FONT_OVERLINE, &getCppuType((sal_Int32*)0), 0, MID_TL_COLOR },
755 {MAP_CHAR_LEN(SC_UNONAME_COVRLHAS), ATTR_FONT_OVERLINE, &getBooleanCppuType(), 0, MID_TL_HASCOLOR },
756 {MAP_CHAR_LEN(SC_UNONAME_CPOST), ATTR_FONT_POSTURE, &getCppuType((awt::FontSlant*)0), 0, MID_POSTURE },
757 {MAP_CHAR_LEN(SC_UNO_CJK_CPOST), ATTR_CJK_FONT_POSTURE,&getCppuType((awt::FontSlant*)0), 0, MID_POSTURE },
758 {MAP_CHAR_LEN(SC_UNO_CTL_CPOST), ATTR_CTL_FONT_POSTURE,&getCppuType((awt::FontSlant*)0), 0, MID_POSTURE },
759 {MAP_CHAR_LEN(SC_UNONAME_CRELIEF), ATTR_FONT_RELIEF, &getCppuType((sal_Int16*)0), 0, MID_RELIEF },
760 {MAP_CHAR_LEN(SC_UNONAME_CSHADD), ATTR_FONT_SHADOWED, &getBooleanCppuType(), 0, 0 },
761 {MAP_CHAR_LEN(SC_UNONAME_CSTRIKE), ATTR_FONT_CROSSEDOUT,&getCppuType((sal_Int16*)0), 0, MID_CROSS_OUT },
762 {MAP_CHAR_LEN(SC_UNONAME_CUNDER), ATTR_FONT_UNDERLINE,&getCppuType((sal_Int16*)0), 0, MID_TL_STYLE },
763 {MAP_CHAR_LEN(SC_UNONAME_CUNDLCOL), ATTR_FONT_UNDERLINE,&getCppuType((sal_Int32*)0), 0, MID_TL_COLOR },
764 {MAP_CHAR_LEN(SC_UNONAME_CUNDLHAS), ATTR_FONT_UNDERLINE,&getBooleanCppuType(), 0, MID_TL_HASCOLOR },
765 {MAP_CHAR_LEN(SC_UNONAME_CWEIGHT), ATTR_FONT_WEIGHT, &getCppuType((float*)0), 0, MID_WEIGHT },
766 {MAP_CHAR_LEN(SC_UNO_CJK_CWEIGHT), ATTR_CJK_FONT_WEIGHT,&getCppuType((float*)0), 0, MID_WEIGHT },
767 {MAP_CHAR_LEN(SC_UNO_CTL_CWEIGHT), ATTR_CTL_FONT_WEIGHT,&getCppuType((float*)0), 0, MID_WEIGHT },
768 {MAP_CHAR_LEN(SC_UNONAME_CWORDMOD), ATTR_FONT_WORDLINE, &getBooleanCppuType(), 0, 0 },
769 {MAP_CHAR_LEN(SC_UNONAME_CHCOLHDR), SC_WID_UNO_CHCOLHDR,&getBooleanCppuType(), 0, 0 },
770 {MAP_CHAR_LEN(SC_UNONAME_CHROWHDR), SC_WID_UNO_CHROWHDR,&getBooleanCppuType(), 0, 0 },
771 {MAP_CHAR_LEN(SC_UNONAME_CONDFMT), SC_WID_UNO_CONDFMT, &getCppuType((uno::Reference<sheet::XSheetConditionalEntries>*)0), 0, 0 },
772 {MAP_CHAR_LEN(SC_UNONAME_CONDLOC), SC_WID_UNO_CONDLOC, &getCppuType((uno::Reference<sheet::XSheetConditionalEntries>*)0), 0, 0 },
773 {MAP_CHAR_LEN(SC_UNONAME_CONDXML), SC_WID_UNO_CONDXML, &getCppuType((uno::Reference<sheet::XSheetConditionalEntries>*)0), 0, 0 },
774 {MAP_CHAR_LEN(SC_UNONAME_COPYBACK), SC_WID_UNO_COPYBACK,&getBooleanCppuType(), 0, 0 },
775 {MAP_CHAR_LEN(SC_UNONAME_COPYFORM), SC_WID_UNO_COPYFORM,&getBooleanCppuType(), 0, 0 },
776 {MAP_CHAR_LEN(SC_UNONAME_COPYSTYL), SC_WID_UNO_COPYSTYL,&getBooleanCppuType(), 0, 0 },
777 {MAP_CHAR_LEN(SC_UNONAME_DIAGONAL_BLTR), ATTR_BORDER_BLTR, &::getCppuType((const table::BorderLine*)0), 0, 0 | CONVERT_TWIPS },
778 {MAP_CHAR_LEN(SC_UNONAME_DIAGONAL_BLTR2), ATTR_BORDER_BLTR, &::getCppuType((const table::BorderLine2*)0), 0, 0 | CONVERT_TWIPS },
779 {MAP_CHAR_LEN(SC_UNONAME_DIAGONAL_TLBR), ATTR_BORDER_TLBR, &::getCppuType((const table::BorderLine*)0), 0, 0 | CONVERT_TWIPS },
780 {MAP_CHAR_LEN(SC_UNONAME_DIAGONAL_TLBR2), ATTR_BORDER_TLBR, &::getCppuType((const table::BorderLine2*)0), 0, 0 | CONVERT_TWIPS },
781 {MAP_CHAR_LEN(SC_UNONAME_CELLHJUS), ATTR_HOR_JUSTIFY, &getCppuType((table::CellHoriJustify*)0), 0, MID_HORJUST_HORJUST },
782 {MAP_CHAR_LEN(SC_UNONAME_CELLHJUS_METHOD), ATTR_HOR_JUSTIFY_METHOD, &::getCppuType((const sal_Int32*)0), 0, 0 },
783 {MAP_CHAR_LEN(SC_UNONAME_ISACTIVE), SC_WID_UNO_ISACTIVE,&getBooleanCppuType(), 0, 0 },
784 {MAP_CHAR_LEN(SC_UNONAME_CELLTRAN), ATTR_BACKGROUND, &getBooleanCppuType(), 0, MID_GRAPHIC_TRANSPARENT },
785 {MAP_CHAR_LEN(SC_UNONAME_WRAP), ATTR_LINEBREAK, &getBooleanCppuType(), 0, 0 },
786 {MAP_CHAR_LEN(SC_UNONAME_CELLVIS), SC_WID_UNO_CELLVIS, &getBooleanCppuType(), 0, 0 },
787 {MAP_CHAR_LEN(SC_UNONAME_LEFTBORDER),ATTR_BORDER, &::getCppuType((const table::BorderLine*)0), 0, LEFT_BORDER | CONVERT_TWIPS },
788 {MAP_CHAR_LEN(SC_UNONAME_LEFTBORDER2),ATTR_BORDER, &::getCppuType((const table::BorderLine2*)0), 0, LEFT_BORDER | CONVERT_TWIPS },
789 {MAP_CHAR_LEN(SC_UNO_LINKDISPBIT), SC_WID_UNO_LINKDISPBIT,&getCppuType((uno::Reference<awt::XBitmap>*)0), 0 | beans::PropertyAttribute::READONLY, 0 },
790 {MAP_CHAR_LEN(SC_UNO_LINKDISPNAME), SC_WID_UNO_LINKDISPNAME,&getCppuType((OUString*)0), 0 | beans::PropertyAttribute::READONLY, 0 },
791 {MAP_CHAR_LEN(SC_UNONAME_NUMFMT), ATTR_VALUE_FORMAT, &getCppuType((sal_Int32*)0), 0, 0 },
792 {MAP_CHAR_LEN(SC_UNONAME_NUMRULES), SC_WID_UNO_NUMRULES,&getCppuType((const uno::Reference<container::XIndexReplace>*)0), 0, 0 },
793 {MAP_CHAR_LEN(SC_UNONAME_CELLORI), ATTR_STACKED, &getCppuType((table::CellOrientation*)0), 0, 0 },
794 {MAP_CHAR_LEN(SC_UNONAME_PAGESTL), SC_WID_UNO_PAGESTL, &getCppuType((OUString*)0), 0, 0 },
795 {MAP_CHAR_LEN(SC_UNONAME_PADJUST), ATTR_HOR_JUSTIFY, &::getCppuType((const sal_Int16*)0), 0, MID_HORJUST_ADJUST },
796 {MAP_CHAR_LEN(SC_UNONAME_PBMARGIN), ATTR_MARGIN, &getCppuType((sal_Int32*)0), 0, MID_MARGIN_LO_MARGIN | CONVERT_TWIPS },
797 {MAP_CHAR_LEN(SC_UNONAME_PINDENT), ATTR_INDENT, &getCppuType((sal_Int16*)0), 0, 0 }, //! CONVERT_TWIPS
798 {MAP_CHAR_LEN(SC_UNONAME_PISCHDIST),ATTR_SCRIPTSPACE, &getBooleanCppuType(), 0, 0 },
799 {MAP_CHAR_LEN(SC_UNONAME_PISFORBID),ATTR_FORBIDDEN_RULES,&getBooleanCppuType(), 0, 0 },
800 {MAP_CHAR_LEN(SC_UNONAME_PISHANG), ATTR_HANGPUNCTUATION,&getBooleanCppuType(), 0, 0 },
801 {MAP_CHAR_LEN(SC_UNONAME_PISHYPHEN),ATTR_HYPHENATE, &getBooleanCppuType(), 0, 0 },
802 {MAP_CHAR_LEN(SC_UNONAME_PLASTADJ), ATTR_HOR_JUSTIFY, &::getCppuType((const sal_Int16*)0), 0, MID_HORJUST_ADJUST },
803 {MAP_CHAR_LEN(SC_UNONAME_PLMARGIN), ATTR_MARGIN, &getCppuType((sal_Int32*)0), 0, MID_MARGIN_L_MARGIN | CONVERT_TWIPS },
804 {MAP_CHAR_LEN(SC_UNONAME_PRMARGIN), ATTR_MARGIN, &getCppuType((sal_Int32*)0), 0, MID_MARGIN_R_MARGIN | CONVERT_TWIPS },
805 {MAP_CHAR_LEN(SC_UNONAME_PTMARGIN), ATTR_MARGIN, &getCppuType((sal_Int32*)0), 0, MID_MARGIN_UP_MARGIN | CONVERT_TWIPS },
806 {MAP_CHAR_LEN(SC_UNONAME_POS), SC_WID_UNO_POS, &getCppuType((awt::Point*)0), 0 | beans::PropertyAttribute::READONLY, 0 },
807 {MAP_CHAR_LEN(SC_UNONAME_PRINTBORD),SC_WID_UNO_PRINTBORD,&getBooleanCppuType(), 0, 0 },
808 {MAP_CHAR_LEN(SC_UNONAME_PROTECT), SC_WID_UNO_PROTECT, &getBooleanCppuType(), 0, 0 },
809 {MAP_CHAR_LEN(SC_UNONAME_RIGHTBORDER),ATTR_BORDER, &::getCppuType((const table::BorderLine*)0), 0, RIGHT_BORDER | CONVERT_TWIPS },
810 {MAP_CHAR_LEN(SC_UNONAME_RIGHTBORDER2),ATTR_BORDER, &::getCppuType((const table::BorderLine2*)0), 0, RIGHT_BORDER | CONVERT_TWIPS },
811 {MAP_CHAR_LEN(SC_UNONAME_ROTANG), ATTR_ROTATE_VALUE, &getCppuType((sal_Int32*)0), 0, 0 },
812 {MAP_CHAR_LEN(SC_UNONAME_ROTREF), ATTR_ROTATE_MODE, &getCppuType((sal_Int32*)0), 0, 0 },
813 {MAP_CHAR_LEN(SC_UNONAME_SHADOW), ATTR_SHADOW, &getCppuType((table::ShadowFormat*)0), 0, 0 | CONVERT_TWIPS },
814 {MAP_CHAR_LEN(SC_UNONAME_SHOWBORD), SC_WID_UNO_SHOWBORD,&getBooleanCppuType(), 0, 0 },
815 {MAP_CHAR_LEN(SC_UNONAME_SHRINK_TO_FIT), ATTR_SHRINKTOFIT, &getBooleanCppuType(), 0, 0 },
816 {MAP_CHAR_LEN(SC_UNONAME_SIZE), SC_WID_UNO_SIZE, &getCppuType((awt::Size*)0), 0 | beans::PropertyAttribute::READONLY, 0 },
817 {MAP_CHAR_LEN(SC_UNONAME_TBLBORD), SC_WID_UNO_TBLBORD, &getCppuType((table::TableBorder*)0), 0, 0 | CONVERT_TWIPS },
818 {MAP_CHAR_LEN(SC_UNONAME_TBLBORD2), SC_WID_UNO_TBLBORD2, &getCppuType((table::TableBorder2*)0), 0, 0 | CONVERT_TWIPS },
819 {MAP_CHAR_LEN(SC_UNONAME_TABLAYOUT),SC_WID_UNO_TABLAYOUT,&getCppuType((sal_Int16*)0), 0, 0 },
820 {MAP_CHAR_LEN(SC_UNONAME_TOPBORDER),ATTR_BORDER, &::getCppuType((const table::BorderLine*)0), 0, TOP_BORDER | CONVERT_TWIPS },
821 {MAP_CHAR_LEN(SC_UNONAME_TOPBORDER2),ATTR_BORDER, &::getCppuType((const table::BorderLine2*)0), 0, TOP_BORDER | CONVERT_TWIPS },
822 {MAP_CHAR_LEN(SC_UNONAME_USERDEF), ATTR_USERDEF, &getCppuType((uno::Reference<container::XNameContainer>*)0), 0, 0 },
823 {MAP_CHAR_LEN(SC_UNONAME_VALIDAT), SC_WID_UNO_VALIDAT, &getCppuType((uno::Reference<beans::XPropertySet>*)0), 0, 0 },
824 {MAP_CHAR_LEN(SC_UNONAME_VALILOC), SC_WID_UNO_VALILOC, &getCppuType((uno::Reference<beans::XPropertySet>*)0), 0, 0 },
825 {MAP_CHAR_LEN(SC_UNONAME_VALIXML), SC_WID_UNO_VALIXML, &getCppuType((uno::Reference<beans::XPropertySet>*)0), 0, 0 },
826 {MAP_CHAR_LEN(SC_UNONAME_CELLVJUS), ATTR_VER_JUSTIFY, &getCppuType((sal_Int32*)0), 0, 0 },
827 {MAP_CHAR_LEN(SC_UNONAME_CELLVJUS_METHOD), ATTR_VER_JUSTIFY_METHOD, &::getCppuType((const sal_Int32*)0), 0, 0 },
828 {MAP_CHAR_LEN(SC_UNONAME_WRITING), ATTR_WRITINGDIR, &getCppuType((sal_Int16*)0), 0, 0 },
829 {MAP_CHAR_LEN(SC_UNONAME_TABCOLOR), SC_WID_UNO_TABCOLOR, &getCppuType((sal_Int32*)0), 0, 0 },
830 {MAP_CHAR_LEN(SC_UNO_CODENAME), SC_WID_UNO_CODENAME, &getCppuType(static_cast< const OUString * >(0)), 0, 0},
831 {MAP_CHAR_LEN(SC_UNO_NAMEDRANGES), SC_WID_UNO_NAMES, &getCppuType((uno::Reference<sheet::XNamedRanges>*)0), 0, 0 },
832 {0,0,0,0,0,0}
834 static SfxItemPropertySet aSheetPropertySet( aSheetPropertyMap_Impl );
835 return &aSheetPropertySet;
838 static const SfxItemPropertyMapEntry* lcl_GetEditPropertyMap()
840 static const SfxItemPropertyMapEntry aEditPropertyMap_Impl[] =
842 SVX_UNOEDIT_CHAR_PROPERTIES,
843 SVX_UNOEDIT_FONT_PROPERTIES,
844 SVX_UNOEDIT_PARA_PROPERTIES,
845 SVX_UNOEDIT_NUMBERING_PROPERTIE, // for completeness of service ParagraphProperties
846 {MAP_CHAR_LEN(SC_UNONAME_TEXTUSER), EE_CHAR_XMLATTRIBS, &getCppuType((const uno::Reference< container::XNameContainer >*)0), 0, 0},
847 {MAP_CHAR_LEN(SC_UNONAME_USERDEF), EE_PARA_XMLATTRIBS, &getCppuType((const uno::Reference< container::XNameContainer >*)0), 0, 0},
848 {0,0,0,0,0,0}
850 return aEditPropertyMap_Impl;
852 static const SvxItemPropertySet* lcl_GetEditPropertySet()
854 static SvxItemPropertySet aEditPropertySet( lcl_GetEditPropertyMap(), SdrObject::GetGlobalDrawObjectItemPool() );
855 return &aEditPropertySet;
858 //------------------------------------------------------------------------
860 using sc::HMMToTwips;
861 using sc::TwipsToHMM;
863 //------------------------------------------------------------------------
865 #define SCCHARPROPERTIES_SERVICE "com.sun.star.style.CharacterProperties"
866 #define SCPARAPROPERTIES_SERVICE "com.sun.star.style.ParagraphProperties"
867 #define SCCELLPROPERTIES_SERVICE "com.sun.star.table.CellProperties"
868 #define SCCELLRANGE_SERVICE "com.sun.star.table.CellRange"
869 #define SCCELL_SERVICE "com.sun.star.table.Cell"
870 #define SCSHEETCELLRANGES_SERVICE "com.sun.star.sheet.SheetCellRanges"
871 #define SCSHEETCELLRANGE_SERVICE "com.sun.star.sheet.SheetCellRange"
872 #define SCSPREADSHEET_SERVICE "com.sun.star.sheet.Spreadsheet"
873 #define SCSHEETCELL_SERVICE "com.sun.star.sheet.SheetCell"
875 SC_SIMPLE_SERVICE_INFO( ScCellFormatsEnumeration, "ScCellFormatsEnumeration", "com.sun.star.sheet.CellFormatRangesEnumeration" )
876 SC_SIMPLE_SERVICE_INFO( ScCellFormatsObj, "ScCellFormatsObj", "com.sun.star.sheet.CellFormatRanges" )
877 SC_SIMPLE_SERVICE_INFO( ScUniqueCellFormatsEnumeration, "ScUniqueCellFormatsEnumeration", "com.sun.star.sheet.UniqueCellFormatRangesEnumeration" )
878 SC_SIMPLE_SERVICE_INFO( ScUniqueCellFormatsObj, "ScUniqueCellFormatsObj", "com.sun.star.sheet.UniqueCellFormatRanges" )
879 SC_SIMPLE_SERVICE_INFO( ScCellRangesBase, "ScCellRangesBase", "stardiv.unknown" )
880 SC_SIMPLE_SERVICE_INFO( ScCellsEnumeration, "ScCellsEnumeration", "com.sun.star.sheet.CellsEnumeration" )
881 SC_SIMPLE_SERVICE_INFO( ScCellsObj, "ScCellsObj", "com.sun.star.sheet.Cells" )
882 SC_SIMPLE_SERVICE_INFO( ScTableColumnObj, "ScTableColumnObj", "com.sun.star.table.TableColumn" )
883 SC_SIMPLE_SERVICE_INFO( ScTableRowObj, "ScTableRowObj", "com.sun.star.table.TableRow" )
885 //------------------------------------------------------------------------
887 //! ScLinkListener in anderes File verschieben !!!
889 ScLinkListener::~ScLinkListener()
893 void ScLinkListener::Notify( SvtBroadcaster&, const SfxHint& rHint )
895 aLink.Call( (SfxHint*)&rHint );
898 //------------------------------------------------------------------------
900 static void lcl_CopyProperties( beans::XPropertySet& rDest, beans::XPropertySet& rSource )
902 uno::Reference<beans::XPropertySetInfo> xInfo(rSource.getPropertySetInfo());
903 if (xInfo.is())
905 uno::Sequence<beans::Property> aSeq(xInfo->getProperties());
906 const beans::Property* pAry = aSeq.getConstArray();
907 sal_uLong nCount = aSeq.getLength();
908 for (sal_uLong i=0; i<nCount; i++)
910 OUString aName(pAry[i].Name);
911 rDest.setPropertyValue( aName, rSource.getPropertyValue( aName ) );
916 static SCTAB lcl_FirstTab( const ScRangeList& rRanges )
918 OSL_ENSURE(rRanges.size() >= 1, "was fuer Ranges ?!?!");
919 const ScRange* pFirst = rRanges[ 0 ];
920 if (pFirst)
921 return pFirst->aStart.Tab();
923 return 0; // soll nicht sein
926 static sal_Bool lcl_WholeSheet( const ScRangeList& rRanges )
928 if ( rRanges.size() == 1 )
930 const ScRange* pRange = rRanges[0];
931 if ( pRange && pRange->aStart.Col() == 0 && pRange->aEnd.Col() == MAXCOL &&
932 pRange->aStart.Row() == 0 && pRange->aEnd.Row() == MAXROW )
933 return sal_True;
935 return false;
938 namespace {
939 template<typename BorderLineType>
940 const ::editeng::SvxBorderLine* lcl_getBorderLine(
941 ::editeng::SvxBorderLine& rLine, const BorderLineType& rStruct )
943 // Convert from 1/100mm to Twips.
944 if (!SvxBoxItem::LineToSvxLine( rStruct, rLine, true))
945 return NULL;
947 if ( rLine.GetOutWidth() || rLine.GetInWidth() || rLine.GetDistance() )
948 return &rLine;
949 else
950 return NULL;
954 const ::editeng::SvxBorderLine* ScHelperFunctions::GetBorderLine(
955 ::editeng::SvxBorderLine& rLine, const table::BorderLine& rStruct )
957 return lcl_getBorderLine( rLine, rStruct);
960 const ::editeng::SvxBorderLine* ScHelperFunctions::GetBorderLine(
961 ::editeng::SvxBorderLine& rLine, const table::BorderLine2& rStruct )
963 return lcl_getBorderLine( rLine, rStruct);
967 namespace {
968 template<typename TableBorderType>
969 void lcl_fillBoxItems( SvxBoxItem& rOuter, SvxBoxInfoItem& rInner, const TableBorderType& rBorder )
971 ::editeng::SvxBorderLine aLine;
972 rOuter.SetDistance( (sal_uInt16)HMMToTwips( rBorder.Distance ) );
973 rOuter.SetLine( ScHelperFunctions::GetBorderLine( aLine, rBorder.TopLine ), BOX_LINE_TOP );
974 rOuter.SetLine( ScHelperFunctions::GetBorderLine( aLine, rBorder.BottomLine ), BOX_LINE_BOTTOM );
975 rOuter.SetLine( ScHelperFunctions::GetBorderLine( aLine, rBorder.LeftLine ), BOX_LINE_LEFT );
976 rOuter.SetLine( ScHelperFunctions::GetBorderLine( aLine, rBorder.RightLine ), BOX_LINE_RIGHT );
977 rInner.SetLine( ScHelperFunctions::GetBorderLine( aLine, rBorder.HorizontalLine ), BOXINFO_LINE_HORI );
978 rInner.SetLine( ScHelperFunctions::GetBorderLine( aLine, rBorder.VerticalLine ), BOXINFO_LINE_VERT );
979 rInner.SetValid( VALID_TOP, rBorder.IsTopLineValid );
980 rInner.SetValid( VALID_BOTTOM, rBorder.IsBottomLineValid );
981 rInner.SetValid( VALID_LEFT, rBorder.IsLeftLineValid );
982 rInner.SetValid( VALID_RIGHT, rBorder.IsRightLineValid );
983 rInner.SetValid( VALID_HORI, rBorder.IsHorizontalLineValid );
984 rInner.SetValid( VALID_VERT, rBorder.IsVerticalLineValid );
985 rInner.SetValid( VALID_DISTANCE, rBorder.IsDistanceValid );
986 rInner.SetTable( sal_True );
990 void ScHelperFunctions::FillBoxItems( SvxBoxItem& rOuter, SvxBoxInfoItem& rInner, const table::TableBorder& rBorder )
992 lcl_fillBoxItems( rOuter, rInner, rBorder);
995 void ScHelperFunctions::FillBoxItems( SvxBoxItem& rOuter, SvxBoxInfoItem& rInner, const table::TableBorder2& rBorder )
997 lcl_fillBoxItems( rOuter, rInner, rBorder);
1001 void ScHelperFunctions::FillBorderLine( table::BorderLine& rStruct, const ::editeng::SvxBorderLine* pLine )
1003 // Convert from Twips to 1/100mm.
1004 table::BorderLine2 aStruct( SvxBoxItem::SvxLineToLine( pLine, true));
1005 rStruct = aStruct;
1008 void ScHelperFunctions::FillBorderLine( table::BorderLine2& rStruct, const ::editeng::SvxBorderLine* pLine )
1010 rStruct = SvxBoxItem::SvxLineToLine( pLine, true);
1014 namespace {
1015 template<typename TableBorderItem>
1016 void lcl_fillTableBorder( TableBorderItem& rBorder, const SvxBoxItem& rOuter, const SvxBoxInfoItem& rInner,
1017 bool bInvalidateHorVerDist )
1019 ScHelperFunctions::FillBorderLine( rBorder.TopLine, rOuter.GetTop() );
1020 ScHelperFunctions::FillBorderLine( rBorder.BottomLine, rOuter.GetBottom() );
1021 ScHelperFunctions::FillBorderLine( rBorder.LeftLine, rOuter.GetLeft() );
1022 ScHelperFunctions::FillBorderLine( rBorder.RightLine, rOuter.GetRight() );
1023 ScHelperFunctions::FillBorderLine( rBorder.HorizontalLine, rInner.GetHori() );
1024 ScHelperFunctions::FillBorderLine( rBorder.VerticalLine, rInner.GetVert() );
1026 rBorder.Distance = rOuter.GetDistance();
1027 rBorder.IsTopLineValid = rInner.IsValid(VALID_TOP);
1028 rBorder.IsBottomLineValid = rInner.IsValid(VALID_BOTTOM);
1029 rBorder.IsLeftLineValid = rInner.IsValid(VALID_LEFT);
1030 rBorder.IsRightLineValid = rInner.IsValid(VALID_RIGHT);
1031 rBorder.IsHorizontalLineValid = !bInvalidateHorVerDist && rInner.IsValid(VALID_HORI);
1032 rBorder.IsVerticalLineValid = !bInvalidateHorVerDist && rInner.IsValid(VALID_VERT);
1033 rBorder.IsDistanceValid = !bInvalidateHorVerDist && rInner.IsValid(VALID_DISTANCE);
1037 void ScHelperFunctions::AssignTableBorderToAny( uno::Any& rAny,
1038 const SvxBoxItem& rOuter, const SvxBoxInfoItem& rInner, bool bInvalidateHorVerDist )
1040 table::TableBorder aBorder;
1041 lcl_fillTableBorder( aBorder, rOuter, rInner, bInvalidateHorVerDist);
1042 rAny <<= aBorder;
1045 void ScHelperFunctions::AssignTableBorder2ToAny( uno::Any& rAny,
1046 const SvxBoxItem& rOuter, const SvxBoxInfoItem& rInner, bool bInvalidateHorVerDist )
1048 table::TableBorder2 aBorder;
1049 lcl_fillTableBorder( aBorder, rOuter, rInner, bInvalidateHorVerDist);
1050 rAny <<= aBorder;
1053 //------------------------------------------------------------------------
1055 //! lcl_ApplyBorder nach docfunc verschieben!
1057 void ScHelperFunctions::ApplyBorder( ScDocShell* pDocShell, const ScRangeList& rRanges,
1058 const SvxBoxItem& rOuter, const SvxBoxInfoItem& rInner )
1060 ScDocument* pDoc = pDocShell->GetDocument();
1061 sal_Bool bUndo(pDoc->IsUndoEnabled());
1062 ScDocument* pUndoDoc = NULL;
1063 if (bUndo)
1064 pUndoDoc = new ScDocument( SCDOCMODE_UNDO );
1065 size_t nCount = rRanges.size();
1066 for (size_t i = 0; i < nCount; ++i)
1068 ScRange aRange( *rRanges[ i ] );
1069 SCTAB nTab = aRange.aStart.Tab();
1071 if (bUndo)
1073 if ( i==0 )
1074 pUndoDoc->InitUndo( pDoc, nTab, nTab );
1075 else
1076 pUndoDoc->AddUndoTab( nTab, nTab );
1077 pDoc->CopyToDocument( aRange, IDF_ATTRIB, false, pUndoDoc );
1080 ScMarkData aMark;
1081 aMark.SetMarkArea( aRange );
1082 aMark.SelectTable( nTab, sal_True );
1084 pDoc->ApplySelectionFrame( aMark, &rOuter, &rInner );
1085 // RowHeight bei Umrandung alleine nicht noetig
1088 if (bUndo)
1090 pDocShell->GetUndoManager()->AddUndoAction(
1091 new ScUndoBorder( pDocShell, rRanges, pUndoDoc, rOuter, rInner ) );
1094 for (size_t i = 0; i < nCount; ++i )
1095 pDocShell->PostPaint( *rRanges[ i ], PAINT_GRID, SC_PF_LINES | SC_PF_TESTMERGE );
1097 pDocShell->SetDocumentModified();
1100 //! move lcl_PutDataArray to docfunc?
1101 //! merge loop with ScFunctionAccess::callFunction
1103 static sal_Bool lcl_PutDataArray( ScDocShell& rDocShell, const ScRange& rRange,
1104 const uno::Sequence< uno::Sequence<uno::Any> >& aData )
1106 ScDocument* pDoc = rDocShell.GetDocument();
1107 SCTAB nTab = rRange.aStart.Tab();
1108 SCCOL nStartCol = rRange.aStart.Col();
1109 SCROW nStartRow = rRange.aStart.Row();
1110 SCCOL nEndCol = rRange.aEnd.Col();
1111 SCROW nEndRow = rRange.aEnd.Row();
1112 sal_Bool bUndo(pDoc->IsUndoEnabled());
1114 if ( !pDoc->IsBlockEditable( nTab, nStartCol,nStartRow, nEndCol,nEndRow ) )
1116 //! error message
1117 return false;
1120 long nCols = 0;
1121 long nRows = aData.getLength();
1122 const uno::Sequence<uno::Any>* pArray = aData.getConstArray();
1123 if ( nRows )
1124 nCols = pArray[0].getLength();
1126 if ( nCols != nEndCol-nStartCol+1 || nRows != nEndRow-nStartRow+1 )
1128 //! error message?
1129 return false;
1132 ScDocument* pUndoDoc = NULL;
1133 if ( bUndo )
1135 pUndoDoc = new ScDocument( SCDOCMODE_UNDO );
1136 pUndoDoc->InitUndo( pDoc, nTab, nTab );
1137 pDoc->CopyToDocument( rRange, IDF_CONTENTS|IDF_NOCAPTIONS, false, pUndoDoc );
1140 pDoc->DeleteAreaTab( nStartCol, nStartRow, nEndCol, nEndRow, nTab, IDF_CONTENTS );
1142 sal_Bool bError = false;
1143 SCROW nDocRow = nStartRow;
1144 for (long nRow=0; nRow<nRows; nRow++)
1146 const uno::Sequence<uno::Any>& rColSeq = pArray[nRow];
1147 if ( rColSeq.getLength() == nCols )
1149 SCCOL nDocCol = nStartCol;
1150 const uno::Any* pColArr = rColSeq.getConstArray();
1151 for (long nCol=0; nCol<nCols; nCol++)
1153 ScAddress aPos(nDocCol, nDocRow, nTab);
1155 const uno::Any& rElement = pColArr[nCol];
1156 switch( rElement.getValueTypeClass() )
1158 case uno::TypeClass_VOID:
1160 // void = "no value"
1161 pDoc->SetError( nDocCol, nDocRow, nTab, NOTAVAILABLE );
1163 break;
1165 // #87871# accept integer types because Basic passes a floating point
1166 // variable as byte, short or long if it's an integer number.
1167 case uno::TypeClass_BYTE:
1168 case uno::TypeClass_SHORT:
1169 case uno::TypeClass_UNSIGNED_SHORT:
1170 case uno::TypeClass_LONG:
1171 case uno::TypeClass_UNSIGNED_LONG:
1172 case uno::TypeClass_FLOAT:
1173 case uno::TypeClass_DOUBLE:
1175 double fVal(0.0);
1176 rElement >>= fVal;
1177 pDoc->SetValue(aPos, fVal);
1179 break;
1181 case uno::TypeClass_STRING:
1183 OUString aUStr;
1184 rElement >>= aUStr;
1185 if ( !aUStr.isEmpty() )
1187 ScSetStringParam aParam;
1188 aParam.setTextInput();
1189 pDoc->SetString(aPos, aUStr, &aParam);
1192 break;
1194 // accept Sequence<FormulaToken> for formula cells
1195 case uno::TypeClass_SEQUENCE:
1197 uno::Sequence< sheet::FormulaToken > aTokens;
1198 if ( rElement >>= aTokens )
1200 ScTokenArray aTokenArray;
1201 ScTokenConversion::ConvertToTokenArray( *pDoc, aTokenArray, aTokens );
1202 pDoc->SetFormula(aPos, aTokenArray);
1204 else
1205 bError = true;
1207 break;
1209 default:
1210 bError = true; // invalid type
1212 ++nDocCol;
1215 else
1216 bError = sal_True; // wrong size
1218 ++nDocRow;
1221 sal_Bool bHeight = rDocShell.AdjustRowHeight( nStartRow, nEndRow, nTab );
1223 if ( pUndoDoc )
1225 ScMarkData aDestMark;
1226 aDestMark.SelectOneTable( nTab );
1227 rDocShell.GetUndoManager()->AddUndoAction(
1228 new ScUndoPaste(
1229 &rDocShell, ScRange(nStartCol, nStartRow, nTab, nEndCol, nEndRow, nTab),
1230 aDestMark, pUndoDoc, NULL, IDF_CONTENTS, NULL, false));
1233 if (!bHeight)
1234 rDocShell.PostPaint( rRange, PAINT_GRID ); // AdjustRowHeight may have painted already
1236 rDocShell.SetDocumentModified();
1238 return !bError;
1241 static sal_Bool lcl_PutFormulaArray( ScDocShell& rDocShell, const ScRange& rRange,
1242 const uno::Sequence< uno::Sequence<OUString> >& aData,
1243 const formula::FormulaGrammar::Grammar eGrammar )
1245 ScDocument* pDoc = rDocShell.GetDocument();
1246 SCTAB nTab = rRange.aStart.Tab();
1247 SCCOL nStartCol = rRange.aStart.Col();
1248 SCROW nStartRow = rRange.aStart.Row();
1249 SCCOL nEndCol = rRange.aEnd.Col();
1250 SCROW nEndRow = rRange.aEnd.Row();
1251 sal_Bool bUndo(pDoc->IsUndoEnabled());
1253 if ( !pDoc->IsBlockEditable( nTab, nStartCol,nStartRow, nEndCol,nEndRow ) )
1255 //! error message
1256 return false;
1259 long nCols = 0;
1260 long nRows = aData.getLength();
1261 const uno::Sequence<OUString>* pArray = aData.getConstArray();
1262 if ( nRows )
1263 nCols = pArray[0].getLength();
1265 if ( nCols != nEndCol-nStartCol+1 || nRows != nEndRow-nStartRow+1 )
1267 //! error message?
1268 return false;
1271 ScDocument* pUndoDoc = NULL;
1272 if ( bUndo )
1274 pUndoDoc = new ScDocument( SCDOCMODE_UNDO );
1275 pUndoDoc->InitUndo( pDoc, nTab, nTab );
1276 pDoc->CopyToDocument( rRange, IDF_CONTENTS, false, pUndoDoc );
1279 pDoc->DeleteAreaTab( nStartCol, nStartRow, nEndCol, nEndRow, nTab, IDF_CONTENTS );
1281 bool bError = false;
1282 SCROW nDocRow = nStartRow;
1283 for (long nRow=0; nRow<nRows; nRow++)
1285 const uno::Sequence<OUString>& rColSeq = pArray[nRow];
1286 if ( rColSeq.getLength() == nCols )
1288 SCCOL nDocCol = nStartCol;
1289 const OUString* pColArr = rColSeq.getConstArray();
1290 for (long nCol=0; nCol<nCols; nCol++)
1292 OUString aText(pColArr[nCol]);
1293 ScAddress aPos( nDocCol, nDocRow, nTab );
1295 ScInputStringType aRes =
1296 ScStringUtil::parseInputString(
1297 *pDoc->GetFormatTable(), aText, LANGUAGE_ENGLISH_US);
1298 switch (aRes.meType)
1300 case ScInputStringType::Formula:
1301 pDoc->SetFormula(aPos, aRes.maText, eGrammar);
1302 break;
1303 case ScInputStringType::Number:
1304 pDoc->SetValue(aPos, aRes.mfValue);
1305 break;
1306 case ScInputStringType::Text:
1307 pDoc->SetTextCell(aPos, aRes.maText);
1308 break;
1309 default:
1313 ++nDocCol;
1316 else
1317 bError = true; // wrong size
1319 ++nDocRow;
1322 sal_Bool bHeight = rDocShell.AdjustRowHeight( nStartRow, nEndRow, nTab );
1324 if ( pUndoDoc )
1326 ScMarkData aDestMark;
1327 aDestMark.SelectOneTable( nTab );
1328 rDocShell.GetUndoManager()->AddUndoAction(
1329 new ScUndoPaste( &rDocShell,
1330 ScRange(nStartCol, nStartRow, nTab, nEndCol, nEndRow, nTab), aDestMark,
1331 pUndoDoc, NULL, IDF_CONTENTS, NULL, false));
1334 if (!bHeight)
1335 rDocShell.PostPaint( rRange, PAINT_GRID ); // AdjustRowHeight may have painted already
1337 rDocShell.SetDocumentModified();
1339 return !bError;
1342 // used in ScCellRangeObj::getFormulaArray and ScCellObj::GetInputString_Impl
1343 static OUString lcl_GetInputString( ScDocument* pDoc, const ScAddress& rPos, sal_Bool bEnglish )
1345 if (!pDoc)
1346 return EMPTY_OUSTRING;
1348 ScRefCellValue aCell;
1349 aCell.assign(*pDoc, rPos);
1350 if (aCell.isEmpty())
1351 return EMPTY_OUSTRING;
1353 OUString aVal;
1355 CellType eType = aCell.meType;
1356 if (eType == CELLTYPE_FORMULA)
1358 ScFormulaCell* pForm = aCell.mpFormula;
1359 pForm->GetFormula( aVal, formula::FormulaGrammar::mapAPItoGrammar( bEnglish, false));
1360 return aVal;
1363 SvNumberFormatter* pFormatter = bEnglish ? ScGlobal::GetEnglishFormatter() :
1364 pDoc->GetFormatTable();
1365 // Since the English formatter was constructed with
1366 // LANGUAGE_ENGLISH_US the "General" format has index key 0,
1367 // we don't have to query.
1368 sal_uInt32 nNumFmt = bEnglish ? 0 : pDoc->GetNumberFormat(rPos);
1370 if (eType == CELLTYPE_EDIT)
1372 // GetString an der EditCell macht Leerzeichen aus Umbruechen,
1373 // hier werden die Umbrueche aber gebraucht
1374 const EditTextObject* pData = aCell.mpEditText;
1375 if (pData)
1377 EditEngine& rEngine = pDoc->GetEditEngine();
1378 rEngine.SetText(*pData);
1379 aVal = rEngine.GetText(LINEEND_LF);
1382 else
1383 ScCellFormat::GetInputString(aCell, nNumFmt, aVal, *pFormatter, pDoc);
1385 // ggf. ein ' davorhaengen wie in ScTabViewShell::UpdateInputHandler
1386 if ( eType == CELLTYPE_STRING || eType == CELLTYPE_EDIT )
1388 double fDummy;
1389 OUString aTempString = aVal;
1390 sal_Bool bIsNumberFormat(pFormatter->IsNumberFormat(aTempString, nNumFmt, fDummy));
1391 if ( bIsNumberFormat )
1392 aTempString = "'" + aTempString;
1393 else if ( !aTempString.isEmpty() && aTempString[0] == '\'' )
1395 // if the string starts with a "'", add another one because setFormula
1396 // strips one (like text input, except for "text" number formats)
1397 if ( bEnglish || ( pFormatter->GetType(nNumFmt) != NUMBERFORMAT_TEXT ) )
1398 aTempString = "'" + aTempString;
1400 aVal = aTempString;
1402 return aVal;
1405 //------------------------------------------------------------------------
1407 ScCellRangesBase::ScCellRangesBase(ScDocShell* pDocSh, const ScRange& rR) :
1408 pPropSet(lcl_GetCellsPropertySet()),
1409 pDocShell( pDocSh ),
1410 pValueListener( NULL ),
1411 pCurrentFlat( NULL ),
1412 pCurrentDeep( NULL ),
1413 pCurrentDataSet( NULL ),
1414 pNoDfltCurrentDataSet( NULL ),
1415 pMarkData( NULL ),
1416 nObjectId( 0 ),
1417 bChartColAsHdr( false ),
1418 bChartRowAsHdr( false ),
1419 bCursorOnly( false ),
1420 bGotDataChangedHint( false ),
1421 aValueListeners( 0 )
1423 ScRange aCellRange(rR);
1424 aCellRange.Justify();
1425 aRanges.Append( aCellRange );
1427 if (pDocShell) // Null if created with createInstance
1429 ScDocument* pDoc = pDocShell->GetDocument();
1430 pDoc->AddUnoObject(*this);
1431 nObjectId = pDoc->GetNewUnoId();
1435 ScCellRangesBase::ScCellRangesBase(ScDocShell* pDocSh, const ScRangeList& rR) :
1436 pPropSet(lcl_GetCellsPropertySet()),
1437 pDocShell( pDocSh ),
1438 pValueListener( NULL ),
1439 pCurrentFlat( NULL ),
1440 pCurrentDeep( NULL ),
1441 pCurrentDataSet( NULL ),
1442 pNoDfltCurrentDataSet( NULL ),
1443 pMarkData( NULL ),
1444 aRanges( rR ),
1445 nObjectId( 0 ),
1446 bChartColAsHdr( false ),
1447 bChartRowAsHdr( false ),
1448 bCursorOnly( false ),
1449 bGotDataChangedHint( false ),
1450 aValueListeners( 0 )
1452 if (pDocShell) // Null if created with createInstance
1454 ScDocument* pDoc = pDocShell->GetDocument();
1455 pDoc->AddUnoObject(*this);
1456 nObjectId = pDoc->GetNewUnoId();
1460 ScCellRangesBase::~ScCellRangesBase()
1462 // call RemoveUnoObject first, so no notification can happen
1463 // during ForgetCurrentAttrs
1465 if (pDocShell)
1466 pDocShell->GetDocument()->RemoveUnoObject(*this);
1468 ForgetCurrentAttrs();
1469 ForgetMarkData();
1471 delete pValueListener;
1473 //! XChartDataChangeEventListener abmelden ??
1474 //! (ChartCollection haelt dann auch dieses Objekt fest!)
1477 void ScCellRangesBase::ForgetCurrentAttrs()
1479 delete pCurrentFlat;
1480 delete pCurrentDeep;
1481 delete pCurrentDataSet;
1482 delete pNoDfltCurrentDataSet;
1483 pCurrentFlat = NULL;
1484 pCurrentDeep = NULL;
1485 pCurrentDataSet = NULL;
1486 pNoDfltCurrentDataSet = NULL;
1488 // #i62483# pMarkData can remain unchanged, is deleted only if the range changes (RefChanged)
1491 void ScCellRangesBase::ForgetMarkData()
1493 delete pMarkData;
1494 pMarkData = NULL;
1497 const ScPatternAttr* ScCellRangesBase::GetCurrentAttrsFlat()
1499 // get and cache direct cell attributes for this object's range
1501 if ( !pCurrentFlat && pDocShell )
1503 ScDocument* pDoc = pDocShell->GetDocument();
1504 pCurrentFlat = pDoc->CreateSelectionPattern( *GetMarkData(), false );
1506 return pCurrentFlat;
1509 const ScPatternAttr* ScCellRangesBase::GetCurrentAttrsDeep()
1511 // get and cache cell attributes (incl. styles) for this object's range
1513 if ( !pCurrentDeep && pDocShell )
1515 ScDocument* pDoc = pDocShell->GetDocument();
1516 pCurrentDeep = pDoc->CreateSelectionPattern( *GetMarkData(), sal_True );
1518 return pCurrentDeep;
1521 SfxItemSet* ScCellRangesBase::GetCurrentDataSet(bool bNoDflt)
1523 if(!pCurrentDataSet)
1525 const ScPatternAttr* pPattern = GetCurrentAttrsDeep();
1526 if ( pPattern )
1528 // Dontcare durch Default ersetzen, damit man immer eine Reflection hat
1529 pCurrentDataSet = new SfxItemSet( pPattern->GetItemSet() );
1530 pNoDfltCurrentDataSet = new SfxItemSet( pPattern->GetItemSet() );
1531 pCurrentDataSet->ClearInvalidItems();
1534 return bNoDflt ? pNoDfltCurrentDataSet : pCurrentDataSet;
1537 const ScMarkData* ScCellRangesBase::GetMarkData()
1539 if (!pMarkData)
1541 pMarkData = new ScMarkData();
1542 pMarkData->MarkFromRangeList( aRanges, false );
1544 return pMarkData;
1547 void ScCellRangesBase::Notify( SfxBroadcaster&, const SfxHint& rHint )
1549 if ( rHint.ISA( ScUpdateRefHint ) )
1551 const ScUpdateRefHint& rRef = (const ScUpdateRefHint&)rHint;
1553 ScDocument* pDoc = pDocShell->GetDocument();
1554 ScRangeList* pUndoRanges = NULL;
1555 if ( pDoc->HasUnoRefUndo() )
1556 pUndoRanges = new ScRangeList( aRanges );
1558 if ( aRanges.UpdateReference( rRef.GetMode(), pDoc, rRef.GetRange(),
1559 rRef.GetDx(), rRef.GetDy(), rRef.GetDz() ) )
1561 // i#90076; the object "this" was destroyed after calling ScTableSheetObj::getImplementation
1562 // this hack make sure that the object lives a bit longer
1563 uno::Reference<uno::XInterface> xInterface((cppu::OWeakObject*)this, uno::UNO_QUERY);
1564 if ( rRef.GetMode() == URM_INSDEL
1565 && aRanges.size() == 1
1566 && ScTableSheetObj::getImplementation( xInterface )
1569 // #101755#; the range size of a sheet does not change
1570 ScRange* pR = aRanges.front();
1571 if (pR)
1573 pR->aStart.SetCol(0);
1574 pR->aStart.SetRow(0);
1575 pR->aEnd.SetCol(MAXCOL);
1576 pR->aEnd.SetRow(MAXROW);
1579 RefChanged();
1581 // any change of the range address is broadcast to value (modify) listeners
1582 if ( !aValueListeners.empty() )
1583 bGotDataChangedHint = sal_True;
1585 if ( pUndoRanges )
1586 pDoc->AddUnoRefChange( nObjectId, *pUndoRanges );
1589 delete pUndoRanges;
1591 else if ( rHint.ISA( SfxSimpleHint ) )
1593 sal_uLong nId = ((const SfxSimpleHint&)rHint).GetId();
1594 if ( nId == SFX_HINT_DYING )
1596 ForgetCurrentAttrs();
1597 pDocShell = NULL; // invalid
1599 if ( !aValueListeners.empty() )
1601 // dispose listeners
1603 lang::EventObject aEvent;
1604 aEvent.Source.set(static_cast<cppu::OWeakObject*>(this));
1605 for ( sal_uInt16 n=0; n<aValueListeners.size(); n++ )
1606 aValueListeners[n]->disposing( aEvent );
1608 aValueListeners.clear();
1610 // The listeners can't have the last ref to this, as it's still held
1611 // by the DocShell.
1614 else if ( nId == SFX_HINT_DATACHANGED )
1616 // document content changed -> forget cached attributes
1617 ForgetCurrentAttrs();
1619 if ( bGotDataChangedHint && pDocShell )
1621 // This object was notified of content changes, so one call
1622 // for each listener is generated now.
1623 // The calls can't be executed directly because the document's
1624 // UNO broadcaster list must not be modified.
1625 // Instead, add to the document's list of listener calls,
1626 // which will be executed directly after the broadcast of
1627 // SFX_HINT_DATACHANGED.
1629 lang::EventObject aEvent;
1630 aEvent.Source.set((cppu::OWeakObject*)this);
1632 // the EventObject holds a Ref to this object until after the listener calls
1634 ScDocument* pDoc = pDocShell->GetDocument();
1635 for ( sal_uInt16 n=0; n<aValueListeners.size(); n++ )
1636 pDoc->AddUnoListenerCall( aValueListeners[n], aEvent );
1638 bGotDataChangedHint = false;
1641 else if ( nId == SC_HINT_CALCALL )
1643 // broadcast from DoHardRecalc - set bGotDataChangedHint
1644 // (SFX_HINT_DATACHANGED follows separately)
1646 if ( !aValueListeners.empty() )
1647 bGotDataChangedHint = sal_True;
1650 else if ( rHint.ISA( ScUnoRefUndoHint ) )
1652 const ScUnoRefUndoHint& rUndoHint = static_cast<const ScUnoRefUndoHint&>(rHint);
1653 if ( rUndoHint.GetObjectId() == nObjectId )
1655 // restore ranges from hint
1657 aRanges = rUndoHint.GetRanges();
1659 RefChanged();
1660 if ( !aValueListeners.empty() )
1661 bGotDataChangedHint = sal_True; // need to broadcast the undo, too
1666 void ScCellRangesBase::RefChanged()
1668 //! adjust XChartDataChangeEventListener
1670 if ( pValueListener && !aValueListeners.empty() )
1672 pValueListener->EndListeningAll();
1674 ScDocument* pDoc = pDocShell->GetDocument();
1675 for ( size_t i = 0, nCount = aRanges.size(); i < nCount; ++i )
1676 pDoc->StartListeningArea( *aRanges[ i ], pValueListener );
1679 ForgetCurrentAttrs();
1680 ForgetMarkData();
1683 ScDocument* ScCellRangesBase::GetDocument() const
1685 if (pDocShell)
1686 return pDocShell->GetDocument();
1687 else
1688 return NULL;
1691 void ScCellRangesBase::InitInsertRange(ScDocShell* pDocSh, const ScRange& rR)
1693 if ( !pDocShell && pDocSh )
1695 pDocShell = pDocSh;
1697 ScRange aCellRange(rR);
1698 aCellRange.Justify();
1699 aRanges.RemoveAll();
1700 aRanges.Append( aCellRange );
1702 pDocShell->GetDocument()->AddUnoObject(*this);
1704 RefChanged(); // Range im Range-Objekt anpassen
1708 void ScCellRangesBase::AddRange(const ScRange& rRange, const sal_Bool bMergeRanges)
1710 if (bMergeRanges)
1711 aRanges.Join(rRange);
1712 else
1713 aRanges.Append(rRange);
1714 RefChanged();
1717 void ScCellRangesBase::SetNewRange(const ScRange& rNew)
1719 ScRange aCellRange(rNew);
1720 aCellRange.Justify();
1722 aRanges.RemoveAll();
1723 aRanges.Append( aCellRange );
1724 RefChanged();
1727 void ScCellRangesBase::SetNewRanges(const ScRangeList& rNew)
1729 aRanges = rNew;
1730 RefChanged();
1733 void ScCellRangesBase::SetCursorOnly( sal_Bool bSet )
1735 // set for a selection object that is created from the cursor position
1736 // without anything selected (may contain several sheets)
1738 bCursorOnly = bSet;
1741 uno::Any SAL_CALL ScCellRangesBase::queryInterface( const uno::Type& rType )
1742 throw(uno::RuntimeException)
1744 SC_QUERYINTERFACE( beans::XPropertySet )
1745 SC_QUERYINTERFACE( beans::XMultiPropertySet )
1746 SC_QUERYINTERFACE( beans::XTolerantMultiPropertySet )
1747 SC_QUERYINTERFACE( beans::XPropertyState )
1748 SC_QUERYINTERFACE( sheet::XSheetOperation )
1749 SC_QUERYINTERFACE( chart::XChartDataArray )
1750 SC_QUERYINTERFACE( chart::XChartData )
1751 SC_QUERYINTERFACE( util::XIndent )
1752 SC_QUERYINTERFACE( sheet::XCellRangesQuery )
1753 SC_QUERYINTERFACE( sheet::XFormulaQuery )
1754 SC_QUERYINTERFACE( util::XReplaceable )
1755 SC_QUERYINTERFACE( util::XSearchable )
1756 SC_QUERYINTERFACE( util::XModifyBroadcaster )
1757 SC_QUERYINTERFACE( lang::XServiceInfo )
1758 SC_QUERYINTERFACE( lang::XUnoTunnel )
1759 SC_QUERYINTERFACE( lang::XTypeProvider )
1761 return OWeakObject::queryInterface( rType );
1764 void SAL_CALL ScCellRangesBase::acquire() throw()
1766 OWeakObject::acquire();
1769 void SAL_CALL ScCellRangesBase::release() throw()
1771 OWeakObject::release();
1774 uno::Sequence<uno::Type> SAL_CALL ScCellRangesBase::getTypes() throw(uno::RuntimeException)
1776 static uno::Sequence<uno::Type> aTypes;
1777 if ( aTypes.getLength() == 0 )
1779 aTypes.realloc(13);
1780 uno::Type* pPtr = aTypes.getArray();
1781 pPtr[0] = getCppuType((const uno::Reference<beans::XPropertySet>*)0);
1782 pPtr[1] = getCppuType((const uno::Reference<beans::XMultiPropertySet>*)0);
1783 pPtr[2] = getCppuType((const uno::Reference<beans::XPropertyState>*)0);
1784 pPtr[3] = getCppuType((const uno::Reference<sheet::XSheetOperation>*)0);
1785 pPtr[4] = getCppuType((const uno::Reference<chart::XChartDataArray>*)0);
1786 pPtr[5] = getCppuType((const uno::Reference<util::XIndent>*)0);
1787 pPtr[6] = getCppuType((const uno::Reference<sheet::XCellRangesQuery>*)0);
1788 pPtr[7] = getCppuType((const uno::Reference<sheet::XFormulaQuery>*)0);
1789 pPtr[8] = getCppuType((const uno::Reference<util::XReplaceable>*)0);
1790 pPtr[9] = getCppuType((const uno::Reference<util::XModifyBroadcaster>*)0);
1791 pPtr[10]= getCppuType((const uno::Reference<lang::XServiceInfo>*)0);
1792 pPtr[11]= getCppuType((const uno::Reference<lang::XUnoTunnel>*)0);
1793 pPtr[12]= getCppuType((const uno::Reference<lang::XTypeProvider>*)0);
1795 return aTypes;
1798 namespace
1800 class theScCellRangesBaseImplementationId : public rtl::Static< UnoTunnelIdInit, theScCellRangesBaseImplementationId > {};
1803 uno::Sequence<sal_Int8> SAL_CALL ScCellRangesBase::getImplementationId()
1804 throw(uno::RuntimeException)
1806 return theScCellRangesBaseImplementationId::get().getSeq();
1809 // ---
1811 void ScCellRangesBase::PaintRanges_Impl( sal_uInt16 nPart )
1813 for (size_t i = 0, nCount = aRanges.size(); i < nCount; ++i)
1814 pDocShell->PostPaint( *aRanges[ i ], nPart );
1817 // XSheetOperation
1819 double SAL_CALL ScCellRangesBase::computeFunction( sheet::GeneralFunction nFunction )
1820 throw(uno::Exception, uno::RuntimeException)
1822 SolarMutexGuard aGuard;
1823 ScMarkData aMark(*GetMarkData());
1824 aMark.MarkToSimple();
1825 if (!aMark.IsMarked())
1826 aMark.SetMarkNegative(sal_True); // um Dummy Position angeben zu koennen
1828 ScAddress aDummy; // wenn nicht Marked, ignoriert wegen Negative
1829 double fVal;
1830 ScSubTotalFunc eFunc = ScDPUtil::toSubTotalFunc(nFunction);
1831 ScDocument* pDoc = pDocShell->GetDocument();
1832 if ( !pDoc->GetSelectionFunction( eFunc, aDummy, aMark, fVal ) )
1834 throw uno::RuntimeException(); //! own exception?
1837 return fVal;
1840 void SAL_CALL ScCellRangesBase::clearContents( sal_Int32 nContentFlags ) throw(uno::RuntimeException)
1842 SolarMutexGuard aGuard;
1843 if ( !aRanges.empty() )
1845 // only for clearContents: EDITATTR is only used if no contents are deleted
1846 sal_uInt16 nDelFlags = static_cast< sal_uInt16 >( nContentFlags & IDF_ALL );
1847 if ( ( nContentFlags & IDF_EDITATTR ) && ( nContentFlags & IDF_CONTENTS ) == 0 )
1848 nDelFlags |= IDF_EDITATTR;
1850 pDocShell->GetDocFunc().DeleteContents( *GetMarkData(), nDelFlags, sal_True, sal_True );
1852 // sonst ist nichts zu tun
1855 // XPropertyState
1857 const SfxItemPropertyMap& ScCellRangesBase::GetItemPropertyMap()
1859 return pPropSet->getPropertyMap();
1862 static void lcl_GetPropertyWhich( const SfxItemPropertySimpleEntry* pEntry,
1863 sal_uInt16& rItemWhich )
1865 // Which-ID des betroffenen Items, auch wenn das Item die Property
1866 // nicht alleine behandeln kann
1867 if ( pEntry )
1869 if ( IsScItemWid( pEntry->nWID ) )
1870 rItemWhich = pEntry->nWID;
1871 else
1872 switch ( pEntry->nWID )
1874 case SC_WID_UNO_TBLBORD:
1875 case SC_WID_UNO_TBLBORD2:
1876 rItemWhich = ATTR_BORDER;
1877 break;
1878 case SC_WID_UNO_CONDFMT:
1879 case SC_WID_UNO_CONDLOC:
1880 case SC_WID_UNO_CONDXML:
1881 rItemWhich = ATTR_CONDITIONAL;
1882 break;
1883 case SC_WID_UNO_VALIDAT:
1884 case SC_WID_UNO_VALILOC:
1885 case SC_WID_UNO_VALIXML:
1886 rItemWhich = ATTR_VALIDDATA;
1887 break;
1893 beans::PropertyState ScCellRangesBase::GetOnePropertyState( sal_uInt16 nItemWhich, const SfxItemPropertySimpleEntry* pEntry )
1895 beans::PropertyState eRet = beans::PropertyState_DIRECT_VALUE;
1896 if ( nItemWhich ) // item wid (from map or special case)
1898 // For items that contain several properties (like background),
1899 // "ambiguous" is returned too often here
1901 // for PropertyState, don't look at styles
1902 const ScPatternAttr* pPattern = GetCurrentAttrsFlat();
1903 if ( pPattern )
1905 SfxItemState eState = pPattern->GetItemSet().GetItemState( nItemWhich, false );
1907 if ( nItemWhich == ATTR_VALUE_FORMAT && eState == SFX_ITEM_DEFAULT )
1908 eState = pPattern->GetItemSet().GetItemState( ATTR_LANGUAGE_FORMAT, false );
1910 if ( eState == SFX_ITEM_SET )
1911 eRet = beans::PropertyState_DIRECT_VALUE;
1912 else if ( eState == SFX_ITEM_DEFAULT )
1913 eRet = beans::PropertyState_DEFAULT_VALUE;
1914 else if ( eState == SFX_ITEM_DONTCARE )
1915 eRet = beans::PropertyState_AMBIGUOUS_VALUE;
1916 else
1918 OSL_FAIL("unbekannter ItemState");
1922 else if ( pEntry )
1924 if ( pEntry->nWID == SC_WID_UNO_CHCOLHDR || pEntry->nWID == SC_WID_UNO_CHROWHDR || pEntry->nWID == SC_WID_UNO_ABSNAME )
1925 eRet = beans::PropertyState_DIRECT_VALUE;
1926 else if ( pEntry->nWID == SC_WID_UNO_CELLSTYL )
1928 // a style is always set, there's no default state
1929 const ScStyleSheet* pStyle = pDocShell->GetDocument()->GetSelectionStyle(*GetMarkData());
1930 if (pStyle)
1931 eRet = beans::PropertyState_DIRECT_VALUE;
1932 else
1933 eRet = beans::PropertyState_AMBIGUOUS_VALUE;
1935 else if ( pEntry->nWID == SC_WID_UNO_NUMRULES )
1936 eRet = beans::PropertyState_DEFAULT_VALUE; // numbering rules are always default
1938 return eRet;
1941 beans::PropertyState SAL_CALL ScCellRangesBase::getPropertyState( const OUString& aPropertyName )
1942 throw(beans::UnknownPropertyException, uno::RuntimeException)
1944 SolarMutexGuard aGuard;
1945 if ( aRanges.empty() )
1946 throw uno::RuntimeException();
1948 const SfxItemPropertyMap& rMap = GetItemPropertyMap(); // from derived class
1949 sal_uInt16 nItemWhich = 0;
1950 const SfxItemPropertySimpleEntry* pEntry = rMap.getByName( aPropertyName );
1951 lcl_GetPropertyWhich( pEntry, nItemWhich );
1952 return GetOnePropertyState( nItemWhich, pEntry );
1955 uno::Sequence<beans::PropertyState> SAL_CALL ScCellRangesBase::getPropertyStates(
1956 const uno::Sequence<OUString>& aPropertyNames )
1957 throw(beans::UnknownPropertyException, uno::RuntimeException)
1959 SolarMutexGuard aGuard;
1961 const SfxItemPropertyMap& rPropertyMap = GetItemPropertyMap(); // from derived class
1963 uno::Sequence<beans::PropertyState> aRet(aPropertyNames.getLength());
1964 beans::PropertyState* pStates = aRet.getArray();
1965 for(sal_Int32 i = 0; i < aPropertyNames.getLength(); i++)
1967 sal_uInt16 nItemWhich = 0;
1968 const SfxItemPropertySimpleEntry* pEntry = rPropertyMap.getByName( aPropertyNames[i] );
1969 lcl_GetPropertyWhich( pEntry, nItemWhich );
1970 pStates[i] = GetOnePropertyState(nItemWhich, pEntry);
1972 return aRet;
1975 void SAL_CALL ScCellRangesBase::setPropertyToDefault( const OUString& aPropertyName )
1976 throw(beans::UnknownPropertyException, uno::RuntimeException)
1978 SolarMutexGuard aGuard;
1979 if ( pDocShell )
1981 const SfxItemPropertyMap& rPropertyMap = GetItemPropertyMap(); // from derived class
1982 sal_uInt16 nItemWhich = 0;
1983 const SfxItemPropertySimpleEntry* pEntry = rPropertyMap.getByName( aPropertyName );
1984 lcl_GetPropertyWhich( pEntry, nItemWhich );
1985 if ( nItemWhich ) // item wid (from map or special case)
1987 if ( !aRanges.empty() ) // leer = nichts zu tun
1989 //! Bei Items, die mehrere Properties enthalten (z.B. Hintergrund)
1990 //! wird hier zuviel zurueckgesetzt
1991 //! for ATTR_ROTATE_VALUE, also reset ATTR_ORIENTATION?
1993 sal_uInt16 aWIDs[3];
1994 aWIDs[0] = nItemWhich;
1995 if ( nItemWhich == ATTR_VALUE_FORMAT )
1997 aWIDs[1] = ATTR_LANGUAGE_FORMAT; // language for number formats
1998 aWIDs[2] = 0;
2000 else
2001 aWIDs[1] = 0;
2002 pDocShell->GetDocFunc().ClearItems( *GetMarkData(), aWIDs, sal_True );
2005 else if ( pEntry )
2007 if ( pEntry->nWID == SC_WID_UNO_CHCOLHDR )
2008 bChartColAsHdr = false;
2009 else if ( pEntry->nWID == SC_WID_UNO_CHROWHDR )
2010 bChartRowAsHdr = false;
2011 else if ( pEntry->nWID == SC_WID_UNO_CELLSTYL )
2013 OUString aStyleName( ScGlobal::GetRscString( STR_STYLENAME_STANDARD ) );
2014 pDocShell->GetDocFunc().ApplyStyle( *GetMarkData(), aStyleName, sal_True, sal_True );
2020 uno::Any SAL_CALL ScCellRangesBase::getPropertyDefault( const OUString& aPropertyName )
2021 throw(beans::UnknownPropertyException, lang::WrappedTargetException,
2022 uno::RuntimeException)
2024 //! mit getPropertyValue zusammenfassen
2026 SolarMutexGuard aGuard;
2027 uno::Any aAny;
2029 if ( pDocShell )
2031 ScDocument* pDoc = pDocShell->GetDocument();
2032 const SfxItemPropertyMap& rPropertyMap = GetItemPropertyMap(); // from derived class
2033 const SfxItemPropertySimpleEntry* pEntry = rPropertyMap.getByName( aPropertyName );
2034 if ( pEntry )
2036 if ( IsScItemWid( pEntry->nWID ) )
2038 const ScPatternAttr* pPattern = pDoc->GetDefPattern();
2039 if ( pPattern )
2041 const SfxItemSet& rSet = pPattern->GetItemSet();
2043 switch ( pEntry->nWID ) // fuer Item-Spezial-Behandlungen
2045 case ATTR_VALUE_FORMAT:
2046 // default has no language set
2047 aAny <<= (sal_Int32)( ((const SfxUInt32Item&)rSet.Get(pEntry->nWID)).GetValue() );
2048 break;
2049 case ATTR_INDENT:
2050 aAny <<= (sal_Int16)( TwipsToHMM(((const SfxUInt16Item&)
2051 rSet.Get(pEntry->nWID)).GetValue()) );
2052 break;
2053 default:
2054 pPropSet->getPropertyValue(aPropertyName, rSet, aAny);
2058 else
2059 switch ( pEntry->nWID )
2061 case SC_WID_UNO_CHCOLHDR:
2062 case SC_WID_UNO_CHROWHDR:
2063 ScUnoHelpFunctions::SetBoolInAny( aAny, false );
2064 break;
2065 case SC_WID_UNO_CELLSTYL:
2066 aAny <<= OUString( ScStyleNameConversion::DisplayToProgrammaticName(
2067 ScGlobal::GetRscString(STR_STYLENAME_STANDARD), SFX_STYLE_FAMILY_PARA ) );
2068 break;
2069 case SC_WID_UNO_TBLBORD:
2070 case SC_WID_UNO_TBLBORD2:
2072 const ScPatternAttr* pPattern = pDoc->GetDefPattern();
2073 if ( pPattern )
2075 if (pEntry->nWID == SC_WID_UNO_TBLBORD2)
2076 ScHelperFunctions::AssignTableBorder2ToAny( aAny,
2077 (const SvxBoxItem&)pPattern->GetItem(ATTR_BORDER),
2078 (const SvxBoxInfoItem&)pPattern->GetItem(ATTR_BORDER_INNER) );
2079 else
2080 ScHelperFunctions::AssignTableBorderToAny( aAny,
2081 (const SvxBoxItem&)pPattern->GetItem(ATTR_BORDER),
2082 (const SvxBoxInfoItem&)pPattern->GetItem(ATTR_BORDER_INNER) );
2085 break;
2086 case SC_WID_UNO_CONDFMT:
2087 case SC_WID_UNO_CONDLOC:
2088 case SC_WID_UNO_CONDXML:
2090 sal_Bool bEnglish = ( pEntry->nWID != SC_WID_UNO_CONDLOC );
2091 sal_Bool bXML = ( pEntry->nWID == SC_WID_UNO_CONDXML );
2092 formula::FormulaGrammar::Grammar eGrammar = (bXML ?
2093 pDoc->GetStorageGrammar() :
2094 formula::FormulaGrammar::mapAPItoGrammar( bEnglish, bXML));
2096 aAny <<= uno::Reference<sheet::XSheetConditionalEntries>(
2097 new ScTableConditionalFormat( pDoc, 0, aRanges[0]->aStart.Tab(), eGrammar ));
2099 break;
2100 case SC_WID_UNO_VALIDAT:
2101 case SC_WID_UNO_VALILOC:
2102 case SC_WID_UNO_VALIXML:
2104 sal_Bool bEnglish = ( pEntry->nWID != SC_WID_UNO_VALILOC );
2105 sal_Bool bXML = ( pEntry->nWID == SC_WID_UNO_VALIXML );
2106 formula::FormulaGrammar::Grammar eGrammar = (bXML ?
2107 pDoc->GetStorageGrammar() :
2108 formula::FormulaGrammar::mapAPItoGrammar( bEnglish, bXML));
2110 aAny <<= uno::Reference<beans::XPropertySet>(
2111 new ScTableValidationObj( pDoc, 0, eGrammar ));
2113 break;
2114 case SC_WID_UNO_NUMRULES:
2116 aAny <<= uno::Reference<container::XIndexReplace>(ScStyleObj::CreateEmptyNumberingRules());
2118 break;
2123 return aAny;
2126 // XPropertySet
2128 uno::Reference<beans::XPropertySetInfo> SAL_CALL ScCellRangesBase::getPropertySetInfo()
2129 throw(uno::RuntimeException)
2131 SolarMutexGuard aGuard;
2132 static uno::Reference<beans::XPropertySetInfo> aRef(
2133 new SfxItemPropertySetInfo( pPropSet->getPropertyMap() ));
2134 return aRef;
2137 static void lcl_SetCellProperty( const SfxItemPropertySimpleEntry& rEntry, const uno::Any& rValue,
2138 ScPatternAttr& rPattern, ScDocument* pDoc,
2139 sal_uInt16& rFirstItemId, sal_uInt16& rSecondItemId )
2141 rFirstItemId = rEntry.nWID;
2142 rSecondItemId = 0;
2144 SfxItemSet& rSet = rPattern.GetItemSet();
2145 switch ( rEntry.nWID )
2147 case ATTR_VALUE_FORMAT:
2149 // language for number formats
2150 SvNumberFormatter* pFormatter = pDoc->GetFormatTable();
2151 sal_uLong nOldFormat = ((const SfxUInt32Item&)rSet.Get( ATTR_VALUE_FORMAT )).GetValue();
2152 LanguageType eOldLang = ((const SvxLanguageItem&)rSet.Get( ATTR_LANGUAGE_FORMAT )).GetLanguage();
2153 nOldFormat = pFormatter->GetFormatForLanguageIfBuiltIn( nOldFormat, eOldLang );
2155 sal_Int32 nIntVal = 0;
2156 if ( rValue >>= nIntVal )
2158 sal_uLong nNewFormat = (sal_uLong)nIntVal;
2159 rSet.Put( SfxUInt32Item( ATTR_VALUE_FORMAT, nNewFormat ) );
2161 const SvNumberformat* pNewEntry = pFormatter->GetEntry( nNewFormat );
2162 LanguageType eNewLang =
2163 pNewEntry ? pNewEntry->GetLanguage() : LANGUAGE_DONTKNOW;
2164 if ( eNewLang != eOldLang && eNewLang != LANGUAGE_DONTKNOW )
2166 rSet.Put( SvxLanguageItem( eNewLang, ATTR_LANGUAGE_FORMAT ) );
2168 // if only language is changed,
2169 // don't touch number format attribute
2170 sal_uLong nNewMod = nNewFormat % SV_COUNTRY_LANGUAGE_OFFSET;
2171 if ( nNewMod == ( nOldFormat % SV_COUNTRY_LANGUAGE_OFFSET ) &&
2172 nNewMod <= SV_MAX_ANZ_STANDARD_FORMATE )
2174 rFirstItemId = 0; // don't use ATTR_VALUE_FORMAT value
2177 rSecondItemId = ATTR_LANGUAGE_FORMAT;
2180 else
2181 throw lang::IllegalArgumentException();
2183 break;
2184 case ATTR_INDENT:
2186 sal_Int16 nIntVal = 0;
2187 if ( rValue >>= nIntVal )
2188 rSet.Put( SfxUInt16Item( rEntry.nWID, (sal_uInt16)HMMToTwips(nIntVal) ) );
2189 else
2190 throw lang::IllegalArgumentException();
2192 break;
2193 case ATTR_ROTATE_VALUE:
2195 sal_Int32 nRotVal = 0;
2196 if ( rValue >>= nRotVal )
2198 // stored value is always between 0 and 360 deg.
2199 nRotVal %= 36000;
2200 if ( nRotVal < 0 )
2201 nRotVal += 36000;
2203 rSet.Put( SfxInt32Item( ATTR_ROTATE_VALUE, nRotVal ) );
2205 else
2206 throw lang::IllegalArgumentException();
2208 break;
2209 case ATTR_STACKED:
2211 table::CellOrientation eOrient;
2212 if( rValue >>= eOrient )
2214 switch( eOrient )
2216 case table::CellOrientation_STANDARD:
2217 rSet.Put( SfxBoolItem( ATTR_STACKED, false ) );
2218 break;
2219 case table::CellOrientation_TOPBOTTOM:
2220 rSet.Put( SfxBoolItem( ATTR_STACKED, false ) );
2221 rSet.Put( SfxInt32Item( ATTR_ROTATE_VALUE, 27000 ) );
2222 rSecondItemId = ATTR_ROTATE_VALUE;
2223 break;
2224 case table::CellOrientation_BOTTOMTOP:
2225 rSet.Put( SfxBoolItem( ATTR_STACKED, false ) );
2226 rSet.Put( SfxInt32Item( ATTR_ROTATE_VALUE, 9000 ) );
2227 rSecondItemId = ATTR_ROTATE_VALUE;
2228 break;
2229 case table::CellOrientation_STACKED:
2230 rSet.Put( SfxBoolItem( ATTR_STACKED, sal_True ) );
2231 break;
2232 default:
2234 // added to avoid warnings
2239 break;
2240 default:
2242 lcl_GetCellsPropertySet()->setPropertyValue(rEntry, rValue, rSet);
2247 void SAL_CALL ScCellRangesBase::setPropertyValue(
2248 const OUString& aPropertyName, const uno::Any& aValue )
2249 throw(beans::UnknownPropertyException, beans::PropertyVetoException,
2250 lang::IllegalArgumentException, lang::WrappedTargetException,
2251 uno::RuntimeException)
2253 SolarMutexGuard aGuard;
2255 if ( !pDocShell || aRanges.empty() )
2256 throw uno::RuntimeException();
2258 const SfxItemPropertyMap& rPropertyMap = GetItemPropertyMap(); // from derived class
2259 const SfxItemPropertySimpleEntry* pEntry = rPropertyMap.getByName( aPropertyName );
2260 if ( !pEntry )
2261 throw beans::UnknownPropertyException();
2263 SetOnePropertyValue( pEntry, aValue );
2266 void ScCellRangesBase::SetOnePropertyValue( const SfxItemPropertySimpleEntry* pEntry, const uno::Any& aValue )
2267 throw(lang::IllegalArgumentException, uno::RuntimeException)
2269 if ( pEntry )
2271 if ( IsScItemWid( pEntry->nWID ) )
2273 if ( !aRanges.empty() ) // leer = nichts zu tun
2275 ScDocument* pDoc = pDocShell->GetDocument();
2277 // Fuer Teile von zusammengesetzten Items mit mehreren Properties (z.B. Hintergrund)
2278 // muss vorher das alte Item aus dem Dokument geholt werden
2279 //! Das kann hier aber nicht erkannt werden
2280 //! -> eigenes Flag im PropertyMap-Eintrag, oder was ???
2281 //! Item direkt von einzelner Position im Bereich holen?
2282 // ClearInvalidItems, damit auf jeden Fall ein Item vom richtigen Typ da ist
2284 ScPatternAttr aPattern( *GetCurrentAttrsDeep() );
2285 SfxItemSet& rSet = aPattern.GetItemSet();
2286 rSet.ClearInvalidItems();
2288 sal_uInt16 nFirstItem, nSecondItem;
2289 lcl_SetCellProperty( *pEntry, aValue, aPattern, pDoc, nFirstItem, nSecondItem );
2291 for (sal_uInt16 nWhich = ATTR_PATTERN_START; nWhich <= ATTR_PATTERN_END; nWhich++)
2292 if ( nWhich != nFirstItem && nWhich != nSecondItem )
2293 rSet.ClearItem(nWhich);
2295 pDocShell->GetDocFunc().ApplyAttributes( *GetMarkData(), aPattern, sal_True, sal_True );
2298 else // implemented here
2299 switch ( pEntry->nWID )
2301 case EE_CHAR_ESCAPEMENT: // Specifically for xlsx import
2303 sal_Int32 nValue = 0;
2304 aValue >>= nValue;
2305 if (nValue)
2307 for (size_t i = 0, n = aRanges.size(); i < n; ++i)
2309 ScRange aRange = *aRanges[i];
2311 /* TODO: Iterate through the range */
2312 ScAddress aAddr = aRange.aStart;
2313 ScDocument *pDoc = pDocShell->GetDocument();
2314 ScRefCellValue aCell;
2315 aCell.assign(*pDoc, aAddr);
2317 OUString aStr = aCell.getString(pDoc);
2318 EditEngine aEngine( pDoc->GetEnginePool() );
2319 aEngine.SetEditTextObjectPool(pDoc->GetEditPool());
2321 /* EE_CHAR_ESCAPEMENT seems to be set on the cell _only_ when
2322 * there are no other attribs for the cell.
2323 * So, it is safe to overwrite the complete attribute set.
2324 * If there is a need - getting CellType and processing
2325 * the attributes could be considered.
2327 SfxItemSet aAttr = aEngine.GetEmptyItemSet();
2328 aEngine.SetText(aStr);
2329 if( nValue < 0 ) // Subscript
2330 aAttr.Put( SvxEscapementItem( SVX_ESCAPEMENT_SUBSCRIPT, EE_CHAR_ESCAPEMENT ) );
2331 else // Superscript
2332 aAttr.Put( SvxEscapementItem( SVX_ESCAPEMENT_SUPERSCRIPT, EE_CHAR_ESCAPEMENT ) );
2333 aEngine.QuickSetAttribs(aAttr, ESelection(0, 0, 0, aStr.getLength()));
2335 // The cell will own the text object instance.
2336 pDoc->SetEditText(aRanges[0]->aStart, aEngine.CreateTextObject());
2340 break;
2341 case SC_WID_UNO_CHCOLHDR:
2342 // chart header flags are set for this object, not stored with document
2343 bChartColAsHdr = ScUnoHelpFunctions::GetBoolFromAny( aValue );
2344 break;
2345 case SC_WID_UNO_CHROWHDR:
2346 bChartRowAsHdr = ScUnoHelpFunctions::GetBoolFromAny( aValue );
2347 break;
2348 case SC_WID_UNO_CELLSTYL:
2350 OUString aStrVal;
2351 aValue >>= aStrVal;
2352 OUString aString(ScStyleNameConversion::ProgrammaticToDisplayName(
2353 aStrVal, SFX_STYLE_FAMILY_PARA ));
2354 pDocShell->GetDocFunc().ApplyStyle( *GetMarkData(), aString, sal_True, sal_True );
2356 break;
2357 case SC_WID_UNO_TBLBORD:
2359 table::TableBorder aBorder;
2360 if ( !aRanges.empty() && ( aValue >>= aBorder ) ) // empty = nothing to do
2362 SvxBoxItem aOuter(ATTR_BORDER);
2363 SvxBoxInfoItem aInner(ATTR_BORDER_INNER);
2364 ScHelperFunctions::FillBoxItems( aOuter, aInner, aBorder );
2366 ScHelperFunctions::ApplyBorder( pDocShell, aRanges, aOuter, aInner ); //! docfunc
2369 break;
2370 case SC_WID_UNO_TBLBORD2:
2372 table::TableBorder2 aBorder2;
2373 if ( !aRanges.empty() && ( aValue >>= aBorder2 ) ) // empty = nothing to do
2375 SvxBoxItem aOuter(ATTR_BORDER);
2376 SvxBoxInfoItem aInner(ATTR_BORDER_INNER);
2377 ScHelperFunctions::FillBoxItems( aOuter, aInner, aBorder2 );
2379 ScHelperFunctions::ApplyBorder( pDocShell, aRanges, aOuter, aInner ); //! docfunc
2382 break;
2383 case SC_WID_UNO_CONDFMT:
2384 case SC_WID_UNO_CONDLOC:
2385 case SC_WID_UNO_CONDXML:
2387 uno::Reference<sheet::XSheetConditionalEntries> xInterface(aValue, uno::UNO_QUERY);
2388 if ( !aRanges.empty() && xInterface.is() ) // leer = nichts zu tun
2390 ScTableConditionalFormat* pFormat =
2391 ScTableConditionalFormat::getImplementation( xInterface );
2392 if (pFormat)
2394 ScDocument* pDoc = pDocShell->GetDocument();
2395 sal_Bool bEnglish = ( pEntry->nWID != SC_WID_UNO_CONDLOC );
2396 sal_Bool bXML = ( pEntry->nWID == SC_WID_UNO_CONDXML );
2397 formula::FormulaGrammar::Grammar eGrammar = (bXML ?
2398 formula::FormulaGrammar::GRAM_UNSPECIFIED :
2399 formula::FormulaGrammar::mapAPItoGrammar( bEnglish, bXML));
2401 ScConditionalFormat* pNew = new ScConditionalFormat( 0, pDoc ); // Index wird beim Einfuegen gesetzt
2402 pFormat->FillFormat( *pNew, pDoc, eGrammar );
2403 pNew->AddRange( aRanges );
2404 SCTAB nTab = aRanges.front()->aStart.Tab();
2405 pDocShell->GetDocFunc().ReplaceConditionalFormat( 0, pNew, nTab, aRanges );
2409 break;
2410 case SC_WID_UNO_VALIDAT:
2411 case SC_WID_UNO_VALILOC:
2412 case SC_WID_UNO_VALIXML:
2414 uno::Reference<beans::XPropertySet> xInterface(aValue, uno::UNO_QUERY);
2415 if ( !aRanges.empty() && xInterface.is() ) // leer = nichts zu tun
2417 ScTableValidationObj* pValidObj =
2418 ScTableValidationObj::getImplementation( xInterface );
2419 if (pValidObj)
2421 ScDocument* pDoc = pDocShell->GetDocument();
2422 sal_Bool bEnglish = ( pEntry->nWID != SC_WID_UNO_VALILOC );
2423 sal_Bool bXML = ( pEntry->nWID == SC_WID_UNO_VALIXML );
2424 formula::FormulaGrammar::Grammar eGrammar = (bXML ?
2425 formula::FormulaGrammar::GRAM_UNSPECIFIED :
2426 formula::FormulaGrammar::mapAPItoGrammar( bEnglish, bXML));
2428 ScValidationData* pNewData =
2429 pValidObj->CreateValidationData( pDoc, eGrammar );
2430 sal_uLong nIndex = pDoc->AddValidationEntry( *pNewData );
2431 delete pNewData;
2433 ScPatternAttr aPattern( pDoc->GetPool() );
2434 aPattern.GetItemSet().Put( SfxUInt32Item( ATTR_VALIDDATA, nIndex ) );
2435 pDocShell->GetDocFunc().ApplyAttributes( *GetMarkData(), aPattern, sal_True, sal_True );
2439 break;
2440 // SC_WID_UNO_NUMRULES is ignored...
2445 uno::Any SAL_CALL ScCellRangesBase::getPropertyValue( const OUString& aPropertyName )
2446 throw(beans::UnknownPropertyException, lang::WrappedTargetException,
2447 uno::RuntimeException)
2449 SolarMutexGuard aGuard;
2451 if ( !pDocShell || aRanges.empty() )
2452 throw uno::RuntimeException();
2454 const SfxItemPropertyMap& rPropertyMap = GetItemPropertyMap(); // from derived class
2455 const SfxItemPropertySimpleEntry* pEntry = rPropertyMap.getByName( aPropertyName );
2456 if ( !pEntry )
2457 throw beans::UnknownPropertyException();
2459 uno::Any aAny;
2460 GetOnePropertyValue( pEntry, aAny );
2461 return aAny;
2464 void ScCellRangesBase::GetOnePropertyValue( const SfxItemPropertySimpleEntry* pEntry,
2465 uno::Any& rAny )
2466 throw(uno::RuntimeException)
2468 if ( pEntry )
2470 if ( IsScItemWid( pEntry->nWID ) )
2472 SfxItemSet* pDataSet = GetCurrentDataSet();
2473 if ( pDataSet )
2475 switch ( pEntry->nWID ) // fuer Item-Spezial-Behandlungen
2477 case ATTR_VALUE_FORMAT:
2479 ScDocument* pDoc = pDocShell->GetDocument();
2481 sal_uLong nOldFormat = ((const SfxUInt32Item&)
2482 pDataSet->Get( ATTR_VALUE_FORMAT )).GetValue();
2483 LanguageType eOldLang = ((const SvxLanguageItem&)
2484 pDataSet->Get( ATTR_LANGUAGE_FORMAT )).GetLanguage();
2485 nOldFormat = pDoc->GetFormatTable()->
2486 GetFormatForLanguageIfBuiltIn( nOldFormat, eOldLang );
2487 rAny <<= (sal_Int32)( nOldFormat );
2489 break;
2490 case ATTR_INDENT:
2491 rAny <<= (sal_Int16)( TwipsToHMM(((const SfxUInt16Item&)
2492 pDataSet->Get(pEntry->nWID)).GetValue()) );
2493 break;
2494 case ATTR_STACKED:
2496 sal_Int32 nRot = ((const SfxInt32Item&)pDataSet->Get(ATTR_ROTATE_VALUE)).GetValue();
2497 sal_Bool bStacked = ((const SfxBoolItem&)pDataSet->Get(pEntry->nWID)).GetValue();
2498 SvxOrientationItem( nRot, bStacked, 0 ).QueryValue( rAny );
2500 break;
2501 default:
2502 pPropSet->getPropertyValue(*pEntry, *pDataSet, rAny);
2506 else // implemented here
2507 switch ( pEntry->nWID )
2509 case SC_WID_UNO_CHCOLHDR:
2510 ScUnoHelpFunctions::SetBoolInAny( rAny, bChartColAsHdr );
2511 break;
2512 case SC_WID_UNO_CHROWHDR:
2513 ScUnoHelpFunctions::SetBoolInAny( rAny, bChartRowAsHdr );
2514 break;
2515 case SC_WID_UNO_CELLSTYL:
2517 OUString aStyleName;
2518 const ScStyleSheet* pStyle = pDocShell->GetDocument()->GetSelectionStyle(*GetMarkData());
2519 if (pStyle)
2520 aStyleName = pStyle->GetName();
2521 rAny <<= OUString( ScStyleNameConversion::DisplayToProgrammaticName(
2522 aStyleName, SFX_STYLE_FAMILY_PARA ) );
2524 break;
2525 case SC_WID_UNO_TBLBORD:
2526 case SC_WID_UNO_TBLBORD2:
2528 //! loop throgh all ranges
2529 if ( !aRanges.empty() )
2531 const ScRange* pFirst = aRanges[ 0 ];
2532 SvxBoxItem aOuter(ATTR_BORDER);
2533 SvxBoxInfoItem aInner(ATTR_BORDER_INNER);
2535 ScDocument* pDoc = pDocShell->GetDocument();
2536 ScMarkData aMark;
2537 aMark.SetMarkArea( *pFirst );
2538 aMark.SelectTable( pFirst->aStart.Tab(), sal_True );
2539 pDoc->GetSelectionFrame( aMark, aOuter, aInner );
2541 if (pEntry->nWID == SC_WID_UNO_TBLBORD2)
2542 ScHelperFunctions::AssignTableBorder2ToAny( rAny, aOuter, aInner);
2543 else
2544 ScHelperFunctions::AssignTableBorderToAny( rAny, aOuter, aInner);
2547 break;
2548 case SC_WID_UNO_CONDFMT:
2549 case SC_WID_UNO_CONDLOC:
2550 case SC_WID_UNO_CONDXML:
2552 const ScPatternAttr* pPattern = GetCurrentAttrsDeep();
2553 if ( pPattern )
2555 ScDocument* pDoc = pDocShell->GetDocument();
2556 sal_Bool bEnglish = ( pEntry->nWID != SC_WID_UNO_CONDLOC );
2557 sal_Bool bXML = ( pEntry->nWID == SC_WID_UNO_CONDXML );
2558 formula::FormulaGrammar::Grammar eGrammar = (bXML ?
2559 pDoc->GetStorageGrammar() :
2560 formula::FormulaGrammar::mapAPItoGrammar( bEnglish, bXML));
2561 const std::vector<sal_uInt32>& rIndex = ((const ScCondFormatItem&)
2562 pPattern->GetItem(ATTR_CONDITIONAL)).GetCondFormatData();
2563 sal_uLong nIndex = 0;
2564 if(!rIndex.empty())
2565 nIndex = rIndex[0];
2566 rAny <<= uno::Reference<sheet::XSheetConditionalEntries>(
2567 new ScTableConditionalFormat( pDoc, nIndex, aRanges.front()->aStart.Tab(), eGrammar ));
2570 break;
2571 case SC_WID_UNO_VALIDAT:
2572 case SC_WID_UNO_VALILOC:
2573 case SC_WID_UNO_VALIXML:
2575 const ScPatternAttr* pPattern = GetCurrentAttrsDeep();
2576 if ( pPattern )
2578 ScDocument* pDoc = pDocShell->GetDocument();
2579 sal_Bool bEnglish = ( pEntry->nWID != SC_WID_UNO_VALILOC );
2580 sal_Bool bXML = ( pEntry->nWID == SC_WID_UNO_VALIXML );
2581 formula::FormulaGrammar::Grammar eGrammar = (bXML ?
2582 pDoc->GetStorageGrammar() :
2583 formula::FormulaGrammar::mapAPItoGrammar( bEnglish, bXML));
2584 sal_uLong nIndex = ((const SfxUInt32Item&)
2585 pPattern->GetItem(ATTR_VALIDDATA)).GetValue();
2586 rAny <<= uno::Reference<beans::XPropertySet>(
2587 new ScTableValidationObj( pDoc, nIndex, eGrammar ));
2590 break;
2591 case SC_WID_UNO_NUMRULES:
2593 // always return empty numbering rules object
2594 rAny <<= uno::Reference<container::XIndexReplace>(ScStyleObj::CreateEmptyNumberingRules());
2596 break;
2597 case SC_WID_UNO_ABSNAME:
2599 OUString sRet;
2600 aRanges.Format(sRet, SCR_ABS_3D, pDocShell->GetDocument());
2601 rAny <<= sRet;
2607 void SAL_CALL ScCellRangesBase::addPropertyChangeListener( const OUString& /* aPropertyName */,
2608 const uno::Reference<beans::XPropertyChangeListener>& /* aListener */)
2609 throw(beans::UnknownPropertyException,
2610 lang::WrappedTargetException, uno::RuntimeException)
2612 SolarMutexGuard aGuard;
2613 if ( aRanges.empty() )
2614 throw uno::RuntimeException();
2616 OSL_FAIL("not implemented");
2619 void SAL_CALL ScCellRangesBase::removePropertyChangeListener( const OUString& /* aPropertyName */,
2620 const uno::Reference<beans::XPropertyChangeListener>& /* aListener */)
2621 throw(beans::UnknownPropertyException,
2622 lang::WrappedTargetException, uno::RuntimeException)
2624 SolarMutexGuard aGuard;
2625 if ( aRanges.empty() )
2626 throw uno::RuntimeException();
2628 OSL_FAIL("not implemented");
2631 void SAL_CALL ScCellRangesBase::addVetoableChangeListener( const OUString&,
2632 const uno::Reference<beans::XVetoableChangeListener>&)
2633 throw(beans::UnknownPropertyException,
2634 lang::WrappedTargetException, uno::RuntimeException)
2636 OSL_FAIL("not implemented");
2639 void SAL_CALL ScCellRangesBase::removeVetoableChangeListener( const OUString&,
2640 const uno::Reference<beans::XVetoableChangeListener>&)
2641 throw(beans::UnknownPropertyException,
2642 lang::WrappedTargetException, uno::RuntimeException)
2644 OSL_FAIL("not implemented");
2647 // XMultiPropertySet
2649 void SAL_CALL ScCellRangesBase::setPropertyValues( const uno::Sequence< OUString >& aPropertyNames,
2650 const uno::Sequence< uno::Any >& aValues )
2651 throw (beans::PropertyVetoException,
2652 lang::IllegalArgumentException,
2653 lang::WrappedTargetException,
2654 uno::RuntimeException)
2656 SolarMutexGuard aGuard;
2658 sal_Int32 nCount(aPropertyNames.getLength());
2659 sal_Int32 nValues(aValues.getLength());
2660 if (nCount != nValues)
2661 throw lang::IllegalArgumentException();
2663 if ( pDocShell && nCount )
2665 const SfxItemPropertyMap& rPropertyMap = GetItemPropertyMap(); // from derived class
2666 const OUString* pNames = aPropertyNames.getConstArray();
2667 const uno::Any* pValues = aValues.getConstArray();
2669 const SfxItemPropertySimpleEntry** pEntryArray = new const SfxItemPropertySimpleEntry*[nCount];
2671 sal_Int32 i;
2672 for(i = 0; i < nCount; i++)
2674 // first loop: find all properties in map, but handle only CellStyle
2675 // (CellStyle must be set before any other cell properties)
2677 const SfxItemPropertySimpleEntry* pEntry = rPropertyMap.getByName( pNames[i] );
2678 pEntryArray[i] = pEntry;
2679 if (pEntry)
2681 if ( pEntry->nWID == SC_WID_UNO_CELLSTYL )
2685 SetOnePropertyValue( pEntry, pValues[i] );
2687 catch ( lang::IllegalArgumentException& )
2689 OSL_FAIL("exception when setting cell style"); // not supposed to happen
2695 ScDocument* pDoc = pDocShell->GetDocument();
2696 ScPatternAttr* pOldPattern = NULL;
2697 ScPatternAttr* pNewPattern = NULL;
2699 for(i = 0; i < nCount; i++)
2701 // second loop: handle other properties
2703 const SfxItemPropertySimpleEntry* pEntry = pEntryArray[i];
2704 if ( pEntry )
2706 if ( IsScItemWid( pEntry->nWID ) ) // can be handled by SfxItemPropertySet
2708 if ( !pOldPattern )
2710 pOldPattern = new ScPatternAttr( *GetCurrentAttrsDeep() );
2711 pOldPattern->GetItemSet().ClearInvalidItems();
2712 pNewPattern = new ScPatternAttr( pDoc->GetPool() );
2715 // collect items in pNewPattern, apply with one call after the loop
2717 sal_uInt16 nFirstItem, nSecondItem;
2718 lcl_SetCellProperty( *pEntry, pValues[i], *pOldPattern, pDoc, nFirstItem, nSecondItem );
2720 // put only affected items into new set
2721 if ( nFirstItem )
2722 pNewPattern->GetItemSet().Put( pOldPattern->GetItemSet().Get( nFirstItem ) );
2723 if ( nSecondItem )
2724 pNewPattern->GetItemSet().Put( pOldPattern->GetItemSet().Get( nSecondItem ) );
2726 else if ( pEntry->nWID != SC_WID_UNO_CELLSTYL ) // CellStyle is handled above
2728 // call virtual method to set a single property
2729 SetOnePropertyValue( pEntry, pValues[i] );
2734 if ( pNewPattern && !aRanges.empty() )
2735 pDocShell->GetDocFunc().ApplyAttributes( *GetMarkData(), *pNewPattern, sal_True, sal_True );
2737 delete pNewPattern;
2738 delete pOldPattern;
2739 delete[] pEntryArray;
2743 uno::Sequence<uno::Any> SAL_CALL ScCellRangesBase::getPropertyValues(
2744 const uno::Sequence< OUString >& aPropertyNames )
2745 throw (uno::RuntimeException)
2747 SolarMutexGuard aGuard;
2749 const SfxItemPropertyMap& rPropertyMap = GetItemPropertyMap(); // from derived class
2751 uno::Sequence<uno::Any> aRet(aPropertyNames.getLength());
2752 uno::Any* pProperties = aRet.getArray();
2753 for(sal_Int32 i = 0; i < aPropertyNames.getLength(); i++)
2755 const SfxItemPropertySimpleEntry* pEntry = rPropertyMap.getByName( aPropertyNames[i] );
2756 GetOnePropertyValue( pEntry, pProperties[i] );
2758 return aRet;
2761 void SAL_CALL ScCellRangesBase::addPropertiesChangeListener( const uno::Sequence< OUString >& /* aPropertyNames */,
2762 const uno::Reference< beans::XPropertiesChangeListener >& /* xListener */ )
2763 throw (uno::RuntimeException)
2765 OSL_FAIL("not implemented");
2768 void SAL_CALL ScCellRangesBase::removePropertiesChangeListener( const uno::Reference< beans::XPropertiesChangeListener >& /* xListener */ )
2769 throw (uno::RuntimeException)
2771 OSL_FAIL("not implemented");
2774 void SAL_CALL ScCellRangesBase::firePropertiesChangeEvent( const uno::Sequence< OUString >& /* aPropertyNames */,
2775 const uno::Reference< beans::XPropertiesChangeListener >& /* xListener */ )
2776 throw (uno::RuntimeException)
2778 OSL_FAIL("not implemented");
2781 IMPL_LINK( ScCellRangesBase, ValueListenerHdl, SfxHint*, pHint )
2783 if ( pDocShell && pHint && pHint->ISA( SfxSimpleHint ) &&
2784 (((const SfxSimpleHint*)pHint)->GetId() & SC_HINT_DATACHANGED))
2786 // This may be called several times for a single change, if several formulas
2787 // in the range are notified. So only a flag is set that is checked when
2788 // SFX_HINT_DATACHANGED is received.
2790 bGotDataChangedHint = sal_True;
2792 return 0;
2795 // XTolerantMultiPropertySet
2796 uno::Sequence< beans::SetPropertyTolerantFailed > SAL_CALL ScCellRangesBase::setPropertyValuesTolerant( const uno::Sequence< OUString >& aPropertyNames,
2797 const uno::Sequence< uno::Any >& aValues )
2798 throw (lang::IllegalArgumentException, uno::RuntimeException)
2800 SolarMutexGuard aGuard;
2802 sal_Int32 nCount(aPropertyNames.getLength());
2803 sal_Int32 nValues(aValues.getLength());
2804 if (nCount != nValues)
2805 throw lang::IllegalArgumentException();
2807 if ( pDocShell && nCount )
2809 uno::Sequence < beans::SetPropertyTolerantFailed > aReturns(nCount);
2810 beans::SetPropertyTolerantFailed* pReturns = aReturns.getArray();
2812 const SfxItemPropertyMap& rPropertyMap = GetItemPropertyMap(); // from derived class
2813 const OUString* pNames = aPropertyNames.getConstArray();
2814 const uno::Any* pValues = aValues.getConstArray();
2816 const SfxItemPropertySimpleEntry** pMapArray = new const SfxItemPropertySimpleEntry*[nCount];
2818 sal_Int32 i;
2819 for(i = 0; i < nCount; i++)
2821 // first loop: find all properties in map, but handle only CellStyle
2822 // (CellStyle must be set before any other cell properties)
2824 const SfxItemPropertySimpleEntry* pEntry = rPropertyMap.getByName( pNames[i] );
2825 pMapArray[i] = pEntry;
2826 if (pEntry)
2828 if ( pEntry->nWID == SC_WID_UNO_CELLSTYL )
2832 SetOnePropertyValue( pEntry, pValues[i] );
2834 catch ( lang::IllegalArgumentException& )
2836 OSL_FAIL("exception when setting cell style"); // not supposed to happen
2842 ScDocument* pDoc = pDocShell->GetDocument();
2843 ScPatternAttr* pOldPattern = NULL;
2844 ScPatternAttr* pNewPattern = NULL;
2846 sal_Int32 nFailed(0);
2847 for(i = 0; i < nCount; i++)
2849 // second loop: handle other properties
2851 const SfxItemPropertySimpleEntry* pEntry = pMapArray[i];
2852 if ( pEntry && ((pEntry->nFlags & beans::PropertyAttribute::READONLY) == 0))
2854 if ( IsScItemWid( pEntry->nWID ) ) // can be handled by SfxItemPropertySet
2856 if ( !pOldPattern )
2858 pOldPattern = new ScPatternAttr( *GetCurrentAttrsDeep() );
2859 pOldPattern->GetItemSet().ClearInvalidItems();
2860 pNewPattern = new ScPatternAttr( pDoc->GetPool() );
2863 // collect items in pNewPattern, apply with one call after the loop
2865 sal_uInt16 nFirstItem, nSecondItem;
2868 lcl_SetCellProperty( *pEntry, pValues[i], *pOldPattern, pDoc, nFirstItem, nSecondItem );
2870 // put only affected items into new set
2871 if ( nFirstItem )
2872 pNewPattern->GetItemSet().Put( pOldPattern->GetItemSet().Get( nFirstItem ) );
2873 if ( nSecondItem )
2874 pNewPattern->GetItemSet().Put( pOldPattern->GetItemSet().Get( nSecondItem ) );
2876 catch ( lang::IllegalArgumentException& )
2878 pReturns[nFailed].Name = pNames[i];
2879 pReturns[nFailed++].Result = beans::TolerantPropertySetResultType::ILLEGAL_ARGUMENT;
2882 else if ( pEntry->nWID != SC_WID_UNO_CELLSTYL ) // CellStyle is handled above
2884 // call virtual method to set a single property
2887 SetOnePropertyValue( pEntry, pValues[i] );
2889 catch ( lang::IllegalArgumentException& )
2891 pReturns[nFailed].Name = pNames[i];
2892 pReturns[nFailed++].Result = beans::TolerantPropertySetResultType::ILLEGAL_ARGUMENT;
2896 else
2898 pReturns[nFailed].Name = pNames[i];
2899 if (pEntry)
2900 pReturns[nFailed++].Result = beans::TolerantPropertySetResultType::PROPERTY_VETO;
2901 else
2902 pReturns[nFailed++].Result = beans::TolerantPropertySetResultType::UNKNOWN_PROPERTY;
2906 if ( pNewPattern && !aRanges.empty() )
2907 pDocShell->GetDocFunc().ApplyAttributes( *GetMarkData(), *pNewPattern, sal_True, sal_True );
2909 delete pNewPattern;
2910 delete pOldPattern;
2911 delete[] pMapArray;
2913 aReturns.realloc(nFailed);
2915 return aReturns;
2917 return uno::Sequence < beans::SetPropertyTolerantFailed >();
2920 uno::Sequence< beans::GetPropertyTolerantResult > SAL_CALL ScCellRangesBase::getPropertyValuesTolerant( const uno::Sequence< OUString >& aPropertyNames )
2921 throw (uno::RuntimeException)
2923 SolarMutexGuard aGuard;
2925 sal_Int32 nCount(aPropertyNames.getLength());
2926 uno::Sequence < beans::GetPropertyTolerantResult > aReturns(nCount);
2927 beans::GetPropertyTolerantResult* pReturns = aReturns.getArray();
2929 const SfxItemPropertyMap& rPropertyMap = GetItemPropertyMap(); // from derived class
2931 for(sal_Int32 i = 0; i < nCount; i++)
2933 const SfxItemPropertySimpleEntry* pEntry = rPropertyMap.getByName( aPropertyNames[i] );
2934 if (!pEntry)
2936 pReturns[i].Result = beans::TolerantPropertySetResultType::UNKNOWN_PROPERTY;
2938 else
2940 sal_uInt16 nItemWhich = 0;
2941 lcl_GetPropertyWhich( pEntry, nItemWhich );
2942 pReturns[i].State = GetOnePropertyState( nItemWhich, pEntry );
2943 GetOnePropertyValue( pEntry, pReturns[i].Value );
2944 pReturns[i].Result = beans::TolerantPropertySetResultType::SUCCESS;
2947 return aReturns;
2950 uno::Sequence< beans::GetDirectPropertyTolerantResult > SAL_CALL ScCellRangesBase::getDirectPropertyValuesTolerant( const uno::Sequence< OUString >& aPropertyNames )
2951 throw (uno::RuntimeException)
2953 SolarMutexGuard aGuard;
2955 sal_Int32 nCount(aPropertyNames.getLength());
2956 uno::Sequence < beans::GetDirectPropertyTolerantResult > aReturns(nCount);
2957 beans::GetDirectPropertyTolerantResult* pReturns = aReturns.getArray();
2959 const SfxItemPropertyMap& rPropertyMap = GetItemPropertyMap(); // from derived class
2961 sal_Int32 j = 0;
2962 for(sal_Int32 i = 0; i < nCount; i++)
2964 const SfxItemPropertySimpleEntry* pEntry = rPropertyMap.getByName( aPropertyNames[i] );
2965 if (!pEntry)
2967 pReturns[i].Result = beans::TolerantPropertySetResultType::UNKNOWN_PROPERTY;
2969 else
2971 sal_uInt16 nItemWhich = 0;
2972 lcl_GetPropertyWhich( pEntry, nItemWhich );
2973 pReturns[j].State = GetOnePropertyState( nItemWhich, pEntry );
2974 if (pReturns[j].State == beans::PropertyState_DIRECT_VALUE)
2976 GetOnePropertyValue( pEntry, pReturns[j].Value );
2977 pReturns[j].Result = beans::TolerantPropertySetResultType::SUCCESS;
2978 pReturns[j].Name = aPropertyNames[i];
2979 ++j;
2983 if (j < nCount)
2984 aReturns.realloc(j);
2985 return aReturns;
2988 // XIndent
2990 void SAL_CALL ScCellRangesBase::decrementIndent() throw(::com::sun::star::uno::RuntimeException)
2992 SolarMutexGuard aGuard;
2993 if ( pDocShell && !aRanges.empty() ) // leer = nichts zu tun
2995 //#97041#; put only MultiMarked ScMarkData in ChangeIndent
2996 ScMarkData aMarkData(*GetMarkData());
2997 aMarkData.MarkToMulti();
2998 pDocShell->GetDocFunc().ChangeIndent( aMarkData, false, sal_True );
3002 void SAL_CALL ScCellRangesBase::incrementIndent() throw(::com::sun::star::uno::RuntimeException)
3004 SolarMutexGuard aGuard;
3005 if ( pDocShell && !aRanges.empty() ) // leer = nichts zu tun
3007 //#97041#; put only MultiMarked ScMarkData in ChangeIndent
3008 ScMarkData aMarkData(*GetMarkData());
3009 aMarkData.MarkToMulti();
3010 pDocShell->GetDocFunc().ChangeIndent( aMarkData, sal_True, sal_True );
3014 // XChartData
3016 ScMemChart* ScCellRangesBase::CreateMemChart_Impl() const
3018 if ( pDocShell && !aRanges.empty() )
3020 ScRangeListRef xChartRanges;
3021 if ( aRanges.size() == 1 )
3023 // ganze Tabelle sinnvoll begrenzen (auf belegten Datenbereich)
3024 // (nur hier, Listener werden auf den ganzen Bereich angemeldet)
3025 //! direkt testen, ob es ein ScTableSheetObj ist?
3027 const ScRange* pRange = aRanges[0];
3028 if ( pRange->aStart.Col() == 0 && pRange->aEnd.Col() == MAXCOL &&
3029 pRange->aStart.Row() == 0 && pRange->aEnd.Row() == MAXROW )
3031 SCTAB nTab = pRange->aStart.Tab();
3033 SCCOL nStartX;
3034 SCROW nStartY; // Anfang holen
3035 if (!pDocShell->GetDocument()->GetDataStart( nTab, nStartX, nStartY ))
3037 nStartX = 0;
3038 nStartY = 0;
3041 SCCOL nEndX;
3042 SCROW nEndY; // Ende holen
3043 if (!pDocShell->GetDocument()->GetTableArea( nTab, nEndX, nEndY ))
3045 nEndX = 0;
3046 nEndY = 0;
3049 xChartRanges = new ScRangeList;
3050 xChartRanges->Append( ScRange( nStartX, nStartY, nTab, nEndX, nEndY, nTab ) );
3053 if (!xChartRanges.Is()) // sonst Ranges direkt uebernehmen
3054 xChartRanges = new ScRangeList(aRanges);
3055 ScChartArray aArr( pDocShell->GetDocument(), xChartRanges, OUString() );
3057 // RowAsHdr = ColHeaders und umgekehrt
3058 aArr.SetHeaders( bChartRowAsHdr, bChartColAsHdr );
3060 return aArr.CreateMemChart();
3062 return NULL;
3065 uno::Sequence< uno::Sequence<double> > SAL_CALL ScCellRangesBase::getData()
3066 throw(uno::RuntimeException)
3068 SolarMutexGuard aGuard;
3069 ScMemChart* pMemChart = CreateMemChart_Impl();
3070 if ( pMemChart )
3072 sal_Int32 nColCount = pMemChart->GetColCount();
3073 sal_Int32 nRowCount = static_cast<sal_Int32>(pMemChart->GetRowCount());
3075 uno::Sequence< uno::Sequence<double> > aRowSeq( nRowCount );
3076 uno::Sequence<double>* pRowAry = aRowSeq.getArray();
3077 for (sal_Int32 nRow = 0; nRow < nRowCount; nRow++)
3079 uno::Sequence<double> aColSeq( nColCount );
3080 double* pColAry = aColSeq.getArray();
3081 for (sal_Int32 nCol = 0; nCol < nColCount; nCol++)
3082 pColAry[nCol] = pMemChart->GetData( static_cast<short>(nCol), static_cast<short>(nRow) );
3084 pRowAry[nRow] = aColSeq;
3087 delete pMemChart;
3088 return aRowSeq;
3091 return uno::Sequence< uno::Sequence<double> >(0);
3094 ScRangeListRef ScCellRangesBase::GetLimitedChartRanges_Impl( long nDataColumns, long nDataRows ) const
3096 if ( aRanges.size() == 1 )
3098 const ScRange* pRange = aRanges[0];
3099 if ( pRange->aStart.Col() == 0 && pRange->aEnd.Col() == MAXCOL &&
3100 pRange->aStart.Row() == 0 && pRange->aEnd.Row() == MAXROW )
3102 // if aRanges is a complete sheet, limit to given size
3104 SCTAB nTab = pRange->aStart.Tab();
3106 long nEndColumn = nDataColumns - 1 + ( bChartColAsHdr ? 1 : 0 );
3107 if ( nEndColumn < 0 )
3108 nEndColumn = 0;
3109 if ( nEndColumn > MAXCOL )
3110 nEndColumn = MAXCOL;
3112 long nEndRow = nDataRows - 1 + ( bChartRowAsHdr ? 1 : 0 );
3113 if ( nEndRow < 0 )
3114 nEndRow = 0;
3115 if ( nEndRow > MAXROW )
3116 nEndRow = MAXROW;
3118 ScRangeListRef xChartRanges = new ScRangeList;
3119 xChartRanges->Append( ScRange( 0, 0, nTab, (SCCOL)nEndColumn, (SCROW)nEndRow, nTab ) );
3120 return xChartRanges;
3124 return new ScRangeList(aRanges); // as-is
3127 void SAL_CALL ScCellRangesBase::setData( const uno::Sequence< uno::Sequence<double> >& aData )
3128 throw(uno::RuntimeException)
3130 SolarMutexGuard aGuard;
3131 sal_Bool bDone = false;
3132 long nRowCount = aData.getLength();
3133 long nColCount = nRowCount ? aData[0].getLength() : 0;
3134 ScRangeListRef xChartRanges = GetLimitedChartRanges_Impl( nColCount, nRowCount );
3135 if ( pDocShell && xChartRanges.Is() )
3137 ScDocument* pDoc = pDocShell->GetDocument();
3138 ScChartArray aArr( pDoc, xChartRanges, OUString() );
3139 aArr.SetHeaders( bChartRowAsHdr, bChartColAsHdr ); // RowAsHdr = ColHeaders
3140 const ScChartPositionMap* pPosMap = aArr.GetPositionMap();
3141 if (pPosMap)
3143 if ( pPosMap->GetColCount() == static_cast<SCCOL>(nColCount) &&
3144 pPosMap->GetRowCount() == static_cast<SCROW>(nRowCount) )
3146 for (long nRow=0; nRow<nRowCount; nRow++)
3148 const uno::Sequence<double>& rRowSeq = aData[nRow];
3149 const double* pArray = rRowSeq.getConstArray();
3150 nColCount = rRowSeq.getLength();
3151 for (long nCol=0; nCol<nColCount; nCol++)
3153 const ScAddress* pPos = pPosMap->GetPosition(
3154 sal::static_int_cast<SCCOL>(nCol),
3155 sal::static_int_cast<SCROW>(nRow) );
3156 if (pPos)
3158 double fVal = pArray[nCol];
3159 if ( fVal == DBL_MIN )
3160 pDoc->SetEmptyCell(*pPos);
3161 else
3162 pDoc->SetValue(*pPos, pArray[nCol]);
3167 //! undo
3168 PaintRanges_Impl( PAINT_GRID );
3169 pDocShell->SetDocumentModified();
3170 ForceChartListener_Impl(); // call listeners for this object synchronously
3171 bDone = sal_True;
3176 if (!bDone)
3177 throw uno::RuntimeException();
3180 uno::Sequence<OUString> SAL_CALL ScCellRangesBase::getRowDescriptions()
3181 throw(uno::RuntimeException)
3183 SolarMutexGuard aGuard;
3184 ScMemChart* pMemChart = CreateMemChart_Impl();
3185 if ( pMemChart )
3187 sal_Int32 nRowCount = static_cast<sal_Int32>(pMemChart->GetRowCount());
3188 uno::Sequence<OUString> aSeq( nRowCount );
3189 OUString* pAry = aSeq.getArray();
3190 for (sal_Int32 nRow = 0; nRow < nRowCount; nRow++)
3191 pAry[nRow] = pMemChart->GetRowText(static_cast<short>(nRow));
3193 delete pMemChart;
3194 return aSeq;
3196 return uno::Sequence<OUString>(0);
3199 void SAL_CALL ScCellRangesBase::setRowDescriptions(
3200 const uno::Sequence<OUString>& aRowDescriptions )
3201 throw(uno::RuntimeException)
3203 SolarMutexGuard aGuard;
3204 sal_Bool bDone = false;
3205 if ( bChartColAsHdr )
3207 long nRowCount = aRowDescriptions.getLength();
3208 ScRangeListRef xChartRanges = GetLimitedChartRanges_Impl( 1, nRowCount );
3209 if ( pDocShell && xChartRanges.Is() )
3211 ScDocument* pDoc = pDocShell->GetDocument();
3212 ScChartArray aArr( pDoc, xChartRanges, OUString() );
3213 aArr.SetHeaders( bChartRowAsHdr, bChartColAsHdr ); // RowAsHdr = ColHeaders
3214 const ScChartPositionMap* pPosMap = aArr.GetPositionMap();
3215 if (pPosMap)
3217 if ( pPosMap->GetRowCount() == static_cast<SCROW>(nRowCount) )
3219 const OUString* pArray = aRowDescriptions.getConstArray();
3220 for (long nRow=0; nRow<nRowCount; nRow++)
3222 const ScAddress* pPos = pPosMap->GetRowHeaderPosition(
3223 static_cast<SCSIZE>(nRow) );
3224 if (pPos)
3226 const OUString& aStr = pArray[nRow];
3227 if (aStr.isEmpty())
3228 pDoc->SetEmptyCell(*pPos);
3229 else
3231 ScSetStringParam aParam;
3232 aParam.setTextInput();
3233 pDoc->SetString(*pPos, aStr, &aParam);
3238 //! undo
3239 PaintRanges_Impl( PAINT_GRID );
3240 pDocShell->SetDocumentModified();
3241 ForceChartListener_Impl(); // call listeners for this object synchronously
3242 bDone = sal_True;
3248 if (!bDone)
3249 throw uno::RuntimeException();
3252 uno::Sequence<OUString> SAL_CALL ScCellRangesBase::getColumnDescriptions()
3253 throw(uno::RuntimeException)
3255 SolarMutexGuard aGuard;
3256 ScMemChart* pMemChart = CreateMemChart_Impl();
3257 if ( pMemChart )
3259 sal_Int32 nColCount = pMemChart->GetColCount();
3260 uno::Sequence<OUString> aSeq( nColCount );
3261 OUString* pAry = aSeq.getArray();
3262 for (sal_Int32 nCol = 0; nCol < nColCount; nCol++)
3263 pAry[nCol] = pMemChart->GetColText(static_cast<short>(nCol));
3265 delete pMemChart;
3266 return aSeq;
3268 return uno::Sequence<OUString>(0);
3271 void SAL_CALL ScCellRangesBase::setColumnDescriptions(
3272 const uno::Sequence<OUString>& aColumnDescriptions )
3273 throw(uno::RuntimeException)
3275 SolarMutexGuard aGuard;
3276 sal_Bool bDone = false;
3277 if ( bChartRowAsHdr )
3279 long nColCount = aColumnDescriptions.getLength();
3280 ScRangeListRef xChartRanges = GetLimitedChartRanges_Impl( nColCount, 1 );
3281 if ( pDocShell && xChartRanges.Is() )
3283 ScDocument* pDoc = pDocShell->GetDocument();
3284 ScChartArray aArr( pDoc, xChartRanges, OUString() );
3285 aArr.SetHeaders( bChartRowAsHdr, bChartColAsHdr ); // RowAsHdr = ColHeaders
3286 const ScChartPositionMap* pPosMap = aArr.GetPositionMap();
3287 if (pPosMap)
3289 if ( pPosMap->GetColCount() == static_cast<SCCOL>(nColCount) )
3291 const OUString* pArray = aColumnDescriptions.getConstArray();
3292 for (long nCol=0; nCol<nColCount; nCol++)
3294 const ScAddress* pPos = pPosMap->GetColHeaderPosition(
3295 sal::static_int_cast<SCCOL>(nCol) );
3296 if (pPos)
3298 const OUString& aStr = pArray[nCol];
3299 if (aStr.isEmpty())
3300 pDoc->SetEmptyCell(*pPos);
3301 else
3303 ScSetStringParam aParam;
3304 aParam.setTextInput();
3305 pDoc->SetString(*pPos, aStr, &aParam);
3310 //! undo
3311 PaintRanges_Impl( PAINT_GRID );
3312 pDocShell->SetDocumentModified();
3313 ForceChartListener_Impl(); // call listeners for this object synchronously
3314 bDone = sal_True;
3320 if (!bDone)
3321 throw uno::RuntimeException();
3324 void ScCellRangesBase::ForceChartListener_Impl()
3326 // call Update immediately so the caller to setData etc. can
3327 // regognize the listener call
3329 if (!pDocShell)
3330 return;
3332 ScChartListenerCollection* pColl = pDocShell->GetDocument()->GetChartListenerCollection();
3333 if (!pColl)
3334 return;
3336 ScChartListenerCollection::ListenersType& rListeners = pColl->getListeners();
3337 ScChartListenerCollection::ListenersType::iterator it = rListeners.begin(), itEnd = rListeners.end();
3338 for (; it != itEnd; ++it)
3340 ScChartListener* p = it->second;
3341 OSL_ASSERT(p);
3342 if (p->GetUnoSource() == static_cast<chart::XChartData*>(this) && p->IsDirty())
3343 p->Update();
3347 void SAL_CALL ScCellRangesBase::addChartDataChangeEventListener( const uno::Reference<
3348 chart::XChartDataChangeEventListener >& aListener )
3349 throw(uno::RuntimeException)
3351 SolarMutexGuard aGuard;
3352 if ( pDocShell && !aRanges.empty() )
3354 //! auf doppelte testen?
3356 ScDocument* pDoc = pDocShell->GetDocument();
3357 ScRangeListRef aRangesRef( new ScRangeList(aRanges) );
3358 ScChartListenerCollection* pColl = pDoc->GetChartListenerCollection();
3359 OUString aName = pColl->getUniqueName(OUString("__Uno"));
3360 if (aName.isEmpty())
3361 // failed to create unique name.
3362 return;
3364 ScChartListener* pListener = new ScChartListener( aName, pDoc, aRangesRef );
3365 pListener->SetUno( aListener, this );
3366 pColl->insert( pListener );
3367 pListener->StartListeningTo();
3371 void SAL_CALL ScCellRangesBase::removeChartDataChangeEventListener( const uno::Reference<
3372 chart::XChartDataChangeEventListener >& aListener )
3373 throw(uno::RuntimeException)
3375 SolarMutexGuard aGuard;
3376 if ( pDocShell && !aRanges.empty() )
3378 ScDocument* pDoc = pDocShell->GetDocument();
3379 ScChartListenerCollection* pColl = pDoc->GetChartListenerCollection();
3380 pColl->FreeUno( aListener, this );
3384 double SAL_CALL ScCellRangesBase::getNotANumber() throw(::com::sun::star::uno::RuntimeException)
3386 // im ScChartArray wird DBL_MIN verwendet, weil das Chart es so will
3387 return DBL_MIN;
3390 sal_Bool SAL_CALL ScCellRangesBase::isNotANumber( double nNumber ) throw(uno::RuntimeException)
3392 // im ScChartArray wird DBL_MIN verwendet, weil das Chart es so will
3393 return (nNumber == DBL_MIN);
3396 // XModifyBroadcaster
3398 void SAL_CALL ScCellRangesBase::addModifyListener( const uno::Reference<util::XModifyListener>& aListener )
3399 throw(uno::RuntimeException)
3401 SolarMutexGuard aGuard;
3402 if ( aRanges.empty() )
3403 throw uno::RuntimeException();
3405 uno::Reference<util::XModifyListener> *pObj =
3406 new uno::Reference<util::XModifyListener>( aListener );
3407 aValueListeners.push_back( pObj );
3409 if ( aValueListeners.size() == 1 )
3411 if (!pValueListener)
3412 pValueListener = new ScLinkListener( LINK( this, ScCellRangesBase, ValueListenerHdl ) );
3414 ScDocument* pDoc = pDocShell->GetDocument();
3415 for ( size_t i = 0, nCount = aRanges.size(); i < nCount; i++)
3416 pDoc->StartListeningArea( *aRanges[ i ], pValueListener );
3418 acquire(); // don't lose this object (one ref for all listeners)
3422 void SAL_CALL ScCellRangesBase::removeModifyListener( const uno::Reference<util::XModifyListener>& aListener )
3423 throw(uno::RuntimeException)
3426 SolarMutexGuard aGuard;
3427 if ( aRanges.empty() )
3428 throw uno::RuntimeException();
3430 acquire(); // in case the listeners have the last ref - released below
3432 sal_uInt16 nCount = aValueListeners.size();
3433 for ( sal_uInt16 n=nCount; n--; )
3435 uno::Reference<util::XModifyListener>& rObj = aValueListeners[n];
3436 if ( rObj == aListener )
3438 aValueListeners.erase( aValueListeners.begin() + n );
3440 if ( aValueListeners.empty() )
3442 if (pValueListener)
3443 pValueListener->EndListeningAll();
3445 release(); // release the ref for the listeners
3448 break;
3452 release(); // might delete this object
3455 // XCellRangesQuery
3457 uno::Reference<sheet::XSheetCellRanges> SAL_CALL ScCellRangesBase::queryVisibleCells()
3458 throw(uno::RuntimeException)
3460 SolarMutexGuard aGuard;
3461 if (pDocShell)
3463 //! fuer alle Tabellen getrennt, wenn Markierungen pro Tabelle getrennt sind!
3464 SCTAB nTab = lcl_FirstTab(aRanges);
3466 ScMarkData aMarkData(*GetMarkData());
3468 ScDocument* pDoc = pDocShell->GetDocument();
3469 SCCOL nCol = 0, nLastCol;
3470 while (nCol <= MAXCOL)
3472 if (pDoc->ColHidden(nCol, nTab, NULL, &nLastCol))
3473 // hidden columns. Unselect them.
3474 aMarkData.SetMultiMarkArea(ScRange(nCol, 0, nTab, nLastCol, MAXROW, nTab), false);
3476 nCol = nLastCol + 1;
3479 SCROW nRow = 0, nLastRow;
3480 while (nRow <= MAXROW)
3482 if (pDoc->RowHidden(nRow, nTab, NULL, &nLastRow))
3483 // These rows are hidden. Unselect them.
3484 aMarkData.SetMultiMarkArea(ScRange(0, nRow, nTab, MAXCOL, nLastRow, nTab), false);
3486 nRow = nLastRow + 1;
3489 ScRangeList aNewRanges;
3490 aMarkData.FillRangeListWithMarks( &aNewRanges, false );
3491 return new ScCellRangesObj( pDocShell, aNewRanges );
3494 return NULL;
3497 uno::Reference<sheet::XSheetCellRanges> SAL_CALL ScCellRangesBase::queryEmptyCells()
3498 throw(uno::RuntimeException)
3500 SolarMutexGuard aGuard;
3501 if (pDocShell)
3503 ScDocument* pDoc = pDocShell->GetDocument();
3505 ScMarkData aMarkData(*GetMarkData());
3507 // belegte Zellen wegmarkieren
3508 for (size_t i = 0, nCount = aRanges.size(); i < nCount; ++i)
3510 ScRange aRange = *aRanges[ i ];
3512 ScCellIterator aIter( pDoc, aRange );
3513 for (bool bHasCell = aIter.first(); bHasCell; bHasCell = aIter.next())
3515 // Notizen zaehlen als nicht-leer
3516 if (!aIter.isEmpty())
3517 aMarkData.SetMultiMarkArea(aIter.GetPos(), false);
3521 ScRangeList aNewRanges;
3522 // IsMultiMarked reicht hier nicht (wird beim deselektieren nicht zurueckgesetzt)
3523 //if (aMarkData.HasAnyMultiMarks()) // #i20044# should be set for all empty range
3524 aMarkData.FillRangeListWithMarks( &aNewRanges, false );
3526 return new ScCellRangesObj( pDocShell, aNewRanges ); // aNewRanges kann leer sein
3529 return NULL;
3532 uno::Reference<sheet::XSheetCellRanges> SAL_CALL ScCellRangesBase::queryContentCells(
3533 sal_Int16 nContentFlags )
3534 throw(uno::RuntimeException)
3536 SolarMutexGuard aGuard;
3537 if (pDocShell)
3539 ScDocument* pDoc = pDocShell->GetDocument();
3541 ScMarkData aMarkData;
3543 // passende Zellen selektieren
3544 for ( size_t i = 0, nCount = aRanges.size(); i < nCount; ++i )
3546 ScRange aRange = *aRanges[ i ];
3548 ScCellIterator aIter( pDoc, aRange );
3549 for (bool bHasCell = aIter.first(); bHasCell; bHasCell = aIter.next())
3551 bool bAdd = false;
3552 switch (aIter.getType())
3554 case CELLTYPE_STRING:
3555 if ( nContentFlags & sheet::CellFlags::STRING )
3556 bAdd = true;
3557 break;
3558 case CELLTYPE_EDIT:
3559 if ( (nContentFlags & sheet::CellFlags::STRING) || (nContentFlags & sheet::CellFlags::FORMATTED) )
3560 bAdd = true;
3561 break;
3562 case CELLTYPE_FORMULA:
3563 if ( nContentFlags & sheet::CellFlags::FORMULA )
3564 bAdd = true;
3565 break;
3566 case CELLTYPE_VALUE:
3567 if ( (nContentFlags & (sheet::CellFlags::VALUE|sheet::CellFlags::DATETIME))
3568 == (sheet::CellFlags::VALUE|sheet::CellFlags::DATETIME) )
3569 bAdd = true;
3570 else
3572 // Date/Time Erkennung
3574 sal_uLong nIndex = (sal_uLong)((SfxUInt32Item*)pDoc->GetAttr(
3575 aIter.GetPos(), ATTR_VALUE_FORMAT))->GetValue();
3576 short nTyp = pDoc->GetFormatTable()->GetType(nIndex);
3577 if ((nTyp == NUMBERFORMAT_DATE) || (nTyp == NUMBERFORMAT_TIME) ||
3578 (nTyp == NUMBERFORMAT_DATETIME))
3580 if ( nContentFlags & sheet::CellFlags::DATETIME )
3581 bAdd = true;
3583 else
3585 if ( nContentFlags & sheet::CellFlags::VALUE )
3586 bAdd = true;
3589 break;
3590 default:
3592 // added to avoid warnings
3596 if (bAdd)
3597 aMarkData.SetMultiMarkArea(aIter.GetPos(), true);
3602 ScRangeList aNewRanges;
3603 if (aMarkData.IsMultiMarked())
3604 aMarkData.FillRangeListWithMarks( &aNewRanges, false );
3606 return new ScCellRangesObj( pDocShell, aNewRanges ); // aNewRanges kann leer sein
3609 return NULL;
3612 uno::Reference<sheet::XSheetCellRanges> SAL_CALL ScCellRangesBase::queryFormulaCells(
3613 sal_Int32 nResultFlags )
3614 throw(uno::RuntimeException)
3616 SolarMutexGuard aGuard;
3617 if (pDocShell)
3619 ScDocument* pDoc = pDocShell->GetDocument();
3621 ScMarkData aMarkData;
3623 // passende Zellen selektieren
3624 for ( size_t i = 0, nCount = aRanges.size(); i < nCount; ++i )
3626 ScRange aRange = *aRanges[ i ];
3628 ScCellIterator aIter( pDoc, aRange );
3629 for (bool bHasCell = aIter.first(); bHasCell; bHasCell = aIter.next())
3631 if (aIter.getType() == CELLTYPE_FORMULA)
3633 ScFormulaCell* pFCell = aIter.getFormulaCell();
3634 bool bAdd = false;
3635 if (pFCell->GetErrCode())
3637 if ( nResultFlags & sheet::FormulaResult::ERROR )
3638 bAdd = true;
3640 else if (pFCell->IsValue())
3642 if ( nResultFlags & sheet::FormulaResult::VALUE )
3643 bAdd = true;
3645 else // String
3647 if ( nResultFlags & sheet::FormulaResult::STRING )
3648 bAdd = true;
3651 if (bAdd)
3652 aMarkData.SetMultiMarkArea(aIter.GetPos(), true);
3657 ScRangeList aNewRanges;
3658 if (aMarkData.IsMultiMarked())
3659 aMarkData.FillRangeListWithMarks( &aNewRanges, false );
3661 return new ScCellRangesObj( pDocShell, aNewRanges ); // aNewRanges kann leer sein
3664 return NULL;
3667 uno::Reference<sheet::XSheetCellRanges> ScCellRangesBase::QueryDifferences_Impl(
3668 const table::CellAddress& aCompare, sal_Bool bColumnDiff)
3670 if (pDocShell)
3672 size_t nRangeCount = aRanges.size();
3673 size_t i;
3674 ScDocument* pDoc = pDocShell->GetDocument();
3675 ScMarkData aMarkData;
3677 SCCOLROW nCmpPos = bColumnDiff ? (SCCOLROW)aCompare.Row : (SCCOLROW)aCompare.Column;
3679 // zuerst alles selektieren, wo ueberhaupt etwas in der Vergleichsspalte steht
3680 // (fuer gleiche Zellen wird die Selektion im zweiten Schritt aufgehoben)
3682 SCTAB nTab = lcl_FirstTab(aRanges); //! fuer alle Tabellen, wenn Markierungen pro Tabelle!
3683 ScRange aCmpRange, aCellRange;
3684 if (bColumnDiff)
3685 aCmpRange = ScRange( 0,nCmpPos,nTab, MAXCOL,nCmpPos,nTab );
3686 else
3687 aCmpRange = ScRange( static_cast<SCCOL>(nCmpPos),0,nTab, static_cast<SCCOL>(nCmpPos),MAXROW,nTab );
3688 ScCellIterator aCmpIter( pDoc, aCmpRange );
3689 for (bool bHasCell = aCmpIter.first(); bHasCell; bHasCell = aCmpIter.next())
3691 SCCOLROW nCellPos = bColumnDiff ? static_cast<SCCOLROW>(aCmpIter.GetPos().Col()) : static_cast<SCCOLROW>(aCmpIter.GetPos().Row());
3692 if (bColumnDiff)
3693 aCellRange = ScRange( static_cast<SCCOL>(nCellPos),0,nTab,
3694 static_cast<SCCOL>(nCellPos),MAXROW,nTab );
3695 else
3696 aCellRange = ScRange( 0,nCellPos,nTab, MAXCOL,nCellPos,nTab );
3698 for (i=0; i<nRangeCount; i++)
3700 ScRange aRange( *aRanges[ i ] );
3701 if ( aRange.Intersects( aCellRange ) )
3703 if (bColumnDiff)
3705 aRange.aStart.SetCol(static_cast<SCCOL>(nCellPos));
3706 aRange.aEnd.SetCol(static_cast<SCCOL>(nCellPos));
3708 else
3710 aRange.aStart.SetRow(nCellPos);
3711 aRange.aEnd.SetRow(nCellPos);
3713 aMarkData.SetMultiMarkArea( aRange );
3718 // alle nichtleeren Zellen mit der Vergleichsspalte vergleichen und entsprechend
3719 // selektieren oder aufheben
3721 ScAddress aCmpAddr;
3722 for (i=0; i<nRangeCount; i++)
3724 ScRange aRange( *aRanges[ i ] );
3726 ScCellIterator aIter( pDoc, aRange );
3727 for (bool bHasCell = aIter.first(); bHasCell; bHasCell = aIter.next())
3729 if (bColumnDiff)
3730 aCmpAddr = ScAddress( aIter.GetPos().Col(), nCmpPos, aIter.GetPos().Tab() );
3731 else
3732 aCmpAddr = ScAddress( static_cast<SCCOL>(nCmpPos), aIter.GetPos().Row(), aIter.GetPos().Tab() );
3734 ScRange aOneRange(aIter.GetPos());
3735 if (!aIter.equalsWithoutFormat(aCmpAddr))
3736 aMarkData.SetMultiMarkArea( aOneRange );
3737 else
3738 aMarkData.SetMultiMarkArea( aOneRange, false ); // deselect
3742 ScRangeList aNewRanges;
3743 if (aMarkData.IsMultiMarked())
3744 aMarkData.FillRangeListWithMarks( &aNewRanges, false );
3746 return new ScCellRangesObj( pDocShell, aNewRanges ); // aNewRanges kann leer sein
3748 return NULL;
3751 uno::Reference<sheet::XSheetCellRanges > SAL_CALL ScCellRangesBase::queryColumnDifferences(
3752 const table::CellAddress& aCompare ) throw(uno::RuntimeException)
3754 SolarMutexGuard aGuard;
3755 return QueryDifferences_Impl( aCompare, true );
3758 uno::Reference<sheet::XSheetCellRanges> SAL_CALL ScCellRangesBase::queryRowDifferences(
3759 const table::CellAddress& aCompare ) throw(uno::RuntimeException)
3761 SolarMutexGuard aGuard;
3762 return QueryDifferences_Impl( aCompare, false );
3765 uno::Reference<sheet::XSheetCellRanges> SAL_CALL ScCellRangesBase::queryIntersection(
3766 const table::CellRangeAddress& aRange ) throw(uno::RuntimeException)
3768 SolarMutexGuard aGuard;
3769 ScRange aMask( (SCCOL)aRange.StartColumn, (SCROW)aRange.StartRow, aRange.Sheet,
3770 (SCCOL)aRange.EndColumn, (SCROW)aRange.EndRow, aRange.Sheet );
3772 ScRangeList aNew;
3773 for ( size_t i = 0, nCount = aRanges.size(); i < nCount; ++i )
3775 ScRange aTemp( *aRanges[ i ] );
3776 if ( aTemp.Intersects( aMask ) )
3777 aNew.Join( ScRange( std::max( aTemp.aStart.Col(), aMask.aStart.Col() ),
3778 std::max( aTemp.aStart.Row(), aMask.aStart.Row() ),
3779 std::max( aTemp.aStart.Tab(), aMask.aStart.Tab() ),
3780 std::min( aTemp.aEnd.Col(), aMask.aEnd.Col() ),
3781 std::min( aTemp.aEnd.Row(), aMask.aEnd.Row() ),
3782 std::min( aTemp.aEnd.Tab(), aMask.aEnd.Tab() ) ) );
3785 return new ScCellRangesObj( pDocShell, aNew ); // kann leer sein
3788 // XFormulaQuery
3790 uno::Reference<sheet::XSheetCellRanges> SAL_CALL ScCellRangesBase::queryPrecedents(
3791 sal_Bool bRecursive ) throw(uno::RuntimeException)
3793 SolarMutexGuard aGuard;
3794 if ( pDocShell )
3796 ScDocument* pDoc = pDocShell->GetDocument();
3798 ScRangeList aNewRanges(aRanges);
3799 sal_Bool bFound;
3802 bFound = false;
3804 // aMarkData uses aNewRanges, not aRanges, so GetMarkData can't be used
3805 ScMarkData aMarkData;
3806 aMarkData.MarkFromRangeList( aNewRanges, false );
3807 aMarkData.MarkToMulti(); // needed for IsAllMarked
3809 for (size_t nR = 0, nCount = aNewRanges.size(); nR<nCount; ++nR)
3811 ScRange aRange( *aNewRanges[ nR] );
3812 ScCellIterator aIter( pDoc, aRange );
3813 for (bool bHasCell = aIter.first(); bHasCell; bHasCell = aIter.next())
3815 if (aIter.getType() != CELLTYPE_FORMULA)
3816 continue;
3818 ScDetectiveRefIter aRefIter(aIter.getFormulaCell());
3819 ScRange aRefRange;
3820 while ( aRefIter.GetNextRef( aRefRange) )
3822 if ( bRecursive && !bFound && !aMarkData.IsAllMarked( aRefRange ) )
3823 bFound = true;
3824 aMarkData.SetMultiMarkArea(aRefRange, true);
3829 aMarkData.FillRangeListWithMarks( &aNewRanges, sal_True );
3831 while ( bRecursive && bFound );
3833 return new ScCellRangesObj( pDocShell, aNewRanges );
3836 return NULL;
3839 uno::Reference<sheet::XSheetCellRanges> SAL_CALL ScCellRangesBase::queryDependents(
3840 sal_Bool bRecursive ) throw(uno::RuntimeException)
3842 SolarMutexGuard aGuard;
3843 if ( pDocShell )
3845 ScDocument* pDoc = pDocShell->GetDocument();
3847 ScRangeList aNewRanges(aRanges);
3848 sal_Bool bFound;
3851 bFound = false;
3853 // aMarkData uses aNewRanges, not aRanges, so GetMarkData can't be used
3854 ScMarkData aMarkData;
3855 aMarkData.MarkFromRangeList( aNewRanges, false );
3856 aMarkData.MarkToMulti(); // needed for IsAllMarked
3858 SCTAB nTab = lcl_FirstTab(aNewRanges); //! alle Tabellen
3860 ScCellIterator aCellIter( pDoc, ScRange(0, 0, nTab, MAXCOL, MAXROW, nTab) );
3861 for (bool bHasCell = aCellIter.first(); bHasCell; bHasCell = aCellIter.next())
3863 if (aCellIter.getType() != CELLTYPE_FORMULA)
3864 continue;
3866 bool bMark = false;
3867 ScDetectiveRefIter aIter(aCellIter.getFormulaCell());
3868 ScRange aRefRange;
3869 while ( aIter.GetNextRef( aRefRange) )
3871 size_t nRangesCount = aNewRanges.size();
3872 for (size_t nR = 0; nR < nRangesCount; ++nR)
3874 ScRange aRange( *aNewRanges[ nR ] );
3875 if (aRange.Intersects(aRefRange))
3876 bMark = sal_True; // von Teil des Ranges abhaengig
3879 if (bMark)
3881 ScRange aCellRange(aCellIter.GetPos());
3882 if ( bRecursive && !bFound && !aMarkData.IsAllMarked( aCellRange ) )
3883 bFound = true;
3884 aMarkData.SetMultiMarkArea(aCellRange, true);
3888 aMarkData.FillRangeListWithMarks( &aNewRanges, sal_True );
3890 while ( bRecursive && bFound );
3892 return new ScCellRangesObj( pDocShell, aNewRanges );
3895 return NULL;
3898 // XSearchable
3900 uno::Reference<util::XSearchDescriptor> SAL_CALL ScCellRangesBase::createSearchDescriptor()
3901 throw(uno::RuntimeException)
3903 SolarMutexGuard aGuard;
3904 return new ScCellSearchObj;
3907 uno::Reference<container::XIndexAccess> SAL_CALL ScCellRangesBase::findAll(
3908 const uno::Reference<util::XSearchDescriptor>& xDesc )
3909 throw(uno::RuntimeException)
3911 SolarMutexGuard aGuard;
3912 // Wenn nichts gefunden wird, soll Null zurueckgegeben werden (?)
3913 uno::Reference<container::XIndexAccess> xRet;
3914 if ( pDocShell && xDesc.is() )
3916 ScCellSearchObj* pSearch = ScCellSearchObj::getImplementation( xDesc );
3917 if (pSearch)
3919 SvxSearchItem* pSearchItem = pSearch->GetSearchItem();
3920 if (pSearchItem)
3922 ScDocument* pDoc = pDocShell->GetDocument();
3923 pSearchItem->SetCommand( SVX_SEARCHCMD_FIND_ALL );
3924 // immer nur innerhalb dieses Objekts
3925 pSearchItem->SetSelection( !lcl_WholeSheet(aRanges) );
3927 ScMarkData aMark(*GetMarkData());
3929 OUString aDummyUndo;
3930 ScRangeList aMatchedRanges;
3931 SCCOL nCol = 0;
3932 SCROW nRow = 0;
3933 SCTAB nTab = 0;
3934 bool bFound = pDoc->SearchAndReplace(
3935 *pSearchItem, nCol, nRow, nTab, aMark, aMatchedRanges, aDummyUndo, NULL);
3936 if (bFound)
3938 // bei findAll immer CellRanges, egal wieviel gefunden wurde
3939 xRet.set(new ScCellRangesObj( pDocShell, aMatchedRanges ));
3944 return xRet;
3947 uno::Reference<uno::XInterface> ScCellRangesBase::Find_Impl(
3948 const uno::Reference<util::XSearchDescriptor>& xDesc,
3949 const ScAddress* pLastPos )
3951 uno::Reference<uno::XInterface> xRet;
3952 if ( pDocShell && xDesc.is() )
3954 ScCellSearchObj* pSearch = ScCellSearchObj::getImplementation( xDesc );
3955 if (pSearch)
3957 SvxSearchItem* pSearchItem = pSearch->GetSearchItem();
3958 if (pSearchItem)
3960 ScDocument* pDoc = pDocShell->GetDocument();
3961 pSearchItem->SetCommand( SVX_SEARCHCMD_FIND );
3962 // immer nur innerhalb dieses Objekts
3963 pSearchItem->SetSelection( !lcl_WholeSheet(aRanges) );
3965 ScMarkData aMark(*GetMarkData());
3967 SCCOL nCol;
3968 SCROW nRow;
3969 SCTAB nTab;
3970 if (pLastPos)
3971 pLastPos->GetVars( nCol, nRow, nTab );
3972 else
3974 nTab = lcl_FirstTab(aRanges); //! mehrere Tabellen?
3975 ScDocument::GetSearchAndReplaceStart( *pSearchItem, nCol, nRow );
3978 OUString aDummyUndo;
3979 ScRangeList aMatchedRanges;
3980 bool bFound = pDoc->SearchAndReplace(
3981 *pSearchItem, nCol, nRow, nTab, aMark, aMatchedRanges, aDummyUndo, NULL);
3982 if (bFound)
3984 ScAddress aFoundPos( nCol, nRow, nTab );
3985 xRet.set((cppu::OWeakObject*) new ScCellObj( pDocShell, aFoundPos ));
3990 return xRet;
3993 uno::Reference<uno::XInterface> SAL_CALL ScCellRangesBase::findFirst(
3994 const uno::Reference<util::XSearchDescriptor>& xDesc )
3995 throw(uno::RuntimeException)
3997 SolarMutexGuard aGuard;
3998 return Find_Impl( xDesc, NULL );
4001 uno::Reference<uno::XInterface> SAL_CALL ScCellRangesBase::findNext(
4002 const uno::Reference<uno::XInterface>& xStartAt,
4003 const uno::Reference<util::XSearchDescriptor >& xDesc )
4004 throw(uno::RuntimeException)
4006 SolarMutexGuard aGuard;
4007 if ( xStartAt.is() )
4009 ScCellRangesBase* pRangesImp = ScCellRangesBase::getImplementation( xStartAt );
4010 if ( pRangesImp && pRangesImp->GetDocShell() == pDocShell )
4012 const ScRangeList& rStartRanges = pRangesImp->GetRangeList();
4013 if ( rStartRanges.size() == 1 )
4015 ScAddress aStartPos = rStartRanges[ 0 ]->aStart;
4016 return Find_Impl( xDesc, &aStartPos );
4020 return NULL;
4023 // XReplaceable
4025 uno::Reference<util::XReplaceDescriptor> SAL_CALL ScCellRangesBase::createReplaceDescriptor()
4026 throw(uno::RuntimeException)
4028 SolarMutexGuard aGuard;
4029 return new ScCellSearchObj;
4032 sal_Int32 SAL_CALL ScCellRangesBase::replaceAll( const uno::Reference<util::XSearchDescriptor>& xDesc )
4033 throw(uno::RuntimeException)
4035 SolarMutexGuard aGuard;
4036 sal_Int32 nReplaced = 0;
4037 if ( pDocShell && xDesc.is() )
4039 ScCellSearchObj* pSearch = ScCellSearchObj::getImplementation( xDesc );
4040 if (pSearch)
4042 SvxSearchItem* pSearchItem = pSearch->GetSearchItem();
4043 if (pSearchItem)
4045 ScDocument* pDoc = pDocShell->GetDocument();
4046 sal_Bool bUndo(pDoc->IsUndoEnabled());
4047 pSearchItem->SetCommand( SVX_SEARCHCMD_REPLACE_ALL );
4048 // immer nur innerhalb dieses Objekts
4049 pSearchItem->SetSelection( !lcl_WholeSheet(aRanges) );
4051 ScMarkData aMark(*GetMarkData());
4053 SCTAB nTabCount = pDoc->GetTableCount();
4054 bool bProtected = !pDocShell->IsEditable();
4055 ScMarkData::iterator itr = aMark.begin(), itrEnd = aMark.end();
4056 for (; itr != itrEnd && *itr < nTabCount; ++itr)
4057 if ( pDoc->IsTabProtected(*itr) )
4058 bProtected = true;
4059 if (bProtected)
4061 //! Exception, oder was?
4063 else
4065 SCTAB nTab = aMark.GetFirstSelected(); // bei SearchAndReplace nicht benutzt
4066 SCCOL nCol = 0;
4067 SCROW nRow = 0;
4069 OUString aUndoStr;
4070 ScDocument* pUndoDoc = NULL;
4071 if (bUndo)
4073 pUndoDoc = new ScDocument( SCDOCMODE_UNDO );
4074 pUndoDoc->InitUndo( pDoc, nTab, nTab );
4076 itr = aMark.begin();
4077 for (; itr != itrEnd && *itr < nTabCount; ++itr)
4078 if ( *itr != nTab && bUndo)
4079 pUndoDoc->AddUndoTab( *itr, *itr );
4080 boost::scoped_ptr<ScMarkData> pUndoMark;
4081 if (bUndo)
4082 pUndoMark.reset(new ScMarkData(aMark));
4084 bool bFound = false;
4085 if (bUndo)
4087 ScRangeList aMatchedRanges;
4088 bFound = pDoc->SearchAndReplace(
4089 *pSearchItem, nCol, nRow, nTab, aMark, aMatchedRanges, aUndoStr, pUndoDoc );
4091 if (bFound)
4093 nReplaced = pUndoDoc->GetCellCount();
4095 pDocShell->GetUndoManager()->AddUndoAction(
4096 new ScUndoReplace( pDocShell, *pUndoMark, nCol, nRow, nTab,
4097 aUndoStr, pUndoDoc, pSearchItem ) );
4099 pDocShell->PostPaintGridAll();
4100 pDocShell->SetDocumentModified();
4102 else
4104 delete pUndoDoc;
4105 // nReplaced bleibt 0
4111 return nReplaced;
4114 // XUnoTunnel
4116 sal_Int64 SAL_CALL ScCellRangesBase::getSomething(
4117 const uno::Sequence<sal_Int8 >& rId ) throw(uno::RuntimeException)
4119 if ( rId.getLength() == 16 &&
4120 0 == memcmp( getUnoTunnelId().getConstArray(),
4121 rId.getConstArray(), 16 ) )
4123 return sal::static_int_cast<sal_Int64>(reinterpret_cast<sal_IntPtr>(this));
4125 return 0;
4128 namespace
4130 class theScCellRangesBaseUnoTunnelId : public rtl::Static< UnoTunnelIdInit, theScCellRangesBaseUnoTunnelId> {};
4133 const uno::Sequence<sal_Int8>& ScCellRangesBase::getUnoTunnelId()
4135 return theScCellRangesBaseUnoTunnelId::get().getSeq();
4138 ScCellRangesBase* ScCellRangesBase::getImplementation( const uno::Reference<uno::XInterface> xObj )
4140 ScCellRangesBase* pRet = NULL;
4141 uno::Reference<lang::XUnoTunnel> xUT( xObj, uno::UNO_QUERY );
4142 if (xUT.is())
4143 pRet = reinterpret_cast<ScCellRangesBase*>(sal::static_int_cast<sal_IntPtr>(xUT->getSomething(getUnoTunnelId())));
4144 return pRet;
4147 //------------------------------------------------------------------------
4149 typedef boost::ptr_vector<ScNamedEntry> ScNamedEntryArr_Impl;
4151 struct ScCellRangesObj::Impl
4153 ScNamedEntryArr_Impl m_aNamedEntries;
4156 ScCellRangesObj::ScCellRangesObj(ScDocShell* pDocSh, const ScRangeList& rR)
4157 : ScCellRangesBase(pDocSh, rR)
4158 , m_pImpl(new Impl)
4162 ScCellRangesObj::~ScCellRangesObj()
4166 void ScCellRangesObj::RefChanged()
4168 ScCellRangesBase::RefChanged();
4170 // nix weiter...
4173 uno::Any SAL_CALL ScCellRangesObj::queryInterface( const uno::Type& rType )
4174 throw(uno::RuntimeException)
4176 SC_QUERYINTERFACE( sheet::XSheetCellRangeContainer )
4177 SC_QUERYINTERFACE( sheet::XSheetCellRanges )
4178 SC_QUERYINTERFACE( container::XIndexAccess )
4179 SC_QUERY_MULTIPLE( container::XElementAccess, container::XIndexAccess )
4180 SC_QUERYINTERFACE( container::XEnumerationAccess )
4181 SC_QUERYINTERFACE( container::XNameContainer )
4182 SC_QUERYINTERFACE( container::XNameReplace )
4183 SC_QUERYINTERFACE( container::XNameAccess )
4185 return ScCellRangesBase::queryInterface( rType );
4188 void SAL_CALL ScCellRangesObj::acquire() throw()
4190 ScCellRangesBase::acquire();
4193 void SAL_CALL ScCellRangesObj::release() throw()
4195 ScCellRangesBase::release();
4198 uno::Sequence<uno::Type> SAL_CALL ScCellRangesObj::getTypes() throw(uno::RuntimeException)
4200 static uno::Sequence<uno::Type> aTypes;
4201 if ( aTypes.getLength() == 0 )
4203 uno::Sequence<uno::Type> aParentTypes(ScCellRangesBase::getTypes());
4204 long nParentLen = aParentTypes.getLength();
4205 const uno::Type* pParentPtr = aParentTypes.getConstArray();
4207 aTypes.realloc( nParentLen + 3 );
4208 uno::Type* pPtr = aTypes.getArray();
4209 pPtr[nParentLen + 0] = getCppuType((const uno::Reference<sheet::XSheetCellRangeContainer>*)0);
4210 pPtr[nParentLen + 1] = getCppuType((const uno::Reference<container::XNameContainer>*)0);
4211 pPtr[nParentLen + 2] = getCppuType((const uno::Reference<container::XEnumerationAccess>*)0);
4213 for (long i=0; i<nParentLen; i++)
4214 pPtr[i] = pParentPtr[i]; // parent types first
4216 return aTypes;
4219 namespace
4221 class theScCellRangesObjImplementationId : public rtl::Static< UnoTunnelIdInit, theScCellRangesObjImplementationId > {};
4224 uno::Sequence<sal_Int8> SAL_CALL ScCellRangesObj::getImplementationId()
4225 throw(uno::RuntimeException)
4227 return theScCellRangesObjImplementationId::get().getSeq();
4230 // XCellRanges
4232 ScCellRangeObj* ScCellRangesObj::GetObjectByIndex_Impl(sal_Int32 nIndex) const
4234 ScDocShell* pDocSh = GetDocShell();
4235 const ScRangeList& rRanges = GetRangeList();
4236 if ( pDocSh && nIndex >= 0 && nIndex < sal::static_int_cast<sal_Int32>(rRanges.size()) )
4238 ScRange aRange( *rRanges[ nIndex ] );
4239 if ( aRange.aStart == aRange.aEnd )
4240 return new ScCellObj( pDocSh, aRange.aStart );
4241 else
4242 return new ScCellRangeObj( pDocSh, aRange );
4245 return NULL; // keine DocShell oder falscher Index
4248 uno::Sequence<table::CellRangeAddress> SAL_CALL ScCellRangesObj::getRangeAddresses()
4249 throw(uno::RuntimeException)
4251 SolarMutexGuard aGuard;
4252 ScDocShell* pDocSh = GetDocShell();
4253 const ScRangeList& rRanges = GetRangeList();
4254 size_t nCount = rRanges.size();
4255 if ( pDocSh && nCount )
4257 table::CellRangeAddress aRangeAddress;
4258 uno::Sequence<table::CellRangeAddress> aSeq(nCount);
4259 table::CellRangeAddress* pAry = aSeq.getArray();
4260 for ( size_t i=0; i < nCount; i++)
4262 ScUnoConversion::FillApiRange( aRangeAddress, *rRanges[ i ] );
4263 pAry[i] = aRangeAddress;
4265 return aSeq;
4268 return uno::Sequence<table::CellRangeAddress>(0); // leer ist moeglich
4271 uno::Reference<container::XEnumerationAccess> SAL_CALL ScCellRangesObj::getCells()
4272 throw(uno::RuntimeException)
4274 SolarMutexGuard aGuard;
4276 // getCells with empty range list is possible (no exception),
4277 // the resulting enumeration just has no elements
4278 // (same behaviour as a valid range with no cells)
4279 // This is handled in ScCellsEnumeration ctor.
4281 const ScRangeList& rRanges = GetRangeList();
4282 ScDocShell* pDocSh = GetDocShell();
4283 if (pDocSh)
4284 return new ScCellsObj( pDocSh, rRanges );
4285 return NULL;
4288 OUString SAL_CALL ScCellRangesObj::getRangeAddressesAsString()
4289 throw(uno::RuntimeException)
4291 SolarMutexGuard aGuard;
4292 OUString aString;
4293 ScDocShell* pDocSh = GetDocShell();
4294 const ScRangeList& rRanges = GetRangeList();
4295 if (pDocSh)
4296 rRanges.Format( aString, SCA_VALID | SCA_TAB_3D, pDocSh->GetDocument() );
4297 return aString;
4300 // XSheetCellRangeContainer
4302 void SAL_CALL ScCellRangesObj::addRangeAddress( const table::CellRangeAddress& rRange,
4303 sal_Bool bMergeRanges )
4304 throw(::com::sun::star::uno::RuntimeException)
4306 SolarMutexGuard aGuard;
4307 ScRange aRange(static_cast<SCCOL>(rRange.StartColumn),
4308 static_cast<SCROW>(rRange.StartRow),
4309 static_cast<SCTAB>(rRange.Sheet),
4310 static_cast<SCCOL>(rRange.EndColumn),
4311 static_cast<SCROW>(rRange.EndRow),
4312 static_cast<SCTAB>(rRange.Sheet));
4313 AddRange(aRange, bMergeRanges);
4316 static void lcl_RemoveNamedEntry( ScNamedEntryArr_Impl& rNamedEntries, const ScRange& rRange )
4318 sal_uInt16 nCount = rNamedEntries.size();
4319 for ( sal_uInt16 n=nCount; n--; )
4320 if ( rNamedEntries[n].GetRange() == rRange )
4321 rNamedEntries.erase( rNamedEntries.begin() + n );
4324 void SAL_CALL ScCellRangesObj::removeRangeAddress( const table::CellRangeAddress& rRange )
4325 throw(::com::sun::star::container::NoSuchElementException,
4326 ::com::sun::star::uno::RuntimeException)
4328 SolarMutexGuard aGuard;
4329 const ScRangeList& rRanges = GetRangeList();
4331 ScRangeList aSheetRanges;
4332 ScRangeList aNotSheetRanges;
4333 for (size_t i = 0; i < rRanges.size(); ++i)
4335 if (rRanges[ i]->aStart.Tab() == rRange.Sheet)
4337 aSheetRanges.Append( *rRanges[ i ] );
4339 else
4341 aNotSheetRanges.Append( *rRanges[ i ] );
4344 ScMarkData aMarkData;
4345 aMarkData.MarkFromRangeList( aSheetRanges, false );
4346 ScRange aRange(static_cast<SCCOL>(rRange.StartColumn),
4347 static_cast<SCROW>(rRange.StartRow),
4348 static_cast<SCTAB>(rRange.Sheet),
4349 static_cast<SCCOL>(rRange.EndColumn),
4350 static_cast<SCROW>(rRange.EndRow),
4351 static_cast<SCTAB>(rRange.Sheet));
4352 if (aMarkData.GetTableSelect( aRange.aStart.Tab() ))
4354 aMarkData.MarkToMulti();
4355 if (aMarkData.IsAllMarked( aRange ) )
4357 aMarkData.SetMultiMarkArea( aRange, false );
4358 lcl_RemoveNamedEntry(m_pImpl->m_aNamedEntries, aRange);
4360 else
4361 throw container::NoSuchElementException();
4363 SetNewRanges(aNotSheetRanges);
4364 ScRangeList aNew;
4365 aMarkData.FillRangeListWithMarks( &aNew, false );
4366 for ( size_t j = 0; j < aNew.size(); ++j)
4368 AddRange(*aNew[ j ], false);
4372 void SAL_CALL ScCellRangesObj::addRangeAddresses( const uno::Sequence<table::CellRangeAddress >& rRanges,
4373 sal_Bool bMergeRanges )
4374 throw(::com::sun::star::uno::RuntimeException)
4376 SolarMutexGuard aGuard;
4377 sal_Int32 nCount(rRanges.getLength());
4378 if (nCount)
4380 const table::CellRangeAddress* pRanges = rRanges.getConstArray();
4381 for (sal_Int32 i = 0; i < rRanges.getLength(); i++, pRanges++)
4383 ScRange aRange(static_cast<SCCOL>(pRanges->StartColumn),
4384 static_cast<SCROW>(pRanges->StartRow),
4385 static_cast<SCTAB>(pRanges->Sheet),
4386 static_cast<SCCOL>(pRanges->EndColumn),
4387 static_cast<SCROW>(pRanges->EndRow),
4388 static_cast<SCTAB>(pRanges->Sheet));
4389 AddRange(aRange, bMergeRanges);
4394 void SAL_CALL ScCellRangesObj::removeRangeAddresses( const uno::Sequence<table::CellRangeAddress >& rRangeSeq )
4395 throw(::com::sun::star::container::NoSuchElementException,
4396 ::com::sun::star::uno::RuntimeException)
4398 // use sometimes a better/faster implementation
4399 sal_uInt32 nCount(rRangeSeq.getLength());
4400 if (nCount)
4402 const table::CellRangeAddress* pRanges = rRangeSeq.getConstArray();
4403 for (sal_uInt32 i=0; i < nCount; ++i, ++pRanges)
4405 removeRangeAddress(*pRanges);
4410 // XNameContainer
4412 static void lcl_RemoveNamedEntry( ScNamedEntryArr_Impl& rNamedEntries, const OUString& rName )
4414 sal_uInt16 nCount = rNamedEntries.size();
4415 for ( sal_uInt16 n=nCount; n--; )
4416 if ( rNamedEntries[n].GetName() == rName )
4417 rNamedEntries.erase( rNamedEntries.begin() + n );
4420 void SAL_CALL ScCellRangesObj::insertByName( const OUString& aName, const uno::Any& aElement )
4421 throw(lang::IllegalArgumentException, container::ElementExistException,
4422 lang::WrappedTargetException, uno::RuntimeException)
4424 SolarMutexGuard aGuard;
4425 ScDocShell* pDocSh = GetDocShell();
4426 sal_Bool bDone = false;
4428 //! Type of aElement can be some specific interface instead of XInterface
4430 uno::Reference<uno::XInterface> xInterface(aElement, uno::UNO_QUERY);
4431 if ( pDocSh && xInterface.is() )
4433 ScCellRangesBase* pRangesImp = ScCellRangesBase::getImplementation( xInterface );
4434 if ( pRangesImp && pRangesImp->GetDocShell() == pDocSh )
4436 // if explicit name is given and already existing, throw exception
4438 OUString aNamStr(aName);
4439 if ( !aNamStr.isEmpty() )
4441 size_t nNamedCount = m_pImpl->m_aNamedEntries.size();
4442 for (size_t n = 0; n < nNamedCount; n++)
4444 if (m_pImpl->m_aNamedEntries[n].GetName() == aNamStr)
4445 throw container::ElementExistException();
4449 ScRangeList aNew(GetRangeList());
4450 const ScRangeList& rAddRanges = pRangesImp->GetRangeList();
4451 size_t nAddCount = rAddRanges.size();
4452 for ( size_t i = 0; i < nAddCount; i++ )
4453 aNew.Join( *rAddRanges[ i ] );
4454 SetNewRanges(aNew);
4455 bDone = sal_True;
4457 if ( !aName.isEmpty() && nAddCount == 1 )
4459 // if a name is given, also insert into list of named entries
4460 // (only possible for a single range)
4461 // name is not in m_pImpl->m_aNamedEntries (tested above)
4463 ScNamedEntry* pEntry = new ScNamedEntry( aNamStr, *rAddRanges[ 0 ] );
4464 m_pImpl->m_aNamedEntries.push_back(pEntry);
4469 if (!bDone)
4471 // invalid element - double names are handled above
4472 throw lang::IllegalArgumentException();
4476 static sal_Bool lcl_FindRangeByName( const ScRangeList& rRanges, ScDocShell* pDocSh,
4477 const OUString& rName, size_t& rIndex )
4479 if (pDocSh)
4481 OUString aRangeStr;
4482 ScDocument* pDoc = pDocSh->GetDocument();
4483 for ( size_t i = 0, nCount = rRanges.size(); i < nCount; i++ )
4485 aRangeStr = rRanges[ i ]->Format(SCA_VALID | SCA_TAB_3D, pDoc);
4486 if ( aRangeStr == rName )
4488 rIndex = i;
4489 return sal_True;
4493 return false; // nicht gefunden
4496 static sal_Bool lcl_FindRangeOrEntry( const ScNamedEntryArr_Impl& rNamedEntries,
4497 const ScRangeList& rRanges, ScDocShell* pDocSh,
4498 const OUString& rName, ScRange& rFound )
4500 // exact range in list?
4502 size_t nIndex = 0;
4503 if ( lcl_FindRangeByName( rRanges, pDocSh, rName, nIndex ) )
4505 rFound = *rRanges[ nIndex ];
4506 return true;
4509 // range contained in selection? (sheet must be specified)
4511 ScRange aCellRange;
4512 sal_uInt16 nParse = aCellRange.ParseAny( rName, pDocSh->GetDocument() );
4513 if ( ( nParse & ( SCA_VALID | SCA_TAB_3D ) ) == ( SCA_VALID | SCA_TAB_3D ) )
4515 ScMarkData aMarkData;
4516 aMarkData.MarkFromRangeList( rRanges, false );
4517 aMarkData.MarkToMulti(); // needed for IsAllMarked
4518 if ( aMarkData.IsAllMarked( aCellRange ) )
4520 rFound = aCellRange;
4521 return sal_True;
4525 // named entry in this object?
4527 if ( !rNamedEntries.empty() )
4529 for ( sal_uInt16 n=0; n<rNamedEntries.size(); n++ )
4530 if ( rNamedEntries[n].GetName() == rName )
4532 // test if named entry is contained in rRanges
4534 const ScRange& rComp = rNamedEntries[n].GetRange();
4535 ScMarkData aMarkData;
4536 aMarkData.MarkFromRangeList( rRanges, false );
4537 aMarkData.MarkToMulti(); // needed for IsAllMarked
4538 if ( aMarkData.IsAllMarked( rComp ) )
4540 rFound = rComp;
4541 return sal_True;
4546 return false; // not found
4549 void SAL_CALL ScCellRangesObj::removeByName( const OUString& aName )
4550 throw(container::NoSuchElementException,
4551 lang::WrappedTargetException, uno::RuntimeException)
4553 SolarMutexGuard aGuard;
4554 sal_Bool bDone = false;
4555 OUString aNameStr(aName);
4556 ScDocShell* pDocSh = GetDocShell();
4557 const ScRangeList& rRanges = GetRangeList();
4558 size_t nIndex = 0;
4559 if ( lcl_FindRangeByName( rRanges, pDocSh, aNameStr, nIndex ) )
4561 // einzelnen Range weglassen
4562 ScRangeList aNew;
4563 for ( size_t i = 0, nCount = rRanges.size(); i < nCount; i++ )
4564 if (i != nIndex)
4565 aNew.Append( *rRanges[ i ] );
4566 SetNewRanges(aNew);
4567 bDone = sal_True;
4569 else if (pDocSh)
4571 // deselect any ranges (parsed or named entry)
4572 ScRangeList aDiff;
4573 sal_Bool bValid = ( aDiff.Parse( aNameStr, pDocSh->GetDocument() ) & SCA_VALID ) != 0;
4574 if (!bValid && !m_pImpl->m_aNamedEntries.empty())
4576 sal_uInt16 nCount = m_pImpl->m_aNamedEntries.size();
4577 for (sal_uInt16 n=0; n<nCount && !bValid; n++)
4578 if (m_pImpl->m_aNamedEntries[n].GetName() == aNameStr)
4580 aDiff.RemoveAll();
4581 aDiff.Append(m_pImpl->m_aNamedEntries[n].GetRange());
4582 bValid = sal_True;
4585 if ( bValid )
4587 ScMarkData aMarkData;
4588 aMarkData.MarkFromRangeList( rRanges, false );
4590 for ( size_t i = 0, nDiffCount = aDiff.size(); i < nDiffCount; i++ )
4592 ScRange* pDiffRange = aDiff[ i ];
4593 if (aMarkData.GetTableSelect( pDiffRange->aStart.Tab() ))
4594 aMarkData.SetMultiMarkArea( *pDiffRange, false );
4597 ScRangeList aNew;
4598 aMarkData.FillRangeListWithMarks( &aNew, false );
4599 SetNewRanges(aNew);
4601 bDone = sal_True; //! error if range was not selected before?
4605 if (!m_pImpl->m_aNamedEntries.empty())
4606 lcl_RemoveNamedEntry(m_pImpl->m_aNamedEntries, aNameStr);
4608 if (!bDone)
4609 throw container::NoSuchElementException(); // not found
4612 // XNameReplace
4614 void SAL_CALL ScCellRangesObj::replaceByName( const OUString& aName, const uno::Any& aElement )
4615 throw(lang::IllegalArgumentException, container::NoSuchElementException,
4616 lang::WrappedTargetException, uno::RuntimeException)
4618 SolarMutexGuard aGuard;
4619 //! zusammenfassen?
4620 removeByName( aName );
4621 insertByName( aName, aElement );
4624 // XNameAccess
4626 uno::Any SAL_CALL ScCellRangesObj::getByName( const OUString& aName )
4627 throw(container::NoSuchElementException,
4628 lang::WrappedTargetException, uno::RuntimeException)
4630 SolarMutexGuard aGuard;
4631 uno::Any aRet;
4633 OUString aNameStr(aName);
4634 ScDocShell* pDocSh = GetDocShell();
4635 const ScRangeList& rRanges = GetRangeList();
4636 ScRange aRange;
4637 if (lcl_FindRangeOrEntry(m_pImpl->m_aNamedEntries, rRanges,
4638 pDocSh, aNameStr, aRange))
4640 uno::Reference<table::XCellRange> xRange;
4641 if ( aRange.aStart == aRange.aEnd )
4642 xRange.set(new ScCellObj( pDocSh, aRange.aStart ));
4643 else
4644 xRange.set(new ScCellRangeObj( pDocSh, aRange ));
4645 aRet <<= xRange;
4647 else
4648 throw container::NoSuchElementException();
4649 return aRet;
4652 static sal_Bool lcl_FindEntryName( const ScNamedEntryArr_Impl& rNamedEntries,
4653 const ScRange& rRange, OUString& rName )
4655 sal_uInt16 nCount = rNamedEntries.size();
4656 for (sal_uInt16 i=0; i<nCount; i++)
4657 if (rNamedEntries[i].GetRange() == rRange)
4659 rName = rNamedEntries[i].GetName();
4660 return sal_True;
4662 return false;
4665 uno::Sequence<OUString> SAL_CALL ScCellRangesObj::getElementNames()
4666 throw(uno::RuntimeException)
4668 SolarMutexGuard aGuard;
4670 ScDocShell* pDocSh = GetDocShell();
4671 const ScRangeList& rRanges = GetRangeList();
4672 if (pDocSh)
4674 OUString aRangeStr;
4675 ScDocument* pDoc = pDocSh->GetDocument();
4676 size_t nCount = rRanges.size();
4678 uno::Sequence<OUString> aSeq(nCount);
4679 OUString* pAry = aSeq.getArray();
4680 for (size_t i=0; i < nCount; i++)
4682 // use given name if for exactly this range, otherwise just format
4683 ScRange aRange = *rRanges[ i ];
4684 if (m_pImpl->m_aNamedEntries.empty() ||
4685 !lcl_FindEntryName(m_pImpl->m_aNamedEntries, aRange, aRangeStr))
4687 aRangeStr = aRange.Format(SCA_VALID | SCA_TAB_3D, pDoc);
4689 pAry[i] = aRangeStr;
4691 return aSeq;
4693 return uno::Sequence<OUString>(0);
4696 sal_Bool SAL_CALL ScCellRangesObj::hasByName( const OUString& aName )
4697 throw(uno::RuntimeException)
4699 SolarMutexGuard aGuard;
4700 OUString aNameStr(aName);
4701 ScDocShell* pDocSh = GetDocShell();
4702 const ScRangeList& rRanges = GetRangeList();
4703 ScRange aRange;
4704 return lcl_FindRangeOrEntry(m_pImpl->m_aNamedEntries, rRanges, pDocSh,
4705 aNameStr, aRange);
4708 // XEnumerationAccess
4710 uno::Reference<container::XEnumeration> SAL_CALL ScCellRangesObj::createEnumeration()
4711 throw(uno::RuntimeException)
4713 SolarMutexGuard aGuard;
4714 return new ScIndexEnumeration(this, OUString("com.sun.star.sheet.SheetCellRangesEnumeration"));
4717 // XIndexAccess
4719 sal_Int32 SAL_CALL ScCellRangesObj::getCount() throw(uno::RuntimeException)
4721 SolarMutexGuard aGuard;
4722 const ScRangeList& rRanges = GetRangeList();
4723 return rRanges.size();
4726 uno::Any SAL_CALL ScCellRangesObj::getByIndex( sal_Int32 nIndex )
4727 throw(lang::IndexOutOfBoundsException,
4728 lang::WrappedTargetException, uno::RuntimeException)
4730 SolarMutexGuard aGuard;
4731 uno::Reference<table::XCellRange> xRange(GetObjectByIndex_Impl(nIndex));
4732 if (xRange.is())
4733 return uno::makeAny(xRange);
4734 else
4735 throw lang::IndexOutOfBoundsException();
4738 uno::Type SAL_CALL ScCellRangesObj::getElementType() throw(uno::RuntimeException)
4740 SolarMutexGuard aGuard;
4741 return getCppuType((uno::Reference<table::XCellRange>*)0);
4744 sal_Bool SAL_CALL ScCellRangesObj::hasElements() throw(uno::RuntimeException)
4746 SolarMutexGuard aGuard;
4747 const ScRangeList& rRanges = GetRangeList();
4748 return !rRanges.empty();
4751 // XServiceInfo
4753 OUString SAL_CALL ScCellRangesObj::getImplementationName() throw(uno::RuntimeException)
4755 return OUString( "ScCellRangesObj" );
4758 sal_Bool SAL_CALL ScCellRangesObj::supportsService( const OUString& rServiceName )
4759 throw(uno::RuntimeException)
4761 OUString aServiceStr(rServiceName);
4762 return aServiceStr.equalsAscii( SCSHEETCELLRANGES_SERVICE ) ||
4763 aServiceStr.equalsAscii( SCCELLPROPERTIES_SERVICE ) ||
4764 aServiceStr.equalsAscii( SCCHARPROPERTIES_SERVICE ) ||
4765 aServiceStr.equalsAscii( SCPARAPROPERTIES_SERVICE );
4768 uno::Sequence<OUString> SAL_CALL ScCellRangesObj::getSupportedServiceNames()
4769 throw(uno::RuntimeException)
4771 uno::Sequence<OUString> aRet(4);
4772 OUString* pArray = aRet.getArray();
4773 pArray[0] = OUString( SCSHEETCELLRANGES_SERVICE );
4774 pArray[1] = OUString( SCCELLPROPERTIES_SERVICE );
4775 pArray[2] = OUString( SCCHARPROPERTIES_SERVICE );
4776 pArray[3] = OUString( SCPARAPROPERTIES_SERVICE );
4777 return aRet;
4780 //------------------------------------------------------------------------
4782 uno::Reference<table::XCellRange> ScCellRangeObj::CreateRangeFromDoc( ScDocument* pDoc, const ScRange& rR )
4784 SfxObjectShell* pObjSh = pDoc->GetDocumentShell();
4785 if ( pObjSh && pObjSh->ISA(ScDocShell) )
4786 return new ScCellRangeObj( (ScDocShell*) pObjSh, rR );
4787 return NULL;
4790 //------------------------------------------------------------------------
4792 ScCellRangeObj::ScCellRangeObj(ScDocShell* pDocSh, const ScRange& rR) :
4793 ScCellRangesBase( pDocSh, rR ),
4794 pRangePropSet( lcl_GetRangePropertySet() ),
4795 aRange( rR )
4797 aRange.Justify(); // Anfang / Ende richtig
4800 ScCellRangeObj::~ScCellRangeObj()
4804 void ScCellRangeObj::RefChanged()
4806 ScCellRangesBase::RefChanged();
4808 const ScRangeList& rRanges = GetRangeList();
4809 OSL_ENSURE(rRanges.size() == 1, "was fuer Ranges ?!?!");
4810 if ( !rRanges.empty() )
4812 const ScRange* pFirst = rRanges[0];
4813 aRange = ScRange(*pFirst);
4814 aRange.Justify();
4818 uno::Any SAL_CALL ScCellRangeObj::queryInterface( const uno::Type& rType )
4819 throw(uno::RuntimeException)
4821 SC_QUERYINTERFACE( sheet::XCellRangeAddressable )
4822 SC_QUERYINTERFACE( table::XCellRange )
4823 SC_QUERYINTERFACE( sheet::XSheetCellRange )
4824 SC_QUERYINTERFACE( sheet::XArrayFormulaRange )
4825 SC_QUERYINTERFACE( sheet::XArrayFormulaTokens )
4826 SC_QUERYINTERFACE( sheet::XCellRangeData )
4827 SC_QUERYINTERFACE( sheet::XCellRangeFormula )
4828 SC_QUERYINTERFACE( sheet::XMultipleOperation )
4829 SC_QUERYINTERFACE( util::XMergeable )
4830 SC_QUERYINTERFACE( sheet::XCellSeries )
4831 SC_QUERYINTERFACE( table::XAutoFormattable )
4832 SC_QUERYINTERFACE( util::XSortable )
4833 SC_QUERYINTERFACE( sheet::XSheetFilterableEx )
4834 SC_QUERYINTERFACE( sheet::XSheetFilterable )
4835 SC_QUERYINTERFACE( sheet::XSubTotalCalculatable )
4836 SC_QUERYINTERFACE( table::XColumnRowRange )
4837 SC_QUERYINTERFACE( util::XImportable )
4838 SC_QUERYINTERFACE( sheet::XCellFormatRangesSupplier )
4839 SC_QUERYINTERFACE( sheet::XUniqueCellFormatRangesSupplier )
4841 return ScCellRangesBase::queryInterface( rType );
4844 void SAL_CALL ScCellRangeObj::acquire() throw()
4846 ScCellRangesBase::acquire();
4849 void SAL_CALL ScCellRangeObj::release() throw()
4851 ScCellRangesBase::release();
4854 uno::Sequence<uno::Type> SAL_CALL ScCellRangeObj::getTypes() throw(uno::RuntimeException)
4856 static uno::Sequence<uno::Type> aTypes;
4857 if ( aTypes.getLength() == 0 )
4859 uno::Sequence<uno::Type> aParentTypes(ScCellRangesBase::getTypes());
4860 long nParentLen = aParentTypes.getLength();
4861 const uno::Type* pParentPtr = aParentTypes.getConstArray();
4863 aTypes.realloc( nParentLen + 17 );
4864 uno::Type* pPtr = aTypes.getArray();
4865 pPtr[nParentLen + 0] = getCppuType((const uno::Reference<sheet::XCellRangeAddressable>*)0);
4866 pPtr[nParentLen + 1] = getCppuType((const uno::Reference<sheet::XSheetCellRange>*)0);
4867 pPtr[nParentLen + 2] = getCppuType((const uno::Reference<sheet::XArrayFormulaRange>*)0);
4868 pPtr[nParentLen + 3] = getCppuType((const uno::Reference<sheet::XArrayFormulaTokens>*)0);
4869 pPtr[nParentLen + 4] = getCppuType((const uno::Reference<sheet::XCellRangeData>*)0);
4870 pPtr[nParentLen + 5] = getCppuType((const uno::Reference<sheet::XCellRangeFormula>*)0);
4871 pPtr[nParentLen + 6] = getCppuType((const uno::Reference<sheet::XMultipleOperation>*)0);
4872 pPtr[nParentLen + 7] = getCppuType((const uno::Reference<util::XMergeable>*)0);
4873 pPtr[nParentLen + 8] = getCppuType((const uno::Reference<sheet::XCellSeries>*)0);
4874 pPtr[nParentLen + 9] = getCppuType((const uno::Reference<table::XAutoFormattable>*)0);
4875 pPtr[nParentLen +10] = getCppuType((const uno::Reference<util::XSortable>*)0);
4876 pPtr[nParentLen +11] = getCppuType((const uno::Reference<sheet::XSheetFilterableEx>*)0);
4877 pPtr[nParentLen +12] = getCppuType((const uno::Reference<sheet::XSubTotalCalculatable>*)0);
4878 pPtr[nParentLen +13] = getCppuType((const uno::Reference<table::XColumnRowRange>*)0);
4879 pPtr[nParentLen +14] = getCppuType((const uno::Reference<util::XImportable>*)0);
4880 pPtr[nParentLen +15] = getCppuType((const uno::Reference<sheet::XCellFormatRangesSupplier>*)0);
4881 pPtr[nParentLen +16] = getCppuType((const uno::Reference<sheet::XUniqueCellFormatRangesSupplier>*)0);
4883 for (long i=0; i<nParentLen; i++)
4884 pPtr[i] = pParentPtr[i]; // parent types first
4886 return aTypes;
4889 namespace
4891 class theScCellRangeObjImplementationId : public rtl::Static< UnoTunnelIdInit, theScCellRangeObjImplementationId > {};
4894 uno::Sequence<sal_Int8> SAL_CALL ScCellRangeObj::getImplementationId()
4895 throw(uno::RuntimeException)
4897 return theScCellRangeObjImplementationId::get().getSeq();
4900 // XCellRange
4902 // ColumnCount / RowCount sind weggefallen
4903 //! werden im Writer fuer Tabellen noch gebraucht ???
4905 uno::Reference<table::XCell> ScCellRangeObj::GetCellByPosition_Impl(
4906 sal_Int32 nColumn, sal_Int32 nRow )
4907 throw(lang::IndexOutOfBoundsException, uno::RuntimeException)
4909 ScDocShell* pDocSh = GetDocShell();
4910 if (!pDocSh)
4911 throw uno::RuntimeException();
4913 if ( nColumn >= 0 && nRow >= 0 )
4915 sal_Int32 nPosX = aRange.aStart.Col() + nColumn;
4916 sal_Int32 nPosY = aRange.aStart.Row() + nRow;
4918 if ( nPosX <= aRange.aEnd.Col() && nPosY <= aRange.aEnd.Row() )
4920 ScAddress aNew( (SCCOL)nPosX, (SCROW)nPosY, aRange.aStart.Tab() );
4921 return new ScCellObj( pDocSh, aNew );
4925 throw lang::IndexOutOfBoundsException();
4928 uno::Reference<table::XCell> SAL_CALL ScCellRangeObj::getCellByPosition(
4929 sal_Int32 nColumn, sal_Int32 nRow )
4930 throw(lang::IndexOutOfBoundsException, uno::RuntimeException)
4932 SolarMutexGuard aGuard;
4934 return GetCellByPosition_Impl(nColumn, nRow);
4937 uno::Reference<table::XCellRange> SAL_CALL ScCellRangeObj::getCellRangeByPosition(
4938 sal_Int32 nLeft, sal_Int32 nTop, sal_Int32 nRight, sal_Int32 nBottom )
4939 throw(lang::IndexOutOfBoundsException, uno::RuntimeException)
4941 SolarMutexGuard aGuard;
4943 ScDocShell* pDocSh = GetDocShell();
4944 if (!pDocSh)
4945 throw uno::RuntimeException();
4947 if ( nLeft >= 0 && nTop >= 0 && nRight >= 0 && nBottom >= 0 )
4949 sal_Int32 nStartX = aRange.aStart.Col() + nLeft;
4950 sal_Int32 nStartY = aRange.aStart.Row() + nTop;
4951 sal_Int32 nEndX = aRange.aStart.Col() + nRight;
4952 sal_Int32 nEndY = aRange.aStart.Row() + nBottom;
4954 if ( nStartX <= nEndX && nEndX <= aRange.aEnd.Col() &&
4955 nStartY <= nEndY && nEndY <= aRange.aEnd.Row() )
4957 ScRange aNew( (SCCOL)nStartX, (SCROW)nStartY, aRange.aStart.Tab(),
4958 (SCCOL)nEndX, (SCROW)nEndY, aRange.aEnd.Tab() );
4959 return new ScCellRangeObj( pDocSh, aNew );
4963 throw lang::IndexOutOfBoundsException();
4966 uno::Reference<table::XCellRange> SAL_CALL ScCellRangeObj::getCellRangeByName(
4967 const OUString& aName ) throw(uno::RuntimeException)
4969 return getCellRangeByName( aName, ScAddress::detailsOOOa1 );
4972 uno::Reference<table::XCellRange> ScCellRangeObj::getCellRangeByName(
4973 const OUString& aName, const ScAddress::Details& rDetails ) throw(uno::RuntimeException)
4975 // name refers to the whole document (with the range's table as default),
4976 // valid only if the range is within this range
4978 SolarMutexGuard aGuard;
4979 ScDocShell* pDocSh = GetDocShell();
4980 if ( pDocSh )
4982 ScDocument* pDoc = pDocSh->GetDocument();
4983 SCTAB nTab = aRange.aStart.Tab();
4985 ScRange aCellRange;
4986 sal_Bool bFound = false;
4987 OUString aString(aName);
4988 sal_uInt16 nParse = aCellRange.ParseAny( aString, pDoc, rDetails );
4989 if ( nParse & SCA_VALID )
4991 if ( !(nParse & SCA_TAB_3D) ) // keine Tabelle angegeben -> auf dieser Tabelle
4993 aCellRange.aStart.SetTab(nTab);
4994 aCellRange.aEnd.SetTab(nTab);
4996 bFound = sal_True;
4998 else
5000 ScRangeUtil aRangeUtil;
5001 if ( aRangeUtil.MakeRangeFromName( aString, pDoc, nTab, aCellRange, RUTL_NAMES ) ||
5002 aRangeUtil.MakeRangeFromName( aString, pDoc, nTab, aCellRange, RUTL_DBASE ) )
5003 bFound = sal_True;
5006 if (bFound) // valid only if within this object's range
5008 if (!aRange.In(aCellRange))
5009 bFound = false;
5012 if (bFound)
5014 if ( aCellRange.aStart == aCellRange.aEnd )
5015 return new ScCellObj( pDocSh, aCellRange.aStart );
5016 else
5017 return new ScCellRangeObj( pDocSh, aCellRange );
5021 throw uno::RuntimeException();
5024 // XColumnRowRange
5026 uno::Reference<table::XTableColumns> SAL_CALL ScCellRangeObj::getColumns() throw(uno::RuntimeException)
5028 SolarMutexGuard aGuard;
5029 ScDocShell* pDocSh = GetDocShell();
5030 if (pDocSh)
5031 return new ScTableColumnsObj( pDocSh, aRange.aStart.Tab(),
5032 aRange.aStart.Col(), aRange.aEnd.Col() );
5034 OSL_FAIL("Dokument ungueltig");
5035 return NULL;
5038 uno::Reference<table::XTableRows> SAL_CALL ScCellRangeObj::getRows() throw(uno::RuntimeException)
5040 SolarMutexGuard aGuard;
5041 ScDocShell* pDocSh = GetDocShell();
5042 if (pDocSh)
5043 return new ScTableRowsObj( pDocSh, aRange.aStart.Tab(),
5044 aRange.aStart.Row(), aRange.aEnd.Row() );
5046 OSL_FAIL("Dokument ungueltig");
5047 return NULL;
5050 // XAddressableCellRange
5052 table::CellRangeAddress SAL_CALL ScCellRangeObj::getRangeAddress() throw(uno::RuntimeException)
5054 SolarMutexGuard aGuard;
5055 table::CellRangeAddress aRet;
5056 ScUnoConversion::FillApiRange( aRet, aRange );
5057 return aRet;
5060 // XSheetCellRange
5062 uno::Reference<sheet::XSpreadsheet> SAL_CALL ScCellRangeObj::getSpreadsheet()
5063 throw(uno::RuntimeException)
5065 SolarMutexGuard aGuard;
5066 ScDocShell* pDocSh = GetDocShell();
5067 if (pDocSh)
5068 return new ScTableSheetObj( pDocSh, aRange.aStart.Tab() );
5070 OSL_FAIL("Dokument ungueltig");
5071 return NULL;
5074 // XArrayFormulaRange
5076 OUString SAL_CALL ScCellRangeObj::getArrayFormula() throw(uno::RuntimeException)
5078 SolarMutexGuard aGuard;
5080 // Matrix-Formel, wenn eindeutig Teil einer Matrix,
5081 // also wenn Anfang und Ende des Blocks zur selben Matrix gehoeren.
5082 // Sonst Leerstring.
5084 ScDocShell* pDocSh = GetDocShell();
5085 if (!pDocSh)
5086 return EMPTY_OUSTRING;
5088 OUString aFormula;
5090 ScDocument* pDoc = pDocSh->GetDocument();
5091 ScRefCellValue aCell1;
5092 ScRefCellValue aCell2;
5093 aCell1.assign(*pDoc, aRange.aStart);
5094 aCell2.assign(*pDoc, aRange.aEnd);
5095 if (aCell1.meType == CELLTYPE_FORMULA && aCell2.meType == CELLTYPE_FORMULA)
5097 const ScFormulaCell* pFCell1 = aCell1.mpFormula;
5098 const ScFormulaCell* pFCell2 = aCell2.mpFormula;
5099 ScAddress aStart1;
5100 ScAddress aStart2;
5101 if (pFCell1->GetMatrixOrigin(aStart1) && pFCell2->GetMatrixOrigin(aStart2))
5103 if (aStart1 == aStart2) // beides dieselbe Matrix
5104 pFCell1->GetFormula(aFormula); // egal, von welcher Zelle
5107 return aFormula;
5110 void ScCellRangeObj::SetArrayFormula_Impl( const OUString& rFormula,
5111 const OUString& rFormulaNmsp, const formula::FormulaGrammar::Grammar eGrammar ) throw(uno::RuntimeException)
5113 ScDocShell* pDocSh = GetDocShell();
5114 if (pDocSh)
5116 if ( !rFormula.isEmpty() )
5118 if ( ScTableSheetObj::getImplementation( (cppu::OWeakObject*)this ) )
5120 // don't set array formula for sheet object
5121 throw uno::RuntimeException();
5124 pDocSh->GetDocFunc().EnterMatrix( aRange, NULL, NULL, rFormula, sal_True, sal_True, rFormulaNmsp, eGrammar );
5126 else
5128 // empty string -> erase array formula
5129 ScMarkData aMark;
5130 aMark.SetMarkArea( aRange );
5131 aMark.SelectTable( aRange.aStart.Tab(), sal_True );
5132 pDocSh->GetDocFunc().DeleteContents( aMark, IDF_CONTENTS, sal_True, sal_True );
5137 void SAL_CALL ScCellRangeObj::setArrayFormula( const OUString& aFormula )
5138 throw(uno::RuntimeException)
5140 SolarMutexGuard aGuard;
5141 // GRAM_PODF_A1 for API compatibility.
5142 SetArrayFormula_Impl( aFormula, OUString(), formula::FormulaGrammar::GRAM_PODF_A1);
5145 void ScCellRangeObj::SetArrayFormulaWithGrammar( const OUString& rFormula,
5146 const OUString& rFormulaNmsp, const formula::FormulaGrammar::Grammar eGrammar ) throw(uno::RuntimeException)
5148 SolarMutexGuard aGuard;
5149 SetArrayFormula_Impl( rFormula, rFormulaNmsp, eGrammar);
5152 // XArrayFormulaTokens
5154 uno::Sequence<sheet::FormulaToken> SAL_CALL ScCellRangeObj::getArrayTokens() throw(uno::RuntimeException)
5156 SolarMutexGuard aGuard;
5158 // same cell logic as in getArrayFormula
5160 uno::Sequence<sheet::FormulaToken> aSequence;
5161 ScDocShell* pDocSh = GetDocShell();
5162 if (!pDocSh)
5163 return aSequence;
5165 ScDocument* pDoc = pDocSh->GetDocument();
5166 ScRefCellValue aCell1;
5167 ScRefCellValue aCell2;
5168 aCell1.assign(*pDoc, aRange.aStart);
5169 aCell2.assign(*pDoc, aRange.aEnd);
5170 if (aCell1.meType == CELLTYPE_FORMULA && aCell2.meType == CELLTYPE_FORMULA)
5172 const ScFormulaCell* pFCell1 = aCell1.mpFormula;
5173 const ScFormulaCell* pFCell2 = aCell2.mpFormula;
5174 ScAddress aStart1;
5175 ScAddress aStart2;
5176 if (pFCell1->GetMatrixOrigin(aStart1) && pFCell2->GetMatrixOrigin(aStart2))
5178 if (aStart1 == aStart2)
5180 const ScTokenArray* pTokenArray = pFCell1->GetCode();
5181 if (pTokenArray)
5182 (void)ScTokenConversion::ConvertToTokenSequence(*pDoc, aSequence, *pTokenArray);
5187 return aSequence;
5190 void SAL_CALL ScCellRangeObj::setArrayTokens( const uno::Sequence<sheet::FormulaToken>& rTokens ) throw(uno::RuntimeException)
5192 SolarMutexGuard aGuard;
5193 ScDocShell* pDocSh = GetDocShell();
5194 if ( pDocSh )
5196 if ( rTokens.getLength() )
5198 if ( ScTableSheetObj::getImplementation( (cppu::OWeakObject*)this ) )
5200 throw uno::RuntimeException();
5203 ScDocument* pDoc = pDocSh->GetDocument();
5204 ScTokenArray aTokenArray;
5205 (void)ScTokenConversion::ConvertToTokenArray( *pDoc, aTokenArray, rTokens );
5207 // Actually GRAM_PODF_A1 is a don't-care here because of the token
5208 // array being set, it fits with other API compatibility grammars
5209 // though.
5210 pDocSh->GetDocFunc().EnterMatrix( aRange, NULL, &aTokenArray, EMPTY_OUSTRING, sal_True, sal_True, EMPTY_OUSTRING, formula::FormulaGrammar::GRAM_PODF_A1 );
5212 else
5214 // empty sequence -> erase array formula
5215 ScMarkData aMark;
5216 aMark.SetMarkArea( aRange );
5217 aMark.SelectTable( aRange.aStart.Tab(), sal_True );
5218 pDocSh->GetDocFunc().DeleteContents( aMark, IDF_CONTENTS, sal_True, sal_True );
5223 // XCellRangeData
5225 uno::Sequence< uno::Sequence<uno::Any> > SAL_CALL ScCellRangeObj::getDataArray()
5226 throw(uno::RuntimeException)
5228 SolarMutexGuard aGuard;
5230 if ( ScTableSheetObj::getImplementation( (cppu::OWeakObject*)this ) )
5232 // don't create a data array for the sheet
5233 throw uno::RuntimeException();
5236 ScDocShell* pDocSh = GetDocShell();
5237 if (pDocSh)
5239 uno::Any aAny;
5240 // bAllowNV = TRUE: errors as void
5241 if ( ScRangeToSequence::FillMixedArray( aAny, pDocSh->GetDocument(), aRange, sal_True ) )
5243 uno::Sequence< uno::Sequence<uno::Any> > aSeq;
5244 if ( aAny >>= aSeq )
5245 return aSeq; // success
5249 throw uno::RuntimeException(); // no other exceptions specified
5252 void SAL_CALL ScCellRangeObj::setDataArray(
5253 const uno::Sequence< uno::Sequence<uno::Any> >& aArray )
5254 throw(uno::RuntimeException)
5256 SolarMutexGuard aGuard;
5258 sal_Bool bDone = false;
5259 ScDocShell* pDocSh = GetDocShell();
5260 if (pDocSh)
5262 //! move lcl_PutDataArray to docfunc?
5263 bDone = lcl_PutDataArray( *pDocSh, aRange, aArray );
5266 if (!bDone)
5267 throw uno::RuntimeException(); // no other exceptions specified
5270 // XCellRangeFormula
5272 uno::Sequence< uno::Sequence<OUString> > SAL_CALL ScCellRangeObj::getFormulaArray()
5273 throw(uno::RuntimeException)
5275 SolarMutexGuard aGuard;
5277 if ( ScTableSheetObj::getImplementation( (cppu::OWeakObject*)this ) )
5279 // don't create a data array for the sheet
5280 throw uno::RuntimeException();
5283 ScDocShell* pDocSh = GetDocShell();
5284 if (pDocSh)
5286 SCCOL nStartCol = aRange.aStart.Col();
5287 SCROW nStartRow = aRange.aStart.Row();
5288 SCCOL nEndCol = aRange.aEnd.Col();
5289 SCROW nEndRow = aRange.aEnd.Row();
5290 SCCOL nColCount = nEndCol + 1 - nStartCol;
5291 SCROW nRowCount = nEndRow + 1 - nStartRow;
5292 SCTAB nTab = aRange.aStart.Tab();
5294 uno::Sequence< uno::Sequence<OUString> > aRowSeq( nRowCount );
5295 uno::Sequence<OUString>* pRowAry = aRowSeq.getArray();
5296 for (SCROW nRowIndex = 0; nRowIndex < nRowCount; nRowIndex++)
5298 uno::Sequence<OUString> aColSeq( nColCount );
5299 OUString* pColAry = aColSeq.getArray();
5300 for (SCCOL nColIndex = 0; nColIndex < nColCount; nColIndex++)
5301 pColAry[nColIndex] = lcl_GetInputString( pDocSh->GetDocument(),
5302 ScAddress( nStartCol+nColIndex, nStartRow+nRowIndex, nTab ), sal_True );
5304 pRowAry[nRowIndex] = aColSeq;
5307 return aRowSeq;
5310 throw uno::RuntimeException(); // no other exceptions specified
5313 void SAL_CALL ScCellRangeObj::setFormulaArray(
5314 const uno::Sequence< uno::Sequence<OUString> >& aArray )
5315 throw(uno::RuntimeException)
5317 SolarMutexGuard aGuard;
5319 sal_Bool bDone = false;
5320 ScDocShell* pDocSh = GetDocShell();
5321 if (pDocSh)
5323 ScExternalRefManager::ApiGuard aExtRefGuard(pDocSh->GetDocument());
5325 // GRAM_PODF_A1 for API compatibility.
5326 bDone = lcl_PutFormulaArray( *pDocSh, aRange, aArray, formula::FormulaGrammar::GRAM_PODF_A1 );
5329 if (!bDone)
5330 throw uno::RuntimeException(); // no other exceptions specified
5333 // XMultipleOperation
5335 void SAL_CALL ScCellRangeObj::setTableOperation( const table::CellRangeAddress& aFormulaRange,
5336 sheet::TableOperationMode nMode,
5337 const table::CellAddress& aColumnCell,
5338 const table::CellAddress& aRowCell )
5339 throw(uno::RuntimeException)
5341 SolarMutexGuard aGuard;
5342 ScDocShell* pDocSh = GetDocShell();
5343 if (pDocSh)
5345 bool bError = false;
5346 ScTabOpParam aParam;
5347 aParam.aRefFormulaCell = ScRefAddress( (SCCOL)aFormulaRange.StartColumn,
5348 (SCROW)aFormulaRange.StartRow, aFormulaRange.Sheet,
5349 false, false, false );
5350 aParam.aRefFormulaEnd = ScRefAddress( (SCCOL)aFormulaRange.EndColumn,
5351 (SCROW)aFormulaRange.EndRow, aFormulaRange.Sheet,
5352 false, false, false );
5353 aParam.aRefRowCell = ScRefAddress( (SCCOL)aRowCell.Column,
5354 (SCROW)aRowCell.Row, aRowCell.Sheet,
5355 false, false, false );
5356 aParam.aRefColCell = ScRefAddress( (SCCOL)aColumnCell.Column,
5357 (SCROW)aColumnCell.Row, aColumnCell.Sheet,
5358 false, false, false );
5360 switch (nMode)
5362 case sheet::TableOperationMode_COLUMN:
5363 aParam.meMode = ScTabOpParam::Column;
5364 break;
5365 case sheet::TableOperationMode_ROW:
5366 aParam.meMode = ScTabOpParam::Row;
5367 break;
5368 case sheet::TableOperationMode_BOTH:
5369 aParam.meMode = ScTabOpParam::Both;
5370 break;
5371 default:
5372 bError = true;
5375 if (!bError)
5376 pDocSh->GetDocFunc().TabOp( aRange, NULL, aParam, sal_True, sal_True );
5380 // XMergeable
5382 void SAL_CALL ScCellRangeObj::merge( sal_Bool bMerge ) throw(uno::RuntimeException)
5384 SolarMutexGuard aGuard;
5385 ScDocShell* pDocSh = GetDocShell();
5386 if ( pDocSh )
5388 ScCellMergeOption aMergeOption(
5389 aRange.aStart.Col(), aRange.aStart.Row(),
5390 aRange.aEnd.Col(), aRange.aEnd.Row(), false);
5391 aMergeOption.maTabs.insert(aRange.aStart.Tab());
5392 if ( bMerge )
5393 pDocSh->GetDocFunc().MergeCells( aMergeOption, false, true, true );
5394 else
5395 pDocSh->GetDocFunc().UnmergeCells( aMergeOption, true );
5397 //! Fehler abfangen?
5401 sal_Bool SAL_CALL ScCellRangeObj::getIsMerged() throw(uno::RuntimeException)
5403 SolarMutexGuard aGuard;
5404 ScDocShell* pDocSh = GetDocShell();
5405 return pDocSh && pDocSh->GetDocument()->HasAttrib( aRange, HASATTR_MERGED );
5408 // XCellSeries
5410 void SAL_CALL ScCellRangeObj::fillSeries( sheet::FillDirection nFillDirection,
5411 sheet::FillMode nFillMode, sheet::FillDateMode nFillDateMode,
5412 double fStep, double fEndValue ) throw(uno::RuntimeException)
5414 SolarMutexGuard aGuard;
5415 ScDocShell* pDocSh = GetDocShell();
5416 if ( pDocSh )
5418 sal_Bool bError = false;
5420 FillDir eDir = FILL_TO_BOTTOM;
5421 switch (nFillDirection)
5423 case sheet::FillDirection_TO_BOTTOM:
5424 eDir = FILL_TO_BOTTOM;
5425 break;
5426 case sheet::FillDirection_TO_RIGHT:
5427 eDir = FILL_TO_RIGHT;
5428 break;
5429 case sheet::FillDirection_TO_TOP:
5430 eDir = FILL_TO_TOP;
5431 break;
5432 case sheet::FillDirection_TO_LEFT:
5433 eDir = FILL_TO_LEFT;
5434 break;
5435 default:
5436 bError = sal_True;
5439 FillCmd eCmd = FILL_SIMPLE;
5440 switch ( nFillMode )
5442 case sheet::FillMode_SIMPLE:
5443 eCmd = FILL_SIMPLE;
5444 break;
5445 case sheet::FillMode_LINEAR:
5446 eCmd = FILL_LINEAR;
5447 break;
5448 case sheet::FillMode_GROWTH:
5449 eCmd = FILL_GROWTH;
5450 break;
5451 case sheet::FillMode_DATE:
5452 eCmd = FILL_DATE;
5453 break;
5454 case sheet::FillMode_AUTO:
5455 eCmd = FILL_AUTO;
5456 break;
5457 default:
5458 bError = sal_True;
5461 FillDateCmd eDateCmd = FILL_DAY;
5462 switch ( nFillDateMode )
5464 case sheet::FillDateMode_FILL_DATE_DAY:
5465 eDateCmd = FILL_DAY;
5466 break;
5467 case sheet::FillDateMode_FILL_DATE_WEEKDAY:
5468 eDateCmd = FILL_WEEKDAY;
5469 break;
5470 case sheet::FillDateMode_FILL_DATE_MONTH:
5471 eDateCmd = FILL_MONTH;
5472 break;
5473 case sheet::FillDateMode_FILL_DATE_YEAR:
5474 eDateCmd = FILL_YEAR;
5475 break;
5476 default:
5477 bError = sal_True;
5480 if (!bError)
5481 pDocSh->GetDocFunc().FillSeries( aRange, NULL, eDir, eCmd, eDateCmd,
5482 MAXDOUBLE, fStep, fEndValue, sal_True, sal_True );
5486 void SAL_CALL ScCellRangeObj::fillAuto( sheet::FillDirection nFillDirection,
5487 sal_Int32 nSourceCount ) throw(uno::RuntimeException)
5489 SolarMutexGuard aGuard;
5490 ScDocShell* pDocSh = GetDocShell();
5491 if ( pDocSh && nSourceCount )
5493 ScRange aSourceRange(aRange);
5494 SCsCOLROW nCount = 0; // "Dest-Count"
5495 FillDir eDir = FILL_TO_BOTTOM;
5496 sal_Bool bError = false;
5497 switch (nFillDirection)
5499 case sheet::FillDirection_TO_BOTTOM:
5500 aSourceRange.aEnd.SetRow( static_cast<SCROW>( aSourceRange.aStart.Row() + nSourceCount - 1 ) );
5501 nCount = aRange.aEnd.Row() - aSourceRange.aEnd.Row();
5502 eDir = FILL_TO_BOTTOM;
5503 break;
5504 case sheet::FillDirection_TO_RIGHT:
5505 aSourceRange.aEnd.SetCol( static_cast<SCCOL>( aSourceRange.aStart.Col() + nSourceCount - 1 ) );
5506 nCount = aRange.aEnd.Col() - aSourceRange.aEnd.Col();
5507 eDir = FILL_TO_RIGHT;
5508 break;
5509 case sheet::FillDirection_TO_TOP:
5510 aSourceRange.aStart.SetRow( static_cast<SCROW>( aSourceRange.aEnd.Row() - nSourceCount + 1 ) );
5511 nCount = aSourceRange.aStart.Row() - aRange.aStart.Row();
5512 eDir = FILL_TO_TOP;
5513 break;
5514 case sheet::FillDirection_TO_LEFT:
5515 aSourceRange.aStart.SetCol( static_cast<SCCOL>( aSourceRange.aEnd.Col() - nSourceCount + 1 ) );
5516 nCount = aSourceRange.aStart.Col() - aRange.aStart.Col();
5517 eDir = FILL_TO_LEFT;
5518 break;
5519 default:
5520 bError = sal_True;
5522 if (nCount < 0 || nCount > MAXROW) // overflow
5523 bError = sal_True;
5525 if (!bError)
5526 pDocSh->GetDocFunc().FillAuto( aSourceRange, NULL, eDir, nCount, sal_True, sal_True );
5530 // XAutoFormattable
5532 void SAL_CALL ScCellRangeObj::autoFormat( const OUString& aName )
5533 throw(lang::IllegalArgumentException, uno::RuntimeException)
5535 SolarMutexGuard aGuard;
5536 ScDocShell* pDocSh = GetDocShell();
5537 if ( pDocSh )
5539 ScAutoFormat* pAutoFormat = ScGlobal::GetOrCreateAutoFormat();
5540 ScAutoFormat::const_iterator it = pAutoFormat->find(aName);
5541 if (it != pAutoFormat->end())
5543 ScAutoFormat::const_iterator itBeg = pAutoFormat->begin();
5544 size_t nIndex = std::distance(itBeg, it);
5545 pDocSh->GetDocFunc().AutoFormat(aRange, NULL, nIndex, true, true);
5547 else
5548 throw lang::IllegalArgumentException();
5552 // XSortable
5554 uno::Sequence<beans::PropertyValue> SAL_CALL ScCellRangeObj::createSortDescriptor()
5555 throw(uno::RuntimeException)
5557 SolarMutexGuard aGuard;
5558 ScSortParam aParam;
5559 ScDocShell* pDocSh = GetDocShell();
5560 if ( pDocSh )
5562 // DB-Bereich anlegen erst beim Ausfuehren, per API immer genau den Bereich
5563 ScDBData* pData = pDocSh->GetDBData( aRange, SC_DB_OLD, SC_DBSEL_FORCE_MARK );
5564 if (pData)
5566 pData->GetSortParam(aParam);
5568 // im SortDescriptor sind die Fields innerhalb des Bereichs gezaehlt
5569 ScRange aDBRange;
5570 pData->GetArea(aDBRange);
5571 SCCOLROW nFieldStart = aParam.bByRow ?
5572 static_cast<SCCOLROW>(aDBRange.aStart.Col()) :
5573 static_cast<SCCOLROW>(aDBRange.aStart.Row());
5574 for (sal_uInt16 i=0; i<aParam.GetSortKeyCount(); i++)
5575 if ( aParam.maKeyState[i].bDoSort && aParam.maKeyState[i].nField >= nFieldStart )
5576 aParam.maKeyState[i].nField -= nFieldStart;
5580 uno::Sequence<beans::PropertyValue> aSeq( ScSortDescriptor::GetPropertyCount() );
5581 ScSortDescriptor::FillProperties( aSeq, aParam );
5582 return aSeq;
5585 void SAL_CALL ScCellRangeObj::sort( const uno::Sequence<beans::PropertyValue>& aDescriptor )
5586 throw(uno::RuntimeException)
5588 SolarMutexGuard aGuard;
5589 ScDocShell* pDocSh = GetDocShell();
5590 if (pDocSh)
5592 sal_uInt16 i;
5593 ScSortParam aParam;
5594 ScDBData* pData = pDocSh->GetDBData( aRange, SC_DB_MAKE, SC_DBSEL_FORCE_MARK ); // ggf. Bereich anlegen
5595 if (pData)
5597 // alten Einstellungen holen, falls nicht alles neu gesetzt wird
5598 pData->GetSortParam(aParam);
5599 SCCOLROW nOldStart = aParam.bByRow ?
5600 static_cast<SCCOLROW>(aRange.aStart.Col()) :
5601 static_cast<SCCOLROW>(aRange.aStart.Row());
5602 for (i=0; i<aParam.GetSortKeyCount(); i++)
5603 if ( aParam.maKeyState[i].bDoSort && aParam.maKeyState[i].nField >= nOldStart )
5604 aParam.maKeyState[i].nField -= nOldStart;
5607 ScSortDescriptor::FillSortParam( aParam, aDescriptor );
5609 // im SortDescriptor sind die Fields innerhalb des Bereichs gezaehlt
5610 // ByRow kann bei FillSortParam umgesetzt worden sein
5611 SCCOLROW nFieldStart = aParam.bByRow ?
5612 static_cast<SCCOLROW>(aRange.aStart.Col()) :
5613 static_cast<SCCOLROW>(aRange.aStart.Row());
5614 for (i=0; i<aParam.GetSortKeyCount(); i++)
5615 aParam.maKeyState[i].nField += nFieldStart;
5617 SCTAB nTab = aRange.aStart.Tab();
5618 aParam.nCol1 = aRange.aStart.Col();
5619 aParam.nRow1 = aRange.aStart.Row();
5620 aParam.nCol2 = aRange.aEnd.Col();
5621 aParam.nRow2 = aRange.aEnd.Row();
5623 pDocSh->GetDBData( aRange, SC_DB_MAKE, SC_DBSEL_FORCE_MARK ); // ggf. Bereich anlegen
5625 ScDBDocFunc aFunc(*pDocSh); // Bereich muss angelegt sein
5626 aFunc.Sort( nTab, aParam, sal_True, sal_True, sal_True );
5630 // XFilterable
5632 uno::Reference<sheet::XSheetFilterDescriptor> SAL_CALL ScCellRangeObj::createFilterDescriptor(
5633 sal_Bool bEmpty ) throw(uno::RuntimeException)
5635 SolarMutexGuard aGuard;
5636 ScDocShell* pDocSh = GetDocShell();
5637 ScFilterDescriptor* pNew = new ScFilterDescriptor(pDocSh);
5638 if ( !bEmpty && pDocSh )
5640 // DB-Bereich anlegen erst beim Ausfuehren, per API immer genau den Bereich
5641 ScDBData* pData = pDocSh->GetDBData( aRange, SC_DB_OLD, SC_DBSEL_FORCE_MARK );
5642 if (pData)
5644 ScQueryParam aParam;
5645 pData->GetQueryParam(aParam);
5646 // im FilterDescriptor sind die Fields innerhalb des Bereichs gezaehlt
5647 ScRange aDBRange;
5648 pData->GetArea(aDBRange);
5649 SCCOLROW nFieldStart = aParam.bByRow ?
5650 static_cast<SCCOLROW>(aDBRange.aStart.Col()) :
5651 static_cast<SCCOLROW>(aDBRange.aStart.Row());
5652 SCSIZE nCount = aParam.GetEntryCount();
5653 for (SCSIZE i=0; i<nCount; i++)
5655 ScQueryEntry& rEntry = aParam.GetEntry(i);
5656 if (rEntry.bDoQuery && rEntry.nField >= nFieldStart)
5657 rEntry.nField -= nFieldStart;
5659 pNew->SetParam(aParam);
5662 return pNew;
5665 void SAL_CALL ScCellRangeObj::filter( const uno::Reference<sheet::XSheetFilterDescriptor>& xDescriptor )
5666 throw(uno::RuntimeException)
5668 SolarMutexGuard aGuard;
5670 // das koennte theoretisch ein fremdes Objekt sein, also nur das
5671 // oeffentliche XSheetFilterDescriptor Interface benutzen, um
5672 // die Daten in ein ScFilterDescriptor Objekt zu kopieren:
5673 //! wenn es schon ein ScFilterDescriptor ist, direkt per getImplementation?
5675 ScDocShell* pDocSh = GetDocShell();
5676 ScFilterDescriptor aImpl(pDocSh);
5677 uno::Reference< sheet::XSheetFilterDescriptor2 > xDescriptor2( xDescriptor, uno::UNO_QUERY );
5678 if ( xDescriptor2.is() )
5680 aImpl.setFilterFields2( xDescriptor2->getFilterFields2() );
5682 else
5684 aImpl.setFilterFields( xDescriptor->getFilterFields() );
5686 // Rest sind jetzt Properties...
5688 uno::Reference<beans::XPropertySet> xPropSet( xDescriptor, uno::UNO_QUERY );
5689 if (xPropSet.is())
5690 lcl_CopyProperties( aImpl, *(beans::XPropertySet*)xPropSet.get() );
5693 // ausfuehren...
5696 if (pDocSh)
5698 ScQueryParam aParam = aImpl.GetParam();
5699 // im FilterDescriptor sind die Fields innerhalb des Bereichs gezaehlt
5700 SCCOLROW nFieldStart = aParam.bByRow ?
5701 static_cast<SCCOLROW>(aRange.aStart.Col()) :
5702 static_cast<SCCOLROW>(aRange.aStart.Row());
5703 SCSIZE nCount = aParam.GetEntryCount();
5704 svl::SharedStringPool& rPool = pDocSh->GetDocument()->GetSharedStringPool();
5705 for (SCSIZE i=0; i<nCount; i++)
5707 ScQueryEntry& rEntry = aParam.GetEntry(i);
5708 if (rEntry.bDoQuery)
5710 rEntry.nField += nFieldStart;
5711 // Im Dialog wird immer der String angezeigt -> muss zum Wert passen
5712 ScQueryEntry::QueryItemsType& rItems = rEntry.GetQueryItems();
5713 rItems.resize(1);
5714 ScQueryEntry::Item& rItem = rItems.front();
5715 if (rItem.meType != ScQueryEntry::ByString)
5717 OUString aStr;
5718 pDocSh->GetDocument()->GetFormatTable()->GetInputLineString(rItem.mfVal, 0, aStr);
5719 rItem.maString = rPool.intern(aStr);
5724 SCTAB nTab = aRange.aStart.Tab();
5725 aParam.nCol1 = aRange.aStart.Col();
5726 aParam.nRow1 = aRange.aStart.Row();
5727 aParam.nCol2 = aRange.aEnd.Col();
5728 aParam.nRow2 = aRange.aEnd.Row();
5730 pDocSh->GetDBData( aRange, SC_DB_MAKE, SC_DBSEL_FORCE_MARK ); // ggf. Bereich anlegen
5732 //! keep source range in filter descriptor
5733 //! if created by createFilterDescriptorByObject ???
5735 ScDBDocFunc aFunc(*pDocSh);
5736 aFunc.Query( nTab, aParam, NULL, sal_True, sal_True ); // Bereich muss angelegt sein
5740 //! get/setAutoFilter als Properties!!!
5742 // XAdvancedFilterSource
5744 uno::Reference<sheet::XSheetFilterDescriptor> SAL_CALL ScCellRangeObj::createFilterDescriptorByObject(
5745 const uno::Reference<sheet::XSheetFilterable>& xObject )
5746 throw(uno::RuntimeException)
5748 SolarMutexGuard aGuard;
5750 // this ist hier nicht der Bereich, der gefiltert wird, sondern der
5751 // Bereich mit der Abfrage...
5753 uno::Reference<sheet::XCellRangeAddressable> xAddr( xObject, uno::UNO_QUERY );
5755 ScDocShell* pDocSh = GetDocShell();
5756 if ( pDocSh && xAddr.is() )
5758 //! Test, ob xObject im selben Dokument ist
5760 ScFilterDescriptor* pNew = new ScFilterDescriptor(pDocSh); //! stattdessen vom Objekt?
5762 ScQueryParam aParam = pNew->GetParam();
5763 aParam.bHasHeader = sal_True;
5765 table::CellRangeAddress aDataAddress(xAddr->getRangeAddress());
5766 aParam.nCol1 = (SCCOL)aDataAddress.StartColumn;
5767 aParam.nRow1 = (SCROW)aDataAddress.StartRow;
5768 aParam.nCol2 = (SCCOL)aDataAddress.EndColumn;
5769 aParam.nRow2 = (SCROW)aDataAddress.EndRow;
5770 aParam.nTab = aDataAddress.Sheet;
5772 ScDocument* pDoc = pDocSh->GetDocument();
5773 sal_Bool bOk = pDoc->CreateQueryParam(
5774 aRange.aStart.Col(), aRange.aStart.Row(),
5775 aRange.aEnd.Col(), aRange.aEnd.Row(),
5776 aRange.aStart.Tab(), aParam );
5777 if ( bOk )
5779 // im FilterDescriptor sind die Fields innerhalb des Bereichs gezaehlt
5780 SCCOLROW nFieldStart = aParam.bByRow ?
5781 static_cast<SCCOLROW>(aDataAddress.StartColumn) :
5782 static_cast<SCCOLROW>(aDataAddress.StartRow);
5783 SCSIZE nCount = aParam.GetEntryCount();
5784 for (SCSIZE i=0; i<nCount; i++)
5786 ScQueryEntry& rEntry = aParam.GetEntry(i);
5787 if (rEntry.bDoQuery && rEntry.nField >= nFieldStart)
5788 rEntry.nField -= nFieldStart;
5791 pNew->SetParam( aParam );
5792 return pNew;
5794 else
5796 delete pNew;
5797 return NULL; // ungueltig -> null
5801 OSL_FAIL("kein Dokument oder kein Bereich");
5802 return NULL;
5805 // XSubTotalSource
5807 uno::Reference<sheet::XSubTotalDescriptor> SAL_CALL ScCellRangeObj::createSubTotalDescriptor(
5808 sal_Bool bEmpty ) throw(uno::RuntimeException)
5810 SolarMutexGuard aGuard;
5811 ScSubTotalDescriptor* pNew = new ScSubTotalDescriptor;
5812 ScDocShell* pDocSh = GetDocShell();
5813 if ( !bEmpty && pDocSh )
5815 // DB-Bereich anlegen erst beim Ausfuehren, per API immer genau den Bereich
5816 ScDBData* pData = pDocSh->GetDBData( aRange, SC_DB_OLD, SC_DBSEL_FORCE_MARK );
5817 if (pData)
5819 ScSubTotalParam aParam;
5820 pData->GetSubTotalParam(aParam);
5821 // im SubTotalDescriptor sind die Fields innerhalb des Bereichs gezaehlt
5822 ScRange aDBRange;
5823 pData->GetArea(aDBRange);
5824 SCCOL nFieldStart = aDBRange.aStart.Col();
5825 for (sal_uInt16 i=0; i<MAXSUBTOTAL; i++)
5827 if ( aParam.bGroupActive[i] )
5829 if ( aParam.nField[i] >= nFieldStart )
5830 aParam.nField[i] = sal::static_int_cast<SCCOL>( aParam.nField[i] - nFieldStart );
5831 for (SCCOL j=0; j<aParam.nSubTotals[i]; j++)
5832 if ( aParam.pSubTotals[i][j] >= nFieldStart )
5833 aParam.pSubTotals[i][j] = sal::static_int_cast<SCCOL>( aParam.pSubTotals[i][j] - nFieldStart );
5836 pNew->SetParam(aParam);
5839 return pNew;
5842 void SAL_CALL ScCellRangeObj::applySubTotals(
5843 const uno::Reference<sheet::XSubTotalDescriptor>& xDescriptor,
5844 sal_Bool bReplace ) throw(uno::RuntimeException)
5846 SolarMutexGuard aGuard;
5848 if (!xDescriptor.is()) return;
5850 ScDocShell* pDocSh = GetDocShell();
5851 ScSubTotalDescriptorBase* pImp =
5852 ScSubTotalDescriptorBase::getImplementation( xDescriptor );
5854 if (pDocSh && pImp)
5856 ScSubTotalParam aParam;
5857 pImp->GetData(aParam); // virtuelle Methode der Basisklasse
5859 // im SubTotalDescriptor sind die Fields innerhalb des Bereichs gezaehlt
5860 SCCOL nFieldStart = aRange.aStart.Col();
5861 for (sal_uInt16 i=0; i<MAXSUBTOTAL; i++)
5863 if ( aParam.bGroupActive[i] )
5865 aParam.nField[i] = sal::static_int_cast<SCCOL>( aParam.nField[i] + nFieldStart );
5866 for (SCCOL j=0; j<aParam.nSubTotals[i]; j++)
5867 aParam.pSubTotals[i][j] = sal::static_int_cast<SCCOL>( aParam.pSubTotals[i][j] + nFieldStart );
5871 aParam.bReplace = bReplace;
5873 SCTAB nTab = aRange.aStart.Tab();
5874 aParam.nCol1 = aRange.aStart.Col();
5875 aParam.nRow1 = aRange.aStart.Row();
5876 aParam.nCol2 = aRange.aEnd.Col();
5877 aParam.nRow2 = aRange.aEnd.Row();
5879 pDocSh->GetDBData( aRange, SC_DB_MAKE, SC_DBSEL_FORCE_MARK ); // ggf. Bereich anlegen
5881 ScDBDocFunc aFunc(*pDocSh);
5882 aFunc.DoSubTotals( nTab, aParam, NULL, sal_True, sal_True ); // Bereich muss angelegt sein
5886 void SAL_CALL ScCellRangeObj::removeSubTotals() throw(uno::RuntimeException)
5888 SolarMutexGuard aGuard;
5890 ScDocShell* pDocSh = GetDocShell();
5891 if (pDocSh)
5893 ScSubTotalParam aParam;
5894 ScDBData* pData = pDocSh->GetDBData( aRange, SC_DB_OLD, SC_DBSEL_FORCE_MARK );
5895 if (pData)
5896 pData->GetSubTotalParam(aParam); // auch bei Remove die Feld-Eintraege behalten
5898 aParam.bRemoveOnly = sal_True;
5900 SCTAB nTab = aRange.aStart.Tab();
5901 aParam.nCol1 = aRange.aStart.Col();
5902 aParam.nRow1 = aRange.aStart.Row();
5903 aParam.nCol2 = aRange.aEnd.Col();
5904 aParam.nRow2 = aRange.aEnd.Row();
5906 pDocSh->GetDBData( aRange, SC_DB_MAKE, SC_DBSEL_FORCE_MARK ); // ggf. Bereich anlegen
5908 ScDBDocFunc aFunc(*pDocSh);
5909 aFunc.DoSubTotals( nTab, aParam, NULL, sal_True, sal_True ); // Bereich muss angelegt sein
5913 uno::Sequence<beans::PropertyValue> SAL_CALL ScCellRangeObj::createImportDescriptor( sal_Bool bEmpty )
5914 throw(uno::RuntimeException)
5916 SolarMutexGuard aGuard;
5917 ScImportParam aParam;
5918 ScDocShell* pDocSh = GetDocShell();
5919 if ( !bEmpty && pDocSh )
5921 // DB-Bereich anlegen erst beim Ausfuehren, per API immer genau den Bereich
5922 ScDBData* pData = pDocSh->GetDBData( aRange, SC_DB_OLD, SC_DBSEL_FORCE_MARK );
5923 if (pData)
5924 pData->GetImportParam(aParam);
5927 uno::Sequence<beans::PropertyValue> aSeq( ScImportDescriptor::GetPropertyCount() );
5928 ScImportDescriptor::FillProperties( aSeq, aParam );
5929 return aSeq;
5932 void SAL_CALL ScCellRangeObj::doImport( const uno::Sequence<beans::PropertyValue>& aDescriptor )
5933 throw(uno::RuntimeException)
5935 SolarMutexGuard aGuard;
5936 ScDocShell* pDocSh = GetDocShell();
5937 if (pDocSh)
5939 ScImportParam aParam;
5940 ScImportDescriptor::FillImportParam( aParam, aDescriptor );
5942 SCTAB nTab = aRange.aStart.Tab();
5943 aParam.nCol1 = aRange.aStart.Col();
5944 aParam.nRow1 = aRange.aStart.Row();
5945 aParam.nCol2 = aRange.aEnd.Col();
5946 aParam.nRow2 = aRange.aEnd.Row();
5948 //! TODO: could we get passed a valid result set by any means?
5950 pDocSh->GetDBData( aRange, SC_DB_MAKE, SC_DBSEL_FORCE_MARK ); // ggf. Bereich anlegen
5952 ScDBDocFunc aFunc(*pDocSh); // Bereich muss angelegt sein
5953 aFunc.DoImport( nTab, aParam, NULL, true ); //! Api-Flag as parameter
5957 // XCellFormatRangesSupplier
5959 uno::Reference<container::XIndexAccess> SAL_CALL ScCellRangeObj::getCellFormatRanges()
5960 throw(uno::RuntimeException)
5962 SolarMutexGuard aGuard;
5963 ScDocShell* pDocSh = GetDocShell();
5964 if ( pDocSh )
5965 return new ScCellFormatsObj( pDocSh, aRange );
5966 return NULL;
5969 // XUniqueCellFormatRangesSupplier
5971 uno::Reference<container::XIndexAccess> SAL_CALL ScCellRangeObj::getUniqueCellFormatRanges()
5972 throw(uno::RuntimeException)
5974 SolarMutexGuard aGuard;
5975 ScDocShell* pDocSh = GetDocShell();
5976 if ( pDocSh )
5977 return new ScUniqueCellFormatsObj( pDocSh, aRange );
5978 return NULL;
5981 // XPropertySet erweitert fuer Range-Properties
5983 uno::Reference<beans::XPropertySetInfo> SAL_CALL ScCellRangeObj::getPropertySetInfo()
5984 throw(uno::RuntimeException)
5986 SolarMutexGuard aGuard;
5987 static uno::Reference<beans::XPropertySetInfo> aRef(
5988 new SfxItemPropertySetInfo( pRangePropSet->getPropertyMap() ));
5989 return aRef;
5992 void ScCellRangeObj::SetOnePropertyValue( const SfxItemPropertySimpleEntry* pEntry, const uno::Any& aValue )
5993 throw(lang::IllegalArgumentException, uno::RuntimeException)
5995 // Range has only Position and Size in addition to ScCellRangesBase, both are ReadOnly
5996 // -> nothing to do here
5998 ScCellRangesBase::SetOnePropertyValue( pEntry, aValue );
6001 void ScCellRangeObj::GetOnePropertyValue( const SfxItemPropertySimpleEntry* pEntry,
6002 uno::Any& rAny )
6003 throw(uno::RuntimeException)
6005 if ( pEntry )
6007 if ( pEntry->nWID == SC_WID_UNO_POS )
6009 ScDocShell* pDocSh = GetDocShell();
6010 if (pDocSh)
6012 // GetMMRect converts using HMM_PER_TWIPS, like the DrawingLayer
6013 Rectangle aMMRect(pDocSh->GetDocument()->GetMMRect(
6014 aRange.aStart.Col(), aRange.aStart.Row(),
6015 aRange.aEnd.Col(), aRange.aEnd.Row(), aRange.aStart.Tab() ));
6016 awt::Point aPos( aMMRect.Left(), aMMRect.Top() );
6017 rAny <<= aPos;
6020 else if ( pEntry->nWID == SC_WID_UNO_SIZE )
6022 ScDocShell* pDocSh = GetDocShell();
6023 if (pDocSh)
6025 // GetMMRect converts using HMM_PER_TWIPS, like the DrawingLayer
6026 Rectangle aMMRect = pDocSh->GetDocument()->GetMMRect(
6027 aRange.aStart.Col(), aRange.aStart.Row(),
6028 aRange.aEnd.Col(), aRange.aEnd.Row(), aRange.aStart.Tab() );
6029 Size aSize(aMMRect.GetSize());
6030 awt::Size aAwtSize( aSize.Width(), aSize.Height() );
6031 rAny <<= aAwtSize;
6034 else
6035 ScCellRangesBase::GetOnePropertyValue( pEntry, rAny );
6040 const SfxItemPropertyMap& ScCellRangeObj::GetItemPropertyMap()
6042 return pRangePropSet->getPropertyMap();
6045 // XServiceInfo
6047 OUString SAL_CALL ScCellRangeObj::getImplementationName() throw(uno::RuntimeException)
6049 return OUString( "ScCellRangeObj" );
6052 sal_Bool SAL_CALL ScCellRangeObj::supportsService( const OUString& rServiceName )
6053 throw(uno::RuntimeException)
6055 return rServiceName.equalsAscii( SCSHEETCELLRANGE_SERVICE ) ||
6056 rServiceName.equalsAscii( SCCELLRANGE_SERVICE ) ||
6057 rServiceName.equalsAscii( SCCELLPROPERTIES_SERVICE ) ||
6058 rServiceName.equalsAscii( SCCHARPROPERTIES_SERVICE ) ||
6059 rServiceName.equalsAscii( SCPARAPROPERTIES_SERVICE );
6062 uno::Sequence<OUString> SAL_CALL ScCellRangeObj::getSupportedServiceNames()
6063 throw(uno::RuntimeException)
6065 uno::Sequence<OUString> aRet(5);
6066 OUString* pArray = aRet.getArray();
6067 pArray[0] = OUString( SCSHEETCELLRANGE_SERVICE );
6068 pArray[1] = OUString( SCCELLRANGE_SERVICE );
6069 pArray[2] = OUString( SCCELLPROPERTIES_SERVICE );
6070 pArray[3] = OUString( SCCHARPROPERTIES_SERVICE );
6071 pArray[4] = OUString( SCPARAPROPERTIES_SERVICE );
6072 return aRet;
6075 //------------------------------------------------------------------------
6077 const SvxItemPropertySet* ScCellObj::GetEditPropertySet()
6079 return lcl_GetEditPropertySet();
6082 const SfxItemPropertyMap& ScCellObj::GetCellPropertyMap()
6084 return lcl_GetCellPropertySet()->getPropertyMap();
6087 ScCellObj::ScCellObj(ScDocShell* pDocSh, const ScAddress& rP) :
6088 ScCellRangeObj( pDocSh, ScRange(rP,rP) ),
6089 pCellPropSet( lcl_GetCellPropertySet() ),
6090 aCellPos( rP ),
6091 nActionLockCount( 0 )
6093 // pUnoText is allocated on demand (GetUnoText)
6094 // can't be aggregated because getString/setString is handled here
6097 SvxUnoText& ScCellObj::GetUnoText()
6099 if (!mxUnoText.is())
6101 mxUnoText.set(new ScCellTextObj(GetDocShell(), aCellPos));
6102 if (nActionLockCount)
6104 ScCellEditSource* pEditSource =
6105 static_cast<ScCellEditSource*> (mxUnoText->GetEditSource());
6106 if (pEditSource)
6107 pEditSource->SetDoUpdateData(false);
6110 return *mxUnoText;
6113 ScCellObj::~ScCellObj()
6117 void ScCellObj::RefChanged()
6119 ScCellRangeObj::RefChanged();
6121 const ScRangeList& rRanges = GetRangeList();
6122 OSL_ENSURE(rRanges.size() == 1, "was fuer Ranges ?!?!");
6123 if ( !rRanges.empty() )
6125 const ScRange* pFirst = rRanges[ 0 ];
6126 aCellPos = pFirst->aStart;
6130 uno::Any SAL_CALL ScCellObj::queryInterface( const uno::Type& rType ) throw(uno::RuntimeException)
6132 SC_QUERYINTERFACE( table::XCell )
6133 SC_QUERYINTERFACE( table::XCell2 )
6134 SC_QUERYINTERFACE( sheet::XFormulaTokens )
6135 SC_QUERYINTERFACE( sheet::XCellAddressable )
6136 SC_QUERYINTERFACE( text::XText )
6137 SC_QUERYINTERFACE( text::XSimpleText )
6138 SC_QUERYINTERFACE( text::XTextRange )
6139 SC_QUERYINTERFACE( container::XEnumerationAccess )
6140 SC_QUERYINTERFACE( container::XElementAccess )
6141 SC_QUERYINTERFACE( sheet::XSheetAnnotationAnchor )
6142 SC_QUERYINTERFACE( text::XTextFieldsSupplier )
6143 SC_QUERYINTERFACE( document::XActionLockable )
6145 return ScCellRangeObj::queryInterface( rType );
6148 void SAL_CALL ScCellObj::acquire() throw()
6150 ScCellRangeObj::acquire();
6153 void SAL_CALL ScCellObj::release() throw()
6155 ScCellRangeObj::release();
6158 uno::Sequence<uno::Type> SAL_CALL ScCellObj::getTypes() throw(uno::RuntimeException)
6160 static uno::Sequence<uno::Type> aTypes;
6161 if ( aTypes.getLength() == 0 )
6163 uno::Sequence<uno::Type> aParentTypes(ScCellRangeObj::getTypes());
6164 long nParentLen = aParentTypes.getLength();
6165 const uno::Type* pParentPtr = aParentTypes.getConstArray();
6167 aTypes.realloc( nParentLen + 9 );
6168 uno::Type* pPtr = aTypes.getArray();
6169 pPtr[nParentLen + 0] = getCppuType((const uno::Reference<table::XCell>*)0);
6170 pPtr[nParentLen + 1] = getCppuType((const uno::Reference<sheet::XCellAddressable>*)0);
6171 pPtr[nParentLen + 2] = getCppuType((const uno::Reference<text::XText>*)0);
6172 pPtr[nParentLen + 3] = getCppuType((const uno::Reference<container::XEnumerationAccess>*)0);
6173 pPtr[nParentLen + 4] = getCppuType((const uno::Reference<sheet::XSheetAnnotationAnchor>*)0);
6174 pPtr[nParentLen + 5] = getCppuType((const uno::Reference<text::XTextFieldsSupplier>*)0);
6175 pPtr[nParentLen + 6] = getCppuType((const uno::Reference<document::XActionLockable>*)0);
6176 pPtr[nParentLen + 7] = getCppuType((const uno::Reference<sheet::XFormulaTokens>*)0);
6177 pPtr[nParentLen + 8] = getCppuType((const uno::Reference<table::XCell2>*)0);
6179 for (long i=0; i<nParentLen; i++)
6180 pPtr[i] = pParentPtr[i]; // parent types first
6182 return aTypes;
6185 namespace
6187 class theScCellObjImplementationId : public rtl::Static< UnoTunnelIdInit, theScCellObjImplementationId > {};
6190 uno::Sequence<sal_Int8> SAL_CALL ScCellObj::getImplementationId() throw(uno::RuntimeException)
6192 return theScCellObjImplementationId::get().getSeq();
6195 // Hilfsfunktionen
6197 OUString ScCellObj::GetInputString_Impl(bool bEnglish) const // fuer getFormula / FormulaLocal
6199 if (GetDocShell())
6200 return lcl_GetInputString( GetDocShell()->GetDocument(), aCellPos, bEnglish );
6201 return OUString();
6204 OUString ScCellObj::GetOutputString_Impl(ScDocument* pDoc, const ScAddress& aCellPos)
6206 if (!pDoc)
6207 return EMPTY_OUSTRING;
6209 ScRefCellValue aCell;
6210 aCell.assign(*pDoc, aCellPos);
6212 if (aCell.isEmpty())
6213 return EMPTY_OUSTRING;
6215 OUString aVal;
6217 if (aCell.meType == CELLTYPE_EDIT)
6219 // GetString an der EditCell macht Leerzeichen aus Umbruechen,
6220 // hier werden die Umbrueche aber gebraucht
6221 const EditTextObject* pData = aCell.mpEditText;
6222 if (pData)
6224 EditEngine& rEngine = pDoc->GetEditEngine();
6225 rEngine.SetText(*pData);
6226 aVal = rEngine.GetText(LINEEND_LF);
6228 // Edit-Zellen auch nicht per NumberFormatter formatieren
6229 // (passend zur Ausgabe)
6231 else
6233 // wie in GetString am Dokument (column)
6234 Color* pColor;
6235 sal_uLong nNumFmt = pDoc->GetNumberFormat( aCellPos );
6236 aVal = ScCellFormat::GetString(*pDoc, aCellPos, nNumFmt, &pColor, *pDoc->GetFormatTable());
6238 return aVal;
6241 OUString ScCellObj::GetOutputString_Impl() const
6243 ScDocShell* pDocSh = GetDocShell();
6244 OUString aVal;
6245 if ( pDocSh )
6246 aVal = GetOutputString_Impl(pDocSh->GetDocument(), aCellPos);
6247 return aVal;
6250 void ScCellObj::SetString_Impl(const OUString& rString, sal_Bool bInterpret, sal_Bool bEnglish)
6252 ScDocShell* pDocSh = GetDocShell();
6253 if ( pDocSh )
6255 // GRAM_PODF_A1 for API compatibility.
6256 (void)pDocSh->GetDocFunc().SetCellText(
6257 aCellPos, rString, bInterpret, bEnglish, true, formula::FormulaGrammar::GRAM_PODF_A1 );
6261 double ScCellObj::GetValue_Impl() const
6263 ScDocShell* pDocSh = GetDocShell();
6264 if ( pDocSh )
6265 return pDocSh->GetDocument()->GetValue( aCellPos );
6267 return 0.0;
6270 void ScCellObj::SetValue_Impl(double fValue)
6272 ScDocShell* pDocSh = GetDocShell();
6273 if ( pDocSh )
6274 pDocSh->GetDocFunc().SetValueCell(aCellPos, fValue, false);
6277 // only for XML import
6279 void ScCellObj::InputEnglishString( const OUString& rText )
6281 // This is like a mixture of setFormula and property FormulaLocal:
6282 // The cell's number format is checked for "text", a new cell format may be set,
6283 // but all parsing is in English.
6285 ScDocShell* pDocSh = GetDocShell();
6286 if (!pDocSh)
6287 return;
6289 OUString aString(rText);
6290 ScDocument* pDoc = pDocSh->GetDocument();
6291 SvNumberFormatter* pFormatter = pDoc->GetFormatTable();
6292 sal_uInt32 nOldFormat = pDoc->GetNumberFormat( aCellPos );
6293 if (pFormatter->GetType(nOldFormat) == NUMBERFORMAT_TEXT)
6295 SetString_Impl(aString, false, false); // text cell
6296 return;
6299 ScDocFunc &rFunc = pDocSh->GetDocFunc();
6301 ScInputStringType aRes =
6302 ScStringUtil::parseInputString(*pFormatter, aString, LANGUAGE_ENGLISH_US);
6304 if (aRes.meType != ScInputStringType::Unknown)
6306 if ((nOldFormat % SV_COUNTRY_LANGUAGE_OFFSET) == 0 && aRes.mnFormatType)
6308 // apply a format for the recognized type and the old format's language
6309 sal_uInt32 nNewFormat = ScGlobal::GetStandardFormat(*pFormatter, nOldFormat, aRes.mnFormatType);
6310 if (nNewFormat != nOldFormat)
6312 ScPatternAttr aPattern( pDoc->GetPool() );
6313 aPattern.GetItemSet().Put( SfxUInt32Item( ATTR_VALUE_FORMAT, nNewFormat ) );
6314 // ATTR_LANGUAGE_FORMAT remains unchanged
6315 rFunc.ApplyAttributes( *GetMarkData(), aPattern, true, true );
6319 switch (aRes.meType)
6321 case ScInputStringType::Formula:
6322 rFunc.SetFormulaCell(
6323 aCellPos,
6324 new ScFormulaCell(pDoc, aCellPos, aRes.maText, formula::FormulaGrammar::GRAM_PODF_A1),
6325 false);
6326 break;
6327 case ScInputStringType::Number:
6328 rFunc.SetValueCell(aCellPos, aRes.mfValue, false);
6329 break;
6330 case ScInputStringType::Text:
6331 rFunc.SetStringOrEditCell(aCellPos, aRes.maText, false);
6332 break;
6333 default:
6334 SetString_Impl(aString, false, false); // probably empty string
6338 // XText
6340 uno::Reference<text::XTextCursor> SAL_CALL ScCellObj::createTextCursor()
6341 throw(uno::RuntimeException)
6343 SolarMutexGuard aGuard;
6344 return new ScCellTextCursor( *this );
6347 uno::Reference<text::XTextCursor> SAL_CALL ScCellObj::createTextCursorByRange(
6348 const uno::Reference<text::XTextRange>& aTextPosition )
6349 throw(uno::RuntimeException)
6351 SolarMutexGuard aGuard;
6352 SvxUnoTextCursor* pCursor = new ScCellTextCursor( *this );
6353 uno::Reference<text::XTextCursor> xCursor(pCursor);
6355 SvxUnoTextRangeBase* pRange = SvxUnoTextRangeBase::getImplementation( aTextPosition );
6356 if(pRange)
6357 pCursor->SetSelection( pRange->GetSelection() );
6358 else
6360 ScCellTextCursor* pOther = ScCellTextCursor::getImplementation( aTextPosition );
6361 if(pOther)
6362 pCursor->SetSelection( pOther->GetSelection() );
6363 else
6364 throw uno::RuntimeException();
6367 return xCursor;
6370 OUString SAL_CALL ScCellObj::getString() throw(uno::RuntimeException)
6372 SolarMutexGuard aGuard;
6373 return GetOutputString_Impl();
6376 void SAL_CALL ScCellObj::setString( const OUString& aText ) throw(uno::RuntimeException)
6378 SolarMutexGuard aGuard;
6379 OUString aString(aText);
6380 SetString_Impl(aString, false, false); // immer Text
6382 // don't create pUnoText here if not there
6383 if (mxUnoText.is())
6384 mxUnoText->SetSelection(ESelection( 0,0, 0,aString.getLength() ));
6387 void SAL_CALL ScCellObj::insertString( const uno::Reference<text::XTextRange>& xRange,
6388 const OUString& aString, sal_Bool bAbsorb )
6389 throw(uno::RuntimeException)
6391 // special handling for ScCellTextCursor is no longer needed,
6392 // SvxUnoText::insertString checks for SvxUnoTextRangeBase instead of SvxUnoTextRange
6394 SolarMutexGuard aGuard;
6395 GetUnoText().insertString(xRange, aString, bAbsorb);
6398 void SAL_CALL ScCellObj::insertControlCharacter( const uno::Reference<text::XTextRange>& xRange,
6399 sal_Int16 nControlCharacter, sal_Bool bAbsorb )
6400 throw(lang::IllegalArgumentException, uno::RuntimeException)
6402 SolarMutexGuard aGuard;
6403 GetUnoText().insertControlCharacter(xRange, nControlCharacter, bAbsorb);
6406 void SAL_CALL ScCellObj::insertTextContent( const uno::Reference<text::XTextRange >& xRange,
6407 const uno::Reference<text::XTextContent >& xContent,
6408 sal_Bool bAbsorb )
6409 throw(lang::IllegalArgumentException, uno::RuntimeException)
6411 SolarMutexGuard aGuard;
6412 ScDocShell* pDocSh = GetDocShell();
6413 if ( pDocSh && xContent.is() )
6415 ScEditFieldObj* pCellField = ScEditFieldObj::getImplementation(xContent);
6416 SvxUnoTextRangeBase* pTextRange = ScCellTextCursor::getImplementation( xRange );
6418 if ( pCellField && !pCellField->IsInserted() && pTextRange )
6420 SvxEditSource* pEditSource = pTextRange->GetEditSource();
6421 ESelection aSelection(pTextRange->GetSelection());
6423 if (!bAbsorb)
6425 // nicht ersetzen -> hinten anhaengen
6426 aSelection.Adjust();
6427 aSelection.nStartPara = aSelection.nEndPara;
6428 aSelection.nStartPos = aSelection.nEndPos;
6431 if (pCellField->GetFieldType() == text::textfield::Type::TABLE)
6432 pCellField->setPropertyValue(SC_UNONAME_TABLEPOS, uno::makeAny<sal_Int32>(aCellPos.Tab()));
6434 SvxFieldItem aItem = pCellField->CreateFieldItem();
6435 SvxTextForwarder* pForwarder = pEditSource->GetTextForwarder();
6436 pForwarder->QuickInsertField( aItem, aSelection );
6437 pEditSource->UpdateData();
6439 // neue Selektion: ein Zeichen
6440 aSelection.Adjust();
6441 aSelection.nEndPara = aSelection.nStartPara;
6442 aSelection.nEndPos = aSelection.nStartPos + 1;
6443 uno::Reference<text::XTextRange> xParent(this);
6444 pCellField->InitDoc(
6445 xParent, new ScCellEditSource(pDocSh, aCellPos), aSelection);
6447 // for bAbsorb=FALSE, the new selection must be behind the inserted content
6448 // (the xml filter relies on this)
6449 if (!bAbsorb)
6450 aSelection.nStartPos = aSelection.nEndPos;
6452 pTextRange->SetSelection( aSelection );
6454 return;
6457 GetUnoText().insertTextContent(xRange, xContent, bAbsorb);
6460 void SAL_CALL ScCellObj::removeTextContent( const uno::Reference<text::XTextContent>& xContent )
6461 throw(container::NoSuchElementException, uno::RuntimeException)
6463 SolarMutexGuard aGuard;
6464 if ( xContent.is() )
6466 ScEditFieldObj* pCellField = ScEditFieldObj::getImplementation(xContent);
6467 if ( pCellField && pCellField->IsInserted() )
6469 //! Testen, ob das Feld in dieser Zelle ist
6470 pCellField->DeleteField();
6471 return;
6474 GetUnoText().removeTextContent(xContent);
6477 uno::Reference<text::XText> SAL_CALL ScCellObj::getText() throw(uno::RuntimeException)
6479 SolarMutexGuard aGuard;
6480 return this;
6483 uno::Reference<text::XTextRange> SAL_CALL ScCellObj::getStart() throw(uno::RuntimeException)
6485 SolarMutexGuard aGuard;
6486 return GetUnoText().getStart();
6489 uno::Reference<text::XTextRange> SAL_CALL ScCellObj::getEnd() throw(uno::RuntimeException)
6491 SolarMutexGuard aGuard;
6492 return GetUnoText().getEnd();
6495 uno::Reference<container::XEnumeration> SAL_CALL ScCellObj::createEnumeration()
6496 throw(uno::RuntimeException)
6498 SolarMutexGuard aGuard;
6499 return GetUnoText().createEnumeration();
6502 uno::Type SAL_CALL ScCellObj::getElementType() throw(uno::RuntimeException)
6504 SolarMutexGuard aGuard;
6505 return GetUnoText().getElementType();
6508 sal_Bool SAL_CALL ScCellObj::hasElements() throw(uno::RuntimeException)
6510 SolarMutexGuard aGuard;
6511 return GetUnoText().hasElements();
6514 // XCell
6516 OUString SAL_CALL ScCellObj::getFormula() throw(uno::RuntimeException)
6518 SolarMutexGuard aGuard;
6519 return GetInputString_Impl( true /* English */ );
6522 void SAL_CALL ScCellObj::setFormula( const OUString& aFormula ) throw(uno::RuntimeException)
6524 SolarMutexGuard aGuard;
6525 OUString aString(aFormula);
6526 SetString_Impl(aString, sal_True, sal_True); // Interpret as English
6529 double SAL_CALL ScCellObj::getValue() throw(uno::RuntimeException)
6531 SolarMutexGuard aGuard;
6532 return GetValue_Impl();
6535 void SAL_CALL ScCellObj::setValue( double nValue ) throw(uno::RuntimeException)
6537 SolarMutexGuard aGuard;
6538 SetValue_Impl(nValue);
6541 void SAL_CALL ScCellObj::setFormulaString( const OUString& aFormula) throw(uno::RuntimeException)
6543 SolarMutexGuard aGuard;
6544 ScDocShell *pDocSh = GetDocShell();
6545 if( pDocSh )
6547 ScFormulaCell* pCell = new ScFormulaCell( pDocSh->GetDocument(), aCellPos );
6548 pCell->SetHybridFormula( aFormula, formula::FormulaGrammar::GRAM_NATIVE );
6549 pDocSh->GetDocFunc().SetFormulaCell(aCellPos, pCell, false);
6552 void SAL_CALL ScCellObj::setFormulaResult( double nValue ) throw(uno::RuntimeException)
6554 SolarMutexGuard aGuard;
6555 ScDocShell* pDocSh = GetDocShell();
6556 if ( pDocSh && pDocSh->GetDocument()->GetCellType( aCellPos ) == CELLTYPE_FORMULA )
6558 ScFormulaCell* pCell = pDocSh->GetDocument()->GetFormulaCell(aCellPos);
6559 pCell->SetHybridDouble( nValue );
6560 pCell->ResetDirty();
6561 pCell->SetChanged(false);
6565 table::CellContentType SAL_CALL ScCellObj::getType() throw(uno::RuntimeException)
6567 SolarMutexGuard aGuard;
6568 table::CellContentType eRet = table::CellContentType_EMPTY;
6569 ScDocShell* pDocSh = GetDocShell();
6570 if (pDocSh)
6572 CellType eCalcType = pDocSh->GetDocument()->GetCellType( aCellPos );
6573 switch (eCalcType)
6575 case CELLTYPE_VALUE:
6576 eRet = table::CellContentType_VALUE;
6577 break;
6578 case CELLTYPE_STRING:
6579 case CELLTYPE_EDIT:
6580 eRet = table::CellContentType_TEXT;
6581 break;
6582 case CELLTYPE_FORMULA:
6583 eRet = table::CellContentType_FORMULA;
6584 break;
6585 default:
6586 eRet = table::CellContentType_EMPTY;
6589 else
6591 OSL_FAIL("keine DocShell"); //! Exception oder so?
6594 return eRet;
6597 table::CellContentType ScCellObj::GetResultType_Impl()
6599 ScDocShell* pDocSh = GetDocShell();
6600 if ( pDocSh )
6602 ScRefCellValue aCell;
6603 aCell.assign(*pDocSh->GetDocument(), aCellPos);
6604 if (aCell.meType == CELLTYPE_FORMULA)
6606 bool bValue = aCell.mpFormula->IsValue();
6607 return bValue ? table::CellContentType_VALUE : table::CellContentType_TEXT;
6610 return getType(); // wenn keine Formel
6613 sal_Int32 SAL_CALL ScCellObj::getError() throw(uno::RuntimeException)
6615 SolarMutexGuard aGuard;
6616 ScDocShell* pDocSh = GetDocShell();
6617 if (!pDocSh)
6619 OSL_FAIL("keine DocShell"); //! Exception oder so?
6620 return 0;
6623 sal_uInt16 nError = 0;
6624 ScRefCellValue aCell;
6625 aCell.assign(*pDocSh->GetDocument(), aCellPos);
6626 if (aCell.meType == CELLTYPE_FORMULA)
6627 nError = aCell.mpFormula->GetErrCode();
6629 return nError;
6632 // XFormulaTokens
6634 uno::Sequence<sheet::FormulaToken> SAL_CALL ScCellObj::getTokens() throw(uno::RuntimeException)
6636 SolarMutexGuard aGuard;
6637 uno::Sequence<sheet::FormulaToken> aSequence;
6638 ScDocShell* pDocSh = GetDocShell();
6639 if (!pDocSh)
6640 return aSequence;
6642 ScDocument* pDoc = pDocSh->GetDocument();
6643 ScRefCellValue aCell;
6644 aCell.assign(*pDoc, aCellPos);
6645 if (aCell.meType == CELLTYPE_FORMULA)
6647 ScTokenArray* pTokenArray = aCell.mpFormula->GetCode();
6648 if (pTokenArray)
6649 ScTokenConversion::ConvertToTokenSequence(*pDoc, aSequence, *pTokenArray);
6651 return aSequence;
6654 void SAL_CALL ScCellObj::setTokens( const uno::Sequence<sheet::FormulaToken>& rTokens ) throw(uno::RuntimeException)
6656 SolarMutexGuard aGuard;
6657 ScDocShell* pDocSh = GetDocShell();
6658 if ( pDocSh )
6660 ScDocument* pDoc = pDocSh->GetDocument();
6661 ScTokenArray aTokenArray;
6662 (void)ScTokenConversion::ConvertToTokenArray( *pDoc, aTokenArray, rTokens );
6664 ScFormulaCell* pNewCell = new ScFormulaCell(pDoc, aCellPos, aTokenArray);
6665 (void)pDocSh->GetDocFunc().SetFormulaCell(aCellPos, pNewCell, false);
6669 // XCellAddressable
6671 table::CellAddress SAL_CALL ScCellObj::getCellAddress() throw(uno::RuntimeException)
6673 SolarMutexGuard aGuard;
6674 table::CellAddress aAdr;
6675 aAdr.Sheet = aCellPos.Tab();
6676 aAdr.Column = aCellPos.Col();
6677 aAdr.Row = aCellPos.Row();
6678 return aAdr;
6681 // XSheetAnnotationAnchor
6683 uno::Reference<sheet::XSheetAnnotation> SAL_CALL ScCellObj::getAnnotation()
6684 throw(uno::RuntimeException)
6686 SolarMutexGuard aGuard;
6687 ScDocShell* pDocSh = GetDocShell();
6688 if ( pDocSh )
6689 return new ScAnnotationObj( pDocSh, aCellPos );
6691 OSL_FAIL("getAnnotation ohne DocShell");
6692 return NULL;
6695 // XFieldTypesSupplier
6697 uno::Reference<container::XEnumerationAccess> SAL_CALL ScCellObj::getTextFields()
6698 throw(uno::RuntimeException)
6700 SolarMutexGuard aGuard;
6701 ScDocShell* pDocSh = GetDocShell();
6702 if ( pDocSh )
6704 uno::Reference<text::XTextRange> xContent(this);
6705 return new ScCellFieldsObj(xContent, pDocSh, aCellPos);
6708 return NULL;
6711 uno::Reference<container::XNameAccess> SAL_CALL ScCellObj::getTextFieldMasters()
6712 throw(uno::RuntimeException)
6714 // sowas gibts nicht im Calc (?)
6715 return NULL;
6718 // XPropertySet erweitert fuer Zell-Properties
6720 uno::Reference<beans::XPropertySetInfo> SAL_CALL ScCellObj::getPropertySetInfo()
6721 throw(uno::RuntimeException)
6723 SolarMutexGuard aGuard;
6724 static uno::Reference<beans::XPropertySetInfo> aRef(
6725 new SfxItemPropertySetInfo( pCellPropSet->getPropertyMap() ));
6726 return aRef;
6729 void ScCellObj::SetOnePropertyValue( const SfxItemPropertySimpleEntry* pEntry, const uno::Any& aValue )
6730 throw(lang::IllegalArgumentException, uno::RuntimeException)
6732 if ( pEntry )
6734 if ( pEntry->nWID == SC_WID_UNO_FORMLOC )
6736 OUString aStrVal;
6737 aValue >>= aStrVal;
6738 OUString aString(aStrVal);
6739 SetString_Impl(aString, sal_True, false); // lokal interpretieren
6741 else if ( pEntry->nWID == SC_WID_UNO_FORMRT )
6743 // Read-Only
6744 //! Exception oder so...
6746 else
6747 ScCellRangeObj::SetOnePropertyValue( pEntry, aValue );
6751 void ScCellObj::GetOnePropertyValue( const SfxItemPropertySimpleEntry* pEntry,
6752 uno::Any& rAny )
6753 throw(uno::RuntimeException)
6755 if ( pEntry )
6757 if ( pEntry->nWID == SC_WID_UNO_FORMLOC )
6759 // sal_False = lokal
6760 rAny <<= OUString( GetInputString_Impl(false) );
6762 else if ( pEntry->nWID == SC_WID_UNO_FORMRT )
6764 table::CellContentType eType = GetResultType_Impl();
6765 rAny <<= eType;
6767 else
6768 ScCellRangeObj::GetOnePropertyValue(pEntry, rAny);
6772 const SfxItemPropertyMap& ScCellObj::GetItemPropertyMap()
6774 return pCellPropSet->getPropertyMap();
6777 // XServiceInfo
6779 OUString SAL_CALL ScCellObj::getImplementationName() throw(uno::RuntimeException)
6781 return OUString( "ScCellObj" );
6784 sal_Bool SAL_CALL ScCellObj::supportsService( const OUString& rServiceName )
6785 throw(uno::RuntimeException)
6787 // CellRange/SheetCellRange are not in SheetCell service description,
6788 // but ScCellObj is used instead of ScCellRangeObj in CellRanges collections,
6789 // so it must support them
6791 return rServiceName.equalsAscii( SCSHEETCELL_SERVICE ) ||
6792 rServiceName.equalsAscii( SCCELL_SERVICE ) ||
6793 rServiceName.equalsAscii( SCCELLPROPERTIES_SERVICE ) ||
6794 rServiceName.equalsAscii( SCCHARPROPERTIES_SERVICE ) ||
6795 rServiceName.equalsAscii( SCPARAPROPERTIES_SERVICE ) ||
6796 rServiceName.equalsAscii( SCSHEETCELLRANGE_SERVICE ) ||
6797 rServiceName.equalsAscii( SCCELLRANGE_SERVICE );
6800 uno::Sequence<OUString> SAL_CALL ScCellObj::getSupportedServiceNames()
6801 throw(uno::RuntimeException)
6803 uno::Sequence<OUString> aRet(7);
6804 OUString* pArray = aRet.getArray();
6805 pArray[0] = OUString( SCSHEETCELL_SERVICE );
6806 pArray[1] = OUString( SCCELL_SERVICE );
6807 pArray[2] = OUString( SCCELLPROPERTIES_SERVICE );
6808 pArray[3] = OUString( SCCHARPROPERTIES_SERVICE );
6809 pArray[4] = OUString( SCPARAPROPERTIES_SERVICE );
6810 pArray[5] = OUString( SCSHEETCELLRANGE_SERVICE );
6811 pArray[6] = OUString( SCCELLRANGE_SERVICE );
6812 return aRet;
6815 // XActionLockable
6817 sal_Bool SAL_CALL ScCellObj::isActionLocked() throw(uno::RuntimeException)
6819 SolarMutexGuard aGuard;
6820 return nActionLockCount != 0;
6823 void SAL_CALL ScCellObj::addActionLock() throw(uno::RuntimeException)
6825 SolarMutexGuard aGuard;
6826 if (!nActionLockCount)
6828 if (mxUnoText.is())
6830 ScCellEditSource* pEditSource =
6831 static_cast<ScCellEditSource*> (mxUnoText->GetEditSource());
6832 if (pEditSource)
6833 pEditSource->SetDoUpdateData(false);
6836 nActionLockCount++;
6839 void SAL_CALL ScCellObj::removeActionLock() throw(uno::RuntimeException)
6841 SolarMutexGuard aGuard;
6842 if (nActionLockCount > 0)
6844 nActionLockCount--;
6845 if (!nActionLockCount)
6847 if (mxUnoText.is())
6849 ScCellEditSource* pEditSource =
6850 static_cast<ScCellEditSource*> (mxUnoText->GetEditSource());
6851 if (pEditSource)
6853 pEditSource->SetDoUpdateData(sal_True);
6854 if (pEditSource->IsDirty())
6855 pEditSource->UpdateData();
6862 void SAL_CALL ScCellObj::setActionLocks( sal_Int16 nLock ) throw(uno::RuntimeException)
6864 SolarMutexGuard aGuard;
6865 if (mxUnoText.is())
6867 ScCellEditSource* pEditSource =
6868 static_cast<ScCellEditSource*> (mxUnoText->GetEditSource());
6869 if (pEditSource)
6871 pEditSource->SetDoUpdateData(nLock == 0);
6872 if ((nActionLockCount > 0) && (nLock == 0) && pEditSource->IsDirty())
6873 pEditSource->UpdateData();
6876 nActionLockCount = nLock;
6879 sal_Int16 SAL_CALL ScCellObj::resetActionLocks() throw(uno::RuntimeException)
6881 SolarMutexGuard aGuard;
6882 sal_uInt16 nRet(nActionLockCount);
6883 if (mxUnoText.is())
6885 ScCellEditSource* pEditSource =
6886 static_cast<ScCellEditSource*> (mxUnoText->GetEditSource());
6887 if (pEditSource)
6889 pEditSource->SetDoUpdateData(sal_True);
6890 if (pEditSource->IsDirty())
6891 pEditSource->UpdateData();
6894 nActionLockCount = 0;
6895 return nRet;
6898 //------------------------------------------------------------------------
6900 ScTableSheetObj::ScTableSheetObj( ScDocShell* pDocSh, SCTAB nTab ) :
6901 ScCellRangeObj( pDocSh, ScRange(0,0,nTab, MAXCOL,MAXROW,nTab) ),
6902 pSheetPropSet(lcl_GetSheetPropertySet())
6906 ScTableSheetObj::~ScTableSheetObj()
6910 void ScTableSheetObj::RefChanged()
6912 // skip calling immediate base
6913 // class ScCellRangeObj::RefChanged as
6914 // it changes the Sheets range ( which shouldn't
6915 // happen ) - hmm maybe we don't even need to
6916 // call ScCellRangesBase::RefChanged() :/
6918 ScCellRangesBase::RefChanged();
6921 void ScTableSheetObj::InitInsertSheet(ScDocShell* pDocSh, SCTAB nTab)
6923 InitInsertRange( pDocSh, ScRange(0,0,nTab, MAXCOL,MAXROW,nTab) );
6926 uno::Any SAL_CALL ScTableSheetObj::queryInterface( const uno::Type& rType ) throw(uno::RuntimeException)
6928 SC_QUERYINTERFACE( sheet::XSpreadsheet )
6929 SC_QUERYINTERFACE( container::XNamed )
6930 SC_QUERYINTERFACE( sheet::XSheetPageBreak )
6931 SC_QUERYINTERFACE( sheet::XCellRangeMovement )
6932 SC_QUERYINTERFACE( table::XTableChartsSupplier )
6933 SC_QUERYINTERFACE( sheet::XDataPilotTablesSupplier )
6934 SC_QUERYINTERFACE( sheet::XScenariosSupplier )
6935 SC_QUERYINTERFACE( sheet::XSheetAnnotationsSupplier )
6936 SC_QUERYINTERFACE( drawing::XDrawPageSupplier )
6937 SC_QUERYINTERFACE( sheet::XPrintAreas )
6938 SC_QUERYINTERFACE( sheet::XSheetAuditing )
6939 SC_QUERYINTERFACE( sheet::XSheetOutline )
6940 SC_QUERYINTERFACE( util::XProtectable )
6941 SC_QUERYINTERFACE( sheet::XScenario )
6942 SC_QUERYINTERFACE( sheet::XScenarioEnhanced )
6943 SC_QUERYINTERFACE( sheet::XSheetLinkable )
6944 SC_QUERYINTERFACE( sheet::XExternalSheetName )
6945 SC_QUERYINTERFACE( document::XEventsSupplier )
6947 return ScCellRangeObj::queryInterface( rType );
6950 void SAL_CALL ScTableSheetObj::acquire() throw()
6952 ScCellRangeObj::acquire();
6955 void SAL_CALL ScTableSheetObj::release() throw()
6957 ScCellRangeObj::release();
6960 uno::Sequence<uno::Type> SAL_CALL ScTableSheetObj::getTypes() throw(uno::RuntimeException)
6962 static uno::Sequence<uno::Type> aTypes;
6963 if ( aTypes.getLength() == 0 )
6965 uno::Sequence<uno::Type> aParentTypes = ScCellRangeObj::getTypes();
6966 long nParentLen = aParentTypes.getLength();
6967 const uno::Type* pParentPtr = aParentTypes.getConstArray();
6969 aTypes.realloc( nParentLen + 18 );
6970 uno::Type* pPtr = aTypes.getArray();
6971 pPtr[nParentLen + 0] = getCppuType((const uno::Reference<sheet::XSpreadsheet>*)0);
6972 pPtr[nParentLen + 1] = getCppuType((const uno::Reference<container::XNamed>*)0);
6973 pPtr[nParentLen + 2] = getCppuType((const uno::Reference<sheet::XSheetPageBreak>*)0);
6974 pPtr[nParentLen + 3] = getCppuType((const uno::Reference<sheet::XCellRangeMovement>*)0);
6975 pPtr[nParentLen + 4] = getCppuType((const uno::Reference<table::XTableChartsSupplier>*)0);
6976 pPtr[nParentLen + 5] = getCppuType((const uno::Reference<sheet::XDataPilotTablesSupplier>*)0);
6977 pPtr[nParentLen + 6] = getCppuType((const uno::Reference<sheet::XScenariosSupplier>*)0);
6978 pPtr[nParentLen + 7] = getCppuType((const uno::Reference<sheet::XSheetAnnotationsSupplier>*)0);
6979 pPtr[nParentLen + 8] = getCppuType((const uno::Reference<drawing::XDrawPageSupplier>*)0);
6980 pPtr[nParentLen + 9] = getCppuType((const uno::Reference<sheet::XPrintAreas>*)0);
6981 pPtr[nParentLen +10] = getCppuType((const uno::Reference<sheet::XSheetAuditing>*)0);
6982 pPtr[nParentLen +11] = getCppuType((const uno::Reference<sheet::XSheetOutline>*)0);
6983 pPtr[nParentLen +12] = getCppuType((const uno::Reference<util::XProtectable>*)0);
6984 pPtr[nParentLen +13] = getCppuType((const uno::Reference<sheet::XScenario>*)0);
6985 pPtr[nParentLen +14] = getCppuType((const uno::Reference<sheet::XScenarioEnhanced>*)0);
6986 pPtr[nParentLen +15] = getCppuType((const uno::Reference<sheet::XSheetLinkable>*)0);
6987 pPtr[nParentLen +16] = getCppuType((const uno::Reference<sheet::XExternalSheetName>*)0);
6988 pPtr[nParentLen +17] = getCppuType((const uno::Reference<document::XEventsSupplier>*)0);
6990 for (long i=0; i<nParentLen; i++)
6991 pPtr[i] = pParentPtr[i]; // parent types first
6993 return aTypes;
6996 namespace
6998 class theScTableSheetObjImplementationId : public rtl::Static< UnoTunnelIdInit, theScTableSheetObjImplementationId > {};
7001 uno::Sequence<sal_Int8> SAL_CALL ScTableSheetObj::getImplementationId() throw(uno::RuntimeException)
7003 return theScTableSheetObjImplementationId::get().getSeq();
7006 // Hilfsfunktionen
7008 SCTAB ScTableSheetObj::GetTab_Impl() const
7010 const ScRangeList& rRanges = GetRangeList();
7011 OSL_ENSURE(rRanges.size() == 1, "was fuer Ranges ?!?!");
7012 if ( !rRanges.empty() )
7014 const ScRange* pFirst = rRanges[ 0 ];
7015 return pFirst->aStart.Tab();
7017 return 0; // soll nicht sein
7020 // former XSheet
7022 uno::Reference<table::XTableCharts> SAL_CALL ScTableSheetObj::getCharts() throw(uno::RuntimeException)
7024 SolarMutexGuard aGuard;
7025 ScDocShell* pDocSh = GetDocShell();
7026 if ( pDocSh )
7027 return new ScChartsObj( pDocSh, GetTab_Impl() );
7029 OSL_FAIL("kein Dokument");
7030 return NULL;
7033 uno::Reference<sheet::XDataPilotTables> SAL_CALL ScTableSheetObj::getDataPilotTables()
7034 throw(uno::RuntimeException)
7036 SolarMutexGuard aGuard;
7037 ScDocShell* pDocSh = GetDocShell();
7038 if ( pDocSh )
7039 return new ScDataPilotTablesObj( pDocSh, GetTab_Impl() );
7041 OSL_FAIL("kein Dokument");
7042 return NULL;
7045 uno::Reference<sheet::XScenarios> SAL_CALL ScTableSheetObj::getScenarios() throw(uno::RuntimeException)
7047 SolarMutexGuard aGuard;
7048 ScDocShell* pDocSh = GetDocShell();
7050 if ( pDocSh )
7051 return new ScScenariosObj( pDocSh, GetTab_Impl() );
7053 OSL_FAIL("kein Dokument");
7054 return NULL;
7057 uno::Reference<sheet::XSheetAnnotations> SAL_CALL ScTableSheetObj::getAnnotations()
7058 throw(uno::RuntimeException)
7060 SolarMutexGuard aGuard;
7061 ScDocShell* pDocSh = GetDocShell();
7063 if ( pDocSh )
7064 return new ScAnnotationsObj( pDocSh, GetTab_Impl() );
7066 OSL_FAIL("kein Dokument");
7067 return NULL;
7070 uno::Reference<table::XCellRange> SAL_CALL ScTableSheetObj::getCellRangeByName(
7071 const OUString& rRange ) throw(uno::RuntimeException)
7073 SolarMutexGuard aGuard;
7074 return ScCellRangeObj::getCellRangeByName( rRange );
7077 uno::Reference<sheet::XSheetCellCursor> SAL_CALL ScTableSheetObj::createCursor()
7078 throw(uno::RuntimeException)
7080 SolarMutexGuard aGuard;
7081 ScDocShell* pDocSh = GetDocShell();
7082 if ( pDocSh )
7084 //! einzelne Zelle oder ganze Tabelle???????
7085 SCTAB nTab = GetTab_Impl();
7086 return new ScCellCursorObj( pDocSh, ScRange( 0,0,nTab, MAXCOL,MAXROW,nTab ) );
7088 return NULL;
7091 uno::Reference<sheet::XSheetCellCursor> SAL_CALL ScTableSheetObj::createCursorByRange(
7092 const uno::Reference<sheet::XSheetCellRange>& xCellRange )
7093 throw(uno::RuntimeException)
7095 SolarMutexGuard aGuard;
7096 ScDocShell* pDocSh = GetDocShell();
7097 if ( pDocSh && xCellRange.is() )
7099 ScCellRangesBase* pRangesImp = ScCellRangesBase::getImplementation( xCellRange );
7100 if (pRangesImp)
7102 const ScRangeList& rRanges = pRangesImp->GetRangeList();
7103 OSL_ENSURE( rRanges.size() == 1, "Range? Ranges?" );
7104 return new ScCellCursorObj( pDocSh, *rRanges[ 0 ] );
7107 return NULL;
7110 // XSheetCellRange
7112 uno::Reference<sheet::XSpreadsheet> SAL_CALL ScTableSheetObj::getSpreadsheet()
7113 throw(uno::RuntimeException)
7115 SolarMutexGuard aGuard;
7116 return this; //!???
7119 // XCellRange
7121 uno::Reference<table::XCell> SAL_CALL ScTableSheetObj::getCellByPosition(
7122 sal_Int32 nColumn, sal_Int32 nRow )
7123 throw(lang::IndexOutOfBoundsException, uno::RuntimeException)
7125 SolarMutexGuard aGuard;
7126 return ScCellRangeObj::GetCellByPosition_Impl(nColumn, nRow);
7129 uno::Reference<table::XCellRange> SAL_CALL ScTableSheetObj::getCellRangeByPosition(
7130 sal_Int32 nLeft, sal_Int32 nTop, sal_Int32 nRight, sal_Int32 nBottom )
7131 throw(lang::IndexOutOfBoundsException, uno::RuntimeException)
7133 SolarMutexGuard aGuard;
7134 return ScCellRangeObj::getCellRangeByPosition(nLeft,nTop,nRight,nBottom);
7137 uno::Sequence<sheet::TablePageBreakData> SAL_CALL ScTableSheetObj::getColumnPageBreaks()
7138 throw(uno::RuntimeException)
7140 SolarMutexGuard aGuard;
7141 ScDocShell* pDocSh = GetDocShell();
7142 if ( pDocSh )
7144 ScDocument* pDoc = pDocSh->GetDocument();
7145 SCTAB nTab = GetTab_Impl();
7147 Size aSize(pDoc->GetPageSize( nTab ));
7148 if (aSize.Width() && aSize.Height()) // effektive Groesse schon gesetzt?
7149 pDoc->UpdatePageBreaks( nTab );
7150 else
7152 // Umbrueche updaten wie in ScDocShell::PageStyleModified:
7153 ScPrintFunc aPrintFunc( pDocSh, pDocSh->GetPrinter(), nTab );
7154 aPrintFunc.UpdatePages();
7157 SCCOL nCount = 0;
7158 SCCOL nCol;
7159 for (nCol=0; nCol<=MAXCOL; nCol++)
7160 if (pDoc->HasColBreak(nCol, nTab))
7161 ++nCount;
7163 sheet::TablePageBreakData aData;
7164 uno::Sequence<sheet::TablePageBreakData> aSeq(nCount);
7165 sheet::TablePageBreakData* pAry = aSeq.getArray();
7166 sal_uInt16 nPos = 0;
7167 for (nCol=0; nCol<=MAXCOL; nCol++)
7169 ScBreakType nBreak = pDoc->HasColBreak(nCol, nTab);
7170 if (nBreak)
7172 aData.Position = nCol;
7173 aData.ManualBreak = (nBreak & BREAK_MANUAL);
7174 pAry[nPos] = aData;
7175 ++nPos;
7178 return aSeq;
7180 return uno::Sequence<sheet::TablePageBreakData>(0);
7183 uno::Sequence<sheet::TablePageBreakData> SAL_CALL ScTableSheetObj::getRowPageBreaks()
7184 throw(uno::RuntimeException)
7186 SolarMutexGuard aGuard;
7187 ScDocShell* pDocSh = GetDocShell();
7188 if ( pDocSh )
7190 ScDocument* pDoc = pDocSh->GetDocument();
7191 SCTAB nTab = GetTab_Impl();
7193 Size aSize(pDoc->GetPageSize( nTab ));
7194 if (aSize.Width() && aSize.Height()) // effektive Groesse schon gesetzt?
7195 pDoc->UpdatePageBreaks( nTab );
7196 else
7198 // Umbrueche updaten wie in ScDocShell::PageStyleModified:
7199 ScPrintFunc aPrintFunc( pDocSh, pDocSh->GetPrinter(), nTab );
7200 aPrintFunc.UpdatePages();
7202 return pDoc->GetRowBreakData(nTab);
7204 return uno::Sequence<sheet::TablePageBreakData>(0);
7207 void SAL_CALL ScTableSheetObj::removeAllManualPageBreaks() throw(uno::RuntimeException)
7209 SolarMutexGuard aGuard;
7210 ScDocShell* pDocSh = GetDocShell();
7211 if ( pDocSh )
7213 //! docfunc Funktion, auch fuer ScViewFunc::RemoveManualBreaks
7215 ScDocument* pDoc = pDocSh->GetDocument();
7216 sal_Bool bUndo (pDoc->IsUndoEnabled());
7217 SCTAB nTab = GetTab_Impl();
7219 if (bUndo)
7221 ScDocument* pUndoDoc = new ScDocument( SCDOCMODE_UNDO );
7222 pUndoDoc->InitUndo( pDoc, nTab, nTab, sal_True, sal_True );
7223 pDoc->CopyToDocument( 0,0,nTab, MAXCOL,MAXROW,nTab, IDF_NONE, false, pUndoDoc );
7224 pDocSh->GetUndoManager()->AddUndoAction(
7225 new ScUndoRemoveBreaks( pDocSh, nTab, pUndoDoc ) );
7228 pDoc->RemoveManualBreaks(nTab);
7229 pDoc->UpdatePageBreaks(nTab);
7231 //? UpdatePageBreakData( sal_True );
7232 pDocSh->SetDocumentModified();
7233 pDocSh->PostPaint(ScRange(0, 0, nTab, MAXCOL, MAXROW, nTab), PAINT_GRID);
7237 // XNamed
7239 OUString SAL_CALL ScTableSheetObj::getName() throw(uno::RuntimeException)
7241 SolarMutexGuard aGuard;
7242 OUString aName;
7243 ScDocShell* pDocSh = GetDocShell();
7244 if ( pDocSh )
7245 pDocSh->GetDocument()->GetName( GetTab_Impl(), aName );
7246 return aName;
7249 void SAL_CALL ScTableSheetObj::setName( const OUString& aNewName )
7250 throw(uno::RuntimeException)
7252 SolarMutexGuard aGuard;
7253 ScDocShell* pDocSh = GetDocShell();
7254 if ( pDocSh )
7256 OUString aString(aNewName);
7257 pDocSh->GetDocFunc().RenameTable( GetTab_Impl(), aString, sal_True, sal_True );
7261 // XDrawPageSupplier
7263 uno::Reference<drawing::XDrawPage> SAL_CALL ScTableSheetObj::getDrawPage()
7264 throw(uno::RuntimeException)
7266 SolarMutexGuard aGuard;
7267 ScDocShell* pDocSh = GetDocShell();
7268 if ( pDocSh )
7270 ScDrawLayer* pDrawLayer = pDocSh->MakeDrawLayer();
7271 OSL_ENSURE(pDrawLayer,"kann Draw-Layer nicht anlegen");
7273 SCTAB nTab = GetTab_Impl();
7274 SdrPage* pPage = pDrawLayer->GetPage(static_cast<sal_uInt16>(nTab));
7275 OSL_ENSURE(pPage,"Draw-Page nicht gefunden");
7276 if (pPage)
7277 return uno::Reference<drawing::XDrawPage> (pPage->getUnoPage(), uno::UNO_QUERY);
7279 // Das DrawPage-Objekt meldet sich als Listener am SdrModel an
7280 // und sollte von dort alle Aktionen mitbekommen
7282 return NULL;
7285 // XCellMovement
7287 void SAL_CALL ScTableSheetObj::insertCells( const table::CellRangeAddress& rRangeAddress,
7288 sheet::CellInsertMode nMode ) throw(uno::RuntimeException)
7290 SolarMutexGuard aGuard;
7291 ScDocShell* pDocSh = GetDocShell();
7292 if ( pDocSh )
7294 sal_Bool bDo = sal_True;
7295 InsCellCmd eCmd = INS_NONE;
7296 switch (nMode)
7298 case sheet::CellInsertMode_NONE: bDo = false; break;
7299 case sheet::CellInsertMode_DOWN: eCmd = INS_CELLSDOWN; break;
7300 case sheet::CellInsertMode_RIGHT: eCmd = INS_CELLSRIGHT; break;
7301 case sheet::CellInsertMode_ROWS: eCmd = INS_INSROWS; break;
7302 case sheet::CellInsertMode_COLUMNS: eCmd = INS_INSCOLS; break;
7303 default:
7304 OSL_FAIL("insertCells: falscher Mode");
7305 bDo = false;
7308 if (bDo)
7310 OSL_ENSURE( rRangeAddress.Sheet == GetTab_Impl(), "falsche Tabelle in CellRangeAddress" );
7311 ScRange aScRange;
7312 ScUnoConversion::FillScRange( aScRange, rRangeAddress );
7313 pDocSh->GetDocFunc().InsertCells( aScRange, NULL, eCmd, sal_True, sal_True );
7318 void SAL_CALL ScTableSheetObj::removeRange( const table::CellRangeAddress& rRangeAddress,
7319 sheet::CellDeleteMode nMode ) throw(uno::RuntimeException)
7321 SolarMutexGuard aGuard;
7322 ScDocShell* pDocSh = GetDocShell();
7323 if ( pDocSh )
7325 sal_Bool bDo = sal_True;
7326 DelCellCmd eCmd = DEL_NONE;
7327 switch (nMode)
7329 case sheet::CellDeleteMode_NONE: bDo = false; break;
7330 case sheet::CellDeleteMode_UP: eCmd = DEL_CELLSUP; break;
7331 case sheet::CellDeleteMode_LEFT: eCmd = DEL_CELLSLEFT; break;
7332 case sheet::CellDeleteMode_ROWS: eCmd = DEL_DELROWS; break;
7333 case sheet::CellDeleteMode_COLUMNS: eCmd = DEL_DELCOLS; break;
7334 default:
7335 OSL_FAIL("deleteCells: falscher Mode");
7336 bDo = false;
7339 if (bDo)
7341 OSL_ENSURE( rRangeAddress.Sheet == GetTab_Impl(), "falsche Tabelle in CellRangeAddress" );
7342 ScRange aScRange;
7343 ScUnoConversion::FillScRange( aScRange, rRangeAddress );
7344 pDocSh->GetDocFunc().DeleteCells( aScRange, NULL, eCmd, sal_True, sal_True );
7349 void SAL_CALL ScTableSheetObj::moveRange( const table::CellAddress& aDestination,
7350 const table::CellRangeAddress& aSource )
7351 throw(uno::RuntimeException)
7353 SolarMutexGuard aGuard;
7354 ScDocShell* pDocSh = GetDocShell();
7355 if ( pDocSh )
7357 OSL_ENSURE( aSource.Sheet == GetTab_Impl(), "falsche Tabelle in CellRangeAddress" );
7358 ScRange aSourceRange;
7359 ScUnoConversion::FillScRange( aSourceRange, aSource );
7360 ScAddress aDestPos( (SCCOL)aDestination.Column, (SCROW)aDestination.Row, aDestination.Sheet );
7361 pDocSh->GetDocFunc().MoveBlock( aSourceRange, aDestPos, sal_True, sal_True, sal_True, sal_True );
7365 void SAL_CALL ScTableSheetObj::copyRange( const table::CellAddress& aDestination,
7366 const table::CellRangeAddress& aSource )
7367 throw(uno::RuntimeException)
7369 SolarMutexGuard aGuard;
7370 ScDocShell* pDocSh = GetDocShell();
7371 if ( pDocSh )
7373 OSL_ENSURE( aSource.Sheet == GetTab_Impl(), "falsche Tabelle in CellRangeAddress" );
7374 ScRange aSourceRange;
7375 ScUnoConversion::FillScRange( aSourceRange, aSource );
7376 ScAddress aDestPos( (SCCOL)aDestination.Column, (SCROW)aDestination.Row, aDestination.Sheet );
7377 pDocSh->GetDocFunc().MoveBlock( aSourceRange, aDestPos, false, sal_True, sal_True, sal_True );
7381 // XPrintAreas
7383 void ScTableSheetObj::PrintAreaUndo_Impl( ScPrintRangeSaver* pOldRanges )
7385 // Umbrueche und Undo
7386 ScDocShell* pDocSh = GetDocShell();
7387 ScDocument* pDoc = pDocSh ? pDocSh->GetDocument() : 0;
7389 if(pDocSh && pDoc)
7391 const bool bUndo(pDoc->IsUndoEnabled());
7392 const SCTAB nTab(GetTab_Impl());
7394 if(bUndo)
7396 pDocSh->GetUndoManager()->AddUndoAction(
7397 new ScUndoPrintRange(
7398 pDocSh,
7399 nTab,
7400 pOldRanges,
7401 pDoc->CreatePrintRangeSaver())); // create new ranges
7403 // #i120105# ownership of old ranges has changed, mark as consumed
7404 pOldRanges = 0;
7407 ScPrintFunc(pDocSh, pDocSh->GetPrinter(), nTab).UpdatePages();
7408 SfxBindings* pBindings = pDocSh->GetViewBindings();
7410 if(pBindings)
7412 pBindings->Invalidate(SID_DELETE_PRINTAREA);
7415 pDocSh->SetDocumentModified();
7418 // #i120105# pOldRanges not used, need to cleanup
7419 delete pOldRanges;
7422 uno::Sequence<table::CellRangeAddress> SAL_CALL ScTableSheetObj::getPrintAreas()
7423 throw(uno::RuntimeException)
7425 SolarMutexGuard aGuard;
7426 ScDocShell* pDocSh = GetDocShell();
7427 if ( pDocSh )
7429 ScDocument* pDoc = pDocSh->GetDocument();
7430 SCTAB nTab = GetTab_Impl();
7431 sal_uInt16 nCount = pDoc->GetPrintRangeCount( nTab );
7433 table::CellRangeAddress aRangeAddress;
7434 uno::Sequence<table::CellRangeAddress> aSeq(nCount);
7435 table::CellRangeAddress* pAry = aSeq.getArray();
7436 for (sal_uInt16 i=0; i<nCount; i++)
7438 const ScRange* pRange = pDoc->GetPrintRange( nTab, i );
7439 OSL_ENSURE(pRange,"wo ist der Druckbereich");
7440 if (pRange)
7442 ScUnoConversion::FillApiRange( aRangeAddress, *pRange );
7443 aRangeAddress.Sheet = nTab; // core does not care about sheet index
7444 pAry[i] = aRangeAddress;
7447 return aSeq;
7449 return uno::Sequence<table::CellRangeAddress>();
7452 void SAL_CALL ScTableSheetObj::setPrintAreas(
7453 const uno::Sequence<table::CellRangeAddress>& aPrintAreas )
7454 throw(uno::RuntimeException)
7456 SolarMutexGuard aGuard;
7457 ScPrintRangeSaver* pOldRanges = NULL;
7458 ScDocShell* pDocSh = GetDocShell();
7459 if ( pDocSh )
7461 ScDocument* pDoc = pDocSh->GetDocument();
7462 SCTAB nTab = GetTab_Impl();
7464 if ( pDoc->IsUndoEnabled() )
7465 pOldRanges = pDoc->CreatePrintRangeSaver();
7467 sal_uInt16 nCount = (sal_uInt16) aPrintAreas.getLength();
7468 pDoc->ClearPrintRanges( nTab );
7469 if (nCount)
7471 ScRange aPrintRange;
7472 const table::CellRangeAddress* pAry = aPrintAreas.getConstArray();
7473 for (sal_uInt16 i=0; i<nCount; i++)
7475 ScUnoConversion::FillScRange( aPrintRange, pAry[i] );
7476 pDoc->AddPrintRange( nTab, aPrintRange );
7480 if ( pDoc->IsUndoEnabled() )
7481 PrintAreaUndo_Impl( pOldRanges ); // Undo, Umbrueche, Modified etc.
7485 sal_Bool SAL_CALL ScTableSheetObj::getPrintTitleColumns() throw(uno::RuntimeException)
7487 SolarMutexGuard aGuard;
7488 ScDocShell* pDocSh = GetDocShell();
7489 if ( pDocSh )
7491 ScDocument* pDoc = pDocSh->GetDocument();
7492 SCTAB nTab = GetTab_Impl();
7493 return ( pDoc->GetRepeatColRange(nTab) != NULL );
7495 return false;
7498 void SAL_CALL ScTableSheetObj::setPrintTitleColumns( sal_Bool bPrintTitleColumns )
7499 throw(uno::RuntimeException)
7501 SolarMutexGuard aGuard;
7502 ScDocShell* pDocSh = GetDocShell();
7503 if ( pDocSh )
7505 ScDocument* pDoc = pDocSh->GetDocument();
7506 SCTAB nTab = GetTab_Impl();
7508 ScPrintRangeSaver* pOldRanges = pDoc->CreatePrintRangeSaver();
7510 if ( bPrintTitleColumns )
7512 if ( !pDoc->GetRepeatColRange( nTab ) ) // keinen bestehenden Bereich veraendern
7514 ScRange aNew( 0, 0, nTab, 0, 0, nTab ); // Default
7515 pDoc->SetRepeatColRange( nTab, &aNew ); // einschalten
7518 else
7519 pDoc->SetRepeatColRange( nTab, NULL ); // abschalten
7521 PrintAreaUndo_Impl( pOldRanges ); // Undo, Umbrueche, Modified etc.
7523 //! zuletzt gesetzten Bereich beim Abschalten merken und beim Einschalten wiederherstellen ???
7527 table::CellRangeAddress SAL_CALL ScTableSheetObj::getTitleColumns() throw(uno::RuntimeException)
7529 SolarMutexGuard aGuard;
7530 table::CellRangeAddress aRet;
7531 ScDocShell* pDocSh = GetDocShell();
7532 if ( pDocSh )
7534 ScDocument* pDoc = pDocSh->GetDocument();
7535 SCTAB nTab = GetTab_Impl();
7536 const ScRange* pRange = pDoc->GetRepeatColRange(nTab);
7537 if (pRange)
7539 ScUnoConversion::FillApiRange( aRet, *pRange );
7540 aRet.Sheet = nTab; // core does not care about sheet index
7543 return aRet;
7546 void SAL_CALL ScTableSheetObj::setTitleColumns( const table::CellRangeAddress& aTitleColumns )
7547 throw(uno::RuntimeException)
7549 SolarMutexGuard aGuard;
7550 ScDocShell* pDocSh = GetDocShell();
7551 if ( pDocSh )
7553 ScDocument* pDoc = pDocSh->GetDocument();
7554 SCTAB nTab = GetTab_Impl();
7556 ScPrintRangeSaver* pOldRanges = pDoc->CreatePrintRangeSaver();
7558 ScRange aNew;
7559 ScUnoConversion::FillScRange( aNew, aTitleColumns );
7560 pDoc->SetRepeatColRange( nTab, &aNew ); // immer auch einschalten
7562 PrintAreaUndo_Impl( pOldRanges ); // Undo, Umbrueche, Modified etc.
7566 sal_Bool SAL_CALL ScTableSheetObj::getPrintTitleRows() throw(uno::RuntimeException)
7568 SolarMutexGuard aGuard;
7569 ScDocShell* pDocSh = GetDocShell();
7570 if ( pDocSh )
7572 ScDocument* pDoc = pDocSh->GetDocument();
7573 SCTAB nTab = GetTab_Impl();
7574 return ( pDoc->GetRepeatRowRange(nTab) != NULL );
7576 return false;
7579 void SAL_CALL ScTableSheetObj::setPrintTitleRows( sal_Bool bPrintTitleRows )
7580 throw(uno::RuntimeException)
7582 SolarMutexGuard aGuard;
7583 ScDocShell* pDocSh = GetDocShell();
7584 if ( pDocSh )
7586 ScDocument* pDoc = pDocSh->GetDocument();
7587 SCTAB nTab = GetTab_Impl();
7589 ScPrintRangeSaver* pOldRanges = pDoc->CreatePrintRangeSaver();
7591 if ( bPrintTitleRows )
7593 if ( !pDoc->GetRepeatRowRange( nTab ) ) // keinen bestehenden Bereich veraendern
7595 ScRange aNew( 0, 0, nTab, 0, 0, nTab ); // Default
7596 pDoc->SetRepeatRowRange( nTab, &aNew ); // einschalten
7599 else
7600 pDoc->SetRepeatRowRange( nTab, NULL ); // abschalten
7602 PrintAreaUndo_Impl( pOldRanges ); // Undo, Umbrueche, Modified etc.
7604 //! zuletzt gesetzten Bereich beim Abschalten merken und beim Einschalten wiederherstellen ???
7608 table::CellRangeAddress SAL_CALL ScTableSheetObj::getTitleRows() throw(uno::RuntimeException)
7610 SolarMutexGuard aGuard;
7611 table::CellRangeAddress aRet;
7612 ScDocShell* pDocSh = GetDocShell();
7613 if ( pDocSh )
7615 ScDocument* pDoc = pDocSh->GetDocument();
7616 SCTAB nTab = GetTab_Impl();
7617 const ScRange* pRange = pDoc->GetRepeatRowRange(nTab);
7618 if (pRange)
7620 ScUnoConversion::FillApiRange( aRet, *pRange );
7621 aRet.Sheet = nTab; // core does not care about sheet index
7624 return aRet;
7627 void SAL_CALL ScTableSheetObj::setTitleRows( const table::CellRangeAddress& aTitleRows )
7628 throw(uno::RuntimeException)
7630 SolarMutexGuard aGuard;
7631 ScDocShell* pDocSh = GetDocShell();
7632 if ( pDocSh )
7634 ScDocument* pDoc = pDocSh->GetDocument();
7635 SCTAB nTab = GetTab_Impl();
7637 ScPrintRangeSaver* pOldRanges = pDoc->CreatePrintRangeSaver();
7639 ScRange aNew;
7640 ScUnoConversion::FillScRange( aNew, aTitleRows );
7641 pDoc->SetRepeatRowRange( nTab, &aNew ); // immer auch einschalten
7643 PrintAreaUndo_Impl( pOldRanges ); // Undo, Umbrueche, Modified etc.
7647 // XSheetLinkable
7649 sheet::SheetLinkMode SAL_CALL ScTableSheetObj::getLinkMode() throw(uno::RuntimeException)
7651 SolarMutexGuard aGuard;
7652 sheet::SheetLinkMode eRet = sheet::SheetLinkMode_NONE;
7653 ScDocShell* pDocSh = GetDocShell();
7654 if ( pDocSh )
7656 sal_uInt8 nMode = pDocSh->GetDocument()->GetLinkMode( GetTab_Impl() );
7657 if ( nMode == SC_LINK_NORMAL )
7658 eRet = sheet::SheetLinkMode_NORMAL;
7659 else if ( nMode == SC_LINK_VALUE )
7660 eRet = sheet::SheetLinkMode_VALUE;
7662 return eRet;
7665 void SAL_CALL ScTableSheetObj::setLinkMode( sheet::SheetLinkMode nLinkMode )
7666 throw(uno::RuntimeException)
7668 SolarMutexGuard aGuard;
7670 //! Filter und Options aus altem Link suchen
7672 OUString aUrl(getLinkUrl());
7673 OUString aSheet(getLinkSheetName());
7675 OUString aEmpty;
7676 link( aUrl, aSheet, aEmpty, aEmpty, nLinkMode );
7679 OUString SAL_CALL ScTableSheetObj::getLinkUrl() throw(uno::RuntimeException)
7681 SolarMutexGuard aGuard;
7682 OUString aFile;
7683 ScDocShell* pDocSh = GetDocShell();
7684 if ( pDocSh )
7685 aFile = pDocSh->GetDocument()->GetLinkDoc( GetTab_Impl() );
7686 return aFile;
7689 void SAL_CALL ScTableSheetObj::setLinkUrl( const OUString& aLinkUrl )
7690 throw(uno::RuntimeException)
7692 SolarMutexGuard aGuard;
7694 //! Filter und Options aus altem Link suchen
7696 sheet::SheetLinkMode eMode = getLinkMode();
7697 OUString aSheet(getLinkSheetName());
7699 OUString aEmpty;
7700 link( aLinkUrl, aSheet, aEmpty, aEmpty, eMode );
7703 OUString SAL_CALL ScTableSheetObj::getLinkSheetName() throw(uno::RuntimeException)
7705 SolarMutexGuard aGuard;
7706 OUString aSheet;
7707 ScDocShell* pDocSh = GetDocShell();
7708 if ( pDocSh )
7709 aSheet = pDocSh->GetDocument()->GetLinkTab( GetTab_Impl() );
7710 return aSheet;
7713 void SAL_CALL ScTableSheetObj::setLinkSheetName( const OUString& aLinkSheetName )
7714 throw(uno::RuntimeException)
7716 SolarMutexGuard aGuard;
7718 //! Filter und Options aus altem Link suchen
7720 sheet::SheetLinkMode eMode = getLinkMode();
7721 OUString aUrl(getLinkUrl());
7723 OUString aEmpty;
7724 link( aUrl, aLinkSheetName, aEmpty, aEmpty, eMode );
7727 void SAL_CALL ScTableSheetObj::link( const OUString& aUrl, const OUString& aSheetName,
7728 const OUString& aFilterName, const OUString& aFilterOptions,
7729 sheet::SheetLinkMode nMode ) throw(uno::RuntimeException)
7731 SolarMutexGuard aGuard;
7732 ScDocShell* pDocSh = GetDocShell();
7733 if ( pDocSh )
7735 ScDocument* pDoc = pDocSh->GetDocument();
7736 SCTAB nTab = GetTab_Impl();
7738 OUString aFileString = aUrl;
7739 OUString aFilterString = aFilterName;
7740 OUString aOptString = aFilterOptions;
7741 OUString aSheetString = aSheetName;
7743 aFileString = ScGlobal::GetAbsDocName( aFileString, pDocSh );
7744 if (aFilterString.isEmpty())
7745 ScDocumentLoader::GetFilterName( aFileString, aFilterString, aOptString, true, false );
7747 // remove application prefix from filter name here, so the filter options
7748 // aren't reset when the filter name is changed in ScTableLink::DataChanged
7749 ScDocumentLoader::RemoveAppPrefix( aFilterString );
7751 sal_uInt8 nLinkMode = SC_LINK_NONE;
7752 if ( nMode == sheet::SheetLinkMode_NORMAL )
7753 nLinkMode = SC_LINK_NORMAL;
7754 else if ( nMode == sheet::SheetLinkMode_VALUE )
7755 nLinkMode = SC_LINK_VALUE;
7757 sal_uLong nRefresh = 0;
7758 pDoc->SetLink( nTab, nLinkMode, aFileString, aFilterString, aOptString, aSheetString, nRefresh );
7760 pDocSh->UpdateLinks(); // ggf. Link eintragen oder loeschen
7761 SfxBindings* pBindings = pDocSh->GetViewBindings();
7762 if (pBindings)
7763 pBindings->Invalidate(SID_LINKS);
7765 //! Undo fuer Link-Daten an der Table
7767 if ( nLinkMode != SC_LINK_NONE && pDoc->IsExecuteLinkEnabled() ) // Link updaten
7769 // Update immer, auch wenn der Link schon da war
7770 //! Update nur fuer die betroffene Tabelle???
7772 sfx2::LinkManager* pLinkManager = pDoc->GetLinkManager();
7773 sal_uInt16 nCount = pLinkManager->GetLinks().size();
7774 for ( sal_uInt16 i=0; i<nCount; i++ )
7776 ::sfx2::SvBaseLink* pBase = *pLinkManager->GetLinks()[i];
7777 if (pBase->ISA(ScTableLink))
7779 ScTableLink* pTabLink = (ScTableLink*)pBase;
7780 if ( aFileString.equals(pTabLink->GetFileName()) )
7781 pTabLink->Update(); // inkl. Paint&Undo
7783 //! Der Dateiname sollte nur einmal vorkommen (?)
7788 //! Notify fuer ScSheetLinkObj Objekte!!!
7792 // XSheetAuditing
7794 sal_Bool SAL_CALL ScTableSheetObj::hideDependents( const table::CellAddress& aPosition )
7795 throw(uno::RuntimeException)
7797 SolarMutexGuard aGuard;
7798 ScDocShell* pDocSh = GetDocShell();
7799 if ( pDocSh )
7801 SCTAB nTab = GetTab_Impl();
7802 OSL_ENSURE( aPosition.Sheet == nTab, "falsche Tabelle in CellAddress" );
7803 ScAddress aPos( (SCCOL)aPosition.Column, (SCROW)aPosition.Row, nTab );
7804 return pDocSh->GetDocFunc().DetectiveDelSucc( aPos );
7806 return false;
7809 sal_Bool SAL_CALL ScTableSheetObj::hidePrecedents( const table::CellAddress& aPosition )
7810 throw(uno::RuntimeException)
7812 SolarMutexGuard aGuard;
7813 ScDocShell* pDocSh = GetDocShell();
7814 if ( pDocSh )
7816 SCTAB nTab = GetTab_Impl();
7817 OSL_ENSURE( aPosition.Sheet == nTab, "falsche Tabelle in CellAddress" );
7818 ScAddress aPos( (SCCOL)aPosition.Column, (SCROW)aPosition.Row, nTab );
7819 return pDocSh->GetDocFunc().DetectiveDelPred( aPos );
7821 return false;
7824 sal_Bool SAL_CALL ScTableSheetObj::showDependents( const table::CellAddress& aPosition )
7825 throw(uno::RuntimeException)
7827 SolarMutexGuard aGuard;
7828 ScDocShell* pDocSh = GetDocShell();
7829 if ( pDocSh )
7831 SCTAB nTab = GetTab_Impl();
7832 OSL_ENSURE( aPosition.Sheet == nTab, "falsche Tabelle in CellAddress" );
7833 ScAddress aPos( (SCCOL)aPosition.Column, (SCROW)aPosition.Row, nTab );
7834 return pDocSh->GetDocFunc().DetectiveAddSucc( aPos );
7836 return false;
7839 sal_Bool SAL_CALL ScTableSheetObj::showPrecedents( const table::CellAddress& aPosition )
7840 throw(uno::RuntimeException)
7842 SolarMutexGuard aGuard;
7843 ScDocShell* pDocSh = GetDocShell();
7844 if ( pDocSh )
7846 SCTAB nTab = GetTab_Impl();
7847 OSL_ENSURE( aPosition.Sheet == nTab, "falsche Tabelle in CellAddress" );
7848 ScAddress aPos( (SCCOL)aPosition.Column, (SCROW)aPosition.Row, nTab );
7849 return pDocSh->GetDocFunc().DetectiveAddPred( aPos );
7851 return false;
7854 sal_Bool SAL_CALL ScTableSheetObj::showErrors( const table::CellAddress& aPosition )
7855 throw(uno::RuntimeException)
7857 SolarMutexGuard aGuard;
7858 ScDocShell* pDocSh = GetDocShell();
7859 if ( pDocSh )
7861 SCTAB nTab = GetTab_Impl();
7862 OSL_ENSURE( aPosition.Sheet == nTab, "falsche Tabelle in CellAddress" );
7863 ScAddress aPos( (SCCOL)aPosition.Column, (SCROW)aPosition.Row, nTab );
7864 return pDocSh->GetDocFunc().DetectiveAddError( aPos );
7866 return false;
7869 sal_Bool SAL_CALL ScTableSheetObj::showInvalid() throw(uno::RuntimeException)
7871 SolarMutexGuard aGuard;
7872 ScDocShell* pDocSh = GetDocShell();
7873 if ( pDocSh )
7874 return pDocSh->GetDocFunc().DetectiveMarkInvalid( GetTab_Impl() );
7875 return false;
7878 void SAL_CALL ScTableSheetObj::clearArrows() throw(uno::RuntimeException)
7880 SolarMutexGuard aGuard;
7881 ScDocShell* pDocSh = GetDocShell();
7882 if ( pDocSh )
7883 pDocSh->GetDocFunc().DetectiveDelAll( GetTab_Impl() );
7886 // XSheetOutline
7888 void SAL_CALL ScTableSheetObj::group( const table::CellRangeAddress& rGroupRange,
7889 table::TableOrientation nOrientation )
7890 throw(uno::RuntimeException)
7892 SolarMutexGuard aGuard;
7893 ScDocShell* pDocSh = GetDocShell();
7894 if ( pDocSh )
7896 sal_Bool bColumns = ( nOrientation == table::TableOrientation_COLUMNS );
7897 ScRange aGroupRange;
7898 ScUnoConversion::FillScRange( aGroupRange, rGroupRange );
7899 ScOutlineDocFunc aFunc(*pDocSh);
7900 aFunc.MakeOutline( aGroupRange, bColumns, sal_True, sal_True );
7904 void SAL_CALL ScTableSheetObj::ungroup( const table::CellRangeAddress& rGroupRange,
7905 table::TableOrientation nOrientation )
7906 throw(uno::RuntimeException)
7908 SolarMutexGuard aGuard;
7909 ScDocShell* pDocSh = GetDocShell();
7910 if ( pDocSh )
7912 sal_Bool bColumns = ( nOrientation == table::TableOrientation_COLUMNS );
7913 ScRange aGroupRange;
7914 ScUnoConversion::FillScRange( aGroupRange, rGroupRange );
7915 ScOutlineDocFunc aFunc(*pDocSh);
7916 aFunc.RemoveOutline( aGroupRange, bColumns, sal_True, sal_True );
7920 void SAL_CALL ScTableSheetObj::autoOutline( const table::CellRangeAddress& rCellRange )
7921 throw(uno::RuntimeException)
7923 SolarMutexGuard aGuard;
7924 ScDocShell* pDocSh = GetDocShell();
7925 if ( pDocSh )
7927 ScRange aFormulaRange;
7928 ScUnoConversion::FillScRange( aFormulaRange, rCellRange );
7929 ScOutlineDocFunc aFunc(*pDocSh);
7930 aFunc.AutoOutline( aFormulaRange, sal_True, sal_True );
7934 void SAL_CALL ScTableSheetObj::clearOutline() throw(uno::RuntimeException)
7936 SolarMutexGuard aGuard;
7937 ScDocShell* pDocSh = GetDocShell();
7938 if ( pDocSh )
7940 SCTAB nTab = GetTab_Impl();
7941 ScOutlineDocFunc aFunc(*pDocSh);
7942 aFunc.RemoveAllOutlines( nTab, sal_True, sal_True );
7946 void SAL_CALL ScTableSheetObj::hideDetail( const table::CellRangeAddress& rCellRange )
7947 throw(uno::RuntimeException)
7949 SolarMutexGuard aGuard;
7950 ScDocShell* pDocSh = GetDocShell();
7951 if ( pDocSh )
7953 ScRange aMarkRange;
7954 ScUnoConversion::FillScRange( aMarkRange, rCellRange );
7955 ScOutlineDocFunc aFunc(*pDocSh);
7956 aFunc.HideMarkedOutlines( aMarkRange, sal_True, sal_True );
7960 void SAL_CALL ScTableSheetObj::showDetail( const table::CellRangeAddress& rCellRange )
7961 throw(uno::RuntimeException)
7963 SolarMutexGuard aGuard;
7964 ScDocShell* pDocSh = GetDocShell();
7965 if ( pDocSh )
7967 ScRange aMarkRange;
7968 ScUnoConversion::FillScRange( aMarkRange, rCellRange );
7969 ScOutlineDocFunc aFunc(*pDocSh);
7970 aFunc.ShowMarkedOutlines( aMarkRange, sal_True );
7974 void SAL_CALL ScTableSheetObj::showLevel( sal_Int16 nLevel, table::TableOrientation nOrientation )
7975 throw(uno::RuntimeException)
7977 SolarMutexGuard aGuard;
7978 ScDocShell* pDocSh = GetDocShell();
7979 if ( pDocSh )
7981 sal_Bool bColumns = ( nOrientation == table::TableOrientation_COLUMNS );
7982 SCTAB nTab = GetTab_Impl();
7983 ScOutlineDocFunc aFunc(*pDocSh);
7984 aFunc.SelectLevel( nTab, bColumns, nLevel, sal_True, sal_True, sal_True );
7988 // XProtectable
7990 void SAL_CALL ScTableSheetObj::protect( const OUString& aPassword )
7991 throw(uno::RuntimeException)
7993 SolarMutexGuard aGuard;
7994 ScDocShell* pDocSh = GetDocShell();
7995 // #i108245# if already protected, don't change anything
7996 if ( pDocSh && !pDocSh->GetDocument()->IsTabProtected( GetTab_Impl() ) )
7998 OUString aString(aPassword);
7999 pDocSh->GetDocFunc().Protect( GetTab_Impl(), aString, sal_True );
8003 void SAL_CALL ScTableSheetObj::unprotect( const OUString& aPassword )
8004 throw(lang::IllegalArgumentException, uno::RuntimeException)
8006 SolarMutexGuard aGuard;
8007 ScDocShell* pDocSh = GetDocShell();
8008 if ( pDocSh )
8010 OUString aString(aPassword);
8011 sal_Bool bDone = pDocSh->GetDocFunc().Unprotect( GetTab_Impl(), aString, sal_True );
8012 if (!bDone)
8013 throw lang::IllegalArgumentException();
8017 sal_Bool SAL_CALL ScTableSheetObj::isProtected() throw(uno::RuntimeException)
8019 SolarMutexGuard aGuard;
8020 ScDocShell* pDocSh = GetDocShell();
8021 if ( pDocSh )
8022 return pDocSh->GetDocument()->IsTabProtected( GetTab_Impl() );
8024 OSL_FAIL("keine DocShell"); //! Exception oder so?
8025 return false;
8028 // XScenario
8030 sal_Bool SAL_CALL ScTableSheetObj::getIsScenario() throw(uno::RuntimeException)
8032 SolarMutexGuard aGuard;
8033 ScDocShell* pDocSh = GetDocShell();
8034 if ( pDocSh )
8035 return pDocSh->GetDocument()->IsScenario( GetTab_Impl() );
8037 return false;
8040 OUString SAL_CALL ScTableSheetObj::getScenarioComment() throw(uno::RuntimeException)
8042 SolarMutexGuard aGuard;
8043 ScDocShell* pDocSh = GetDocShell();
8044 if ( pDocSh )
8046 OUString aComment;
8047 Color aColor;
8048 sal_uInt16 nFlags;
8049 pDocSh->GetDocument()->GetScenarioData( GetTab_Impl(), aComment, aColor, nFlags );
8050 return aComment;
8052 return OUString();
8055 void SAL_CALL ScTableSheetObj::setScenarioComment( const OUString& aScenarioComment )
8056 throw(uno::RuntimeException)
8058 SolarMutexGuard aGuard;
8059 ScDocShell* pDocSh = GetDocShell();
8060 if ( pDocSh )
8062 ScDocument* pDoc = pDocSh->GetDocument();
8063 SCTAB nTab = GetTab_Impl();
8065 OUString aName;
8066 OUString aComment;
8067 Color aColor;
8068 sal_uInt16 nFlags;
8069 pDoc->GetName( nTab, aName );
8070 pDoc->GetScenarioData( nTab, aComment, aColor, nFlags );
8072 aComment = aScenarioComment;
8074 pDocSh->ModifyScenario( nTab, aName, aComment, aColor, nFlags );
8078 void SAL_CALL ScTableSheetObj::addRanges( const uno::Sequence<table::CellRangeAddress>& rScenRanges )
8079 throw(uno::RuntimeException)
8081 SolarMutexGuard aGuard;
8082 ScDocShell* pDocSh = GetDocShell();
8083 if ( pDocSh )
8085 ScDocument* pDoc = pDocSh->GetDocument();
8086 SCTAB nTab = GetTab_Impl();
8088 if (pDoc->IsScenario(nTab))
8090 ScMarkData aMarkData;
8091 aMarkData.SelectTable( nTab, sal_True );
8093 sal_uInt16 nRangeCount = (sal_uInt16)rScenRanges.getLength();
8094 if (nRangeCount)
8096 const table::CellRangeAddress* pAry = rScenRanges.getConstArray();
8097 for (sal_uInt16 i=0; i<nRangeCount; i++)
8099 OSL_ENSURE( pAry[i].Sheet == nTab, "addRanges mit falscher Tab" );
8100 ScRange aOneRange( (SCCOL)pAry[i].StartColumn, (SCROW)pAry[i].StartRow, nTab,
8101 (SCCOL)pAry[i].EndColumn, (SCROW)pAry[i].EndRow, nTab );
8103 aMarkData.SetMultiMarkArea( aOneRange );
8107 // Szenario-Ranges sind durch Attribut gekennzeichnet
8108 ScPatternAttr aPattern( pDoc->GetPool() );
8109 aPattern.GetItemSet().Put( ScMergeFlagAttr( SC_MF_SCENARIO ) );
8110 aPattern.GetItemSet().Put( ScProtectionAttr( sal_True ) );
8111 pDocSh->GetDocFunc().ApplyAttributes( aMarkData, aPattern, sal_True, sal_True );
8116 void SAL_CALL ScTableSheetObj::apply() throw(uno::RuntimeException)
8118 SolarMutexGuard aGuard;
8119 ScDocShell* pDocSh = GetDocShell();
8120 if ( pDocSh )
8122 ScDocument* pDoc = pDocSh->GetDocument();
8123 SCTAB nTab = GetTab_Impl();
8124 OUString aName;
8125 pDoc->GetName( nTab, aName ); // Name dieses Szenarios
8127 SCTAB nDestTab = nTab;
8128 while ( nDestTab > 0 && pDoc->IsScenario(nDestTab) )
8129 --nDestTab;
8131 if ( !pDoc->IsScenario(nDestTab) )
8132 pDocSh->UseScenario( nDestTab, aName );
8134 //! sonst Fehler oder so
8138 // XScenarioEnhanced
8140 uno::Sequence< table::CellRangeAddress > SAL_CALL ScTableSheetObj::getRanges( )
8141 throw(uno::RuntimeException)
8143 SolarMutexGuard aGuard;
8144 ScDocShell* pDocSh = GetDocShell();
8145 if ( pDocSh )
8147 ScDocument* pDoc = pDocSh->GetDocument();
8148 SCTAB nTab = GetTab_Impl();
8149 const ScRangeList* pRangeList = pDoc->GetScenarioRanges(nTab);
8150 if (pRangeList)
8152 size_t nCount = pRangeList->size();
8153 uno::Sequence< table::CellRangeAddress > aRetRanges( nCount );
8154 table::CellRangeAddress* pAry = aRetRanges.getArray();
8155 for( size_t nIndex = 0; nIndex < nCount; nIndex++ )
8157 const ScRange* pRange = (*pRangeList)[nIndex];
8158 pAry->StartColumn = pRange->aStart.Col();
8159 pAry->StartRow = pRange->aStart.Row();
8160 pAry->EndColumn = pRange->aEnd.Col();
8161 pAry->EndRow = pRange->aEnd.Row();
8162 pAry->Sheet = pRange->aStart.Tab();
8163 ++pAry;
8165 return aRetRanges;
8168 return uno::Sequence< table::CellRangeAddress > ();
8171 // XExternalSheetName
8173 void ScTableSheetObj::setExternalName( const OUString& aUrl, const OUString& aSheetName )
8174 throw (container::ElementExistException, uno::RuntimeException)
8176 SolarMutexGuard aGuard;
8177 ScDocShell* pDocSh = GetDocShell();
8178 if ( pDocSh )
8180 ScDocument* pDoc = pDocSh->GetDocument();
8181 if ( pDoc )
8183 const SCTAB nTab = GetTab_Impl();
8184 const OUString aAbsDocName( ScGlobal::GetAbsDocName( aUrl, pDocSh ) );
8185 const OUString aDocTabName( ScGlobal::GetDocTabName( aAbsDocName, aSheetName ) );
8186 if ( !pDoc->RenameTab( nTab, aDocTabName, false /*bUpdateRef*/, sal_True /*bExternalDocument*/ ) )
8188 throw container::ElementExistException( OUString(), *this );
8194 // XEventsSupplier
8196 uno::Reference<container::XNameReplace> SAL_CALL ScTableSheetObj::getEvents() throw (uno::RuntimeException)
8198 SolarMutexGuard aGuard;
8199 ScDocShell* pDocSh = GetDocShell();
8200 if ( pDocSh )
8201 return new ScSheetEventsObj( pDocSh, GetTab_Impl() );
8203 return NULL;
8206 // XPropertySet erweitert fuer Sheet-Properties
8208 uno::Reference<beans::XPropertySetInfo> SAL_CALL ScTableSheetObj::getPropertySetInfo()
8209 throw(uno::RuntimeException)
8211 SolarMutexGuard aGuard;
8212 static uno::Reference<beans::XPropertySetInfo> aRef(
8213 new SfxItemPropertySetInfo( pSheetPropSet->getPropertyMap() ));
8214 return aRef;
8217 void ScTableSheetObj::SetOnePropertyValue( const SfxItemPropertySimpleEntry* pEntry, const uno::Any& aValue )
8218 throw(lang::IllegalArgumentException, uno::RuntimeException)
8220 if ( pEntry )
8222 if ( IsScItemWid( pEntry->nWID ) )
8224 // for Item WIDs, call ScCellRangesBase directly
8225 ScCellRangesBase::SetOnePropertyValue(pEntry, aValue);
8226 return;
8229 // own properties
8231 ScDocShell* pDocSh = GetDocShell();
8232 if (!pDocSh)
8233 return; //! Exception oder so?
8234 ScDocument* pDoc = pDocSh->GetDocument();
8235 SCTAB nTab = GetTab_Impl();
8236 ScDocFunc &rFunc = pDocSh->GetDocFunc();
8238 if ( pEntry->nWID == SC_WID_UNO_PAGESTL )
8240 OUString aStrVal;
8241 aValue >>= aStrVal;
8242 OUString aNewStr(ScStyleNameConversion::ProgrammaticToDisplayName(
8243 aStrVal, SFX_STYLE_FAMILY_PAGE ));
8245 //! Undo? (auch bei SID_STYLE_APPLY an der View)
8247 if ( pDoc->GetPageStyle( nTab ) != aNewStr )
8249 pDoc->SetPageStyle( nTab, aNewStr );
8250 if (!pDoc->IsImportingXML())
8252 ScPrintFunc( pDocSh, pDocSh->GetPrinter(), nTab ).UpdatePages();
8254 SfxBindings* pBindings = pDocSh->GetViewBindings();
8255 if (pBindings)
8257 pBindings->Invalidate( SID_STYLE_FAMILY4 );
8258 pBindings->Invalidate( SID_STATUS_PAGESTYLE );
8259 pBindings->Invalidate( FID_RESET_PRINTZOOM );
8260 pBindings->Invalidate( SID_ATTR_PARA_LEFT_TO_RIGHT );
8261 pBindings->Invalidate( SID_ATTR_PARA_RIGHT_TO_LEFT );
8264 pDocSh->SetDocumentModified();
8267 else if ( pEntry->nWID == SC_WID_UNO_CELLVIS )
8269 sal_Bool bVis = ScUnoHelpFunctions::GetBoolFromAny( aValue );
8270 rFunc.SetTableVisible( nTab, bVis, sal_True );
8272 else if ( pEntry->nWID == SC_WID_UNO_ISACTIVE )
8274 if (pDoc->IsScenario(nTab))
8275 pDoc->SetActiveScenario( nTab, ScUnoHelpFunctions::GetBoolFromAny( aValue ) );
8277 else if ( pEntry->nWID == SC_WID_UNO_BORDCOL )
8279 if (pDoc->IsScenario(nTab))
8281 sal_Int32 nNewColor = 0;
8282 if (aValue >>= nNewColor)
8284 OUString aName;
8285 OUString aComment;
8286 Color aColor;
8287 sal_uInt16 nFlags;
8288 pDoc->GetName( nTab, aName );
8289 pDoc->GetScenarioData( nTab, aComment, aColor, nFlags );
8291 aColor = Color(static_cast<sal_uInt32>(nNewColor));
8293 pDocSh->ModifyScenario( nTab, aName, aComment, aColor, nFlags );
8297 else if ( pEntry->nWID == SC_WID_UNO_PROTECT )
8299 if (pDoc->IsScenario(nTab))
8301 OUString aName;
8302 OUString aComment;
8303 Color aColor;
8304 sal_uInt16 nFlags;
8305 pDoc->GetName( nTab, aName );
8306 pDoc->GetScenarioData( nTab, aComment, aColor, nFlags );
8307 sal_Bool bModify(false);
8309 if (ScUnoHelpFunctions::GetBoolFromAny( aValue ))
8311 if (!(nFlags & SC_SCENARIO_PROTECT))
8313 nFlags |= SC_SCENARIO_PROTECT;
8314 bModify = sal_True;
8317 else
8319 if (nFlags & SC_SCENARIO_PROTECT)
8321 nFlags -= SC_SCENARIO_PROTECT;
8322 bModify = sal_True;
8326 if (bModify)
8327 pDocSh->ModifyScenario( nTab, aName, aComment, aColor, nFlags );
8330 else if ( pEntry->nWID == SC_WID_UNO_SHOWBORD )
8332 if (pDoc->IsScenario(nTab))
8334 OUString aName;
8335 OUString aComment;
8336 Color aColor;
8337 sal_uInt16 nFlags;
8338 pDoc->GetName( nTab, aName );
8339 pDoc->GetScenarioData( nTab, aComment, aColor, nFlags );
8340 sal_Bool bModify(false);
8342 if (ScUnoHelpFunctions::GetBoolFromAny( aValue ))
8344 if (!(nFlags & SC_SCENARIO_SHOWFRAME))
8346 nFlags |= SC_SCENARIO_SHOWFRAME;
8347 bModify = sal_True;
8350 else
8352 if (nFlags & SC_SCENARIO_SHOWFRAME)
8354 nFlags -= SC_SCENARIO_SHOWFRAME;
8355 bModify = sal_True;
8359 if (bModify)
8360 pDocSh->ModifyScenario( nTab, aName, aComment, aColor, nFlags );
8363 else if ( pEntry->nWID == SC_WID_UNO_PRINTBORD )
8365 if (pDoc->IsScenario(nTab))
8367 OUString aName;
8368 OUString aComment;
8369 Color aColor;
8370 sal_uInt16 nFlags;
8371 pDoc->GetName( nTab, aName );
8372 pDoc->GetScenarioData( nTab, aComment, aColor, nFlags );
8373 sal_Bool bModify(false);
8375 if (ScUnoHelpFunctions::GetBoolFromAny( aValue ))
8377 if (!(nFlags & SC_SCENARIO_PRINTFRAME))
8379 nFlags |= SC_SCENARIO_PRINTFRAME;
8380 bModify = sal_True;
8383 else
8385 if (nFlags & SC_SCENARIO_PRINTFRAME)
8387 nFlags -= SC_SCENARIO_PRINTFRAME;
8388 bModify = sal_True;
8392 if (bModify)
8393 pDocSh->ModifyScenario( nTab, aName, aComment, aColor, nFlags );
8396 else if ( pEntry->nWID == SC_WID_UNO_COPYBACK )
8398 if (pDoc->IsScenario(nTab))
8400 OUString aName;
8401 OUString aComment;
8402 Color aColor;
8403 sal_uInt16 nFlags;
8404 pDoc->GetName( nTab, aName );
8405 pDoc->GetScenarioData( nTab, aComment, aColor, nFlags );
8406 sal_Bool bModify(false);
8408 if (ScUnoHelpFunctions::GetBoolFromAny( aValue ))
8410 if (!(nFlags & SC_SCENARIO_TWOWAY))
8412 nFlags |= SC_SCENARIO_TWOWAY;
8413 bModify = sal_True;
8416 else
8418 if (nFlags & SC_SCENARIO_TWOWAY)
8420 nFlags -= SC_SCENARIO_TWOWAY;
8421 bModify = sal_True;
8425 if (bModify)
8426 pDocSh->ModifyScenario( nTab, aName, aComment, aColor, nFlags );
8429 else if ( pEntry->nWID == SC_WID_UNO_COPYSTYL )
8431 if (pDoc->IsScenario(nTab))
8433 OUString aName;
8434 OUString aComment;
8435 Color aColor;
8436 sal_uInt16 nFlags;
8437 pDoc->GetName( nTab, aName );
8438 pDoc->GetScenarioData( nTab, aComment, aColor, nFlags );
8439 sal_Bool bModify(false);
8441 if (ScUnoHelpFunctions::GetBoolFromAny( aValue ))
8443 if (!(nFlags & SC_SCENARIO_ATTRIB))
8445 nFlags |= SC_SCENARIO_ATTRIB;
8446 bModify = sal_True;
8449 else
8451 if (nFlags & SC_SCENARIO_ATTRIB)
8453 nFlags -= SC_SCENARIO_ATTRIB;
8454 bModify = sal_True;
8458 if (bModify)
8459 pDocSh->ModifyScenario( nTab, aName, aComment, aColor, nFlags );
8462 else if ( pEntry->nWID == SC_WID_UNO_COPYFORM )
8464 if (pDoc->IsScenario(nTab))
8466 OUString aName;
8467 OUString aComment;
8468 Color aColor;
8469 sal_uInt16 nFlags;
8470 pDoc->GetName( nTab, aName );
8471 pDoc->GetScenarioData( nTab, aComment, aColor, nFlags );
8472 sal_Bool bModify(false);
8474 if (ScUnoHelpFunctions::GetBoolFromAny( aValue ))
8476 if (nFlags & SC_SCENARIO_VALUE)
8478 nFlags -= SC_SCENARIO_VALUE;
8479 bModify = sal_True;
8482 else
8484 if (!(nFlags & SC_SCENARIO_VALUE))
8486 nFlags |= SC_SCENARIO_VALUE;
8487 bModify = sal_True;
8491 if (bModify)
8492 pDocSh->ModifyScenario( nTab, aName, aComment, aColor, nFlags );
8495 else if ( pEntry->nWID == SC_WID_UNO_TABLAYOUT )
8497 sal_Int16 nValue = 0;
8498 if (aValue >>= nValue)
8500 if (nValue == com::sun::star::text::WritingMode2::RL_TB)
8501 rFunc.SetLayoutRTL(nTab, sal_True, sal_True);
8502 else
8503 rFunc.SetLayoutRTL(nTab, false, sal_True);
8506 else if ( pEntry->nWID == SC_WID_UNO_AUTOPRINT )
8508 sal_Bool bAutoPrint = ScUnoHelpFunctions::GetBoolFromAny( aValue );
8509 if (bAutoPrint)
8510 pDoc->SetPrintEntireSheet( nTab ); // clears all print ranges
8511 else
8513 if (pDoc->IsPrintEntireSheet( nTab ))
8514 pDoc->ClearPrintRanges( nTab ); // if this flag is true, there are no PrintRanges, so Clear clears only the flag.
8517 else if ( pEntry->nWID == SC_WID_UNO_TABCOLOR )
8519 sal_Int32 nColor = COL_AUTO;
8520 if ( aValue >>= nColor )
8522 const Color aColor( static_cast< ColorData >( nColor ) );
8523 if ( pDoc->GetTabBgColor( nTab ) != aColor )
8524 rFunc.SetTabBgColor( nTab, aColor, true, true );
8527 else if ( pEntry->nWID == SC_WID_UNO_CODENAME )
8529 OUString aCodeName;
8530 if ( pDocSh && ( aValue >>= aCodeName ) )
8532 pDocSh->GetDocument()->SetCodeName( GetTab_Impl(), aCodeName );
8535 else
8536 ScCellRangeObj::SetOnePropertyValue(pEntry, aValue); // base class, no Item WID
8540 void ScTableSheetObj::GetOnePropertyValue( const SfxItemPropertySimpleEntry* pEntry,
8541 uno::Any& rAny )
8542 throw(uno::RuntimeException)
8544 if ( pEntry )
8546 ScDocShell* pDocSh = GetDocShell();
8547 if (!pDocSh)
8548 throw uno::RuntimeException();
8549 ScDocument* pDoc = pDocSh->GetDocument();
8550 SCTAB nTab = GetTab_Impl();
8552 if ( pEntry->nWID == SC_WID_UNO_NAMES )
8554 rAny <<= uno::Reference<sheet::XNamedRanges>(new ScLocalNamedRangesObj(pDocSh, this));
8556 else if ( pEntry->nWID == SC_WID_UNO_PAGESTL )
8558 rAny <<= OUString( ScStyleNameConversion::DisplayToProgrammaticName(
8559 pDoc->GetPageStyle( nTab ), SFX_STYLE_FAMILY_PAGE ) );
8561 else if ( pEntry->nWID == SC_WID_UNO_CELLVIS )
8563 sal_Bool bVis = pDoc->IsVisible( nTab );
8564 ScUnoHelpFunctions::SetBoolInAny( rAny, bVis );
8566 else if ( pEntry->nWID == SC_WID_UNO_LINKDISPBIT )
8568 // no target bitmaps for individual entries (would be all equal)
8569 // ScLinkTargetTypeObj::SetLinkTargetBitmap( aAny, SC_LINKTARGETTYPE_SHEET );
8571 else if ( pEntry->nWID == SC_WID_UNO_LINKDISPNAME )
8573 // LinkDisplayName for hyperlink dialog
8574 rAny <<= getName(); // sheet name
8576 else if ( pEntry->nWID == SC_WID_UNO_ISACTIVE )
8578 if (pDoc->IsScenario(nTab))
8579 ScUnoHelpFunctions::SetBoolInAny( rAny, pDoc->IsActiveScenario( nTab ));
8581 else if ( pEntry->nWID == SC_WID_UNO_BORDCOL )
8583 if (pDoc->IsScenario(nTab))
8585 OUString aComment;
8586 Color aColor;
8587 sal_uInt16 nFlags;
8588 pDoc->GetScenarioData( nTab, aComment, aColor, nFlags );
8590 rAny <<= static_cast<sal_Int32>(aColor.GetColor());
8593 else if ( pEntry->nWID == SC_WID_UNO_PROTECT )
8595 if (pDoc->IsScenario(nTab))
8597 OUString aComment;
8598 Color aColor;
8599 sal_uInt16 nFlags;
8600 pDoc->GetScenarioData( nTab, aComment, aColor, nFlags );
8602 ScUnoHelpFunctions::SetBoolInAny( rAny, (nFlags & SC_SCENARIO_PROTECT) != 0 );
8605 else if ( pEntry->nWID == SC_WID_UNO_SHOWBORD )
8607 if (pDoc->IsScenario(nTab))
8609 OUString aComment;
8610 Color aColor;
8611 sal_uInt16 nFlags;
8612 pDoc->GetScenarioData( nTab, aComment, aColor, nFlags );
8614 ScUnoHelpFunctions::SetBoolInAny( rAny, (nFlags & SC_SCENARIO_SHOWFRAME) != 0 );
8617 else if ( pEntry->nWID == SC_WID_UNO_PRINTBORD )
8619 if (pDoc->IsScenario(nTab))
8621 OUString aComment;
8622 Color aColor;
8623 sal_uInt16 nFlags;
8624 pDoc->GetScenarioData( nTab, aComment, aColor, nFlags );
8626 ScUnoHelpFunctions::SetBoolInAny( rAny, (nFlags & SC_SCENARIO_PRINTFRAME) != 0 );
8629 else if ( pEntry->nWID == SC_WID_UNO_COPYBACK )
8631 if (pDoc->IsScenario(nTab))
8633 OUString aComment;
8634 Color aColor;
8635 sal_uInt16 nFlags;
8636 pDoc->GetScenarioData( nTab, aComment, aColor, nFlags );
8638 ScUnoHelpFunctions::SetBoolInAny( rAny, (nFlags & SC_SCENARIO_TWOWAY) != 0 );
8641 else if ( pEntry->nWID == SC_WID_UNO_COPYSTYL )
8643 if (pDoc->IsScenario(nTab))
8645 OUString aComment;
8646 Color aColor;
8647 sal_uInt16 nFlags;
8648 pDoc->GetScenarioData( nTab, aComment, aColor, nFlags );
8650 ScUnoHelpFunctions::SetBoolInAny( rAny, (nFlags & SC_SCENARIO_ATTRIB) != 0 );
8653 else if ( pEntry->nWID == SC_WID_UNO_COPYFORM )
8655 if (pDoc->IsScenario(nTab))
8657 OUString aComment;
8658 Color aColor;
8659 sal_uInt16 nFlags;
8660 pDoc->GetScenarioData( nTab, aComment, aColor, nFlags );
8662 ScUnoHelpFunctions::SetBoolInAny( rAny, !(nFlags & SC_SCENARIO_VALUE));
8665 else if ( pEntry->nWID == SC_WID_UNO_TABLAYOUT )
8667 if (pDoc->IsLayoutRTL(nTab))
8668 rAny <<= sal_Int16(com::sun::star::text::WritingMode2::RL_TB);
8669 else
8670 rAny <<= sal_Int16(com::sun::star::text::WritingMode2::LR_TB);
8672 else if ( pEntry->nWID == SC_WID_UNO_AUTOPRINT )
8674 sal_Bool bAutoPrint = pDoc->IsPrintEntireSheet( nTab );
8675 ScUnoHelpFunctions::SetBoolInAny( rAny, bAutoPrint );
8677 else if ( pEntry->nWID == SC_WID_UNO_TABCOLOR )
8679 rAny <<= sal_Int32(pDoc->GetTabBgColor(nTab).GetColor());
8681 else if ( pEntry->nWID == SC_WID_UNO_CODENAME )
8683 OUString aCodeName;
8684 if ( pDocSh )
8685 pDocSh->GetDocument()->GetCodeName( GetTab_Impl(), aCodeName );
8686 rAny <<= OUString( aCodeName );
8688 else
8689 ScCellRangeObj::GetOnePropertyValue(pEntry, rAny);
8693 const SfxItemPropertyMap& ScTableSheetObj::GetItemPropertyMap()
8695 return pSheetPropSet->getPropertyMap();
8698 // XServiceInfo
8700 OUString SAL_CALL ScTableSheetObj::getImplementationName() throw(uno::RuntimeException)
8702 return OUString( "ScTableSheetObj" );
8705 sal_Bool SAL_CALL ScTableSheetObj::supportsService( const OUString& rServiceName )
8706 throw(uno::RuntimeException)
8708 return rServiceName.equalsAscii( SCSPREADSHEET_SERVICE ) ||
8709 rServiceName.equalsAscii( SCSHEETCELLRANGE_SERVICE ) ||
8710 rServiceName.equalsAscii( SCCELLRANGE_SERVICE ) ||
8711 rServiceName.equalsAscii( SCCELLPROPERTIES_SERVICE ) ||
8712 rServiceName.equalsAscii( SCCHARPROPERTIES_SERVICE ) ||
8713 rServiceName.equalsAscii( SCPARAPROPERTIES_SERVICE ) ||
8714 rServiceName.equalsAscii( SCLINKTARGET_SERVICE );
8717 uno::Sequence<OUString> SAL_CALL ScTableSheetObj::getSupportedServiceNames()
8718 throw(uno::RuntimeException)
8720 uno::Sequence<OUString> aRet(7);
8721 OUString* pArray = aRet.getArray();
8722 pArray[0] = OUString( SCSPREADSHEET_SERVICE );
8723 pArray[1] = OUString( SCSHEETCELLRANGE_SERVICE );
8724 pArray[2] = OUString( SCCELLRANGE_SERVICE );
8725 pArray[3] = OUString( SCCELLPROPERTIES_SERVICE );
8726 pArray[4] = OUString( SCCHARPROPERTIES_SERVICE );
8727 pArray[5] = OUString( SCPARAPROPERTIES_SERVICE );
8728 pArray[6] = OUString( SCLINKTARGET_SERVICE );
8729 return aRet;
8732 // XUnoTunnel
8734 sal_Int64 SAL_CALL ScTableSheetObj::getSomething(
8735 const uno::Sequence<sal_Int8 >& rId ) throw(uno::RuntimeException)
8737 if ( rId.getLength() == 16 &&
8738 0 == memcmp( getUnoTunnelId().getConstArray(),
8739 rId.getConstArray(), 16 ) )
8741 return sal::static_int_cast<sal_Int64>(reinterpret_cast<sal_IntPtr>(this));
8744 return ScCellRangeObj::getSomething( rId );
8747 namespace
8749 class theScTableSheetObjUnoTunnelId : public rtl::Static< UnoTunnelIdInit, theScTableSheetObjUnoTunnelId> {};
8752 const uno::Sequence<sal_Int8>& ScTableSheetObj::getUnoTunnelId()
8754 return theScTableSheetObjUnoTunnelId::get().getSeq();
8757 ScTableSheetObj* ScTableSheetObj::getImplementation( const uno::Reference<uno::XInterface> xObj )
8759 ScTableSheetObj* pRet = NULL;
8760 uno::Reference<lang::XUnoTunnel> xUT( xObj, uno::UNO_QUERY );
8761 if (xUT.is())
8762 pRet = reinterpret_cast<ScTableSheetObj*>(sal::static_int_cast<sal_IntPtr>(xUT->getSomething(getUnoTunnelId())));
8763 return pRet;
8766 //------------------------------------------------------------------------
8768 ScTableColumnObj::ScTableColumnObj( ScDocShell* pDocSh, SCCOL nCol, SCTAB nTab ) :
8769 ScCellRangeObj( pDocSh, ScRange(nCol,0,nTab, nCol,MAXROW,nTab) ),
8770 pColPropSet(lcl_GetColumnPropertySet())
8774 ScTableColumnObj::~ScTableColumnObj()
8778 uno::Any SAL_CALL ScTableColumnObj::queryInterface( const uno::Type& rType ) throw(uno::RuntimeException)
8780 SC_QUERYINTERFACE( container::XNamed )
8782 return ScCellRangeObj::queryInterface( rType );
8785 void SAL_CALL ScTableColumnObj::acquire() throw()
8787 ScCellRangeObj::acquire();
8790 void SAL_CALL ScTableColumnObj::release() throw()
8792 ScCellRangeObj::release();
8795 uno::Sequence<uno::Type> SAL_CALL ScTableColumnObj::getTypes() throw(uno::RuntimeException)
8797 static uno::Sequence<uno::Type> aTypes;
8798 if ( aTypes.getLength() == 0 )
8800 uno::Sequence<uno::Type> aParentTypes(ScCellRangeObj::getTypes());
8801 long nParentLen = aParentTypes.getLength();
8802 const uno::Type* pParentPtr = aParentTypes.getConstArray();
8804 aTypes.realloc( nParentLen + 1 );
8805 uno::Type* pPtr = aTypes.getArray();
8806 pPtr[nParentLen + 0] = getCppuType((const uno::Reference<container::XNamed>*)0);
8808 for (long i=0; i<nParentLen; i++)
8809 pPtr[i] = pParentPtr[i]; // parent types first
8811 return aTypes;
8814 namespace
8816 class theScTableColumnObjImplementationId : public rtl::Static< UnoTunnelIdInit, theScTableColumnObjImplementationId > {};
8819 uno::Sequence<sal_Int8> SAL_CALL ScTableColumnObj::getImplementationId() throw(uno::RuntimeException)
8821 return theScTableColumnObjImplementationId::get().getSeq();
8824 // XNamed
8826 OUString SAL_CALL ScTableColumnObj::getName() throw(uno::RuntimeException)
8828 SolarMutexGuard aGuard;
8830 const ScRange& rRange = GetRange();
8831 OSL_ENSURE(rRange.aStart.Col() == rRange.aEnd.Col(), "too many columns");
8832 SCCOL nCol = rRange.aStart.Col();
8834 return ScColToAlpha( nCol ); // from global.hxx
8837 void SAL_CALL ScTableColumnObj::setName( const OUString& /* aNewName */ )
8838 throw(uno::RuntimeException)
8840 SolarMutexGuard aGuard;
8841 throw uno::RuntimeException(); // read-only
8844 // XPropertySet erweitert fuer Spalten-Properties
8846 uno::Reference<beans::XPropertySetInfo> SAL_CALL ScTableColumnObj::getPropertySetInfo()
8847 throw(uno::RuntimeException)
8849 SolarMutexGuard aGuard;
8850 static uno::Reference<beans::XPropertySetInfo> aRef(
8851 new SfxItemPropertySetInfo( pColPropSet->getPropertyMap() ));
8852 return aRef;
8855 void ScTableColumnObj::SetOnePropertyValue( const SfxItemPropertySimpleEntry* pEntry, const uno::Any& aValue )
8856 throw(lang::IllegalArgumentException, uno::RuntimeException)
8858 if ( pEntry )
8860 if ( IsScItemWid( pEntry->nWID ) )
8862 // for Item WIDs, call ScCellRangesBase directly
8863 ScCellRangesBase::SetOnePropertyValue(pEntry, aValue);
8864 return;
8867 // own properties
8869 ScDocShell* pDocSh = GetDocShell();
8870 if (!pDocSh)
8871 return; //! Exception oder so?
8872 const ScRange& rRange = GetRange();
8873 OSL_ENSURE(rRange.aStart.Col() == rRange.aEnd.Col(), "zuviele Spalten");
8874 SCCOL nCol = rRange.aStart.Col();
8875 SCTAB nTab = rRange.aStart.Tab();
8876 ScDocFunc &rFunc = pDocSh->GetDocFunc();
8878 SCCOLROW nColArr[2];
8879 nColArr[0] = nColArr[1] = nCol;
8881 if ( pEntry->nWID == SC_WID_UNO_CELLWID )
8883 sal_Int32 nNewWidth = 0;
8884 if ( aValue >>= nNewWidth )
8886 // property is 1/100mm, column width is twips
8887 nNewWidth = HMMToTwips(nNewWidth);
8888 rFunc.SetWidthOrHeight( sal_True, 1, nColArr, nTab, SC_SIZE_ORIGINAL,
8889 (sal_uInt16)nNewWidth, sal_True, sal_True );
8892 else if ( pEntry->nWID == SC_WID_UNO_CELLVIS )
8894 sal_Bool bVis = ScUnoHelpFunctions::GetBoolFromAny( aValue );
8895 ScSizeMode eMode = bVis ? SC_SIZE_SHOW : SC_SIZE_DIRECT;
8896 rFunc.SetWidthOrHeight( sal_True, 1, nColArr, nTab, eMode, 0, sal_True, sal_True );
8897 // SC_SIZE_DIRECT mit Groesse 0 blendet aus
8899 else if ( pEntry->nWID == SC_WID_UNO_OWIDTH )
8901 sal_Bool bOpt = ScUnoHelpFunctions::GetBoolFromAny( aValue );
8902 if (bOpt)
8903 rFunc.SetWidthOrHeight( sal_True, 1, nColArr, nTab,
8904 SC_SIZE_OPTIMAL, STD_EXTRA_WIDTH, sal_True, sal_True );
8905 // sal_False bei Spalten momentan ohne Auswirkung
8907 else if ( pEntry->nWID == SC_WID_UNO_NEWPAGE || pEntry->nWID == SC_WID_UNO_MANPAGE )
8909 sal_Bool bSet = ScUnoHelpFunctions::GetBoolFromAny( aValue );
8910 if (bSet)
8911 rFunc.InsertPageBreak( sal_True, rRange.aStart, sal_True, sal_True, sal_True );
8912 else
8913 rFunc.RemovePageBreak( sal_True, rRange.aStart, sal_True, sal_True, sal_True );
8915 else
8916 ScCellRangeObj::SetOnePropertyValue(pEntry, aValue); // base class, no Item WID
8920 void ScTableColumnObj::GetOnePropertyValue( const SfxItemPropertySimpleEntry* pEntry,
8921 uno::Any& rAny )
8922 throw(uno::RuntimeException)
8924 if ( pEntry )
8926 ScDocShell* pDocSh = GetDocShell();
8927 if (!pDocSh)
8928 throw uno::RuntimeException();
8930 ScDocument* pDoc = pDocSh->GetDocument();
8931 const ScRange& rRange = GetRange();
8932 OSL_ENSURE(rRange.aStart.Col() == rRange.aEnd.Col(), "zuviele Spalten");
8933 SCCOL nCol = rRange.aStart.Col();
8934 SCTAB nTab = rRange.aStart.Tab();
8936 if ( pEntry->nWID == SC_WID_UNO_CELLWID )
8938 // for hidden column, return original height
8939 sal_uInt16 nWidth = pDoc->GetOriginalWidth( nCol, nTab );
8940 // property is 1/100mm, column width is twips
8941 nWidth = (sal_uInt16) TwipsToHMM(nWidth);
8942 rAny <<= (sal_Int32)( nWidth );
8944 else if ( pEntry->nWID == SC_WID_UNO_CELLVIS )
8946 bool bHidden = pDoc->ColHidden(nCol, nTab);
8947 ScUnoHelpFunctions::SetBoolInAny( rAny, !bHidden );
8949 else if ( pEntry->nWID == SC_WID_UNO_OWIDTH )
8951 //! momentan immer gesetzt ??!?!
8952 sal_Bool bOpt = !(pDoc->GetColFlags( nCol, nTab ) & CR_MANUALSIZE);
8953 ScUnoHelpFunctions::SetBoolInAny( rAny, bOpt );
8955 else if ( pEntry->nWID == SC_WID_UNO_NEWPAGE )
8957 ScBreakType nBreak = pDoc->HasColBreak(nCol, nTab);
8958 ScUnoHelpFunctions::SetBoolInAny( rAny, nBreak );
8960 else if ( pEntry->nWID == SC_WID_UNO_MANPAGE )
8962 ScBreakType nBreak = pDoc->HasColBreak(nCol, nTab);
8963 ScUnoHelpFunctions::SetBoolInAny(rAny, (nBreak & BREAK_MANUAL));
8965 else
8966 ScCellRangeObj::GetOnePropertyValue(pEntry, rAny);
8970 const SfxItemPropertyMap& ScTableColumnObj::GetItemPropertyMap()
8972 return pColPropSet->getPropertyMap();
8975 //------------------------------------------------------------------------
8977 ScTableRowObj::ScTableRowObj(ScDocShell* pDocSh, SCROW nRow, SCTAB nTab) :
8978 ScCellRangeObj( pDocSh, ScRange(0,nRow,nTab, MAXCOL,nRow,nTab) ),
8979 pRowPropSet(lcl_GetRowPropertySet())
8983 ScTableRowObj::~ScTableRowObj()
8987 // XPropertySet erweitert fuer Zeilen-Properties
8989 uno::Reference<beans::XPropertySetInfo> SAL_CALL ScTableRowObj::getPropertySetInfo()
8990 throw(uno::RuntimeException)
8992 SolarMutexGuard aGuard;
8993 static uno::Reference<beans::XPropertySetInfo> aRef(
8994 new SfxItemPropertySetInfo( pRowPropSet->getPropertyMap() ));
8995 return aRef;
8998 void ScTableRowObj::SetOnePropertyValue( const SfxItemPropertySimpleEntry* pEntry, const uno::Any& aValue )
8999 throw(lang::IllegalArgumentException, uno::RuntimeException)
9001 if ( pEntry )
9003 if ( IsScItemWid( pEntry->nWID ) )
9005 // for Item WIDs, call ScCellRangesBase directly
9006 ScCellRangesBase::SetOnePropertyValue(pEntry, aValue);
9007 return;
9010 // own properties
9012 ScDocShell* pDocSh = GetDocShell();
9013 if (!pDocSh)
9014 return; //! Exception oder so?
9015 ScDocument* pDoc = pDocSh->GetDocument();
9016 const ScRange& rRange = GetRange();
9017 OSL_ENSURE(rRange.aStart.Row() == rRange.aEnd.Row(), "zuviele Zeilen");
9018 SCROW nRow = rRange.aStart.Row();
9019 SCTAB nTab = rRange.aStart.Tab();
9020 ScDocFunc &rFunc = pDocSh->GetDocFunc();
9022 SCCOLROW nRowArr[2];
9023 nRowArr[0] = nRowArr[1] = nRow;
9025 if ( pEntry->nWID == SC_WID_UNO_CELLHGT )
9027 sal_Int32 nNewHeight = 0;
9028 if ( aValue >>= nNewHeight )
9030 // property is 1/100mm, row height is twips
9031 nNewHeight = HMMToTwips(nNewHeight);
9032 rFunc.SetWidthOrHeight( false, 1, nRowArr, nTab, SC_SIZE_ORIGINAL,
9033 (sal_uInt16)nNewHeight, sal_True, sal_True );
9036 else if ( pEntry->nWID == SC_WID_UNO_CELLVIS )
9038 sal_Bool bVis = ScUnoHelpFunctions::GetBoolFromAny( aValue );
9039 ScSizeMode eMode = bVis ? SC_SIZE_SHOW : SC_SIZE_DIRECT;
9040 rFunc.SetWidthOrHeight( false, 1, nRowArr, nTab, eMode, 0, sal_True, sal_True );
9041 // SC_SIZE_DIRECT mit Groesse 0 blendet aus
9043 else if ( pEntry->nWID == SC_WID_UNO_CELLFILT )
9045 sal_Bool bFil = ScUnoHelpFunctions::GetBoolFromAny( aValue );
9046 // SC_SIZE_DIRECT mit Groesse 0 blendet aus
9047 pDoc->SetRowFiltered(nRow, nRow, nTab, bFil);
9049 else if ( pEntry->nWID == SC_WID_UNO_OHEIGHT )
9051 sal_Bool bOpt = ScUnoHelpFunctions::GetBoolFromAny( aValue );
9052 if (bOpt)
9053 rFunc.SetWidthOrHeight( false, 1, nRowArr, nTab, SC_SIZE_OPTIMAL, 0, sal_True, sal_True );
9054 else
9056 // set current height again manually
9057 sal_uInt16 nHeight = pDoc->GetOriginalHeight( nRow, nTab );
9058 rFunc.SetWidthOrHeight( false, 1, nRowArr, nTab, SC_SIZE_ORIGINAL, nHeight, sal_True, sal_True );
9061 else if ( pEntry->nWID == SC_WID_UNO_NEWPAGE || pEntry->nWID == SC_WID_UNO_MANPAGE )
9063 sal_Bool bSet = ScUnoHelpFunctions::GetBoolFromAny( aValue );
9064 if (bSet)
9065 rFunc.InsertPageBreak( false, rRange.aStart, sal_True, sal_True, sal_True );
9066 else
9067 rFunc.RemovePageBreak( false, rRange.aStart, sal_True, sal_True, sal_True );
9069 else
9070 ScCellRangeObj::SetOnePropertyValue(pEntry, aValue); // base class, no Item WID
9074 void ScTableRowObj::GetOnePropertyValue( const SfxItemPropertySimpleEntry* pEntry,
9075 uno::Any& rAny )
9076 throw(uno::RuntimeException)
9078 if ( pEntry )
9080 ScDocShell* pDocSh = GetDocShell();
9081 if (!pDocSh)
9082 throw uno::RuntimeException();
9083 ScDocument* pDoc = pDocSh->GetDocument();
9084 const ScRange& rRange = GetRange();
9085 OSL_ENSURE(rRange.aStart.Row() == rRange.aEnd.Row(), "zuviele Zeilen");
9086 SCROW nRow = rRange.aStart.Row();
9087 SCTAB nTab = rRange.aStart.Tab();
9089 if ( pEntry->nWID == SC_WID_UNO_CELLHGT )
9091 // for hidden row, return original height
9092 sal_uInt16 nHeight = pDoc->GetOriginalHeight( nRow, nTab );
9093 // property is 1/100mm, row height is twips
9094 nHeight = (sal_uInt16) TwipsToHMM(nHeight);
9095 rAny <<= (sal_Int32)( nHeight );
9097 else if ( pEntry->nWID == SC_WID_UNO_CELLVIS )
9099 bool bHidden = pDoc->RowHidden(nRow, nTab);
9100 ScUnoHelpFunctions::SetBoolInAny( rAny, !bHidden );
9102 else if ( pEntry->nWID == SC_WID_UNO_CELLFILT )
9104 bool bVis = pDoc->RowFiltered(nRow, nTab);
9105 ScUnoHelpFunctions::SetBoolInAny( rAny, bVis );
9107 else if ( pEntry->nWID == SC_WID_UNO_OHEIGHT )
9109 sal_Bool bOpt = !(pDoc->GetRowFlags( nRow, nTab ) & CR_MANUALSIZE);
9110 ScUnoHelpFunctions::SetBoolInAny( rAny, bOpt );
9112 else if ( pEntry->nWID == SC_WID_UNO_NEWPAGE )
9114 ScBreakType nBreak = pDoc->HasRowBreak(nRow, nTab);
9115 ScUnoHelpFunctions::SetBoolInAny( rAny, nBreak );
9117 else if ( pEntry->nWID == SC_WID_UNO_MANPAGE )
9119 ScBreakType nBreak = (pDoc->HasRowBreak(nRow, nTab) & BREAK_MANUAL);
9120 ScUnoHelpFunctions::SetBoolInAny( rAny, nBreak );
9122 else
9123 ScCellRangeObj::GetOnePropertyValue(pEntry, rAny);
9127 const SfxItemPropertyMap& ScTableRowObj::GetItemPropertyMap()
9129 return pRowPropSet->getPropertyMap();
9132 //------------------------------------------------------------------------
9134 ScCellsObj::ScCellsObj(ScDocShell* pDocSh, const ScRangeList& rR) :
9135 pDocShell( pDocSh ),
9136 aRanges( rR )
9138 pDocShell->GetDocument()->AddUnoObject(*this);
9141 ScCellsObj::~ScCellsObj()
9143 if (pDocShell)
9144 pDocShell->GetDocument()->RemoveUnoObject(*this);
9147 void ScCellsObj::Notify( SfxBroadcaster&, const SfxHint& rHint )
9149 if ( rHint.ISA( ScUpdateRefHint ) )
9151 const ScUpdateRefHint& rRef = (const ScUpdateRefHint&)rHint;
9152 aRanges.UpdateReference( rRef.GetMode(), pDocShell->GetDocument(), rRef.GetRange(),
9153 rRef.GetDx(), rRef.GetDy(), rRef.GetDz() );
9155 else if ( rHint.ISA( SfxSimpleHint ) &&
9156 ((const SfxSimpleHint&)rHint).GetId() == SFX_HINT_DYING )
9158 pDocShell = NULL; // ungueltig geworden
9162 // XEnumerationAccess
9164 uno::Reference<container::XEnumeration> SAL_CALL ScCellsObj::createEnumeration()
9165 throw(uno::RuntimeException)
9167 SolarMutexGuard aGuard;
9168 if (pDocShell)
9169 return new ScCellsEnumeration( pDocShell, aRanges );
9170 return NULL;
9173 uno::Type SAL_CALL ScCellsObj::getElementType() throw(uno::RuntimeException)
9175 SolarMutexGuard aGuard;
9176 return getCppuType((uno::Reference<table::XCell>*)0);
9179 sal_Bool SAL_CALL ScCellsObj::hasElements() throw(uno::RuntimeException)
9181 SolarMutexGuard aGuard;
9182 sal_Bool bHas = false;
9183 if ( pDocShell )
9185 //! schneller selber testen?
9187 uno::Reference<container::XEnumeration> xEnum(new ScCellsEnumeration( pDocShell, aRanges ));
9188 bHas = xEnum->hasMoreElements();
9190 return bHas;
9193 //------------------------------------------------------------------------
9195 ScCellsEnumeration::ScCellsEnumeration(ScDocShell* pDocSh, const ScRangeList& rR) :
9196 pDocShell( pDocSh ),
9197 aRanges( rR ),
9198 pMark( NULL ),
9199 bAtEnd( false )
9201 ScDocument* pDoc = pDocShell->GetDocument();
9202 pDoc->AddUnoObject(*this);
9204 if ( aRanges.empty() )
9205 bAtEnd = true;
9206 else
9208 SCTAB nTab = 0;
9209 const ScRange* pFirst = aRanges[ 0 ];
9210 if (pFirst)
9211 nTab = pFirst->aStart.Tab();
9212 aPos = ScAddress(0,0,nTab);
9213 CheckPos_Impl(); // aPos auf erste passende Zelle setzen
9217 void ScCellsEnumeration::CheckPos_Impl()
9219 if (!pDocShell)
9220 return;
9222 bool bFound = false;
9223 ScDocument* pDoc = pDocShell->GetDocument();
9224 ScRefCellValue aCell;
9225 aCell.assign(*pDoc, aPos);
9226 if (!aCell.isEmpty())
9228 if (!pMark)
9230 pMark = new ScMarkData;
9231 pMark->MarkFromRangeList(aRanges, false);
9232 pMark->MarkToMulti(); // needed for GetNextMarkedCell
9234 bFound = pMark->IsCellMarked(aPos.Col(), aPos.Row());
9236 if (!bFound)
9237 Advance_Impl();
9240 ScCellsEnumeration::~ScCellsEnumeration()
9242 if (pDocShell)
9243 pDocShell->GetDocument()->RemoveUnoObject(*this);
9244 delete pMark;
9247 void ScCellsEnumeration::Advance_Impl()
9249 OSL_ENSURE(!bAtEnd,"zuviel Advance_Impl");
9250 if (!pMark)
9252 pMark = new ScMarkData;
9253 pMark->MarkFromRangeList( aRanges, false );
9254 pMark->MarkToMulti(); // needed for GetNextMarkedCell
9257 SCCOL nCol = aPos.Col();
9258 SCROW nRow = aPos.Row();
9259 SCTAB nTab = aPos.Tab();
9260 sal_Bool bFound = pDocShell->GetDocument()->GetNextMarkedCell( nCol, nRow, nTab, *pMark );
9261 if (bFound)
9262 aPos.Set( nCol, nRow, nTab );
9263 else
9264 bAtEnd = sal_True; // kommt nix mehr
9267 void ScCellsEnumeration::Notify( SfxBroadcaster&, const SfxHint& rHint )
9269 if ( rHint.ISA( ScUpdateRefHint ) )
9271 if (pDocShell)
9273 const ScUpdateRefHint& rRef = (const ScUpdateRefHint&)rHint;
9274 aRanges.UpdateReference( rRef.GetMode(), pDocShell->GetDocument(), rRef.GetRange(),
9275 rRef.GetDx(), rRef.GetDy(), rRef.GetDz() );
9277 delete pMark; // aus verschobenen Bereichen neu erzeugen
9278 pMark = NULL;
9280 if (!bAtEnd) // aPos anpassen
9282 ScRangeList aNew;
9283 aNew.Append(ScRange(aPos));
9284 aNew.UpdateReference( rRef.GetMode(), pDocShell->GetDocument(), rRef.GetRange(),
9285 rRef.GetDx(), rRef.GetDy(), rRef.GetDz() );
9286 if (aNew.size()==1)
9288 aPos = aNew[ 0 ]->aStart;
9289 CheckPos_Impl();
9294 else if ( rHint.ISA( SfxSimpleHint ) &&
9295 ((const SfxSimpleHint&)rHint).GetId() == SFX_HINT_DYING )
9297 pDocShell = NULL; // ungueltig geworden
9301 // XEnumeration
9303 sal_Bool SAL_CALL ScCellsEnumeration::hasMoreElements() throw(uno::RuntimeException)
9305 SolarMutexGuard aGuard;
9306 return !bAtEnd;
9309 uno::Any SAL_CALL ScCellsEnumeration::nextElement() throw(container::NoSuchElementException,
9310 lang::WrappedTargetException, uno::RuntimeException)
9312 SolarMutexGuard aGuard;
9313 if (pDocShell && !bAtEnd)
9315 // Interface-Typ muss zu ScCellsObj::getElementType passen
9317 ScAddress aTempPos(aPos);
9318 Advance_Impl();
9319 return uno::makeAny(uno::Reference<table::XCell>(new ScCellObj( pDocShell, aTempPos )));
9322 throw container::NoSuchElementException(); // no more elements
9325 //------------------------------------------------------------------------
9327 ScCellFormatsObj::ScCellFormatsObj(ScDocShell* pDocSh, const ScRange& rRange) :
9328 pDocShell( pDocSh ),
9329 aTotalRange( rRange )
9331 ScDocument* pDoc = pDocShell->GetDocument();
9332 pDoc->AddUnoObject(*this);
9334 OSL_ENSURE( aTotalRange.aStart.Tab() == aTotalRange.aEnd.Tab(), "unterschiedliche Tabellen" );
9337 ScCellFormatsObj::~ScCellFormatsObj()
9339 if (pDocShell)
9340 pDocShell->GetDocument()->RemoveUnoObject(*this);
9343 void ScCellFormatsObj::Notify( SfxBroadcaster&, const SfxHint& rHint )
9345 if ( rHint.ISA( ScUpdateRefHint ) )
9347 //! aTotalRange...
9349 else if ( rHint.ISA( SfxSimpleHint ) &&
9350 ((const SfxSimpleHint&)rHint).GetId() == SFX_HINT_DYING )
9352 pDocShell = NULL; // ungueltig geworden
9356 ScCellRangeObj* ScCellFormatsObj::GetObjectByIndex_Impl(long nIndex) const
9358 //! direkt auf die AttrArrays zugreifen !!!!
9360 ScCellRangeObj* pRet = NULL;
9361 if (pDocShell)
9363 ScDocument* pDoc = pDocShell->GetDocument();
9364 long nPos = 0;
9365 ScAttrRectIterator aIter( pDoc, aTotalRange.aStart.Tab(),
9366 aTotalRange.aStart.Col(), aTotalRange.aStart.Row(),
9367 aTotalRange.aEnd.Col(), aTotalRange.aEnd.Row() );
9368 SCCOL nCol1, nCol2;
9369 SCROW nRow1, nRow2;
9370 while ( aIter.GetNext( nCol1, nCol2, nRow1, nRow2 ) )
9372 if ( nPos == nIndex )
9374 SCTAB nTab = aTotalRange.aStart.Tab();
9375 ScRange aNext( nCol1, nRow1, nTab, nCol2, nRow2, nTab );
9377 if ( aNext.aStart == aNext.aEnd )
9378 pRet = new ScCellObj( pDocShell, aNext.aStart );
9379 else
9380 pRet = new ScCellRangeObj( pDocShell, aNext );
9382 ++nPos;
9385 return pRet;
9388 // XIndexAccess
9390 sal_Int32 SAL_CALL ScCellFormatsObj::getCount() throw(uno::RuntimeException)
9392 SolarMutexGuard aGuard;
9394 //! direkt auf die AttrArrays zugreifen !!!!
9396 long nCount = 0;
9397 if (pDocShell)
9399 ScDocument* pDoc = pDocShell->GetDocument();
9400 ScAttrRectIterator aIter( pDoc, aTotalRange.aStart.Tab(),
9401 aTotalRange.aStart.Col(), aTotalRange.aStart.Row(),
9402 aTotalRange.aEnd.Col(), aTotalRange.aEnd.Row() );
9403 SCCOL nCol1, nCol2;
9404 SCROW nRow1, nRow2;
9405 while ( aIter.GetNext( nCol1, nCol2, nRow1, nRow2 ) )
9406 ++nCount;
9408 return nCount;
9411 uno::Any SAL_CALL ScCellFormatsObj::getByIndex( sal_Int32 nIndex )
9412 throw(lang::IndexOutOfBoundsException,
9413 lang::WrappedTargetException, uno::RuntimeException)
9415 SolarMutexGuard aGuard;
9417 uno::Reference<table::XCellRange> xRange(GetObjectByIndex_Impl(nIndex));
9418 if (xRange.is())
9419 return uno::makeAny(xRange);
9420 else
9421 throw lang::IndexOutOfBoundsException();
9424 uno::Type SAL_CALL ScCellFormatsObj::getElementType() throw(uno::RuntimeException)
9426 SolarMutexGuard aGuard;
9427 return getCppuType((uno::Reference<table::XCellRange>*)0);
9430 sal_Bool SAL_CALL ScCellFormatsObj::hasElements() throw(uno::RuntimeException)
9432 SolarMutexGuard aGuard;
9433 return ( getCount() != 0 ); //! immer groesser 0 ??
9436 // XEnumerationAccess
9438 uno::Reference<container::XEnumeration> SAL_CALL ScCellFormatsObj::createEnumeration()
9439 throw(uno::RuntimeException)
9441 SolarMutexGuard aGuard;
9442 if (pDocShell)
9443 return new ScCellFormatsEnumeration( pDocShell, aTotalRange );
9444 return NULL;
9447 //------------------------------------------------------------------------
9449 ScCellFormatsEnumeration::ScCellFormatsEnumeration(ScDocShell* pDocSh, const ScRange& rRange) :
9450 pDocShell( pDocSh ),
9451 nTab( rRange.aStart.Tab() ),
9452 pIter( NULL ),
9453 bAtEnd( false ),
9454 bDirty( false )
9456 ScDocument* pDoc = pDocShell->GetDocument();
9457 pDoc->AddUnoObject(*this);
9459 OSL_ENSURE( rRange.aStart.Tab() == rRange.aEnd.Tab(),
9460 "CellFormatsEnumeration: unterschiedliche Tabellen" );
9462 pIter = new ScAttrRectIterator( pDoc, nTab,
9463 rRange.aStart.Col(), rRange.aStart.Row(),
9464 rRange.aEnd.Col(), rRange.aEnd.Row() );
9465 Advance_Impl();
9468 ScCellFormatsEnumeration::~ScCellFormatsEnumeration()
9470 if (pDocShell)
9471 pDocShell->GetDocument()->RemoveUnoObject(*this);
9472 delete pIter;
9475 void ScCellFormatsEnumeration::Advance_Impl()
9477 OSL_ENSURE(!bAtEnd,"zuviel Advance_Impl");
9479 if ( pIter )
9481 if ( bDirty )
9483 pIter->DataChanged(); // AttrArray-Index neu suchen
9484 bDirty = false;
9487 SCCOL nCol1, nCol2;
9488 SCROW nRow1, nRow2;
9489 if ( pIter->GetNext( nCol1, nCol2, nRow1, nRow2 ) )
9490 aNext = ScRange( nCol1, nRow1, nTab, nCol2, nRow2, nTab );
9491 else
9492 bAtEnd = sal_True; // kommt nix mehr
9494 else
9495 bAtEnd = sal_True; // Dok weggekommen oder so
9498 ScCellRangeObj* ScCellFormatsEnumeration::NextObject_Impl()
9500 ScCellRangeObj* pRet = NULL;
9501 if (pDocShell && !bAtEnd)
9503 if ( aNext.aStart == aNext.aEnd )
9504 pRet = new ScCellObj( pDocShell, aNext.aStart );
9505 else
9506 pRet = new ScCellRangeObj( pDocShell, aNext );
9507 Advance_Impl();
9509 return pRet;
9512 void ScCellFormatsEnumeration::Notify( SfxBroadcaster&, const SfxHint& rHint )
9514 if ( rHint.ISA( ScUpdateRefHint ) )
9516 //! und nun ???
9518 else if ( rHint.ISA( SfxSimpleHint ) )
9520 sal_uLong nId = ((const SfxSimpleHint&)rHint).GetId();
9521 if ( nId == SFX_HINT_DYING )
9523 pDocShell = NULL; // ungueltig geworden
9524 delete pIter;
9525 pIter = NULL;
9527 else if ( nId == SFX_HINT_DATACHANGED )
9529 bDirty = sal_True; // AttrArray-Index evtl. ungueltig geworden
9534 // XEnumeration
9536 sal_Bool SAL_CALL ScCellFormatsEnumeration::hasMoreElements() throw(uno::RuntimeException)
9538 SolarMutexGuard aGuard;
9539 return !bAtEnd;
9542 uno::Any SAL_CALL ScCellFormatsEnumeration::nextElement() throw(container::NoSuchElementException,
9543 lang::WrappedTargetException, uno::RuntimeException)
9545 SolarMutexGuard aGuard;
9547 if ( bAtEnd || !pDocShell )
9548 throw container::NoSuchElementException(); // no more elements
9550 // Interface-Typ muss zu ScCellFormatsObj::getElementType passen
9552 return uno::makeAny(uno::Reference<table::XCellRange> (NextObject_Impl()));
9555 //------------------------------------------------------------------------
9557 ScUniqueCellFormatsObj::ScUniqueCellFormatsObj(ScDocShell* pDocSh, const ScRange& rRange) :
9558 pDocShell( pDocSh ),
9559 aTotalRange( rRange ),
9560 aRangeLists()
9562 pDocShell->GetDocument()->AddUnoObject(*this);
9564 OSL_ENSURE( aTotalRange.aStart.Tab() == aTotalRange.aEnd.Tab(), "unterschiedliche Tabellen" );
9566 GetObjects_Impl();
9569 ScUniqueCellFormatsObj::~ScUniqueCellFormatsObj()
9571 if (pDocShell)
9572 pDocShell->GetDocument()->RemoveUnoObject(*this);
9575 void ScUniqueCellFormatsObj::Notify( SfxBroadcaster&, const SfxHint& rHint )
9577 if ( rHint.ISA( ScUpdateRefHint ) )
9579 //! aTotalRange...
9581 else if ( rHint.ISA( SfxSimpleHint ) )
9583 sal_uLong nId = ((const SfxSimpleHint&)rHint).GetId();
9584 if ( nId == SFX_HINT_DYING )
9585 pDocShell = NULL; // ungueltig geworden
9590 // Fill the list of formats from the document
9593 // hash code to access the range lists by ScPatternAttr pointer
9594 struct ScPatternHashCode
9596 size_t operator()( const ScPatternAttr* pPattern ) const
9598 return reinterpret_cast<size_t>(pPattern);
9602 // Hash map to find a range by its start row
9603 typedef ::boost::unordered_map< SCROW, ScRange > ScRowRangeHashMap;
9605 typedef ::std::vector<ScRange> ScRangeVector;
9607 // Hash map entry.
9608 // The Join method depends on the column-wise order of ScAttrRectIterator
9609 class ScUniqueFormatsEntry
9611 enum EntryState { STATE_EMPTY, STATE_SINGLE, STATE_COMPLEX };
9613 EntryState eState;
9614 ScRange aSingleRange;
9615 ScRowRangeHashMap aJoinedRanges; // "active" ranges to be merged
9616 ScRangeVector aCompletedRanges; // ranges that will no longer be touched
9617 ScRangeListRef aReturnRanges; // result as ScRangeList for further use
9619 public:
9620 ScUniqueFormatsEntry() : eState( STATE_EMPTY ) {}
9621 ScUniqueFormatsEntry( const ScUniqueFormatsEntry& r ) :
9622 eState( r.eState ),
9623 aSingleRange( r.aSingleRange ),
9624 aJoinedRanges( r.aJoinedRanges ),
9625 aCompletedRanges( r.aCompletedRanges ),
9626 aReturnRanges( r.aReturnRanges ) {}
9627 ~ScUniqueFormatsEntry() {}
9629 void Join( const ScRange& rNewRange );
9630 const ScRangeList& GetRanges();
9631 void Clear() { aReturnRanges.Clear(); } // aJoinedRanges and aCompletedRanges are cleared in GetRanges
9634 void ScUniqueFormatsEntry::Join( const ScRange& rNewRange )
9636 // Special-case handling for single range
9638 if ( eState == STATE_EMPTY )
9640 aSingleRange = rNewRange;
9641 eState = STATE_SINGLE;
9642 return;
9644 if ( eState == STATE_SINGLE )
9646 if ( aSingleRange.aStart.Row() == rNewRange.aStart.Row() &&
9647 aSingleRange.aEnd.Row() == rNewRange.aEnd.Row() &&
9648 aSingleRange.aEnd.Col() + 1 == rNewRange.aStart.Col() )
9650 aSingleRange.aEnd.SetCol( rNewRange.aEnd.Col() );
9651 return; // still a single range
9654 SCROW nSingleRow = aSingleRange.aStart.Row();
9655 aJoinedRanges.insert( ScRowRangeHashMap::value_type( nSingleRow, aSingleRange ) );
9656 eState = STATE_COMPLEX;
9657 // continue normally
9660 // This is called in the order of ScAttrRectIterator results.
9661 // rNewRange can only be joined with an existing entry if it's the same rows, starting in the next column.
9662 // If the old entry for the start row extends to a different end row, or ends in a different column, it
9663 // can be moved to aCompletedRanges because it can't be joined with following iterator results.
9664 // Everything happens within one sheet, so Tab can be ignored.
9666 SCROW nStartRow = rNewRange.aStart.Row();
9667 ScRowRangeHashMap::iterator aIter( aJoinedRanges.find( nStartRow ) ); // find the active entry for the start row
9668 if ( aIter != aJoinedRanges.end() )
9670 ScRange& rOldRange = aIter->second;
9671 if ( rOldRange.aEnd.Row() == rNewRange.aEnd.Row() &&
9672 rOldRange.aEnd.Col() + 1 == rNewRange.aStart.Col() )
9674 // extend existing range
9675 rOldRange.aEnd.SetCol( rNewRange.aEnd.Col() );
9677 else
9679 // move old range to aCompletedRanges, keep rNewRange for joining
9680 aCompletedRanges.push_back( rOldRange );
9681 rOldRange = rNewRange; // replace in hash map
9684 else
9686 // keep rNewRange for joining
9687 aJoinedRanges.insert( ScRowRangeHashMap::value_type( nStartRow, rNewRange ) );
9691 const ScRangeList& ScUniqueFormatsEntry::GetRanges()
9693 if ( eState == STATE_SINGLE )
9695 aReturnRanges = new ScRangeList;
9696 aReturnRanges->Append( aSingleRange );
9697 return *aReturnRanges;
9700 // move remaining entries from aJoinedRanges to aCompletedRanges
9702 ScRowRangeHashMap::const_iterator aJoinedEnd = aJoinedRanges.end();
9703 for ( ScRowRangeHashMap::const_iterator aJoinedIter = aJoinedRanges.begin(); aJoinedIter != aJoinedEnd; ++aJoinedIter )
9704 aCompletedRanges.push_back( aJoinedIter->second );
9705 aJoinedRanges.clear();
9707 // sort all ranges for a predictable API result
9709 std::sort( aCompletedRanges.begin(), aCompletedRanges.end() );
9711 // fill and return ScRangeList
9713 aReturnRanges = new ScRangeList;
9714 ScRangeVector::const_iterator aCompEnd( aCompletedRanges.end() );
9715 for ( ScRangeVector::const_iterator aCompIter( aCompletedRanges.begin() ); aCompIter != aCompEnd; ++aCompIter )
9716 aReturnRanges->Append( *aCompIter );
9717 aCompletedRanges.clear();
9719 return *aReturnRanges;
9722 typedef ::boost::unordered_map< const ScPatternAttr*, ScUniqueFormatsEntry, ScPatternHashCode > ScUniqueFormatsHashMap;
9724 // function object to sort the range lists by start of first range
9725 struct ScUniqueFormatsOrder
9727 bool operator()( const ScRangeList& rList1, const ScRangeList& rList2 ) const
9729 // all range lists have at least one entry
9730 OSL_ENSURE( rList1.size() > 0 && rList2.size() > 0, "ScUniqueFormatsOrder: empty list" );
9732 // compare start positions using ScAddress comparison operator
9733 return ( rList1[ 0 ]->aStart < rList2[ 0 ]->aStart );
9737 void ScUniqueCellFormatsObj::GetObjects_Impl()
9739 if (pDocShell)
9741 ScDocument* pDoc = pDocShell->GetDocument();
9742 SCTAB nTab = aTotalRange.aStart.Tab();
9743 ScAttrRectIterator aIter( pDoc, nTab,
9744 aTotalRange.aStart.Col(), aTotalRange.aStart.Row(),
9745 aTotalRange.aEnd.Col(), aTotalRange.aEnd.Row() );
9746 SCCOL nCol1, nCol2;
9747 SCROW nRow1, nRow2;
9749 // Collect the ranges for each format in a hash map, to avoid nested loops
9751 ScUniqueFormatsHashMap aHashMap;
9752 while (aIter.GetNext( nCol1, nCol2, nRow1, nRow2 ) )
9754 ScRange aRange( nCol1, nRow1, nTab, nCol2, nRow2, nTab );
9755 const ScPatternAttr* pPattern = pDoc->GetPattern(nCol1, nRow1, nTab);
9756 aHashMap[pPattern].Join( aRange );
9759 // Fill the vector aRangeLists with the range lists from the hash map
9761 aRangeLists.reserve( aHashMap.size() );
9762 ScUniqueFormatsHashMap::iterator aMapIter( aHashMap.begin() );
9763 ScUniqueFormatsHashMap::iterator aMapEnd( aHashMap.end() );
9764 while ( aMapIter != aMapEnd )
9766 ScUniqueFormatsEntry& rEntry = aMapIter->second;
9767 const ScRangeList& rRanges = rEntry.GetRanges();
9768 aRangeLists.push_back( rRanges ); // copy ScRangeList
9769 rEntry.Clear(); // free memory, don't hold both copies of all ranges
9770 ++aMapIter;
9773 // Sort the vector by first range's start position, to avoid random shuffling
9774 // due to using the ScPatterAttr pointers
9776 ScUniqueFormatsOrder aComp;
9777 ::std::sort( aRangeLists.begin(), aRangeLists.end(), aComp );
9781 // XIndexAccess
9783 sal_Int32 SAL_CALL ScUniqueCellFormatsObj::getCount() throw(uno::RuntimeException)
9785 SolarMutexGuard aGuard;
9787 return aRangeLists.size();
9790 uno::Any SAL_CALL ScUniqueCellFormatsObj::getByIndex( sal_Int32 nIndex )
9791 throw(lang::IndexOutOfBoundsException,
9792 lang::WrappedTargetException, uno::RuntimeException)
9794 SolarMutexGuard aGuard;
9796 if(static_cast<sal_uInt32>(nIndex) < aRangeLists.size())
9797 return uno::makeAny(uno::Reference<sheet::XSheetCellRangeContainer>(new ScCellRangesObj(pDocShell, aRangeLists[nIndex])));
9798 else
9799 throw lang::IndexOutOfBoundsException();
9802 uno::Type SAL_CALL ScUniqueCellFormatsObj::getElementType() throw(uno::RuntimeException)
9804 SolarMutexGuard aGuard;
9805 return getCppuType((uno::Reference<sheet::XSheetCellRangeContainer>*)0);
9808 sal_Bool SAL_CALL ScUniqueCellFormatsObj::hasElements() throw(uno::RuntimeException)
9810 SolarMutexGuard aGuard;
9811 return ( aRangeLists.size() != 0 );
9814 // XEnumerationAccess
9816 uno::Reference<container::XEnumeration> SAL_CALL ScUniqueCellFormatsObj::createEnumeration()
9817 throw(uno::RuntimeException)
9819 SolarMutexGuard aGuard;
9820 if (pDocShell)
9821 return new ScUniqueCellFormatsEnumeration( pDocShell, aRangeLists );
9822 return NULL;
9825 //------------------------------------------------------------------------
9827 ScUniqueCellFormatsEnumeration::ScUniqueCellFormatsEnumeration(ScDocShell* pDocSh, const ScMyRangeLists& rRangeLists) :
9828 aRangeLists(rRangeLists),
9829 pDocShell( pDocSh ),
9830 nCurrentPosition(0)
9832 pDocShell->GetDocument()->AddUnoObject(*this);
9835 ScUniqueCellFormatsEnumeration::~ScUniqueCellFormatsEnumeration()
9837 if (pDocShell)
9838 pDocShell->GetDocument()->RemoveUnoObject(*this);
9841 void ScUniqueCellFormatsEnumeration::Notify( SfxBroadcaster&, const SfxHint& rHint )
9843 if ( rHint.ISA( ScUpdateRefHint ) )
9845 //! und nun ???
9847 else if ( rHint.ISA( SfxSimpleHint ) )
9849 sal_uLong nId = ((const SfxSimpleHint&)rHint).GetId();
9850 if ( nId == SFX_HINT_DYING )
9851 pDocShell = NULL; // ungueltig geworden
9855 // XEnumeration
9857 sal_Bool SAL_CALL ScUniqueCellFormatsEnumeration::hasMoreElements() throw(uno::RuntimeException)
9859 SolarMutexGuard aGuard;
9860 return static_cast<sal_uInt32>(nCurrentPosition) < aRangeLists.size();
9863 uno::Any SAL_CALL ScUniqueCellFormatsEnumeration::nextElement() throw(container::NoSuchElementException,
9864 lang::WrappedTargetException, uno::RuntimeException)
9866 SolarMutexGuard aGuard;
9868 if ( !hasMoreElements() || !pDocShell )
9869 throw container::NoSuchElementException(); // no more elements
9871 // Interface-Typ muss zu ScCellFormatsObj::getElementType passen
9873 return uno::makeAny(uno::Reference<sheet::XSheetCellRangeContainer>(new ScCellRangesObj(pDocShell, aRangeLists[nCurrentPosition++])));
9876 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */