merge the formfield patch from ooo-build
[ooovba.git] / sc / source / ui / unoobj / cellsuno.cxx
blob321dd85a52225ee857e2cb7d424b8e73586bc87e
1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: cellsuno.cxx,v $
10 * $Revision: 1.113.126.2 $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
31 // MARKER(update_precomp.py): autogen include statement, do not remove
32 #include "precompiled_sc.hxx"
35 #include "scitems.hxx"
36 #include <svx/eeitem.hxx>
39 #include <svx/algitem.hxx>
40 #include <svx/boxitem.hxx>
41 #include <svx/brshitem.hxx>
42 #include <svx/editeng.hxx>
43 #include <svx/flditem.hxx>
44 #include <svx/fmdpage.hxx>
45 #include <svx/langitem.hxx>
46 #include <svx/linkmgr.hxx>
47 #include <svx/srchitem.hxx>
48 #include <svx/unomid.hxx>
49 #include <svx/unoprnms.hxx>
50 #include <svx/unotext.hxx>
51 #include <svx/svdpage.hxx>
52 #include <sfx2/bindings.hxx>
53 #include <svtools/zforlist.hxx>
54 #include <svtools/zformat.hxx>
55 #include <rtl/uuid.h>
56 #include <float.h> // DBL_MIN
58 #include <com/sun/star/awt/XBitmap.hpp>
59 #include <com/sun/star/util/CellProtection.hpp>
60 #include <com/sun/star/table/CellHoriJustify.hpp>
61 #include <com/sun/star/table/CellOrientation.hpp>
62 #include <com/sun/star/table/CellVertJustify.hpp>
63 #include <com/sun/star/table/ShadowFormat.hpp>
64 #include <com/sun/star/table/TableBorder.hpp>
65 #include <com/sun/star/sheet/CellFlags.hpp>
66 #include <com/sun/star/sheet/FormulaResult.hpp>
67 #include <com/sun/star/beans/PropertyAttribute.hpp>
68 #include <com/sun/star/lang/Locale.hpp>
69 #include <com/sun/star/beans/TolerantPropertySetResultType.hpp>
70 #include <com/sun/star/beans/SetPropertyTolerantFailed.hpp>
71 #include <com/sun/star/text/WritingMode2.hpp>
73 #include "autoform.hxx"
74 #include "cellmergeoption.hxx"
75 #include "cellsuno.hxx"
76 #include "cursuno.hxx"
77 #include "textuno.hxx"
78 #include "editsrc.hxx"
79 #include "notesuno.hxx"
80 #include "fielduno.hxx"
81 #include "docuno.hxx" // ScTableColumnsObj etc
82 #include "datauno.hxx"
83 #include "dapiuno.hxx"
84 #include "chartuno.hxx"
85 #include "fmtuno.hxx"
86 #include "miscuno.hxx"
87 #include "convuno.hxx"
88 #include "srchuno.hxx"
89 #include "targuno.hxx"
90 #include "tokenuno.hxx"
91 #include "docsh.hxx"
92 #include "markdata.hxx"
93 #include "patattr.hxx"
94 #include "docpool.hxx"
95 #include "docfunc.hxx"
96 #include "dbdocfun.hxx"
97 #include "olinefun.hxx"
98 #include "hints.hxx"
99 #include "cell.hxx"
100 #include "undocell.hxx"
101 #include "undotab.hxx"
102 #include "undoblk.hxx" // fuer lcl_ApplyBorder - nach docfunc verschieben!
103 #include "stlsheet.hxx"
104 #include "dbcolect.hxx"
105 #include "attrib.hxx"
106 #include "chartarr.hxx"
107 #include "chartlis.hxx"
108 #include "drwlayer.hxx"
109 #include "printfun.hxx"
110 #include "prnsave.hxx"
111 #include "tablink.hxx"
112 #include "dociter.hxx"
113 #include "rangeutl.hxx"
114 #include "conditio.hxx"
115 #include "validat.hxx"
116 #include "sc.hrc"
117 #include "brdcst.hxx"
118 #include "unoguard.hxx"
119 #include "cellform.hxx"
120 #include "globstr.hrc"
121 #include "unonames.hxx"
122 #include "styleuno.hxx"
123 #include "rangeseq.hxx"
124 #include "unowids.hxx"
125 #include "paramisc.hxx"
126 #include "formula/errorcodes.hxx"
127 #include "unoreflist.hxx"
128 #include "formula/grammar.hxx"
130 #include <list>
132 using namespace com::sun::star;
134 //------------------------------------------------------------------------
137 class ScNamedEntry
139 String aName;
140 ScRange aRange;
142 public:
143 ScNamedEntry(const String& rN, const ScRange& rR) :
144 aName(rN), aRange(rR) {}
146 const String& GetName() const { return aName; }
147 const ScRange& GetRange() const { return aRange; }
151 //------------------------------------------------------------------------
153 // Die Namen in den Maps muessen (nach strcmp) sortiert sein!
154 //! statt Which-ID 0 special IDs verwenden, und nicht ueber Namen vergleichen !!!!!!!!!
156 // Left/Right/Top/BottomBorder are mapped directly to the core items,
157 // not collected/applied to the borders of a range -> ATTR_BORDER can be used directly
159 const SfxItemPropertySet* lcl_GetCellsPropertySet()
161 static SfxItemPropertyMapEntry aCellsPropertyMap_Impl[] =
163 {MAP_CHAR_LEN(SC_UNONAME_ABSNAME), SC_WID_UNO_ABSNAME, &getCppuType((rtl::OUString*)0), 0 | beans::PropertyAttribute::READONLY, 0 },
164 {MAP_CHAR_LEN(SC_UNONAME_ASIANVERT),ATTR_VERTICAL_ASIAN,&getBooleanCppuType(), 0, 0 },
165 {MAP_CHAR_LEN(SC_UNONAME_BOTTBORDER),ATTR_BORDER, &::getCppuType((const table::BorderLine*)0), 0, BOTTOM_BORDER | CONVERT_TWIPS },
166 {MAP_CHAR_LEN(SC_UNONAME_CELLBACK), ATTR_BACKGROUND, &getCppuType((sal_Int32*)0), 0, MID_BACK_COLOR },
167 {MAP_CHAR_LEN(SC_UNONAME_CELLPRO), ATTR_PROTECTION, &getCppuType((util::CellProtection*)0), 0, 0 },
168 {MAP_CHAR_LEN(SC_UNONAME_CELLSTYL), SC_WID_UNO_CELLSTYL,&getCppuType((rtl::OUString*)0), 0, 0 },
169 {MAP_CHAR_LEN(SC_UNONAME_CCOLOR), ATTR_FONT_COLOR, &getCppuType((sal_Int32*)0), 0, 0 },
170 {MAP_CHAR_LEN(SC_UNONAME_COUTL), ATTR_FONT_CONTOUR, &getBooleanCppuType(), 0, 0 },
171 {MAP_CHAR_LEN(SC_UNONAME_CCROSS), ATTR_FONT_CROSSEDOUT,&getBooleanCppuType(), 0, MID_CROSSED_OUT },
172 {MAP_CHAR_LEN(SC_UNONAME_CEMPHAS), ATTR_FONT_EMPHASISMARK,&getCppuType((sal_Int16*)0), 0, MID_EMPHASIS },
173 {MAP_CHAR_LEN(SC_UNONAME_CFONT), ATTR_FONT, &getCppuType((sal_Int16*)0), 0, MID_FONT_FAMILY },
174 {MAP_CHAR_LEN(SC_UNONAME_CFCHARS), ATTR_FONT, &getCppuType((sal_Int16*)0), 0, MID_FONT_CHAR_SET },
175 {MAP_CHAR_LEN(SC_UNO_CJK_CFCHARS), ATTR_CJK_FONT, &getCppuType((sal_Int16*)0), 0, MID_FONT_CHAR_SET },
176 {MAP_CHAR_LEN(SC_UNO_CTL_CFCHARS), ATTR_CTL_FONT, &getCppuType((sal_Int16*)0), 0, MID_FONT_CHAR_SET },
177 {MAP_CHAR_LEN(SC_UNONAME_CFFAMIL), ATTR_FONT, &getCppuType((sal_Int16*)0), 0, MID_FONT_FAMILY },
178 {MAP_CHAR_LEN(SC_UNO_CJK_CFFAMIL), ATTR_CJK_FONT, &getCppuType((sal_Int16*)0), 0, MID_FONT_FAMILY },
179 {MAP_CHAR_LEN(SC_UNO_CTL_CFFAMIL), ATTR_CTL_FONT, &getCppuType((sal_Int16*)0), 0, MID_FONT_FAMILY },
180 {MAP_CHAR_LEN(SC_UNONAME_CFNAME), ATTR_FONT, &getCppuType((rtl::OUString*)0), 0, MID_FONT_FAMILY_NAME },
181 {MAP_CHAR_LEN(SC_UNO_CJK_CFNAME), ATTR_CJK_FONT, &getCppuType((rtl::OUString*)0), 0, MID_FONT_FAMILY_NAME },
182 {MAP_CHAR_LEN(SC_UNO_CTL_CFNAME), ATTR_CTL_FONT, &getCppuType((rtl::OUString*)0), 0, MID_FONT_FAMILY_NAME },
183 {MAP_CHAR_LEN(SC_UNONAME_CFPITCH), ATTR_FONT, &getCppuType((sal_Int16*)0), 0, MID_FONT_PITCH },
184 {MAP_CHAR_LEN(SC_UNO_CJK_CFPITCH), ATTR_CJK_FONT, &getCppuType((sal_Int16*)0), 0, MID_FONT_PITCH },
185 {MAP_CHAR_LEN(SC_UNO_CTL_CFPITCH), ATTR_CTL_FONT, &getCppuType((sal_Int16*)0), 0, MID_FONT_PITCH },
186 {MAP_CHAR_LEN(SC_UNONAME_CFSTYLE), ATTR_FONT, &getCppuType((rtl::OUString*)0), 0, MID_FONT_STYLE_NAME },
187 {MAP_CHAR_LEN(SC_UNO_CJK_CFSTYLE), ATTR_CJK_FONT, &getCppuType((rtl::OUString*)0), 0, MID_FONT_STYLE_NAME },
188 {MAP_CHAR_LEN(SC_UNO_CTL_CFSTYLE), ATTR_CTL_FONT, &getCppuType((rtl::OUString*)0), 0, MID_FONT_STYLE_NAME },
189 {MAP_CHAR_LEN(SC_UNONAME_CHEIGHT), ATTR_FONT_HEIGHT, &getCppuType((float*)0), 0, MID_FONTHEIGHT | CONVERT_TWIPS },
190 {MAP_CHAR_LEN(SC_UNO_CJK_CHEIGHT), ATTR_CJK_FONT_HEIGHT,&getCppuType((float*)0), 0, MID_FONTHEIGHT | CONVERT_TWIPS },
191 {MAP_CHAR_LEN(SC_UNO_CTL_CHEIGHT), ATTR_CTL_FONT_HEIGHT,&getCppuType((float*)0), 0, MID_FONTHEIGHT | CONVERT_TWIPS },
192 {MAP_CHAR_LEN(SC_UNONAME_CLOCAL), ATTR_FONT_LANGUAGE, &getCppuType((lang::Locale*)0), 0, MID_LANG_LOCALE },
193 {MAP_CHAR_LEN(SC_UNO_CJK_CLOCAL), ATTR_CJK_FONT_LANGUAGE,&getCppuType((lang::Locale*)0), 0, MID_LANG_LOCALE },
194 {MAP_CHAR_LEN(SC_UNO_CTL_CLOCAL), ATTR_CTL_FONT_LANGUAGE,&getCppuType((lang::Locale*)0), 0, MID_LANG_LOCALE },
195 {MAP_CHAR_LEN(SC_UNONAME_COVER), ATTR_FONT_OVERLINE, &getCppuType((sal_Int16*)0), 0, MID_TL_STYLE },
196 {MAP_CHAR_LEN(SC_UNONAME_COVRLCOL), ATTR_FONT_OVERLINE, &getCppuType((sal_Int32*)0), 0, MID_TL_COLOR },
197 {MAP_CHAR_LEN(SC_UNONAME_COVRLHAS), ATTR_FONT_OVERLINE, &getBooleanCppuType(), 0, MID_TL_HASCOLOR },
198 {MAP_CHAR_LEN(SC_UNONAME_CPOST), ATTR_FONT_POSTURE, &getCppuType((awt::FontSlant*)0), 0, MID_POSTURE },
199 {MAP_CHAR_LEN(SC_UNO_CJK_CPOST), ATTR_CJK_FONT_POSTURE,&getCppuType((awt::FontSlant*)0), 0, MID_POSTURE },
200 {MAP_CHAR_LEN(SC_UNO_CTL_CPOST), ATTR_CTL_FONT_POSTURE,&getCppuType((awt::FontSlant*)0), 0, MID_POSTURE },
201 {MAP_CHAR_LEN(SC_UNONAME_CRELIEF), ATTR_FONT_RELIEF, &getCppuType((sal_Int16*)0), 0, MID_RELIEF },
202 {MAP_CHAR_LEN(SC_UNONAME_CSHADD), ATTR_FONT_SHADOWED, &getBooleanCppuType(), 0, 0 },
203 {MAP_CHAR_LEN(SC_UNONAME_CSTRIKE), ATTR_FONT_CROSSEDOUT,&getCppuType((sal_Int16*)0), 0, MID_CROSS_OUT },
204 {MAP_CHAR_LEN(SC_UNONAME_CUNDER), ATTR_FONT_UNDERLINE,&getCppuType((sal_Int16*)0), 0, MID_TL_STYLE },
205 {MAP_CHAR_LEN(SC_UNONAME_CUNDLCOL), ATTR_FONT_UNDERLINE,&getCppuType((sal_Int32*)0), 0, MID_TL_COLOR },
206 {MAP_CHAR_LEN(SC_UNONAME_CUNDLHAS), ATTR_FONT_UNDERLINE,&getBooleanCppuType(), 0, MID_TL_HASCOLOR },
207 {MAP_CHAR_LEN(SC_UNONAME_CWEIGHT), ATTR_FONT_WEIGHT, &getCppuType((float*)0), 0, MID_WEIGHT },
208 {MAP_CHAR_LEN(SC_UNO_CJK_CWEIGHT), ATTR_CJK_FONT_WEIGHT,&getCppuType((float*)0), 0, MID_WEIGHT },
209 {MAP_CHAR_LEN(SC_UNO_CTL_CWEIGHT), ATTR_CTL_FONT_WEIGHT,&getCppuType((float*)0), 0, MID_WEIGHT },
210 {MAP_CHAR_LEN(SC_UNONAME_CWORDMOD), ATTR_FONT_WORDLINE, &getBooleanCppuType(), 0, 0 },
211 {MAP_CHAR_LEN(SC_UNONAME_CHCOLHDR), SC_WID_UNO_CHCOLHDR,&getBooleanCppuType(), 0, 0 },
212 {MAP_CHAR_LEN(SC_UNONAME_CHROWHDR), SC_WID_UNO_CHROWHDR,&getBooleanCppuType(), 0, 0 },
213 {MAP_CHAR_LEN(SC_UNONAME_CONDFMT), SC_WID_UNO_CONDFMT, &getCppuType((uno::Reference<sheet::XSheetConditionalEntries>*)0), 0, 0 },
214 {MAP_CHAR_LEN(SC_UNONAME_CONDLOC), SC_WID_UNO_CONDLOC, &getCppuType((uno::Reference<sheet::XSheetConditionalEntries>*)0), 0, 0 },
215 {MAP_CHAR_LEN(SC_UNONAME_CONDXML), SC_WID_UNO_CONDXML, &getCppuType((uno::Reference<sheet::XSheetConditionalEntries>*)0), 0, 0 },
216 {MAP_CHAR_LEN(SC_UNONAME_DIAGONAL_BLTR), ATTR_BORDER_BLTR, &::getCppuType((const table::BorderLine*)0), 0, 0 | CONVERT_TWIPS },
217 {MAP_CHAR_LEN(SC_UNONAME_DIAGONAL_TLBR), ATTR_BORDER_TLBR, &::getCppuType((const table::BorderLine*)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_CELLTRAN), ATTR_BACKGROUND, &getBooleanCppuType(), 0, MID_GRAPHIC_TRANSPARENT },
220 {MAP_CHAR_LEN(SC_UNONAME_WRAP), ATTR_LINEBREAK, &getBooleanCppuType(), 0, 0 },
221 {MAP_CHAR_LEN(SC_UNONAME_LEFTBORDER),ATTR_BORDER, &::getCppuType((const table::BorderLine*)0), 0, LEFT_BORDER | CONVERT_TWIPS },
222 {MAP_CHAR_LEN(SC_UNONAME_NUMFMT), ATTR_VALUE_FORMAT, &getCppuType((sal_Int32*)0), 0, 0 },
223 {MAP_CHAR_LEN(SC_UNONAME_NUMRULES), SC_WID_UNO_NUMRULES,&getCppuType((const uno::Reference<container::XIndexReplace>*)0), 0, 0 },
224 {MAP_CHAR_LEN(SC_UNONAME_CELLORI), ATTR_STACKED, &getCppuType((table::CellOrientation*)0), 0, 0 },
225 {MAP_CHAR_LEN(SC_UNONAME_PADJUST), ATTR_HOR_JUSTIFY, &::getCppuType((const sal_Int16*)0), 0, MID_HORJUST_ADJUST },
226 {MAP_CHAR_LEN(SC_UNONAME_PBMARGIN), ATTR_MARGIN, &getCppuType((sal_Int32*)0), 0, MID_MARGIN_LO_MARGIN | CONVERT_TWIPS },
227 {MAP_CHAR_LEN(SC_UNONAME_PINDENT), ATTR_INDENT, &getCppuType((sal_Int16*)0), 0, 0 }, //! CONVERT_TWIPS
228 {MAP_CHAR_LEN(SC_UNONAME_PISCHDIST),ATTR_SCRIPTSPACE, &getBooleanCppuType(), 0, 0 },
229 {MAP_CHAR_LEN(SC_UNONAME_PISFORBID),ATTR_FORBIDDEN_RULES,&getBooleanCppuType(), 0, 0 },
230 {MAP_CHAR_LEN(SC_UNONAME_PISHANG), ATTR_HANGPUNCTUATION,&getBooleanCppuType(), 0, 0 },
231 {MAP_CHAR_LEN(SC_UNONAME_PISHYPHEN),ATTR_HYPHENATE, &getBooleanCppuType(), 0, 0 },
232 {MAP_CHAR_LEN(SC_UNONAME_PLASTADJ), ATTR_HOR_JUSTIFY, &::getCppuType((const sal_Int16*)0), 0, MID_HORJUST_ADJUST },
233 {MAP_CHAR_LEN(SC_UNONAME_PLMARGIN), ATTR_MARGIN, &getCppuType((sal_Int32*)0), 0, MID_MARGIN_L_MARGIN | CONVERT_TWIPS },
234 {MAP_CHAR_LEN(SC_UNONAME_PRMARGIN), ATTR_MARGIN, &getCppuType((sal_Int32*)0), 0, MID_MARGIN_R_MARGIN | CONVERT_TWIPS },
235 {MAP_CHAR_LEN(SC_UNONAME_PTMARGIN), ATTR_MARGIN, &getCppuType((sal_Int32*)0), 0, MID_MARGIN_UP_MARGIN | CONVERT_TWIPS },
236 {MAP_CHAR_LEN(SC_UNONAME_RIGHTBORDER),ATTR_BORDER, &::getCppuType((const table::BorderLine*)0), 0, RIGHT_BORDER | CONVERT_TWIPS },
237 {MAP_CHAR_LEN(SC_UNONAME_ROTANG), ATTR_ROTATE_VALUE, &getCppuType((sal_Int32*)0), 0, 0 },
238 {MAP_CHAR_LEN(SC_UNONAME_ROTREF), ATTR_ROTATE_MODE, &getCppuType((table::CellVertJustify*)0), 0, 0 },
239 {MAP_CHAR_LEN(SC_UNONAME_SHADOW), ATTR_SHADOW, &getCppuType((table::ShadowFormat*)0), 0, 0 | CONVERT_TWIPS },
240 {MAP_CHAR_LEN(SC_UNONAME_SHRINK_TO_FIT), ATTR_SHRINKTOFIT, &getBooleanCppuType(), 0, 0 },
241 {MAP_CHAR_LEN(SC_UNONAME_TBLBORD), SC_WID_UNO_TBLBORD, &getCppuType((table::TableBorder*)0), 0, 0 | CONVERT_TWIPS },
242 {MAP_CHAR_LEN(SC_UNONAME_TOPBORDER),ATTR_BORDER, &::getCppuType((const table::BorderLine*)0), 0, TOP_BORDER | CONVERT_TWIPS },
243 {MAP_CHAR_LEN(SC_UNONAME_USERDEF), ATTR_USERDEF, &getCppuType((uno::Reference<container::XNameContainer>*)0), 0, 0 },
244 {MAP_CHAR_LEN(SC_UNONAME_VALIDAT), SC_WID_UNO_VALIDAT, &getCppuType((uno::Reference<beans::XPropertySet>*)0), 0, 0 },
245 {MAP_CHAR_LEN(SC_UNONAME_VALILOC), SC_WID_UNO_VALILOC, &getCppuType((uno::Reference<beans::XPropertySet>*)0), 0, 0 },
246 {MAP_CHAR_LEN(SC_UNONAME_VALIXML), SC_WID_UNO_VALIXML, &getCppuType((uno::Reference<beans::XPropertySet>*)0), 0, 0 },
247 {MAP_CHAR_LEN(SC_UNONAME_CELLVJUS), ATTR_VER_JUSTIFY, &getCppuType((table::CellVertJustify*)0), 0, 0 },
248 {MAP_CHAR_LEN(SC_UNONAME_WRITING), ATTR_WRITINGDIR, &getCppuType((sal_Int16*)0), 0, 0 },
249 {0,0,0,0,0,0}
251 static SfxItemPropertySet aCellsPropertySet( aCellsPropertyMap_Impl );
252 return &aCellsPropertySet;
255 // CellRange enthaelt alle Eintraege von Cells, zusaetzlich eigene Eintraege
256 // mit Which-ID 0 (werden nur fuer getPropertySetInfo benoetigt).
258 const SfxItemPropertySet* lcl_GetRangePropertySet()
260 static SfxItemPropertyMapEntry aRangePropertyMap_Impl[] =
262 {MAP_CHAR_LEN(SC_UNONAME_ABSNAME), SC_WID_UNO_ABSNAME, &getCppuType((rtl::OUString*)0), 0 | beans::PropertyAttribute::READONLY, 0 },
263 {MAP_CHAR_LEN(SC_UNONAME_ASIANVERT),ATTR_VERTICAL_ASIAN,&getBooleanCppuType(), 0, 0 },
264 {MAP_CHAR_LEN(SC_UNONAME_BOTTBORDER),ATTR_BORDER, &::getCppuType((const table::BorderLine*)0), 0, BOTTOM_BORDER | CONVERT_TWIPS },
265 {MAP_CHAR_LEN(SC_UNONAME_CELLBACK), ATTR_BACKGROUND, &getCppuType((sal_Int32*)0), 0, MID_BACK_COLOR },
266 {MAP_CHAR_LEN(SC_UNONAME_CELLPRO), ATTR_PROTECTION, &getCppuType((util::CellProtection*)0), 0, 0 },
267 {MAP_CHAR_LEN(SC_UNONAME_CELLSTYL), SC_WID_UNO_CELLSTYL,&getCppuType((rtl::OUString*)0), 0, 0 },
268 {MAP_CHAR_LEN(SC_UNONAME_CCOLOR), ATTR_FONT_COLOR, &getCppuType((sal_Int32*)0), 0, 0 },
269 {MAP_CHAR_LEN(SC_UNONAME_COUTL), ATTR_FONT_CONTOUR, &getBooleanCppuType(), 0, 0 },
270 {MAP_CHAR_LEN(SC_UNONAME_CCROSS), ATTR_FONT_CROSSEDOUT,&getBooleanCppuType(), 0, MID_CROSSED_OUT },
271 {MAP_CHAR_LEN(SC_UNONAME_CEMPHAS), ATTR_FONT_EMPHASISMARK,&getCppuType((sal_Int16*)0), 0, MID_EMPHASIS },
272 {MAP_CHAR_LEN(SC_UNONAME_CFONT), ATTR_FONT, &getCppuType((sal_Int16*)0), 0, MID_FONT_FAMILY },
273 {MAP_CHAR_LEN(SC_UNONAME_CFCHARS), ATTR_FONT, &getCppuType((sal_Int16*)0), 0, MID_FONT_CHAR_SET },
274 {MAP_CHAR_LEN(SC_UNO_CJK_CFCHARS), ATTR_CJK_FONT, &getCppuType((sal_Int16*)0), 0, MID_FONT_CHAR_SET },
275 {MAP_CHAR_LEN(SC_UNO_CTL_CFCHARS), ATTR_CTL_FONT, &getCppuType((sal_Int16*)0), 0, MID_FONT_CHAR_SET },
276 {MAP_CHAR_LEN(SC_UNONAME_CFFAMIL), ATTR_FONT, &getCppuType((sal_Int16*)0), 0, MID_FONT_FAMILY },
277 {MAP_CHAR_LEN(SC_UNO_CJK_CFFAMIL), ATTR_CJK_FONT, &getCppuType((sal_Int16*)0), 0, MID_FONT_FAMILY },
278 {MAP_CHAR_LEN(SC_UNO_CTL_CFFAMIL), ATTR_CTL_FONT, &getCppuType((sal_Int16*)0), 0, MID_FONT_FAMILY },
279 {MAP_CHAR_LEN(SC_UNONAME_CFNAME), ATTR_FONT, &getCppuType((rtl::OUString*)0), 0, MID_FONT_FAMILY_NAME },
280 {MAP_CHAR_LEN(SC_UNO_CJK_CFNAME), ATTR_CJK_FONT, &getCppuType((rtl::OUString*)0), 0, MID_FONT_FAMILY_NAME },
281 {MAP_CHAR_LEN(SC_UNO_CTL_CFNAME), ATTR_CTL_FONT, &getCppuType((rtl::OUString*)0), 0, MID_FONT_FAMILY_NAME },
282 {MAP_CHAR_LEN(SC_UNONAME_CFPITCH), ATTR_FONT, &getCppuType((sal_Int16*)0), 0, MID_FONT_PITCH },
283 {MAP_CHAR_LEN(SC_UNO_CJK_CFPITCH), ATTR_CJK_FONT, &getCppuType((sal_Int16*)0), 0, MID_FONT_PITCH },
284 {MAP_CHAR_LEN(SC_UNO_CTL_CFPITCH), ATTR_CTL_FONT, &getCppuType((sal_Int16*)0), 0, MID_FONT_PITCH },
285 {MAP_CHAR_LEN(SC_UNONAME_CFSTYLE), ATTR_FONT, &getCppuType((rtl::OUString*)0), 0, MID_FONT_STYLE_NAME },
286 {MAP_CHAR_LEN(SC_UNO_CJK_CFSTYLE), ATTR_CJK_FONT, &getCppuType((rtl::OUString*)0), 0, MID_FONT_STYLE_NAME },
287 {MAP_CHAR_LEN(SC_UNO_CTL_CFSTYLE), ATTR_CTL_FONT, &getCppuType((rtl::OUString*)0), 0, MID_FONT_STYLE_NAME },
288 {MAP_CHAR_LEN(SC_UNONAME_CHEIGHT), ATTR_FONT_HEIGHT, &getCppuType((float*)0), 0, MID_FONTHEIGHT | CONVERT_TWIPS },
289 {MAP_CHAR_LEN(SC_UNO_CJK_CHEIGHT), ATTR_CJK_FONT_HEIGHT,&getCppuType((float*)0), 0, MID_FONTHEIGHT | CONVERT_TWIPS },
290 {MAP_CHAR_LEN(SC_UNO_CTL_CHEIGHT), ATTR_CTL_FONT_HEIGHT,&getCppuType((float*)0), 0, MID_FONTHEIGHT | CONVERT_TWIPS },
291 {MAP_CHAR_LEN(SC_UNONAME_CLOCAL), ATTR_FONT_LANGUAGE, &getCppuType((lang::Locale*)0), 0, MID_LANG_LOCALE },
292 {MAP_CHAR_LEN(SC_UNO_CJK_CLOCAL), ATTR_CJK_FONT_LANGUAGE,&getCppuType((lang::Locale*)0), 0, MID_LANG_LOCALE },
293 {MAP_CHAR_LEN(SC_UNO_CTL_CLOCAL), ATTR_CTL_FONT_LANGUAGE,&getCppuType((lang::Locale*)0), 0, MID_LANG_LOCALE },
294 {MAP_CHAR_LEN(SC_UNONAME_COVER), ATTR_FONT_OVERLINE, &getCppuType((sal_Int16*)0), 0, MID_TL_STYLE },
295 {MAP_CHAR_LEN(SC_UNONAME_COVRLCOL), ATTR_FONT_OVERLINE, &getCppuType((sal_Int32*)0), 0, MID_TL_COLOR },
296 {MAP_CHAR_LEN(SC_UNONAME_COVRLHAS), ATTR_FONT_OVERLINE, &getBooleanCppuType(), 0, MID_TL_HASCOLOR },
297 {MAP_CHAR_LEN(SC_UNONAME_CPOST), ATTR_FONT_POSTURE, &getCppuType((awt::FontSlant*)0), 0, MID_POSTURE },
298 {MAP_CHAR_LEN(SC_UNO_CJK_CPOST), ATTR_CJK_FONT_POSTURE,&getCppuType((awt::FontSlant*)0), 0, MID_POSTURE },
299 {MAP_CHAR_LEN(SC_UNO_CTL_CPOST), ATTR_CTL_FONT_POSTURE,&getCppuType((awt::FontSlant*)0), 0, MID_POSTURE },
300 {MAP_CHAR_LEN(SC_UNONAME_CRELIEF), ATTR_FONT_RELIEF, &getCppuType((sal_Int16*)0), 0, MID_RELIEF },
301 {MAP_CHAR_LEN(SC_UNONAME_CSHADD), ATTR_FONT_SHADOWED, &getBooleanCppuType(), 0, 0 },
302 {MAP_CHAR_LEN(SC_UNONAME_CSTRIKE), ATTR_FONT_CROSSEDOUT,&getCppuType((sal_Int16*)0), 0, MID_CROSS_OUT },
303 {MAP_CHAR_LEN(SC_UNONAME_CUNDER), ATTR_FONT_UNDERLINE,&getCppuType((sal_Int16*)0), 0, MID_TL_STYLE },
304 {MAP_CHAR_LEN(SC_UNONAME_CUNDLCOL), ATTR_FONT_UNDERLINE,&getCppuType((sal_Int32*)0), 0, MID_TL_COLOR },
305 {MAP_CHAR_LEN(SC_UNONAME_CUNDLHAS), ATTR_FONT_UNDERLINE,&getBooleanCppuType(), 0, MID_TL_HASCOLOR },
306 {MAP_CHAR_LEN(SC_UNONAME_CWEIGHT), ATTR_FONT_WEIGHT, &getCppuType((float*)0), 0, MID_WEIGHT },
307 {MAP_CHAR_LEN(SC_UNO_CJK_CWEIGHT), ATTR_CJK_FONT_WEIGHT,&getCppuType((float*)0), 0, MID_WEIGHT },
308 {MAP_CHAR_LEN(SC_UNO_CTL_CWEIGHT), ATTR_CTL_FONT_WEIGHT,&getCppuType((float*)0), 0, MID_WEIGHT },
309 {MAP_CHAR_LEN(SC_UNONAME_CWORDMOD), ATTR_FONT_WORDLINE, &getBooleanCppuType(), 0, 0 },
310 {MAP_CHAR_LEN(SC_UNONAME_CHCOLHDR), SC_WID_UNO_CHCOLHDR,&getBooleanCppuType(), 0, 0 },
311 {MAP_CHAR_LEN(SC_UNONAME_CHROWHDR), SC_WID_UNO_CHROWHDR,&getBooleanCppuType(), 0, 0 },
312 {MAP_CHAR_LEN(SC_UNONAME_CONDFMT), SC_WID_UNO_CONDFMT, &getCppuType((uno::Reference<sheet::XSheetConditionalEntries>*)0), 0, 0 },
313 {MAP_CHAR_LEN(SC_UNONAME_CONDLOC), SC_WID_UNO_CONDLOC, &getCppuType((uno::Reference<sheet::XSheetConditionalEntries>*)0), 0, 0 },
314 {MAP_CHAR_LEN(SC_UNONAME_CONDXML), SC_WID_UNO_CONDXML, &getCppuType((uno::Reference<sheet::XSheetConditionalEntries>*)0), 0, 0 },
315 {MAP_CHAR_LEN(SC_UNONAME_DIAGONAL_BLTR), ATTR_BORDER_BLTR, &::getCppuType((const table::BorderLine*)0), 0, 0 | CONVERT_TWIPS },
316 {MAP_CHAR_LEN(SC_UNONAME_DIAGONAL_TLBR), ATTR_BORDER_TLBR, &::getCppuType((const table::BorderLine*)0), 0, 0 | CONVERT_TWIPS },
317 {MAP_CHAR_LEN(SC_UNONAME_CELLHJUS), ATTR_HOR_JUSTIFY, &getCppuType((table::CellHoriJustify*)0), 0, MID_HORJUST_HORJUST },
318 {MAP_CHAR_LEN(SC_UNONAME_CELLTRAN), ATTR_BACKGROUND, &getBooleanCppuType(), 0, MID_GRAPHIC_TRANSPARENT },
319 {MAP_CHAR_LEN(SC_UNONAME_WRAP), ATTR_LINEBREAK, &getBooleanCppuType(), 0, 0 },
320 {MAP_CHAR_LEN(SC_UNONAME_LEFTBORDER),ATTR_BORDER, &::getCppuType((const table::BorderLine*)0), 0, LEFT_BORDER | CONVERT_TWIPS },
321 {MAP_CHAR_LEN(SC_UNONAME_NUMFMT), ATTR_VALUE_FORMAT, &getCppuType((sal_Int32*)0), 0, 0 },
322 {MAP_CHAR_LEN(SC_UNONAME_NUMRULES), SC_WID_UNO_NUMRULES,&getCppuType((const uno::Reference<container::XIndexReplace>*)0), 0, 0 },
323 {MAP_CHAR_LEN(SC_UNONAME_CELLORI), ATTR_STACKED, &getCppuType((table::CellOrientation*)0), 0, 0 },
324 {MAP_CHAR_LEN(SC_UNONAME_PADJUST), ATTR_HOR_JUSTIFY, &::getCppuType((const sal_Int16*)0), 0, MID_HORJUST_ADJUST },
325 {MAP_CHAR_LEN(SC_UNONAME_PBMARGIN), ATTR_MARGIN, &getCppuType((sal_Int32*)0), 0, MID_MARGIN_LO_MARGIN | CONVERT_TWIPS },
326 {MAP_CHAR_LEN(SC_UNONAME_PINDENT), ATTR_INDENT, &getCppuType((sal_Int16*)0), 0, 0 }, //! CONVERT_TWIPS
327 {MAP_CHAR_LEN(SC_UNONAME_PISCHDIST),ATTR_SCRIPTSPACE, &getBooleanCppuType(), 0, 0 },
328 {MAP_CHAR_LEN(SC_UNONAME_PISFORBID),ATTR_FORBIDDEN_RULES,&getBooleanCppuType(), 0, 0 },
329 {MAP_CHAR_LEN(SC_UNONAME_PISHANG), ATTR_HANGPUNCTUATION,&getBooleanCppuType(), 0, 0 },
330 {MAP_CHAR_LEN(SC_UNONAME_PISHYPHEN),ATTR_HYPHENATE, &getBooleanCppuType(), 0, 0 },
331 {MAP_CHAR_LEN(SC_UNONAME_PLASTADJ), ATTR_HOR_JUSTIFY, &::getCppuType((const sal_Int16*)0), 0, MID_HORJUST_ADJUST },
332 {MAP_CHAR_LEN(SC_UNONAME_PLMARGIN), ATTR_MARGIN, &getCppuType((sal_Int32*)0), 0, MID_MARGIN_L_MARGIN | CONVERT_TWIPS },
333 {MAP_CHAR_LEN(SC_UNONAME_PRMARGIN), ATTR_MARGIN, &getCppuType((sal_Int32*)0), 0, MID_MARGIN_R_MARGIN | CONVERT_TWIPS },
334 {MAP_CHAR_LEN(SC_UNONAME_PTMARGIN), ATTR_MARGIN, &getCppuType((sal_Int32*)0), 0, MID_MARGIN_UP_MARGIN | CONVERT_TWIPS },
335 {MAP_CHAR_LEN(SC_UNONAME_POS), SC_WID_UNO_POS, &getCppuType((awt::Point*)0), 0 | beans::PropertyAttribute::READONLY, 0 },
336 {MAP_CHAR_LEN(SC_UNONAME_RIGHTBORDER),ATTR_BORDER, &::getCppuType((const table::BorderLine*)0), 0, RIGHT_BORDER | CONVERT_TWIPS },
337 {MAP_CHAR_LEN(SC_UNONAME_ROTANG), ATTR_ROTATE_VALUE, &getCppuType((sal_Int32*)0), 0, 0 },
338 {MAP_CHAR_LEN(SC_UNONAME_ROTREF), ATTR_ROTATE_MODE, &getCppuType((table::CellVertJustify*)0), 0, 0 },
339 {MAP_CHAR_LEN(SC_UNONAME_SHADOW), ATTR_SHADOW, &getCppuType((table::ShadowFormat*)0), 0, 0 | CONVERT_TWIPS },
340 {MAP_CHAR_LEN(SC_UNONAME_SHRINK_TO_FIT), ATTR_SHRINKTOFIT, &getBooleanCppuType(), 0, 0 },
341 {MAP_CHAR_LEN(SC_UNONAME_SIZE), SC_WID_UNO_SIZE, &getCppuType((awt::Size*)0), 0 | beans::PropertyAttribute::READONLY, 0 },
342 {MAP_CHAR_LEN(SC_UNONAME_TBLBORD), SC_WID_UNO_TBLBORD, &getCppuType((table::TableBorder*)0), 0, 0 | CONVERT_TWIPS },
343 {MAP_CHAR_LEN(SC_UNONAME_TOPBORDER),ATTR_BORDER, &::getCppuType((const table::BorderLine*)0), 0, TOP_BORDER | CONVERT_TWIPS },
344 {MAP_CHAR_LEN(SC_UNONAME_USERDEF), ATTR_USERDEF, &getCppuType((uno::Reference<container::XNameContainer>*)0), 0, 0 },
345 {MAP_CHAR_LEN(SC_UNONAME_VALIDAT), SC_WID_UNO_VALIDAT, &getCppuType((uno::Reference<beans::XPropertySet>*)0), 0, 0 },
346 {MAP_CHAR_LEN(SC_UNONAME_VALILOC), SC_WID_UNO_VALILOC, &getCppuType((uno::Reference<beans::XPropertySet>*)0), 0, 0 },
347 {MAP_CHAR_LEN(SC_UNONAME_VALIXML), SC_WID_UNO_VALIXML, &getCppuType((uno::Reference<beans::XPropertySet>*)0), 0, 0 },
348 {MAP_CHAR_LEN(SC_UNONAME_CELLVJUS), ATTR_VER_JUSTIFY, &getCppuType((table::CellVertJustify*)0), 0, 0 },
349 {MAP_CHAR_LEN(SC_UNONAME_WRITING), ATTR_WRITINGDIR, &getCppuType((sal_Int16*)0), 0, 0 },
350 {0,0,0,0,0,0}
352 static SfxItemPropertySet aRangePropertySet( aRangePropertyMap_Impl );
353 return &aRangePropertySet;
356 // Cell enthaelt alle Eintraege von CellRange, zusaetzlich eigene Eintraege
357 // mit Which-ID 0 (werden nur fuer getPropertySetInfo benoetigt).
359 const SfxItemPropertySet* lcl_GetCellPropertySet()
361 static SfxItemPropertyMapEntry aCellPropertyMap_Impl[] =
363 {MAP_CHAR_LEN(SC_UNONAME_ABSNAME), SC_WID_UNO_ABSNAME, &getCppuType((rtl::OUString*)0), 0 | beans::PropertyAttribute::READONLY, 0 },
364 {MAP_CHAR_LEN(SC_UNONAME_ASIANVERT),ATTR_VERTICAL_ASIAN,&getBooleanCppuType(), 0, 0 },
365 {MAP_CHAR_LEN(SC_UNONAME_BOTTBORDER),ATTR_BORDER, &::getCppuType((const table::BorderLine*)0), 0, BOTTOM_BORDER | CONVERT_TWIPS },
366 {MAP_CHAR_LEN(SC_UNONAME_CELLBACK), ATTR_BACKGROUND, &getCppuType((sal_Int32*)0), 0, MID_BACK_COLOR },
367 {MAP_CHAR_LEN(SC_UNONAME_CELLPRO), ATTR_PROTECTION, &getCppuType((util::CellProtection*)0), 0, 0 },
368 {MAP_CHAR_LEN(SC_UNONAME_CELLSTYL), SC_WID_UNO_CELLSTYL,&getCppuType((rtl::OUString*)0), 0, 0 },
369 {MAP_CHAR_LEN(SC_UNONAME_CCOLOR), ATTR_FONT_COLOR, &getCppuType((sal_Int32*)0), 0, 0 },
370 {MAP_CHAR_LEN(SC_UNONAME_COUTL), ATTR_FONT_CONTOUR, &getBooleanCppuType(), 0, 0 },
371 {MAP_CHAR_LEN(SC_UNONAME_CCROSS), ATTR_FONT_CROSSEDOUT,&getBooleanCppuType(), 0, MID_CROSSED_OUT },
372 {MAP_CHAR_LEN(SC_UNONAME_CEMPHAS), ATTR_FONT_EMPHASISMARK,&getCppuType((sal_Int16*)0), 0, MID_EMPHASIS },
373 {MAP_CHAR_LEN(SC_UNONAME_CFONT), ATTR_FONT, &getCppuType((sal_Int16*)0), 0, MID_FONT_FAMILY },
374 {MAP_CHAR_LEN(SC_UNONAME_CFCHARS), ATTR_FONT, &getCppuType((sal_Int16*)0), 0, MID_FONT_CHAR_SET },
375 {MAP_CHAR_LEN(SC_UNO_CJK_CFCHARS), ATTR_CJK_FONT, &getCppuType((sal_Int16*)0), 0, MID_FONT_CHAR_SET },
376 {MAP_CHAR_LEN(SC_UNO_CTL_CFCHARS), ATTR_CTL_FONT, &getCppuType((sal_Int16*)0), 0, MID_FONT_CHAR_SET },
377 {MAP_CHAR_LEN(SC_UNONAME_CFFAMIL), ATTR_FONT, &getCppuType((sal_Int16*)0), 0, MID_FONT_FAMILY },
378 {MAP_CHAR_LEN(SC_UNO_CJK_CFFAMIL), ATTR_CJK_FONT, &getCppuType((sal_Int16*)0), 0, MID_FONT_FAMILY },
379 {MAP_CHAR_LEN(SC_UNO_CTL_CFFAMIL), ATTR_CTL_FONT, &getCppuType((sal_Int16*)0), 0, MID_FONT_FAMILY },
380 {MAP_CHAR_LEN(SC_UNONAME_CFNAME), ATTR_FONT, &getCppuType((rtl::OUString*)0), 0, MID_FONT_FAMILY_NAME },
381 {MAP_CHAR_LEN(SC_UNO_CJK_CFNAME), ATTR_CJK_FONT, &getCppuType((rtl::OUString*)0), 0, MID_FONT_FAMILY_NAME },
382 {MAP_CHAR_LEN(SC_UNO_CTL_CFNAME), ATTR_CTL_FONT, &getCppuType((rtl::OUString*)0), 0, MID_FONT_FAMILY_NAME },
383 {MAP_CHAR_LEN(SC_UNONAME_CFPITCH), ATTR_FONT, &getCppuType((sal_Int16*)0), 0, MID_FONT_PITCH },
384 {MAP_CHAR_LEN(SC_UNO_CJK_CFPITCH), ATTR_CJK_FONT, &getCppuType((sal_Int16*)0), 0, MID_FONT_PITCH },
385 {MAP_CHAR_LEN(SC_UNO_CTL_CFPITCH), ATTR_CTL_FONT, &getCppuType((sal_Int16*)0), 0, MID_FONT_PITCH },
386 {MAP_CHAR_LEN(SC_UNONAME_CFSTYLE), ATTR_FONT, &getCppuType((rtl::OUString*)0), 0, MID_FONT_STYLE_NAME },
387 {MAP_CHAR_LEN(SC_UNO_CJK_CFSTYLE), ATTR_CJK_FONT, &getCppuType((rtl::OUString*)0), 0, MID_FONT_STYLE_NAME },
388 {MAP_CHAR_LEN(SC_UNO_CTL_CFSTYLE), ATTR_CTL_FONT, &getCppuType((rtl::OUString*)0), 0, MID_FONT_STYLE_NAME },
389 {MAP_CHAR_LEN(SC_UNONAME_CHEIGHT), ATTR_FONT_HEIGHT, &getCppuType((float*)0), 0, MID_FONTHEIGHT | CONVERT_TWIPS },
390 {MAP_CHAR_LEN(SC_UNO_CJK_CHEIGHT), ATTR_CJK_FONT_HEIGHT,&getCppuType((float*)0), 0, MID_FONTHEIGHT | CONVERT_TWIPS },
391 {MAP_CHAR_LEN(SC_UNO_CTL_CHEIGHT), ATTR_CTL_FONT_HEIGHT,&getCppuType((float*)0), 0, MID_FONTHEIGHT | CONVERT_TWIPS },
392 {MAP_CHAR_LEN(SC_UNONAME_CLOCAL), ATTR_FONT_LANGUAGE, &getCppuType((lang::Locale*)0), 0, MID_LANG_LOCALE },
393 {MAP_CHAR_LEN(SC_UNO_CJK_CLOCAL), ATTR_CJK_FONT_LANGUAGE,&getCppuType((lang::Locale*)0), 0, MID_LANG_LOCALE },
394 {MAP_CHAR_LEN(SC_UNO_CTL_CLOCAL), ATTR_CTL_FONT_LANGUAGE,&getCppuType((lang::Locale*)0), 0, MID_LANG_LOCALE },
395 {MAP_CHAR_LEN(SC_UNONAME_COVER), ATTR_FONT_OVERLINE, &getCppuType((sal_Int16*)0), 0, MID_TL_STYLE },
396 {MAP_CHAR_LEN(SC_UNONAME_COVRLCOL), ATTR_FONT_OVERLINE, &getCppuType((sal_Int32*)0), 0, MID_TL_COLOR },
397 {MAP_CHAR_LEN(SC_UNONAME_COVRLHAS), ATTR_FONT_OVERLINE, &getBooleanCppuType(), 0, MID_TL_HASCOLOR },
398 {MAP_CHAR_LEN(SC_UNONAME_CPOST), ATTR_FONT_POSTURE, &getCppuType((awt::FontSlant*)0), 0, MID_POSTURE },
399 {MAP_CHAR_LEN(SC_UNO_CJK_CPOST), ATTR_CJK_FONT_POSTURE,&getCppuType((awt::FontSlant*)0), 0, MID_POSTURE },
400 {MAP_CHAR_LEN(SC_UNO_CTL_CPOST), ATTR_CTL_FONT_POSTURE,&getCppuType((awt::FontSlant*)0), 0, MID_POSTURE },
401 {MAP_CHAR_LEN(SC_UNONAME_CRELIEF), ATTR_FONT_RELIEF, &getCppuType((sal_Int16*)0), 0, MID_RELIEF },
402 {MAP_CHAR_LEN(SC_UNONAME_CSHADD), ATTR_FONT_SHADOWED, &getBooleanCppuType(), 0, 0 },
403 {MAP_CHAR_LEN(SC_UNONAME_CSTRIKE), ATTR_FONT_CROSSEDOUT,&getCppuType((sal_Int16*)0), 0, MID_CROSS_OUT },
404 {MAP_CHAR_LEN(SC_UNONAME_CUNDER), ATTR_FONT_UNDERLINE,&getCppuType((sal_Int16*)0), 0, MID_TL_STYLE },
405 {MAP_CHAR_LEN(SC_UNONAME_CUNDLCOL), ATTR_FONT_UNDERLINE,&getCppuType((sal_Int32*)0), 0, MID_TL_COLOR },
406 {MAP_CHAR_LEN(SC_UNONAME_CUNDLHAS), ATTR_FONT_UNDERLINE,&getBooleanCppuType(), 0, MID_TL_HASCOLOR },
407 {MAP_CHAR_LEN(SC_UNONAME_CWEIGHT), ATTR_FONT_WEIGHT, &getCppuType((float*)0), 0, MID_WEIGHT },
408 {MAP_CHAR_LEN(SC_UNO_CJK_CWEIGHT), ATTR_CJK_FONT_WEIGHT,&getCppuType((float*)0), 0, MID_WEIGHT },
409 {MAP_CHAR_LEN(SC_UNO_CTL_CWEIGHT), ATTR_CTL_FONT_WEIGHT,&getCppuType((float*)0), 0, MID_WEIGHT },
410 {MAP_CHAR_LEN(SC_UNONAME_CWORDMOD), ATTR_FONT_WORDLINE, &getBooleanCppuType(), 0, 0 },
411 {MAP_CHAR_LEN(SC_UNONAME_CHCOLHDR), SC_WID_UNO_CHCOLHDR,&getBooleanCppuType(), 0, 0 },
412 {MAP_CHAR_LEN(SC_UNONAME_CHROWHDR), SC_WID_UNO_CHROWHDR,&getBooleanCppuType(), 0, 0 },
413 {MAP_CHAR_LEN(SC_UNONAME_CONDFMT), SC_WID_UNO_CONDFMT, &getCppuType((uno::Reference<sheet::XSheetConditionalEntries>*)0), 0, 0 },
414 {MAP_CHAR_LEN(SC_UNONAME_CONDLOC), SC_WID_UNO_CONDLOC, &getCppuType((uno::Reference<sheet::XSheetConditionalEntries>*)0), 0, 0 },
415 {MAP_CHAR_LEN(SC_UNONAME_CONDXML), SC_WID_UNO_CONDXML, &getCppuType((uno::Reference<sheet::XSheetConditionalEntries>*)0), 0, 0 },
416 {MAP_CHAR_LEN(SC_UNONAME_DIAGONAL_BLTR), ATTR_BORDER_BLTR, &::getCppuType((const table::BorderLine*)0), 0, 0 | CONVERT_TWIPS },
417 {MAP_CHAR_LEN(SC_UNONAME_DIAGONAL_TLBR), ATTR_BORDER_TLBR, &::getCppuType((const table::BorderLine*)0), 0, 0 | CONVERT_TWIPS },
418 {MAP_CHAR_LEN(SC_UNONAME_FORMLOC), SC_WID_UNO_FORMLOC, &getCppuType((rtl::OUString*)0), 0, 0 },
419 {MAP_CHAR_LEN(SC_UNONAME_FORMRT), SC_WID_UNO_FORMRT, &getCppuType((table::CellContentType*)0), 0 | beans::PropertyAttribute::READONLY, 0 },
420 {MAP_CHAR_LEN(SC_UNONAME_CELLHJUS), ATTR_HOR_JUSTIFY, &getCppuType((table::CellHoriJustify*)0), 0, MID_HORJUST_HORJUST },
421 {MAP_CHAR_LEN(SC_UNONAME_CELLTRAN), ATTR_BACKGROUND, &getBooleanCppuType(), 0, MID_GRAPHIC_TRANSPARENT },
422 {MAP_CHAR_LEN(SC_UNONAME_WRAP), ATTR_LINEBREAK, &getBooleanCppuType(), 0, 0 },
423 {MAP_CHAR_LEN(SC_UNONAME_LEFTBORDER),ATTR_BORDER, &::getCppuType((const table::BorderLine*)0), 0, LEFT_BORDER | CONVERT_TWIPS },
424 {MAP_CHAR_LEN(SC_UNONAME_NUMFMT), ATTR_VALUE_FORMAT, &getCppuType((sal_Int32*)0), 0, 0 },
425 {MAP_CHAR_LEN(SC_UNONAME_NUMRULES), SC_WID_UNO_NUMRULES,&getCppuType((const uno::Reference<container::XIndexReplace>*)0), 0, 0 },
426 {MAP_CHAR_LEN(SC_UNONAME_CELLORI), ATTR_STACKED, &getCppuType((table::CellOrientation*)0), 0, 0 },
427 {MAP_CHAR_LEN(SC_UNONAME_PADJUST), ATTR_HOR_JUSTIFY, &::getCppuType((const sal_Int16*)0), 0, MID_HORJUST_ADJUST },
428 {MAP_CHAR_LEN(SC_UNONAME_PBMARGIN), ATTR_MARGIN, &getCppuType((sal_Int32*)0), 0, MID_MARGIN_LO_MARGIN | CONVERT_TWIPS },
429 {MAP_CHAR_LEN(SC_UNONAME_PINDENT), ATTR_INDENT, &getCppuType((sal_Int16*)0), 0, 0 }, //! CONVERT_TWIPS
430 {MAP_CHAR_LEN(SC_UNONAME_PISCHDIST),ATTR_SCRIPTSPACE, &getBooleanCppuType(), 0, 0 },
431 {MAP_CHAR_LEN(SC_UNONAME_PISFORBID),ATTR_FORBIDDEN_RULES,&getBooleanCppuType(), 0, 0 },
432 {MAP_CHAR_LEN(SC_UNONAME_PISHANG), ATTR_HANGPUNCTUATION,&getBooleanCppuType(), 0, 0 },
433 {MAP_CHAR_LEN(SC_UNONAME_PISHYPHEN),ATTR_HYPHENATE, &getBooleanCppuType(), 0, 0 },
434 {MAP_CHAR_LEN(SC_UNONAME_PLASTADJ), ATTR_HOR_JUSTIFY, &::getCppuType((const sal_Int16*)0), 0, MID_HORJUST_ADJUST },
435 {MAP_CHAR_LEN(SC_UNONAME_PLMARGIN), ATTR_MARGIN, &getCppuType((sal_Int32*)0), 0, MID_MARGIN_L_MARGIN | CONVERT_TWIPS },
436 {MAP_CHAR_LEN(SC_UNONAME_PRMARGIN), ATTR_MARGIN, &getCppuType((sal_Int32*)0), 0, MID_MARGIN_R_MARGIN | CONVERT_TWIPS },
437 {MAP_CHAR_LEN(SC_UNONAME_PTMARGIN), ATTR_MARGIN, &getCppuType((sal_Int32*)0), 0, MID_MARGIN_UP_MARGIN | CONVERT_TWIPS },
438 {MAP_CHAR_LEN(SC_UNONAME_POS), SC_WID_UNO_POS, &getCppuType((awt::Point*)0), 0 | beans::PropertyAttribute::READONLY, 0 },
439 {MAP_CHAR_LEN(SC_UNONAME_RIGHTBORDER),ATTR_BORDER, &::getCppuType((const table::BorderLine*)0), 0, RIGHT_BORDER | CONVERT_TWIPS },
440 {MAP_CHAR_LEN(SC_UNONAME_ROTANG), ATTR_ROTATE_VALUE, &getCppuType((sal_Int32*)0), 0, 0 },
441 {MAP_CHAR_LEN(SC_UNONAME_ROTREF), ATTR_ROTATE_MODE, &getCppuType((table::CellVertJustify*)0), 0, 0 },
442 {MAP_CHAR_LEN(SC_UNONAME_SHADOW), ATTR_SHADOW, &getCppuType((table::ShadowFormat*)0), 0, 0 | CONVERT_TWIPS },
443 {MAP_CHAR_LEN(SC_UNONAME_SHRINK_TO_FIT), ATTR_SHRINKTOFIT, &getBooleanCppuType(), 0, 0 },
444 {MAP_CHAR_LEN(SC_UNONAME_SIZE), SC_WID_UNO_SIZE, &getCppuType((awt::Size*)0), 0 | beans::PropertyAttribute::READONLY, 0 },
445 {MAP_CHAR_LEN(SC_UNONAME_TBLBORD), SC_WID_UNO_TBLBORD, &getCppuType((table::TableBorder*)0), 0, 0 | CONVERT_TWIPS },
446 {MAP_CHAR_LEN(SC_UNONAME_TOPBORDER),ATTR_BORDER, &::getCppuType((const table::BorderLine*)0), 0, TOP_BORDER | CONVERT_TWIPS },
447 {MAP_CHAR_LEN(SC_UNONAME_USERDEF), ATTR_USERDEF, &getCppuType((uno::Reference<container::XNameContainer>*)0), 0, 0 },
448 {MAP_CHAR_LEN(SC_UNONAME_VALIDAT), SC_WID_UNO_VALIDAT, &getCppuType((uno::Reference<beans::XPropertySet>*)0), 0, 0 },
449 {MAP_CHAR_LEN(SC_UNONAME_VALILOC), SC_WID_UNO_VALILOC, &getCppuType((uno::Reference<beans::XPropertySet>*)0), 0, 0 },
450 {MAP_CHAR_LEN(SC_UNONAME_VALIXML), SC_WID_UNO_VALIXML, &getCppuType((uno::Reference<beans::XPropertySet>*)0), 0, 0 },
451 {MAP_CHAR_LEN(SC_UNONAME_CELLVJUS), ATTR_VER_JUSTIFY, &getCppuType((table::CellVertJustify*)0), 0, 0 },
452 {MAP_CHAR_LEN(SC_UNONAME_WRITING), ATTR_WRITINGDIR, &getCppuType((sal_Int16*)0), 0, 0 },
453 {0,0,0,0,0,0}
455 static SfxItemPropertySet aCellPropertySet( aCellPropertyMap_Impl );
456 return &aCellPropertySet;
459 // Column und Row enthalten alle Eintraege von CellRange, zusaetzlich eigene Eintraege
460 // mit Which-ID 0 (werden nur fuer getPropertySetInfo benoetigt).
462 const SfxItemPropertySet* lcl_GetColumnPropertySet()
464 static SfxItemPropertyMapEntry aColumnPropertyMap_Impl[] =
466 {MAP_CHAR_LEN(SC_UNONAME_ABSNAME), SC_WID_UNO_ABSNAME, &getCppuType((rtl::OUString*)0), 0 | beans::PropertyAttribute::READONLY, 0 },
467 {MAP_CHAR_LEN(SC_UNONAME_ASIANVERT),ATTR_VERTICAL_ASIAN,&getBooleanCppuType(), 0, 0 },
468 {MAP_CHAR_LEN(SC_UNONAME_BOTTBORDER),ATTR_BORDER, &::getCppuType((const table::BorderLine*)0), 0, BOTTOM_BORDER | CONVERT_TWIPS },
469 {MAP_CHAR_LEN(SC_UNONAME_CELLBACK), ATTR_BACKGROUND, &getCppuType((sal_Int32*)0), 0, MID_BACK_COLOR },
470 {MAP_CHAR_LEN(SC_UNONAME_CELLPRO), ATTR_PROTECTION, &getCppuType((util::CellProtection*)0), 0, 0 },
471 {MAP_CHAR_LEN(SC_UNONAME_CELLSTYL), SC_WID_UNO_CELLSTYL,&getCppuType((rtl::OUString*)0), 0, 0 },
472 {MAP_CHAR_LEN(SC_UNONAME_CCOLOR), ATTR_FONT_COLOR, &getCppuType((sal_Int32*)0), 0, 0 },
473 {MAP_CHAR_LEN(SC_UNONAME_COUTL), ATTR_FONT_CONTOUR, &getBooleanCppuType(), 0, 0 },
474 {MAP_CHAR_LEN(SC_UNONAME_CCROSS), ATTR_FONT_CROSSEDOUT,&getBooleanCppuType(), 0, MID_CROSSED_OUT },
475 {MAP_CHAR_LEN(SC_UNONAME_CEMPHAS), ATTR_FONT_EMPHASISMARK,&getCppuType((sal_Int16*)0), 0, MID_EMPHASIS },
476 {MAP_CHAR_LEN(SC_UNONAME_CFONT), ATTR_FONT, &getCppuType((sal_Int16*)0), 0, MID_FONT_FAMILY },
477 {MAP_CHAR_LEN(SC_UNONAME_CFCHARS), ATTR_FONT, &getCppuType((sal_Int16*)0), 0, MID_FONT_CHAR_SET },
478 {MAP_CHAR_LEN(SC_UNO_CJK_CFCHARS), ATTR_CJK_FONT, &getCppuType((sal_Int16*)0), 0, MID_FONT_CHAR_SET },
479 {MAP_CHAR_LEN(SC_UNO_CTL_CFCHARS), ATTR_CTL_FONT, &getCppuType((sal_Int16*)0), 0, MID_FONT_CHAR_SET },
480 {MAP_CHAR_LEN(SC_UNONAME_CFFAMIL), ATTR_FONT, &getCppuType((sal_Int16*)0), 0, MID_FONT_FAMILY },
481 {MAP_CHAR_LEN(SC_UNO_CJK_CFFAMIL), ATTR_CJK_FONT, &getCppuType((sal_Int16*)0), 0, MID_FONT_FAMILY },
482 {MAP_CHAR_LEN(SC_UNO_CTL_CFFAMIL), ATTR_CTL_FONT, &getCppuType((sal_Int16*)0), 0, MID_FONT_FAMILY },
483 {MAP_CHAR_LEN(SC_UNONAME_CFNAME), ATTR_FONT, &getCppuType((rtl::OUString*)0), 0, MID_FONT_FAMILY_NAME },
484 {MAP_CHAR_LEN(SC_UNO_CJK_CFNAME), ATTR_CJK_FONT, &getCppuType((rtl::OUString*)0), 0, MID_FONT_FAMILY_NAME },
485 {MAP_CHAR_LEN(SC_UNO_CTL_CFNAME), ATTR_CTL_FONT, &getCppuType((rtl::OUString*)0), 0, MID_FONT_FAMILY_NAME },
486 {MAP_CHAR_LEN(SC_UNONAME_CFPITCH), ATTR_FONT, &getCppuType((sal_Int16*)0), 0, MID_FONT_PITCH },
487 {MAP_CHAR_LEN(SC_UNO_CJK_CFPITCH), ATTR_CJK_FONT, &getCppuType((sal_Int16*)0), 0, MID_FONT_PITCH },
488 {MAP_CHAR_LEN(SC_UNO_CTL_CFPITCH), ATTR_CTL_FONT, &getCppuType((sal_Int16*)0), 0, MID_FONT_PITCH },
489 {MAP_CHAR_LEN(SC_UNONAME_CFSTYLE), ATTR_FONT, &getCppuType((rtl::OUString*)0), 0, MID_FONT_STYLE_NAME },
490 {MAP_CHAR_LEN(SC_UNO_CJK_CFSTYLE), ATTR_CJK_FONT, &getCppuType((rtl::OUString*)0), 0, MID_FONT_STYLE_NAME },
491 {MAP_CHAR_LEN(SC_UNO_CTL_CFSTYLE), ATTR_CTL_FONT, &getCppuType((rtl::OUString*)0), 0, MID_FONT_STYLE_NAME },
492 {MAP_CHAR_LEN(SC_UNONAME_CHEIGHT), ATTR_FONT_HEIGHT, &getCppuType((float*)0), 0, MID_FONTHEIGHT | CONVERT_TWIPS },
493 {MAP_CHAR_LEN(SC_UNO_CJK_CHEIGHT), ATTR_CJK_FONT_HEIGHT,&getCppuType((float*)0), 0, MID_FONTHEIGHT | CONVERT_TWIPS },
494 {MAP_CHAR_LEN(SC_UNO_CTL_CHEIGHT), ATTR_CTL_FONT_HEIGHT,&getCppuType((float*)0), 0, MID_FONTHEIGHT | CONVERT_TWIPS },
495 {MAP_CHAR_LEN(SC_UNONAME_CLOCAL), ATTR_FONT_LANGUAGE, &getCppuType((lang::Locale*)0), 0, MID_LANG_LOCALE },
496 {MAP_CHAR_LEN(SC_UNO_CJK_CLOCAL), ATTR_CJK_FONT_LANGUAGE,&getCppuType((lang::Locale*)0), 0, MID_LANG_LOCALE },
497 {MAP_CHAR_LEN(SC_UNO_CTL_CLOCAL), ATTR_CTL_FONT_LANGUAGE,&getCppuType((lang::Locale*)0), 0, MID_LANG_LOCALE },
498 {MAP_CHAR_LEN(SC_UNONAME_COVER), ATTR_FONT_OVERLINE, &getCppuType((sal_Int16*)0), 0, MID_TL_STYLE },
499 {MAP_CHAR_LEN(SC_UNONAME_COVRLCOL), ATTR_FONT_OVERLINE, &getCppuType((sal_Int32*)0), 0, MID_TL_COLOR },
500 {MAP_CHAR_LEN(SC_UNONAME_COVRLHAS), ATTR_FONT_OVERLINE, &getBooleanCppuType(), 0, MID_TL_HASCOLOR },
501 {MAP_CHAR_LEN(SC_UNONAME_CPOST), ATTR_FONT_POSTURE, &getCppuType((awt::FontSlant*)0), 0, MID_POSTURE },
502 {MAP_CHAR_LEN(SC_UNO_CJK_CPOST), ATTR_CJK_FONT_POSTURE,&getCppuType((awt::FontSlant*)0), 0, MID_POSTURE },
503 {MAP_CHAR_LEN(SC_UNO_CTL_CPOST), ATTR_CTL_FONT_POSTURE,&getCppuType((awt::FontSlant*)0), 0, MID_POSTURE },
504 {MAP_CHAR_LEN(SC_UNONAME_CRELIEF), ATTR_FONT_RELIEF, &getCppuType((sal_Int16*)0), 0, MID_RELIEF },
505 {MAP_CHAR_LEN(SC_UNONAME_CSHADD), ATTR_FONT_SHADOWED, &getBooleanCppuType(), 0, 0 },
506 {MAP_CHAR_LEN(SC_UNONAME_CSTRIKE), ATTR_FONT_CROSSEDOUT,&getCppuType((sal_Int16*)0), 0, MID_CROSS_OUT },
507 {MAP_CHAR_LEN(SC_UNONAME_CUNDER), ATTR_FONT_UNDERLINE,&getCppuType((sal_Int16*)0), 0, MID_TL_STYLE },
508 {MAP_CHAR_LEN(SC_UNONAME_CUNDLCOL), ATTR_FONT_UNDERLINE,&getCppuType((sal_Int32*)0), 0, MID_TL_COLOR },
509 {MAP_CHAR_LEN(SC_UNONAME_CUNDLHAS), ATTR_FONT_UNDERLINE,&getBooleanCppuType(), 0, MID_TL_HASCOLOR },
510 {MAP_CHAR_LEN(SC_UNONAME_CWEIGHT), ATTR_FONT_WEIGHT, &getCppuType((float*)0), 0, MID_WEIGHT },
511 {MAP_CHAR_LEN(SC_UNO_CJK_CWEIGHT), ATTR_CJK_FONT_WEIGHT,&getCppuType((float*)0), 0, MID_WEIGHT },
512 {MAP_CHAR_LEN(SC_UNO_CTL_CWEIGHT), ATTR_CTL_FONT_WEIGHT,&getCppuType((float*)0), 0, MID_WEIGHT },
513 {MAP_CHAR_LEN(SC_UNONAME_CWORDMOD), ATTR_FONT_WORDLINE, &getBooleanCppuType(), 0, 0 },
514 {MAP_CHAR_LEN(SC_UNONAME_CHCOLHDR), SC_WID_UNO_CHCOLHDR,&getBooleanCppuType(), 0, 0 },
515 {MAP_CHAR_LEN(SC_UNONAME_CHROWHDR), SC_WID_UNO_CHROWHDR,&getBooleanCppuType(), 0, 0 },
516 {MAP_CHAR_LEN(SC_UNONAME_CONDFMT), SC_WID_UNO_CONDFMT, &getCppuType((uno::Reference<sheet::XSheetConditionalEntries>*)0), 0, 0 },
517 {MAP_CHAR_LEN(SC_UNONAME_CONDLOC), SC_WID_UNO_CONDLOC, &getCppuType((uno::Reference<sheet::XSheetConditionalEntries>*)0), 0, 0 },
518 {MAP_CHAR_LEN(SC_UNONAME_CONDXML), SC_WID_UNO_CONDXML, &getCppuType((uno::Reference<sheet::XSheetConditionalEntries>*)0), 0, 0 },
519 {MAP_CHAR_LEN(SC_UNONAME_DIAGONAL_BLTR), ATTR_BORDER_BLTR, &::getCppuType((const table::BorderLine*)0), 0, 0 | CONVERT_TWIPS },
520 {MAP_CHAR_LEN(SC_UNONAME_DIAGONAL_TLBR), ATTR_BORDER_TLBR, &::getCppuType((const table::BorderLine*)0), 0, 0 | CONVERT_TWIPS },
521 {MAP_CHAR_LEN(SC_UNONAME_CELLHJUS), ATTR_HOR_JUSTIFY, &getCppuType((table::CellHoriJustify*)0), 0, MID_HORJUST_HORJUST },
522 {MAP_CHAR_LEN(SC_UNONAME_CELLTRAN), ATTR_BACKGROUND, &getBooleanCppuType(), 0, MID_GRAPHIC_TRANSPARENT },
523 // {MAP_CHAR_LEN(SC_UNONAME_CELLFILT), SC_WID_UNO_CELLFILT,&getBooleanCppuType(), 0, 0 },
524 {MAP_CHAR_LEN(SC_UNONAME_MANPAGE), SC_WID_UNO_MANPAGE, &getBooleanCppuType(), 0, 0 },
525 {MAP_CHAR_LEN(SC_UNONAME_NEWPAGE), SC_WID_UNO_NEWPAGE, &getBooleanCppuType(), 0, 0 },
526 {MAP_CHAR_LEN(SC_UNONAME_WRAP), ATTR_LINEBREAK, &getBooleanCppuType(), 0, 0 },
527 {MAP_CHAR_LEN(SC_UNONAME_CELLVIS), SC_WID_UNO_CELLVIS, &getBooleanCppuType(), 0, 0 },
528 {MAP_CHAR_LEN(SC_UNONAME_LEFTBORDER),ATTR_BORDER, &::getCppuType((const table::BorderLine*)0), 0, LEFT_BORDER | CONVERT_TWIPS },
529 {MAP_CHAR_LEN(SC_UNONAME_NUMFMT), ATTR_VALUE_FORMAT, &getCppuType((sal_Int32*)0), 0, 0 },
530 {MAP_CHAR_LEN(SC_UNONAME_NUMRULES), SC_WID_UNO_NUMRULES,&getCppuType((const uno::Reference<container::XIndexReplace>*)0), 0, 0 },
531 {MAP_CHAR_LEN(SC_UNONAME_OWIDTH), SC_WID_UNO_OWIDTH, &getBooleanCppuType(), 0, 0 },
532 {MAP_CHAR_LEN(SC_UNONAME_CELLORI), ATTR_STACKED, &getCppuType((table::CellOrientation*)0), 0, 0 },
533 {MAP_CHAR_LEN(SC_UNONAME_PADJUST), ATTR_HOR_JUSTIFY, &::getCppuType((const sal_Int16*)0), 0, MID_HORJUST_ADJUST },
534 {MAP_CHAR_LEN(SC_UNONAME_PBMARGIN), ATTR_MARGIN, &getCppuType((sal_Int32*)0), 0, MID_MARGIN_LO_MARGIN | CONVERT_TWIPS },
535 {MAP_CHAR_LEN(SC_UNONAME_PINDENT), ATTR_INDENT, &getCppuType((sal_Int16*)0), 0, 0 }, //! CONVERT_TWIPS
536 {MAP_CHAR_LEN(SC_UNONAME_PISCHDIST),ATTR_SCRIPTSPACE, &getBooleanCppuType(), 0, 0 },
537 {MAP_CHAR_LEN(SC_UNONAME_PISFORBID),ATTR_FORBIDDEN_RULES,&getBooleanCppuType(), 0, 0 },
538 {MAP_CHAR_LEN(SC_UNONAME_PISHANG), ATTR_HANGPUNCTUATION,&getBooleanCppuType(), 0, 0 },
539 {MAP_CHAR_LEN(SC_UNONAME_PISHYPHEN),ATTR_HYPHENATE, &getBooleanCppuType(), 0, 0 },
540 {MAP_CHAR_LEN(SC_UNONAME_PLASTADJ), ATTR_HOR_JUSTIFY, &::getCppuType((const sal_Int16*)0), 0, MID_HORJUST_ADJUST },
541 {MAP_CHAR_LEN(SC_UNONAME_PLMARGIN), ATTR_MARGIN, &getCppuType((sal_Int32*)0), 0, MID_MARGIN_L_MARGIN | CONVERT_TWIPS },
542 {MAP_CHAR_LEN(SC_UNONAME_PRMARGIN), ATTR_MARGIN, &getCppuType((sal_Int32*)0), 0, MID_MARGIN_R_MARGIN | CONVERT_TWIPS },
543 {MAP_CHAR_LEN(SC_UNONAME_PTMARGIN), ATTR_MARGIN, &getCppuType((sal_Int32*)0), 0, MID_MARGIN_UP_MARGIN | CONVERT_TWIPS },
544 {MAP_CHAR_LEN(SC_UNONAME_POS), SC_WID_UNO_POS, &getCppuType((awt::Point*)0), 0 | beans::PropertyAttribute::READONLY, 0 },
545 {MAP_CHAR_LEN(SC_UNONAME_RIGHTBORDER),ATTR_BORDER, &::getCppuType((const table::BorderLine*)0), 0, RIGHT_BORDER | CONVERT_TWIPS },
546 {MAP_CHAR_LEN(SC_UNONAME_ROTANG), ATTR_ROTATE_VALUE, &getCppuType((sal_Int32*)0), 0, 0 },
547 {MAP_CHAR_LEN(SC_UNONAME_ROTREF), ATTR_ROTATE_MODE, &getCppuType((table::CellVertJustify*)0), 0, 0 },
548 {MAP_CHAR_LEN(SC_UNONAME_SHADOW), ATTR_SHADOW, &getCppuType((table::ShadowFormat*)0), 0, 0 | CONVERT_TWIPS },
549 {MAP_CHAR_LEN(SC_UNONAME_SHRINK_TO_FIT), ATTR_SHRINKTOFIT, &getBooleanCppuType(), 0, 0 },
550 {MAP_CHAR_LEN(SC_UNONAME_SIZE), SC_WID_UNO_SIZE, &getCppuType((awt::Size*)0), 0 | beans::PropertyAttribute::READONLY, 0 },
551 {MAP_CHAR_LEN(SC_UNONAME_TBLBORD), SC_WID_UNO_TBLBORD, &getCppuType((table::TableBorder*)0), 0, 0 | CONVERT_TWIPS },
552 {MAP_CHAR_LEN(SC_UNONAME_TOPBORDER),ATTR_BORDER, &::getCppuType((const table::BorderLine*)0), 0, TOP_BORDER | CONVERT_TWIPS },
553 {MAP_CHAR_LEN(SC_UNONAME_USERDEF), ATTR_USERDEF, &getCppuType((uno::Reference<container::XNameContainer>*)0), 0, 0 },
554 {MAP_CHAR_LEN(SC_UNONAME_VALIDAT), SC_WID_UNO_VALIDAT, &getCppuType((uno::Reference<beans::XPropertySet>*)0), 0, 0 },
555 {MAP_CHAR_LEN(SC_UNONAME_VALILOC), SC_WID_UNO_VALILOC, &getCppuType((uno::Reference<beans::XPropertySet>*)0), 0, 0 },
556 {MAP_CHAR_LEN(SC_UNONAME_VALIXML), SC_WID_UNO_VALIXML, &getCppuType((uno::Reference<beans::XPropertySet>*)0), 0, 0 },
557 {MAP_CHAR_LEN(SC_UNONAME_CELLVJUS), ATTR_VER_JUSTIFY, &getCppuType((table::CellVertJustify*)0), 0, 0 },
558 {MAP_CHAR_LEN(SC_UNONAME_CELLWID), SC_WID_UNO_CELLWID, &getCppuType((sal_Int32*)0), 0, 0 },
559 {MAP_CHAR_LEN(SC_UNONAME_WRITING), ATTR_WRITINGDIR, &getCppuType((sal_Int16*)0), 0, 0 },
560 {0,0,0,0,0,0}
562 static SfxItemPropertySet aColumnPropertySet( aColumnPropertyMap_Impl );
563 return &aColumnPropertySet;
566 const SfxItemPropertySet* lcl_GetRowPropertySet()
568 static SfxItemPropertyMapEntry aRowPropertyMap_Impl[] =
570 {MAP_CHAR_LEN(SC_UNONAME_ABSNAME), SC_WID_UNO_ABSNAME, &getCppuType((rtl::OUString*)0), 0 | beans::PropertyAttribute::READONLY, 0 },
571 {MAP_CHAR_LEN(SC_UNONAME_ASIANVERT),ATTR_VERTICAL_ASIAN,&getBooleanCppuType(), 0, 0 },
572 {MAP_CHAR_LEN(SC_UNONAME_BOTTBORDER),ATTR_BORDER, &::getCppuType((const table::BorderLine*)0), 0, BOTTOM_BORDER | CONVERT_TWIPS },
573 {MAP_CHAR_LEN(SC_UNONAME_CELLBACK), ATTR_BACKGROUND, &getCppuType((sal_Int32*)0), 0, MID_BACK_COLOR },
574 {MAP_CHAR_LEN(SC_UNONAME_CELLPRO), ATTR_PROTECTION, &getCppuType((util::CellProtection*)0), 0, 0 },
575 {MAP_CHAR_LEN(SC_UNONAME_CELLSTYL), SC_WID_UNO_CELLSTYL,&getCppuType((rtl::OUString*)0), 0, 0 },
576 {MAP_CHAR_LEN(SC_UNONAME_CCOLOR), ATTR_FONT_COLOR, &getCppuType((sal_Int32*)0), 0, 0 },
577 {MAP_CHAR_LEN(SC_UNONAME_COUTL), ATTR_FONT_CONTOUR, &getBooleanCppuType(), 0, 0 },
578 {MAP_CHAR_LEN(SC_UNONAME_CCROSS), ATTR_FONT_CROSSEDOUT,&getBooleanCppuType(), 0, MID_CROSSED_OUT },
579 {MAP_CHAR_LEN(SC_UNONAME_CEMPHAS), ATTR_FONT_EMPHASISMARK,&getCppuType((sal_Int16*)0), 0, MID_EMPHASIS },
580 {MAP_CHAR_LEN(SC_UNONAME_CFONT), ATTR_FONT, &getCppuType((sal_Int16*)0), 0, MID_FONT_FAMILY },
581 {MAP_CHAR_LEN(SC_UNONAME_CFCHARS), ATTR_FONT, &getCppuType((sal_Int16*)0), 0, MID_FONT_CHAR_SET },
582 {MAP_CHAR_LEN(SC_UNO_CJK_CFCHARS), ATTR_CJK_FONT, &getCppuType((sal_Int16*)0), 0, MID_FONT_CHAR_SET },
583 {MAP_CHAR_LEN(SC_UNO_CTL_CFCHARS), ATTR_CTL_FONT, &getCppuType((sal_Int16*)0), 0, MID_FONT_CHAR_SET },
584 {MAP_CHAR_LEN(SC_UNONAME_CFFAMIL), ATTR_FONT, &getCppuType((sal_Int16*)0), 0, MID_FONT_FAMILY },
585 {MAP_CHAR_LEN(SC_UNO_CJK_CFFAMIL), ATTR_CJK_FONT, &getCppuType((sal_Int16*)0), 0, MID_FONT_FAMILY },
586 {MAP_CHAR_LEN(SC_UNO_CTL_CFFAMIL), ATTR_CTL_FONT, &getCppuType((sal_Int16*)0), 0, MID_FONT_FAMILY },
587 {MAP_CHAR_LEN(SC_UNONAME_CFNAME), ATTR_FONT, &getCppuType((rtl::OUString*)0), 0, MID_FONT_FAMILY_NAME },
588 {MAP_CHAR_LEN(SC_UNO_CJK_CFNAME), ATTR_CJK_FONT, &getCppuType((rtl::OUString*)0), 0, MID_FONT_FAMILY_NAME },
589 {MAP_CHAR_LEN(SC_UNO_CTL_CFNAME), ATTR_CTL_FONT, &getCppuType((rtl::OUString*)0), 0, MID_FONT_FAMILY_NAME },
590 {MAP_CHAR_LEN(SC_UNONAME_CFPITCH), ATTR_FONT, &getCppuType((sal_Int16*)0), 0, MID_FONT_PITCH },
591 {MAP_CHAR_LEN(SC_UNO_CJK_CFPITCH), ATTR_CJK_FONT, &getCppuType((sal_Int16*)0), 0, MID_FONT_PITCH },
592 {MAP_CHAR_LEN(SC_UNO_CTL_CFPITCH), ATTR_CTL_FONT, &getCppuType((sal_Int16*)0), 0, MID_FONT_PITCH },
593 {MAP_CHAR_LEN(SC_UNONAME_CFSTYLE), ATTR_FONT, &getCppuType((rtl::OUString*)0), 0, MID_FONT_STYLE_NAME },
594 {MAP_CHAR_LEN(SC_UNO_CJK_CFSTYLE), ATTR_CJK_FONT, &getCppuType((rtl::OUString*)0), 0, MID_FONT_STYLE_NAME },
595 {MAP_CHAR_LEN(SC_UNO_CTL_CFSTYLE), ATTR_CTL_FONT, &getCppuType((rtl::OUString*)0), 0, MID_FONT_STYLE_NAME },
596 {MAP_CHAR_LEN(SC_UNONAME_CHEIGHT), ATTR_FONT_HEIGHT, &getCppuType((float*)0), 0, MID_FONTHEIGHT | CONVERT_TWIPS },
597 {MAP_CHAR_LEN(SC_UNO_CJK_CHEIGHT), ATTR_CJK_FONT_HEIGHT,&getCppuType((float*)0), 0, MID_FONTHEIGHT | CONVERT_TWIPS },
598 {MAP_CHAR_LEN(SC_UNO_CTL_CHEIGHT), ATTR_CTL_FONT_HEIGHT,&getCppuType((float*)0), 0, MID_FONTHEIGHT | CONVERT_TWIPS },
599 {MAP_CHAR_LEN(SC_UNONAME_CLOCAL), ATTR_FONT_LANGUAGE, &getCppuType((lang::Locale*)0), 0, MID_LANG_LOCALE },
600 {MAP_CHAR_LEN(SC_UNO_CJK_CLOCAL), ATTR_CJK_FONT_LANGUAGE,&getCppuType((lang::Locale*)0), 0, MID_LANG_LOCALE },
601 {MAP_CHAR_LEN(SC_UNO_CTL_CLOCAL), ATTR_CTL_FONT_LANGUAGE,&getCppuType((lang::Locale*)0), 0, MID_LANG_LOCALE },
602 {MAP_CHAR_LEN(SC_UNONAME_COVER), ATTR_FONT_OVERLINE, &getCppuType((sal_Int16*)0), 0, MID_TL_STYLE },
603 {MAP_CHAR_LEN(SC_UNONAME_COVRLCOL), ATTR_FONT_OVERLINE, &getCppuType((sal_Int32*)0), 0, MID_TL_COLOR },
604 {MAP_CHAR_LEN(SC_UNONAME_COVRLHAS), ATTR_FONT_OVERLINE, &getBooleanCppuType(), 0, MID_TL_HASCOLOR },
605 {MAP_CHAR_LEN(SC_UNONAME_CPOST), ATTR_FONT_POSTURE, &getCppuType((awt::FontSlant*)0), 0, MID_POSTURE },
606 {MAP_CHAR_LEN(SC_UNO_CJK_CPOST), ATTR_CJK_FONT_POSTURE,&getCppuType((awt::FontSlant*)0), 0, MID_POSTURE },
607 {MAP_CHAR_LEN(SC_UNO_CTL_CPOST), ATTR_CTL_FONT_POSTURE,&getCppuType((awt::FontSlant*)0), 0, MID_POSTURE },
608 {MAP_CHAR_LEN(SC_UNONAME_CRELIEF), ATTR_FONT_RELIEF, &getCppuType((sal_Int16*)0), 0, MID_RELIEF },
609 {MAP_CHAR_LEN(SC_UNONAME_CSHADD), ATTR_FONT_SHADOWED, &getBooleanCppuType(), 0, 0 },
610 {MAP_CHAR_LEN(SC_UNONAME_CSTRIKE), ATTR_FONT_CROSSEDOUT,&getCppuType((sal_Int16*)0), 0, MID_CROSS_OUT },
611 {MAP_CHAR_LEN(SC_UNONAME_CUNDER), ATTR_FONT_UNDERLINE,&getCppuType((sal_Int16*)0), 0, MID_TL_STYLE },
612 {MAP_CHAR_LEN(SC_UNONAME_CUNDLCOL), ATTR_FONT_UNDERLINE,&getCppuType((sal_Int32*)0), 0, MID_TL_COLOR },
613 {MAP_CHAR_LEN(SC_UNONAME_CUNDLHAS), ATTR_FONT_UNDERLINE,&getBooleanCppuType(), 0, MID_TL_HASCOLOR },
614 {MAP_CHAR_LEN(SC_UNONAME_CWEIGHT), ATTR_FONT_WEIGHT, &getCppuType((float*)0), 0, MID_WEIGHT },
615 {MAP_CHAR_LEN(SC_UNO_CJK_CWEIGHT), ATTR_CJK_FONT_WEIGHT,&getCppuType((float*)0), 0, MID_WEIGHT },
616 {MAP_CHAR_LEN(SC_UNO_CTL_CWEIGHT), ATTR_CTL_FONT_WEIGHT,&getCppuType((float*)0), 0, MID_WEIGHT },
617 {MAP_CHAR_LEN(SC_UNONAME_CWORDMOD), ATTR_FONT_WORDLINE, &getBooleanCppuType(), 0, 0 },
618 {MAP_CHAR_LEN(SC_UNONAME_CHCOLHDR), SC_WID_UNO_CHCOLHDR,&getBooleanCppuType(), 0, 0 },
619 {MAP_CHAR_LEN(SC_UNONAME_CHROWHDR), SC_WID_UNO_CHROWHDR,&getBooleanCppuType(), 0, 0 },
620 {MAP_CHAR_LEN(SC_UNONAME_CONDFMT), SC_WID_UNO_CONDFMT, &getCppuType((uno::Reference<sheet::XSheetConditionalEntries>*)0), 0, 0 },
621 {MAP_CHAR_LEN(SC_UNONAME_CONDLOC), SC_WID_UNO_CONDLOC, &getCppuType((uno::Reference<sheet::XSheetConditionalEntries>*)0), 0, 0 },
622 {MAP_CHAR_LEN(SC_UNONAME_CONDXML), SC_WID_UNO_CONDXML, &getCppuType((uno::Reference<sheet::XSheetConditionalEntries>*)0), 0, 0 },
623 {MAP_CHAR_LEN(SC_UNONAME_DIAGONAL_BLTR), ATTR_BORDER_BLTR, &::getCppuType((const table::BorderLine*)0), 0, 0 | CONVERT_TWIPS },
624 {MAP_CHAR_LEN(SC_UNONAME_DIAGONAL_TLBR), ATTR_BORDER_TLBR, &::getCppuType((const table::BorderLine*)0), 0, 0 | CONVERT_TWIPS },
625 {MAP_CHAR_LEN(SC_UNONAME_CELLHGT), SC_WID_UNO_CELLHGT, &getCppuType((sal_Int32*)0), 0, 0 },
626 {MAP_CHAR_LEN(SC_UNONAME_CELLHJUS), ATTR_HOR_JUSTIFY, &getCppuType((table::CellHoriJustify*)0), 0, MID_HORJUST_HORJUST },
627 {MAP_CHAR_LEN(SC_UNONAME_CELLTRAN), ATTR_BACKGROUND, &getBooleanCppuType(), 0, MID_GRAPHIC_TRANSPARENT },
628 {MAP_CHAR_LEN(SC_UNONAME_CELLFILT), SC_WID_UNO_CELLFILT,&getBooleanCppuType(), 0, 0 },
629 {MAP_CHAR_LEN(SC_UNONAME_MANPAGE), SC_WID_UNO_MANPAGE, &getBooleanCppuType(), 0, 0 },
630 {MAP_CHAR_LEN(SC_UNONAME_NEWPAGE), SC_WID_UNO_NEWPAGE, &getBooleanCppuType(), 0, 0 },
631 {MAP_CHAR_LEN(SC_UNONAME_WRAP), ATTR_LINEBREAK, &getBooleanCppuType(), 0, 0 },
632 {MAP_CHAR_LEN(SC_UNONAME_CELLVIS), SC_WID_UNO_CELLVIS, &getBooleanCppuType(), 0, 0 },
633 {MAP_CHAR_LEN(SC_UNONAME_LEFTBORDER),ATTR_BORDER, &::getCppuType((const table::BorderLine*)0), 0, LEFT_BORDER | CONVERT_TWIPS },
634 {MAP_CHAR_LEN(SC_UNONAME_NUMFMT), ATTR_VALUE_FORMAT, &getCppuType((sal_Int32*)0), 0, 0 },
635 {MAP_CHAR_LEN(SC_UNONAME_NUMRULES), SC_WID_UNO_NUMRULES,&getCppuType((const uno::Reference<container::XIndexReplace>*)0), 0, 0 },
636 {MAP_CHAR_LEN(SC_UNONAME_OHEIGHT), SC_WID_UNO_OHEIGHT, &getBooleanCppuType(), 0, 0 },
637 {MAP_CHAR_LEN(SC_UNONAME_CELLORI), ATTR_STACKED, &getCppuType((table::CellOrientation*)0), 0, 0 },
638 {MAP_CHAR_LEN(SC_UNONAME_PADJUST), ATTR_HOR_JUSTIFY, &::getCppuType((const sal_Int16*)0), 0, MID_HORJUST_ADJUST },
639 {MAP_CHAR_LEN(SC_UNONAME_PBMARGIN), ATTR_MARGIN, &getCppuType((sal_Int32*)0), 0, MID_MARGIN_LO_MARGIN | CONVERT_TWIPS },
640 {MAP_CHAR_LEN(SC_UNONAME_PINDENT), ATTR_INDENT, &getCppuType((sal_Int16*)0), 0, 0 }, //! CONVERT_TWIPS
641 {MAP_CHAR_LEN(SC_UNONAME_PISCHDIST),ATTR_SCRIPTSPACE, &getBooleanCppuType(), 0, 0 },
642 {MAP_CHAR_LEN(SC_UNONAME_PISFORBID),ATTR_FORBIDDEN_RULES,&getBooleanCppuType(), 0, 0 },
643 {MAP_CHAR_LEN(SC_UNONAME_PISHANG), ATTR_HANGPUNCTUATION,&getBooleanCppuType(), 0, 0 },
644 {MAP_CHAR_LEN(SC_UNONAME_PISHYPHEN),ATTR_HYPHENATE, &getBooleanCppuType(), 0, 0 },
645 {MAP_CHAR_LEN(SC_UNONAME_PLASTADJ), ATTR_HOR_JUSTIFY, &::getCppuType((const sal_Int16*)0), 0, MID_HORJUST_ADJUST },
646 {MAP_CHAR_LEN(SC_UNONAME_PLMARGIN), ATTR_MARGIN, &getCppuType((sal_Int32*)0), 0, MID_MARGIN_L_MARGIN | CONVERT_TWIPS },
647 {MAP_CHAR_LEN(SC_UNONAME_PRMARGIN), ATTR_MARGIN, &getCppuType((sal_Int32*)0), 0, MID_MARGIN_R_MARGIN | CONVERT_TWIPS },
648 {MAP_CHAR_LEN(SC_UNONAME_PTMARGIN), ATTR_MARGIN, &getCppuType((sal_Int32*)0), 0, MID_MARGIN_UP_MARGIN | CONVERT_TWIPS },
649 {MAP_CHAR_LEN(SC_UNONAME_POS), SC_WID_UNO_POS, &getCppuType((awt::Point*)0), 0 | beans::PropertyAttribute::READONLY, 0 },
650 {MAP_CHAR_LEN(SC_UNONAME_RIGHTBORDER),ATTR_BORDER, &::getCppuType((const table::BorderLine*)0), 0, RIGHT_BORDER | CONVERT_TWIPS },
651 {MAP_CHAR_LEN(SC_UNONAME_ROTANG), ATTR_ROTATE_VALUE, &getCppuType((sal_Int32*)0), 0, 0 },
652 {MAP_CHAR_LEN(SC_UNONAME_ROTREF), ATTR_ROTATE_MODE, &getCppuType((table::CellVertJustify*)0), 0, 0 },
653 {MAP_CHAR_LEN(SC_UNONAME_SHADOW), ATTR_SHADOW, &getCppuType((table::ShadowFormat*)0), 0, 0 | CONVERT_TWIPS },
654 {MAP_CHAR_LEN(SC_UNONAME_SHRINK_TO_FIT), ATTR_SHRINKTOFIT, &getBooleanCppuType(), 0, 0 },
655 {MAP_CHAR_LEN(SC_UNONAME_SIZE), SC_WID_UNO_SIZE, &getCppuType((awt::Size*)0), 0 | beans::PropertyAttribute::READONLY, 0 },
656 {MAP_CHAR_LEN(SC_UNONAME_TBLBORD), SC_WID_UNO_TBLBORD, &getCppuType((table::TableBorder*)0), 0, 0 | CONVERT_TWIPS },
657 {MAP_CHAR_LEN(SC_UNONAME_TOPBORDER),ATTR_BORDER, &::getCppuType((const table::BorderLine*)0), 0, TOP_BORDER | CONVERT_TWIPS },
658 {MAP_CHAR_LEN(SC_UNONAME_USERDEF), ATTR_USERDEF, &getCppuType((uno::Reference<container::XNameContainer>*)0), 0, 0 },
659 {MAP_CHAR_LEN(SC_UNONAME_VALIDAT), SC_WID_UNO_VALIDAT, &getCppuType((uno::Reference<beans::XPropertySet>*)0), 0, 0 },
660 {MAP_CHAR_LEN(SC_UNONAME_VALILOC), SC_WID_UNO_VALILOC, &getCppuType((uno::Reference<beans::XPropertySet>*)0), 0, 0 },
661 {MAP_CHAR_LEN(SC_UNONAME_VALIXML), SC_WID_UNO_VALIXML, &getCppuType((uno::Reference<beans::XPropertySet>*)0), 0, 0 },
662 {MAP_CHAR_LEN(SC_UNONAME_CELLVJUS), ATTR_VER_JUSTIFY, &getCppuType((table::CellVertJustify*)0), 0, 0 },
663 {MAP_CHAR_LEN(SC_UNONAME_WRITING), ATTR_WRITINGDIR, &getCppuType((sal_Int16*)0), 0, 0 },
664 {0,0,0,0,0,0}
666 static SfxItemPropertySet aRowPropertySet( aRowPropertyMap_Impl );
667 return &aRowPropertySet;
670 const SfxItemPropertySet* lcl_GetSheetPropertySet()
672 static SfxItemPropertyMapEntry aSheetPropertyMap_Impl[] =
674 {MAP_CHAR_LEN(SC_UNONAME_ABSNAME), SC_WID_UNO_ABSNAME, &getCppuType((rtl::OUString*)0), 0 | beans::PropertyAttribute::READONLY, 0 },
675 {MAP_CHAR_LEN(SC_UNONAME_ASIANVERT),ATTR_VERTICAL_ASIAN,&getBooleanCppuType(), 0, 0 },
676 {MAP_CHAR_LEN(SC_UNONAME_AUTOPRINT),SC_WID_UNO_AUTOPRINT,&getBooleanCppuType(), 0, 0 },
677 {MAP_CHAR_LEN(SC_UNONAME_BORDCOL), SC_WID_UNO_BORDCOL, &getCppuType((sal_Int32*)0), 0, 0 },
678 {MAP_CHAR_LEN(SC_UNONAME_BOTTBORDER),ATTR_BORDER, &::getCppuType((const table::BorderLine*)0), 0, BOTTOM_BORDER | CONVERT_TWIPS },
679 {MAP_CHAR_LEN(SC_UNONAME_CELLBACK), ATTR_BACKGROUND, &getCppuType((sal_Int32*)0), 0, MID_BACK_COLOR },
680 {MAP_CHAR_LEN(SC_UNONAME_CELLPRO), ATTR_PROTECTION, &getCppuType((util::CellProtection*)0), 0, 0 },
681 {MAP_CHAR_LEN(SC_UNONAME_CELLSTYL), SC_WID_UNO_CELLSTYL,&getCppuType((rtl::OUString*)0), 0, 0 },
682 {MAP_CHAR_LEN(SC_UNONAME_CCOLOR), ATTR_FONT_COLOR, &getCppuType((sal_Int32*)0), 0, 0 },
683 {MAP_CHAR_LEN(SC_UNONAME_COUTL), ATTR_FONT_CONTOUR, &getBooleanCppuType(), 0, 0 },
684 {MAP_CHAR_LEN(SC_UNONAME_CCROSS), ATTR_FONT_CROSSEDOUT,&getBooleanCppuType(), 0, MID_CROSSED_OUT },
685 {MAP_CHAR_LEN(SC_UNONAME_CEMPHAS), ATTR_FONT_EMPHASISMARK,&getCppuType((sal_Int16*)0), 0, MID_EMPHASIS },
686 {MAP_CHAR_LEN(SC_UNONAME_CFONT), ATTR_FONT, &getCppuType((sal_Int16*)0), 0, MID_FONT_FAMILY },
687 {MAP_CHAR_LEN(SC_UNONAME_CFCHARS), ATTR_FONT, &getCppuType((sal_Int16*)0), 0, MID_FONT_CHAR_SET },
688 {MAP_CHAR_LEN(SC_UNO_CJK_CFCHARS), ATTR_CJK_FONT, &getCppuType((sal_Int16*)0), 0, MID_FONT_CHAR_SET },
689 {MAP_CHAR_LEN(SC_UNO_CTL_CFCHARS), ATTR_CTL_FONT, &getCppuType((sal_Int16*)0), 0, MID_FONT_CHAR_SET },
690 {MAP_CHAR_LEN(SC_UNONAME_CFFAMIL), ATTR_FONT, &getCppuType((sal_Int16*)0), 0, MID_FONT_FAMILY },
691 {MAP_CHAR_LEN(SC_UNO_CJK_CFFAMIL), ATTR_CJK_FONT, &getCppuType((sal_Int16*)0), 0, MID_FONT_FAMILY },
692 {MAP_CHAR_LEN(SC_UNO_CTL_CFFAMIL), ATTR_CTL_FONT, &getCppuType((sal_Int16*)0), 0, MID_FONT_FAMILY },
693 {MAP_CHAR_LEN(SC_UNONAME_CFNAME), ATTR_FONT, &getCppuType((rtl::OUString*)0), 0, MID_FONT_FAMILY_NAME },
694 {MAP_CHAR_LEN(SC_UNO_CJK_CFNAME), ATTR_CJK_FONT, &getCppuType((rtl::OUString*)0), 0, MID_FONT_FAMILY_NAME },
695 {MAP_CHAR_LEN(SC_UNO_CTL_CFNAME), ATTR_CTL_FONT, &getCppuType((rtl::OUString*)0), 0, MID_FONT_FAMILY_NAME },
696 {MAP_CHAR_LEN(SC_UNONAME_CFPITCH), ATTR_FONT, &getCppuType((sal_Int16*)0), 0, MID_FONT_PITCH },
697 {MAP_CHAR_LEN(SC_UNO_CJK_CFPITCH), ATTR_CJK_FONT, &getCppuType((sal_Int16*)0), 0, MID_FONT_PITCH },
698 {MAP_CHAR_LEN(SC_UNO_CTL_CFPITCH), ATTR_CTL_FONT, &getCppuType((sal_Int16*)0), 0, MID_FONT_PITCH },
699 {MAP_CHAR_LEN(SC_UNONAME_CFSTYLE), ATTR_FONT, &getCppuType((rtl::OUString*)0), 0, MID_FONT_STYLE_NAME },
700 {MAP_CHAR_LEN(SC_UNO_CJK_CFSTYLE), ATTR_CJK_FONT, &getCppuType((rtl::OUString*)0), 0, MID_FONT_STYLE_NAME },
701 {MAP_CHAR_LEN(SC_UNO_CTL_CFSTYLE), ATTR_CTL_FONT, &getCppuType((rtl::OUString*)0), 0, MID_FONT_STYLE_NAME },
702 {MAP_CHAR_LEN(SC_UNONAME_CHEIGHT), ATTR_FONT_HEIGHT, &getCppuType((float*)0), 0, MID_FONTHEIGHT | CONVERT_TWIPS },
703 {MAP_CHAR_LEN(SC_UNO_CJK_CHEIGHT), ATTR_CJK_FONT_HEIGHT,&getCppuType((float*)0), 0, MID_FONTHEIGHT | CONVERT_TWIPS },
704 {MAP_CHAR_LEN(SC_UNO_CTL_CHEIGHT), ATTR_CTL_FONT_HEIGHT,&getCppuType((float*)0), 0, MID_FONTHEIGHT | CONVERT_TWIPS },
705 {MAP_CHAR_LEN(SC_UNONAME_CLOCAL), ATTR_FONT_LANGUAGE, &getCppuType((lang::Locale*)0), 0, MID_LANG_LOCALE },
706 {MAP_CHAR_LEN(SC_UNO_CJK_CLOCAL), ATTR_CJK_FONT_LANGUAGE,&getCppuType((lang::Locale*)0), 0, MID_LANG_LOCALE },
707 {MAP_CHAR_LEN(SC_UNO_CTL_CLOCAL), ATTR_CTL_FONT_LANGUAGE,&getCppuType((lang::Locale*)0), 0, MID_LANG_LOCALE },
708 {MAP_CHAR_LEN(SC_UNONAME_COVER), ATTR_FONT_OVERLINE, &getCppuType((sal_Int16*)0), 0, MID_TL_STYLE },
709 {MAP_CHAR_LEN(SC_UNONAME_COVRLCOL), ATTR_FONT_OVERLINE, &getCppuType((sal_Int32*)0), 0, MID_TL_COLOR },
710 {MAP_CHAR_LEN(SC_UNONAME_COVRLHAS), ATTR_FONT_OVERLINE, &getBooleanCppuType(), 0, MID_TL_HASCOLOR },
711 {MAP_CHAR_LEN(SC_UNONAME_CPOST), ATTR_FONT_POSTURE, &getCppuType((awt::FontSlant*)0), 0, MID_POSTURE },
712 {MAP_CHAR_LEN(SC_UNO_CJK_CPOST), ATTR_CJK_FONT_POSTURE,&getCppuType((awt::FontSlant*)0), 0, MID_POSTURE },
713 {MAP_CHAR_LEN(SC_UNO_CTL_CPOST), ATTR_CTL_FONT_POSTURE,&getCppuType((awt::FontSlant*)0), 0, MID_POSTURE },
714 {MAP_CHAR_LEN(SC_UNONAME_CRELIEF), ATTR_FONT_RELIEF, &getCppuType((sal_Int16*)0), 0, MID_RELIEF },
715 {MAP_CHAR_LEN(SC_UNONAME_CSHADD), ATTR_FONT_SHADOWED, &getBooleanCppuType(), 0, 0 },
716 {MAP_CHAR_LEN(SC_UNONAME_CSTRIKE), ATTR_FONT_CROSSEDOUT,&getCppuType((sal_Int16*)0), 0, MID_CROSS_OUT },
717 {MAP_CHAR_LEN(SC_UNONAME_CUNDER), ATTR_FONT_UNDERLINE,&getCppuType((sal_Int16*)0), 0, MID_TL_STYLE },
718 {MAP_CHAR_LEN(SC_UNONAME_CUNDLCOL), ATTR_FONT_UNDERLINE,&getCppuType((sal_Int32*)0), 0, MID_TL_COLOR },
719 {MAP_CHAR_LEN(SC_UNONAME_CUNDLHAS), ATTR_FONT_UNDERLINE,&getBooleanCppuType(), 0, MID_TL_HASCOLOR },
720 {MAP_CHAR_LEN(SC_UNONAME_CWEIGHT), ATTR_FONT_WEIGHT, &getCppuType((float*)0), 0, MID_WEIGHT },
721 {MAP_CHAR_LEN(SC_UNO_CJK_CWEIGHT), ATTR_CJK_FONT_WEIGHT,&getCppuType((float*)0), 0, MID_WEIGHT },
722 {MAP_CHAR_LEN(SC_UNO_CTL_CWEIGHT), ATTR_CTL_FONT_WEIGHT,&getCppuType((float*)0), 0, MID_WEIGHT },
723 {MAP_CHAR_LEN(SC_UNONAME_CWORDMOD), ATTR_FONT_WORDLINE, &getBooleanCppuType(), 0, 0 },
724 {MAP_CHAR_LEN(SC_UNONAME_CHCOLHDR), SC_WID_UNO_CHCOLHDR,&getBooleanCppuType(), 0, 0 },
725 {MAP_CHAR_LEN(SC_UNONAME_CHROWHDR), SC_WID_UNO_CHROWHDR,&getBooleanCppuType(), 0, 0 },
726 {MAP_CHAR_LEN(SC_UNONAME_CONDFMT), SC_WID_UNO_CONDFMT, &getCppuType((uno::Reference<sheet::XSheetConditionalEntries>*)0), 0, 0 },
727 {MAP_CHAR_LEN(SC_UNONAME_CONDLOC), SC_WID_UNO_CONDLOC, &getCppuType((uno::Reference<sheet::XSheetConditionalEntries>*)0), 0, 0 },
728 {MAP_CHAR_LEN(SC_UNONAME_CONDXML), SC_WID_UNO_CONDXML, &getCppuType((uno::Reference<sheet::XSheetConditionalEntries>*)0), 0, 0 },
729 {MAP_CHAR_LEN(SC_UNONAME_COPYBACK), SC_WID_UNO_COPYBACK,&getBooleanCppuType(), 0, 0 },
730 {MAP_CHAR_LEN(SC_UNONAME_COPYFORM), SC_WID_UNO_COPYFORM,&getBooleanCppuType(), 0, 0 },
731 {MAP_CHAR_LEN(SC_UNONAME_COPYSTYL), SC_WID_UNO_COPYSTYL,&getBooleanCppuType(), 0, 0 },
732 {MAP_CHAR_LEN(SC_UNONAME_DIAGONAL_BLTR), ATTR_BORDER_BLTR, &::getCppuType((const table::BorderLine*)0), 0, 0 | CONVERT_TWIPS },
733 {MAP_CHAR_LEN(SC_UNONAME_DIAGONAL_TLBR), ATTR_BORDER_TLBR, &::getCppuType((const table::BorderLine*)0), 0, 0 | CONVERT_TWIPS },
734 {MAP_CHAR_LEN(SC_UNONAME_CELLHJUS), ATTR_HOR_JUSTIFY, &getCppuType((table::CellHoriJustify*)0), 0, MID_HORJUST_HORJUST },
735 {MAP_CHAR_LEN(SC_UNONAME_ISACTIVE), SC_WID_UNO_ISACTIVE,&getBooleanCppuType(), 0, 0 },
736 {MAP_CHAR_LEN(SC_UNONAME_CELLTRAN), ATTR_BACKGROUND, &getBooleanCppuType(), 0, MID_GRAPHIC_TRANSPARENT },
737 {MAP_CHAR_LEN(SC_UNONAME_WRAP), ATTR_LINEBREAK, &getBooleanCppuType(), 0, 0 },
738 {MAP_CHAR_LEN(SC_UNONAME_CELLVIS), SC_WID_UNO_CELLVIS, &getBooleanCppuType(), 0, 0 },
739 {MAP_CHAR_LEN(SC_UNONAME_LEFTBORDER),ATTR_BORDER, &::getCppuType((const table::BorderLine*)0), 0, LEFT_BORDER | CONVERT_TWIPS },
740 {MAP_CHAR_LEN(SC_UNO_LINKDISPBIT), SC_WID_UNO_LINKDISPBIT,&getCppuType((uno::Reference<awt::XBitmap>*)0), 0 | beans::PropertyAttribute::READONLY, 0 },
741 {MAP_CHAR_LEN(SC_UNO_LINKDISPNAME), SC_WID_UNO_LINKDISPNAME,&getCppuType((rtl::OUString*)0), 0 | beans::PropertyAttribute::READONLY, 0 },
742 {MAP_CHAR_LEN(SC_UNONAME_NUMFMT), ATTR_VALUE_FORMAT, &getCppuType((sal_Int32*)0), 0, 0 },
743 {MAP_CHAR_LEN(SC_UNONAME_NUMRULES), SC_WID_UNO_NUMRULES,&getCppuType((const uno::Reference<container::XIndexReplace>*)0), 0, 0 },
744 {MAP_CHAR_LEN(SC_UNONAME_CELLORI), ATTR_STACKED, &getCppuType((table::CellOrientation*)0), 0, 0 },
745 {MAP_CHAR_LEN(SC_UNONAME_PAGESTL), SC_WID_UNO_PAGESTL, &getCppuType((rtl::OUString*)0), 0, 0 },
746 {MAP_CHAR_LEN(SC_UNONAME_PADJUST), ATTR_HOR_JUSTIFY, &::getCppuType((const sal_Int16*)0), 0, MID_HORJUST_ADJUST },
747 {MAP_CHAR_LEN(SC_UNONAME_PBMARGIN), ATTR_MARGIN, &getCppuType((sal_Int32*)0), 0, MID_MARGIN_LO_MARGIN | CONVERT_TWIPS },
748 {MAP_CHAR_LEN(SC_UNONAME_PINDENT), ATTR_INDENT, &getCppuType((sal_Int16*)0), 0, 0 }, //! CONVERT_TWIPS
749 {MAP_CHAR_LEN(SC_UNONAME_PISCHDIST),ATTR_SCRIPTSPACE, &getBooleanCppuType(), 0, 0 },
750 {MAP_CHAR_LEN(SC_UNONAME_PISFORBID),ATTR_FORBIDDEN_RULES,&getBooleanCppuType(), 0, 0 },
751 {MAP_CHAR_LEN(SC_UNONAME_PISHANG), ATTR_HANGPUNCTUATION,&getBooleanCppuType(), 0, 0 },
752 {MAP_CHAR_LEN(SC_UNONAME_PISHYPHEN),ATTR_HYPHENATE, &getBooleanCppuType(), 0, 0 },
753 {MAP_CHAR_LEN(SC_UNONAME_PLASTADJ), ATTR_HOR_JUSTIFY, &::getCppuType((const sal_Int16*)0), 0, MID_HORJUST_ADJUST },
754 {MAP_CHAR_LEN(SC_UNONAME_PLMARGIN), ATTR_MARGIN, &getCppuType((sal_Int32*)0), 0, MID_MARGIN_L_MARGIN | CONVERT_TWIPS },
755 {MAP_CHAR_LEN(SC_UNONAME_PRMARGIN), ATTR_MARGIN, &getCppuType((sal_Int32*)0), 0, MID_MARGIN_R_MARGIN | CONVERT_TWIPS },
756 {MAP_CHAR_LEN(SC_UNONAME_PTMARGIN), ATTR_MARGIN, &getCppuType((sal_Int32*)0), 0, MID_MARGIN_UP_MARGIN | CONVERT_TWIPS },
757 {MAP_CHAR_LEN(SC_UNONAME_POS), SC_WID_UNO_POS, &getCppuType((awt::Point*)0), 0 | beans::PropertyAttribute::READONLY, 0 },
758 {MAP_CHAR_LEN(SC_UNONAME_PRINTBORD),SC_WID_UNO_PRINTBORD,&getBooleanCppuType(), 0, 0 },
759 {MAP_CHAR_LEN(SC_UNONAME_PROTECT), SC_WID_UNO_PROTECT, &getBooleanCppuType(), 0, 0 },
760 {MAP_CHAR_LEN(SC_UNONAME_RIGHTBORDER),ATTR_BORDER, &::getCppuType((const table::BorderLine*)0), 0, RIGHT_BORDER | CONVERT_TWIPS },
761 {MAP_CHAR_LEN(SC_UNONAME_ROTANG), ATTR_ROTATE_VALUE, &getCppuType((sal_Int32*)0), 0, 0 },
762 {MAP_CHAR_LEN(SC_UNONAME_ROTREF), ATTR_ROTATE_MODE, &getCppuType((table::CellVertJustify*)0), 0, 0 },
763 {MAP_CHAR_LEN(SC_UNONAME_SHADOW), ATTR_SHADOW, &getCppuType((table::ShadowFormat*)0), 0, 0 | CONVERT_TWIPS },
764 {MAP_CHAR_LEN(SC_UNONAME_SHOWBORD), SC_WID_UNO_SHOWBORD,&getBooleanCppuType(), 0, 0 },
765 {MAP_CHAR_LEN(SC_UNONAME_SHRINK_TO_FIT), ATTR_SHRINKTOFIT, &getBooleanCppuType(), 0, 0 },
766 {MAP_CHAR_LEN(SC_UNONAME_SIZE), SC_WID_UNO_SIZE, &getCppuType((awt::Size*)0), 0 | beans::PropertyAttribute::READONLY, 0 },
767 {MAP_CHAR_LEN(SC_UNONAME_TBLBORD), SC_WID_UNO_TBLBORD, &getCppuType((table::TableBorder*)0), 0, 0 | CONVERT_TWIPS },
768 {MAP_CHAR_LEN(SC_UNONAME_TABLAYOUT),SC_WID_UNO_TABLAYOUT,&getCppuType((sal_Int16*)0), 0, 0 },
769 {MAP_CHAR_LEN(SC_UNONAME_TOPBORDER),ATTR_BORDER, &::getCppuType((const table::BorderLine*)0), 0, TOP_BORDER | CONVERT_TWIPS },
770 {MAP_CHAR_LEN(SC_UNONAME_USERDEF), ATTR_USERDEF, &getCppuType((uno::Reference<container::XNameContainer>*)0), 0, 0 },
771 {MAP_CHAR_LEN(SC_UNONAME_VALIDAT), SC_WID_UNO_VALIDAT, &getCppuType((uno::Reference<beans::XPropertySet>*)0), 0, 0 },
772 {MAP_CHAR_LEN(SC_UNONAME_VALILOC), SC_WID_UNO_VALILOC, &getCppuType((uno::Reference<beans::XPropertySet>*)0), 0, 0 },
773 {MAP_CHAR_LEN(SC_UNONAME_VALIXML), SC_WID_UNO_VALIXML, &getCppuType((uno::Reference<beans::XPropertySet>*)0), 0, 0 },
774 {MAP_CHAR_LEN(SC_UNONAME_CELLVJUS), ATTR_VER_JUSTIFY, &getCppuType((table::CellVertJustify*)0), 0, 0 },
775 {MAP_CHAR_LEN(SC_UNONAME_WRITING), ATTR_WRITINGDIR, &getCppuType((sal_Int16*)0), 0, 0 },
776 {0,0,0,0,0,0}
778 static SfxItemPropertySet aSheetPropertySet( aSheetPropertyMap_Impl );
779 return &aSheetPropertySet;
782 const SfxItemPropertyMapEntry* lcl_GetEditPropertyMap()
784 static SfxItemPropertyMapEntry aEditPropertyMap_Impl[] =
786 SVX_UNOEDIT_CHAR_PROPERTIES,
787 SVX_UNOEDIT_FONT_PROPERTIES,
788 SVX_UNOEDIT_PARA_PROPERTIES,
789 SVX_UNOEDIT_NUMBERING_PROPERTIE, // for completeness of service ParagraphProperties
790 {MAP_CHAR_LEN(SC_UNONAME_TEXTUSER), EE_CHAR_XMLATTRIBS, &getCppuType((const uno::Reference< container::XNameContainer >*)0), 0, 0},
791 {MAP_CHAR_LEN(SC_UNONAME_USERDEF), EE_PARA_XMLATTRIBS, &getCppuType((const uno::Reference< container::XNameContainer >*)0), 0, 0},
792 {0,0,0,0,0,0}
794 return aEditPropertyMap_Impl;
796 const SvxItemPropertySet* lcl_GetEditPropertySet()
798 static SvxItemPropertySet aEditPropertySet( lcl_GetEditPropertyMap() );
799 return &aEditPropertySet;
803 //------------------------------------------------------------------------
805 //! diese Funktionen in einen allgemeinen Header verschieben
806 inline long TwipsToHMM(long nTwips) { return (nTwips * 127 + 36) / 72; }
807 inline long HMMToTwips(long nHMM) { return (nHMM * 72 + 63) / 127; }
809 //------------------------------------------------------------------------
811 #define SCCHARPROPERTIES_SERVICE "com.sun.star.style.CharacterProperties"
812 #define SCPARAPROPERTIES_SERVICE "com.sun.star.style.ParagraphProperties"
813 #define SCCELLPROPERTIES_SERVICE "com.sun.star.table.CellProperties"
814 #define SCCELLRANGE_SERVICE "com.sun.star.table.CellRange"
815 #define SCCELL_SERVICE "com.sun.star.table.Cell"
816 #define SCSHEETCELLRANGES_SERVICE "com.sun.star.sheet.SheetCellRanges"
817 #define SCSHEETCELLRANGE_SERVICE "com.sun.star.sheet.SheetCellRange"
818 #define SCSPREADSHEET_SERVICE "com.sun.star.sheet.Spreadsheet"
819 #define SCSHEETCELL_SERVICE "com.sun.star.sheet.SheetCell"
821 SC_SIMPLE_SERVICE_INFO( ScCellFormatsEnumeration, "ScCellFormatsEnumeration", "com.sun.star.sheet.CellFormatRangesEnumeration" )
822 SC_SIMPLE_SERVICE_INFO( ScCellFormatsObj, "ScCellFormatsObj", "com.sun.star.sheet.CellFormatRanges" )
823 SC_SIMPLE_SERVICE_INFO( ScUniqueCellFormatsEnumeration, "ScUniqueCellFormatsEnumeration", "com.sun.star.sheet.UniqueCellFormatRangesEnumeration" )
824 SC_SIMPLE_SERVICE_INFO( ScUniqueCellFormatsObj, "ScUniqueCellFormatsObj", "com.sun.star.sheet.UniqueCellFormatRanges" )
825 SC_SIMPLE_SERVICE_INFO( ScCellRangesBase, "ScCellRangesBase", "stardiv.unknown" )
826 SC_SIMPLE_SERVICE_INFO( ScCellsEnumeration, "ScCellsEnumeration", "com.sun.star.sheet.CellsEnumeration" )
827 SC_SIMPLE_SERVICE_INFO( ScCellsObj, "ScCellsObj", "com.sun.star.sheet.Cells" )
828 SC_SIMPLE_SERVICE_INFO( ScTableColumnObj, "ScTableColumnObj", "com.sun.star.table.TableColumn" )
829 SC_SIMPLE_SERVICE_INFO( ScTableRowObj, "ScTableRowObj", "com.sun.star.table.TableRow" )
831 //------------------------------------------------------------------------
833 SV_IMPL_PTRARR( XModifyListenerArr_Impl, XModifyListenerPtr );
834 SV_IMPL_PTRARR( ScNamedEntryArr_Impl, ScNamedEntryPtr );
836 //------------------------------------------------------------------------
838 //! ScLinkListener in anderes File verschieben !!!
840 ScLinkListener::~ScLinkListener()
844 void ScLinkListener::Notify( SvtBroadcaster&, const SfxHint& rHint )
846 aLink.Call( (SfxHint*)&rHint );
849 //------------------------------------------------------------------------
851 void lcl_CopyProperties( beans::XPropertySet& rDest, beans::XPropertySet& rSource )
853 uno::Reference<beans::XPropertySetInfo> xInfo(rSource.getPropertySetInfo());
854 if (xInfo.is())
856 uno::Sequence<beans::Property> aSeq(xInfo->getProperties());
857 const beans::Property* pAry = aSeq.getConstArray();
858 ULONG nCount = aSeq.getLength();
859 for (ULONG i=0; i<nCount; i++)
861 rtl::OUString aName(pAry[i].Name);
862 rDest.setPropertyValue( aName, rSource.getPropertyValue( aName ) );
867 SCTAB lcl_FirstTab( const ScRangeList& rRanges )
869 DBG_ASSERT(rRanges.Count() >= 1, "was fuer Ranges ?!?!");
870 const ScRange* pFirst = rRanges.GetObject(0);
871 if (pFirst)
872 return pFirst->aStart.Tab();
874 return 0; // soll nicht sein
877 BOOL lcl_WholeSheet( const ScRangeList& rRanges )
879 if ( rRanges.Count() == 1 )
881 ScRange* pRange = rRanges.GetObject(0);
882 if ( pRange && pRange->aStart.Col() == 0 && pRange->aEnd.Col() == MAXCOL &&
883 pRange->aStart.Row() == 0 && pRange->aEnd.Row() == MAXROW )
884 return TRUE;
886 return FALSE;
889 //------------------------------------------------------------------------
891 ScSubTotalFunc lcl_SummaryToSubTotal( sheet::GeneralFunction eSummary )
893 ScSubTotalFunc eSubTotal;
894 switch (eSummary)
896 case sheet::GeneralFunction_SUM:
897 eSubTotal = SUBTOTAL_FUNC_SUM;
898 break;
899 case sheet::GeneralFunction_COUNT:
900 eSubTotal = SUBTOTAL_FUNC_CNT2;
901 break;
902 case sheet::GeneralFunction_AVERAGE:
903 eSubTotal = SUBTOTAL_FUNC_AVE;
904 break;
905 case sheet::GeneralFunction_MAX:
906 eSubTotal = SUBTOTAL_FUNC_MAX;
907 break;
908 case sheet::GeneralFunction_MIN:
909 eSubTotal = SUBTOTAL_FUNC_MIN;
910 break;
911 case sheet::GeneralFunction_PRODUCT:
912 eSubTotal = SUBTOTAL_FUNC_PROD;
913 break;
914 case sheet::GeneralFunction_COUNTNUMS:
915 eSubTotal = SUBTOTAL_FUNC_CNT;
916 break;
917 case sheet::GeneralFunction_STDEV:
918 eSubTotal = SUBTOTAL_FUNC_STD;
919 break;
920 case sheet::GeneralFunction_STDEVP:
921 eSubTotal = SUBTOTAL_FUNC_STDP;
922 break;
923 case sheet::GeneralFunction_VAR:
924 eSubTotal = SUBTOTAL_FUNC_VAR;
925 break;
926 case sheet::GeneralFunction_VARP:
927 eSubTotal = SUBTOTAL_FUNC_VARP;
928 break;
930 case sheet::GeneralFunction_NONE:
931 case sheet::GeneralFunction_AUTO:
932 default:
933 eSubTotal = SUBTOTAL_FUNC_NONE;
934 break;
936 return eSubTotal;
939 //------------------------------------------------------------------------
941 const SvxBorderLine* ScHelperFunctions::GetBorderLine( SvxBorderLine& rLine, const table::BorderLine& rStruct )
943 // Calc braucht Twips, im Uno-Struct sind 1/100mm
945 rLine.SetOutWidth( (USHORT)HMMToTwips( rStruct.OuterLineWidth ) );
946 rLine.SetInWidth( (USHORT)HMMToTwips( rStruct.InnerLineWidth ) );
947 rLine.SetDistance( (USHORT)HMMToTwips( rStruct.LineDistance ) );
948 rLine.SetColor( ColorData( rStruct.Color ) );
950 if ( rLine.GetOutWidth() || rLine.GetInWidth() || rLine.GetDistance() )
951 return &rLine;
952 else
953 return NULL;
956 void ScHelperFunctions::FillBoxItems( SvxBoxItem& rOuter, SvxBoxInfoItem& rInner, const table::TableBorder& rBorder )
958 SvxBorderLine aLine;
959 rOuter.SetDistance( (USHORT)HMMToTwips( rBorder.Distance ) );
960 rOuter.SetLine( ScHelperFunctions::GetBorderLine( aLine, rBorder.TopLine ), BOX_LINE_TOP );
961 rOuter.SetLine( ScHelperFunctions::GetBorderLine( aLine, rBorder.BottomLine ), BOX_LINE_BOTTOM );
962 rOuter.SetLine( ScHelperFunctions::GetBorderLine( aLine, rBorder.LeftLine ), BOX_LINE_LEFT );
963 rOuter.SetLine( ScHelperFunctions::GetBorderLine( aLine, rBorder.RightLine ), BOX_LINE_RIGHT );
964 rInner.SetLine( ScHelperFunctions::GetBorderLine( aLine, rBorder.HorizontalLine ), BOXINFO_LINE_HORI );
965 rInner.SetLine( ScHelperFunctions::GetBorderLine( aLine, rBorder.VerticalLine ), BOXINFO_LINE_VERT );
966 rInner.SetValid( VALID_TOP, rBorder.IsTopLineValid );
967 rInner.SetValid( VALID_BOTTOM, rBorder.IsBottomLineValid );
968 rInner.SetValid( VALID_LEFT, rBorder.IsLeftLineValid );
969 rInner.SetValid( VALID_RIGHT, rBorder.IsRightLineValid );
970 rInner.SetValid( VALID_HORI, rBorder.IsHorizontalLineValid );
971 rInner.SetValid( VALID_VERT, rBorder.IsVerticalLineValid );
972 rInner.SetValid( VALID_DISTANCE, rBorder.IsDistanceValid );
973 rInner.SetTable( TRUE );
976 void ScHelperFunctions::FillBorderLine( table::BorderLine& rStruct, const SvxBorderLine* pLine )
978 if (pLine)
980 rStruct.Color = pLine->GetColor().GetColor();
981 rStruct.InnerLineWidth = (sal_Int16)TwipsToHMM( pLine->GetInWidth() );
982 rStruct.OuterLineWidth = (sal_Int16)TwipsToHMM( pLine->GetOutWidth() );
983 rStruct.LineDistance = (sal_Int16)TwipsToHMM( pLine->GetDistance() );
985 else
986 rStruct.Color = rStruct.InnerLineWidth =
987 rStruct.OuterLineWidth = rStruct.LineDistance = 0;
990 void ScHelperFunctions::FillTableBorder( table::TableBorder& rBorder,
991 const SvxBoxItem& rOuter, const SvxBoxInfoItem& rInner )
993 ScHelperFunctions::FillBorderLine( rBorder.TopLine, rOuter.GetTop() );
994 ScHelperFunctions::FillBorderLine( rBorder.BottomLine, rOuter.GetBottom() );
995 ScHelperFunctions::FillBorderLine( rBorder.LeftLine, rOuter.GetLeft() );
996 ScHelperFunctions::FillBorderLine( rBorder.RightLine, rOuter.GetRight() );
997 ScHelperFunctions::FillBorderLine( rBorder.HorizontalLine, rInner.GetHori() );
998 ScHelperFunctions::FillBorderLine( rBorder.VerticalLine, rInner.GetVert() );
1000 rBorder.Distance = rOuter.GetDistance();
1001 rBorder.IsTopLineValid = rInner.IsValid(VALID_TOP);
1002 rBorder.IsBottomLineValid = rInner.IsValid(VALID_BOTTOM);
1003 rBorder.IsLeftLineValid = rInner.IsValid(VALID_LEFT);
1004 rBorder.IsRightLineValid = rInner.IsValid(VALID_RIGHT);
1005 rBorder.IsHorizontalLineValid = rInner.IsValid(VALID_HORI);
1006 rBorder.IsVerticalLineValid = rInner.IsValid(VALID_VERT);
1007 rBorder.IsDistanceValid = rInner.IsValid(VALID_DISTANCE);
1010 //------------------------------------------------------------------------
1012 //! lcl_ApplyBorder nach docfunc verschieben!
1014 void ScHelperFunctions::ApplyBorder( ScDocShell* pDocShell, const ScRangeList& rRanges,
1015 const SvxBoxItem& rOuter, const SvxBoxInfoItem& rInner )
1017 ScDocument* pDoc = pDocShell->GetDocument();
1018 BOOL bUndo(pDoc->IsUndoEnabled());
1019 ScDocument* pUndoDoc = NULL;
1020 if (bUndo)
1021 pUndoDoc = new ScDocument( SCDOCMODE_UNDO );
1022 ULONG nCount = rRanges.Count();
1023 ULONG i;
1024 for (i=0; i<nCount; i++)
1026 ScRange aRange(*rRanges.GetObject(i));
1027 SCTAB nTab = aRange.aStart.Tab();
1029 if (bUndo)
1031 if ( i==0 )
1032 pUndoDoc->InitUndo( pDoc, nTab, nTab );
1033 else
1034 pUndoDoc->AddUndoTab( nTab, nTab );
1035 pDoc->CopyToDocument( aRange, IDF_ATTRIB, FALSE, pUndoDoc );
1038 ScMarkData aMark;
1039 aMark.SetMarkArea( aRange );
1040 aMark.SelectTable( nTab, TRUE );
1042 pDoc->ApplySelectionFrame( aMark, &rOuter, &rInner );
1043 // RowHeight bei Umrandung alleine nicht noetig
1046 if (bUndo)
1048 pDocShell->GetUndoManager()->AddUndoAction(
1049 new ScUndoBorder( pDocShell, rRanges, pUndoDoc, rOuter, rInner ) );
1052 for (i=0; i<nCount; i++)
1053 pDocShell->PostPaint( *rRanges.GetObject(i), PAINT_GRID, SC_PF_LINES | SC_PF_TESTMERGE );
1055 pDocShell->SetDocumentModified();
1058 //! move lcl_PutDataArray to docfunc?
1059 //! merge loop with ScFunctionAccess::callFunction
1061 BOOL lcl_PutDataArray( ScDocShell& rDocShell, const ScRange& rRange,
1062 const uno::Sequence< uno::Sequence<uno::Any> >& aData )
1064 // BOOL bApi = TRUE;
1066 ScDocument* pDoc = rDocShell.GetDocument();
1067 SCTAB nTab = rRange.aStart.Tab();
1068 SCCOL nStartCol = rRange.aStart.Col();
1069 SCROW nStartRow = rRange.aStart.Row();
1070 SCCOL nEndCol = rRange.aEnd.Col();
1071 SCROW nEndRow = rRange.aEnd.Row();
1072 BOOL bUndo(pDoc->IsUndoEnabled());
1074 if ( !pDoc->IsBlockEditable( nTab, nStartCol,nStartRow, nEndCol,nEndRow ) )
1076 //! error message
1077 return FALSE;
1080 long nCols = 0;
1081 long nRows = aData.getLength();
1082 const uno::Sequence<uno::Any>* pArray = aData.getConstArray();
1083 if ( nRows )
1084 nCols = pArray[0].getLength();
1086 if ( nCols != nEndCol-nStartCol+1 || nRows != nEndRow-nStartRow+1 )
1088 //! error message?
1089 return FALSE;
1092 ScDocument* pUndoDoc = NULL;
1093 if ( bUndo )
1095 pUndoDoc = new ScDocument( SCDOCMODE_UNDO );
1096 pUndoDoc->InitUndo( pDoc, nTab, nTab );
1097 pDoc->CopyToDocument( rRange, IDF_CONTENTS|IDF_NOCAPTIONS, FALSE, pUndoDoc );
1100 pDoc->DeleteAreaTab( nStartCol, nStartRow, nEndCol, nEndRow, nTab, IDF_CONTENTS );
1102 BOOL bError = FALSE;
1103 SCROW nDocRow = nStartRow;
1104 for (long nRow=0; nRow<nRows; nRow++)
1106 const uno::Sequence<uno::Any>& rColSeq = pArray[nRow];
1107 if ( rColSeq.getLength() == nCols )
1109 SCCOL nDocCol = nStartCol;
1110 const uno::Any* pColArr = rColSeq.getConstArray();
1111 for (long nCol=0; nCol<nCols; nCol++)
1113 const uno::Any& rElement = pColArr[nCol];
1114 uno::TypeClass eElemClass = rElement.getValueTypeClass();
1115 if ( eElemClass == uno::TypeClass_VOID )
1117 // void = "no value"
1118 pDoc->SetError( nDocCol, nDocRow, nTab, NOTAVAILABLE );
1120 else if ( eElemClass == uno::TypeClass_BYTE ||
1121 eElemClass == uno::TypeClass_SHORT ||
1122 eElemClass == uno::TypeClass_UNSIGNED_SHORT ||
1123 eElemClass == uno::TypeClass_LONG ||
1124 eElemClass == uno::TypeClass_UNSIGNED_LONG ||
1125 eElemClass == uno::TypeClass_FLOAT ||
1126 eElemClass == uno::TypeClass_DOUBLE )
1128 // #87871# accept integer types because Basic passes a floating point
1129 // variable as byte, short or long if it's an integer number.
1130 double fVal;
1131 rElement >>= fVal;
1132 pDoc->SetValue( nDocCol, nDocRow, nTab, fVal );
1134 else if ( eElemClass == uno::TypeClass_STRING )
1136 rtl::OUString aUStr;
1137 rElement >>= aUStr;
1138 if ( aUStr.getLength() )
1139 pDoc->PutCell( nDocCol, nDocRow, nTab, new ScStringCell( aUStr ) );
1141 else
1142 bError = TRUE; // invalid type
1144 ++nDocCol;
1147 else
1148 bError = TRUE; // wrong size
1150 ++nDocRow;
1153 BOOL bHeight = rDocShell.AdjustRowHeight( nStartRow, nEndRow, nTab );
1155 if ( pUndoDoc )
1157 ScMarkData aDestMark;
1158 aDestMark.SelectOneTable( nTab );
1159 rDocShell.GetUndoManager()->AddUndoAction(
1160 new ScUndoPaste( &rDocShell,
1161 nStartCol, nStartRow, nTab, nEndCol, nEndRow, nTab, aDestMark,
1162 pUndoDoc, NULL, IDF_CONTENTS, NULL,NULL,NULL,NULL, FALSE ) );
1165 if (!bHeight)
1166 rDocShell.PostPaint( rRange, PAINT_GRID ); // AdjustRowHeight may have painted already
1168 rDocShell.SetDocumentModified();
1170 return !bError;
1173 BOOL lcl_PutFormulaArray( ScDocShell& rDocShell, const ScRange& rRange,
1174 const uno::Sequence< uno::Sequence<rtl::OUString> >& aData,
1175 const ::rtl::OUString& rFormulaNmsp, const formula::FormulaGrammar::Grammar eGrammar )
1177 // BOOL bApi = TRUE;
1179 ScDocument* pDoc = rDocShell.GetDocument();
1180 SCTAB nTab = rRange.aStart.Tab();
1181 SCCOL nStartCol = rRange.aStart.Col();
1182 SCROW nStartRow = rRange.aStart.Row();
1183 SCCOL nEndCol = rRange.aEnd.Col();
1184 SCROW nEndRow = rRange.aEnd.Row();
1185 BOOL bUndo(pDoc->IsUndoEnabled());
1187 if ( !pDoc->IsBlockEditable( nTab, nStartCol,nStartRow, nEndCol,nEndRow ) )
1189 //! error message
1190 return FALSE;
1193 long nCols = 0;
1194 long nRows = aData.getLength();
1195 const uno::Sequence<rtl::OUString>* pArray = aData.getConstArray();
1196 if ( nRows )
1197 nCols = pArray[0].getLength();
1199 if ( nCols != nEndCol-nStartCol+1 || nRows != nEndRow-nStartRow+1 )
1201 //! error message?
1202 return FALSE;
1205 ScDocument* pUndoDoc = NULL;
1206 if ( bUndo )
1208 pUndoDoc = new ScDocument( SCDOCMODE_UNDO );
1209 pUndoDoc->InitUndo( pDoc, nTab, nTab );
1210 pDoc->CopyToDocument( rRange, IDF_CONTENTS, FALSE, pUndoDoc );
1213 pDoc->DeleteAreaTab( nStartCol, nStartRow, nEndCol, nEndRow, nTab, IDF_CONTENTS );
1215 ScDocFunc aFunc( rDocShell ); // for InterpretEnglishString
1217 BOOL bError = FALSE;
1218 SCROW nDocRow = nStartRow;
1219 for (long nRow=0; nRow<nRows; nRow++)
1221 const uno::Sequence<rtl::OUString>& rColSeq = pArray[nRow];
1222 if ( rColSeq.getLength() == nCols )
1224 SCCOL nDocCol = nStartCol;
1225 const rtl::OUString* pColArr = rColSeq.getConstArray();
1226 for (long nCol=0; nCol<nCols; nCol++)
1228 String aText(pColArr[nCol]);
1229 ScAddress aPos( nDocCol, nDocRow, nTab );
1230 ScBaseCell* pNewCell = aFunc.InterpretEnglishString( aPos, aText, rFormulaNmsp, eGrammar );
1231 pDoc->PutCell( aPos, pNewCell );
1233 ++nDocCol;
1236 else
1237 bError = TRUE; // wrong size
1239 ++nDocRow;
1242 BOOL bHeight = rDocShell.AdjustRowHeight( nStartRow, nEndRow, nTab );
1244 if ( pUndoDoc )
1246 ScMarkData aDestMark;
1247 aDestMark.SelectOneTable( nTab );
1248 rDocShell.GetUndoManager()->AddUndoAction(
1249 new ScUndoPaste( &rDocShell,
1250 nStartCol, nStartRow, nTab, nEndCol, nEndRow, nTab, aDestMark,
1251 pUndoDoc, NULL, IDF_CONTENTS, NULL,NULL,NULL,NULL, FALSE ) );
1254 if (!bHeight)
1255 rDocShell.PostPaint( rRange, PAINT_GRID ); // AdjustRowHeight may have painted already
1257 rDocShell.SetDocumentModified();
1259 return !bError;
1262 // used in ScCellRangeObj::getFormulaArray and ScCellObj::GetInputString_Impl
1263 String lcl_GetInputString( ScDocument* pDoc, const ScAddress& rPosition, BOOL bEnglish )
1265 String aVal;
1266 if ( pDoc )
1268 ScBaseCell* pCell = pDoc->GetCell( rPosition );
1269 if ( pCell && pCell->GetCellType() != CELLTYPE_NOTE )
1271 CellType eType = pCell->GetCellType();
1272 if ( eType == CELLTYPE_FORMULA )
1274 ScFormulaCell* pForm = (ScFormulaCell*)pCell;
1275 pForm->GetFormula( aVal,formula::FormulaGrammar::mapAPItoGrammar( bEnglish, false));
1277 else
1279 SvNumberFormatter* pFormatter = bEnglish ? ScGlobal::GetEnglishFormatter() :
1280 pDoc->GetFormatTable();
1281 // Since the English formatter was constructed with
1282 // LANGUAGE_ENGLISH_US the "General" format has index key 0,
1283 // we don't have to query.
1284 sal_uInt32 nNumFmt = bEnglish ?
1285 // pFormatter->GetStandardIndex(LANGUAGE_ENGLISH_US) :
1287 pDoc->GetNumberFormat( rPosition );
1289 if ( eType == CELLTYPE_EDIT )
1291 // GetString an der EditCell macht Leerzeichen aus Umbruechen,
1292 // hier werden die Umbrueche aber gebraucht
1293 const EditTextObject* pData = ((ScEditCell*)pCell)->GetData();
1294 if (pData)
1296 EditEngine& rEngine = pDoc->GetEditEngine();
1297 rEngine.SetText( *pData );
1298 aVal = rEngine.GetText( LINEEND_LF );
1301 else
1302 ScCellFormat::GetInputString( pCell, nNumFmt, aVal, *pFormatter );
1304 // ggf. ein ' davorhaengen wie in ScTabViewShell::UpdateInputHandler
1305 if ( eType == CELLTYPE_STRING || eType == CELLTYPE_EDIT )
1307 double fDummy;
1308 sal_Bool bIsNumberFormat(pFormatter->IsNumberFormat(aVal, nNumFmt, fDummy));
1309 if ( bIsNumberFormat )
1310 aVal.Insert('\'',0);
1311 else if ( aVal.Len() && aVal.GetChar(0) == '\'' )
1313 // if the string starts with a "'", add another one because setFormula
1314 // strips one (like text input, except for "text" number formats)
1315 if ( bEnglish || ( pFormatter->GetType(nNumFmt) != NUMBERFORMAT_TEXT ) )
1316 aVal.Insert('\'',0);
1322 return aVal;
1325 //------------------------------------------------------------------------
1327 // Default-ctor fuer SMART_REFLECTION Krempel
1328 ScCellRangesBase::ScCellRangesBase() :
1329 pPropSet(lcl_GetCellsPropertySet()),
1330 pDocShell( NULL ),
1331 pValueListener( NULL ),
1332 pCurrentFlat( NULL ),
1333 pCurrentDeep( NULL ),
1334 pCurrentDataSet( NULL ),
1335 pNoDfltCurrentDataSet( NULL ),
1336 pMarkData( NULL ),
1337 nObjectId( 0 ),
1338 bChartColAsHdr( FALSE ),
1339 bChartRowAsHdr( FALSE ),
1340 bCursorOnly( FALSE ),
1341 bGotDataChangedHint( FALSE ),
1342 aValueListeners( 0 )
1346 ScCellRangesBase::ScCellRangesBase(ScDocShell* pDocSh, const ScRange& rR) :
1347 pPropSet(lcl_GetCellsPropertySet()),
1348 pDocShell( pDocSh ),
1349 pValueListener( NULL ),
1350 pCurrentFlat( NULL ),
1351 pCurrentDeep( NULL ),
1352 pCurrentDataSet( NULL ),
1353 pNoDfltCurrentDataSet( NULL ),
1354 pMarkData( NULL ),
1355 nObjectId( 0 ),
1356 bChartColAsHdr( FALSE ),
1357 bChartRowAsHdr( FALSE ),
1358 bCursorOnly( FALSE ),
1359 bGotDataChangedHint( FALSE ),
1360 aValueListeners( 0 )
1362 ScRange aCellRange(rR);
1363 aCellRange.Justify();
1364 aRanges.Append( aCellRange );
1366 if (pDocShell) // Null if created with createInstance
1368 ScDocument* pDoc = pDocShell->GetDocument();
1369 pDoc->AddUnoObject(*this);
1370 nObjectId = pDoc->GetNewUnoId();
1374 ScCellRangesBase::ScCellRangesBase(ScDocShell* pDocSh, const ScRangeList& rR) :
1375 pPropSet(lcl_GetCellsPropertySet()),
1376 pDocShell( pDocSh ),
1377 pValueListener( NULL ),
1378 pCurrentFlat( NULL ),
1379 pCurrentDeep( NULL ),
1380 pCurrentDataSet( NULL ),
1381 pNoDfltCurrentDataSet( NULL ),
1382 pMarkData( NULL ),
1383 aRanges( rR ),
1384 nObjectId( 0 ),
1385 bChartColAsHdr( FALSE ),
1386 bChartRowAsHdr( FALSE ),
1387 bCursorOnly( FALSE ),
1388 bGotDataChangedHint( FALSE ),
1389 aValueListeners( 0 )
1391 if (pDocShell) // Null if created with createInstance
1393 ScDocument* pDoc = pDocShell->GetDocument();
1394 pDoc->AddUnoObject(*this);
1395 nObjectId = pDoc->GetNewUnoId();
1399 ScCellRangesBase::~ScCellRangesBase()
1401 // #107294# call RemoveUnoObject first, so no notification can happen
1402 // during ForgetCurrentAttrs
1404 if (pDocShell)
1405 pDocShell->GetDocument()->RemoveUnoObject(*this);
1407 ForgetCurrentAttrs();
1408 ForgetMarkData();
1410 delete pValueListener;
1412 //! XChartDataChangeEventListener abmelden ??
1413 //! (ChartCollection haelt dann auch dieses Objekt fest!)
1416 void ScCellRangesBase::ForgetCurrentAttrs()
1418 delete pCurrentFlat;
1419 delete pCurrentDeep;
1420 delete pCurrentDataSet;
1421 delete pNoDfltCurrentDataSet;
1422 pCurrentFlat = NULL;
1423 pCurrentDeep = NULL;
1424 pCurrentDataSet = NULL;
1425 pNoDfltCurrentDataSet = NULL;
1427 // #i62483# pMarkData can remain unchanged, is deleted only if the range changes (RefChanged)
1430 void ScCellRangesBase::ForgetMarkData()
1432 delete pMarkData;
1433 pMarkData = NULL;
1436 const ScPatternAttr* ScCellRangesBase::GetCurrentAttrsFlat()
1438 // get and cache direct cell attributes for this object's range
1440 if ( !pCurrentFlat && pDocShell )
1442 ScDocument* pDoc = pDocShell->GetDocument();
1443 pCurrentFlat = pDoc->CreateSelectionPattern( *GetMarkData(), FALSE );
1445 return pCurrentFlat;
1448 const ScPatternAttr* ScCellRangesBase::GetCurrentAttrsDeep()
1450 // get and cache cell attributes (incl. styles) for this object's range
1452 if ( !pCurrentDeep && pDocShell )
1454 ScDocument* pDoc = pDocShell->GetDocument();
1455 pCurrentDeep = pDoc->CreateSelectionPattern( *GetMarkData(), TRUE );
1457 return pCurrentDeep;
1460 SfxItemSet* ScCellRangesBase::GetCurrentDataSet(bool bNoDflt)
1462 if(!pCurrentDataSet)
1464 const ScPatternAttr* pPattern = GetCurrentAttrsDeep();
1465 if ( pPattern )
1467 // Dontcare durch Default ersetzen, damit man immer eine Reflection hat
1468 pCurrentDataSet = new SfxItemSet( pPattern->GetItemSet() );
1469 pNoDfltCurrentDataSet = new SfxItemSet( pPattern->GetItemSet() );
1470 pCurrentDataSet->ClearInvalidItems();
1473 return bNoDflt ? pNoDfltCurrentDataSet : pCurrentDataSet;
1476 const ScMarkData* ScCellRangesBase::GetMarkData()
1478 if (!pMarkData)
1480 pMarkData = new ScMarkData();
1481 pMarkData->MarkFromRangeList( aRanges, FALSE );
1483 return pMarkData;
1486 void ScCellRangesBase::Notify( SfxBroadcaster&, const SfxHint& rHint )
1488 if ( rHint.ISA( ScUpdateRefHint ) )
1490 const ScUpdateRefHint& rRef = (const ScUpdateRefHint&)rHint;
1492 ScDocument* pDoc = pDocShell->GetDocument();
1493 ScRangeList* pUndoRanges = NULL;
1494 if ( pDoc->HasUnoRefUndo() )
1495 pUndoRanges = new ScRangeList( aRanges );
1497 if ( aRanges.UpdateReference( rRef.GetMode(), pDoc, rRef.GetRange(),
1498 rRef.GetDx(), rRef.GetDy(), rRef.GetDz() ) )
1500 uno::Reference<uno::XInterface> xInterface((cppu::OWeakObject*)this, uno::UNO_QUERY);
1501 if (rRef.GetMode() == URM_INSDEL &&
1502 aRanges.Count() == 1 &&
1503 ScTableSheetObj::getImplementation( xInterface ))
1505 // #101755#; the range size of a sheet does not change
1506 ScRange* pR = aRanges.First();
1507 if (pR)
1509 pR->aStart.SetCol(0);
1510 pR->aStart.SetRow(0);
1511 pR->aEnd.SetCol(MAXCOL);
1512 pR->aEnd.SetRow(MAXROW);
1515 RefChanged();
1517 // #129050# any change of the range address is broadcast to value (modify) listeners
1518 if ( aValueListeners.Count() )
1519 bGotDataChangedHint = TRUE;
1521 if ( pUndoRanges )
1522 pDoc->AddUnoRefChange( nObjectId, *pUndoRanges );
1525 delete pUndoRanges;
1527 else if ( rHint.ISA( SfxSimpleHint ) )
1529 ULONG nId = ((const SfxSimpleHint&)rHint).GetId();
1530 if ( nId == SFX_HINT_DYING )
1532 ForgetCurrentAttrs();
1533 pDocShell = NULL; // invalid
1535 if ( aValueListeners.Count() != 0 )
1537 // dispose listeners
1539 lang::EventObject aEvent;
1540 aEvent.Source.set(static_cast<cppu::OWeakObject*>(this));
1541 for ( USHORT n=0; n<aValueListeners.Count(); n++ )
1542 (*aValueListeners[n])->disposing( aEvent );
1544 aValueListeners.DeleteAndDestroy( 0, aValueListeners.Count() );
1546 // The listeners can't have the last ref to this, as it's still held
1547 // by the DocShell.
1550 else if ( nId == SFX_HINT_DATACHANGED )
1552 // document content changed -> forget cached attributes
1553 ForgetCurrentAttrs();
1555 if ( bGotDataChangedHint && pDocShell )
1557 // This object was notified of content changes, so one call
1558 // for each listener is generated now.
1559 // The calls can't be executed directly because the document's
1560 // UNO broadcaster list must not be modified.
1561 // Instead, add to the document's list of listener calls,
1562 // which will be executed directly after the broadcast of
1563 // SFX_HINT_DATACHANGED.
1565 lang::EventObject aEvent;
1566 aEvent.Source.set((cppu::OWeakObject*)this);
1568 // the EventObject holds a Ref to this object until after the listener calls
1570 ScDocument* pDoc = pDocShell->GetDocument();
1571 for ( USHORT n=0; n<aValueListeners.Count(); n++ )
1572 pDoc->AddUnoListenerCall( *aValueListeners[n], aEvent );
1574 bGotDataChangedHint = FALSE;
1577 else if ( nId == SC_HINT_CALCALL )
1579 // broadcast from DoHardRecalc - set bGotDataChangedHint
1580 // (SFX_HINT_DATACHANGED follows separately)
1582 if ( aValueListeners.Count() )
1583 bGotDataChangedHint = TRUE;
1586 else if ( rHint.ISA( ScUnoRefUndoHint ) )
1588 const ScUnoRefUndoHint& rUndoHint = static_cast<const ScUnoRefUndoHint&>(rHint);
1589 if ( rUndoHint.GetObjectId() == nObjectId )
1591 // restore ranges from hint
1593 aRanges = rUndoHint.GetRanges();
1595 RefChanged();
1596 if ( aValueListeners.Count() )
1597 bGotDataChangedHint = TRUE; // need to broadcast the undo, too
1602 void ScCellRangesBase::RefChanged()
1604 //! adjust XChartDataChangeEventListener
1606 if ( pValueListener && aValueListeners.Count() != 0 )
1608 pValueListener->EndListeningAll();
1610 ScDocument* pDoc = pDocShell->GetDocument();
1611 ULONG nCount = aRanges.Count();
1612 for (ULONG i=0; i<nCount; i++)
1613 pDoc->StartListeningArea( *aRanges.GetObject(i), pValueListener );
1616 ForgetCurrentAttrs();
1617 ForgetMarkData();
1620 ScDocument* ScCellRangesBase::GetDocument() const
1622 if (pDocShell)
1623 return pDocShell->GetDocument();
1624 else
1625 return NULL;
1628 void ScCellRangesBase::InitInsertRange(ScDocShell* pDocSh, const ScRange& rR)
1630 if ( !pDocShell && pDocSh )
1632 pDocShell = pDocSh;
1634 ScRange aCellRange(rR);
1635 aCellRange.Justify();
1636 aRanges.RemoveAll();
1637 aRanges.Append( aCellRange );
1639 pDocShell->GetDocument()->AddUnoObject(*this);
1641 RefChanged(); // Range im Range-Objekt anpassen
1645 void ScCellRangesBase::AddRange(const ScRange& rRange, const sal_Bool bMergeRanges)
1647 if (bMergeRanges)
1648 aRanges.Join(rRange);
1649 else
1650 aRanges.Append(rRange);
1651 RefChanged();
1654 void ScCellRangesBase::SetNewRange(const ScRange& rNew)
1656 ScRange aCellRange(rNew);
1657 aCellRange.Justify();
1659 aRanges.RemoveAll();
1660 aRanges.Append( aCellRange );
1661 RefChanged();
1664 void ScCellRangesBase::SetNewRanges(const ScRangeList& rNew)
1666 aRanges = rNew;
1667 RefChanged();
1670 void ScCellRangesBase::SetCursorOnly( BOOL bSet )
1672 // set for a selection object that is created from the cursor position
1673 // without anything selected (may contain several sheets)
1675 bCursorOnly = bSet;
1678 uno::Any SAL_CALL ScCellRangesBase::queryInterface( const uno::Type& rType )
1679 throw(uno::RuntimeException)
1681 SC_QUERYINTERFACE( beans::XPropertySet )
1682 SC_QUERYINTERFACE( beans::XMultiPropertySet )
1683 SC_QUERYINTERFACE( beans::XTolerantMultiPropertySet )
1684 SC_QUERYINTERFACE( beans::XPropertyState )
1685 SC_QUERYINTERFACE( sheet::XSheetOperation )
1686 SC_QUERYINTERFACE( chart::XChartDataArray )
1687 SC_QUERYINTERFACE( chart::XChartData )
1688 SC_QUERYINTERFACE( util::XIndent )
1689 SC_QUERYINTERFACE( sheet::XCellRangesQuery )
1690 SC_QUERYINTERFACE( sheet::XFormulaQuery )
1691 SC_QUERYINTERFACE( util::XReplaceable )
1692 SC_QUERYINTERFACE( util::XSearchable )
1693 SC_QUERYINTERFACE( util::XModifyBroadcaster )
1694 SC_QUERYINTERFACE( lang::XServiceInfo )
1695 SC_QUERYINTERFACE( lang::XUnoTunnel )
1696 SC_QUERYINTERFACE( lang::XTypeProvider )
1698 return OWeakObject::queryInterface( rType );
1701 void SAL_CALL ScCellRangesBase::acquire() throw()
1703 OWeakObject::acquire();
1706 void SAL_CALL ScCellRangesBase::release() throw()
1708 OWeakObject::release();
1711 uno::Sequence<uno::Type> SAL_CALL ScCellRangesBase::getTypes() throw(uno::RuntimeException)
1713 static uno::Sequence<uno::Type> aTypes;
1714 if ( aTypes.getLength() == 0 )
1716 aTypes.realloc(13);
1717 uno::Type* pPtr = aTypes.getArray();
1718 pPtr[0] = getCppuType((const uno::Reference<beans::XPropertySet>*)0);
1719 pPtr[1] = getCppuType((const uno::Reference<beans::XMultiPropertySet>*)0);
1720 pPtr[2] = getCppuType((const uno::Reference<beans::XPropertyState>*)0);
1721 pPtr[3] = getCppuType((const uno::Reference<sheet::XSheetOperation>*)0);
1722 pPtr[4] = getCppuType((const uno::Reference<chart::XChartDataArray>*)0);
1723 pPtr[5] = getCppuType((const uno::Reference<util::XIndent>*)0);
1724 pPtr[6] = getCppuType((const uno::Reference<sheet::XCellRangesQuery>*)0);
1725 pPtr[7] = getCppuType((const uno::Reference<sheet::XFormulaQuery>*)0);
1726 pPtr[8] = getCppuType((const uno::Reference<util::XReplaceable>*)0);
1727 pPtr[9] = getCppuType((const uno::Reference<util::XModifyBroadcaster>*)0);
1728 pPtr[10]= getCppuType((const uno::Reference<lang::XServiceInfo>*)0);
1729 pPtr[11]= getCppuType((const uno::Reference<lang::XUnoTunnel>*)0);
1730 pPtr[12]= getCppuType((const uno::Reference<lang::XTypeProvider>*)0);
1732 return aTypes;
1735 uno::Sequence<sal_Int8> SAL_CALL ScCellRangesBase::getImplementationId()
1736 throw(uno::RuntimeException)
1738 static uno::Sequence< sal_Int8 > aId;
1739 if( aId.getLength() == 0 )
1741 aId.realloc( 16 );
1742 rtl_createUuid( (sal_uInt8 *)aId.getArray(), 0, sal_True );
1744 return aId;
1747 // ---
1749 void ScCellRangesBase::PaintRanges_Impl( USHORT nPart )
1751 ULONG nCount = aRanges.Count();
1752 for (ULONG i=0; i<nCount; i++)
1753 pDocShell->PostPaint( *aRanges.GetObject(i), nPart );
1756 // XSheetOperation
1758 double SAL_CALL ScCellRangesBase::computeFunction( sheet::GeneralFunction nFunction )
1759 throw(uno::Exception, uno::RuntimeException)
1761 ScUnoGuard aGuard;
1762 ScMarkData aMark(*GetMarkData());
1763 aMark.MarkToSimple();
1764 if (!aMark.IsMarked())
1765 aMark.SetMarkNegative(TRUE); // um Dummy Position angeben zu koennen
1767 ScAddress aDummy; // wenn nicht Marked, ignoriert wegen Negative
1768 double fVal;
1769 ScSubTotalFunc eFunc = lcl_SummaryToSubTotal( nFunction );
1770 ScDocument* pDoc = pDocShell->GetDocument();
1771 if ( !pDoc->GetSelectionFunction( eFunc, aDummy, aMark, fVal ) )
1773 throw uno::RuntimeException(); //! own exception?
1776 return fVal;
1779 void SAL_CALL ScCellRangesBase::clearContents( sal_Int32 nContentFlags ) throw(uno::RuntimeException)
1781 ScUnoGuard aGuard;
1782 if ( aRanges.Count() )
1784 // only for clearContents: EDITATTR is only used if no contents are deleted
1785 USHORT nDelFlags = static_cast< USHORT >( nContentFlags & IDF_ALL );
1786 if ( ( nContentFlags & IDF_EDITATTR ) && ( nContentFlags & IDF_CONTENTS ) == 0 )
1787 nDelFlags |= IDF_EDITATTR;
1789 ScDocFunc aFunc(*pDocShell);
1790 aFunc.DeleteContents( *GetMarkData(), nDelFlags, TRUE, TRUE );
1792 // sonst ist nichts zu tun
1795 // XPropertyState
1797 const SfxItemPropertyMap* ScCellRangesBase::GetItemPropertyMap()
1799 return pPropSet->getPropertyMap();
1802 void lcl_GetPropertyWhich( const SfxItemPropertySimpleEntry* pEntry,
1803 USHORT& rItemWhich )
1805 // Which-ID des betroffenen Items, auch wenn das Item die Property
1806 // nicht alleine behandeln kann
1807 if ( pEntry )
1809 if ( IsScItemWid( pEntry->nWID ) )
1810 rItemWhich = pEntry->nWID;
1811 else
1812 switch ( pEntry->nWID )
1814 case SC_WID_UNO_TBLBORD:
1815 rItemWhich = ATTR_BORDER;
1816 break;
1817 case SC_WID_UNO_CONDFMT:
1818 case SC_WID_UNO_CONDLOC:
1819 case SC_WID_UNO_CONDXML:
1820 rItemWhich = ATTR_CONDITIONAL;
1821 break;
1822 case SC_WID_UNO_VALIDAT:
1823 case SC_WID_UNO_VALILOC:
1824 case SC_WID_UNO_VALIXML:
1825 rItemWhich = ATTR_VALIDDATA;
1826 break;
1832 beans::PropertyState ScCellRangesBase::GetOnePropertyState( USHORT nItemWhich, const SfxItemPropertySimpleEntry* pEntry )
1834 beans::PropertyState eRet = beans::PropertyState_DIRECT_VALUE;
1835 if ( nItemWhich ) // item wid (from map or special case)
1837 // For items that contain several properties (like background),
1838 // "ambiguous" is returned too often here
1840 // for PropertyState, don't look at styles
1841 const ScPatternAttr* pPattern = GetCurrentAttrsFlat();
1842 if ( pPattern )
1844 SfxItemState eState = pPattern->GetItemSet().GetItemState( nItemWhich, FALSE );
1846 // // if no rotate value is set, look at orientation
1847 // //! also for a fixed value of 0 (in case orientation is ambiguous)?
1848 // if ( nItemWhich == ATTR_ROTATE_VALUE && eState == SFX_ITEM_DEFAULT )
1849 // eState = pPattern->GetItemSet().GetItemState( ATTR_ORIENTATION, FALSE );
1851 if ( nItemWhich == ATTR_VALUE_FORMAT && eState == SFX_ITEM_DEFAULT )
1852 eState = pPattern->GetItemSet().GetItemState( ATTR_LANGUAGE_FORMAT, FALSE );
1854 if ( eState == SFX_ITEM_SET )
1855 eRet = beans::PropertyState_DIRECT_VALUE;
1856 else if ( eState == SFX_ITEM_DEFAULT )
1857 eRet = beans::PropertyState_DEFAULT_VALUE;
1858 else if ( eState == SFX_ITEM_DONTCARE )
1859 eRet = beans::PropertyState_AMBIGUOUS_VALUE;
1860 else
1862 DBG_ERROR("unbekannter ItemState");
1866 else if ( pEntry )
1868 if ( pEntry->nWID == SC_WID_UNO_CHCOLHDR || pEntry->nWID == SC_WID_UNO_CHROWHDR || pEntry->nWID == SC_WID_UNO_ABSNAME )
1869 eRet = beans::PropertyState_DIRECT_VALUE;
1870 else if ( pEntry->nWID == SC_WID_UNO_CELLSTYL )
1872 // a style is always set, there's no default state
1873 const ScStyleSheet* pStyle = pDocShell->GetDocument()->GetSelectionStyle(*GetMarkData());
1874 if (pStyle)
1875 eRet = beans::PropertyState_DIRECT_VALUE;
1876 else
1877 eRet = beans::PropertyState_AMBIGUOUS_VALUE;
1879 else if ( pEntry->nWID == SC_WID_UNO_NUMRULES )
1880 eRet = beans::PropertyState_DEFAULT_VALUE; // numbering rules are always default
1882 return eRet;
1885 beans::PropertyState SAL_CALL ScCellRangesBase::getPropertyState( const rtl::OUString& aPropertyName )
1886 throw(beans::UnknownPropertyException, uno::RuntimeException)
1888 ScUnoGuard aGuard;
1889 if ( aRanges.Count() == 0 )
1890 throw uno::RuntimeException();
1892 const SfxItemPropertyMap* pMap = GetItemPropertyMap(); // from derived class
1893 USHORT nItemWhich = 0;
1894 const SfxItemPropertySimpleEntry* pEntry = pMap->getByName( aPropertyName );
1895 lcl_GetPropertyWhich( pEntry, nItemWhich );
1896 return GetOnePropertyState( nItemWhich, pEntry );
1899 uno::Sequence<beans::PropertyState> SAL_CALL ScCellRangesBase::getPropertyStates(
1900 const uno::Sequence<rtl::OUString>& aPropertyNames )
1901 throw(beans::UnknownPropertyException, uno::RuntimeException)
1903 ScUnoGuard aGuard;
1905 const SfxItemPropertyMap* pPropertyMap = GetItemPropertyMap(); // from derived class
1907 uno::Sequence<beans::PropertyState> aRet(aPropertyNames.getLength());
1908 beans::PropertyState* pStates = aRet.getArray();
1909 for(INT32 i = 0; i < aPropertyNames.getLength(); i++)
1911 USHORT nItemWhich = 0;
1912 const SfxItemPropertySimpleEntry* pEntry = pPropertyMap->getByName( aPropertyNames[i] );
1913 lcl_GetPropertyWhich( pEntry, nItemWhich );
1914 pStates[i] = GetOnePropertyState(nItemWhich, pEntry);
1916 return aRet;
1919 void SAL_CALL ScCellRangesBase::setPropertyToDefault( const rtl::OUString& aPropertyName )
1920 throw(beans::UnknownPropertyException, uno::RuntimeException)
1922 ScUnoGuard aGuard;
1923 if ( pDocShell )
1925 const SfxItemPropertyMap* pPropertyMap = GetItemPropertyMap(); // from derived class
1926 USHORT nItemWhich = 0;
1927 const SfxItemPropertySimpleEntry* pEntry = pPropertyMap->getByName( aPropertyName );
1928 lcl_GetPropertyWhich( pEntry, nItemWhich );
1929 if ( nItemWhich ) // item wid (from map or special case)
1931 if ( aRanges.Count() ) // leer = nichts zu tun
1933 ScDocFunc aFunc(*pDocShell);
1935 //! Bei Items, die mehrere Properties enthalten (z.B. Hintergrund)
1936 //! wird hier zuviel zurueckgesetzt
1938 // //! for ATTR_ROTATE_VALUE, also reset ATTR_ORIENTATION?
1940 USHORT aWIDs[3];
1941 aWIDs[0] = nItemWhich;
1942 if ( nItemWhich == ATTR_VALUE_FORMAT )
1944 aWIDs[1] = ATTR_LANGUAGE_FORMAT; // #67847# language for number formats
1945 aWIDs[2] = 0;
1947 else
1948 aWIDs[1] = 0;
1949 aFunc.ClearItems( *GetMarkData(), aWIDs, TRUE );
1952 else if ( pEntry )
1954 if ( pEntry->nWID == SC_WID_UNO_CHCOLHDR )
1955 bChartColAsHdr = FALSE;
1956 else if ( pEntry->nWID == SC_WID_UNO_CHROWHDR )
1957 bChartRowAsHdr = FALSE;
1958 else if ( pEntry->nWID == SC_WID_UNO_CELLSTYL )
1960 ScDocFunc aFunc(*pDocShell);
1961 aFunc.ApplyStyle( *GetMarkData(), ScGlobal::GetRscString(STR_STYLENAME_STANDARD), TRUE, TRUE );
1967 uno::Any SAL_CALL ScCellRangesBase::getPropertyDefault( const rtl::OUString& aPropertyName )
1968 throw(beans::UnknownPropertyException, lang::WrappedTargetException,
1969 uno::RuntimeException)
1971 //! mit getPropertyValue zusammenfassen
1973 ScUnoGuard aGuard;
1974 uno::Any aAny;
1976 if ( pDocShell )
1978 ScDocument* pDoc = pDocShell->GetDocument();
1979 const SfxItemPropertyMap* pPropertyMap = GetItemPropertyMap(); // from derived class
1980 const SfxItemPropertySimpleEntry* pEntry = pPropertyMap->getByName( aPropertyName );
1981 if ( pEntry )
1983 if ( IsScItemWid( pEntry->nWID ) )
1985 const ScPatternAttr* pPattern = pDoc->GetDefPattern();
1986 if ( pPattern )
1988 const SfxItemSet& rSet = pPattern->GetItemSet();
1990 switch ( pEntry->nWID ) // fuer Item-Spezial-Behandlungen
1992 case ATTR_VALUE_FORMAT:
1993 // default has no language set
1994 aAny <<= (sal_Int32)( ((const SfxUInt32Item&)rSet.Get(pEntry->nWID)).GetValue() );
1995 break;
1996 case ATTR_INDENT:
1997 aAny <<= (sal_Int16)( TwipsToHMM(((const SfxUInt16Item&)
1998 rSet.Get(pEntry->nWID)).GetValue()) );
1999 break;
2000 default:
2001 pPropSet->getPropertyValue(aPropertyName, rSet, aAny);
2005 else
2006 switch ( pEntry->nWID )
2008 case SC_WID_UNO_CHCOLHDR:
2009 case SC_WID_UNO_CHROWHDR:
2010 ScUnoHelpFunctions::SetBoolInAny( aAny, FALSE );
2011 break;
2012 case SC_WID_UNO_CELLSTYL:
2013 aAny <<= rtl::OUString( ScStyleNameConversion::DisplayToProgrammaticName(
2014 ScGlobal::GetRscString(STR_STYLENAME_STANDARD), SFX_STYLE_FAMILY_PARA ) );
2015 break;
2016 case SC_WID_UNO_TBLBORD:
2018 const ScPatternAttr* pPattern = pDoc->GetDefPattern();
2019 if ( pPattern )
2021 table::TableBorder aBorder;
2022 ScHelperFunctions::FillTableBorder( aBorder,
2023 (const SvxBoxItem&)pPattern->GetItem(ATTR_BORDER),
2024 (const SvxBoxInfoItem&)pPattern->GetItem(ATTR_BORDER_INNER) );
2025 aAny <<= aBorder;
2028 break;
2029 case SC_WID_UNO_CONDFMT:
2030 case SC_WID_UNO_CONDLOC:
2031 case SC_WID_UNO_CONDXML:
2033 BOOL bEnglish = ( pEntry->nWID != SC_WID_UNO_CONDLOC );
2034 BOOL bXML = ( pEntry->nWID == SC_WID_UNO_CONDXML );
2035 formula::FormulaGrammar::Grammar eGrammar = (bXML ?
2036 pDoc->GetStorageGrammar() :
2037 formula::FormulaGrammar::mapAPItoGrammar( bEnglish, bXML));
2039 aAny <<= uno::Reference<sheet::XSheetConditionalEntries>(
2040 new ScTableConditionalFormat( pDoc, 0, eGrammar ));
2042 break;
2043 case SC_WID_UNO_VALIDAT:
2044 case SC_WID_UNO_VALILOC:
2045 case SC_WID_UNO_VALIXML:
2047 BOOL bEnglish = ( pEntry->nWID != SC_WID_UNO_VALILOC );
2048 BOOL bXML = ( pEntry->nWID == SC_WID_UNO_VALIXML );
2049 formula::FormulaGrammar::Grammar eGrammar = (bXML ?
2050 pDoc->GetStorageGrammar() :
2051 formula::FormulaGrammar::mapAPItoGrammar( bEnglish, bXML));
2053 aAny <<= uno::Reference<beans::XPropertySet>(
2054 new ScTableValidationObj( pDoc, 0, eGrammar ));
2056 break;
2057 case SC_WID_UNO_NUMRULES:
2059 aAny <<= uno::Reference<container::XIndexReplace>(ScStyleObj::CreateEmptyNumberingRules());
2061 break;
2066 return aAny;
2069 // XPropertySet
2071 uno::Reference<beans::XPropertySetInfo> SAL_CALL ScCellRangesBase::getPropertySetInfo()
2072 throw(uno::RuntimeException)
2074 ScUnoGuard aGuard;
2075 static uno::Reference<beans::XPropertySetInfo> aRef(
2076 new SfxItemPropertySetInfo( pPropSet->getPropertyMap() ));
2077 return aRef;
2081 void lcl_SetCellProperty( const SfxItemPropertySimpleEntry& rEntry, const uno::Any& rValue,
2082 ScPatternAttr& rPattern, ScDocument* pDoc,
2083 USHORT& rFirstItemId, USHORT& rSecondItemId )
2085 rFirstItemId = rEntry.nWID;
2086 rSecondItemId = 0;
2088 SfxItemSet& rSet = rPattern.GetItemSet();
2089 switch ( rEntry.nWID )
2091 case ATTR_VALUE_FORMAT:
2093 // #67847# language for number formats
2094 SvNumberFormatter* pFormatter = pDoc->GetFormatTable();
2095 ULONG nOldFormat = ((const SfxUInt32Item&)rSet.Get( ATTR_VALUE_FORMAT )).GetValue();
2096 LanguageType eOldLang = ((const SvxLanguageItem&)rSet.Get( ATTR_LANGUAGE_FORMAT )).GetLanguage();
2097 nOldFormat = pFormatter->GetFormatForLanguageIfBuiltIn( nOldFormat, eOldLang );
2099 sal_Int32 nIntVal = 0;
2100 if ( rValue >>= nIntVal )
2102 ULONG nNewFormat = (ULONG)nIntVal;
2103 rSet.Put( SfxUInt32Item( ATTR_VALUE_FORMAT, nNewFormat ) );
2105 const SvNumberformat* pNewEntry = pFormatter->GetEntry( nNewFormat );
2106 LanguageType eNewLang =
2107 pNewEntry ? pNewEntry->GetLanguage() : LANGUAGE_DONTKNOW;
2108 if ( eNewLang != eOldLang && eNewLang != LANGUAGE_DONTKNOW )
2110 rSet.Put( SvxLanguageItem( eNewLang, ATTR_LANGUAGE_FORMAT ) );
2112 // #40606# if only language is changed,
2113 // don't touch number format attribute
2114 ULONG nNewMod = nNewFormat % SV_COUNTRY_LANGUAGE_OFFSET;
2115 if ( nNewMod == ( nOldFormat % SV_COUNTRY_LANGUAGE_OFFSET ) &&
2116 nNewMod <= SV_MAX_ANZ_STANDARD_FORMATE )
2118 rFirstItemId = 0; // don't use ATTR_VALUE_FORMAT value
2121 rSecondItemId = ATTR_LANGUAGE_FORMAT;
2124 else
2125 throw lang::IllegalArgumentException();
2127 break;
2128 case ATTR_INDENT:
2130 sal_Int16 nIntVal = 0;
2131 if ( rValue >>= nIntVal )
2132 rSet.Put( SfxUInt16Item( rEntry.nWID, (USHORT)HMMToTwips(nIntVal) ) );
2133 else
2134 throw lang::IllegalArgumentException();
2136 break;
2137 case ATTR_ROTATE_VALUE:
2139 sal_Int32 nRotVal = 0;
2140 if ( rValue >>= nRotVal )
2142 // stored value is always between 0 and 360 deg.
2143 nRotVal %= 36000;
2144 if ( nRotVal < 0 )
2145 nRotVal += 36000;
2147 rSet.Put( SfxInt32Item( ATTR_ROTATE_VALUE, nRotVal ) );
2149 else
2150 throw lang::IllegalArgumentException();
2152 break;
2153 case ATTR_STACKED:
2155 table::CellOrientation eOrient;
2156 if( rValue >>= eOrient )
2158 switch( eOrient )
2160 case table::CellOrientation_STANDARD:
2161 rSet.Put( SfxBoolItem( ATTR_STACKED, FALSE ) );
2162 break;
2163 case table::CellOrientation_TOPBOTTOM:
2164 rSet.Put( SfxBoolItem( ATTR_STACKED, FALSE ) );
2165 rSet.Put( SfxInt32Item( ATTR_ROTATE_VALUE, 27000 ) );
2166 rSecondItemId = ATTR_ROTATE_VALUE;
2167 break;
2168 case table::CellOrientation_BOTTOMTOP:
2169 rSet.Put( SfxBoolItem( ATTR_STACKED, FALSE ) );
2170 rSet.Put( SfxInt32Item( ATTR_ROTATE_VALUE, 9000 ) );
2171 rSecondItemId = ATTR_ROTATE_VALUE;
2172 break;
2173 case table::CellOrientation_STACKED:
2174 rSet.Put( SfxBoolItem( ATTR_STACKED, TRUE ) );
2175 break;
2176 default:
2178 // added to avoid warnings
2183 break;
2184 default:
2186 lcl_GetCellsPropertySet()->setPropertyValue(rEntry, rValue, rSet);
2191 void SAL_CALL ScCellRangesBase::setPropertyValue(
2192 const rtl::OUString& aPropertyName, const uno::Any& aValue )
2193 throw(beans::UnknownPropertyException, beans::PropertyVetoException,
2194 lang::IllegalArgumentException, lang::WrappedTargetException,
2195 uno::RuntimeException)
2197 ScUnoGuard aGuard;
2199 if ( !pDocShell || aRanges.Count() == 0 )
2200 throw uno::RuntimeException();
2202 const SfxItemPropertyMap* pPropertyMap = GetItemPropertyMap(); // from derived class
2203 const SfxItemPropertySimpleEntry* pEntry = pPropertyMap->getByName( aPropertyName );
2204 if ( !pEntry )
2205 throw beans::UnknownPropertyException();
2207 SetOnePropertyValue( pEntry, aValue );
2210 void ScCellRangesBase::SetOnePropertyValue( const SfxItemPropertySimpleEntry* pEntry, const uno::Any& aValue )
2211 throw(lang::IllegalArgumentException, uno::RuntimeException)
2213 if ( pEntry )
2215 if ( IsScItemWid( pEntry->nWID ) )
2217 if ( aRanges.Count() ) // leer = nichts zu tun
2219 ScDocument* pDoc = pDocShell->GetDocument();
2220 ScDocFunc aFunc(*pDocShell);
2222 // Fuer Teile von zusammengesetzten Items mit mehreren Properties (z.B. Hintergrund)
2223 // muss vorher das alte Item aus dem Dokument geholt werden
2224 //! Das kann hier aber nicht erkannt werden
2225 //! -> eigenes Flag im PropertyMap-Eintrag, oder was ???
2226 //! Item direkt von einzelner Position im Bereich holen?
2227 // ClearInvalidItems, damit auf jeden Fall ein Item vom richtigen Typ da ist
2229 ScPatternAttr aPattern( *GetCurrentAttrsDeep() );
2230 SfxItemSet& rSet = aPattern.GetItemSet();
2231 rSet.ClearInvalidItems();
2233 USHORT nFirstItem, nSecondItem;
2234 lcl_SetCellProperty( *pEntry, aValue, aPattern, pDoc, nFirstItem, nSecondItem );
2236 for (USHORT nWhich = ATTR_PATTERN_START; nWhich <= ATTR_PATTERN_END; nWhich++)
2237 if ( nWhich != nFirstItem && nWhich != nSecondItem )
2238 rSet.ClearItem(nWhich);
2240 aFunc.ApplyAttributes( *GetMarkData(), aPattern, TRUE, TRUE );
2243 else // implemented here
2244 switch ( pEntry->nWID )
2246 case SC_WID_UNO_CHCOLHDR:
2247 // chart header flags are set for this object, not stored with document
2248 bChartColAsHdr = ScUnoHelpFunctions::GetBoolFromAny( aValue );
2249 break;
2250 case SC_WID_UNO_CHROWHDR:
2251 bChartRowAsHdr = ScUnoHelpFunctions::GetBoolFromAny( aValue );
2252 break;
2253 case SC_WID_UNO_CELLSTYL:
2255 rtl::OUString aStrVal;
2256 aValue >>= aStrVal;
2257 String aString(ScStyleNameConversion::ProgrammaticToDisplayName(
2258 aStrVal, SFX_STYLE_FAMILY_PARA ));
2259 ScDocFunc aFunc(*pDocShell);
2260 aFunc.ApplyStyle( *GetMarkData(), aString, TRUE, TRUE );
2262 break;
2263 case SC_WID_UNO_TBLBORD:
2265 table::TableBorder aBorder;
2266 if ( aRanges.Count() && ( aValue >>= aBorder ) ) // empty = nothing to do
2268 SvxBoxItem aOuter(ATTR_BORDER);
2269 SvxBoxInfoItem aInner(ATTR_BORDER_INNER);
2270 ScHelperFunctions::FillBoxItems( aOuter, aInner, aBorder );
2272 ScHelperFunctions::ApplyBorder( pDocShell, aRanges, aOuter, aInner ); //! docfunc
2275 break;
2276 case SC_WID_UNO_CONDFMT:
2277 case SC_WID_UNO_CONDLOC:
2278 case SC_WID_UNO_CONDXML:
2280 uno::Reference<sheet::XSheetConditionalEntries> xInterface(aValue, uno::UNO_QUERY);
2281 if ( aRanges.Count() && xInterface.is() ) // leer = nichts zu tun
2283 ScTableConditionalFormat* pFormat =
2284 ScTableConditionalFormat::getImplementation( xInterface );
2285 if (pFormat)
2287 ScDocument* pDoc = pDocShell->GetDocument();
2288 BOOL bEnglish = ( pEntry->nWID != SC_WID_UNO_CONDLOC );
2289 BOOL bXML = ( pEntry->nWID == SC_WID_UNO_CONDXML );
2290 formula::FormulaGrammar::Grammar eGrammar = (bXML ?
2291 formula::FormulaGrammar::GRAM_UNSPECIFIED :
2292 formula::FormulaGrammar::mapAPItoGrammar( bEnglish, bXML));
2294 ScConditionalFormat aNew( 0, pDoc ); // Index wird beim Einfuegen gesetzt
2295 pFormat->FillFormat( aNew, pDoc, eGrammar );
2296 ULONG nIndex = pDoc->AddCondFormat( aNew );
2298 ScDocFunc aFunc(*pDocShell);
2300 ScPatternAttr aPattern( pDoc->GetPool() );
2301 aPattern.GetItemSet().Put( SfxUInt32Item( ATTR_CONDITIONAL, nIndex ) );
2302 aFunc.ApplyAttributes( *GetMarkData(), aPattern, TRUE, TRUE );
2306 break;
2307 case SC_WID_UNO_VALIDAT:
2308 case SC_WID_UNO_VALILOC:
2309 case SC_WID_UNO_VALIXML:
2311 uno::Reference<beans::XPropertySet> xInterface(aValue, uno::UNO_QUERY);
2312 if ( aRanges.Count() && xInterface.is() ) // leer = nichts zu tun
2314 ScTableValidationObj* pValidObj =
2315 ScTableValidationObj::getImplementation( xInterface );
2316 if (pValidObj)
2318 ScDocument* pDoc = pDocShell->GetDocument();
2319 BOOL bEnglish = ( pEntry->nWID != SC_WID_UNO_VALILOC );
2320 BOOL bXML = ( pEntry->nWID == SC_WID_UNO_VALIXML );
2321 formula::FormulaGrammar::Grammar eGrammar = (bXML ?
2322 formula::FormulaGrammar::GRAM_UNSPECIFIED :
2323 formula::FormulaGrammar::mapAPItoGrammar( bEnglish, bXML));
2325 ScValidationData* pNewData =
2326 pValidObj->CreateValidationData( pDoc, eGrammar );
2327 ULONG nIndex = pDoc->AddValidationEntry( *pNewData );
2328 delete pNewData;
2330 ScDocFunc aFunc(*pDocShell);
2332 ScPatternAttr aPattern( pDoc->GetPool() );
2333 aPattern.GetItemSet().Put( SfxUInt32Item( ATTR_VALIDDATA, nIndex ) );
2334 aFunc.ApplyAttributes( *GetMarkData(), aPattern, TRUE, TRUE );
2338 break;
2339 // SC_WID_UNO_NUMRULES is ignored...
2344 uno::Any SAL_CALL ScCellRangesBase::getPropertyValue( const rtl::OUString& aPropertyName )
2345 throw(beans::UnknownPropertyException, lang::WrappedTargetException,
2346 uno::RuntimeException)
2348 ScUnoGuard aGuard;
2350 if ( !pDocShell || aRanges.Count() == 0 )
2351 throw uno::RuntimeException();
2353 const SfxItemPropertyMap* pPropertyMap = GetItemPropertyMap(); // from derived class
2354 const SfxItemPropertySimpleEntry* pEntry = pPropertyMap->getByName( aPropertyName );
2355 if ( !pEntry )
2356 throw beans::UnknownPropertyException();
2358 uno::Any aAny;
2359 GetOnePropertyValue( pEntry, aAny );
2360 return aAny;
2363 void ScCellRangesBase::GetOnePropertyValue( const SfxItemPropertySimpleEntry* pEntry,
2364 uno::Any& rAny )
2365 throw(uno::RuntimeException)
2367 if ( pEntry )
2369 if ( IsScItemWid( pEntry->nWID ) )
2371 SfxItemSet* pDataSet = GetCurrentDataSet();
2372 if ( pDataSet )
2374 switch ( pEntry->nWID ) // fuer Item-Spezial-Behandlungen
2376 case ATTR_VALUE_FORMAT:
2378 ScDocument* pDoc = pDocShell->GetDocument();
2380 ULONG nOldFormat = ((const SfxUInt32Item&)
2381 pDataSet->Get( ATTR_VALUE_FORMAT )).GetValue();
2382 LanguageType eOldLang = ((const SvxLanguageItem&)
2383 pDataSet->Get( ATTR_LANGUAGE_FORMAT )).GetLanguage();
2384 nOldFormat = pDoc->GetFormatTable()->
2385 GetFormatForLanguageIfBuiltIn( nOldFormat, eOldLang );
2386 rAny <<= (sal_Int32)( nOldFormat );
2388 break;
2389 case ATTR_INDENT:
2390 rAny <<= (sal_Int16)( TwipsToHMM(((const SfxUInt16Item&)
2391 pDataSet->Get(pEntry->nWID)).GetValue()) );
2392 break;
2393 case ATTR_STACKED:
2395 sal_Int32 nRot = ((const SfxInt32Item&)pDataSet->Get(ATTR_ROTATE_VALUE)).GetValue();
2396 BOOL bStacked = ((const SfxBoolItem&)pDataSet->Get(pEntry->nWID)).GetValue();
2397 SvxOrientationItem( nRot, bStacked, 0 ).QueryValue( rAny );
2399 break;
2400 default:
2401 pPropSet->getPropertyValue(*pEntry, *pDataSet, rAny);
2405 else // implemented here
2406 switch ( pEntry->nWID )
2408 case SC_WID_UNO_CHCOLHDR:
2409 ScUnoHelpFunctions::SetBoolInAny( rAny, bChartColAsHdr );
2410 break;
2411 case SC_WID_UNO_CHROWHDR:
2412 ScUnoHelpFunctions::SetBoolInAny( rAny, bChartRowAsHdr );
2413 break;
2414 case SC_WID_UNO_CELLSTYL:
2416 String aStyleName;
2417 const ScStyleSheet* pStyle = pDocShell->GetDocument()->GetSelectionStyle(*GetMarkData());
2418 if (pStyle)
2419 aStyleName = pStyle->GetName();
2420 rAny <<= rtl::OUString( ScStyleNameConversion::DisplayToProgrammaticName(
2421 aStyleName, SFX_STYLE_FAMILY_PARA ) );
2423 break;
2424 case SC_WID_UNO_TBLBORD:
2426 //! loop throgh all ranges
2427 const ScRange* pFirst = aRanges.GetObject(0);
2428 if (pFirst)
2430 SvxBoxItem aOuter(ATTR_BORDER);
2431 SvxBoxInfoItem aInner(ATTR_BORDER_INNER);
2433 ScDocument* pDoc = pDocShell->GetDocument();
2434 ScMarkData aMark;
2435 aMark.SetMarkArea( *pFirst );
2436 aMark.SelectTable( pFirst->aStart.Tab(), TRUE );
2437 pDoc->GetSelectionFrame( aMark, aOuter, aInner );
2439 table::TableBorder aBorder;
2440 ScHelperFunctions::FillTableBorder( aBorder, aOuter, aInner );
2441 rAny <<= aBorder;
2444 break;
2445 case SC_WID_UNO_CONDFMT:
2446 case SC_WID_UNO_CONDLOC:
2447 case SC_WID_UNO_CONDXML:
2449 const ScPatternAttr* pPattern = GetCurrentAttrsDeep();
2450 if ( pPattern )
2452 ScDocument* pDoc = pDocShell->GetDocument();
2453 BOOL bEnglish = ( pEntry->nWID != SC_WID_UNO_CONDLOC );
2454 BOOL bXML = ( pEntry->nWID == SC_WID_UNO_CONDXML );
2455 formula::FormulaGrammar::Grammar eGrammar = (bXML ?
2456 pDoc->GetStorageGrammar() :
2457 formula::FormulaGrammar::mapAPItoGrammar( bEnglish, bXML));
2458 ULONG nIndex = ((const SfxUInt32Item&)
2459 pPattern->GetItem(ATTR_CONDITIONAL)).GetValue();
2460 rAny <<= uno::Reference<sheet::XSheetConditionalEntries>(
2461 new ScTableConditionalFormat( pDoc, nIndex, eGrammar ));
2464 break;
2465 case SC_WID_UNO_VALIDAT:
2466 case SC_WID_UNO_VALILOC:
2467 case SC_WID_UNO_VALIXML:
2469 const ScPatternAttr* pPattern = GetCurrentAttrsDeep();
2470 if ( pPattern )
2472 ScDocument* pDoc = pDocShell->GetDocument();
2473 BOOL bEnglish = ( pEntry->nWID != SC_WID_UNO_VALILOC );
2474 BOOL bXML = ( pEntry->nWID == SC_WID_UNO_VALIXML );
2475 formula::FormulaGrammar::Grammar eGrammar = (bXML ?
2476 pDoc->GetStorageGrammar() :
2477 formula::FormulaGrammar::mapAPItoGrammar( bEnglish, bXML));
2478 ULONG nIndex = ((const SfxUInt32Item&)
2479 pPattern->GetItem(ATTR_VALIDDATA)).GetValue();
2480 rAny <<= uno::Reference<beans::XPropertySet>(
2481 new ScTableValidationObj( pDoc, nIndex, eGrammar ));
2484 break;
2485 case SC_WID_UNO_NUMRULES:
2487 // always return empty numbering rules object
2488 rAny <<= uno::Reference<container::XIndexReplace>(ScStyleObj::CreateEmptyNumberingRules());
2490 break;
2491 case SC_WID_UNO_ABSNAME:
2493 String sRet;
2494 aRanges.Format(sRet, SCR_ABS_3D, pDocShell->GetDocument());
2495 rAny <<= rtl::OUString(sRet);
2501 void SAL_CALL ScCellRangesBase::addPropertyChangeListener( const rtl::OUString& /* aPropertyName */,
2502 const uno::Reference<beans::XPropertyChangeListener>& /* aListener */)
2503 throw(beans::UnknownPropertyException,
2504 lang::WrappedTargetException, uno::RuntimeException)
2506 ScUnoGuard aGuard;
2507 if ( aRanges.Count() == 0 )
2508 throw uno::RuntimeException();
2510 DBG_ERROR("not implemented");
2513 void SAL_CALL ScCellRangesBase::removePropertyChangeListener( const rtl::OUString& /* aPropertyName */,
2514 const uno::Reference<beans::XPropertyChangeListener>& /* aListener */)
2515 throw(beans::UnknownPropertyException,
2516 lang::WrappedTargetException, uno::RuntimeException)
2518 ScUnoGuard aGuard;
2519 if ( aRanges.Count() == 0 )
2520 throw uno::RuntimeException();
2522 DBG_ERROR("not implemented");
2525 void SAL_CALL ScCellRangesBase::addVetoableChangeListener( const rtl::OUString&,
2526 const uno::Reference<beans::XVetoableChangeListener>&)
2527 throw(beans::UnknownPropertyException,
2528 lang::WrappedTargetException, uno::RuntimeException)
2530 DBG_ERROR("not implemented");
2533 void SAL_CALL ScCellRangesBase::removeVetoableChangeListener( const rtl::OUString&,
2534 const uno::Reference<beans::XVetoableChangeListener>&)
2535 throw(beans::UnknownPropertyException,
2536 lang::WrappedTargetException, uno::RuntimeException)
2538 DBG_ERROR("not implemented");
2541 // XMultiPropertySet
2543 void SAL_CALL ScCellRangesBase::setPropertyValues( const uno::Sequence< rtl::OUString >& aPropertyNames,
2544 const uno::Sequence< uno::Any >& aValues )
2545 throw (beans::PropertyVetoException,
2546 lang::IllegalArgumentException,
2547 lang::WrappedTargetException,
2548 uno::RuntimeException)
2550 ScUnoGuard aGuard;
2552 sal_Int32 nCount(aPropertyNames.getLength());
2553 sal_Int32 nValues(aValues.getLength());
2554 if (nCount != nValues)
2555 throw lang::IllegalArgumentException();
2557 if ( pDocShell && nCount )
2559 const SfxItemPropertyMap* pPropertyMap = GetItemPropertyMap(); // from derived class
2560 const rtl::OUString* pNames = aPropertyNames.getConstArray();
2561 const uno::Any* pValues = aValues.getConstArray();
2563 const SfxItemPropertySimpleEntry** pEntryArray = new const SfxItemPropertySimpleEntry*[nCount];
2565 sal_Int32 i;
2566 for(i = 0; i < nCount; i++)
2568 // first loop: find all properties in map, but handle only CellStyle
2569 // (CellStyle must be set before any other cell properties)
2571 const SfxItemPropertySimpleEntry* pEntry = pPropertyMap->getByName( pNames[i] );
2572 pEntryArray[i] = pEntry;
2573 if (pEntry)
2575 if ( pEntry->nWID == SC_WID_UNO_CELLSTYL )
2579 SetOnePropertyValue( pEntry, pValues[i] );
2581 catch ( lang::IllegalArgumentException& )
2583 DBG_ERROR("exception when setting cell style"); // not supposed to happen
2589 ScDocument* pDoc = pDocShell->GetDocument();
2590 ScPatternAttr* pOldPattern = NULL;
2591 ScPatternAttr* pNewPattern = NULL;
2593 for(i = 0; i < nCount; i++)
2595 // second loop: handle other properties
2597 const SfxItemPropertySimpleEntry* pEntry = pEntryArray[i];
2598 if ( pEntry )
2600 if ( IsScItemWid( pEntry->nWID ) ) // can be handled by SfxItemPropertySet
2602 if ( !pOldPattern )
2604 pOldPattern = new ScPatternAttr( *GetCurrentAttrsDeep() );
2605 pOldPattern->GetItemSet().ClearInvalidItems();
2606 pNewPattern = new ScPatternAttr( pDoc->GetPool() );
2609 // collect items in pNewPattern, apply with one call after the loop
2611 USHORT nFirstItem, nSecondItem;
2612 lcl_SetCellProperty( *pEntry, pValues[i], *pOldPattern, pDoc, nFirstItem, nSecondItem );
2614 // put only affected items into new set
2615 if ( nFirstItem )
2616 pNewPattern->GetItemSet().Put( pOldPattern->GetItemSet().Get( nFirstItem ) );
2617 if ( nSecondItem )
2618 pNewPattern->GetItemSet().Put( pOldPattern->GetItemSet().Get( nSecondItem ) );
2620 else if ( pEntry->nWID != SC_WID_UNO_CELLSTYL ) // CellStyle is handled above
2622 // call virtual method to set a single property
2623 SetOnePropertyValue( pEntry, pValues[i] );
2628 if ( pNewPattern && aRanges.Count() )
2630 ScDocFunc aFunc(*pDocShell);
2631 aFunc.ApplyAttributes( *GetMarkData(), *pNewPattern, TRUE, TRUE );
2634 delete pNewPattern;
2635 delete pOldPattern;
2636 delete[] pEntryArray;
2640 uno::Sequence<uno::Any> SAL_CALL ScCellRangesBase::getPropertyValues(
2641 const uno::Sequence< rtl::OUString >& aPropertyNames )
2642 throw (uno::RuntimeException)
2644 ScUnoGuard aGuard;
2646 const SfxItemPropertyMap* pPropertyMap = GetItemPropertyMap(); // from derived class
2648 uno::Sequence<uno::Any> aRet(aPropertyNames.getLength());
2649 uno::Any* pProperties = aRet.getArray();
2650 for(INT32 i = 0; i < aPropertyNames.getLength(); i++)
2652 const SfxItemPropertySimpleEntry* pEntry = pPropertyMap->getByName( aPropertyNames[i] );
2653 GetOnePropertyValue( pEntry, pProperties[i] );
2655 return aRet;
2658 void SAL_CALL ScCellRangesBase::addPropertiesChangeListener( const uno::Sequence< rtl::OUString >& /* aPropertyNames */,
2659 const uno::Reference< beans::XPropertiesChangeListener >& /* xListener */ )
2660 throw (uno::RuntimeException)
2662 DBG_ERROR("not implemented");
2665 void SAL_CALL ScCellRangesBase::removePropertiesChangeListener( const uno::Reference< beans::XPropertiesChangeListener >& /* xListener */ )
2666 throw (uno::RuntimeException)
2668 DBG_ERROR("not implemented");
2671 void SAL_CALL ScCellRangesBase::firePropertiesChangeEvent( const uno::Sequence< rtl::OUString >& /* aPropertyNames */,
2672 const uno::Reference< beans::XPropertiesChangeListener >& /* xListener */ )
2673 throw (uno::RuntimeException)
2675 DBG_ERROR("not implemented");
2678 IMPL_LINK( ScCellRangesBase, ValueListenerHdl, SfxHint*, pHint )
2680 if ( pDocShell && pHint && pHint->ISA( SfxSimpleHint ) &&
2681 ((const SfxSimpleHint*)pHint)->GetId() & (SC_HINT_DATACHANGED | SC_HINT_DYING) )
2683 // This may be called several times for a single change, if several formulas
2684 // in the range are notified. So only a flag is set that is checked when
2685 // SFX_HINT_DATACHANGED is received.
2687 bGotDataChangedHint = TRUE;
2689 return 0;
2692 // XTolerantMultiPropertySet
2693 uno::Sequence< beans::SetPropertyTolerantFailed > SAL_CALL ScCellRangesBase::setPropertyValuesTolerant( const uno::Sequence< ::rtl::OUString >& aPropertyNames,
2694 const uno::Sequence< uno::Any >& aValues )
2695 throw (lang::IllegalArgumentException, uno::RuntimeException)
2697 ScUnoGuard aGuard;
2699 sal_Int32 nCount(aPropertyNames.getLength());
2700 sal_Int32 nValues(aValues.getLength());
2701 if (nCount != nValues)
2702 throw lang::IllegalArgumentException();
2704 if ( pDocShell && nCount )
2706 uno::Sequence < beans::SetPropertyTolerantFailed > aReturns(nCount);
2707 beans::SetPropertyTolerantFailed* pReturns = aReturns.getArray();
2709 const SfxItemPropertyMap* pPropertyMap = GetItemPropertyMap(); // from derived class
2710 const rtl::OUString* pNames = aPropertyNames.getConstArray();
2711 const uno::Any* pValues = aValues.getConstArray();
2713 const SfxItemPropertySimpleEntry** pMapArray = new const SfxItemPropertySimpleEntry*[nCount];
2715 sal_Int32 i;
2716 for(i = 0; i < nCount; i++)
2718 // first loop: find all properties in map, but handle only CellStyle
2719 // (CellStyle must be set before any other cell properties)
2721 const SfxItemPropertySimpleEntry* pEntry = pPropertyMap->getByName( pNames[i] );
2722 pMapArray[i] = pEntry;
2723 if (pEntry)
2725 if ( pEntry->nWID == SC_WID_UNO_CELLSTYL )
2729 SetOnePropertyValue( pEntry, pValues[i] );
2731 catch ( lang::IllegalArgumentException& )
2733 DBG_ERROR("exception when setting cell style"); // not supposed to happen
2739 ScDocument* pDoc = pDocShell->GetDocument();
2740 ScPatternAttr* pOldPattern = NULL;
2741 ScPatternAttr* pNewPattern = NULL;
2743 sal_Int32 nFailed(0);
2744 for(i = 0; i < nCount; i++)
2746 // second loop: handle other properties
2748 const SfxItemPropertySimpleEntry* pEntry = pMapArray[i];
2749 if ( pEntry && ((pEntry->nFlags & beans::PropertyAttribute::READONLY) == 0))
2751 if ( IsScItemWid( pEntry->nWID ) ) // can be handled by SfxItemPropertySet
2753 if ( !pOldPattern )
2755 pOldPattern = new ScPatternAttr( *GetCurrentAttrsDeep() );
2756 pOldPattern->GetItemSet().ClearInvalidItems();
2757 pNewPattern = new ScPatternAttr( pDoc->GetPool() );
2760 // collect items in pNewPattern, apply with one call after the loop
2762 USHORT nFirstItem, nSecondItem;
2765 lcl_SetCellProperty( *pEntry, pValues[i], *pOldPattern, pDoc, nFirstItem, nSecondItem );
2767 // put only affected items into new set
2768 if ( nFirstItem )
2769 pNewPattern->GetItemSet().Put( pOldPattern->GetItemSet().Get( nFirstItem ) );
2770 if ( nSecondItem )
2771 pNewPattern->GetItemSet().Put( pOldPattern->GetItemSet().Get( nSecondItem ) );
2773 catch ( lang::IllegalArgumentException& )
2775 pReturns[nFailed].Name = pNames[i];
2776 pReturns[nFailed++].Result = beans::TolerantPropertySetResultType::ILLEGAL_ARGUMENT;
2779 else if ( pEntry->nWID != SC_WID_UNO_CELLSTYL ) // CellStyle is handled above
2781 // call virtual method to set a single property
2784 SetOnePropertyValue( pEntry, pValues[i] );
2786 catch ( lang::IllegalArgumentException& )
2788 pReturns[nFailed].Name = pNames[i];
2789 pReturns[nFailed++].Result = beans::TolerantPropertySetResultType::ILLEGAL_ARGUMENT;
2793 else
2795 pReturns[nFailed].Name = pNames[i];
2796 if (pEntry)
2797 pReturns[nFailed++].Result = beans::TolerantPropertySetResultType::PROPERTY_VETO;
2798 else
2799 pReturns[nFailed++].Result = beans::TolerantPropertySetResultType::UNKNOWN_PROPERTY;
2803 if ( pNewPattern && aRanges.Count() )
2805 ScDocFunc aFunc(*pDocShell);
2806 aFunc.ApplyAttributes( *GetMarkData(), *pNewPattern, TRUE, TRUE );
2809 delete pNewPattern;
2810 delete pOldPattern;
2811 delete[] pMapArray;
2813 aReturns.realloc(nFailed);
2815 return aReturns;
2817 return uno::Sequence < beans::SetPropertyTolerantFailed >();
2820 uno::Sequence< beans::GetPropertyTolerantResult > SAL_CALL ScCellRangesBase::getPropertyValuesTolerant( const uno::Sequence< ::rtl::OUString >& aPropertyNames )
2821 throw (uno::RuntimeException)
2823 ScUnoGuard aGuard;
2825 sal_Int32 nCount(aPropertyNames.getLength());
2826 uno::Sequence < beans::GetPropertyTolerantResult > aReturns(nCount);
2827 beans::GetPropertyTolerantResult* pReturns = aReturns.getArray();
2829 const SfxItemPropertyMap* pPropertyMap = GetItemPropertyMap(); // from derived class
2831 for(INT32 i = 0; i < nCount; i++)
2833 const SfxItemPropertySimpleEntry* pEntry = pPropertyMap->getByName( aPropertyNames[i] );
2834 if (!pEntry)
2836 pReturns[i].Result = beans::TolerantPropertySetResultType::UNKNOWN_PROPERTY;
2838 else
2840 USHORT nItemWhich = 0;
2841 lcl_GetPropertyWhich( pEntry, nItemWhich );
2842 pReturns[i].State = GetOnePropertyState( nItemWhich, pEntry );
2843 GetOnePropertyValue( pEntry, pReturns[i].Value );
2844 pReturns[i].Result = beans::TolerantPropertySetResultType::SUCCESS;
2847 return aReturns;
2850 uno::Sequence< beans::GetDirectPropertyTolerantResult > SAL_CALL ScCellRangesBase::getDirectPropertyValuesTolerant( const uno::Sequence< ::rtl::OUString >& aPropertyNames )
2851 throw (uno::RuntimeException)
2853 ScUnoGuard aGuard;
2855 sal_Int32 nCount(aPropertyNames.getLength());
2856 uno::Sequence < beans::GetDirectPropertyTolerantResult > aReturns(nCount);
2857 beans::GetDirectPropertyTolerantResult* pReturns = aReturns.getArray();
2859 const SfxItemPropertyMap* pPropertyMap = GetItemPropertyMap(); // from derived class
2861 INT32 j = 0;
2862 for(INT32 i = 0; i < nCount; i++)
2864 const SfxItemPropertySimpleEntry* pEntry = pPropertyMap->getByName( aPropertyNames[i] );
2865 if (!pEntry)
2867 pReturns[i].Result = beans::TolerantPropertySetResultType::UNKNOWN_PROPERTY;
2869 else
2871 USHORT nItemWhich = 0;
2872 lcl_GetPropertyWhich( pEntry, nItemWhich );
2873 pReturns[j].State = GetOnePropertyState( nItemWhich, pEntry );
2874 if (pReturns[j].State == beans::PropertyState_DIRECT_VALUE)
2876 GetOnePropertyValue( pEntry, pReturns[j].Value );
2877 pReturns[j].Result = beans::TolerantPropertySetResultType::SUCCESS;
2878 pReturns[j].Name = aPropertyNames[i];
2879 ++j;
2883 if (j < nCount)
2884 aReturns.realloc(j);
2885 return aReturns;
2888 // XIndent
2890 void SAL_CALL ScCellRangesBase::decrementIndent() throw(::com::sun::star::uno::RuntimeException)
2892 ScUnoGuard aGuard;
2893 if ( pDocShell && aRanges.Count() ) // leer = nichts zu tun
2895 ScDocFunc aFunc(*pDocShell);
2896 //#97041#; put only MultiMarked ScMarkData in ChangeIndent
2897 ScMarkData aMarkData(*GetMarkData());
2898 aMarkData.MarkToMulti();
2899 aFunc.ChangeIndent( aMarkData, FALSE, TRUE );
2903 void SAL_CALL ScCellRangesBase::incrementIndent() throw(::com::sun::star::uno::RuntimeException)
2905 ScUnoGuard aGuard;
2906 if ( pDocShell && aRanges.Count() ) // leer = nichts zu tun
2908 ScDocFunc aFunc(*pDocShell);
2909 //#97041#; put only MultiMarked ScMarkData in ChangeIndent
2910 ScMarkData aMarkData(*GetMarkData());
2911 aMarkData.MarkToMulti();
2912 aFunc.ChangeIndent( aMarkData, TRUE, TRUE );
2916 // XChartData
2918 ScMemChart* ScCellRangesBase::CreateMemChart_Impl() const
2920 if ( pDocShell && aRanges.Count() )
2922 ScRangeListRef xChartRanges;
2923 if ( aRanges.Count() == 1 )
2925 // ganze Tabelle sinnvoll begrenzen (auf belegten Datenbereich)
2926 // (nur hier, Listener werden auf den ganzen Bereich angemeldet)
2927 //! direkt testen, ob es ein ScTableSheetObj ist?
2929 ScRange* pRange = aRanges.GetObject(0);
2930 if ( pRange->aStart.Col() == 0 && pRange->aEnd.Col() == MAXCOL &&
2931 pRange->aStart.Row() == 0 && pRange->aEnd.Row() == MAXROW )
2933 SCTAB nTab = pRange->aStart.Tab();
2935 SCCOL nStartX;
2936 SCROW nStartY; // Anfang holen
2937 if (!pDocShell->GetDocument()->GetDataStart( nTab, nStartX, nStartY ))
2939 nStartX = 0;
2940 nStartY = 0;
2943 SCCOL nEndX;
2944 SCROW nEndY; // Ende holen
2945 if (!pDocShell->GetDocument()->GetTableArea( nTab, nEndX, nEndY ))
2947 nEndX = 0;
2948 nEndY = 0;
2951 xChartRanges = new ScRangeList;
2952 xChartRanges->Append( ScRange( nStartX, nStartY, nTab, nEndX, nEndY, nTab ) );
2955 if (!xChartRanges.Is()) // sonst Ranges direkt uebernehmen
2956 xChartRanges = new ScRangeList(aRanges);
2957 ScChartArray aArr( pDocShell->GetDocument(), xChartRanges, String() );
2959 // RowAsHdr = ColHeaders und umgekehrt
2960 aArr.SetHeaders( bChartRowAsHdr, bChartColAsHdr );
2962 return aArr.CreateMemChart();
2964 return NULL;
2967 uno::Sequence< uno::Sequence<double> > SAL_CALL ScCellRangesBase::getData()
2968 throw(uno::RuntimeException)
2970 ScUnoGuard aGuard;
2971 ScMemChart* pMemChart = CreateMemChart_Impl();
2972 if ( pMemChart )
2974 sal_Int32 nColCount = pMemChart->GetColCount();
2975 sal_Int32 nRowCount = static_cast<sal_Int32>(pMemChart->GetRowCount());
2977 uno::Sequence< uno::Sequence<double> > aRowSeq( nRowCount );
2978 uno::Sequence<double>* pRowAry = aRowSeq.getArray();
2979 for (sal_Int32 nRow = 0; nRow < nRowCount; nRow++)
2981 uno::Sequence<double> aColSeq( nColCount );
2982 double* pColAry = aColSeq.getArray();
2983 for (sal_Int32 nCol = 0; nCol < nColCount; nCol++)
2984 pColAry[nCol] = pMemChart->GetData( static_cast<short>(nCol), static_cast<short>(nRow) );
2986 pRowAry[nRow] = aColSeq;
2989 delete pMemChart;
2990 return aRowSeq;
2993 return uno::Sequence< uno::Sequence<double> >(0);
2996 ScRangeListRef ScCellRangesBase::GetLimitedChartRanges_Impl( long nDataColumns, long nDataRows ) const
2998 if ( aRanges.Count() == 1 )
3000 ScRange* pRange = aRanges.GetObject(0);
3001 if ( pRange->aStart.Col() == 0 && pRange->aEnd.Col() == MAXCOL &&
3002 pRange->aStart.Row() == 0 && pRange->aEnd.Row() == MAXROW )
3004 // if aRanges is a complete sheet, limit to given size
3006 SCTAB nTab = pRange->aStart.Tab();
3008 long nEndColumn = nDataColumns - 1 + ( bChartColAsHdr ? 1 : 0 );
3009 if ( nEndColumn < 0 )
3010 nEndColumn = 0;
3011 if ( nEndColumn > MAXCOL )
3012 nEndColumn = MAXCOL;
3014 long nEndRow = nDataRows - 1 + ( bChartRowAsHdr ? 1 : 0 );
3015 if ( nEndRow < 0 )
3016 nEndRow = 0;
3017 if ( nEndRow > MAXROW )
3018 nEndRow = MAXROW;
3020 ScRangeListRef xChartRanges = new ScRangeList;
3021 xChartRanges->Append( ScRange( 0, 0, nTab, (SCCOL)nEndColumn, (SCROW)nEndRow, nTab ) );
3022 return xChartRanges;
3026 return new ScRangeList(aRanges); // as-is
3029 void SAL_CALL ScCellRangesBase::setData( const uno::Sequence< uno::Sequence<double> >& aData )
3030 throw(uno::RuntimeException)
3032 ScUnoGuard aGuard;
3033 BOOL bDone = FALSE;
3034 long nRowCount = aData.getLength();
3035 long nColCount = nRowCount ? aData[0].getLength() : 0;
3036 ScRangeListRef xChartRanges = GetLimitedChartRanges_Impl( nColCount, nRowCount );
3037 if ( pDocShell && xChartRanges.Is() )
3039 ScDocument* pDoc = pDocShell->GetDocument();
3040 ScChartArray aArr( pDoc, xChartRanges, String() );
3041 aArr.SetHeaders( bChartRowAsHdr, bChartColAsHdr ); // RowAsHdr = ColHeaders
3042 const ScChartPositionMap* pPosMap = aArr.GetPositionMap();
3043 if (pPosMap)
3045 if ( pPosMap->GetColCount() == static_cast<SCCOL>(nColCount) &&
3046 pPosMap->GetRowCount() == static_cast<SCROW>(nRowCount) )
3048 for (long nRow=0; nRow<nRowCount; nRow++)
3050 const uno::Sequence<double>& rRowSeq = aData[nRow];
3051 const double* pArray = rRowSeq.getConstArray();
3052 nColCount = rRowSeq.getLength();
3053 for (long nCol=0; nCol<nColCount; nCol++)
3055 const ScAddress* pPos = pPosMap->GetPosition(
3056 sal::static_int_cast<SCCOL>(nCol),
3057 sal::static_int_cast<SCROW>(nRow) );
3058 if (pPos)
3060 double fVal = pArray[nCol];
3061 if ( fVal == DBL_MIN )
3062 pDoc->PutCell( *pPos, NULL ); // empty cell
3063 else
3064 pDoc->SetValue( pPos->Col(), pPos->Row(), pPos->Tab(), pArray[nCol] );
3069 //! undo
3070 PaintRanges_Impl( PAINT_GRID );
3071 pDocShell->SetDocumentModified();
3072 ForceChartListener_Impl(); // call listeners for this object synchronously
3073 bDone = TRUE;
3078 if (!bDone)
3079 throw uno::RuntimeException();
3082 uno::Sequence<rtl::OUString> SAL_CALL ScCellRangesBase::getRowDescriptions()
3083 throw(uno::RuntimeException)
3085 ScUnoGuard aGuard;
3086 ScMemChart* pMemChart = CreateMemChart_Impl();
3087 if ( pMemChart )
3089 sal_Int32 nRowCount = static_cast<sal_Int32>(pMemChart->GetRowCount());
3090 uno::Sequence<rtl::OUString> aSeq( nRowCount );
3091 rtl::OUString* pAry = aSeq.getArray();
3092 for (sal_Int32 nRow = 0; nRow < nRowCount; nRow++)
3093 pAry[nRow] = pMemChart->GetRowText(static_cast<short>(nRow));
3095 delete pMemChart;
3096 return aSeq;
3098 return uno::Sequence<rtl::OUString>(0);
3101 void SAL_CALL ScCellRangesBase::setRowDescriptions(
3102 const uno::Sequence<rtl::OUString>& aRowDescriptions )
3103 throw(uno::RuntimeException)
3105 ScUnoGuard aGuard;
3106 BOOL bDone = FALSE;
3107 if ( bChartColAsHdr )
3109 long nRowCount = aRowDescriptions.getLength();
3110 ScRangeListRef xChartRanges = GetLimitedChartRanges_Impl( 1, nRowCount );
3111 if ( pDocShell && xChartRanges.Is() )
3113 ScDocument* pDoc = pDocShell->GetDocument();
3114 ScChartArray aArr( pDoc, xChartRanges, String() );
3115 aArr.SetHeaders( bChartRowAsHdr, bChartColAsHdr ); // RowAsHdr = ColHeaders
3116 const ScChartPositionMap* pPosMap = aArr.GetPositionMap();
3117 if (pPosMap)
3119 if ( pPosMap->GetRowCount() == static_cast<SCROW>(nRowCount) )
3121 const rtl::OUString* pArray = aRowDescriptions.getConstArray();
3122 for (long nRow=0; nRow<nRowCount; nRow++)
3124 const ScAddress* pPos = pPosMap->GetRowHeaderPosition(
3125 static_cast<SCSIZE>(nRow) );
3126 if (pPos)
3128 String aStr = pArray[nRow];
3129 if ( aStr.Len() )
3130 pDoc->PutCell( *pPos, new ScStringCell( aStr ) );
3131 else
3132 pDoc->PutCell( *pPos, NULL ); // empty cell
3136 //! undo
3137 PaintRanges_Impl( PAINT_GRID );
3138 pDocShell->SetDocumentModified();
3139 ForceChartListener_Impl(); // call listeners for this object synchronously
3140 bDone = TRUE;
3146 if (!bDone)
3147 throw uno::RuntimeException();
3150 uno::Sequence<rtl::OUString> SAL_CALL ScCellRangesBase::getColumnDescriptions()
3151 throw(uno::RuntimeException)
3153 ScUnoGuard aGuard;
3154 ScMemChart* pMemChart = CreateMemChart_Impl();
3155 if ( pMemChart )
3157 sal_Int32 nColCount = pMemChart->GetColCount();
3158 uno::Sequence<rtl::OUString> aSeq( nColCount );
3159 rtl::OUString* pAry = aSeq.getArray();
3160 for (sal_Int32 nCol = 0; nCol < nColCount; nCol++)
3161 pAry[nCol] = pMemChart->GetColText(static_cast<short>(nCol));
3163 delete pMemChart;
3164 return aSeq;
3166 return uno::Sequence<rtl::OUString>(0);
3169 void SAL_CALL ScCellRangesBase::setColumnDescriptions(
3170 const uno::Sequence<rtl::OUString>& aColumnDescriptions )
3171 throw(uno::RuntimeException)
3173 ScUnoGuard aGuard;
3174 BOOL bDone = FALSE;
3175 if ( bChartRowAsHdr )
3177 long nColCount = aColumnDescriptions.getLength();
3178 ScRangeListRef xChartRanges = GetLimitedChartRanges_Impl( nColCount, 1 );
3179 if ( pDocShell && xChartRanges.Is() )
3181 ScDocument* pDoc = pDocShell->GetDocument();
3182 ScChartArray aArr( pDoc, xChartRanges, String() );
3183 aArr.SetHeaders( bChartRowAsHdr, bChartColAsHdr ); // RowAsHdr = ColHeaders
3184 const ScChartPositionMap* pPosMap = aArr.GetPositionMap();
3185 if (pPosMap)
3187 if ( pPosMap->GetColCount() == static_cast<SCCOL>(nColCount) )
3189 const rtl::OUString* pArray = aColumnDescriptions.getConstArray();
3190 for (long nCol=0; nCol<nColCount; nCol++)
3192 const ScAddress* pPos = pPosMap->GetColHeaderPosition(
3193 sal::static_int_cast<SCCOL>(nCol) );
3194 if (pPos)
3196 String aStr(pArray[nCol]);
3197 if ( aStr.Len() )
3198 pDoc->PutCell( *pPos, new ScStringCell( aStr ) );
3199 else
3200 pDoc->PutCell( *pPos, NULL ); // empty cell
3204 //! undo
3205 PaintRanges_Impl( PAINT_GRID );
3206 pDocShell->SetDocumentModified();
3207 ForceChartListener_Impl(); // call listeners for this object synchronously
3208 bDone = TRUE;
3214 if (!bDone)
3215 throw uno::RuntimeException();
3218 void ScCellRangesBase::ForceChartListener_Impl()
3220 // call Update immediately so the caller to setData etc. can
3221 // regognize the listener call
3223 if ( pDocShell )
3225 ScChartListenerCollection* pColl = pDocShell->GetDocument()->GetChartListenerCollection();
3226 if ( pColl )
3228 USHORT nCollCount = pColl->GetCount();
3229 for ( USHORT nIndex = 0; nIndex < nCollCount; nIndex++ )
3231 ScChartListener* pChartListener = (ScChartListener*)pColl->At(nIndex);
3232 if ( pChartListener &&
3233 pChartListener->GetUnoSource() == static_cast<chart::XChartData*>(this) &&
3234 pChartListener->IsDirty() )
3235 pChartListener->Update();
3241 String lcl_UniqueName( ScStrCollection& rColl, const String& rPrefix )
3243 long nNumber = 1;
3244 USHORT nCollCount = rColl.GetCount();
3245 while (TRUE)
3247 String aName(rPrefix);
3248 aName += String::CreateFromInt32( nNumber );
3249 BOOL bFound = FALSE;
3250 for (USHORT i=0; i<nCollCount; i++)
3251 if ( rColl[i]->GetString() == aName )
3253 bFound = TRUE;
3254 break;
3256 if (!bFound)
3257 return aName;
3258 ++nNumber;
3262 void SAL_CALL ScCellRangesBase::addChartDataChangeEventListener( const uno::Reference<
3263 chart::XChartDataChangeEventListener >& aListener )
3264 throw(uno::RuntimeException)
3266 ScUnoGuard aGuard;
3267 if ( pDocShell && aRanges.Count() )
3269 //! auf doppelte testen?
3271 ScDocument* pDoc = pDocShell->GetDocument();
3272 ScRangeListRef aRangesRef( new ScRangeList(aRanges) );
3273 ScChartListenerCollection* pColl = pDoc->GetChartListenerCollection();
3274 String aName(lcl_UniqueName( *pColl,
3275 String::CreateFromAscii(RTL_CONSTASCII_STRINGPARAM("__Uno")) ));
3276 ScChartListener* pListener = new ScChartListener( aName, pDoc, aRangesRef );
3277 pListener->SetUno( aListener, this );
3278 pColl->Insert( pListener );
3279 pListener->StartListeningTo();
3283 void SAL_CALL ScCellRangesBase::removeChartDataChangeEventListener( const uno::Reference<
3284 chart::XChartDataChangeEventListener >& aListener )
3285 throw(uno::RuntimeException)
3287 ScUnoGuard aGuard;
3288 if ( pDocShell && aRanges.Count() )
3290 ScDocument* pDoc = pDocShell->GetDocument();
3291 ScChartListenerCollection* pColl = pDoc->GetChartListenerCollection();
3292 pColl->FreeUno( aListener, this );
3296 double SAL_CALL ScCellRangesBase::getNotANumber() throw(::com::sun::star::uno::RuntimeException)
3298 // im ScChartArray wird DBL_MIN verwendet, weil das Chart es so will
3299 return DBL_MIN;
3302 sal_Bool SAL_CALL ScCellRangesBase::isNotANumber( double nNumber ) throw(uno::RuntimeException)
3304 // im ScChartArray wird DBL_MIN verwendet, weil das Chart es so will
3305 return (nNumber == DBL_MIN);
3308 // XModifyBroadcaster
3310 void SAL_CALL ScCellRangesBase::addModifyListener( const uno::Reference<util::XModifyListener>& aListener )
3311 throw(uno::RuntimeException)
3313 ScUnoGuard aGuard;
3314 if ( aRanges.Count() == 0 )
3315 throw uno::RuntimeException();
3317 uno::Reference<util::XModifyListener> *pObj =
3318 new uno::Reference<util::XModifyListener>( aListener );
3319 aValueListeners.Insert( pObj, aValueListeners.Count() );
3321 if ( aValueListeners.Count() == 1 )
3323 if (!pValueListener)
3324 pValueListener = new ScLinkListener( LINK( this, ScCellRangesBase, ValueListenerHdl ) );
3326 ScDocument* pDoc = pDocShell->GetDocument();
3327 ULONG nCount = aRanges.Count();
3328 for (ULONG i=0; i<nCount; i++)
3329 pDoc->StartListeningArea( *aRanges.GetObject(i), pValueListener );
3331 acquire(); // don't lose this object (one ref for all listeners)
3335 void SAL_CALL ScCellRangesBase::removeModifyListener( const uno::Reference<util::XModifyListener>& aListener )
3336 throw(uno::RuntimeException)
3339 ScUnoGuard aGuard;
3340 if ( aRanges.Count() == 0 )
3341 throw uno::RuntimeException();
3343 acquire(); // in case the listeners have the last ref - released below
3345 USHORT nCount = aValueListeners.Count();
3346 for ( USHORT n=nCount; n--; )
3348 uno::Reference<util::XModifyListener> *pObj = aValueListeners[n];
3349 if ( *pObj == aListener )
3351 aValueListeners.DeleteAndDestroy( n );
3353 if ( aValueListeners.Count() == 0 )
3355 if (pValueListener)
3356 pValueListener->EndListeningAll();
3358 release(); // release the ref for the listeners
3361 break;
3365 release(); // might delete this object
3368 // XCellRangesQuery
3370 uno::Reference<sheet::XSheetCellRanges> SAL_CALL ScCellRangesBase::queryVisibleCells()
3371 throw(uno::RuntimeException)
3373 ScUnoGuard aGuard;
3374 if (pDocShell)
3376 //! fuer alle Tabellen getrennt, wenn Markierungen pro Tabelle getrennt sind!
3377 SCTAB nTab = lcl_FirstTab(aRanges);
3379 ScMarkData aMarkData(*GetMarkData());
3381 ScDocument* pDoc = pDocShell->GetDocument();
3382 SCCOL nCol = 0, nLastCol;
3383 while (nCol <= MAXCOL)
3385 if (pDoc->ColHidden(nCol, nTab, nLastCol))
3386 // hidden columns. Unselect them.
3387 aMarkData.SetMultiMarkArea(ScRange(nCol, 0, nTab, nLastCol, MAXROW, nTab), false);
3389 nCol = nLastCol + 1;
3392 SCROW nRow = 0, nLastRow;
3393 while (nRow <= MAXROW)
3395 if (pDoc->RowHidden(nRow, nTab, nLastRow))
3396 // These rows are hidden. Unselect them.
3397 aMarkData.SetMultiMarkArea(ScRange(0, nRow, nTab, MAXCOL, nLastRow, nTab), false);
3399 nRow = nLastRow + 1;
3402 ScRangeList aNewRanges;
3403 aMarkData.FillRangeListWithMarks( &aNewRanges, FALSE );
3404 return new ScCellRangesObj( pDocShell, aNewRanges );
3407 return NULL;
3410 uno::Reference<sheet::XSheetCellRanges> SAL_CALL ScCellRangesBase::queryEmptyCells()
3411 throw(uno::RuntimeException)
3413 ScUnoGuard aGuard;
3414 if (pDocShell)
3416 ScDocument* pDoc = pDocShell->GetDocument();
3418 ScMarkData aMarkData(*GetMarkData());
3420 // belegte Zellen wegmarkieren
3421 ULONG nCount = aRanges.Count();
3422 for (ULONG i=0; i<nCount; i++)
3424 ScRange aRange = *aRanges.GetObject(i);
3426 ScCellIterator aIter( pDoc, aRange );
3427 ScBaseCell* pCell = aIter.GetFirst();
3428 while (pCell)
3430 // Notizen zaehlen als nicht-leer
3431 if ( !pCell->IsBlank() )
3432 aMarkData.SetMultiMarkArea(
3433 ScRange( aIter.GetCol(), aIter.GetRow(), aIter.GetTab() ),
3434 FALSE );
3436 pCell = aIter.GetNext();
3440 ScRangeList aNewRanges;
3441 // IsMultiMarked reicht hier nicht (wird beim deselektieren nicht zurueckgesetzt)
3442 if (aMarkData.HasAnyMultiMarks())
3443 aMarkData.FillRangeListWithMarks( &aNewRanges, FALSE );
3445 return new ScCellRangesObj( pDocShell, aNewRanges ); // aNewRanges kann leer sein
3448 return NULL;
3451 uno::Reference<sheet::XSheetCellRanges> SAL_CALL ScCellRangesBase::queryContentCells(
3452 sal_Int16 nContentFlags )
3453 throw(uno::RuntimeException)
3455 ScUnoGuard aGuard;
3456 if (pDocShell)
3458 ScDocument* pDoc = pDocShell->GetDocument();
3460 ScMarkData aMarkData;
3462 // passende Zellen selektieren
3463 ULONG nCount = aRanges.Count();
3464 for (ULONG i=0; i<nCount; i++)
3466 ScRange aRange = *aRanges.GetObject(i);
3468 ScCellIterator aIter( pDoc, aRange );
3469 ScBaseCell* pCell = aIter.GetFirst();
3470 while (pCell)
3472 BOOL bAdd = FALSE;
3473 if ( pCell->HasNote() && ( nContentFlags & sheet::CellFlags::ANNOTATION ) )
3474 bAdd = TRUE;
3475 else
3476 switch ( pCell->GetCellType() )
3478 case CELLTYPE_STRING:
3479 if ( nContentFlags & sheet::CellFlags::STRING )
3480 bAdd = TRUE;
3481 break;
3482 case CELLTYPE_EDIT:
3483 if ( (nContentFlags & sheet::CellFlags::STRING) || (nContentFlags & sheet::CellFlags::FORMATTED) )
3484 bAdd = TRUE;
3485 break;
3486 case CELLTYPE_FORMULA:
3487 if ( nContentFlags & sheet::CellFlags::FORMULA )
3488 bAdd = TRUE;
3489 break;
3490 case CELLTYPE_VALUE:
3491 if ( (nContentFlags & (sheet::CellFlags::VALUE|sheet::CellFlags::DATETIME))
3492 == (sheet::CellFlags::VALUE|sheet::CellFlags::DATETIME) )
3493 bAdd = TRUE;
3494 else
3496 // Date/Time Erkennung
3498 ULONG nIndex = (ULONG)((SfxUInt32Item*)pDoc->GetAttr(
3499 aIter.GetCol(), aIter.GetRow(), aIter.GetTab(),
3500 ATTR_VALUE_FORMAT ))->GetValue();
3501 short nTyp = pDoc->GetFormatTable()->GetType(nIndex);
3502 if ((nTyp == NUMBERFORMAT_DATE) || (nTyp == NUMBERFORMAT_TIME) ||
3503 (nTyp == NUMBERFORMAT_DATETIME))
3505 if ( nContentFlags & sheet::CellFlags::DATETIME )
3506 bAdd = TRUE;
3508 else
3510 if ( nContentFlags & sheet::CellFlags::VALUE )
3511 bAdd = TRUE;
3514 break;
3515 default:
3517 // added to avoid warnings
3521 if (bAdd)
3522 aMarkData.SetMultiMarkArea(
3523 ScRange( aIter.GetCol(), aIter.GetRow(), aIter.GetTab() ),
3524 TRUE );
3526 pCell = aIter.GetNext();
3530 ScRangeList aNewRanges;
3531 if (aMarkData.IsMultiMarked())
3532 aMarkData.FillRangeListWithMarks( &aNewRanges, FALSE );
3534 return new ScCellRangesObj( pDocShell, aNewRanges ); // aNewRanges kann leer sein
3537 return NULL;
3540 uno::Reference<sheet::XSheetCellRanges> SAL_CALL ScCellRangesBase::queryFormulaCells(
3541 sal_Int32 nResultFlags )
3542 throw(uno::RuntimeException)
3544 ScUnoGuard aGuard;
3545 if (pDocShell)
3547 ScDocument* pDoc = pDocShell->GetDocument();
3549 ScMarkData aMarkData;
3551 // passende Zellen selektieren
3552 ULONG nCount = aRanges.Count();
3553 for (ULONG i=0; i<nCount; i++)
3555 ScRange aRange = *aRanges.GetObject(i);
3557 ScCellIterator aIter( pDoc, aRange );
3558 ScBaseCell* pCell = aIter.GetFirst();
3559 while (pCell)
3561 if (pCell->GetCellType() == CELLTYPE_FORMULA)
3563 ScFormulaCell* pFCell = (ScFormulaCell*)pCell;
3564 BOOL bAdd = FALSE;
3565 if (pFCell->GetErrCode())
3567 if ( nResultFlags & sheet::FormulaResult::ERROR )
3568 bAdd = TRUE;
3570 else if (pFCell->IsValue())
3572 if ( nResultFlags & sheet::FormulaResult::VALUE )
3573 bAdd = TRUE;
3575 else // String
3577 if ( nResultFlags & sheet::FormulaResult::STRING )
3578 bAdd = TRUE;
3581 if (bAdd)
3582 aMarkData.SetMultiMarkArea(
3583 ScRange( aIter.GetCol(), aIter.GetRow(), aIter.GetTab() ),
3584 TRUE );
3587 pCell = aIter.GetNext();
3591 ScRangeList aNewRanges;
3592 if (aMarkData.IsMultiMarked())
3593 aMarkData.FillRangeListWithMarks( &aNewRanges, FALSE );
3595 return new ScCellRangesObj( pDocShell, aNewRanges ); // aNewRanges kann leer sein
3598 return NULL;
3601 uno::Reference<sheet::XSheetCellRanges> ScCellRangesBase::QueryDifferences_Impl(
3602 const table::CellAddress& aCompare, BOOL bColumnDiff)
3604 if (pDocShell)
3606 ULONG nRangeCount = aRanges.Count();
3607 ULONG i;
3608 ScDocument* pDoc = pDocShell->GetDocument();
3609 ScMarkData aMarkData;
3611 SCCOLROW nCmpPos = bColumnDiff ? (SCCOLROW)aCompare.Row : (SCCOLROW)aCompare.Column;
3613 // zuerst alles selektieren, wo ueberhaupt etwas in der Vergleichsspalte steht
3614 // (fuer gleiche Zellen wird die Selektion im zweiten Schritt aufgehoben)
3616 SCTAB nTab = lcl_FirstTab(aRanges); //! fuer alle Tabellen, wenn Markierungen pro Tabelle!
3617 ScRange aCmpRange, aCellRange;
3618 if (bColumnDiff)
3619 aCmpRange = ScRange( 0,nCmpPos,nTab, MAXCOL,nCmpPos,nTab );
3620 else
3621 aCmpRange = ScRange( static_cast<SCCOL>(nCmpPos),0,nTab, static_cast<SCCOL>(nCmpPos),MAXROW,nTab );
3622 ScCellIterator aCmpIter( pDoc, aCmpRange );
3623 ScBaseCell* pCmpCell = aCmpIter.GetFirst();
3624 while (pCmpCell)
3626 if (pCmpCell->GetCellType() != CELLTYPE_NOTE)
3628 SCCOLROW nCellPos = bColumnDiff ? static_cast<SCCOLROW>(aCmpIter.GetCol()) : static_cast<SCCOLROW>(aCmpIter.GetRow());
3629 if (bColumnDiff)
3630 aCellRange = ScRange( static_cast<SCCOL>(nCellPos),0,nTab,
3631 static_cast<SCCOL>(nCellPos),MAXROW,nTab );
3632 else
3633 aCellRange = ScRange( 0,nCellPos,nTab, MAXCOL,nCellPos,nTab );
3635 for (i=0; i<nRangeCount; i++)
3637 ScRange aRange(*aRanges.GetObject(i));
3638 if ( aRange.Intersects( aCellRange ) )
3640 if (bColumnDiff)
3642 aRange.aStart.SetCol(static_cast<SCCOL>(nCellPos));
3643 aRange.aEnd.SetCol(static_cast<SCCOL>(nCellPos));
3645 else
3647 aRange.aStart.SetRow(nCellPos);
3648 aRange.aEnd.SetRow(nCellPos);
3650 aMarkData.SetMultiMarkArea( aRange );
3654 pCmpCell = aCmpIter.GetNext();
3657 // alle nichtleeren Zellen mit der Vergleichsspalte vergleichen und entsprechend
3658 // selektieren oder aufheben
3660 ScAddress aCmpAddr;
3661 for (i=0; i<nRangeCount; i++)
3663 ScRange aRange(*aRanges.GetObject(i));
3665 ScCellIterator aIter( pDoc, aRange );
3666 ScBaseCell* pCell = aIter.GetFirst();
3667 while (pCell)
3669 if (bColumnDiff)
3670 aCmpAddr = ScAddress( aIter.GetCol(), nCmpPos, aIter.GetTab() );
3671 else
3672 aCmpAddr = ScAddress( static_cast<SCCOL>(nCmpPos), aIter.GetRow(), aIter.GetTab() );
3673 const ScBaseCell* pOtherCell = pDoc->GetCell( aCmpAddr );
3675 ScRange aOneRange( aIter.GetCol(), aIter.GetRow(), aIter.GetTab() );
3676 if ( !ScBaseCell::CellEqual( pCell, pOtherCell ) )
3677 aMarkData.SetMultiMarkArea( aOneRange );
3678 else
3679 aMarkData.SetMultiMarkArea( aOneRange, FALSE ); // deselect
3681 pCell = aIter.GetNext();
3685 ScRangeList aNewRanges;
3686 if (aMarkData.IsMultiMarked())
3687 aMarkData.FillRangeListWithMarks( &aNewRanges, FALSE );
3689 return new ScCellRangesObj( pDocShell, aNewRanges ); // aNewRanges kann leer sein
3691 return NULL;
3694 uno::Reference<sheet::XSheetCellRanges > SAL_CALL ScCellRangesBase::queryColumnDifferences(
3695 const table::CellAddress& aCompare ) throw(uno::RuntimeException)
3697 ScUnoGuard aGuard;
3698 return QueryDifferences_Impl( aCompare, TRUE );
3701 uno::Reference<sheet::XSheetCellRanges> SAL_CALL ScCellRangesBase::queryRowDifferences(
3702 const table::CellAddress& aCompare ) throw(uno::RuntimeException)
3704 ScUnoGuard aGuard;
3705 return QueryDifferences_Impl( aCompare, FALSE );
3708 uno::Reference<sheet::XSheetCellRanges> SAL_CALL ScCellRangesBase::queryIntersection(
3709 const table::CellRangeAddress& aRange ) throw(uno::RuntimeException)
3711 ScUnoGuard aGuard;
3712 ScRange aMask( (SCCOL)aRange.StartColumn, (SCROW)aRange.StartRow, aRange.Sheet,
3713 (SCCOL)aRange.EndColumn, (SCROW)aRange.EndRow, aRange.Sheet );
3715 ScRangeList aNew;
3716 ULONG nCount = aRanges.Count();
3717 for (ULONG i=0; i<nCount; i++)
3719 ScRange aTemp(*aRanges.GetObject(i));
3720 if ( aTemp.Intersects( aMask ) )
3721 aNew.Join( ScRange( Max( aTemp.aStart.Col(), aMask.aStart.Col() ),
3722 Max( aTemp.aStart.Row(), aMask.aStart.Row() ),
3723 Max( aTemp.aStart.Tab(), aMask.aStart.Tab() ),
3724 Min( aTemp.aEnd.Col(), aMask.aEnd.Col() ),
3725 Min( aTemp.aEnd.Row(), aMask.aEnd.Row() ),
3726 Min( aTemp.aEnd.Tab(), aMask.aEnd.Tab() ) ) );
3729 return new ScCellRangesObj( pDocShell, aNew ); // kann leer sein
3732 // XFormulaQuery
3734 uno::Reference<sheet::XSheetCellRanges> SAL_CALL ScCellRangesBase::queryPrecedents(
3735 sal_Bool bRecursive ) throw(uno::RuntimeException)
3737 ScUnoGuard aGuard;
3738 if ( pDocShell )
3740 ScDocument* pDoc = pDocShell->GetDocument();
3742 ScRangeList aNewRanges(aRanges);
3743 BOOL bFound;
3746 bFound = FALSE;
3748 // #97205# aMarkData uses aNewRanges, not aRanges, so GetMarkData can't be used
3749 ScMarkData aMarkData;
3750 aMarkData.MarkFromRangeList( aNewRanges, FALSE );
3751 aMarkData.MarkToMulti(); // needed for IsAllMarked
3753 ULONG nCount = aNewRanges.Count();
3754 for (ULONG nR=0; nR<nCount; nR++)
3756 ScRange aRange(*aNewRanges.GetObject(nR));
3757 ScCellIterator aIter( pDoc, aRange );
3758 ScBaseCell* pCell = aIter.GetFirst();
3759 while (pCell)
3761 if ( pCell->GetCellType() == CELLTYPE_FORMULA )
3763 ScFormulaCell* pFCell = (ScFormulaCell*) pCell;
3765 ScDetectiveRefIter aRefIter( pFCell );
3766 ScRange aRefRange;
3767 while ( aRefIter.GetNextRef( aRefRange) )
3769 if ( bRecursive && !bFound && !aMarkData.IsAllMarked( aRefRange ) )
3770 bFound = TRUE;
3771 aMarkData.SetMultiMarkArea( aRefRange, TRUE );
3774 pCell = aIter.GetNext();
3778 aMarkData.FillRangeListWithMarks( &aNewRanges, TRUE );
3780 while ( bRecursive && bFound );
3782 return new ScCellRangesObj( pDocShell, aNewRanges );
3785 return NULL;
3788 uno::Reference<sheet::XSheetCellRanges> SAL_CALL ScCellRangesBase::queryDependents(
3789 sal_Bool bRecursive ) throw(uno::RuntimeException)
3791 ScUnoGuard aGuard;
3792 if ( pDocShell )
3794 ScDocument* pDoc = pDocShell->GetDocument();
3796 ScRangeList aNewRanges(aRanges);
3797 BOOL bFound;
3800 bFound = FALSE;
3801 ULONG nRangesCount = aNewRanges.Count();
3803 // #97205# aMarkData uses aNewRanges, not aRanges, so GetMarkData can't be used
3804 ScMarkData aMarkData;
3805 aMarkData.MarkFromRangeList( aNewRanges, FALSE );
3806 aMarkData.MarkToMulti(); // needed for IsAllMarked
3808 SCTAB nTab = lcl_FirstTab(aNewRanges); //! alle Tabellen
3810 ScCellIterator aCellIter( pDoc, 0,0, nTab, MAXCOL,MAXROW, nTab );
3811 ScBaseCell* pCell = aCellIter.GetFirst();
3812 while (pCell)
3814 if (pCell->GetCellType() == CELLTYPE_FORMULA)
3816 BOOL bMark = FALSE;
3817 ScDetectiveRefIter aIter( (ScFormulaCell*) pCell );
3818 ScRange aRefRange;
3819 while ( aIter.GetNextRef( aRefRange) )
3821 for (ULONG nR=0; nR<nRangesCount; nR++)
3823 ScRange aRange(*aNewRanges.GetObject(nR));
3824 if (aRange.Intersects(aRefRange))
3825 bMark = TRUE; // von Teil des Ranges abhaengig
3828 if (bMark)
3830 ScRange aCellRange( aCellIter.GetCol(),
3831 aCellIter.GetRow(),
3832 aCellIter.GetTab() );
3833 if ( bRecursive && !bFound && !aMarkData.IsAllMarked( aCellRange ) )
3834 bFound = TRUE;
3835 aMarkData.SetMultiMarkArea( aCellRange, TRUE );
3838 pCell = aCellIter.GetNext();
3841 aMarkData.FillRangeListWithMarks( &aNewRanges, TRUE );
3843 while ( bRecursive && bFound );
3845 return new ScCellRangesObj( pDocShell, aNewRanges );
3848 return NULL;
3851 // XSearchable
3853 uno::Reference<util::XSearchDescriptor> SAL_CALL ScCellRangesBase::createSearchDescriptor()
3854 throw(uno::RuntimeException)
3856 ScUnoGuard aGuard;
3857 return new ScCellSearchObj;
3860 uno::Reference<container::XIndexAccess> SAL_CALL ScCellRangesBase::findAll(
3861 const uno::Reference<util::XSearchDescriptor>& xDesc )
3862 throw(uno::RuntimeException)
3864 // Wenn nichts gefunden wird, soll Null zurueckgegeben werden (?)
3865 uno::Reference<container::XIndexAccess> xRet;
3866 if ( pDocShell && xDesc.is() )
3868 ScCellSearchObj* pSearch = ScCellSearchObj::getImplementation( xDesc );
3869 if (pSearch)
3871 SvxSearchItem* pSearchItem = pSearch->GetSearchItem();
3872 if (pSearchItem)
3874 ScDocument* pDoc = pDocShell->GetDocument();
3875 pSearchItem->SetCommand( SVX_SEARCHCMD_FIND_ALL );
3876 // immer nur innerhalb dieses Objekts
3877 pSearchItem->SetSelection( !lcl_WholeSheet(aRanges) );
3879 ScMarkData aMark(*GetMarkData());
3881 String aDummyUndo;
3882 SCCOL nCol = 0;
3883 SCROW nRow = 0;
3884 SCTAB nTab = 0;
3885 BOOL bFound = pDoc->SearchAndReplace( *pSearchItem, nCol, nRow, nTab,
3886 aMark, aDummyUndo, NULL );
3887 if (bFound)
3889 ScRangeList aNewRanges;
3890 aMark.FillRangeListWithMarks( &aNewRanges, TRUE );
3891 // bei findAll immer CellRanges, egal wieviel gefunden wurde
3892 xRet.set(new ScCellRangesObj( pDocShell, aNewRanges ));
3897 return xRet;
3900 uno::Reference<uno::XInterface> ScCellRangesBase::Find_Impl(
3901 const uno::Reference<util::XSearchDescriptor>& xDesc,
3902 const ScAddress* pLastPos )
3904 uno::Reference<uno::XInterface> xRet;
3905 if ( pDocShell && xDesc.is() )
3907 ScCellSearchObj* pSearch = ScCellSearchObj::getImplementation( xDesc );
3908 if (pSearch)
3910 SvxSearchItem* pSearchItem = pSearch->GetSearchItem();
3911 if (pSearchItem)
3913 ScDocument* pDoc = pDocShell->GetDocument();
3914 pSearchItem->SetCommand( SVX_SEARCHCMD_FIND );
3915 // immer nur innerhalb dieses Objekts
3916 pSearchItem->SetSelection( !lcl_WholeSheet(aRanges) );
3918 ScMarkData aMark(*GetMarkData());
3920 SCCOL nCol;
3921 SCROW nRow;
3922 SCTAB nTab;
3923 if (pLastPos)
3924 pLastPos->GetVars( nCol, nRow, nTab );
3925 else
3927 nTab = lcl_FirstTab(aRanges); //! mehrere Tabellen?
3928 ScDocument::GetSearchAndReplaceStart( *pSearchItem, nCol, nRow );
3931 String aDummyUndo;
3932 BOOL bFound = pDoc->SearchAndReplace( *pSearchItem, nCol, nRow, nTab,
3933 aMark, aDummyUndo, NULL );
3934 if (bFound)
3936 ScAddress aFoundPos( nCol, nRow, nTab );
3937 xRet.set((cppu::OWeakObject*) new ScCellObj( pDocShell, aFoundPos ));
3942 return xRet;
3945 uno::Reference<uno::XInterface> SAL_CALL ScCellRangesBase::findFirst(
3946 const uno::Reference<util::XSearchDescriptor>& xDesc )
3947 throw(uno::RuntimeException)
3949 ScUnoGuard aGuard;
3950 return Find_Impl( xDesc, NULL );
3953 uno::Reference<uno::XInterface> SAL_CALL ScCellRangesBase::findNext(
3954 const uno::Reference<uno::XInterface>& xStartAt,
3955 const uno::Reference<util::XSearchDescriptor >& xDesc )
3956 throw(uno::RuntimeException)
3958 ScUnoGuard aGuard;
3959 if ( xStartAt.is() )
3961 ScCellRangesBase* pRangesImp = ScCellRangesBase::getImplementation( xStartAt );
3962 if ( pRangesImp && pRangesImp->GetDocShell() == pDocShell )
3964 const ScRangeList& rStartRanges = pRangesImp->GetRangeList();
3965 if ( rStartRanges.Count() == 1 )
3967 ScAddress aStartPos = rStartRanges.GetObject(0)->aStart;
3968 return Find_Impl( xDesc, &aStartPos );
3972 return NULL;
3975 // XReplaceable
3977 uno::Reference<util::XReplaceDescriptor> SAL_CALL ScCellRangesBase::createReplaceDescriptor()
3978 throw(uno::RuntimeException)
3980 ScUnoGuard aGuard;
3981 return new ScCellSearchObj;
3984 sal_Int32 SAL_CALL ScCellRangesBase::replaceAll( const uno::Reference<util::XSearchDescriptor>& xDesc )
3985 throw(uno::RuntimeException)
3987 ScUnoGuard aGuard;
3988 INT32 nReplaced = 0;
3989 if ( pDocShell && xDesc.is() )
3991 ScCellSearchObj* pSearch = ScCellSearchObj::getImplementation( xDesc );
3992 if (pSearch)
3994 SvxSearchItem* pSearchItem = pSearch->GetSearchItem();
3995 if (pSearchItem)
3997 ScDocument* pDoc = pDocShell->GetDocument();
3998 BOOL bUndo(pDoc->IsUndoEnabled());
3999 pSearchItem->SetCommand( SVX_SEARCHCMD_REPLACE_ALL );
4000 // immer nur innerhalb dieses Objekts
4001 pSearchItem->SetSelection( !lcl_WholeSheet(aRanges) );
4003 ScMarkData aMark(*GetMarkData());
4005 SCTAB nTabCount = pDoc->GetTableCount();
4006 BOOL bProtected = !pDocShell->IsEditable();
4007 for (SCTAB i=0; i<nTabCount; i++)
4008 if ( aMark.GetTableSelect(i) && pDoc->IsTabProtected(i) )
4009 bProtected = TRUE;
4010 if (bProtected)
4012 //! Exception, oder was?
4014 else
4016 SCTAB nTab = aMark.GetFirstSelected(); // bei SearchAndReplace nicht benutzt
4017 SCCOL nCol = 0;
4018 SCROW nRow = 0;
4020 String aUndoStr;
4021 ScDocument* pUndoDoc = NULL;
4022 if (bUndo)
4024 pUndoDoc = new ScDocument( SCDOCMODE_UNDO );
4025 pUndoDoc->InitUndo( pDoc, nTab, nTab );
4027 for (SCTAB i=0; i<nTabCount; i++)
4028 if ( aMark.GetTableSelect(i) && i != nTab && bUndo)
4029 pUndoDoc->AddUndoTab( i, i );
4030 ScMarkData* pUndoMark = NULL;
4031 if (bUndo)
4032 pUndoMark = new ScMarkData(aMark);
4034 BOOL bFound(FALSE);
4035 if (bUndo)
4036 bFound = pDoc->SearchAndReplace( *pSearchItem, nCol, nRow, nTab,
4037 aMark, aUndoStr, pUndoDoc );
4038 if (bFound)
4040 nReplaced = pUndoDoc->GetCellCount();
4042 pDocShell->GetUndoManager()->AddUndoAction(
4043 new ScUndoReplace( pDocShell, *pUndoMark, nCol, nRow, nTab,
4044 aUndoStr, pUndoDoc, pSearchItem ) );
4046 pDocShell->PostPaintGridAll();
4047 pDocShell->SetDocumentModified();
4049 else
4051 delete pUndoDoc;
4052 delete pUndoMark;
4053 // nReplaced bleibt 0
4059 return nReplaced;
4062 // XUnoTunnel
4064 sal_Int64 SAL_CALL ScCellRangesBase::getSomething(
4065 const uno::Sequence<sal_Int8 >& rId ) throw(uno::RuntimeException)
4067 if ( rId.getLength() == 16 &&
4068 0 == rtl_compareMemory( getUnoTunnelId().getConstArray(),
4069 rId.getConstArray(), 16 ) )
4071 return sal::static_int_cast<sal_Int64>(reinterpret_cast<sal_IntPtr>(this));
4073 return 0;
4076 // static
4077 const uno::Sequence<sal_Int8>& ScCellRangesBase::getUnoTunnelId()
4079 static uno::Sequence<sal_Int8> * pSeq = 0;
4080 if( !pSeq )
4082 osl::Guard< osl::Mutex > aGuard( osl::Mutex::getGlobalMutex() );
4083 if( !pSeq )
4085 static uno::Sequence< sal_Int8 > aSeq( 16 );
4086 rtl_createUuid( (sal_uInt8*)aSeq.getArray(), 0, sal_True );
4087 pSeq = &aSeq;
4090 return *pSeq;
4093 // static
4094 ScCellRangesBase* ScCellRangesBase::getImplementation( const uno::Reference<uno::XInterface> xObj )
4096 ScCellRangesBase* pRet = NULL;
4097 uno::Reference<lang::XUnoTunnel> xUT( xObj, uno::UNO_QUERY );
4098 if (xUT.is())
4099 pRet = reinterpret_cast<ScCellRangesBase*>(sal::static_int_cast<sal_IntPtr>(xUT->getSomething(getUnoTunnelId())));
4100 return pRet;
4103 //------------------------------------------------------------------------
4105 ScCellRangesObj::ScCellRangesObj(ScDocShell* pDocSh, const ScRangeList& rR) :
4106 ScCellRangesBase( pDocSh, rR )
4110 ScCellRangesObj::~ScCellRangesObj()
4114 void ScCellRangesObj::RefChanged()
4116 ScCellRangesBase::RefChanged();
4118 // nix weiter...
4121 uno::Any SAL_CALL ScCellRangesObj::queryInterface( const uno::Type& rType )
4122 throw(uno::RuntimeException)
4124 SC_QUERYINTERFACE( sheet::XSheetCellRangeContainer )
4125 SC_QUERYINTERFACE( sheet::XSheetCellRanges )
4126 SC_QUERYINTERFACE( container::XIndexAccess )
4127 SC_QUERY_MULTIPLE( container::XElementAccess, container::XIndexAccess )
4128 SC_QUERYINTERFACE( container::XEnumerationAccess )
4129 SC_QUERYINTERFACE( container::XNameContainer )
4130 SC_QUERYINTERFACE( container::XNameReplace )
4131 SC_QUERYINTERFACE( container::XNameAccess )
4133 return ScCellRangesBase::queryInterface( rType );
4136 void SAL_CALL ScCellRangesObj::acquire() throw()
4138 ScCellRangesBase::acquire();
4141 void SAL_CALL ScCellRangesObj::release() throw()
4143 ScCellRangesBase::release();
4146 uno::Sequence<uno::Type> SAL_CALL ScCellRangesObj::getTypes() throw(uno::RuntimeException)
4148 static uno::Sequence<uno::Type> aTypes;
4149 if ( aTypes.getLength() == 0 )
4151 uno::Sequence<uno::Type> aParentTypes(ScCellRangesBase::getTypes());
4152 long nParentLen = aParentTypes.getLength();
4153 const uno::Type* pParentPtr = aParentTypes.getConstArray();
4155 aTypes.realloc( nParentLen + 3 );
4156 uno::Type* pPtr = aTypes.getArray();
4157 pPtr[nParentLen + 0] = getCppuType((const uno::Reference<sheet::XSheetCellRangeContainer>*)0);
4158 pPtr[nParentLen + 1] = getCppuType((const uno::Reference<container::XNameContainer>*)0);
4159 pPtr[nParentLen + 2] = getCppuType((const uno::Reference<container::XEnumerationAccess>*)0);
4161 for (long i=0; i<nParentLen; i++)
4162 pPtr[i] = pParentPtr[i]; // parent types first
4164 return aTypes;
4167 uno::Sequence<sal_Int8> SAL_CALL ScCellRangesObj::getImplementationId()
4168 throw(uno::RuntimeException)
4170 static uno::Sequence< sal_Int8 > aId;
4171 if( aId.getLength() == 0 )
4173 aId.realloc( 16 );
4174 rtl_createUuid( (sal_uInt8 *)aId.getArray(), 0, sal_True );
4176 return aId;
4179 // XCellRanges
4181 ScCellRangeObj* ScCellRangesObj::GetObjectByIndex_Impl(sal_Int32 nIndex) const
4183 ScDocShell* pDocSh = GetDocShell();
4184 const ScRangeList& rRanges = GetRangeList();
4185 if ( pDocSh && nIndex >= 0 && nIndex < sal::static_int_cast<sal_Int32>(rRanges.Count()) )
4187 ScRange aRange(*rRanges.GetObject(nIndex));
4188 if ( aRange.aStart == aRange.aEnd )
4189 return new ScCellObj( pDocSh, aRange.aStart );
4190 else
4191 return new ScCellRangeObj( pDocSh, aRange );
4194 return NULL; // keine DocShell oder falscher Index
4197 uno::Sequence<table::CellRangeAddress> SAL_CALL ScCellRangesObj::getRangeAddresses()
4198 throw(uno::RuntimeException)
4200 ScUnoGuard aGuard;
4201 ScDocShell* pDocSh = GetDocShell();
4202 const ScRangeList& rRanges = GetRangeList();
4203 ULONG nCount = rRanges.Count();
4204 if ( pDocSh && nCount )
4206 table::CellRangeAddress aRangeAddress;
4207 uno::Sequence<table::CellRangeAddress> aSeq(nCount);
4208 table::CellRangeAddress* pAry = aSeq.getArray();
4209 for (sal_uInt32 i=0; i<nCount; i++)
4211 ScUnoConversion::FillApiRange( aRangeAddress, *rRanges.GetObject(i) );
4212 pAry[i] = aRangeAddress;
4214 return aSeq;
4217 return uno::Sequence<table::CellRangeAddress>(0); // leer ist moeglich
4220 uno::Reference<container::XEnumerationAccess> SAL_CALL ScCellRangesObj::getCells()
4221 throw(uno::RuntimeException)
4223 ScUnoGuard aGuard;
4225 // getCells with empty range list is possible (no exception),
4226 // the resulting enumeration just has no elements
4227 // (same behaviour as a valid range with no cells)
4228 // This is handled in ScCellsEnumeration ctor.
4230 const ScRangeList& rRanges = GetRangeList();
4231 ScDocShell* pDocSh = GetDocShell();
4232 if (pDocSh)
4233 return new ScCellsObj( pDocSh, rRanges );
4234 return NULL;
4237 rtl::OUString SAL_CALL ScCellRangesObj::getRangeAddressesAsString()
4238 throw(uno::RuntimeException)
4240 ScUnoGuard aGuard;
4241 String aString;
4242 ScDocShell* pDocSh = GetDocShell();
4243 const ScRangeList& rRanges = GetRangeList();
4244 if (pDocSh)
4245 rRanges.Format( aString, SCA_VALID | SCA_TAB_3D, pDocSh->GetDocument() );
4246 return aString;
4249 // XSheetCellRangeContainer
4251 void SAL_CALL ScCellRangesObj::addRangeAddress( const table::CellRangeAddress& rRange,
4252 sal_Bool bMergeRanges )
4253 throw(::com::sun::star::uno::RuntimeException)
4255 ScUnoGuard aGuard;
4256 ScRange aRange(static_cast<SCCOL>(rRange.StartColumn),
4257 static_cast<SCROW>(rRange.StartRow),
4258 static_cast<SCTAB>(rRange.Sheet),
4259 static_cast<SCCOL>(rRange.EndColumn),
4260 static_cast<SCROW>(rRange.EndRow),
4261 static_cast<SCTAB>(rRange.Sheet));
4262 AddRange(aRange, bMergeRanges);
4265 void lcl_RemoveNamedEntry( ScNamedEntryArr_Impl& rNamedEntries, const ScRange& rRange )
4267 USHORT nCount = rNamedEntries.Count();
4268 for ( USHORT n=nCount; n--; )
4269 if ( rNamedEntries[n]->GetRange() == rRange )
4270 rNamedEntries.DeleteAndDestroy( n );
4273 void SAL_CALL ScCellRangesObj::removeRangeAddress( const table::CellRangeAddress& rRange )
4274 throw(::com::sun::star::container::NoSuchElementException,
4275 ::com::sun::star::uno::RuntimeException)
4277 ScUnoGuard aGuard;
4278 const ScRangeList& rRanges = GetRangeList();
4280 ScRangeList aSheetRanges;
4281 ScRangeList aNotSheetRanges;
4282 for (sal_uInt32 i = 0; i < rRanges.Count(); ++i)
4284 if (rRanges.GetObject(i)->aStart.Tab() == rRange.Sheet)
4286 aSheetRanges.Append(*rRanges.GetObject(i));
4288 else
4290 aNotSheetRanges.Append(*rRanges.GetObject(i));
4293 ScMarkData aMarkData;
4294 aMarkData.MarkFromRangeList( aSheetRanges, FALSE );
4295 ScRange aRange(static_cast<SCCOL>(rRange.StartColumn),
4296 static_cast<SCROW>(rRange.StartRow),
4297 static_cast<SCTAB>(rRange.Sheet),
4298 static_cast<SCCOL>(rRange.EndColumn),
4299 static_cast<SCROW>(rRange.EndRow),
4300 static_cast<SCTAB>(rRange.Sheet));
4301 if (aMarkData.GetTableSelect( aRange.aStart.Tab() ))
4303 aMarkData.MarkToMulti();
4304 if (aMarkData.IsAllMarked( aRange ) )
4306 aMarkData.SetMultiMarkArea( aRange, FALSE );
4307 lcl_RemoveNamedEntry(aNamedEntries, aRange);
4309 else
4310 throw container::NoSuchElementException();
4312 SetNewRanges(aNotSheetRanges);
4313 ScRangeList aNew;
4314 aMarkData.FillRangeListWithMarks( &aNew, FALSE );
4315 for (sal_uInt32 j = 0; j < aNew.Count(); ++j)
4317 AddRange(*aNew.GetObject(j), sal_False);
4321 void SAL_CALL ScCellRangesObj::addRangeAddresses( const uno::Sequence<table::CellRangeAddress >& rRanges,
4322 sal_Bool bMergeRanges )
4323 throw(::com::sun::star::uno::RuntimeException)
4325 ScUnoGuard aGuard;
4326 sal_Int32 nCount(rRanges.getLength());
4327 if (nCount)
4329 const table::CellRangeAddress* pRanges = rRanges.getConstArray();
4330 for (sal_Int32 i = 0; i < rRanges.getLength(); i++, pRanges++)
4332 ScRange aRange(static_cast<SCCOL>(pRanges->StartColumn),
4333 static_cast<SCROW>(pRanges->StartRow),
4334 static_cast<SCTAB>(pRanges->Sheet),
4335 static_cast<SCCOL>(pRanges->EndColumn),
4336 static_cast<SCROW>(pRanges->EndRow),
4337 static_cast<SCTAB>(pRanges->Sheet));
4338 AddRange(aRange, bMergeRanges);
4343 void SAL_CALL ScCellRangesObj::removeRangeAddresses( const uno::Sequence<table::CellRangeAddress >& rRangeSeq )
4344 throw(::com::sun::star::container::NoSuchElementException,
4345 ::com::sun::star::uno::RuntimeException)
4347 // with this implementation not needed
4348 // ScUnoGuard aGuard;
4351 // use sometimes a better/faster implementation
4352 sal_uInt32 nCount(rRangeSeq.getLength());
4353 if (nCount)
4355 const table::CellRangeAddress* pRanges = rRangeSeq.getConstArray();
4356 for (sal_uInt32 i=0; i < nCount; ++i, ++pRanges)
4358 removeRangeAddress(*pRanges);
4363 // XNameContainer
4365 void lcl_RemoveNamedEntry( ScNamedEntryArr_Impl& rNamedEntries, const String& rName )
4367 USHORT nCount = rNamedEntries.Count();
4368 for ( USHORT n=nCount; n--; )
4369 if ( rNamedEntries[n]->GetName() == rName )
4370 rNamedEntries.DeleteAndDestroy( n );
4373 void SAL_CALL ScCellRangesObj::insertByName( const rtl::OUString& aName, const uno::Any& aElement )
4374 throw(lang::IllegalArgumentException, container::ElementExistException,
4375 lang::WrappedTargetException, uno::RuntimeException)
4377 ScUnoGuard aGuard;
4378 ScDocShell* pDocSh = GetDocShell();
4379 BOOL bDone = FALSE;
4381 //! Type of aElement can be some specific interface instead of XInterface
4383 uno::Reference<uno::XInterface> xInterface(aElement, uno::UNO_QUERY);
4384 if ( pDocSh && xInterface.is() )
4386 ScCellRangesBase* pRangesImp = ScCellRangesBase::getImplementation( xInterface );
4387 if ( pRangesImp && pRangesImp->GetDocShell() == pDocSh )
4389 // if explicit name is given and already existing, throw exception
4391 String aNamStr(aName);
4392 if ( aNamStr.Len() )
4394 USHORT nNamedCount = aNamedEntries.Count();
4395 for (USHORT n=0; n<nNamedCount; n++)
4396 if ( aNamedEntries[n]->GetName() == aNamStr )
4397 throw container::ElementExistException();
4400 ScRangeList aNew(GetRangeList());
4401 const ScRangeList& rAddRanges = pRangesImp->GetRangeList();
4402 ULONG nAddCount = rAddRanges.Count();
4403 for (ULONG i=0; i<nAddCount; i++)
4404 aNew.Join( *rAddRanges.GetObject(i) );
4405 SetNewRanges(aNew);
4406 bDone = TRUE;
4408 if ( aName.getLength() && nAddCount == 1 )
4410 // if a name is given, also insert into list of named entries
4411 // (only possible for a single range)
4412 // name is not in aNamedEntries (tested above)
4414 ScNamedEntry* pEntry = new ScNamedEntry( aNamStr, *rAddRanges.GetObject(0) );
4415 aNamedEntries.Insert( pEntry, aNamedEntries.Count() );
4420 if (!bDone)
4422 // invalid element - double names are handled above
4423 throw lang::IllegalArgumentException();
4427 BOOL lcl_FindRangeByName( const ScRangeList& rRanges, ScDocShell* pDocSh,
4428 const String& rName, ULONG& rIndex )
4430 if (pDocSh)
4432 String aRangeStr;
4433 ScDocument* pDoc = pDocSh->GetDocument();
4434 ULONG nCount = rRanges.Count();
4435 for (ULONG i=0; i<nCount; i++)
4437 rRanges.GetObject(i)->Format( aRangeStr, SCA_VALID | SCA_TAB_3D, pDoc );
4438 if ( aRangeStr == rName )
4440 rIndex = i;
4441 return TRUE;
4445 return FALSE; // nicht gefunden
4448 BOOL lcl_FindRangeOrEntry( const ScNamedEntryArr_Impl& rNamedEntries,
4449 const ScRangeList& rRanges, ScDocShell* pDocSh,
4450 const String& rName, ScRange& rFound )
4452 // exact range in list?
4454 ULONG nIndex = 0;
4455 if ( lcl_FindRangeByName( rRanges, pDocSh, rName, nIndex ) )
4457 rFound = *rRanges.GetObject(nIndex);
4458 return TRUE;
4461 // range contained in selection? (sheet must be specified)
4463 ScRange aCellRange;
4464 USHORT nParse = aCellRange.ParseAny( rName, pDocSh->GetDocument() );
4465 if ( ( nParse & ( SCA_VALID | SCA_TAB_3D ) ) == ( SCA_VALID | SCA_TAB_3D ) )
4467 ScMarkData aMarkData;
4468 aMarkData.MarkFromRangeList( rRanges, FALSE );
4469 aMarkData.MarkToMulti(); // needed for IsAllMarked
4470 if ( aMarkData.IsAllMarked( aCellRange ) )
4472 rFound = aCellRange;
4473 return TRUE;
4477 // named entry in this object?
4479 if ( rNamedEntries.Count() )
4481 for ( USHORT n=0; n<rNamedEntries.Count(); n++ )
4482 if ( rNamedEntries[n]->GetName() == rName )
4484 // test if named entry is contained in rRanges
4486 const ScRange& rComp = rNamedEntries[n]->GetRange();
4487 ScMarkData aMarkData;
4488 aMarkData.MarkFromRangeList( rRanges, FALSE );
4489 aMarkData.MarkToMulti(); // needed for IsAllMarked
4490 if ( aMarkData.IsAllMarked( rComp ) )
4492 rFound = rComp;
4493 return TRUE;
4498 return FALSE; // not found
4501 void SAL_CALL ScCellRangesObj::removeByName( const rtl::OUString& aName )
4502 throw(container::NoSuchElementException,
4503 lang::WrappedTargetException, uno::RuntimeException)
4505 ScUnoGuard aGuard;
4506 BOOL bDone = FALSE;
4507 String aNameStr(aName);
4508 ScDocShell* pDocSh = GetDocShell();
4509 const ScRangeList& rRanges = GetRangeList();
4510 ULONG nIndex = 0;
4511 if ( lcl_FindRangeByName( rRanges, pDocSh, aNameStr, nIndex ) )
4513 // einzelnen Range weglassen
4514 ScRangeList aNew;
4515 ULONG nCount = rRanges.Count();
4516 for (ULONG i=0; i<nCount; i++)
4517 if (i != nIndex)
4518 aNew.Append( *rRanges.GetObject(i) );
4519 SetNewRanges(aNew);
4520 bDone = TRUE;
4522 else if (pDocSh)
4524 // deselect any ranges (parsed or named entry)
4525 ScRangeList aDiff;
4526 BOOL bValid = ( aDiff.Parse( aNameStr, pDocSh->GetDocument() ) & SCA_VALID ) != 0;
4527 if ( !bValid && aNamedEntries.Count() )
4529 USHORT nCount = aNamedEntries.Count();
4530 for (USHORT n=0; n<nCount && !bValid; n++)
4531 if (aNamedEntries[n]->GetName() == aNameStr)
4533 aDiff.RemoveAll();
4534 aDiff.Append( aNamedEntries[n]->GetRange() );
4535 bValid = TRUE;
4538 if ( bValid )
4540 ScMarkData aMarkData;
4541 aMarkData.MarkFromRangeList( rRanges, FALSE );
4543 ULONG nDiffCount = aDiff.Count();
4544 for (ULONG i=0; i<nDiffCount; i++)
4546 ScRange* pDiffRange = aDiff.GetObject(i);
4547 if (aMarkData.GetTableSelect( pDiffRange->aStart.Tab() ))
4548 aMarkData.SetMultiMarkArea( *pDiffRange, FALSE );
4551 ScRangeList aNew;
4552 aMarkData.FillRangeListWithMarks( &aNew, FALSE );
4553 SetNewRanges(aNew);
4555 bDone = TRUE; //! error if range was not selected before?
4559 if (aNamedEntries.Count())
4560 lcl_RemoveNamedEntry( aNamedEntries, aNameStr ); // remove named entry
4562 if (!bDone)
4563 throw container::NoSuchElementException(); // not found
4566 // XNameReplace
4568 void SAL_CALL ScCellRangesObj::replaceByName( const rtl::OUString& aName, const uno::Any& aElement )
4569 throw(lang::IllegalArgumentException, container::NoSuchElementException,
4570 lang::WrappedTargetException, uno::RuntimeException)
4572 ScUnoGuard aGuard;
4573 //! zusammenfassen?
4574 removeByName( aName );
4575 insertByName( aName, aElement );
4578 // XNameAccess
4580 uno::Any SAL_CALL ScCellRangesObj::getByName( const rtl::OUString& aName )
4581 throw(container::NoSuchElementException,
4582 lang::WrappedTargetException, uno::RuntimeException)
4584 ScUnoGuard aGuard;
4585 uno::Any aRet;
4587 String aNameStr(aName);
4588 ScDocShell* pDocSh = GetDocShell();
4589 const ScRangeList& rRanges = GetRangeList();
4590 ScRange aRange;
4591 if ( lcl_FindRangeOrEntry( aNamedEntries, rRanges, pDocSh, aNameStr, aRange ) )
4593 uno::Reference<table::XCellRange> xRange;
4594 if ( aRange.aStart == aRange.aEnd )
4595 xRange.set(new ScCellObj( pDocSh, aRange.aStart ));
4596 else
4597 xRange.set(new ScCellRangeObj( pDocSh, aRange ));
4598 aRet <<= xRange;
4600 else
4601 throw container::NoSuchElementException();
4602 return aRet;
4605 BOOL lcl_FindEntryName( const ScNamedEntryArr_Impl& rNamedEntries,
4606 const ScRange& rRange, String& rName )
4608 USHORT nCount = rNamedEntries.Count();
4609 for (USHORT i=0; i<nCount; i++)
4610 if (rNamedEntries[i]->GetRange() == rRange)
4612 rName = rNamedEntries[i]->GetName();
4613 return TRUE;
4615 return FALSE;
4618 uno::Sequence<rtl::OUString> SAL_CALL ScCellRangesObj::getElementNames()
4619 throw(uno::RuntimeException)
4621 ScUnoGuard aGuard;
4623 ScDocShell* pDocSh = GetDocShell();
4624 const ScRangeList& rRanges = GetRangeList();
4625 if (pDocSh)
4627 String aRangeStr;
4628 ScDocument* pDoc = pDocSh->GetDocument();
4629 ULONG nCount = rRanges.Count();
4631 uno::Sequence<rtl::OUString> aSeq(nCount);
4632 rtl::OUString* pAry = aSeq.getArray();
4633 for (ULONG i=0; i<nCount; i++)
4635 // use given name if for exactly this range, otherwise just format
4636 ScRange aRange = *rRanges.GetObject(i);
4637 if ( !aNamedEntries.Count() || !lcl_FindEntryName( aNamedEntries, aRange, aRangeStr ) )
4638 aRange.Format( aRangeStr, SCA_VALID | SCA_TAB_3D, pDoc );
4639 pAry[i] = aRangeStr;
4641 return aSeq;
4643 return uno::Sequence<rtl::OUString>(0);
4646 sal_Bool SAL_CALL ScCellRangesObj::hasByName( const rtl::OUString& aName )
4647 throw(uno::RuntimeException)
4649 ScUnoGuard aGuard;
4650 String aNameStr(aName);
4651 ScDocShell* pDocSh = GetDocShell();
4652 const ScRangeList& rRanges = GetRangeList();
4653 ScRange aRange;
4654 return lcl_FindRangeOrEntry( aNamedEntries, rRanges, pDocSh, aNameStr, aRange );
4657 // XEnumerationAccess
4659 uno::Reference<container::XEnumeration> SAL_CALL ScCellRangesObj::createEnumeration()
4660 throw(uno::RuntimeException)
4662 ScUnoGuard aGuard;
4663 return new ScIndexEnumeration(this, rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.sheet.SheetCellRangesEnumeration")));
4666 // XIndexAccess
4668 sal_Int32 SAL_CALL ScCellRangesObj::getCount() throw(uno::RuntimeException)
4670 ScUnoGuard aGuard;
4671 const ScRangeList& rRanges = GetRangeList();
4672 return rRanges.Count();
4675 uno::Any SAL_CALL ScCellRangesObj::getByIndex( sal_Int32 nIndex )
4676 throw(lang::IndexOutOfBoundsException,
4677 lang::WrappedTargetException, uno::RuntimeException)
4679 ScUnoGuard aGuard;
4680 uno::Reference<table::XCellRange> xRange(GetObjectByIndex_Impl(nIndex));
4681 if (xRange.is())
4682 return uno::makeAny(xRange);
4683 else
4684 throw lang::IndexOutOfBoundsException();
4685 // return uno::Any();
4688 uno::Type SAL_CALL ScCellRangesObj::getElementType() throw(uno::RuntimeException)
4690 ScUnoGuard aGuard;
4691 return getCppuType((uno::Reference<table::XCellRange>*)0);
4694 sal_Bool SAL_CALL ScCellRangesObj::hasElements() throw(uno::RuntimeException)
4696 ScUnoGuard aGuard;
4697 const ScRangeList& rRanges = GetRangeList();
4698 return rRanges.Count() != 0;
4701 // XServiceInfo
4703 rtl::OUString SAL_CALL ScCellRangesObj::getImplementationName() throw(uno::RuntimeException)
4705 return rtl::OUString::createFromAscii( "ScCellRangesObj" );
4708 sal_Bool SAL_CALL ScCellRangesObj::supportsService( const rtl::OUString& rServiceName )
4709 throw(uno::RuntimeException)
4711 String aServiceStr(rServiceName);
4712 return aServiceStr.EqualsAscii( SCSHEETCELLRANGES_SERVICE ) ||
4713 aServiceStr.EqualsAscii( SCCELLPROPERTIES_SERVICE ) ||
4714 aServiceStr.EqualsAscii( SCCHARPROPERTIES_SERVICE ) ||
4715 aServiceStr.EqualsAscii( SCPARAPROPERTIES_SERVICE );
4718 uno::Sequence<rtl::OUString> SAL_CALL ScCellRangesObj::getSupportedServiceNames()
4719 throw(uno::RuntimeException)
4721 uno::Sequence<rtl::OUString> aRet(4);
4722 rtl::OUString* pArray = aRet.getArray();
4723 pArray[0] = rtl::OUString::createFromAscii( SCSHEETCELLRANGES_SERVICE );
4724 pArray[1] = rtl::OUString::createFromAscii( SCCELLPROPERTIES_SERVICE );
4725 pArray[2] = rtl::OUString::createFromAscii( SCCHARPROPERTIES_SERVICE );
4726 pArray[3] = rtl::OUString::createFromAscii( SCPARAPROPERTIES_SERVICE );
4727 return aRet;
4730 //------------------------------------------------------------------------
4732 // static
4733 uno::Reference<table::XCellRange> ScCellRangeObj::CreateRangeFromDoc( ScDocument* pDoc, const ScRange& rR )
4735 SfxObjectShell* pObjSh = pDoc->GetDocumentShell();
4736 if ( pObjSh && pObjSh->ISA(ScDocShell) )
4737 return new ScCellRangeObj( (ScDocShell*) pObjSh, rR );
4738 return NULL;
4741 //------------------------------------------------------------------------
4743 ScCellRangeObj::ScCellRangeObj(ScDocShell* pDocSh, const ScRange& rR) :
4744 ScCellRangesBase( pDocSh, rR ),
4745 pRangePropSet( lcl_GetRangePropertySet() ),
4746 aRange( rR )
4748 aRange.Justify(); // Anfang / Ende richtig
4751 ScCellRangeObj::~ScCellRangeObj()
4755 void ScCellRangeObj::RefChanged()
4757 ScCellRangesBase::RefChanged();
4759 const ScRangeList& rRanges = GetRangeList();
4760 DBG_ASSERT(rRanges.Count() == 1, "was fuer Ranges ?!?!");
4761 const ScRange* pFirst = rRanges.GetObject(0);
4762 if (pFirst)
4764 aRange = *pFirst;
4765 aRange.Justify();
4769 uno::Any SAL_CALL ScCellRangeObj::queryInterface( const uno::Type& rType )
4770 throw(uno::RuntimeException)
4772 SC_QUERYINTERFACE( sheet::XCellRangeAddressable )
4773 SC_QUERYINTERFACE( table::XCellRange )
4774 SC_QUERYINTERFACE( sheet::XSheetCellRange )
4775 SC_QUERYINTERFACE( sheet::XArrayFormulaRange )
4776 SC_QUERYINTERFACE( sheet::XArrayFormulaTokens )
4777 SC_QUERYINTERFACE( sheet::XCellRangeData )
4778 SC_QUERYINTERFACE( sheet::XCellRangeFormula )
4779 SC_QUERYINTERFACE( sheet::XMultipleOperation )
4780 SC_QUERYINTERFACE( util::XMergeable )
4781 SC_QUERYINTERFACE( sheet::XCellSeries )
4782 SC_QUERYINTERFACE( table::XAutoFormattable )
4783 SC_QUERYINTERFACE( util::XSortable )
4784 SC_QUERYINTERFACE( sheet::XSheetFilterableEx )
4785 SC_QUERYINTERFACE( sheet::XSheetFilterable )
4786 SC_QUERYINTERFACE( sheet::XSubTotalCalculatable )
4787 SC_QUERYINTERFACE( table::XColumnRowRange )
4788 SC_QUERYINTERFACE( util::XImportable )
4789 SC_QUERYINTERFACE( sheet::XCellFormatRangesSupplier )
4790 SC_QUERYINTERFACE( sheet::XUniqueCellFormatRangesSupplier )
4792 return ScCellRangesBase::queryInterface( rType );
4795 void SAL_CALL ScCellRangeObj::acquire() throw()
4797 ScCellRangesBase::acquire();
4800 void SAL_CALL ScCellRangeObj::release() throw()
4802 ScCellRangesBase::release();
4805 uno::Sequence<uno::Type> SAL_CALL ScCellRangeObj::getTypes() throw(uno::RuntimeException)
4807 static uno::Sequence<uno::Type> aTypes;
4808 if ( aTypes.getLength() == 0 )
4810 uno::Sequence<uno::Type> aParentTypes(ScCellRangesBase::getTypes());
4811 long nParentLen = aParentTypes.getLength();
4812 const uno::Type* pParentPtr = aParentTypes.getConstArray();
4814 aTypes.realloc( nParentLen + 17 );
4815 uno::Type* pPtr = aTypes.getArray();
4816 pPtr[nParentLen + 0] = getCppuType((const uno::Reference<sheet::XCellRangeAddressable>*)0);
4817 pPtr[nParentLen + 1] = getCppuType((const uno::Reference<sheet::XSheetCellRange>*)0);
4818 pPtr[nParentLen + 2] = getCppuType((const uno::Reference<sheet::XArrayFormulaRange>*)0);
4819 pPtr[nParentLen + 3] = getCppuType((const uno::Reference<sheet::XArrayFormulaTokens>*)0);
4820 pPtr[nParentLen + 4] = getCppuType((const uno::Reference<sheet::XCellRangeData>*)0);
4821 pPtr[nParentLen + 5] = getCppuType((const uno::Reference<sheet::XCellRangeFormula>*)0);
4822 pPtr[nParentLen + 6] = getCppuType((const uno::Reference<sheet::XMultipleOperation>*)0);
4823 pPtr[nParentLen + 7] = getCppuType((const uno::Reference<util::XMergeable>*)0);
4824 pPtr[nParentLen + 8] = getCppuType((const uno::Reference<sheet::XCellSeries>*)0);
4825 pPtr[nParentLen + 9] = getCppuType((const uno::Reference<table::XAutoFormattable>*)0);
4826 pPtr[nParentLen +10] = getCppuType((const uno::Reference<util::XSortable>*)0);
4827 pPtr[nParentLen +11] = getCppuType((const uno::Reference<sheet::XSheetFilterableEx>*)0);
4828 pPtr[nParentLen +12] = getCppuType((const uno::Reference<sheet::XSubTotalCalculatable>*)0);
4829 pPtr[nParentLen +13] = getCppuType((const uno::Reference<table::XColumnRowRange>*)0);
4830 pPtr[nParentLen +14] = getCppuType((const uno::Reference<util::XImportable>*)0);
4831 pPtr[nParentLen +15] = getCppuType((const uno::Reference<sheet::XCellFormatRangesSupplier>*)0);
4832 pPtr[nParentLen +16] = getCppuType((const uno::Reference<sheet::XUniqueCellFormatRangesSupplier>*)0);
4834 for (long i=0; i<nParentLen; i++)
4835 pPtr[i] = pParentPtr[i]; // parent types first
4837 return aTypes;
4840 uno::Sequence<sal_Int8> SAL_CALL ScCellRangeObj::getImplementationId()
4841 throw(uno::RuntimeException)
4843 static uno::Sequence< sal_Int8 > aId;
4844 if( aId.getLength() == 0 )
4846 aId.realloc( 16 );
4847 rtl_createUuid( (sal_uInt8 *)aId.getArray(), 0, sal_True );
4849 return aId;
4852 // XCellRange
4854 // ColumnCount / RowCount sind weggefallen
4855 //! werden im Writer fuer Tabellen noch gebraucht ???
4857 uno::Reference<table::XCell> ScCellRangeObj::GetCellByPosition_Impl(
4858 sal_Int32 nColumn, sal_Int32 nRow )
4859 throw(lang::IndexOutOfBoundsException, uno::RuntimeException)
4861 ScDocShell* pDocSh = GetDocShell();
4862 if (!pDocSh)
4863 throw uno::RuntimeException();
4865 if ( nColumn >= 0 && nRow >= 0 )
4867 sal_Int32 nPosX = aRange.aStart.Col() + nColumn;
4868 sal_Int32 nPosY = aRange.aStart.Row() + nRow;
4870 if ( nPosX <= aRange.aEnd.Col() && nPosY <= aRange.aEnd.Row() )
4872 ScAddress aNew( (SCCOL)nPosX, (SCROW)nPosY, aRange.aStart.Tab() );
4873 return new ScCellObj( pDocSh, aNew );
4877 throw lang::IndexOutOfBoundsException();
4878 // return NULL;
4881 uno::Reference<table::XCell> SAL_CALL ScCellRangeObj::getCellByPosition(
4882 sal_Int32 nColumn, sal_Int32 nRow )
4883 throw(lang::IndexOutOfBoundsException, uno::RuntimeException)
4885 ScUnoGuard aGuard;
4887 return GetCellByPosition_Impl(nColumn, nRow);
4890 uno::Reference<table::XCellRange> SAL_CALL ScCellRangeObj::getCellRangeByPosition(
4891 sal_Int32 nLeft, sal_Int32 nTop, sal_Int32 nRight, sal_Int32 nBottom )
4892 throw(lang::IndexOutOfBoundsException, uno::RuntimeException)
4894 ScUnoGuard aGuard;
4896 ScDocShell* pDocSh = GetDocShell();
4897 if (!pDocSh)
4898 throw uno::RuntimeException();
4900 if ( nLeft >= 0 && nTop >= 0 && nRight >= 0 && nBottom >= 0 )
4902 sal_Int32 nStartX = aRange.aStart.Col() + nLeft;
4903 sal_Int32 nStartY = aRange.aStart.Row() + nTop;
4904 sal_Int32 nEndX = aRange.aStart.Col() + nRight;
4905 sal_Int32 nEndY = aRange.aStart.Row() + nBottom;
4907 if ( nStartX <= nEndX && nEndX <= aRange.aEnd.Col() &&
4908 nStartY <= nEndY && nEndY <= aRange.aEnd.Row() )
4910 ScRange aNew( (SCCOL)nStartX, (SCROW)nStartY, aRange.aStart.Tab(),
4911 (SCCOL)nEndX, (SCROW)nEndY, aRange.aEnd.Tab() );
4912 return new ScCellRangeObj( pDocSh, aNew );
4916 throw lang::IndexOutOfBoundsException();
4917 // return NULL;
4921 uno::Reference<table::XCellRange> SAL_CALL ScCellRangeObj::getCellRangeByName(
4922 const rtl::OUString& aName ) throw(uno::RuntimeException)
4924 return getCellRangeByName( aName, ScAddress::detailsOOOa1 );
4927 uno::Reference<table::XCellRange> ScCellRangeObj::getCellRangeByName(
4928 const rtl::OUString& aName, const ScAddress::Details& rDetails ) throw(uno::RuntimeException)
4930 // name refers to the whole document (with the range's table as default),
4931 // valid only if the range is within this range
4933 ScUnoGuard aGuard;
4934 ScDocShell* pDocSh = GetDocShell();
4935 if ( pDocSh )
4937 ScDocument* pDoc = pDocSh->GetDocument();
4938 SCTAB nTab = aRange.aStart.Tab();
4940 ScRange aCellRange;
4941 BOOL bFound = FALSE;
4942 String aString(aName);
4943 USHORT nParse = aCellRange.ParseAny( aString, pDoc, rDetails );
4944 if ( nParse & SCA_VALID )
4946 if ( !(nParse & SCA_TAB_3D) ) // keine Tabelle angegeben -> auf dieser Tabelle
4948 aCellRange.aStart.SetTab(nTab);
4949 aCellRange.aEnd.SetTab(nTab);
4951 bFound = TRUE;
4953 else
4955 ScRangeUtil aRangeUtil;
4956 if ( aRangeUtil.MakeRangeFromName( aString, pDoc, nTab, aCellRange, RUTL_NAMES ) ||
4957 aRangeUtil.MakeRangeFromName( aString, pDoc, nTab, aCellRange, RUTL_DBASE ) )
4958 bFound = TRUE;
4961 if (bFound) // valid only if within this object's range
4963 if (!aRange.In(aCellRange))
4964 bFound = FALSE;
4967 if (bFound)
4969 if ( aCellRange.aStart == aCellRange.aEnd )
4970 return new ScCellObj( pDocSh, aCellRange.aStart );
4971 else
4972 return new ScCellRangeObj( pDocSh, aCellRange );
4976 throw uno::RuntimeException();
4977 // return NULL;
4980 // XColumnRowRange
4982 uno::Reference<table::XTableColumns> SAL_CALL ScCellRangeObj::getColumns() throw(uno::RuntimeException)
4984 ScUnoGuard aGuard;
4985 ScDocShell* pDocSh = GetDocShell();
4986 if (pDocSh)
4987 return new ScTableColumnsObj( pDocSh, aRange.aStart.Tab(),
4988 aRange.aStart.Col(), aRange.aEnd.Col() );
4990 DBG_ERROR("Dokument ungueltig");
4991 return NULL;
4994 uno::Reference<table::XTableRows> SAL_CALL ScCellRangeObj::getRows() throw(uno::RuntimeException)
4996 ScUnoGuard aGuard;
4997 ScDocShell* pDocSh = GetDocShell();
4998 if (pDocSh)
4999 return new ScTableRowsObj( pDocSh, aRange.aStart.Tab(),
5000 aRange.aStart.Row(), aRange.aEnd.Row() );
5002 DBG_ERROR("Dokument ungueltig");
5003 return NULL;
5006 // XAddressableCellRange
5008 table::CellRangeAddress SAL_CALL ScCellRangeObj::getRangeAddress() throw(uno::RuntimeException)
5010 ScUnoGuard aGuard;
5011 table::CellRangeAddress aRet;
5012 ScUnoConversion::FillApiRange( aRet, aRange );
5013 return aRet;
5016 // XSheetCellRange
5018 uno::Reference<sheet::XSpreadsheet> SAL_CALL ScCellRangeObj::getSpreadsheet()
5019 throw(uno::RuntimeException)
5021 ScUnoGuard aGuard;
5022 ScDocShell* pDocSh = GetDocShell();
5023 if (pDocSh)
5024 return new ScTableSheetObj( pDocSh, aRange.aStart.Tab() );
5026 DBG_ERROR("Dokument ungueltig");
5027 return NULL;
5030 // XArrayFormulaRange
5032 rtl::OUString SAL_CALL ScCellRangeObj::getArrayFormula() throw(uno::RuntimeException)
5034 ScUnoGuard aGuard;
5036 // Matrix-Formel, wenn eindeutig Teil einer Matrix,
5037 // also wenn Anfang und Ende des Blocks zur selben Matrix gehoeren.
5038 // Sonst Leerstring.
5040 String aFormula;
5041 ScDocShell* pDocSh = GetDocShell();
5042 if (pDocSh)
5044 ScDocument* pDoc = pDocSh->GetDocument();
5045 const ScBaseCell* pCell1 = pDoc->GetCell( aRange.aStart );
5046 const ScBaseCell* pCell2 = pDoc->GetCell( aRange.aEnd );
5047 if ( pCell1 && pCell2 && pCell1->GetCellType() == CELLTYPE_FORMULA &&
5048 pCell2->GetCellType() == CELLTYPE_FORMULA )
5050 const ScFormulaCell* pFCell1 = (const ScFormulaCell*)pCell1;
5051 const ScFormulaCell* pFCell2 = (const ScFormulaCell*)pCell2;
5052 ScAddress aStart1;
5053 ScAddress aStart2;
5054 if ( pFCell1->GetMatrixOrigin( aStart1 ) && pFCell2->GetMatrixOrigin( aStart2 ) )
5056 if ( aStart1 == aStart2 ) // beides dieselbe Matrix
5057 pFCell1->GetFormula( aFormula ); // egal, von welcher Zelle
5061 return aFormula;
5064 void ScCellRangeObj::SetArrayFormula_Impl( const rtl::OUString& rFormula,
5065 const rtl::OUString& rFormulaNmsp, const formula::FormulaGrammar::Grammar eGrammar ) throw(uno::RuntimeException)
5067 ScDocShell* pDocSh = GetDocShell();
5068 if (pDocSh)
5070 ScDocFunc aFunc(*pDocSh);
5071 if ( rFormula.getLength() )
5073 if ( ScTableSheetObj::getImplementation( (cppu::OWeakObject*)this ) )
5075 // #74681# don't set array formula for sheet object
5076 throw uno::RuntimeException();
5079 aFunc.EnterMatrix( aRange, NULL, NULL, rFormula, TRUE, TRUE, rFormulaNmsp, eGrammar );
5081 else
5083 // empty string -> erase array formula
5084 ScMarkData aMark;
5085 aMark.SetMarkArea( aRange );
5086 aMark.SelectTable( aRange.aStart.Tab(), TRUE );
5087 aFunc.DeleteContents( aMark, IDF_CONTENTS, TRUE, TRUE );
5092 void SAL_CALL ScCellRangeObj::setArrayFormula( const rtl::OUString& aFormula )
5093 throw(uno::RuntimeException)
5095 ScUnoGuard aGuard;
5096 // GRAM_PODF_A1 for API compatibility.
5097 SetArrayFormula_Impl( aFormula, ::rtl::OUString(), formula::FormulaGrammar::GRAM_PODF_A1);
5100 void ScCellRangeObj::SetArrayFormulaWithGrammar( const rtl::OUString& rFormula,
5101 const rtl::OUString& rFormulaNmsp, const formula::FormulaGrammar::Grammar eGrammar ) throw(uno::RuntimeException)
5103 ScUnoGuard aGuard;
5104 SetArrayFormula_Impl( rFormula, rFormulaNmsp, eGrammar);
5107 // XArrayFormulaTokens
5109 uno::Sequence<sheet::FormulaToken> SAL_CALL ScCellRangeObj::getArrayTokens() throw(uno::RuntimeException)
5111 ScUnoGuard aGuard;
5113 // same cell logic as in getArrayFormula
5115 uno::Sequence<sheet::FormulaToken> aSequence;
5116 ScDocShell* pDocSh = GetDocShell();
5117 if ( pDocSh )
5119 ScDocument* pDoc = pDocSh->GetDocument();
5120 const ScBaseCell* pCell1 = pDoc->GetCell( aRange.aStart );
5121 const ScBaseCell* pCell2 = pDoc->GetCell( aRange.aEnd );
5122 if ( pCell1 && pCell2 && pCell1->GetCellType() == CELLTYPE_FORMULA &&
5123 pCell2->GetCellType() == CELLTYPE_FORMULA )
5125 const ScFormulaCell* pFCell1 = (const ScFormulaCell*)pCell1;
5126 const ScFormulaCell* pFCell2 = (const ScFormulaCell*)pCell2;
5127 ScAddress aStart1;
5128 ScAddress aStart2;
5129 if ( pFCell1->GetMatrixOrigin( aStart1 ) && pFCell2->GetMatrixOrigin( aStart2 ) )
5131 if ( aStart1 == aStart2 )
5133 ScTokenArray* pTokenArray = pFCell1->GetCode();
5134 if ( pTokenArray )
5135 (void)ScTokenConversion::ConvertToTokenSequence( *pDoc, aSequence, *pTokenArray );
5140 return aSequence;
5143 void SAL_CALL ScCellRangeObj::setArrayTokens( const uno::Sequence<sheet::FormulaToken>& rTokens ) throw(uno::RuntimeException)
5145 ScUnoGuard aGuard;
5146 ScDocShell* pDocSh = GetDocShell();
5147 if ( pDocSh )
5149 ScDocFunc aFunc(*pDocSh);
5150 if ( rTokens.getLength() )
5152 if ( ScTableSheetObj::getImplementation( (cppu::OWeakObject*)this ) )
5154 throw uno::RuntimeException();
5157 ScDocument* pDoc = pDocSh->GetDocument();
5158 ScTokenArray aTokenArray;
5159 (void)ScTokenConversion::ConvertToTokenArray( *pDoc, aTokenArray, rTokens );
5161 // Actually GRAM_PODF_A1 is a don't-care here because of the token
5162 // array being set, it fits with other API compatibility grammars
5163 // though.
5164 aFunc.EnterMatrix( aRange, NULL, &aTokenArray, EMPTY_STRING, TRUE, TRUE, EMPTY_STRING, formula::FormulaGrammar::GRAM_PODF_A1 );
5166 else
5168 // empty sequence -> erase array formula
5169 ScMarkData aMark;
5170 aMark.SetMarkArea( aRange );
5171 aMark.SelectTable( aRange.aStart.Tab(), TRUE );
5172 aFunc.DeleteContents( aMark, IDF_CONTENTS, TRUE, TRUE );
5177 // XCellRangeData
5179 uno::Sequence< uno::Sequence<uno::Any> > SAL_CALL ScCellRangeObj::getDataArray()
5180 throw(uno::RuntimeException)
5182 ScUnoGuard aGuard;
5184 if ( ScTableSheetObj::getImplementation( (cppu::OWeakObject*)this ) )
5186 // don't create a data array for the sheet
5187 throw uno::RuntimeException();
5190 ScDocShell* pDocSh = GetDocShell();
5191 if (pDocSh)
5193 uno::Any aAny;
5194 // bAllowNV = TRUE: errors as void
5195 if ( ScRangeToSequence::FillMixedArray( aAny, pDocSh->GetDocument(), aRange, TRUE ) )
5197 uno::Sequence< uno::Sequence<uno::Any> > aSeq;
5198 if ( aAny >>= aSeq )
5199 return aSeq; // success
5203 throw uno::RuntimeException(); // no other exceptions specified
5204 // return uno::Sequence< uno::Sequence<uno::Any> >(0);
5207 void SAL_CALL ScCellRangeObj::setDataArray(
5208 const uno::Sequence< uno::Sequence<uno::Any> >& aArray )
5209 throw(uno::RuntimeException)
5211 ScUnoGuard aGuard;
5213 BOOL bDone = FALSE;
5214 ScDocShell* pDocSh = GetDocShell();
5215 if (pDocSh)
5217 //! move lcl_PutDataArray to docfunc?
5218 bDone = lcl_PutDataArray( *pDocSh, aRange, aArray );
5221 if (!bDone)
5222 throw uno::RuntimeException(); // no other exceptions specified
5225 // XCellRangeFormula
5227 uno::Sequence< uno::Sequence<rtl::OUString> > SAL_CALL ScCellRangeObj::getFormulaArray()
5228 throw(uno::RuntimeException)
5230 ScUnoGuard aGuard;
5232 if ( ScTableSheetObj::getImplementation( (cppu::OWeakObject*)this ) )
5234 // don't create a data array for the sheet
5235 throw uno::RuntimeException();
5238 ScDocShell* pDocSh = GetDocShell();
5239 if (pDocSh)
5241 SCCOL nStartCol = aRange.aStart.Col();
5242 SCROW nStartRow = aRange.aStart.Row();
5243 SCCOL nEndCol = aRange.aEnd.Col();
5244 SCROW nEndRow = aRange.aEnd.Row();
5245 SCCOL nColCount = nEndCol + 1 - nStartCol;
5246 SCROW nRowCount = nEndRow + 1 - nStartRow;
5247 SCTAB nTab = aRange.aStart.Tab();
5249 uno::Sequence< uno::Sequence<rtl::OUString> > aRowSeq( nRowCount );
5250 uno::Sequence<rtl::OUString>* pRowAry = aRowSeq.getArray();
5251 for (SCROW nRowIndex = 0; nRowIndex < nRowCount; nRowIndex++)
5253 uno::Sequence<rtl::OUString> aColSeq( nColCount );
5254 rtl::OUString* pColAry = aColSeq.getArray();
5255 for (SCCOL nColIndex = 0; nColIndex < nColCount; nColIndex++)
5256 pColAry[nColIndex] = lcl_GetInputString( pDocSh->GetDocument(),
5257 ScAddress( nStartCol+nColIndex, nStartRow+nRowIndex, nTab ), TRUE );
5259 pRowAry[nRowIndex] = aColSeq;
5262 return aRowSeq;
5265 throw uno::RuntimeException(); // no other exceptions specified
5266 // return uno::Sequence< uno::Sequence<rtl::OUString> >(0);
5269 void SAL_CALL ScCellRangeObj::setFormulaArray(
5270 const uno::Sequence< uno::Sequence<rtl::OUString> >& aArray )
5271 throw(uno::RuntimeException)
5273 ScUnoGuard aGuard;
5275 BOOL bDone = FALSE;
5276 ScDocShell* pDocSh = GetDocShell();
5277 if (pDocSh)
5279 // GRAM_PODF_A1 for API compatibility.
5280 bDone = lcl_PutFormulaArray( *pDocSh, aRange, aArray, EMPTY_STRING, formula::FormulaGrammar::GRAM_PODF_A1 );
5283 if (!bDone)
5284 throw uno::RuntimeException(); // no other exceptions specified
5287 // XMultipleOperation
5289 void SAL_CALL ScCellRangeObj::setTableOperation( const table::CellRangeAddress& aFormulaRange,
5290 sheet::TableOperationMode nMode,
5291 const table::CellAddress& aColumnCell,
5292 const table::CellAddress& aRowCell )
5293 throw(uno::RuntimeException)
5295 ScUnoGuard aGuard;
5296 ScDocShell* pDocSh = GetDocShell();
5297 if (pDocSh)
5299 BOOL bError = FALSE;
5300 ScTabOpParam aParam;
5301 aParam.aRefFormulaCell = ScRefAddress( (SCCOL)aFormulaRange.StartColumn,
5302 (SCROW)aFormulaRange.StartRow, aFormulaRange.Sheet,
5303 FALSE, FALSE, FALSE );
5304 aParam.aRefFormulaEnd = ScRefAddress( (SCCOL)aFormulaRange.EndColumn,
5305 (SCROW)aFormulaRange.EndRow, aFormulaRange.Sheet,
5306 FALSE, FALSE, FALSE );
5307 aParam.aRefRowCell = ScRefAddress( (SCCOL)aRowCell.Column,
5308 (SCROW)aRowCell.Row, aRowCell.Sheet,
5309 FALSE, FALSE, FALSE );
5310 aParam.aRefColCell = ScRefAddress( (SCCOL)aColumnCell.Column,
5311 (SCROW)aColumnCell.Row, aColumnCell.Sheet,
5312 FALSE, FALSE, FALSE );
5313 switch (nMode)
5315 case sheet::TableOperationMode_COLUMN:
5316 aParam.nMode = 0;
5317 break;
5318 case sheet::TableOperationMode_ROW:
5319 aParam.nMode = 1;
5320 break;
5321 case sheet::TableOperationMode_BOTH:
5322 aParam.nMode = 2;
5323 break;
5324 default:
5325 bError = TRUE;
5328 if (!bError)
5330 ScDocFunc aFunc(*pDocSh);
5331 aFunc.TabOp( aRange, NULL, aParam, TRUE, TRUE );
5336 // XMergeable
5338 void SAL_CALL ScCellRangeObj::merge( sal_Bool bMerge ) throw(uno::RuntimeException)
5340 ScUnoGuard aGuard;
5341 ScDocShell* pDocSh = GetDocShell();
5342 if ( pDocSh )
5344 ScDocFunc aFunc(*pDocSh);
5345 ScCellMergeOption aMergeOption(
5346 aRange.aStart.Col(), aRange.aStart.Row(),
5347 aRange.aEnd.Col(), aRange.aEnd.Row(), false);
5348 aMergeOption.maTabs.insert(aRange.aStart.Tab());
5349 if ( bMerge )
5350 aFunc.MergeCells( aMergeOption, FALSE, TRUE, TRUE );
5351 else
5352 aFunc.UnmergeCells( aMergeOption, TRUE, TRUE );
5354 //! Fehler abfangen?
5358 sal_Bool SAL_CALL ScCellRangeObj::getIsMerged() throw(uno::RuntimeException)
5360 ScUnoGuard aGuard;
5361 ScDocShell* pDocSh = GetDocShell();
5362 return pDocSh && pDocSh->GetDocument()->HasAttrib( aRange, HASATTR_MERGED );
5365 // XCellSeries
5367 void SAL_CALL ScCellRangeObj::fillSeries( sheet::FillDirection nFillDirection,
5368 sheet::FillMode nFillMode, sheet::FillDateMode nFillDateMode,
5369 double fStep, double fEndValue ) throw(uno::RuntimeException)
5371 ScUnoGuard aGuard;
5372 ScDocShell* pDocSh = GetDocShell();
5373 if ( pDocSh )
5375 BOOL bError = FALSE;
5377 FillDir eDir = FILL_TO_BOTTOM;
5378 switch (nFillDirection)
5380 case sheet::FillDirection_TO_BOTTOM:
5381 eDir = FILL_TO_BOTTOM;
5382 break;
5383 case sheet::FillDirection_TO_RIGHT:
5384 eDir = FILL_TO_RIGHT;
5385 break;
5386 case sheet::FillDirection_TO_TOP:
5387 eDir = FILL_TO_TOP;
5388 break;
5389 case sheet::FillDirection_TO_LEFT:
5390 eDir = FILL_TO_LEFT;
5391 break;
5392 default:
5393 bError = TRUE;
5396 FillCmd eCmd = FILL_SIMPLE;
5397 switch ( nFillMode )
5399 case sheet::FillMode_SIMPLE:
5400 eCmd = FILL_SIMPLE;
5401 break;
5402 case sheet::FillMode_LINEAR:
5403 eCmd = FILL_LINEAR;
5404 break;
5405 case sheet::FillMode_GROWTH:
5406 eCmd = FILL_GROWTH;
5407 break;
5408 case sheet::FillMode_DATE:
5409 eCmd = FILL_DATE;
5410 break;
5411 case sheet::FillMode_AUTO:
5412 eCmd = FILL_AUTO;
5413 break;
5414 default:
5415 bError = TRUE;
5418 FillDateCmd eDateCmd = FILL_DAY;
5419 switch ( nFillDateMode )
5421 case sheet::FillDateMode_FILL_DATE_DAY:
5422 eDateCmd = FILL_DAY;
5423 break;
5424 case sheet::FillDateMode_FILL_DATE_WEEKDAY:
5425 eDateCmd = FILL_WEEKDAY;
5426 break;
5427 case sheet::FillDateMode_FILL_DATE_MONTH:
5428 eDateCmd = FILL_MONTH;
5429 break;
5430 case sheet::FillDateMode_FILL_DATE_YEAR:
5431 eDateCmd = FILL_YEAR;
5432 break;
5433 default:
5434 bError = TRUE;
5437 if (!bError)
5439 ScDocFunc aFunc(*pDocSh);
5440 aFunc.FillSeries( aRange, NULL, eDir, eCmd, eDateCmd,
5441 MAXDOUBLE, fStep, fEndValue, TRUE, TRUE );
5446 void SAL_CALL ScCellRangeObj::fillAuto( sheet::FillDirection nFillDirection,
5447 sal_Int32 nSourceCount ) throw(uno::RuntimeException)
5449 ScUnoGuard aGuard;
5450 ScDocShell* pDocSh = GetDocShell();
5451 if ( pDocSh && nSourceCount )
5453 ScRange aSourceRange(aRange);
5454 SCsCOLROW nCount = 0; // "Dest-Count"
5455 FillDir eDir = FILL_TO_BOTTOM;
5456 BOOL bError = FALSE;
5457 switch (nFillDirection)
5459 case sheet::FillDirection_TO_BOTTOM:
5460 aSourceRange.aEnd.SetRow( static_cast<SCROW>( aSourceRange.aStart.Row() + nSourceCount - 1 ) );
5461 nCount = aRange.aEnd.Row() - aSourceRange.aEnd.Row();
5462 eDir = FILL_TO_BOTTOM;
5463 break;
5464 case sheet::FillDirection_TO_RIGHT:
5465 aSourceRange.aEnd.SetCol( static_cast<SCCOL>( aSourceRange.aStart.Col() + nSourceCount - 1 ) );
5466 nCount = aRange.aEnd.Col() - aSourceRange.aEnd.Col();
5467 eDir = FILL_TO_RIGHT;
5468 break;
5469 case sheet::FillDirection_TO_TOP:
5470 aSourceRange.aStart.SetRow( static_cast<SCROW>( aSourceRange.aEnd.Row() - nSourceCount + 1 ) );
5471 nCount = aSourceRange.aStart.Row() - aRange.aStart.Row();
5472 eDir = FILL_TO_TOP;
5473 break;
5474 case sheet::FillDirection_TO_LEFT:
5475 aSourceRange.aStart.SetCol( static_cast<SCCOL>( aSourceRange.aEnd.Col() - nSourceCount + 1 ) );
5476 nCount = aSourceRange.aStart.Col() - aRange.aStart.Col();
5477 eDir = FILL_TO_LEFT;
5478 break;
5479 default:
5480 bError = TRUE;
5482 if (nCount < 0 || nCount > MAXROW) // overflow
5483 bError = TRUE;
5485 if (!bError)
5487 ScDocFunc aFunc(*pDocSh);
5488 aFunc.FillAuto( aSourceRange, NULL, eDir, nCount, TRUE, TRUE );
5493 // XAutoFormattable
5495 void SAL_CALL ScCellRangeObj::autoFormat( const rtl::OUString& aName )
5496 throw(lang::IllegalArgumentException, uno::RuntimeException)
5498 ScUnoGuard aGuard;
5499 ScAutoFormat* pAutoFormat = ScGlobal::GetAutoFormat();
5500 ScDocShell* pDocSh = GetDocShell();
5501 if ( pDocSh && pAutoFormat )
5503 String aNameString(aName);
5504 USHORT nCount = pAutoFormat->GetCount();
5505 USHORT nIndex;
5506 String aCompare;
5507 for (nIndex=0; nIndex<nCount; nIndex++)
5509 (*pAutoFormat)[nIndex]->GetName(aCompare);
5510 if ( aCompare == aNameString ) //! Case-insensitiv ???
5511 break;
5513 if (nIndex<nCount)
5515 ScDocFunc aFunc(*pDocSh);
5516 aFunc.AutoFormat( aRange, NULL, nIndex, TRUE, TRUE );
5518 else
5519 throw lang::IllegalArgumentException();
5523 // XSortable
5525 uno::Sequence<beans::PropertyValue> SAL_CALL ScCellRangeObj::createSortDescriptor()
5526 throw(uno::RuntimeException)
5528 ScUnoGuard aGuard;
5529 ScSortParam aParam;
5530 ScDocShell* pDocSh = GetDocShell();
5531 if ( pDocSh )
5533 // DB-Bereich anlegen erst beim Ausfuehren, per API immer genau den Bereich
5534 ScDBData* pData = pDocSh->GetDBData( aRange, SC_DB_OLD, TRUE );
5535 if (pData)
5537 pData->GetSortParam(aParam);
5539 // im SortDescriptor sind die Fields innerhalb des Bereichs gezaehlt
5540 ScRange aDBRange;
5541 pData->GetArea(aDBRange);
5542 SCCOLROW nFieldStart = aParam.bByRow ?
5543 static_cast<SCCOLROW>(aDBRange.aStart.Col()) :
5544 static_cast<SCCOLROW>(aDBRange.aStart.Row());
5545 for (USHORT i=0; i<MAXSORT; i++)
5546 if ( aParam.bDoSort[i] && aParam.nField[i] >= nFieldStart )
5547 aParam.nField[i] -= nFieldStart;
5551 uno::Sequence<beans::PropertyValue> aSeq( ScSortDescriptor::GetPropertyCount() );
5552 ScSortDescriptor::FillProperties( aSeq, aParam );
5553 return aSeq;
5556 void SAL_CALL ScCellRangeObj::sort( const uno::Sequence<beans::PropertyValue>& aDescriptor )
5557 throw(uno::RuntimeException)
5559 ScUnoGuard aGuard;
5560 ScDocShell* pDocSh = GetDocShell();
5561 if (pDocSh)
5563 USHORT i;
5564 ScSortParam aParam;
5565 ScDBData* pData = pDocSh->GetDBData( aRange, SC_DB_MAKE, TRUE ); // ggf. Bereich anlegen
5566 if (pData)
5568 // alten Einstellungen holen, falls nicht alles neu gesetzt wird
5569 pData->GetSortParam(aParam);
5570 SCCOLROW nOldStart = aParam.bByRow ?
5571 static_cast<SCCOLROW>(aRange.aStart.Col()) :
5572 static_cast<SCCOLROW>(aRange.aStart.Row());
5573 for (i=0; i<MAXSORT; i++)
5574 if ( aParam.bDoSort[i] && aParam.nField[i] >= nOldStart )
5575 aParam.nField[i] -= nOldStart;
5578 ScSortDescriptor::FillSortParam( aParam, aDescriptor );
5580 // im SortDescriptor sind die Fields innerhalb des Bereichs gezaehlt
5581 // ByRow kann bei FillSortParam umgesetzt worden sein
5582 SCCOLROW nFieldStart = aParam.bByRow ?
5583 static_cast<SCCOLROW>(aRange.aStart.Col()) :
5584 static_cast<SCCOLROW>(aRange.aStart.Row());
5585 for (i=0; i<MAXSORT; i++)
5586 aParam.nField[i] += nFieldStart;
5588 SCTAB nTab = aRange.aStart.Tab();
5589 aParam.nCol1 = aRange.aStart.Col();
5590 aParam.nRow1 = aRange.aStart.Row();
5591 aParam.nCol2 = aRange.aEnd.Col();
5592 aParam.nRow2 = aRange.aEnd.Row();
5594 pDocSh->GetDBData( aRange, SC_DB_MAKE, TRUE ); // ggf. Bereich anlegen
5596 ScDBDocFunc aFunc(*pDocSh); // Bereich muss angelegt sein
5597 aFunc.Sort( nTab, aParam, TRUE, TRUE, TRUE );
5601 // XFilterable
5603 uno::Reference<sheet::XSheetFilterDescriptor> SAL_CALL ScCellRangeObj::createFilterDescriptor(
5604 sal_Bool bEmpty ) throw(uno::RuntimeException)
5606 ScUnoGuard aGuard;
5607 ScDocShell* pDocSh = GetDocShell();
5608 ScFilterDescriptor* pNew = new ScFilterDescriptor(pDocSh);
5609 if ( !bEmpty && pDocSh )
5611 // DB-Bereich anlegen erst beim Ausfuehren, per API immer genau den Bereich
5612 ScDBData* pData = pDocSh->GetDBData( aRange, SC_DB_OLD, TRUE );
5613 if (pData)
5615 ScQueryParam aParam;
5616 pData->GetQueryParam(aParam);
5617 // im FilterDescriptor sind die Fields innerhalb des Bereichs gezaehlt
5618 ScRange aDBRange;
5619 pData->GetArea(aDBRange);
5620 SCCOLROW nFieldStart = aParam.bByRow ?
5621 static_cast<SCCOLROW>(aDBRange.aStart.Col()) :
5622 static_cast<SCCOLROW>(aDBRange.aStart.Row());
5623 SCSIZE nCount = aParam.GetEntryCount();
5624 for (SCSIZE i=0; i<nCount; i++)
5626 ScQueryEntry& rEntry = aParam.GetEntry(i);
5627 if (rEntry.bDoQuery && rEntry.nField >= nFieldStart)
5628 rEntry.nField -= nFieldStart;
5630 pNew->SetParam(aParam);
5633 return pNew;
5636 void SAL_CALL ScCellRangeObj::filter( const uno::Reference<sheet::XSheetFilterDescriptor>& xDescriptor )
5637 throw(uno::RuntimeException)
5639 ScUnoGuard aGuard;
5641 // das koennte theoretisch ein fremdes Objekt sein, also nur das
5642 // oeffentliche XSheetFilterDescriptor Interface benutzen, um
5643 // die Daten in ein ScFilterDescriptor Objekt zu kopieren:
5644 //! wenn es schon ein ScFilterDescriptor ist, direkt per getImplementation?
5646 ScDocShell* pDocSh = GetDocShell();
5647 ScFilterDescriptor aImpl(pDocSh);
5648 uno::Reference< sheet::XSheetFilterDescriptor2 > xDescriptor2( xDescriptor, uno::UNO_QUERY );
5649 if ( xDescriptor2.is() )
5651 aImpl.setFilterFields2( xDescriptor2->getFilterFields2() );
5653 else
5655 aImpl.setFilterFields( xDescriptor->getFilterFields() );
5657 // Rest sind jetzt Properties...
5659 uno::Reference<beans::XPropertySet> xPropSet( xDescriptor, uno::UNO_QUERY );
5660 if (xPropSet.is())
5661 lcl_CopyProperties( aImpl, *(beans::XPropertySet*)xPropSet.get() );
5664 // ausfuehren...
5667 if (pDocSh)
5669 ScQueryParam aParam = aImpl.GetParam();
5670 // im FilterDescriptor sind die Fields innerhalb des Bereichs gezaehlt
5671 SCCOLROW nFieldStart = aParam.bByRow ?
5672 static_cast<SCCOLROW>(aRange.aStart.Col()) :
5673 static_cast<SCCOLROW>(aRange.aStart.Row());
5674 SCSIZE nCount = aParam.GetEntryCount();
5675 for (SCSIZE i=0; i<nCount; i++)
5677 ScQueryEntry& rEntry = aParam.GetEntry(i);
5678 if (rEntry.bDoQuery)
5680 rEntry.nField += nFieldStart;
5681 // Im Dialog wird immer der String angezeigt -> muss zum Wert passen
5682 if ( !rEntry.bQueryByString )
5683 pDocSh->GetDocument()->GetFormatTable()->
5684 GetInputLineString( rEntry.nVal, 0, *rEntry.pStr );
5688 SCTAB nTab = aRange.aStart.Tab();
5689 aParam.nCol1 = aRange.aStart.Col();
5690 aParam.nRow1 = aRange.aStart.Row();
5691 aParam.nCol2 = aRange.aEnd.Col();
5692 aParam.nRow2 = aRange.aEnd.Row();
5694 pDocSh->GetDBData( aRange, SC_DB_MAKE, TRUE ); // ggf. Bereich anlegen
5696 //! keep source range in filter descriptor
5697 //! if created by createFilterDescriptorByObject ???
5699 ScDBDocFunc aFunc(*pDocSh);
5700 aFunc.Query( nTab, aParam, NULL, TRUE, TRUE ); // Bereich muss angelegt sein
5704 //! get/setAutoFilter als Properties!!!
5706 // XAdvancedFilterSource
5708 uno::Reference<sheet::XSheetFilterDescriptor> SAL_CALL ScCellRangeObj::createFilterDescriptorByObject(
5709 const uno::Reference<sheet::XSheetFilterable>& xObject )
5710 throw(uno::RuntimeException)
5712 ScUnoGuard aGuard;
5714 // this ist hier nicht der Bereich, der gefiltert wird, sondern der
5715 // Bereich mit der Abfrage...
5717 uno::Reference<sheet::XCellRangeAddressable> xAddr( xObject, uno::UNO_QUERY );
5719 ScDocShell* pDocSh = GetDocShell();
5720 if ( pDocSh && xAddr.is() )
5722 //! Test, ob xObject im selben Dokument ist
5724 ScFilterDescriptor* pNew = new ScFilterDescriptor(pDocSh); //! stattdessen vom Objekt?
5725 //XSheetFilterDescriptorRef xNew = xObject->createFilterDescriptor(TRUE);
5727 ScQueryParam aParam = pNew->GetParam();
5728 aParam.bHasHeader = TRUE;
5730 table::CellRangeAddress aDataAddress(xAddr->getRangeAddress());
5731 aParam.nCol1 = (SCCOL)aDataAddress.StartColumn;
5732 aParam.nRow1 = (SCROW)aDataAddress.StartRow;
5733 aParam.nCol2 = (SCCOL)aDataAddress.EndColumn;
5734 aParam.nRow2 = (SCROW)aDataAddress.EndRow;
5735 aParam.nTab = aDataAddress.Sheet;
5737 ScDocument* pDoc = pDocSh->GetDocument();
5738 BOOL bOk = pDoc->CreateQueryParam(
5739 aRange.aStart.Col(), aRange.aStart.Row(),
5740 aRange.aEnd.Col(), aRange.aEnd.Row(),
5741 aRange.aStart.Tab(), aParam );
5742 if ( bOk )
5744 // im FilterDescriptor sind die Fields innerhalb des Bereichs gezaehlt
5745 SCCOLROW nFieldStart = aParam.bByRow ?
5746 static_cast<SCCOLROW>(aDataAddress.StartColumn) :
5747 static_cast<SCCOLROW>(aDataAddress.StartRow);
5748 SCSIZE nCount = aParam.GetEntryCount();
5749 for (SCSIZE i=0; i<nCount; i++)
5751 ScQueryEntry& rEntry = aParam.GetEntry(i);
5752 if (rEntry.bDoQuery && rEntry.nField >= nFieldStart)
5753 rEntry.nField -= nFieldStart;
5756 pNew->SetParam( aParam );
5757 return pNew;
5759 else
5761 delete pNew;
5762 return NULL; // ungueltig -> null
5766 DBG_ERROR("kein Dokument oder kein Bereich");
5767 return NULL;
5770 // XSubTotalSource
5772 uno::Reference<sheet::XSubTotalDescriptor> SAL_CALL ScCellRangeObj::createSubTotalDescriptor(
5773 sal_Bool bEmpty ) throw(uno::RuntimeException)
5775 ScUnoGuard aGuard;
5776 ScSubTotalDescriptor* pNew = new ScSubTotalDescriptor;
5777 ScDocShell* pDocSh = GetDocShell();
5778 if ( !bEmpty && pDocSh )
5780 // DB-Bereich anlegen erst beim Ausfuehren, per API immer genau den Bereich
5781 ScDBData* pData = pDocSh->GetDBData( aRange, SC_DB_OLD, TRUE );
5782 if (pData)
5784 ScSubTotalParam aParam;
5785 pData->GetSubTotalParam(aParam);
5786 // im SubTotalDescriptor sind die Fields innerhalb des Bereichs gezaehlt
5787 ScRange aDBRange;
5788 pData->GetArea(aDBRange);
5789 SCCOL nFieldStart = aDBRange.aStart.Col();
5790 for (USHORT i=0; i<MAXSUBTOTAL; i++)
5792 if ( aParam.bGroupActive[i] )
5794 if ( aParam.nField[i] >= nFieldStart )
5795 aParam.nField[i] = sal::static_int_cast<SCCOL>( aParam.nField[i] - nFieldStart );
5796 for (SCCOL j=0; j<aParam.nSubTotals[i]; j++)
5797 if ( aParam.pSubTotals[i][j] >= nFieldStart )
5798 aParam.pSubTotals[i][j] = sal::static_int_cast<SCCOL>( aParam.pSubTotals[i][j] - nFieldStart );
5801 pNew->SetParam(aParam);
5804 return pNew;
5807 void SAL_CALL ScCellRangeObj::applySubTotals(
5808 const uno::Reference<sheet::XSubTotalDescriptor>& xDescriptor,
5809 sal_Bool bReplace ) throw(uno::RuntimeException)
5811 ScUnoGuard aGuard;
5813 if (!xDescriptor.is()) return;
5815 ScDocShell* pDocSh = GetDocShell();
5816 ScSubTotalDescriptorBase* pImp =
5817 ScSubTotalDescriptorBase::getImplementation( xDescriptor );
5819 if (pDocSh && pImp)
5821 ScSubTotalParam aParam;
5822 pImp->GetData(aParam); // virtuelle Methode der Basisklasse
5824 // im SubTotalDescriptor sind die Fields innerhalb des Bereichs gezaehlt
5825 SCCOL nFieldStart = aRange.aStart.Col();
5826 for (USHORT i=0; i<MAXSUBTOTAL; i++)
5828 if ( aParam.bGroupActive[i] )
5830 aParam.nField[i] = sal::static_int_cast<SCCOL>( aParam.nField[i] + nFieldStart );
5831 for (SCCOL j=0; j<aParam.nSubTotals[i]; j++)
5832 aParam.pSubTotals[i][j] = sal::static_int_cast<SCCOL>( aParam.pSubTotals[i][j] + nFieldStart );
5836 aParam.bReplace = bReplace;
5838 SCTAB nTab = aRange.aStart.Tab();
5839 aParam.nCol1 = aRange.aStart.Col();
5840 aParam.nRow1 = aRange.aStart.Row();
5841 aParam.nCol2 = aRange.aEnd.Col();
5842 aParam.nRow2 = aRange.aEnd.Row();
5844 pDocSh->GetDBData( aRange, SC_DB_MAKE, TRUE ); // ggf. Bereich anlegen
5846 ScDBDocFunc aFunc(*pDocSh);
5847 aFunc.DoSubTotals( nTab, aParam, NULL, TRUE, TRUE ); // Bereich muss angelegt sein
5851 void SAL_CALL ScCellRangeObj::removeSubTotals() throw(uno::RuntimeException)
5853 ScUnoGuard aGuard;
5855 ScDocShell* pDocSh = GetDocShell();
5856 if (pDocSh)
5858 ScSubTotalParam aParam;
5859 ScDBData* pData = pDocSh->GetDBData( aRange, SC_DB_OLD, TRUE );
5860 if (pData)
5861 pData->GetSubTotalParam(aParam); // auch bei Remove die Feld-Eintraege behalten
5863 aParam.bRemoveOnly = TRUE;
5865 SCTAB nTab = aRange.aStart.Tab();
5866 aParam.nCol1 = aRange.aStart.Col();
5867 aParam.nRow1 = aRange.aStart.Row();
5868 aParam.nCol2 = aRange.aEnd.Col();
5869 aParam.nRow2 = aRange.aEnd.Row();
5871 pDocSh->GetDBData( aRange, SC_DB_MAKE, TRUE ); // ggf. Bereich anlegen
5873 ScDBDocFunc aFunc(*pDocSh);
5874 aFunc.DoSubTotals( nTab, aParam, NULL, TRUE, TRUE ); // Bereich muss angelegt sein
5878 uno::Sequence<beans::PropertyValue> SAL_CALL ScCellRangeObj::createImportDescriptor( sal_Bool bEmpty )
5879 throw(uno::RuntimeException)
5881 ScUnoGuard aGuard;
5882 ScImportParam aParam;
5883 ScDocShell* pDocSh = GetDocShell();
5884 if ( !bEmpty && pDocSh )
5886 // DB-Bereich anlegen erst beim Ausfuehren, per API immer genau den Bereich
5887 ScDBData* pData = pDocSh->GetDBData( aRange, SC_DB_OLD, TRUE );
5888 if (pData)
5889 pData->GetImportParam(aParam);
5892 uno::Sequence<beans::PropertyValue> aSeq( ScImportDescriptor::GetPropertyCount() );
5893 ScImportDescriptor::FillProperties( aSeq, aParam );
5894 return aSeq;
5897 void SAL_CALL ScCellRangeObj::doImport( const uno::Sequence<beans::PropertyValue>& aDescriptor )
5898 throw(uno::RuntimeException)
5900 ScUnoGuard aGuard;
5901 ScDocShell* pDocSh = GetDocShell();
5902 if (pDocSh)
5904 ScImportParam aParam;
5905 ScImportDescriptor::FillImportParam( aParam, aDescriptor );
5907 SCTAB nTab = aRange.aStart.Tab();
5908 aParam.nCol1 = aRange.aStart.Col();
5909 aParam.nRow1 = aRange.aStart.Row();
5910 aParam.nCol2 = aRange.aEnd.Col();
5911 aParam.nRow2 = aRange.aEnd.Row();
5913 //! TODO: could we get passed a valid result set by any means?
5914 uno::Reference< sdbc::XResultSet > xResultSet;
5916 pDocSh->GetDBData( aRange, SC_DB_MAKE, TRUE ); // ggf. Bereich anlegen
5918 ScDBDocFunc aFunc(*pDocSh); // Bereich muss angelegt sein
5919 aFunc.DoImport( nTab, aParam, xResultSet, NULL, TRUE, FALSE ); //! Api-Flag als Parameter
5923 // XCellFormatRangesSupplier
5925 uno::Reference<container::XIndexAccess> SAL_CALL ScCellRangeObj::getCellFormatRanges()
5926 throw(uno::RuntimeException)
5928 ScUnoGuard aGuard;
5929 ScDocShell* pDocSh = GetDocShell();
5930 if ( pDocSh )
5931 return new ScCellFormatsObj( pDocSh, aRange );
5932 return NULL;
5935 // XUniqueCellFormatRangesSupplier
5937 uno::Reference<container::XIndexAccess> SAL_CALL ScCellRangeObj::getUniqueCellFormatRanges()
5938 throw(uno::RuntimeException)
5940 ScUnoGuard aGuard;
5941 ScDocShell* pDocSh = GetDocShell();
5942 if ( pDocSh )
5943 return new ScUniqueCellFormatsObj( pDocSh, aRange );
5944 return NULL;
5947 // XPropertySet erweitert fuer Range-Properties
5949 uno::Reference<beans::XPropertySetInfo> SAL_CALL ScCellRangeObj::getPropertySetInfo()
5950 throw(uno::RuntimeException)
5952 ScUnoGuard aGuard;
5953 static uno::Reference<beans::XPropertySetInfo> aRef(
5954 new SfxItemPropertySetInfo( pRangePropSet->getPropertyMap() ));
5955 return aRef;
5958 void ScCellRangeObj::SetOnePropertyValue( const SfxItemPropertySimpleEntry* pEntry, const uno::Any& aValue )
5959 throw(lang::IllegalArgumentException, uno::RuntimeException)
5961 // Range has only Position and Size in addition to ScCellRangesBase, both are ReadOnly
5962 // -> nothing to do here
5964 ScCellRangesBase::SetOnePropertyValue( pEntry, aValue );
5967 void ScCellRangeObj::GetOnePropertyValue( const SfxItemPropertySimpleEntry* pEntry,
5968 uno::Any& rAny )
5969 throw(uno::RuntimeException)
5971 if ( pEntry )
5973 if ( pEntry->nWID == SC_WID_UNO_POS )
5975 ScDocShell* pDocSh = GetDocShell();
5976 if (pDocSh)
5978 // GetMMRect converts using HMM_PER_TWIPS, like the DrawingLayer
5979 Rectangle aMMRect(pDocSh->GetDocument()->GetMMRect(
5980 aRange.aStart.Col(), aRange.aStart.Row(),
5981 aRange.aEnd.Col(), aRange.aEnd.Row(), aRange.aStart.Tab() ));
5982 awt::Point aPos( aMMRect.Left(), aMMRect.Top() );
5983 rAny <<= aPos;
5986 else if ( pEntry->nWID == SC_WID_UNO_SIZE )
5988 ScDocShell* pDocSh = GetDocShell();
5989 if (pDocSh)
5991 // GetMMRect converts using HMM_PER_TWIPS, like the DrawingLayer
5992 Rectangle aMMRect = pDocSh->GetDocument()->GetMMRect(
5993 aRange.aStart.Col(), aRange.aStart.Row(),
5994 aRange.aEnd.Col(), aRange.aEnd.Row(), aRange.aStart.Tab() );
5995 Size aSize(aMMRect.GetSize());
5996 awt::Size aAwtSize( aSize.Width(), aSize.Height() );
5997 rAny <<= aAwtSize;
6000 else
6001 ScCellRangesBase::GetOnePropertyValue( pEntry, rAny );
6006 const SfxItemPropertyMap* ScCellRangeObj::GetItemPropertyMap()
6008 return pRangePropSet->getPropertyMap();
6011 // XServiceInfo
6013 rtl::OUString SAL_CALL ScCellRangeObj::getImplementationName() throw(uno::RuntimeException)
6015 return rtl::OUString::createFromAscii( "ScCellRangeObj" );
6018 sal_Bool SAL_CALL ScCellRangeObj::supportsService( const rtl::OUString& rServiceName )
6019 throw(uno::RuntimeException)
6021 String aServiceStr( rServiceName );
6022 return aServiceStr.EqualsAscii( SCSHEETCELLRANGE_SERVICE ) ||
6023 aServiceStr.EqualsAscii( SCCELLRANGE_SERVICE ) ||
6024 aServiceStr.EqualsAscii( SCCELLPROPERTIES_SERVICE ) ||
6025 aServiceStr.EqualsAscii( SCCHARPROPERTIES_SERVICE ) ||
6026 aServiceStr.EqualsAscii( SCPARAPROPERTIES_SERVICE );
6029 uno::Sequence<rtl::OUString> SAL_CALL ScCellRangeObj::getSupportedServiceNames()
6030 throw(uno::RuntimeException)
6032 uno::Sequence<rtl::OUString> aRet(5);
6033 rtl::OUString* pArray = aRet.getArray();
6034 pArray[0] = rtl::OUString::createFromAscii( SCSHEETCELLRANGE_SERVICE );
6035 pArray[1] = rtl::OUString::createFromAscii( SCCELLRANGE_SERVICE );
6036 pArray[2] = rtl::OUString::createFromAscii( SCCELLPROPERTIES_SERVICE );
6037 pArray[3] = rtl::OUString::createFromAscii( SCCHARPROPERTIES_SERVICE );
6038 pArray[4] = rtl::OUString::createFromAscii( SCPARAPROPERTIES_SERVICE );
6039 return aRet;
6042 //------------------------------------------------------------------------
6044 const SvxItemPropertySet* ScCellObj::GetEditPropertySet() // static
6046 return lcl_GetEditPropertySet();
6048 const SfxItemPropertyMap* ScCellObj::GetCellPropertyMap()
6050 return lcl_GetCellPropertySet()->getPropertyMap();
6053 ScCellObj::ScCellObj(ScDocShell* pDocSh, const ScAddress& rP) :
6054 ScCellRangeObj( pDocSh, ScRange(rP,rP) ),
6055 pUnoText( NULL ),
6056 pCellPropSet( lcl_GetCellPropertySet() ),
6057 aCellPos( rP ),
6058 nActionLockCount( 0 )
6060 // pUnoText is allocated on demand (GetUnoText)
6061 // can't be aggregated because getString/setString is handled here
6064 SvxUnoText& ScCellObj::GetUnoText()
6066 if (!pUnoText)
6068 pUnoText = new ScCellTextObj( GetDocShell(), aCellPos );
6069 pUnoText->acquire();
6070 if (nActionLockCount)
6072 ScSharedCellEditSource* pEditSource =
6073 static_cast<ScSharedCellEditSource*> (pUnoText->GetEditSource());
6074 if (pEditSource)
6075 pEditSource->SetDoUpdateData(sal_False);
6078 return *pUnoText;
6081 ScCellObj::~ScCellObj()
6083 if (pUnoText)
6084 pUnoText->release();
6087 void ScCellObj::RefChanged()
6089 ScCellRangeObj::RefChanged();
6091 const ScRangeList& rRanges = GetRangeList();
6092 DBG_ASSERT(rRanges.Count() == 1, "was fuer Ranges ?!?!");
6093 const ScRange* pFirst = rRanges.GetObject(0);
6094 if (pFirst)
6095 aCellPos = pFirst->aStart;
6098 uno::Any SAL_CALL ScCellObj::queryInterface( const uno::Type& rType ) throw(uno::RuntimeException)
6100 SC_QUERYINTERFACE( table::XCell )
6101 SC_QUERYINTERFACE( sheet::XFormulaTokens )
6102 SC_QUERYINTERFACE( sheet::XCellAddressable )
6103 SC_QUERYINTERFACE( text::XText )
6104 SC_QUERYINTERFACE( text::XSimpleText )
6105 SC_QUERYINTERFACE( text::XTextRange )
6106 SC_QUERYINTERFACE( container::XEnumerationAccess )
6107 SC_QUERYINTERFACE( container::XElementAccess )
6108 SC_QUERYINTERFACE( sheet::XSheetAnnotationAnchor )
6109 SC_QUERYINTERFACE( text::XTextFieldsSupplier )
6110 SC_QUERYINTERFACE( document::XActionLockable )
6112 return ScCellRangeObj::queryInterface( rType );
6115 void SAL_CALL ScCellObj::acquire() throw()
6117 ScCellRangeObj::acquire();
6120 void SAL_CALL ScCellObj::release() throw()
6122 ScCellRangeObj::release();
6125 uno::Sequence<uno::Type> SAL_CALL ScCellObj::getTypes() throw(uno::RuntimeException)
6127 static uno::Sequence<uno::Type> aTypes;
6128 if ( aTypes.getLength() == 0 )
6130 uno::Sequence<uno::Type> aParentTypes(ScCellRangeObj::getTypes());
6131 long nParentLen = aParentTypes.getLength();
6132 const uno::Type* pParentPtr = aParentTypes.getConstArray();
6134 aTypes.realloc( nParentLen + 8 );
6135 uno::Type* pPtr = aTypes.getArray();
6136 pPtr[nParentLen + 0] = getCppuType((const uno::Reference<table::XCell>*)0);
6137 pPtr[nParentLen + 1] = getCppuType((const uno::Reference<sheet::XCellAddressable>*)0);
6138 pPtr[nParentLen + 2] = getCppuType((const uno::Reference<text::XText>*)0);
6139 pPtr[nParentLen + 3] = getCppuType((const uno::Reference<container::XEnumerationAccess>*)0);
6140 pPtr[nParentLen + 4] = getCppuType((const uno::Reference<sheet::XSheetAnnotationAnchor>*)0);
6141 pPtr[nParentLen + 5] = getCppuType((const uno::Reference<text::XTextFieldsSupplier>*)0);
6142 pPtr[nParentLen + 6] = getCppuType((const uno::Reference<document::XActionLockable>*)0);
6143 pPtr[nParentLen + 7] = getCppuType((const uno::Reference<sheet::XFormulaTokens>*)0);
6145 for (long i=0; i<nParentLen; i++)
6146 pPtr[i] = pParentPtr[i]; // parent types first
6148 return aTypes;
6151 uno::Sequence<sal_Int8> SAL_CALL ScCellObj::getImplementationId() throw(uno::RuntimeException)
6153 static uno::Sequence< sal_Int8 > aId;
6154 if( aId.getLength() == 0 )
6156 aId.realloc( 16 );
6157 rtl_createUuid( (sal_uInt8 *)aId.getArray(), 0, sal_True );
6159 return aId;
6162 // Hilfsfunktionen
6164 String ScCellObj::GetInputString_Impl(BOOL bEnglish) const // fuer getFormula / FormulaLocal
6166 if (GetDocShell())
6167 return lcl_GetInputString( GetDocShell()->GetDocument(), aCellPos, bEnglish );
6168 return String();
6171 String ScCellObj::GetOutputString_Impl(ScDocument* pDoc, const ScAddress& aCellPos)
6173 String aVal;
6174 if ( pDoc )
6176 ScBaseCell* pCell = pDoc->GetCell( aCellPos );
6177 if ( pCell && pCell->GetCellType() != CELLTYPE_NOTE )
6179 if ( pCell->GetCellType() == CELLTYPE_EDIT )
6181 // GetString an der EditCell macht Leerzeichen aus Umbruechen,
6182 // hier werden die Umbrueche aber gebraucht
6183 const EditTextObject* pData = ((ScEditCell*)pCell)->GetData();
6184 if (pData)
6186 EditEngine& rEngine = pDoc->GetEditEngine();
6187 rEngine.SetText( *pData );
6188 aVal = rEngine.GetText( LINEEND_LF );
6190 // Edit-Zellen auch nicht per NumberFormatter formatieren
6191 // (passend zur Ausgabe)
6193 else
6195 // wie in GetString am Dokument (column)
6196 Color* pColor;
6197 ULONG nNumFmt = pDoc->GetNumberFormat( aCellPos );
6198 ScCellFormat::GetString( pCell, nNumFmt, aVal, &pColor, *pDoc->GetFormatTable() );
6202 return aVal;
6205 String ScCellObj::GetOutputString_Impl() const
6207 ScDocShell* pDocSh = GetDocShell();
6208 String aVal;
6209 if ( pDocSh )
6210 aVal = GetOutputString_Impl(pDocSh->GetDocument(), aCellPos);
6211 return aVal;
6214 void ScCellObj::SetString_Impl(const String& rString, BOOL bInterpret, BOOL bEnglish)
6216 ScDocShell* pDocSh = GetDocShell();
6217 if ( pDocSh )
6219 ScDocFunc aFunc(*pDocSh);
6220 // GRAM_PODF_A1 for API compatibility.
6221 (void)aFunc.SetCellText( aCellPos, rString, bInterpret, bEnglish, TRUE, EMPTY_STRING, formula::FormulaGrammar::GRAM_PODF_A1 );
6225 double ScCellObj::GetValue_Impl() const
6227 ScDocShell* pDocSh = GetDocShell();
6228 if ( pDocSh )
6229 return pDocSh->GetDocument()->GetValue( aCellPos );
6231 return 0.0;
6234 void ScCellObj::SetValue_Impl(double fValue)
6236 ScDocShell* pDocSh = GetDocShell();
6237 if ( pDocSh )
6239 ScDocFunc aFunc(*pDocSh);
6240 (void)aFunc.PutCell( aCellPos, new ScValueCell(fValue), TRUE );
6244 // only for XML import
6246 void ScCellObj::SetFormulaResultString( const ::rtl::OUString& rResult )
6248 ScDocShell* pDocSh = GetDocShell();
6249 if ( pDocSh )
6251 ScBaseCell* pCell = pDocSh->GetDocument()->GetCell( aCellPos );
6252 if ( pCell && pCell->GetCellType() == CELLTYPE_FORMULA )
6253 ((ScFormulaCell*)pCell)->SetHybridString( rResult );
6257 void ScCellObj::SetFormulaResultDouble( double fResult )
6259 ScDocShell* pDocSh = GetDocShell();
6260 if ( pDocSh )
6262 ScBaseCell* pCell = pDocSh->GetDocument()->GetCell( aCellPos );
6263 if ( pCell && pCell->GetCellType() == CELLTYPE_FORMULA )
6264 ((ScFormulaCell*)pCell)->SetHybridDouble( fResult );
6268 void ScCellObj::SetFormulaWithGrammar( const ::rtl::OUString& rFormula,
6269 const ::rtl::OUString& rFormulaNmsp, const formula::FormulaGrammar::Grammar eGrammar )
6271 ScDocShell* pDocSh = GetDocShell();
6272 if ( pDocSh )
6274 ScDocFunc aFunc(*pDocSh);
6275 aFunc.SetCellText( aCellPos, rFormula, TRUE, TRUE, TRUE, rFormulaNmsp, eGrammar);
6279 // XText
6281 uno::Reference<text::XTextCursor> SAL_CALL ScCellObj::createTextCursor()
6282 throw(uno::RuntimeException)
6284 ScUnoGuard aGuard;
6285 return new ScCellTextCursor( *this );
6288 uno::Reference<text::XTextCursor> SAL_CALL ScCellObj::createTextCursorByRange(
6289 const uno::Reference<text::XTextRange>& aTextPosition )
6290 throw(uno::RuntimeException)
6292 ScUnoGuard aGuard;
6293 SvxUnoTextCursor* pCursor = new ScCellTextCursor( *this );
6294 uno::Reference<text::XTextCursor> xCursor(pCursor);
6296 SvxUnoTextRangeBase* pRange = SvxUnoTextRangeBase::getImplementation( aTextPosition );
6297 if(pRange)
6298 pCursor->SetSelection( pRange->GetSelection() );
6299 else
6301 ScCellTextCursor* pOther = ScCellTextCursor::getImplementation( aTextPosition );
6302 if(pOther)
6303 pCursor->SetSelection( pOther->GetSelection() );
6304 else
6305 throw uno::RuntimeException();
6308 return xCursor;
6311 rtl::OUString SAL_CALL ScCellObj::getString() throw(uno::RuntimeException)
6313 ScUnoGuard aGuard;
6314 return GetOutputString_Impl();
6317 void SAL_CALL ScCellObj::setString( const rtl::OUString& aText ) throw(uno::RuntimeException)
6319 ScUnoGuard aGuard;
6320 String aString(aText);
6321 SetString_Impl(aString, FALSE, FALSE); // immer Text
6323 // don't create pUnoText here if not there
6324 if (pUnoText)
6325 pUnoText->SetSelection(ESelection( 0,0, 0,aString.Len() ));
6328 void SAL_CALL ScCellObj::insertString( const uno::Reference<text::XTextRange>& xRange,
6329 const rtl::OUString& aString, sal_Bool bAbsorb )
6330 throw(uno::RuntimeException)
6332 // special handling for ScCellTextCursor is no longer needed,
6333 // SvxUnoText::insertString checks for SvxUnoTextRangeBase instead of SvxUnoTextRange
6335 ScUnoGuard aGuard;
6336 GetUnoText().insertString(xRange, aString, bAbsorb);
6339 void SAL_CALL ScCellObj::insertControlCharacter( const uno::Reference<text::XTextRange>& xRange,
6340 sal_Int16 nControlCharacter, sal_Bool bAbsorb )
6341 throw(lang::IllegalArgumentException, uno::RuntimeException)
6343 ScUnoGuard aGuard;
6344 GetUnoText().insertControlCharacter(xRange, nControlCharacter, bAbsorb);
6347 void SAL_CALL ScCellObj::insertTextContent( const uno::Reference<text::XTextRange >& xRange,
6348 const uno::Reference<text::XTextContent >& xContent,
6349 sal_Bool bAbsorb )
6350 throw(lang::IllegalArgumentException, uno::RuntimeException)
6352 ScUnoGuard aGuard;
6353 ScDocShell* pDocSh = GetDocShell();
6354 if ( pDocSh && xContent.is() )
6356 ScCellFieldObj* pCellField = ScCellFieldObj::getImplementation( xContent );
6357 SvxUnoTextRangeBase* pTextRange = ScCellTextCursor::getImplementation( xRange );
6359 #if 0
6360 if (!pTextRange)
6361 pTextRange = SvxUnoTextRangeBase::getImplementation( xRange );
6363 //! bei SvxUnoTextRange testen, ob in passendem Objekt !!!
6364 #endif
6366 if ( pCellField && !pCellField->IsInserted() && pTextRange )
6368 SvxEditSource* pEditSource = pTextRange->GetEditSource();
6369 ESelection aSelection(pTextRange->GetSelection());
6371 if (!bAbsorb)
6373 // nicht ersetzen -> hinten anhaengen
6374 aSelection.Adjust();
6375 aSelection.nStartPara = aSelection.nEndPara;
6376 aSelection.nStartPos = aSelection.nEndPos;
6379 SvxFieldItem aItem(pCellField->CreateFieldItem());
6381 SvxTextForwarder* pForwarder = pEditSource->GetTextForwarder();
6382 pForwarder->QuickInsertField( aItem, aSelection );
6383 pEditSource->UpdateData();
6385 // neue Selektion: ein Zeichen
6386 aSelection.Adjust();
6387 aSelection.nEndPara = aSelection.nStartPara;
6388 aSelection.nEndPos = aSelection.nStartPos + 1;
6389 pCellField->InitDoc( pDocSh, aCellPos, aSelection );
6391 // #91431# for bAbsorb=FALSE, the new selection must be behind the inserted content
6392 // (the xml filter relies on this)
6393 if (!bAbsorb)
6394 aSelection.nStartPos = aSelection.nEndPos;
6396 pTextRange->SetSelection( aSelection );
6398 return;
6401 GetUnoText().insertTextContent(xRange, xContent, bAbsorb);
6404 void SAL_CALL ScCellObj::removeTextContent( const uno::Reference<text::XTextContent>& xContent )
6405 throw(container::NoSuchElementException, uno::RuntimeException)
6407 ScUnoGuard aGuard;
6408 if ( xContent.is() )
6410 ScCellFieldObj* pCellField = ScCellFieldObj::getImplementation( xContent );
6411 if ( pCellField && pCellField->IsInserted() )
6413 //! Testen, ob das Feld in dieser Zelle ist
6414 pCellField->DeleteField();
6415 return;
6418 GetUnoText().removeTextContent(xContent);
6421 uno::Reference<text::XText> SAL_CALL ScCellObj::getText() throw(uno::RuntimeException)
6423 ScUnoGuard aGuard;
6424 return this;
6427 uno::Reference<text::XTextRange> SAL_CALL ScCellObj::getStart() throw(uno::RuntimeException)
6429 ScUnoGuard aGuard;
6430 return GetUnoText().getStart();
6433 uno::Reference<text::XTextRange> SAL_CALL ScCellObj::getEnd() throw(uno::RuntimeException)
6435 ScUnoGuard aGuard;
6436 return GetUnoText().getEnd();
6439 uno::Reference<container::XEnumeration> SAL_CALL ScCellObj::createEnumeration()
6440 throw(uno::RuntimeException)
6442 ScUnoGuard aGuard;
6443 return GetUnoText().createEnumeration();
6446 uno::Type SAL_CALL ScCellObj::getElementType() throw(uno::RuntimeException)
6448 ScUnoGuard aGuard;
6449 return GetUnoText().getElementType();
6452 sal_Bool SAL_CALL ScCellObj::hasElements() throw(uno::RuntimeException)
6454 ScUnoGuard aGuard;
6455 return GetUnoText().hasElements();
6458 // XCell
6460 rtl::OUString SAL_CALL ScCellObj::getFormula() throw(uno::RuntimeException)
6462 ScUnoGuard aGuard;
6463 // TRUE = englisch
6464 return GetInputString_Impl(TRUE);
6467 void SAL_CALL ScCellObj::setFormula( const rtl::OUString& aFormula ) throw(uno::RuntimeException)
6469 ScUnoGuard aGuard;
6470 String aString(aFormula);
6471 SetString_Impl(aString, TRUE, TRUE); // englisch interpretieren
6474 double SAL_CALL ScCellObj::getValue() throw(uno::RuntimeException)
6476 ScUnoGuard aGuard;
6477 return GetValue_Impl();
6480 void SAL_CALL ScCellObj::setValue( double nValue ) throw(uno::RuntimeException)
6482 ScUnoGuard aGuard;
6483 SetValue_Impl(nValue);
6486 table::CellContentType SAL_CALL ScCellObj::getType() throw(uno::RuntimeException)
6488 ScUnoGuard aGuard;
6489 table::CellContentType eRet = table::CellContentType_EMPTY;
6490 ScDocShell* pDocSh = GetDocShell();
6491 if (pDocSh)
6493 CellType eCalcType = pDocSh->GetDocument()->GetCellType( aCellPos );
6494 switch (eCalcType)
6496 case CELLTYPE_VALUE:
6497 eRet = table::CellContentType_VALUE;
6498 break;
6499 case CELLTYPE_STRING:
6500 case CELLTYPE_EDIT:
6501 eRet = table::CellContentType_TEXT;
6502 break;
6503 case CELLTYPE_FORMULA:
6504 eRet = table::CellContentType_FORMULA;
6505 break;
6506 default:
6507 eRet = table::CellContentType_EMPTY;
6510 else
6512 DBG_ERROR("keine DocShell"); //! Exception oder so?
6515 return eRet;
6518 table::CellContentType ScCellObj::GetResultType_Impl()
6520 ScDocShell* pDocSh = GetDocShell();
6521 if ( pDocSh )
6523 ScBaseCell* pCell = pDocSh->GetDocument()->GetCell(aCellPos);
6524 if ( pCell && pCell->GetCellType() == CELLTYPE_FORMULA )
6526 BOOL bValue = ((ScFormulaCell*)pCell)->IsValue();
6527 return bValue ? table::CellContentType_VALUE : table::CellContentType_TEXT;
6530 return getType(); // wenn keine Formel
6533 sal_Int32 SAL_CALL ScCellObj::getError() throw(uno::RuntimeException)
6535 ScUnoGuard aGuard;
6536 USHORT nError = 0;
6537 ScDocShell* pDocSh = GetDocShell();
6538 if (pDocSh)
6540 ScBaseCell* pCell = pDocSh->GetDocument()->GetCell( aCellPos );
6541 if ( pCell && pCell->GetCellType() == CELLTYPE_FORMULA )
6542 nError = ((ScFormulaCell*)pCell)->GetErrCode();
6543 // sonst bleibt's bei 0
6545 else
6547 DBG_ERROR("keine DocShell"); //! Exception oder so?
6550 return nError;
6553 // XFormulaTokens
6555 uno::Sequence<sheet::FormulaToken> SAL_CALL ScCellObj::getTokens() throw(uno::RuntimeException)
6557 ScUnoGuard aGuard;
6558 uno::Sequence<sheet::FormulaToken> aSequence;
6559 ScDocShell* pDocSh = GetDocShell();
6560 if ( pDocSh )
6562 ScDocument* pDoc = pDocSh->GetDocument();
6563 ScBaseCell* pCell = pDoc->GetCell( aCellPos );
6564 if ( pCell && pCell->GetCellType() == CELLTYPE_FORMULA )
6566 ScTokenArray* pTokenArray = static_cast<ScFormulaCell*>(pCell)->GetCode();
6567 if ( pTokenArray )
6568 (void)ScTokenConversion::ConvertToTokenSequence( *pDoc, aSequence, *pTokenArray );
6571 return aSequence;
6574 void SAL_CALL ScCellObj::setTokens( const uno::Sequence<sheet::FormulaToken>& rTokens ) throw(uno::RuntimeException)
6576 ScUnoGuard aGuard;
6577 ScDocShell* pDocSh = GetDocShell();
6578 if ( pDocSh )
6580 ScDocument* pDoc = pDocSh->GetDocument();
6581 ScTokenArray aTokenArray;
6582 (void)ScTokenConversion::ConvertToTokenArray( *pDoc, aTokenArray, rTokens );
6584 ScDocFunc aFunc( *pDocSh );
6585 ScBaseCell* pNewCell = new ScFormulaCell( pDoc, aCellPos, &aTokenArray );
6586 (void)aFunc.PutCell( aCellPos, pNewCell, TRUE );
6590 // XCellAddressable
6592 table::CellAddress SAL_CALL ScCellObj::getCellAddress() throw(uno::RuntimeException)
6594 ScUnoGuard aGuard;
6595 table::CellAddress aAdr;
6596 aAdr.Sheet = aCellPos.Tab();
6597 aAdr.Column = aCellPos.Col();
6598 aAdr.Row = aCellPos.Row();
6599 return aAdr;
6602 // XSheetAnnotationAnchor
6604 uno::Reference<sheet::XSheetAnnotation> SAL_CALL ScCellObj::getAnnotation()
6605 throw(uno::RuntimeException)
6607 ScUnoGuard aGuard;
6608 ScDocShell* pDocSh = GetDocShell();
6609 if ( pDocSh )
6610 return new ScAnnotationObj( pDocSh, aCellPos );
6612 DBG_ERROR("getAnnotation ohne DocShell");
6613 return NULL;
6616 // XFieldTypesSupplier
6618 uno::Reference<container::XEnumerationAccess> SAL_CALL ScCellObj::getTextFields()
6619 throw(uno::RuntimeException)
6621 ScUnoGuard aGuard;
6622 ScDocShell* pDocSh = GetDocShell();
6623 if ( pDocSh )
6624 return new ScCellFieldsObj( pDocSh, aCellPos );
6626 return NULL;
6629 uno::Reference<container::XNameAccess> SAL_CALL ScCellObj::getTextFieldMasters()
6630 throw(uno::RuntimeException)
6632 // sowas gibts nicht im Calc (?)
6633 return NULL;
6636 // XPropertySet erweitert fuer Zell-Properties
6638 uno::Reference<beans::XPropertySetInfo> SAL_CALL ScCellObj::getPropertySetInfo()
6639 throw(uno::RuntimeException)
6641 ScUnoGuard aGuard;
6642 static uno::Reference<beans::XPropertySetInfo> aRef(
6643 new SfxItemPropertySetInfo( pCellPropSet->getPropertyMap() ));
6644 return aRef;
6647 void ScCellObj::SetOnePropertyValue( const SfxItemPropertySimpleEntry* pEntry, const uno::Any& aValue )
6648 throw(lang::IllegalArgumentException, uno::RuntimeException)
6650 if ( pEntry )
6652 if ( pEntry->nWID == SC_WID_UNO_FORMLOC )
6654 rtl::OUString aStrVal;
6655 aValue >>= aStrVal;
6656 String aString(aStrVal);
6657 SetString_Impl(aString, TRUE, FALSE); // lokal interpretieren
6659 else if ( pEntry->nWID == SC_WID_UNO_FORMRT )
6661 // Read-Only
6662 //! Exception oder so...
6664 else
6665 ScCellRangeObj::SetOnePropertyValue( pEntry, aValue );
6669 void ScCellObj::GetOnePropertyValue( const SfxItemPropertySimpleEntry* pEntry,
6670 uno::Any& rAny )
6671 throw(uno::RuntimeException)
6673 if ( pEntry )
6675 if ( pEntry->nWID == SC_WID_UNO_FORMLOC )
6677 // FALSE = lokal
6678 rAny <<= rtl::OUString( GetInputString_Impl(FALSE) );
6680 else if ( pEntry->nWID == SC_WID_UNO_FORMRT )
6682 table::CellContentType eType = GetResultType_Impl();
6683 rAny <<= eType;
6685 else
6686 ScCellRangeObj::GetOnePropertyValue(pEntry, rAny);
6690 const SfxItemPropertyMap* ScCellObj::GetItemPropertyMap()
6692 return pCellPropSet->getPropertyMap();
6695 // XServiceInfo
6697 rtl::OUString SAL_CALL ScCellObj::getImplementationName() throw(uno::RuntimeException)
6699 return rtl::OUString::createFromAscii( "ScCellObj" );
6702 sal_Bool SAL_CALL ScCellObj::supportsService( const rtl::OUString& rServiceName )
6703 throw(uno::RuntimeException)
6705 // CellRange/SheetCellRange are not in SheetCell service description,
6706 // but ScCellObj is used instead of ScCellRangeObj in CellRanges collections,
6707 // so it must support them
6709 String aServiceStr(rServiceName);
6710 return aServiceStr.EqualsAscii( SCSHEETCELL_SERVICE ) ||
6711 aServiceStr.EqualsAscii( SCCELL_SERVICE ) ||
6712 aServiceStr.EqualsAscii( SCCELLPROPERTIES_SERVICE ) ||
6713 aServiceStr.EqualsAscii( SCCHARPROPERTIES_SERVICE ) ||
6714 aServiceStr.EqualsAscii( SCPARAPROPERTIES_SERVICE ) ||
6715 aServiceStr.EqualsAscii( SCSHEETCELLRANGE_SERVICE ) ||
6716 aServiceStr.EqualsAscii( SCCELLRANGE_SERVICE );
6719 uno::Sequence<rtl::OUString> SAL_CALL ScCellObj::getSupportedServiceNames()
6720 throw(uno::RuntimeException)
6722 uno::Sequence<rtl::OUString> aRet(7);
6723 rtl::OUString* pArray = aRet.getArray();
6724 pArray[0] = rtl::OUString::createFromAscii( SCSHEETCELL_SERVICE );
6725 pArray[1] = rtl::OUString::createFromAscii( SCCELL_SERVICE );
6726 pArray[2] = rtl::OUString::createFromAscii( SCCELLPROPERTIES_SERVICE );
6727 pArray[3] = rtl::OUString::createFromAscii( SCCHARPROPERTIES_SERVICE );
6728 pArray[4] = rtl::OUString::createFromAscii( SCPARAPROPERTIES_SERVICE );
6729 pArray[5] = rtl::OUString::createFromAscii( SCSHEETCELLRANGE_SERVICE );
6730 pArray[6] = rtl::OUString::createFromAscii( SCCELLRANGE_SERVICE );
6731 return aRet;
6734 // XActionLockable
6736 sal_Bool SAL_CALL ScCellObj::isActionLocked() throw(uno::RuntimeException)
6738 ScUnoGuard aGuard;
6739 return nActionLockCount != 0;
6742 void SAL_CALL ScCellObj::addActionLock() throw(uno::RuntimeException)
6744 ScUnoGuard aGuard;
6745 if (!nActionLockCount)
6747 if (pUnoText)
6749 ScSharedCellEditSource* pEditSource =
6750 static_cast<ScSharedCellEditSource*> (pUnoText->GetEditSource());
6751 if (pEditSource)
6752 pEditSource->SetDoUpdateData(sal_False);
6755 nActionLockCount++;
6758 void SAL_CALL ScCellObj::removeActionLock() throw(uno::RuntimeException)
6760 ScUnoGuard aGuard;
6761 if (nActionLockCount > 0)
6763 nActionLockCount--;
6764 if (!nActionLockCount)
6766 if (pUnoText)
6768 ScSharedCellEditSource* pEditSource =
6769 static_cast<ScSharedCellEditSource*> (pUnoText->GetEditSource());
6770 if (pEditSource)
6772 pEditSource->SetDoUpdateData(sal_True);
6773 if (pEditSource->IsDirty())
6774 pEditSource->UpdateData();
6781 void SAL_CALL ScCellObj::setActionLocks( sal_Int16 nLock ) throw(uno::RuntimeException)
6783 ScUnoGuard aGuard;
6784 if (pUnoText)
6786 ScSharedCellEditSource* pEditSource =
6787 static_cast<ScSharedCellEditSource*> (pUnoText->GetEditSource());
6788 if (pEditSource)
6790 pEditSource->SetDoUpdateData(nLock == 0);
6791 if ((nActionLockCount > 0) && (nLock == 0) && pEditSource->IsDirty())
6792 pEditSource->UpdateData();
6795 nActionLockCount = nLock;
6798 sal_Int16 SAL_CALL ScCellObj::resetActionLocks() throw(uno::RuntimeException)
6800 ScUnoGuard aGuard;
6801 USHORT nRet(nActionLockCount);
6802 if (pUnoText)
6804 ScSharedCellEditSource* pEditSource =
6805 static_cast<ScSharedCellEditSource*> (pUnoText->GetEditSource());
6806 if (pEditSource)
6808 pEditSource->SetDoUpdateData(sal_True);
6809 if (pEditSource->IsDirty())
6810 pEditSource->UpdateData();
6813 nActionLockCount = 0;
6814 return nRet;
6817 //------------------------------------------------------------------------
6819 ScTableSheetObj::ScTableSheetObj( ScDocShell* pDocSh, SCTAB nTab ) :
6820 ScCellRangeObj( pDocSh, ScRange(0,0,nTab, MAXCOL,MAXROW,nTab) ),
6821 pSheetPropSet(lcl_GetSheetPropertySet())
6825 ScTableSheetObj::~ScTableSheetObj()
6829 void ScTableSheetObj::InitInsertSheet(ScDocShell* pDocSh, SCTAB nTab)
6831 InitInsertRange( pDocSh, ScRange(0,0,nTab, MAXCOL,MAXROW,nTab) );
6834 uno::Any SAL_CALL ScTableSheetObj::queryInterface( const uno::Type& rType ) throw(uno::RuntimeException)
6836 SC_QUERYINTERFACE( sheet::XSpreadsheet )
6837 SC_QUERYINTERFACE( container::XNamed )
6838 SC_QUERYINTERFACE( sheet::XSheetPageBreak )
6839 SC_QUERYINTERFACE( sheet::XCellRangeMovement )
6840 SC_QUERYINTERFACE( table::XTableChartsSupplier )
6841 SC_QUERYINTERFACE( sheet::XDataPilotTablesSupplier )
6842 SC_QUERYINTERFACE( sheet::XScenariosSupplier )
6843 SC_QUERYINTERFACE( sheet::XSheetAnnotationsSupplier )
6844 SC_QUERYINTERFACE( drawing::XDrawPageSupplier )
6845 SC_QUERYINTERFACE( sheet::XPrintAreas )
6846 SC_QUERYINTERFACE( sheet::XSheetAuditing )
6847 SC_QUERYINTERFACE( sheet::XSheetOutline )
6848 SC_QUERYINTERFACE( util::XProtectable )
6849 SC_QUERYINTERFACE( sheet::XScenario )
6850 SC_QUERYINTERFACE( sheet::XScenarioEnhanced )
6851 SC_QUERYINTERFACE( sheet::XSheetLinkable )
6852 SC_QUERYINTERFACE( sheet::XExternalSheetName )
6854 return ScCellRangeObj::queryInterface( rType );
6857 void SAL_CALL ScTableSheetObj::acquire() throw()
6859 ScCellRangeObj::acquire();
6862 void SAL_CALL ScTableSheetObj::release() throw()
6864 ScCellRangeObj::release();
6867 uno::Sequence<uno::Type> SAL_CALL ScTableSheetObj::getTypes() throw(uno::RuntimeException)
6869 static uno::Sequence<uno::Type> aTypes;
6870 if ( aTypes.getLength() == 0 )
6872 uno::Sequence<uno::Type> aParentTypes = ScCellRangeObj::getTypes();
6873 long nParentLen = aParentTypes.getLength();
6874 const uno::Type* pParentPtr = aParentTypes.getConstArray();
6876 aTypes.realloc( nParentLen + 17 );
6877 uno::Type* pPtr = aTypes.getArray();
6878 pPtr[nParentLen + 0] = getCppuType((const uno::Reference<sheet::XSpreadsheet>*)0);
6879 pPtr[nParentLen + 1] = getCppuType((const uno::Reference<container::XNamed>*)0);
6880 pPtr[nParentLen + 2] = getCppuType((const uno::Reference<sheet::XSheetPageBreak>*)0);
6881 pPtr[nParentLen + 3] = getCppuType((const uno::Reference<sheet::XCellRangeMovement>*)0);
6882 pPtr[nParentLen + 4] = getCppuType((const uno::Reference<table::XTableChartsSupplier>*)0);
6883 pPtr[nParentLen + 5] = getCppuType((const uno::Reference<sheet::XDataPilotTablesSupplier>*)0);
6884 pPtr[nParentLen + 6] = getCppuType((const uno::Reference<sheet::XScenariosSupplier>*)0);
6885 pPtr[nParentLen + 7] = getCppuType((const uno::Reference<sheet::XSheetAnnotationsSupplier>*)0);
6886 pPtr[nParentLen + 8] = getCppuType((const uno::Reference<drawing::XDrawPageSupplier>*)0);
6887 pPtr[nParentLen + 9] = getCppuType((const uno::Reference<sheet::XPrintAreas>*)0);
6888 pPtr[nParentLen +10] = getCppuType((const uno::Reference<sheet::XSheetAuditing>*)0);
6889 pPtr[nParentLen +11] = getCppuType((const uno::Reference<sheet::XSheetOutline>*)0);
6890 pPtr[nParentLen +12] = getCppuType((const uno::Reference<util::XProtectable>*)0);
6891 pPtr[nParentLen +13] = getCppuType((const uno::Reference<sheet::XScenario>*)0);
6892 pPtr[nParentLen +14] = getCppuType((const uno::Reference<sheet::XScenarioEnhanced>*)0);
6893 pPtr[nParentLen +15] = getCppuType((const uno::Reference<sheet::XSheetLinkable>*)0);
6894 pPtr[nParentLen +16] = getCppuType((const uno::Reference<sheet::XExternalSheetName>*)0);
6896 for (long i=0; i<nParentLen; i++)
6897 pPtr[i] = pParentPtr[i]; // parent types first
6899 return aTypes;
6902 uno::Sequence<sal_Int8> SAL_CALL ScTableSheetObj::getImplementationId() throw(uno::RuntimeException)
6904 static uno::Sequence< sal_Int8 > aId;
6905 if( aId.getLength() == 0 )
6907 aId.realloc( 16 );
6908 rtl_createUuid( (sal_uInt8 *)aId.getArray(), 0, sal_True );
6910 return aId;
6913 // Hilfsfunktionen
6915 SCTAB ScTableSheetObj::GetTab_Impl() const
6917 const ScRangeList& rRanges = GetRangeList();
6918 DBG_ASSERT(rRanges.Count() == 1, "was fuer Ranges ?!?!");
6919 const ScRange* pFirst = rRanges.GetObject(0);
6920 if (pFirst)
6921 return pFirst->aStart.Tab();
6923 return 0; // soll nicht sein
6926 // former XSheet
6928 uno::Reference<table::XTableCharts> SAL_CALL ScTableSheetObj::getCharts() throw(uno::RuntimeException)
6930 ScUnoGuard aGuard;
6931 ScDocShell* pDocSh = GetDocShell();
6932 if ( pDocSh )
6933 return new ScChartsObj( pDocSh, GetTab_Impl() );
6935 DBG_ERROR("kein Dokument");
6936 return NULL;
6939 uno::Reference<sheet::XDataPilotTables> SAL_CALL ScTableSheetObj::getDataPilotTables()
6940 throw(uno::RuntimeException)
6942 ScUnoGuard aGuard;
6943 ScDocShell* pDocSh = GetDocShell();
6944 if ( pDocSh )
6945 return new ScDataPilotTablesObj( pDocSh, GetTab_Impl() );
6947 DBG_ERROR("kein Dokument");
6948 return NULL;
6951 uno::Reference<sheet::XScenarios> SAL_CALL ScTableSheetObj::getScenarios() throw(uno::RuntimeException)
6953 ScUnoGuard aGuard;
6954 ScDocShell* pDocSh = GetDocShell();
6956 if ( pDocSh )
6957 return new ScScenariosObj( pDocSh, GetTab_Impl() );
6959 DBG_ERROR("kein Dokument");
6960 return NULL;
6963 uno::Reference<sheet::XSheetAnnotations> SAL_CALL ScTableSheetObj::getAnnotations()
6964 throw(uno::RuntimeException)
6966 ScUnoGuard aGuard;
6967 ScDocShell* pDocSh = GetDocShell();
6969 if ( pDocSh )
6970 return new ScAnnotationsObj( pDocSh, GetTab_Impl() );
6972 DBG_ERROR("kein Dokument");
6973 return NULL;
6976 uno::Reference<table::XCellRange> SAL_CALL ScTableSheetObj::getCellRangeByName(
6977 const rtl::OUString& rRange ) throw(uno::RuntimeException)
6979 ScUnoGuard aGuard;
6980 return ScCellRangeObj::getCellRangeByName( rRange );
6983 uno::Reference<sheet::XSheetCellCursor> SAL_CALL ScTableSheetObj::createCursor()
6984 throw(uno::RuntimeException)
6986 ScUnoGuard aGuard;
6987 ScDocShell* pDocSh = GetDocShell();
6988 if ( pDocSh )
6990 //! einzelne Zelle oder ganze Tabelle???????
6991 SCTAB nTab = GetTab_Impl();
6992 return new ScCellCursorObj( pDocSh, ScRange( 0,0,nTab, MAXCOL,MAXROW,nTab ) );
6994 return NULL;
6997 uno::Reference<sheet::XSheetCellCursor> SAL_CALL ScTableSheetObj::createCursorByRange(
6998 const uno::Reference<sheet::XSheetCellRange>& xCellRange )
6999 throw(uno::RuntimeException)
7001 ScUnoGuard aGuard;
7002 ScDocShell* pDocSh = GetDocShell();
7003 if ( pDocSh && xCellRange.is() )
7005 ScCellRangesBase* pRangesImp = ScCellRangesBase::getImplementation( xCellRange );
7006 if (pRangesImp)
7008 const ScRangeList& rRanges = pRangesImp->GetRangeList();
7009 DBG_ASSERT( rRanges.Count() == 1, "Range? Ranges?" );
7010 return new ScCellCursorObj( pDocSh, *rRanges.GetObject(0) );
7013 return NULL;
7016 // XSheetCellRange
7018 uno::Reference<sheet::XSpreadsheet> SAL_CALL ScTableSheetObj::getSpreadsheet()
7019 throw(uno::RuntimeException)
7021 ScUnoGuard aGuard;
7022 return this; //!???
7025 // XCellRange
7027 uno::Reference<table::XCell> SAL_CALL ScTableSheetObj::getCellByPosition(
7028 sal_Int32 nColumn, sal_Int32 nRow )
7029 throw(lang::IndexOutOfBoundsException, uno::RuntimeException)
7031 ScUnoGuard aGuard;
7032 return ScCellRangeObj::GetCellByPosition_Impl(nColumn, nRow);
7035 uno::Reference<table::XCellRange> SAL_CALL ScTableSheetObj::getCellRangeByPosition(
7036 sal_Int32 nLeft, sal_Int32 nTop, sal_Int32 nRight, sal_Int32 nBottom )
7037 throw(lang::IndexOutOfBoundsException, uno::RuntimeException)
7039 ScUnoGuard aGuard;
7040 return ScCellRangeObj::getCellRangeByPosition(nLeft,nTop,nRight,nBottom);
7043 uno::Sequence<sheet::TablePageBreakData> SAL_CALL ScTableSheetObj::getColumnPageBreaks()
7044 throw(uno::RuntimeException)
7046 ScUnoGuard aGuard;
7047 ScDocShell* pDocSh = GetDocShell();
7048 if ( pDocSh )
7050 ScDocument* pDoc = pDocSh->GetDocument();
7051 SCTAB nTab = GetTab_Impl();
7053 Size aSize(pDoc->GetPageSize( nTab ));
7054 if (aSize.Width() && aSize.Height()) // effektive Groesse schon gesetzt?
7055 pDoc->UpdatePageBreaks( nTab );
7056 else
7058 // Umbrueche updaten wie in ScDocShell::PageStyleModified:
7059 ScPrintFunc aPrintFunc( pDocSh, pDocSh->GetPrinter(), nTab );
7060 aPrintFunc.UpdatePages();
7063 SCCOL nCount = 0;
7064 SCCOL nCol;
7065 for (nCol=0; nCol<=MAXCOL; nCol++)
7066 if (pDoc->HasColBreak(nCol, nTab))
7067 ++nCount;
7069 sheet::TablePageBreakData aData;
7070 uno::Sequence<sheet::TablePageBreakData> aSeq(nCount);
7071 sheet::TablePageBreakData* pAry = aSeq.getArray();
7072 USHORT nPos = 0;
7073 for (nCol=0; nCol<=MAXCOL; nCol++)
7075 ScBreakType nBreak = pDoc->HasColBreak(nCol, nTab);
7076 if (nBreak)
7078 aData.Position = nCol;
7079 aData.ManualBreak = (nBreak & BREAK_MANUAL);
7080 pAry[nPos] = aData;
7081 ++nPos;
7084 return aSeq;
7086 return uno::Sequence<sheet::TablePageBreakData>(0);
7089 uno::Sequence<sheet::TablePageBreakData> SAL_CALL ScTableSheetObj::getRowPageBreaks()
7090 throw(uno::RuntimeException)
7092 ScUnoGuard aGuard;
7093 ScDocShell* pDocSh = GetDocShell();
7094 if ( pDocSh )
7096 ScDocument* pDoc = pDocSh->GetDocument();
7097 SCTAB nTab = GetTab_Impl();
7099 Size aSize(pDoc->GetPageSize( nTab ));
7100 if (aSize.Width() && aSize.Height()) // effektive Groesse schon gesetzt?
7101 pDoc->UpdatePageBreaks( nTab );
7102 else
7104 // Umbrueche updaten wie in ScDocShell::PageStyleModified:
7105 ScPrintFunc aPrintFunc( pDocSh, pDocSh->GetPrinter(), nTab );
7106 aPrintFunc.UpdatePages();
7108 return pDoc->GetRowBreakData(nTab);
7110 return uno::Sequence<sheet::TablePageBreakData>(0);
7113 void SAL_CALL ScTableSheetObj::removeAllManualPageBreaks() throw(uno::RuntimeException)
7115 ScUnoGuard aGuard;
7116 ScDocShell* pDocSh = GetDocShell();
7117 if ( pDocSh )
7119 //! docfunc Funktion, auch fuer ScViewFunc::RemoveManualBreaks
7121 ScDocument* pDoc = pDocSh->GetDocument();
7122 BOOL bUndo (pDoc->IsUndoEnabled());
7123 SCTAB nTab = GetTab_Impl();
7125 if (bUndo)
7127 ScDocument* pUndoDoc = new ScDocument( SCDOCMODE_UNDO );
7128 pUndoDoc->InitUndo( pDoc, nTab, nTab, TRUE, TRUE );
7129 pDoc->CopyToDocument( 0,0,nTab, MAXCOL,MAXROW,nTab, IDF_NONE, FALSE, pUndoDoc );
7130 pDocSh->GetUndoManager()->AddUndoAction(
7131 new ScUndoRemoveBreaks( pDocSh, nTab, pUndoDoc ) );
7134 pDoc->RemoveManualBreaks(nTab);
7135 pDoc->UpdatePageBreaks(nTab);
7137 //? UpdatePageBreakData( TRUE );
7138 pDocSh->SetDocumentModified();
7139 pDocSh->PostPaint( 0,0,nTab, MAXCOL,MAXROW,nTab, PAINT_GRID );
7143 // XNamed
7145 rtl::OUString SAL_CALL ScTableSheetObj::getName() throw(uno::RuntimeException)
7147 ScUnoGuard aGuard;
7148 String aName;
7149 ScDocShell* pDocSh = GetDocShell();
7150 if ( pDocSh )
7151 pDocSh->GetDocument()->GetName( GetTab_Impl(), aName );
7152 return aName;
7155 void SAL_CALL ScTableSheetObj::setName( const rtl::OUString& aNewName )
7156 throw(uno::RuntimeException)
7158 ScUnoGuard aGuard;
7159 ScDocShell* pDocSh = GetDocShell();
7160 if ( pDocSh )
7162 String aString(aNewName);
7163 ScDocFunc aFunc( *pDocSh );
7164 aFunc.RenameTable( GetTab_Impl(), aString, TRUE, TRUE );
7168 // XDrawPageSupplier
7170 uno::Reference<drawing::XDrawPage> SAL_CALL ScTableSheetObj::getDrawPage()
7171 throw(uno::RuntimeException)
7173 ScUnoGuard aGuard;
7174 ScDocShell* pDocSh = GetDocShell();
7175 if ( pDocSh )
7177 ScDrawLayer* pDrawLayer = pDocSh->MakeDrawLayer();
7178 DBG_ASSERT(pDrawLayer,"kann Draw-Layer nicht anlegen");
7180 SCTAB nTab = GetTab_Impl();
7181 SdrPage* pPage = pDrawLayer->GetPage(static_cast<sal_uInt16>(nTab));
7182 DBG_ASSERT(pPage,"Draw-Page nicht gefunden");
7183 if (pPage)
7184 return uno::Reference<drawing::XDrawPage> (pPage->getUnoPage(), uno::UNO_QUERY);
7186 // Das DrawPage-Objekt meldet sich als Listener am SdrModel an
7187 // und sollte von dort alle Aktionen mitbekommen
7189 return NULL;
7192 // XCellMovement
7194 void SAL_CALL ScTableSheetObj::insertCells( const table::CellRangeAddress& rRangeAddress,
7195 sheet::CellInsertMode nMode ) throw(uno::RuntimeException)
7197 ScUnoGuard aGuard;
7198 ScDocShell* pDocSh = GetDocShell();
7199 if ( pDocSh )
7201 BOOL bDo = TRUE;
7202 InsCellCmd eCmd = INS_NONE;
7203 switch (nMode)
7205 case sheet::CellInsertMode_NONE: bDo = FALSE; break;
7206 case sheet::CellInsertMode_DOWN: eCmd = INS_CELLSDOWN; break;
7207 case sheet::CellInsertMode_RIGHT: eCmd = INS_CELLSRIGHT; break;
7208 case sheet::CellInsertMode_ROWS: eCmd = INS_INSROWS; break;
7209 case sheet::CellInsertMode_COLUMNS: eCmd = INS_INSCOLS; break;
7210 default:
7211 DBG_ERROR("insertCells: falscher Mode");
7212 bDo = FALSE;
7215 if (bDo)
7217 DBG_ASSERT( rRangeAddress.Sheet == GetTab_Impl(), "falsche Tabelle in CellRangeAddress" );
7218 ScRange aScRange;
7219 ScUnoConversion::FillScRange( aScRange, rRangeAddress );
7220 ScDocFunc aFunc(*pDocSh);
7221 aFunc.InsertCells( aScRange, NULL, eCmd, TRUE, TRUE );
7226 void SAL_CALL ScTableSheetObj::removeRange( const table::CellRangeAddress& rRangeAddress,
7227 sheet::CellDeleteMode nMode ) throw(uno::RuntimeException)
7229 ScUnoGuard aGuard;
7230 ScDocShell* pDocSh = GetDocShell();
7231 if ( pDocSh )
7233 BOOL bDo = TRUE;
7234 DelCellCmd eCmd = DEL_NONE;
7235 switch (nMode)
7237 case sheet::CellDeleteMode_NONE: bDo = FALSE; break;
7238 case sheet::CellDeleteMode_UP: eCmd = DEL_CELLSUP; break;
7239 case sheet::CellDeleteMode_LEFT: eCmd = DEL_CELLSLEFT; break;
7240 case sheet::CellDeleteMode_ROWS: eCmd = DEL_DELROWS; break;
7241 case sheet::CellDeleteMode_COLUMNS: eCmd = DEL_DELCOLS; break;
7242 default:
7243 DBG_ERROR("deleteCells: falscher Mode");
7244 bDo = FALSE;
7247 if (bDo)
7249 DBG_ASSERT( rRangeAddress.Sheet == GetTab_Impl(), "falsche Tabelle in CellRangeAddress" );
7250 ScRange aScRange;
7251 ScUnoConversion::FillScRange( aScRange, rRangeAddress );
7252 ScDocFunc aFunc(*pDocSh);
7253 aFunc.DeleteCells( aScRange, NULL, eCmd, TRUE, TRUE );
7258 void SAL_CALL ScTableSheetObj::moveRange( const table::CellAddress& aDestination,
7259 const table::CellRangeAddress& aSource )
7260 throw(uno::RuntimeException)
7262 ScUnoGuard aGuard;
7263 ScDocShell* pDocSh = GetDocShell();
7264 if ( pDocSh )
7266 DBG_ASSERT( aSource.Sheet == GetTab_Impl(), "falsche Tabelle in CellRangeAddress" );
7267 ScRange aSourceRange;
7268 ScUnoConversion::FillScRange( aSourceRange, aSource );
7269 ScAddress aDestPos( (SCCOL)aDestination.Column, (SCROW)aDestination.Row, aDestination.Sheet );
7270 ScDocFunc aFunc(*pDocSh);
7271 aFunc.MoveBlock( aSourceRange, aDestPos, TRUE, TRUE, TRUE, TRUE );
7275 void SAL_CALL ScTableSheetObj::copyRange( const table::CellAddress& aDestination,
7276 const table::CellRangeAddress& aSource )
7277 throw(uno::RuntimeException)
7279 ScUnoGuard aGuard;
7280 ScDocShell* pDocSh = GetDocShell();
7281 if ( pDocSh )
7283 DBG_ASSERT( aSource.Sheet == GetTab_Impl(), "falsche Tabelle in CellRangeAddress" );
7284 ScRange aSourceRange;
7285 ScUnoConversion::FillScRange( aSourceRange, aSource );
7286 ScAddress aDestPos( (SCCOL)aDestination.Column, (SCROW)aDestination.Row, aDestination.Sheet );
7287 ScDocFunc aFunc(*pDocSh);
7288 aFunc.MoveBlock( aSourceRange, aDestPos, FALSE, TRUE, TRUE, TRUE );
7292 // XPrintAreas
7294 void ScTableSheetObj::PrintAreaUndo_Impl( ScPrintRangeSaver* pOldRanges )
7296 // Umbrueche und Undo
7298 ScDocShell* pDocSh = GetDocShell();
7299 if ( pDocSh )
7301 ScDocument* pDoc = pDocSh->GetDocument();
7302 BOOL bUndo(pDoc->IsUndoEnabled());
7303 SCTAB nTab = GetTab_Impl();
7305 ScPrintRangeSaver* pNewRanges = pDoc->CreatePrintRangeSaver();
7306 if (bUndo)
7308 pDocSh->GetUndoManager()->AddUndoAction(
7309 new ScUndoPrintRange( pDocSh, nTab, pOldRanges, pNewRanges ) );
7312 ScPrintFunc( pDocSh, pDocSh->GetPrinter(), nTab ).UpdatePages();
7314 SfxBindings* pBindings = pDocSh->GetViewBindings();
7315 if (pBindings)
7316 pBindings->Invalidate( SID_DELETE_PRINTAREA );
7318 pDocSh->SetDocumentModified();
7320 else
7321 delete pOldRanges;
7324 uno::Sequence<table::CellRangeAddress> SAL_CALL ScTableSheetObj::getPrintAreas()
7325 throw(uno::RuntimeException)
7327 ScUnoGuard aGuard;
7328 ScDocShell* pDocSh = GetDocShell();
7329 if ( pDocSh )
7331 ScDocument* pDoc = pDocSh->GetDocument();
7332 SCTAB nTab = GetTab_Impl();
7333 USHORT nCount = pDoc->GetPrintRangeCount( nTab );
7335 table::CellRangeAddress aRangeAddress;
7336 uno::Sequence<table::CellRangeAddress> aSeq(nCount);
7337 table::CellRangeAddress* pAry = aSeq.getArray();
7338 for (USHORT i=0; i<nCount; i++)
7340 const ScRange* pRange = pDoc->GetPrintRange( nTab, i );
7341 DBG_ASSERT(pRange,"wo ist der Druckbereich");
7342 if (pRange)
7344 ScUnoConversion::FillApiRange( aRangeAddress, *pRange );
7345 aRangeAddress.Sheet = nTab; // core does not care about sheet index
7346 pAry[i] = aRangeAddress;
7349 return aSeq;
7351 return uno::Sequence<table::CellRangeAddress>();
7354 void SAL_CALL ScTableSheetObj::setPrintAreas(
7355 const uno::Sequence<table::CellRangeAddress>& aPrintAreas )
7356 throw(uno::RuntimeException)
7358 ScUnoGuard aGuard;
7359 ScDocShell* pDocSh = GetDocShell();
7360 if ( pDocSh )
7362 ScDocument* pDoc = pDocSh->GetDocument();
7363 SCTAB nTab = GetTab_Impl();
7365 ScPrintRangeSaver* pOldRanges = pDoc->CreatePrintRangeSaver();
7367 USHORT nCount = (USHORT) aPrintAreas.getLength();
7368 pDoc->ClearPrintRanges( nTab );
7369 if (nCount)
7371 ScRange aPrintRange;
7372 const table::CellRangeAddress* pAry = aPrintAreas.getConstArray();
7373 for (USHORT i=0; i<nCount; i++)
7375 ScUnoConversion::FillScRange( aPrintRange, pAry[i] );
7376 pDoc->AddPrintRange( nTab, aPrintRange );
7380 PrintAreaUndo_Impl( pOldRanges ); // Undo, Umbrueche, Modified etc.
7384 sal_Bool SAL_CALL ScTableSheetObj::getPrintTitleColumns() throw(uno::RuntimeException)
7386 ScUnoGuard aGuard;
7387 ScDocShell* pDocSh = GetDocShell();
7388 if ( pDocSh )
7390 ScDocument* pDoc = pDocSh->GetDocument();
7391 SCTAB nTab = GetTab_Impl();
7392 return ( pDoc->GetRepeatColRange(nTab) != NULL );
7394 return FALSE;
7397 void SAL_CALL ScTableSheetObj::setPrintTitleColumns( sal_Bool bPrintTitleColumns )
7398 throw(uno::RuntimeException)
7400 ScUnoGuard aGuard;
7401 ScDocShell* pDocSh = GetDocShell();
7402 if ( pDocSh )
7404 ScDocument* pDoc = pDocSh->GetDocument();
7405 SCTAB nTab = GetTab_Impl();
7407 ScPrintRangeSaver* pOldRanges = pDoc->CreatePrintRangeSaver();
7409 if ( bPrintTitleColumns )
7411 if ( !pDoc->GetRepeatColRange( nTab ) ) // keinen bestehenden Bereich veraendern
7413 ScRange aNew( 0, 0, nTab, 0, 0, nTab ); // Default
7414 pDoc->SetRepeatColRange( nTab, &aNew ); // einschalten
7417 else
7418 pDoc->SetRepeatColRange( nTab, NULL ); // abschalten
7420 PrintAreaUndo_Impl( pOldRanges ); // Undo, Umbrueche, Modified etc.
7422 //! zuletzt gesetzten Bereich beim Abschalten merken und beim Einschalten wiederherstellen ???
7426 table::CellRangeAddress SAL_CALL ScTableSheetObj::getTitleColumns() throw(uno::RuntimeException)
7428 ScUnoGuard aGuard;
7429 table::CellRangeAddress aRet;
7430 ScDocShell* pDocSh = GetDocShell();
7431 if ( pDocSh )
7433 ScDocument* pDoc = pDocSh->GetDocument();
7434 SCTAB nTab = GetTab_Impl();
7435 const ScRange* pRange = pDoc->GetRepeatColRange(nTab);
7436 if (pRange)
7438 ScUnoConversion::FillApiRange( aRet, *pRange );
7439 aRet.Sheet = nTab; // core does not care about sheet index
7442 return aRet;
7445 void SAL_CALL ScTableSheetObj::setTitleColumns( const table::CellRangeAddress& aTitleColumns )
7446 throw(uno::RuntimeException)
7448 ScUnoGuard aGuard;
7449 ScDocShell* pDocSh = GetDocShell();
7450 if ( pDocSh )
7452 ScDocument* pDoc = pDocSh->GetDocument();
7453 SCTAB nTab = GetTab_Impl();
7455 ScPrintRangeSaver* pOldRanges = pDoc->CreatePrintRangeSaver();
7457 ScRange aNew;
7458 ScUnoConversion::FillScRange( aNew, aTitleColumns );
7459 pDoc->SetRepeatColRange( nTab, &aNew ); // immer auch einschalten
7461 PrintAreaUndo_Impl( pOldRanges ); // Undo, Umbrueche, Modified etc.
7465 sal_Bool SAL_CALL ScTableSheetObj::getPrintTitleRows() throw(uno::RuntimeException)
7467 ScUnoGuard aGuard;
7468 ScDocShell* pDocSh = GetDocShell();
7469 if ( pDocSh )
7471 ScDocument* pDoc = pDocSh->GetDocument();
7472 SCTAB nTab = GetTab_Impl();
7473 return ( pDoc->GetRepeatRowRange(nTab) != NULL );
7475 return FALSE;
7478 void SAL_CALL ScTableSheetObj::setPrintTitleRows( sal_Bool bPrintTitleRows )
7479 throw(uno::RuntimeException)
7481 ScUnoGuard aGuard;
7482 ScDocShell* pDocSh = GetDocShell();
7483 if ( pDocSh )
7485 ScDocument* pDoc = pDocSh->GetDocument();
7486 SCTAB nTab = GetTab_Impl();
7488 ScPrintRangeSaver* pOldRanges = pDoc->CreatePrintRangeSaver();
7490 if ( bPrintTitleRows )
7492 if ( !pDoc->GetRepeatRowRange( nTab ) ) // keinen bestehenden Bereich veraendern
7494 ScRange aNew( 0, 0, nTab, 0, 0, nTab ); // Default
7495 pDoc->SetRepeatRowRange( nTab, &aNew ); // einschalten
7498 else
7499 pDoc->SetRepeatRowRange( nTab, NULL ); // abschalten
7501 PrintAreaUndo_Impl( pOldRanges ); // Undo, Umbrueche, Modified etc.
7503 //! zuletzt gesetzten Bereich beim Abschalten merken und beim Einschalten wiederherstellen ???
7507 table::CellRangeAddress SAL_CALL ScTableSheetObj::getTitleRows() throw(uno::RuntimeException)
7509 ScUnoGuard aGuard;
7510 table::CellRangeAddress aRet;
7511 ScDocShell* pDocSh = GetDocShell();
7512 if ( pDocSh )
7514 ScDocument* pDoc = pDocSh->GetDocument();
7515 SCTAB nTab = GetTab_Impl();
7516 const ScRange* pRange = pDoc->GetRepeatRowRange(nTab);
7517 if (pRange)
7519 ScUnoConversion::FillApiRange( aRet, *pRange );
7520 aRet.Sheet = nTab; // core does not care about sheet index
7523 return aRet;
7526 void SAL_CALL ScTableSheetObj::setTitleRows( const table::CellRangeAddress& aTitleRows )
7527 throw(uno::RuntimeException)
7529 ScUnoGuard aGuard;
7530 ScDocShell* pDocSh = GetDocShell();
7531 if ( pDocSh )
7533 ScDocument* pDoc = pDocSh->GetDocument();
7534 SCTAB nTab = GetTab_Impl();
7536 ScPrintRangeSaver* pOldRanges = pDoc->CreatePrintRangeSaver();
7538 ScRange aNew;
7539 ScUnoConversion::FillScRange( aNew, aTitleRows );
7540 pDoc->SetRepeatRowRange( nTab, &aNew ); // immer auch einschalten
7542 PrintAreaUndo_Impl( pOldRanges ); // Undo, Umbrueche, Modified etc.
7546 // XSheetLinkable
7548 sheet::SheetLinkMode SAL_CALL ScTableSheetObj::getLinkMode() throw(uno::RuntimeException)
7550 ScUnoGuard aGuard;
7551 sheet::SheetLinkMode eRet = sheet::SheetLinkMode_NONE;
7552 ScDocShell* pDocSh = GetDocShell();
7553 if ( pDocSh )
7555 BYTE nMode = pDocSh->GetDocument()->GetLinkMode( GetTab_Impl() );
7556 if ( nMode == SC_LINK_NORMAL )
7557 eRet = sheet::SheetLinkMode_NORMAL;
7558 else if ( nMode == SC_LINK_VALUE )
7559 eRet = sheet::SheetLinkMode_VALUE;
7561 return eRet;
7564 void SAL_CALL ScTableSheetObj::setLinkMode( sheet::SheetLinkMode nLinkMode )
7565 throw(uno::RuntimeException)
7567 ScUnoGuard aGuard;
7569 //! Filter und Options aus altem Link suchen
7571 rtl::OUString aUrl(getLinkUrl());
7572 rtl::OUString aSheet(getLinkSheetName());
7574 rtl::OUString aEmpty;
7575 link( aUrl, aSheet, aEmpty, aEmpty, nLinkMode );
7578 rtl::OUString SAL_CALL ScTableSheetObj::getLinkUrl() throw(uno::RuntimeException)
7580 ScUnoGuard aGuard;
7581 String aFile;
7582 ScDocShell* pDocSh = GetDocShell();
7583 if ( pDocSh )
7584 aFile = pDocSh->GetDocument()->GetLinkDoc( GetTab_Impl() );
7585 return aFile;
7588 void SAL_CALL ScTableSheetObj::setLinkUrl( const rtl::OUString& aLinkUrl )
7589 throw(uno::RuntimeException)
7591 ScUnoGuard aGuard;
7593 //! Filter und Options aus altem Link suchen
7595 sheet::SheetLinkMode eMode = getLinkMode();
7596 rtl::OUString aSheet(getLinkSheetName());
7598 rtl::OUString aEmpty;
7599 link( aLinkUrl, aSheet, aEmpty, aEmpty, eMode );
7602 rtl::OUString SAL_CALL ScTableSheetObj::getLinkSheetName() throw(uno::RuntimeException)
7604 ScUnoGuard aGuard;
7605 String aSheet;
7606 ScDocShell* pDocSh = GetDocShell();
7607 if ( pDocSh )
7608 aSheet = pDocSh->GetDocument()->GetLinkTab( GetTab_Impl() );
7609 return aSheet;
7612 void SAL_CALL ScTableSheetObj::setLinkSheetName( const rtl::OUString& aLinkSheetName )
7613 throw(uno::RuntimeException)
7615 ScUnoGuard aGuard;
7617 //! Filter und Options aus altem Link suchen
7619 sheet::SheetLinkMode eMode = getLinkMode();
7620 rtl::OUString aUrl(getLinkUrl());
7622 rtl::OUString aEmpty;
7623 link( aUrl, aLinkSheetName, aEmpty, aEmpty, eMode );
7626 void SAL_CALL ScTableSheetObj::link( const rtl::OUString& aUrl, const rtl::OUString& aSheetName,
7627 const rtl::OUString& aFilterName, const rtl::OUString& aFilterOptions,
7628 sheet::SheetLinkMode nMode ) throw(uno::RuntimeException)
7630 ScUnoGuard aGuard;
7631 ScDocShell* pDocSh = GetDocShell();
7632 if ( pDocSh )
7634 ScDocument* pDoc = pDocSh->GetDocument();
7635 SCTAB nTab = GetTab_Impl();
7637 String aFileString (aUrl);
7638 String aFilterString (aFilterName);
7639 String aOptString (aFilterOptions);
7640 String aSheetString (aSheetName);
7642 aFileString = ScGlobal::GetAbsDocName( aFileString, pDocSh );
7643 if ( !aFilterString.Len() )
7644 ScDocumentLoader::GetFilterName( aFileString, aFilterString, aOptString, TRUE, FALSE );
7646 // remove application prefix from filter name here, so the filter options
7647 // aren't reset when the filter name is changed in ScTableLink::DataChanged
7648 ScDocumentLoader::RemoveAppPrefix( aFilterString );
7650 BYTE nLinkMode = SC_LINK_NONE;
7651 if ( nMode == sheet::SheetLinkMode_NORMAL )
7652 nLinkMode = SC_LINK_NORMAL;
7653 else if ( nMode == sheet::SheetLinkMode_VALUE )
7654 nLinkMode = SC_LINK_VALUE;
7656 ULONG nRefresh = 0;
7657 pDoc->SetLink( nTab, nLinkMode, aFileString, aFilterString, aOptString, aSheetString, nRefresh );
7659 pDocSh->UpdateLinks(); // ggf. Link eintragen oder loeschen
7660 SfxBindings* pBindings = pDocSh->GetViewBindings();
7661 if (pBindings)
7662 pBindings->Invalidate(SID_LINKS);
7664 //! Undo fuer Link-Daten an der Table
7666 if ( nLinkMode != SC_LINK_NONE && pDoc->IsExecuteLinkEnabled() ) // Link updaten
7668 // Update immer, auch wenn der Link schon da war
7669 //! Update nur fuer die betroffene Tabelle???
7671 SvxLinkManager* pLinkManager = pDoc->GetLinkManager();
7672 USHORT nCount = pLinkManager->GetLinks().Count();
7673 for ( USHORT i=0; i<nCount; i++ )
7675 ::sfx2::SvBaseLink* pBase = *pLinkManager->GetLinks()[i];
7676 if (pBase->ISA(ScTableLink))
7678 ScTableLink* pTabLink = (ScTableLink*)pBase;
7679 if ( pTabLink->GetFileName() == aFileString )
7680 pTabLink->Update(); // inkl. Paint&Undo
7682 //! Der Dateiname sollte nur einmal vorkommen (?)
7687 //! Notify fuer ScSheetLinkObj Objekte!!!
7691 // XSheetAuditing
7693 sal_Bool SAL_CALL ScTableSheetObj::hideDependents( const table::CellAddress& aPosition )
7694 throw(uno::RuntimeException)
7696 ScUnoGuard aGuard;
7697 ScDocShell* pDocSh = GetDocShell();
7698 if ( pDocSh )
7700 SCTAB nTab = GetTab_Impl();
7701 DBG_ASSERT( aPosition.Sheet == nTab, "falsche Tabelle in CellAddress" );
7702 ScAddress aPos( (SCCOL)aPosition.Column, (SCROW)aPosition.Row, nTab );
7703 ScDocFunc aFunc(*pDocSh);
7704 return aFunc.DetectiveDelSucc( aPos );
7706 return FALSE;
7709 sal_Bool SAL_CALL ScTableSheetObj::hidePrecedents( const table::CellAddress& aPosition )
7710 throw(uno::RuntimeException)
7712 ScUnoGuard aGuard;
7713 ScDocShell* pDocSh = GetDocShell();
7714 if ( pDocSh )
7716 SCTAB nTab = GetTab_Impl();
7717 DBG_ASSERT( aPosition.Sheet == nTab, "falsche Tabelle in CellAddress" );
7718 ScAddress aPos( (SCCOL)aPosition.Column, (SCROW)aPosition.Row, nTab );
7719 ScDocFunc aFunc(*pDocSh);
7720 return aFunc.DetectiveDelPred( aPos );
7722 return FALSE;
7725 sal_Bool SAL_CALL ScTableSheetObj::showDependents( const table::CellAddress& aPosition )
7726 throw(uno::RuntimeException)
7728 ScUnoGuard aGuard;
7729 ScDocShell* pDocSh = GetDocShell();
7730 if ( pDocSh )
7732 SCTAB nTab = GetTab_Impl();
7733 DBG_ASSERT( aPosition.Sheet == nTab, "falsche Tabelle in CellAddress" );
7734 ScAddress aPos( (SCCOL)aPosition.Column, (SCROW)aPosition.Row, nTab );
7735 ScDocFunc aFunc(*pDocSh);
7736 return aFunc.DetectiveAddSucc( aPos );
7738 return FALSE;
7741 sal_Bool SAL_CALL ScTableSheetObj::showPrecedents( const table::CellAddress& aPosition )
7742 throw(uno::RuntimeException)
7744 ScUnoGuard aGuard;
7745 ScDocShell* pDocSh = GetDocShell();
7746 if ( pDocSh )
7748 SCTAB nTab = GetTab_Impl();
7749 DBG_ASSERT( aPosition.Sheet == nTab, "falsche Tabelle in CellAddress" );
7750 ScAddress aPos( (SCCOL)aPosition.Column, (SCROW)aPosition.Row, nTab );
7751 ScDocFunc aFunc(*pDocSh);
7752 return aFunc.DetectiveAddPred( aPos );
7754 return FALSE;
7757 sal_Bool SAL_CALL ScTableSheetObj::showErrors( const table::CellAddress& aPosition )
7758 throw(uno::RuntimeException)
7760 ScUnoGuard aGuard;
7761 ScDocShell* pDocSh = GetDocShell();
7762 if ( pDocSh )
7764 SCTAB nTab = GetTab_Impl();
7765 DBG_ASSERT( aPosition.Sheet == nTab, "falsche Tabelle in CellAddress" );
7766 ScAddress aPos( (SCCOL)aPosition.Column, (SCROW)aPosition.Row, nTab );
7767 ScDocFunc aFunc(*pDocSh);
7768 return aFunc.DetectiveAddError( aPos );
7770 return FALSE;
7773 sal_Bool SAL_CALL ScTableSheetObj::showInvalid() throw(uno::RuntimeException)
7775 ScUnoGuard aGuard;
7776 ScDocShell* pDocSh = GetDocShell();
7777 if ( pDocSh )
7779 ScDocFunc aFunc(*pDocSh);
7780 return aFunc.DetectiveMarkInvalid( GetTab_Impl() );
7782 return FALSE;
7785 void SAL_CALL ScTableSheetObj::clearArrows() throw(uno::RuntimeException)
7787 ScUnoGuard aGuard;
7788 ScDocShell* pDocSh = GetDocShell();
7789 if ( pDocSh )
7791 ScDocFunc aFunc(*pDocSh);
7792 aFunc.DetectiveDelAll( GetTab_Impl() );
7796 // XSheetOutline
7798 void SAL_CALL ScTableSheetObj::group( const table::CellRangeAddress& rGroupRange,
7799 table::TableOrientation nOrientation )
7800 throw(uno::RuntimeException)
7802 ScUnoGuard aGuard;
7803 ScDocShell* pDocSh = GetDocShell();
7804 if ( pDocSh )
7806 BOOL bColumns = ( nOrientation == table::TableOrientation_COLUMNS );
7807 ScRange aGroupRange;
7808 ScUnoConversion::FillScRange( aGroupRange, rGroupRange );
7809 ScOutlineDocFunc aFunc(*pDocSh);
7810 aFunc.MakeOutline( aGroupRange, bColumns, TRUE, TRUE );
7814 void SAL_CALL ScTableSheetObj::ungroup( const table::CellRangeAddress& rGroupRange,
7815 table::TableOrientation nOrientation )
7816 throw(uno::RuntimeException)
7818 ScUnoGuard aGuard;
7819 ScDocShell* pDocSh = GetDocShell();
7820 if ( pDocSh )
7822 BOOL bColumns = ( nOrientation == table::TableOrientation_COLUMNS );
7823 ScRange aGroupRange;
7824 ScUnoConversion::FillScRange( aGroupRange, rGroupRange );
7825 ScOutlineDocFunc aFunc(*pDocSh);
7826 aFunc.RemoveOutline( aGroupRange, bColumns, TRUE, TRUE );
7830 void SAL_CALL ScTableSheetObj::autoOutline( const table::CellRangeAddress& rCellRange )
7831 throw(uno::RuntimeException)
7833 ScUnoGuard aGuard;
7834 ScDocShell* pDocSh = GetDocShell();
7835 if ( pDocSh )
7837 ScRange aFormulaRange;
7838 ScUnoConversion::FillScRange( aFormulaRange, rCellRange );
7839 ScOutlineDocFunc aFunc(*pDocSh);
7840 aFunc.AutoOutline( aFormulaRange, TRUE, TRUE );
7844 void SAL_CALL ScTableSheetObj::clearOutline() throw(uno::RuntimeException)
7846 ScUnoGuard aGuard;
7847 ScDocShell* pDocSh = GetDocShell();
7848 if ( pDocSh )
7850 SCTAB nTab = GetTab_Impl();
7851 ScOutlineDocFunc aFunc(*pDocSh);
7852 aFunc.RemoveAllOutlines( nTab, TRUE, TRUE );
7856 void SAL_CALL ScTableSheetObj::hideDetail( const table::CellRangeAddress& rCellRange )
7857 throw(uno::RuntimeException)
7859 ScUnoGuard aGuard;
7860 ScDocShell* pDocSh = GetDocShell();
7861 if ( pDocSh )
7863 ScRange aMarkRange;
7864 ScUnoConversion::FillScRange( aMarkRange, rCellRange );
7865 ScOutlineDocFunc aFunc(*pDocSh);
7866 aFunc.HideMarkedOutlines( aMarkRange, TRUE, TRUE );
7870 void SAL_CALL ScTableSheetObj::showDetail( const table::CellRangeAddress& rCellRange )
7871 throw(uno::RuntimeException)
7873 ScUnoGuard aGuard;
7874 ScDocShell* pDocSh = GetDocShell();
7875 if ( pDocSh )
7877 ScRange aMarkRange;
7878 ScUnoConversion::FillScRange( aMarkRange, rCellRange );
7879 ScOutlineDocFunc aFunc(*pDocSh);
7880 aFunc.ShowMarkedOutlines( aMarkRange, TRUE, TRUE );
7884 void SAL_CALL ScTableSheetObj::showLevel( sal_Int16 nLevel, table::TableOrientation nOrientation )
7885 throw(uno::RuntimeException)
7887 ScUnoGuard aGuard;
7888 ScDocShell* pDocSh = GetDocShell();
7889 if ( pDocSh )
7891 BOOL bColumns = ( nOrientation == table::TableOrientation_COLUMNS );
7892 SCTAB nTab = GetTab_Impl();
7893 ScOutlineDocFunc aFunc(*pDocSh);
7894 aFunc.SelectLevel( nTab, bColumns, nLevel, TRUE, TRUE, TRUE );
7898 // XProtectable
7900 void SAL_CALL ScTableSheetObj::protect( const rtl::OUString& aPassword )
7901 throw(uno::RuntimeException)
7903 ScUnoGuard aGuard;
7904 ScDocShell* pDocSh = GetDocShell();
7905 if ( pDocSh )
7907 String aString(aPassword);
7908 ScDocFunc aFunc(*pDocSh);
7909 aFunc.Protect( GetTab_Impl(), aString, TRUE );
7913 void SAL_CALL ScTableSheetObj::unprotect( const rtl::OUString& aPassword )
7914 throw(lang::IllegalArgumentException, uno::RuntimeException)
7916 ScUnoGuard aGuard;
7917 ScDocShell* pDocSh = GetDocShell();
7918 if ( pDocSh )
7920 String aString(aPassword);
7921 ScDocFunc aFunc(*pDocSh);
7922 aFunc.Unprotect( GetTab_Impl(), aString, TRUE );
7924 //! Rueckgabewert auswerten, Exception oder so
7928 sal_Bool SAL_CALL ScTableSheetObj::isProtected() throw(uno::RuntimeException)
7930 ScUnoGuard aGuard;
7931 ScDocShell* pDocSh = GetDocShell();
7932 if ( pDocSh )
7933 return pDocSh->GetDocument()->IsTabProtected( GetTab_Impl() );
7935 DBG_ERROR("keine DocShell"); //! Exception oder so?
7936 return FALSE;
7939 // XScenario
7941 sal_Bool SAL_CALL ScTableSheetObj::getIsScenario() throw(uno::RuntimeException)
7943 ScUnoGuard aGuard;
7944 ScDocShell* pDocSh = GetDocShell();
7945 if ( pDocSh )
7946 return pDocSh->GetDocument()->IsScenario( GetTab_Impl() );
7948 return FALSE;
7951 rtl::OUString SAL_CALL ScTableSheetObj::getScenarioComment() throw(uno::RuntimeException)
7953 ScUnoGuard aGuard;
7954 ScDocShell* pDocSh = GetDocShell();
7955 if ( pDocSh )
7957 String aComment;
7958 Color aColor;
7959 USHORT nFlags;
7960 pDocSh->GetDocument()->GetScenarioData( GetTab_Impl(), aComment, aColor, nFlags );
7961 return aComment;
7963 return rtl::OUString();
7966 void SAL_CALL ScTableSheetObj::setScenarioComment( const rtl::OUString& aScenarioComment )
7967 throw(uno::RuntimeException)
7969 ScUnoGuard aGuard;
7970 ScDocShell* pDocSh = GetDocShell();
7971 if ( pDocSh )
7973 ScDocument* pDoc = pDocSh->GetDocument();
7974 SCTAB nTab = GetTab_Impl();
7976 String aName;
7977 String aComment;
7978 Color aColor;
7979 USHORT nFlags;
7980 pDoc->GetName( nTab, aName );
7981 pDoc->GetScenarioData( nTab, aComment, aColor, nFlags );
7983 aComment = String( aScenarioComment );
7985 pDocSh->ModifyScenario( nTab, aName, aComment, aColor, nFlags );
7989 void SAL_CALL ScTableSheetObj::addRanges( const uno::Sequence<table::CellRangeAddress>& rScenRanges )
7990 throw(uno::RuntimeException)
7992 ScUnoGuard aGuard;
7993 ScDocShell* pDocSh = GetDocShell();
7994 if ( pDocSh )
7996 ScDocument* pDoc = pDocSh->GetDocument();
7997 SCTAB nTab = GetTab_Impl();
7999 if (pDoc->IsScenario(nTab))
8001 ScMarkData aMarkData;
8002 aMarkData.SelectTable( nTab, TRUE );
8004 USHORT nRangeCount = (USHORT)rScenRanges.getLength();
8005 if (nRangeCount)
8007 const table::CellRangeAddress* pAry = rScenRanges.getConstArray();
8008 for (USHORT i=0; i<nRangeCount; i++)
8010 DBG_ASSERT( pAry[i].Sheet == nTab, "addRanges mit falscher Tab" );
8011 ScRange aOneRange( (SCCOL)pAry[i].StartColumn, (SCROW)pAry[i].StartRow, nTab,
8012 (SCCOL)pAry[i].EndColumn, (SCROW)pAry[i].EndRow, nTab );
8014 aMarkData.SetMultiMarkArea( aOneRange );
8018 // Szenario-Ranges sind durch Attribut gekennzeichnet
8019 ScPatternAttr aPattern( pDoc->GetPool() );
8020 aPattern.GetItemSet().Put( ScMergeFlagAttr( SC_MF_SCENARIO ) );
8021 aPattern.GetItemSet().Put( ScProtectionAttr( TRUE ) );
8022 ScDocFunc aFunc(*pDocSh);
8023 aFunc.ApplyAttributes( aMarkData, aPattern, TRUE, TRUE );
8026 // don't use. We should use therefor a private interface, so we can also set the flags.
8027 /* else if (nTab > 0 && pDoc->IsImportingXML()) // make this sheet as an scenario and only if it is not the first sheet and only if it is ImportingXML,
8028 // because than no UNDO and repaint is necessary.
8030 USHORT nRangeCount = (USHORT)rScenRanges.getLength();
8031 if (nRangeCount)
8033 pDoc->SetScenario( nTab, TRUE );
8035 // default flags
8036 Color aColor( COL_LIGHTGRAY ); // Default
8037 USHORT nFlags = SC_SCENARIO_SHOWFRAME | SC_SCENARIO_PRINTFRAME | SC_SCENARIO_TWOWAY;
8038 String aComment;
8040 pDoc->SetScenarioData( nTab, aComment, aColor, nFlags );
8041 const table::CellRangeAddress* pAry = rScenRanges.getConstArray();
8042 for (USHORT i=0; i<nRangeCount; i++)
8044 DBG_ASSERT( pAry[i].Sheet == nTab, "addRanges mit falscher Tab" );
8045 pDoc->ApplyFlagsTab( (USHORT)pAry[i].StartColumn, (USHORT)pAry[i].StartRow,
8046 (USHORT)pAry[i].EndColumn, (USHORT)pAry[i].EndRow, nTab, SC_MF_SCENARIO );
8048 pDoc->SetActiveScenario( nTab, TRUE );
8050 // set to next visible tab
8051 USHORT j = nTab - 1;
8052 BOOL bFinished = FALSE;
8053 while (j < nTab && !bFinished)
8055 if (pDoc->IsVisible(j))
8057 pDoc->SetVisibleTab(j);
8058 bFinished = TRUE;
8060 else
8061 --j;
8064 ScDocFunc aFunc(*pDocSh);
8065 aFunc.SetTableVisible( nTab, FALSE, TRUE );
8071 void SAL_CALL ScTableSheetObj::apply() throw(uno::RuntimeException)
8073 ScUnoGuard aGuard;
8074 ScDocShell* pDocSh = GetDocShell();
8075 if ( pDocSh )
8077 ScDocument* pDoc = pDocSh->GetDocument();
8078 SCTAB nTab = GetTab_Impl();
8079 String aName;
8080 pDoc->GetName( nTab, aName ); // Name dieses Szenarios
8082 SCTAB nDestTab = nTab;
8083 while ( nDestTab > 0 && pDoc->IsScenario(nDestTab) )
8084 --nDestTab;
8086 if ( !pDoc->IsScenario(nDestTab) )
8087 pDocSh->UseScenario( nDestTab, aName );
8089 //! sonst Fehler oder so
8093 // XScenarioEnhanced
8095 uno::Sequence< table::CellRangeAddress > SAL_CALL ScTableSheetObj::getRanges( )
8096 throw(uno::RuntimeException)
8098 ScUnoGuard aGuard;
8099 ScDocShell* pDocSh = GetDocShell();
8100 if ( pDocSh )
8102 ScDocument* pDoc = pDocSh->GetDocument();
8103 SCTAB nTab = GetTab_Impl();
8104 const ScRangeList* pRangeList = pDoc->GetScenarioRanges(nTab);
8105 if (pRangeList)
8107 sal_Int32 nCount = pRangeList->Count();
8108 uno::Sequence< table::CellRangeAddress > aRetRanges(nCount);
8109 table::CellRangeAddress* pAry = aRetRanges.getArray();
8110 for( sal_Int32 nIndex = 0; nIndex < nCount; nIndex++ )
8112 const ScRange* pRange = pRangeList->GetObject( nIndex );
8113 pAry->StartColumn = pRange->aStart.Col();
8114 pAry->StartRow = pRange->aStart.Row();
8115 pAry->EndColumn = pRange->aEnd.Col();
8116 pAry->EndRow = pRange->aEnd.Row();
8117 pAry->Sheet = pRange->aStart.Tab();
8118 ++pAry;
8120 return aRetRanges;
8123 return uno::Sequence< table::CellRangeAddress > ();
8126 // XExternalSheetName
8128 void ScTableSheetObj::setExternalName( const ::rtl::OUString& aUrl, const ::rtl::OUString& aSheetName )
8129 throw (container::ElementExistException, uno::RuntimeException)
8131 ScUnoGuard aGuard;
8132 ScDocShell* pDocSh = GetDocShell();
8133 if ( pDocSh )
8135 ScDocument* pDoc = pDocSh->GetDocument();
8136 if ( pDoc )
8138 const SCTAB nTab = GetTab_Impl();
8139 const String aAbsDocName( ScGlobal::GetAbsDocName( aUrl, pDocSh ) );
8140 const String aDocTabName( ScGlobal::GetDocTabName( aAbsDocName, aSheetName ) );
8141 if ( !pDoc->RenameTab( nTab, aDocTabName, FALSE /*bUpdateRef*/, TRUE /*bExternalDocument*/ ) )
8143 throw container::ElementExistException( ::rtl::OUString(), *this );
8149 // XPropertySet erweitert fuer Sheet-Properties
8151 uno::Reference<beans::XPropertySetInfo> SAL_CALL ScTableSheetObj::getPropertySetInfo()
8152 throw(uno::RuntimeException)
8154 ScUnoGuard aGuard;
8155 static uno::Reference<beans::XPropertySetInfo> aRef(
8156 new SfxItemPropertySetInfo( pSheetPropSet->getPropertyMap() ));
8157 return aRef;
8160 void ScTableSheetObj::SetOnePropertyValue( const SfxItemPropertySimpleEntry* pEntry, const uno::Any& aValue )
8161 throw(lang::IllegalArgumentException, uno::RuntimeException)
8163 if ( pEntry )
8165 if ( IsScItemWid( pEntry->nWID ) )
8167 // for Item WIDs, call ScCellRangesBase directly
8168 ScCellRangesBase::SetOnePropertyValue(pEntry, aValue);
8169 return;
8172 // own properties
8174 ScDocShell* pDocSh = GetDocShell();
8175 if (!pDocSh)
8176 return; //! Exception oder so?
8177 ScDocument* pDoc = pDocSh->GetDocument();
8178 SCTAB nTab = GetTab_Impl();
8179 ScDocFunc aFunc(*pDocSh);
8181 if ( pEntry->nWID == SC_WID_UNO_PAGESTL )
8183 rtl::OUString aStrVal;
8184 aValue >>= aStrVal;
8185 String aNewStr(ScStyleNameConversion::ProgrammaticToDisplayName(
8186 aStrVal, SFX_STYLE_FAMILY_PAGE ));
8188 //! Undo? (auch bei SID_STYLE_APPLY an der View)
8190 if ( pDoc->GetPageStyle( nTab ) != aNewStr )
8192 pDoc->SetPageStyle( nTab, aNewStr );
8193 if (!pDoc->IsImportingXML())
8195 ScPrintFunc( pDocSh, pDocSh->GetPrinter(), nTab ).UpdatePages();
8197 SfxBindings* pBindings = pDocSh->GetViewBindings();
8198 if (pBindings)
8200 pBindings->Invalidate( SID_STYLE_FAMILY4 );
8201 pBindings->Invalidate( SID_STATUS_PAGESTYLE );
8202 pBindings->Invalidate( FID_RESET_PRINTZOOM );
8203 pBindings->Invalidate( SID_ATTR_PARA_LEFT_TO_RIGHT );
8204 pBindings->Invalidate( SID_ATTR_PARA_RIGHT_TO_LEFT );
8207 pDocSh->SetDocumentModified();
8210 else if ( pEntry->nWID == SC_WID_UNO_CELLVIS )
8212 BOOL bVis = ScUnoHelpFunctions::GetBoolFromAny( aValue );
8213 aFunc.SetTableVisible( nTab, bVis, TRUE );
8215 else if ( pEntry->nWID == SC_WID_UNO_ISACTIVE )
8217 if (pDoc->IsScenario(nTab))
8218 pDoc->SetActiveScenario( nTab, ScUnoHelpFunctions::GetBoolFromAny( aValue ) );
8220 else if ( pEntry->nWID == SC_WID_UNO_BORDCOL )
8222 if (pDoc->IsScenario(nTab))
8224 sal_Int32 nNewColor = 0;
8225 if (aValue >>= nNewColor)
8227 String aName;
8228 String aComment;
8229 Color aColor;
8230 USHORT nFlags;
8231 pDoc->GetName( nTab, aName );
8232 pDoc->GetScenarioData( nTab, aComment, aColor, nFlags );
8234 aColor = Color(static_cast<sal_uInt32>(nNewColor));
8236 pDocSh->ModifyScenario( nTab, aName, aComment, aColor, nFlags );
8240 else if ( pEntry->nWID == SC_WID_UNO_PROTECT )
8242 if (pDoc->IsScenario(nTab))
8244 String aName;
8245 String aComment;
8246 Color aColor;
8247 USHORT nFlags;
8248 pDoc->GetName( nTab, aName );
8249 pDoc->GetScenarioData( nTab, aComment, aColor, nFlags );
8250 sal_Bool bModify(sal_False);
8252 if (ScUnoHelpFunctions::GetBoolFromAny( aValue ))
8254 if (!(nFlags & SC_SCENARIO_PROTECT))
8256 nFlags |= SC_SCENARIO_PROTECT;
8257 bModify = sal_True;
8260 else
8262 if (nFlags & SC_SCENARIO_PROTECT)
8264 nFlags -= SC_SCENARIO_PROTECT;
8265 bModify = sal_True;
8269 if (bModify)
8270 pDocSh->ModifyScenario( nTab, aName, aComment, aColor, nFlags );
8273 else if ( pEntry->nWID == SC_WID_UNO_SHOWBORD )
8275 if (pDoc->IsScenario(nTab))
8277 String aName;
8278 String aComment;
8279 Color aColor;
8280 USHORT nFlags;
8281 pDoc->GetName( nTab, aName );
8282 pDoc->GetScenarioData( nTab, aComment, aColor, nFlags );
8283 sal_Bool bModify(sal_False);
8285 if (ScUnoHelpFunctions::GetBoolFromAny( aValue ))
8287 if (!(nFlags & SC_SCENARIO_SHOWFRAME))
8289 nFlags |= SC_SCENARIO_SHOWFRAME;
8290 bModify = sal_True;
8293 else
8295 if (nFlags & SC_SCENARIO_SHOWFRAME)
8297 nFlags -= SC_SCENARIO_SHOWFRAME;
8298 bModify = sal_True;
8302 if (bModify)
8303 pDocSh->ModifyScenario( nTab, aName, aComment, aColor, nFlags );
8306 else if ( pEntry->nWID == SC_WID_UNO_PRINTBORD )
8308 if (pDoc->IsScenario(nTab))
8310 String aName;
8311 String aComment;
8312 Color aColor;
8313 USHORT nFlags;
8314 pDoc->GetName( nTab, aName );
8315 pDoc->GetScenarioData( nTab, aComment, aColor, nFlags );
8316 sal_Bool bModify(sal_False);
8318 if (ScUnoHelpFunctions::GetBoolFromAny( aValue ))
8320 if (!(nFlags & SC_SCENARIO_PRINTFRAME))
8322 nFlags |= SC_SCENARIO_PRINTFRAME;
8323 bModify = sal_True;
8326 else
8328 if (nFlags & SC_SCENARIO_PRINTFRAME)
8330 nFlags -= SC_SCENARIO_PRINTFRAME;
8331 bModify = sal_True;
8335 if (bModify)
8336 pDocSh->ModifyScenario( nTab, aName, aComment, aColor, nFlags );
8339 else if ( pEntry->nWID == SC_WID_UNO_COPYBACK )
8341 if (pDoc->IsScenario(nTab))
8343 String aName;
8344 String aComment;
8345 Color aColor;
8346 USHORT nFlags;
8347 pDoc->GetName( nTab, aName );
8348 pDoc->GetScenarioData( nTab, aComment, aColor, nFlags );
8349 sal_Bool bModify(sal_False);
8351 if (ScUnoHelpFunctions::GetBoolFromAny( aValue ))
8353 if (!(nFlags & SC_SCENARIO_TWOWAY))
8355 nFlags |= SC_SCENARIO_TWOWAY;
8356 bModify = sal_True;
8359 else
8361 if (nFlags & SC_SCENARIO_TWOWAY)
8363 nFlags -= SC_SCENARIO_TWOWAY;
8364 bModify = sal_True;
8368 if (bModify)
8369 pDocSh->ModifyScenario( nTab, aName, aComment, aColor, nFlags );
8372 else if ( pEntry->nWID == SC_WID_UNO_COPYSTYL )
8374 if (pDoc->IsScenario(nTab))
8376 String aName;
8377 String aComment;
8378 Color aColor;
8379 USHORT nFlags;
8380 pDoc->GetName( nTab, aName );
8381 pDoc->GetScenarioData( nTab, aComment, aColor, nFlags );
8382 sal_Bool bModify(sal_False);
8384 if (ScUnoHelpFunctions::GetBoolFromAny( aValue ))
8386 if (!(nFlags & SC_SCENARIO_ATTRIB))
8388 nFlags |= SC_SCENARIO_ATTRIB;
8389 bModify = sal_True;
8392 else
8394 if (nFlags & SC_SCENARIO_ATTRIB)
8396 nFlags -= SC_SCENARIO_ATTRIB;
8397 bModify = sal_True;
8401 if (bModify)
8402 pDocSh->ModifyScenario( nTab, aName, aComment, aColor, nFlags );
8405 else if ( pEntry->nWID == SC_WID_UNO_COPYFORM )
8407 if (pDoc->IsScenario(nTab))
8409 String aName;
8410 String aComment;
8411 Color aColor;
8412 USHORT nFlags;
8413 pDoc->GetName( nTab, aName );
8414 pDoc->GetScenarioData( nTab, aComment, aColor, nFlags );
8415 sal_Bool bModify(sal_False);
8417 if (ScUnoHelpFunctions::GetBoolFromAny( aValue ))
8419 if (nFlags & SC_SCENARIO_VALUE)
8421 nFlags -= SC_SCENARIO_VALUE;
8422 bModify = sal_True;
8425 else
8427 if (!(nFlags & SC_SCENARIO_VALUE))
8429 nFlags |= SC_SCENARIO_VALUE;
8430 bModify = sal_True;
8434 if (bModify)
8435 pDocSh->ModifyScenario( nTab, aName, aComment, aColor, nFlags );
8438 else if ( pEntry->nWID == SC_WID_UNO_TABLAYOUT )
8440 sal_Int16 nValue = 0;
8441 if (aValue >>= nValue)
8443 if (nValue == com::sun::star::text::WritingMode2::RL_TB)
8444 aFunc.SetLayoutRTL(nTab, sal_True, sal_True);
8445 else
8446 aFunc.SetLayoutRTL(nTab, sal_False, sal_True);
8449 else if ( pEntry->nWID == SC_WID_UNO_AUTOPRINT )
8451 BOOL bAutoPrint = ScUnoHelpFunctions::GetBoolFromAny( aValue );
8452 if (bAutoPrint)
8453 pDoc->SetPrintEntireSheet( nTab ); // clears all print ranges
8454 else
8456 if (pDoc->IsPrintEntireSheet( nTab ))
8457 pDoc->ClearPrintRanges( nTab ); // if this flag is true, there are no PrintRanges, so Clear clears only the flag.
8460 else
8461 ScCellRangeObj::SetOnePropertyValue(pEntry, aValue); // base class, no Item WID
8465 void ScTableSheetObj::GetOnePropertyValue( const SfxItemPropertySimpleEntry* pEntry,
8466 uno::Any& rAny )
8467 throw(uno::RuntimeException)
8469 if ( pEntry )
8471 ScDocShell* pDocSh = GetDocShell();
8472 if (!pDocSh)
8473 throw uno::RuntimeException();
8474 ScDocument* pDoc = pDocSh->GetDocument();
8475 SCTAB nTab = GetTab_Impl();
8477 if ( pEntry->nWID == SC_WID_UNO_PAGESTL )
8479 rAny <<= rtl::OUString( ScStyleNameConversion::DisplayToProgrammaticName(
8480 pDoc->GetPageStyle( nTab ), SFX_STYLE_FAMILY_PAGE ) );
8482 else if ( pEntry->nWID == SC_WID_UNO_CELLVIS )
8484 BOOL bVis = pDoc->IsVisible( nTab );
8485 ScUnoHelpFunctions::SetBoolInAny( rAny, bVis );
8487 else if ( pEntry->nWID == SC_WID_UNO_LINKDISPBIT )
8489 // no target bitmaps for individual entries (would be all equal)
8490 // ScLinkTargetTypeObj::SetLinkTargetBitmap( aAny, SC_LINKTARGETTYPE_SHEET );
8492 else if ( pEntry->nWID == SC_WID_UNO_LINKDISPNAME )
8494 // LinkDisplayName for hyperlink dialog
8495 rAny <<= getName(); // sheet name
8497 else if ( pEntry->nWID == SC_WID_UNO_ISACTIVE )
8499 if (pDoc->IsScenario(nTab))
8500 ScUnoHelpFunctions::SetBoolInAny( rAny, pDoc->IsActiveScenario( nTab ));
8502 else if ( pEntry->nWID == SC_WID_UNO_BORDCOL )
8504 if (pDoc->IsScenario(nTab))
8506 String aComment;
8507 Color aColor;
8508 USHORT nFlags;
8509 pDoc->GetScenarioData( nTab, aComment, aColor, nFlags );
8511 rAny <<= static_cast<sal_Int32>(aColor.GetColor());
8514 else if ( pEntry->nWID == SC_WID_UNO_PROTECT )
8516 if (pDoc->IsScenario(nTab))
8518 String aComment;
8519 Color aColor;
8520 USHORT nFlags;
8521 pDoc->GetScenarioData( nTab, aComment, aColor, nFlags );
8523 ScUnoHelpFunctions::SetBoolInAny( rAny, (nFlags & SC_SCENARIO_PROTECT) != 0 );
8526 else if ( pEntry->nWID == SC_WID_UNO_SHOWBORD )
8528 if (pDoc->IsScenario(nTab))
8530 String aComment;
8531 Color aColor;
8532 USHORT nFlags;
8533 pDoc->GetScenarioData( nTab, aComment, aColor, nFlags );
8535 ScUnoHelpFunctions::SetBoolInAny( rAny, (nFlags & SC_SCENARIO_SHOWFRAME) != 0 );
8538 else if ( pEntry->nWID == SC_WID_UNO_PRINTBORD )
8540 if (pDoc->IsScenario(nTab))
8542 String aComment;
8543 Color aColor;
8544 USHORT nFlags;
8545 pDoc->GetScenarioData( nTab, aComment, aColor, nFlags );
8547 ScUnoHelpFunctions::SetBoolInAny( rAny, (nFlags & SC_SCENARIO_PRINTFRAME) != 0 );
8550 else if ( pEntry->nWID == SC_WID_UNO_COPYBACK )
8552 if (pDoc->IsScenario(nTab))
8554 String aComment;
8555 Color aColor;
8556 USHORT nFlags;
8557 pDoc->GetScenarioData( nTab, aComment, aColor, nFlags );
8559 ScUnoHelpFunctions::SetBoolInAny( rAny, (nFlags & SC_SCENARIO_TWOWAY) != 0 );
8562 else if ( pEntry->nWID == SC_WID_UNO_COPYSTYL )
8564 if (pDoc->IsScenario(nTab))
8566 String aComment;
8567 Color aColor;
8568 USHORT nFlags;
8569 pDoc->GetScenarioData( nTab, aComment, aColor, nFlags );
8571 ScUnoHelpFunctions::SetBoolInAny( rAny, (nFlags & SC_SCENARIO_ATTRIB) != 0 );
8574 else if ( pEntry->nWID == SC_WID_UNO_COPYFORM )
8576 if (pDoc->IsScenario(nTab))
8578 String aComment;
8579 Color aColor;
8580 USHORT nFlags;
8581 pDoc->GetScenarioData( nTab, aComment, aColor, nFlags );
8583 ScUnoHelpFunctions::SetBoolInAny( rAny, !(nFlags & SC_SCENARIO_VALUE));
8586 else if ( pEntry->nWID == SC_WID_UNO_TABLAYOUT )
8588 if (pDoc->IsLayoutRTL(nTab))
8589 rAny <<= sal_Int16(com::sun::star::text::WritingMode2::RL_TB);
8590 else
8591 rAny <<= sal_Int16(com::sun::star::text::WritingMode2::LR_TB);
8593 else if ( pEntry->nWID == SC_WID_UNO_AUTOPRINT )
8595 BOOL bAutoPrint = pDoc->IsPrintEntireSheet( nTab );
8596 ScUnoHelpFunctions::SetBoolInAny( rAny, bAutoPrint );
8598 else
8599 ScCellRangeObj::GetOnePropertyValue(pEntry, rAny);
8603 const SfxItemPropertyMap* ScTableSheetObj::GetItemPropertyMap()
8605 return pSheetPropSet->getPropertyMap();
8608 // XServiceInfo
8610 rtl::OUString SAL_CALL ScTableSheetObj::getImplementationName() throw(uno::RuntimeException)
8612 return rtl::OUString::createFromAscii( "ScTableSheetObj" );
8615 sal_Bool SAL_CALL ScTableSheetObj::supportsService( const rtl::OUString& rServiceName )
8616 throw(uno::RuntimeException)
8618 String aServiceStr( rServiceName );
8619 return aServiceStr.EqualsAscii( SCSPREADSHEET_SERVICE ) ||
8620 aServiceStr.EqualsAscii( SCSHEETCELLRANGE_SERVICE ) ||
8621 aServiceStr.EqualsAscii( SCCELLRANGE_SERVICE ) ||
8622 aServiceStr.EqualsAscii( SCCELLPROPERTIES_SERVICE ) ||
8623 aServiceStr.EqualsAscii( SCCHARPROPERTIES_SERVICE ) ||
8624 aServiceStr.EqualsAscii( SCPARAPROPERTIES_SERVICE ) ||
8625 aServiceStr.EqualsAscii( SCLINKTARGET_SERVICE );
8628 uno::Sequence<rtl::OUString> SAL_CALL ScTableSheetObj::getSupportedServiceNames()
8629 throw(uno::RuntimeException)
8631 uno::Sequence<rtl::OUString> aRet(7);
8632 rtl::OUString* pArray = aRet.getArray();
8633 pArray[0] = rtl::OUString::createFromAscii( SCSPREADSHEET_SERVICE );
8634 pArray[1] = rtl::OUString::createFromAscii( SCSHEETCELLRANGE_SERVICE );
8635 pArray[2] = rtl::OUString::createFromAscii( SCCELLRANGE_SERVICE );
8636 pArray[3] = rtl::OUString::createFromAscii( SCCELLPROPERTIES_SERVICE );
8637 pArray[4] = rtl::OUString::createFromAscii( SCCHARPROPERTIES_SERVICE );
8638 pArray[5] = rtl::OUString::createFromAscii( SCPARAPROPERTIES_SERVICE );
8639 pArray[6] = rtl::OUString::createFromAscii( SCLINKTARGET_SERVICE );
8640 return aRet;
8643 // XUnoTunnel
8645 sal_Int64 SAL_CALL ScTableSheetObj::getSomething(
8646 const uno::Sequence<sal_Int8 >& rId ) throw(uno::RuntimeException)
8648 if ( rId.getLength() == 16 &&
8649 0 == rtl_compareMemory( getUnoTunnelId().getConstArray(),
8650 rId.getConstArray(), 16 ) )
8652 return sal::static_int_cast<sal_Int64>(reinterpret_cast<sal_IntPtr>(this));
8655 return ScCellRangeObj::getSomething( rId );
8658 // static
8659 const uno::Sequence<sal_Int8>& ScTableSheetObj::getUnoTunnelId()
8661 static uno::Sequence<sal_Int8> * pSeq = 0;
8662 if( !pSeq )
8664 osl::Guard< osl::Mutex > aGuard( osl::Mutex::getGlobalMutex() );
8665 if( !pSeq )
8667 static uno::Sequence< sal_Int8 > aSeq( 16 );
8668 rtl_createUuid( (sal_uInt8*)aSeq.getArray(), 0, sal_True );
8669 pSeq = &aSeq;
8672 return *pSeq;
8675 // static
8676 ScTableSheetObj* ScTableSheetObj::getImplementation( const uno::Reference<uno::XInterface> xObj )
8678 ScTableSheetObj* pRet = NULL;
8679 uno::Reference<lang::XUnoTunnel> xUT( xObj, uno::UNO_QUERY );
8680 if (xUT.is())
8681 pRet = reinterpret_cast<ScTableSheetObj*>(sal::static_int_cast<sal_IntPtr>(xUT->getSomething(getUnoTunnelId())));
8682 return pRet;
8685 //------------------------------------------------------------------------
8687 ScTableColumnObj::ScTableColumnObj( ScDocShell* pDocSh, SCCOL nCol, SCTAB nTab ) :
8688 ScCellRangeObj( pDocSh, ScRange(nCol,0,nTab, nCol,MAXROW,nTab) ),
8689 pColPropSet(lcl_GetColumnPropertySet())
8693 ScTableColumnObj::~ScTableColumnObj()
8697 uno::Any SAL_CALL ScTableColumnObj::queryInterface( const uno::Type& rType ) throw(uno::RuntimeException)
8699 SC_QUERYINTERFACE( container::XNamed )
8701 return ScCellRangeObj::queryInterface( rType );
8704 void SAL_CALL ScTableColumnObj::acquire() throw()
8706 ScCellRangeObj::acquire();
8709 void SAL_CALL ScTableColumnObj::release() throw()
8711 ScCellRangeObj::release();
8714 uno::Sequence<uno::Type> SAL_CALL ScTableColumnObj::getTypes() throw(uno::RuntimeException)
8716 static uno::Sequence<uno::Type> aTypes;
8717 if ( aTypes.getLength() == 0 )
8719 uno::Sequence<uno::Type> aParentTypes(ScCellRangeObj::getTypes());
8720 long nParentLen = aParentTypes.getLength();
8721 const uno::Type* pParentPtr = aParentTypes.getConstArray();
8723 aTypes.realloc( nParentLen + 1 );
8724 uno::Type* pPtr = aTypes.getArray();
8725 pPtr[nParentLen + 0] = getCppuType((const uno::Reference<container::XNamed>*)0);
8727 for (long i=0; i<nParentLen; i++)
8728 pPtr[i] = pParentPtr[i]; // parent types first
8730 return aTypes;
8733 uno::Sequence<sal_Int8> SAL_CALL ScTableColumnObj::getImplementationId() throw(uno::RuntimeException)
8735 static uno::Sequence< sal_Int8 > aId;
8736 if( aId.getLength() == 0 )
8738 aId.realloc( 16 );
8739 rtl_createUuid( (sal_uInt8 *)aId.getArray(), 0, sal_True );
8741 return aId;
8744 // XNamed
8746 rtl::OUString SAL_CALL ScTableColumnObj::getName() throw(uno::RuntimeException)
8748 ScUnoGuard aGuard;
8750 const ScRange& rRange = GetRange();
8751 DBG_ASSERT(rRange.aStart.Col() == rRange.aEnd.Col(), "too many columns");
8752 SCCOL nCol = rRange.aStart.Col();
8754 return ScColToAlpha( nCol ); // from global.hxx
8757 void SAL_CALL ScTableColumnObj::setName( const rtl::OUString& /* aNewName */ )
8758 throw(uno::RuntimeException)
8760 ScUnoGuard aGuard;
8761 throw uno::RuntimeException(); // read-only
8764 // XPropertySet erweitert fuer Spalten-Properties
8766 uno::Reference<beans::XPropertySetInfo> SAL_CALL ScTableColumnObj::getPropertySetInfo()
8767 throw(uno::RuntimeException)
8769 ScUnoGuard aGuard;
8770 static uno::Reference<beans::XPropertySetInfo> aRef(
8771 new SfxItemPropertySetInfo( pColPropSet->getPropertyMap() ));
8772 return aRef;
8775 void ScTableColumnObj::SetOnePropertyValue( const SfxItemPropertySimpleEntry* pEntry, const uno::Any& aValue )
8776 throw(lang::IllegalArgumentException, uno::RuntimeException)
8778 if ( pEntry )
8780 if ( IsScItemWid( pEntry->nWID ) )
8782 // for Item WIDs, call ScCellRangesBase directly
8783 ScCellRangesBase::SetOnePropertyValue(pEntry, aValue);
8784 return;
8787 // own properties
8789 ScDocShell* pDocSh = GetDocShell();
8790 if (!pDocSh)
8791 return; //! Exception oder so?
8792 const ScRange& rRange = GetRange();
8793 DBG_ASSERT(rRange.aStart.Col() == rRange.aEnd.Col(), "zuviele Spalten");
8794 SCCOL nCol = rRange.aStart.Col();
8795 SCTAB nTab = rRange.aStart.Tab();
8796 ScDocFunc aFunc(*pDocSh);
8798 SCCOLROW nColArr[2];
8799 nColArr[0] = nColArr[1] = nCol;
8801 if ( pEntry->nWID == SC_WID_UNO_CELLWID )
8803 sal_Int32 nNewWidth = 0;
8804 if ( aValue >>= nNewWidth )
8806 // property is 1/100mm, column width is twips
8807 nNewWidth = HMMToTwips(nNewWidth);
8808 aFunc.SetWidthOrHeight( TRUE, 1, nColArr, nTab, SC_SIZE_ORIGINAL,
8809 (USHORT)nNewWidth, TRUE, TRUE );
8812 else if ( pEntry->nWID == SC_WID_UNO_CELLVIS )
8814 BOOL bVis = ScUnoHelpFunctions::GetBoolFromAny( aValue );
8815 ScSizeMode eMode = bVis ? SC_SIZE_SHOW : SC_SIZE_DIRECT;
8816 aFunc.SetWidthOrHeight( TRUE, 1, nColArr, nTab, eMode, 0, TRUE, TRUE );
8817 // SC_SIZE_DIRECT mit Groesse 0 blendet aus
8819 else if ( pEntry->nWID == SC_WID_UNO_OWIDTH )
8821 BOOL bOpt = ScUnoHelpFunctions::GetBoolFromAny( aValue );
8822 if (bOpt)
8823 aFunc.SetWidthOrHeight( TRUE, 1, nColArr, nTab,
8824 SC_SIZE_OPTIMAL, STD_EXTRA_WIDTH, TRUE, TRUE );
8825 // FALSE bei Spalten momentan ohne Auswirkung
8827 else if ( pEntry->nWID == SC_WID_UNO_NEWPAGE || pEntry->nWID == SC_WID_UNO_MANPAGE )
8829 BOOL bSet = ScUnoHelpFunctions::GetBoolFromAny( aValue );
8830 if (bSet)
8831 aFunc.InsertPageBreak( TRUE, rRange.aStart, TRUE, TRUE, TRUE );
8832 else
8833 aFunc.RemovePageBreak( TRUE, rRange.aStart, TRUE, TRUE, TRUE );
8835 else
8836 ScCellRangeObj::SetOnePropertyValue(pEntry, aValue); // base class, no Item WID
8840 void ScTableColumnObj::GetOnePropertyValue( const SfxItemPropertySimpleEntry* pEntry,
8841 uno::Any& rAny )
8842 throw(uno::RuntimeException)
8844 if ( pEntry )
8846 ScDocShell* pDocSh = GetDocShell();
8847 if (!pDocSh)
8848 throw uno::RuntimeException();
8850 ScDocument* pDoc = pDocSh->GetDocument();
8851 const ScRange& rRange = GetRange();
8852 DBG_ASSERT(rRange.aStart.Col() == rRange.aEnd.Col(), "zuviele Spalten");
8853 SCCOL nCol = rRange.aStart.Col();
8854 SCTAB nTab = rRange.aStart.Tab();
8856 if ( pEntry->nWID == SC_WID_UNO_CELLWID )
8858 // for hidden column, return original height
8859 USHORT nWidth = pDoc->GetOriginalWidth( nCol, nTab );
8860 // property is 1/100mm, column width is twips
8861 nWidth = (USHORT) TwipsToHMM(nWidth);
8862 rAny <<= (sal_Int32)( nWidth );
8864 else if ( pEntry->nWID == SC_WID_UNO_CELLVIS )
8866 SCCOL nDummy;
8867 bool bHidden = pDoc->ColHidden(nCol, nTab, nDummy);
8868 ScUnoHelpFunctions::SetBoolInAny( rAny, !bHidden );
8870 else if ( pEntry->nWID == SC_WID_UNO_OWIDTH )
8872 //! momentan immer gesetzt ??!?!
8873 BOOL bOpt = !(pDoc->GetColFlags( nCol, nTab ) & CR_MANUALSIZE);
8874 ScUnoHelpFunctions::SetBoolInAny( rAny, bOpt );
8876 else if ( pEntry->nWID == SC_WID_UNO_NEWPAGE )
8878 ScBreakType nBreak = pDoc->HasColBreak(nCol, nTab);
8879 ScUnoHelpFunctions::SetBoolInAny( rAny, nBreak );
8881 else if ( pEntry->nWID == SC_WID_UNO_MANPAGE )
8883 ScBreakType nBreak = pDoc->HasColBreak(nCol, nTab);
8884 ScUnoHelpFunctions::SetBoolInAny(rAny, (nBreak & BREAK_MANUAL));
8886 else
8887 ScCellRangeObj::GetOnePropertyValue(pEntry, rAny);
8891 const SfxItemPropertyMap* ScTableColumnObj::GetItemPropertyMap()
8893 return pColPropSet->getPropertyMap();
8896 //------------------------------------------------------------------------
8898 ScTableRowObj::ScTableRowObj(ScDocShell* pDocSh, SCROW nRow, SCTAB nTab) :
8899 ScCellRangeObj( pDocSh, ScRange(0,nRow,nTab, MAXCOL,nRow,nTab) ),
8900 pRowPropSet(lcl_GetRowPropertySet())
8904 ScTableRowObj::~ScTableRowObj()
8908 // XPropertySet erweitert fuer Zeilen-Properties
8910 uno::Reference<beans::XPropertySetInfo> SAL_CALL ScTableRowObj::getPropertySetInfo()
8911 throw(uno::RuntimeException)
8913 ScUnoGuard aGuard;
8914 static uno::Reference<beans::XPropertySetInfo> aRef(
8915 new SfxItemPropertySetInfo( pRowPropSet->getPropertyMap() ));
8916 return aRef;
8919 void ScTableRowObj::SetOnePropertyValue( const SfxItemPropertySimpleEntry* pEntry, const uno::Any& aValue )
8920 throw(lang::IllegalArgumentException, uno::RuntimeException)
8922 if ( pEntry )
8924 if ( IsScItemWid( pEntry->nWID ) )
8926 // for Item WIDs, call ScCellRangesBase directly
8927 ScCellRangesBase::SetOnePropertyValue(pEntry, aValue);
8928 return;
8931 // own properties
8933 ScDocShell* pDocSh = GetDocShell();
8934 if (!pDocSh)
8935 return; //! Exception oder so?
8936 ScDocument* pDoc = pDocSh->GetDocument();
8937 const ScRange& rRange = GetRange();
8938 DBG_ASSERT(rRange.aStart.Row() == rRange.aEnd.Row(), "zuviele Zeilen");
8939 SCROW nRow = rRange.aStart.Row();
8940 SCTAB nTab = rRange.aStart.Tab();
8941 ScDocFunc aFunc(*pDocSh);
8943 SCCOLROW nRowArr[2];
8944 nRowArr[0] = nRowArr[1] = nRow;
8946 if ( pEntry->nWID == SC_WID_UNO_CELLHGT )
8948 sal_Int32 nNewHeight = 0;
8949 if ( aValue >>= nNewHeight )
8951 // property is 1/100mm, row height is twips
8952 nNewHeight = HMMToTwips(nNewHeight);
8953 aFunc.SetWidthOrHeight( FALSE, 1, nRowArr, nTab, SC_SIZE_ORIGINAL,
8954 (USHORT)nNewHeight, TRUE, TRUE );
8957 else if ( pEntry->nWID == SC_WID_UNO_CELLVIS )
8959 BOOL bVis = ScUnoHelpFunctions::GetBoolFromAny( aValue );
8960 ScSizeMode eMode = bVis ? SC_SIZE_SHOW : SC_SIZE_DIRECT;
8961 aFunc.SetWidthOrHeight( FALSE, 1, nRowArr, nTab, eMode, 0, TRUE, TRUE );
8962 // SC_SIZE_DIRECT mit Groesse 0 blendet aus
8964 else if ( pEntry->nWID == SC_WID_UNO_CELLFILT )
8966 BOOL bFil = ScUnoHelpFunctions::GetBoolFromAny( aValue );
8967 // ScSizeMode eMode = bVis ? SC_SIZE_SHOW : SC_SIZE_DIRECT;
8968 // aFunc.SetWidthOrHeight( FALSE, 1, nRowArr, nTab, eMode, 0, TRUE, TRUE );
8969 // SC_SIZE_DIRECT mit Groesse 0 blendet aus
8970 pDoc->SetRowFiltered(nRow, nRow, nTab, bFil);
8972 else if ( pEntry->nWID == SC_WID_UNO_OHEIGHT )
8974 BOOL bOpt = ScUnoHelpFunctions::GetBoolFromAny( aValue );
8975 if (bOpt)
8976 aFunc.SetWidthOrHeight( FALSE, 1, nRowArr, nTab, SC_SIZE_OPTIMAL, 0, TRUE, TRUE );
8977 else
8979 // set current height again manually
8980 USHORT nHeight = pDoc->GetOriginalHeight( nRow, nTab );
8981 aFunc.SetWidthOrHeight( FALSE, 1, nRowArr, nTab, SC_SIZE_ORIGINAL, nHeight, TRUE, TRUE );
8984 else if ( pEntry->nWID == SC_WID_UNO_NEWPAGE || pEntry->nWID == SC_WID_UNO_MANPAGE )
8986 BOOL bSet = ScUnoHelpFunctions::GetBoolFromAny( aValue );
8987 if (bSet)
8988 aFunc.InsertPageBreak( FALSE, rRange.aStart, TRUE, TRUE, TRUE );
8989 else
8990 aFunc.RemovePageBreak( FALSE, rRange.aStart, TRUE, TRUE, TRUE );
8992 else
8993 ScCellRangeObj::SetOnePropertyValue(pEntry, aValue); // base class, no Item WID
8997 void ScTableRowObj::GetOnePropertyValue( const SfxItemPropertySimpleEntry* pEntry,
8998 uno::Any& rAny )
8999 throw(uno::RuntimeException)
9001 if ( pEntry )
9003 ScDocShell* pDocSh = GetDocShell();
9004 if (!pDocSh)
9005 throw uno::RuntimeException();
9006 ScDocument* pDoc = pDocSh->GetDocument();
9007 const ScRange& rRange = GetRange();
9008 DBG_ASSERT(rRange.aStart.Row() == rRange.aEnd.Row(), "zuviele Zeilen");
9009 SCROW nRow = rRange.aStart.Row();
9010 SCTAB nTab = rRange.aStart.Tab();
9012 if ( pEntry->nWID == SC_WID_UNO_CELLHGT )
9014 // for hidden row, return original height
9015 USHORT nHeight = pDoc->GetOriginalHeight( nRow, nTab );
9016 // property is 1/100mm, row height is twips
9017 nHeight = (USHORT) TwipsToHMM(nHeight);
9018 rAny <<= (sal_Int32)( nHeight );
9020 else if ( pEntry->nWID == SC_WID_UNO_CELLVIS )
9022 SCROW nDummy;
9023 bool bHidden = pDoc->RowHidden(nRow, nTab, nDummy);
9024 ScUnoHelpFunctions::SetBoolInAny( rAny, !bHidden );
9026 else if ( pEntry->nWID == SC_WID_UNO_CELLFILT )
9028 bool bVis = pDoc->RowFiltered(nRow, nTab);
9029 ScUnoHelpFunctions::SetBoolInAny( rAny, bVis );
9031 else if ( pEntry->nWID == SC_WID_UNO_OHEIGHT )
9033 BOOL bOpt = !(pDoc->GetRowFlags( nRow, nTab ) & CR_MANUALSIZE);
9034 ScUnoHelpFunctions::SetBoolInAny( rAny, bOpt );
9036 else if ( pEntry->nWID == SC_WID_UNO_NEWPAGE )
9038 ScBreakType nBreak = pDoc->HasRowBreak(nRow, nTab);
9039 ScUnoHelpFunctions::SetBoolInAny( rAny, nBreak );
9041 else if ( pEntry->nWID == SC_WID_UNO_MANPAGE )
9043 ScBreakType nBreak = (pDoc->HasRowBreak(nRow, nTab) & BREAK_MANUAL);
9044 ScUnoHelpFunctions::SetBoolInAny( rAny, nBreak );
9046 else
9047 ScCellRangeObj::GetOnePropertyValue(pEntry, rAny);
9051 const SfxItemPropertyMap* ScTableRowObj::GetItemPropertyMap()
9053 return pRowPropSet->getPropertyMap();
9056 //------------------------------------------------------------------------
9058 ScCellsObj::ScCellsObj(ScDocShell* pDocSh, const ScRangeList& rR) :
9059 pDocShell( pDocSh ),
9060 aRanges( rR )
9062 pDocShell->GetDocument()->AddUnoObject(*this);
9065 ScCellsObj::~ScCellsObj()
9067 if (pDocShell)
9068 pDocShell->GetDocument()->RemoveUnoObject(*this);
9071 void ScCellsObj::Notify( SfxBroadcaster&, const SfxHint& rHint )
9073 if ( rHint.ISA( ScUpdateRefHint ) )
9075 const ScUpdateRefHint& rRef = (const ScUpdateRefHint&)rHint;
9076 aRanges.UpdateReference( rRef.GetMode(), pDocShell->GetDocument(), rRef.GetRange(),
9077 rRef.GetDx(), rRef.GetDy(), rRef.GetDz() );
9079 else if ( rHint.ISA( SfxSimpleHint ) &&
9080 ((const SfxSimpleHint&)rHint).GetId() == SFX_HINT_DYING )
9082 pDocShell = NULL; // ungueltig geworden
9086 // XEnumerationAccess
9088 uno::Reference<container::XEnumeration> SAL_CALL ScCellsObj::createEnumeration()
9089 throw(uno::RuntimeException)
9091 ScUnoGuard aGuard;
9092 if (pDocShell)
9093 return new ScCellsEnumeration( pDocShell, aRanges );
9094 return NULL;
9097 uno::Type SAL_CALL ScCellsObj::getElementType() throw(uno::RuntimeException)
9099 ScUnoGuard aGuard;
9100 return getCppuType((uno::Reference<table::XCell>*)0);
9103 sal_Bool SAL_CALL ScCellsObj::hasElements() throw(uno::RuntimeException)
9105 ScUnoGuard aGuard;
9106 BOOL bHas = FALSE;
9107 if ( pDocShell )
9109 //! schneller selber testen?
9111 uno::Reference<container::XEnumeration> xEnum(new ScCellsEnumeration( pDocShell, aRanges ));
9112 bHas = xEnum->hasMoreElements();
9114 return bHas;
9117 //------------------------------------------------------------------------
9119 ScCellsEnumeration::ScCellsEnumeration(ScDocShell* pDocSh, const ScRangeList& rR) :
9120 pDocShell( pDocSh ),
9121 aRanges( rR ),
9122 pMark( NULL ),
9123 bAtEnd( FALSE )
9125 ScDocument* pDoc = pDocShell->GetDocument();
9126 pDoc->AddUnoObject(*this);
9128 if ( aRanges.Count() == 0 )
9129 bAtEnd = TRUE;
9130 else
9132 SCTAB nTab = 0;
9133 const ScRange* pFirst = aRanges.GetObject(0);
9134 if (pFirst)
9135 nTab = pFirst->aStart.Tab();
9136 aPos = ScAddress(0,0,nTab);
9137 CheckPos_Impl(); // aPos auf erste passende Zelle setzen
9141 void ScCellsEnumeration::CheckPos_Impl()
9143 if (pDocShell)
9145 BOOL bFound = FALSE;
9146 ScDocument* pDoc = pDocShell->GetDocument();
9147 ScBaseCell* pCell = pDoc->GetCell(aPos);
9148 if ( pCell && pCell->GetCellType() != CELLTYPE_NOTE )
9150 if (!pMark)
9152 pMark = new ScMarkData;
9153 pMark->MarkFromRangeList( aRanges, FALSE );
9154 pMark->MarkToMulti(); // needed for GetNextMarkedCell
9156 bFound = pMark->IsCellMarked( aPos.Col(), aPos.Row() );
9158 if (!bFound)
9159 Advance_Impl();
9163 ScCellsEnumeration::~ScCellsEnumeration()
9165 if (pDocShell)
9166 pDocShell->GetDocument()->RemoveUnoObject(*this);
9167 delete pMark;
9170 void ScCellsEnumeration::Advance_Impl()
9172 DBG_ASSERT(!bAtEnd,"zuviel Advance_Impl");
9173 if (!pMark)
9175 pMark = new ScMarkData;
9176 pMark->MarkFromRangeList( aRanges, FALSE );
9177 pMark->MarkToMulti(); // needed for GetNextMarkedCell
9180 SCCOL nCol = aPos.Col();
9181 SCROW nRow = aPos.Row();
9182 SCTAB nTab = aPos.Tab();
9183 BOOL bFound = pDocShell->GetDocument()->GetNextMarkedCell( nCol, nRow, nTab, *pMark );
9184 if (bFound)
9185 aPos.Set( nCol, nRow, nTab );
9186 else
9187 bAtEnd = TRUE; // kommt nix mehr
9190 void ScCellsEnumeration::Notify( SfxBroadcaster&, const SfxHint& rHint )
9192 if ( rHint.ISA( ScUpdateRefHint ) )
9194 if (pDocShell)
9196 const ScUpdateRefHint& rRef = (const ScUpdateRefHint&)rHint;
9197 aRanges.UpdateReference( rRef.GetMode(), pDocShell->GetDocument(), rRef.GetRange(),
9198 rRef.GetDx(), rRef.GetDy(), rRef.GetDz() );
9200 delete pMark; // aus verschobenen Bereichen neu erzeugen
9201 pMark = NULL;
9203 if (!bAtEnd) // aPos anpassen
9205 ScRangeList aNew;
9206 aNew.Append(ScRange(aPos));
9207 aNew.UpdateReference( rRef.GetMode(), pDocShell->GetDocument(), rRef.GetRange(),
9208 rRef.GetDx(), rRef.GetDy(), rRef.GetDz() );
9209 if (aNew.Count()==1)
9211 aPos = aNew.GetObject(0)->aStart;
9212 CheckPos_Impl();
9217 else if ( rHint.ISA( SfxSimpleHint ) &&
9218 ((const SfxSimpleHint&)rHint).GetId() == SFX_HINT_DYING )
9220 pDocShell = NULL; // ungueltig geworden
9224 // XEnumeration
9226 sal_Bool SAL_CALL ScCellsEnumeration::hasMoreElements() throw(uno::RuntimeException)
9228 ScUnoGuard aGuard;
9229 return !bAtEnd;
9232 uno::Any SAL_CALL ScCellsEnumeration::nextElement() throw(container::NoSuchElementException,
9233 lang::WrappedTargetException, uno::RuntimeException)
9235 ScUnoGuard aGuard;
9236 if (pDocShell && !bAtEnd)
9238 // Interface-Typ muss zu ScCellsObj::getElementType passen
9240 ScAddress aTempPos(aPos);
9241 Advance_Impl();
9242 return uno::makeAny(uno::Reference<table::XCell>(new ScCellObj( pDocShell, aTempPos )));
9245 throw container::NoSuchElementException(); // no more elements
9246 // return uno::Any();
9249 //------------------------------------------------------------------------
9251 ScCellFormatsObj::ScCellFormatsObj(ScDocShell* pDocSh, const ScRange& rRange) :
9252 pDocShell( pDocSh ),
9253 aTotalRange( rRange )
9255 ScDocument* pDoc = pDocShell->GetDocument();
9256 pDoc->AddUnoObject(*this);
9258 DBG_ASSERT( aTotalRange.aStart.Tab() == aTotalRange.aEnd.Tab(), "unterschiedliche Tabellen" );
9261 ScCellFormatsObj::~ScCellFormatsObj()
9263 if (pDocShell)
9264 pDocShell->GetDocument()->RemoveUnoObject(*this);
9267 void ScCellFormatsObj::Notify( SfxBroadcaster&, const SfxHint& rHint )
9269 if ( rHint.ISA( ScUpdateRefHint ) )
9271 //! aTotalRange...
9273 else if ( rHint.ISA( SfxSimpleHint ) &&
9274 ((const SfxSimpleHint&)rHint).GetId() == SFX_HINT_DYING )
9276 pDocShell = NULL; // ungueltig geworden
9280 ScCellRangeObj* ScCellFormatsObj::GetObjectByIndex_Impl(long nIndex) const
9282 //! direkt auf die AttrArrays zugreifen !!!!
9284 ScCellRangeObj* pRet = NULL;
9285 if (pDocShell)
9287 ScDocument* pDoc = pDocShell->GetDocument();
9288 long nPos = 0;
9289 ScAttrRectIterator aIter( pDoc, aTotalRange.aStart.Tab(),
9290 aTotalRange.aStart.Col(), aTotalRange.aStart.Row(),
9291 aTotalRange.aEnd.Col(), aTotalRange.aEnd.Row() );
9292 SCCOL nCol1, nCol2;
9293 SCROW nRow1, nRow2;
9294 while ( aIter.GetNext( nCol1, nCol2, nRow1, nRow2 ) )
9296 if ( nPos == nIndex )
9298 SCTAB nTab = aTotalRange.aStart.Tab();
9299 ScRange aNext( nCol1, nRow1, nTab, nCol2, nRow2, nTab );
9301 if ( aNext.aStart == aNext.aEnd )
9302 pRet = new ScCellObj( pDocShell, aNext.aStart );
9303 else
9304 pRet = new ScCellRangeObj( pDocShell, aNext );
9306 ++nPos;
9309 return pRet;
9312 // XIndexAccess
9314 sal_Int32 SAL_CALL ScCellFormatsObj::getCount() throw(uno::RuntimeException)
9316 ScUnoGuard aGuard;
9318 //! direkt auf die AttrArrays zugreifen !!!!
9320 long nCount = 0;
9321 if (pDocShell)
9323 ScDocument* pDoc = pDocShell->GetDocument();
9324 ScAttrRectIterator aIter( pDoc, aTotalRange.aStart.Tab(),
9325 aTotalRange.aStart.Col(), aTotalRange.aStart.Row(),
9326 aTotalRange.aEnd.Col(), aTotalRange.aEnd.Row() );
9327 SCCOL nCol1, nCol2;
9328 SCROW nRow1, nRow2;
9329 while ( aIter.GetNext( nCol1, nCol2, nRow1, nRow2 ) )
9330 ++nCount;
9332 return nCount;
9335 uno::Any SAL_CALL ScCellFormatsObj::getByIndex( sal_Int32 nIndex )
9336 throw(lang::IndexOutOfBoundsException,
9337 lang::WrappedTargetException, uno::RuntimeException)
9339 ScUnoGuard aGuard;
9341 uno::Reference<table::XCellRange> xRange(GetObjectByIndex_Impl(nIndex));
9342 if (xRange.is())
9343 return uno::makeAny(xRange);
9344 else
9345 throw lang::IndexOutOfBoundsException();
9346 // return uno::Any();
9349 uno::Type SAL_CALL ScCellFormatsObj::getElementType() throw(uno::RuntimeException)
9351 ScUnoGuard aGuard;
9352 return getCppuType((uno::Reference<table::XCellRange>*)0);
9355 sal_Bool SAL_CALL ScCellFormatsObj::hasElements() throw(uno::RuntimeException)
9357 ScUnoGuard aGuard;
9358 return ( getCount() != 0 ); //! immer groesser 0 ??
9361 // XEnumerationAccess
9363 uno::Reference<container::XEnumeration> SAL_CALL ScCellFormatsObj::createEnumeration()
9364 throw(uno::RuntimeException)
9366 ScUnoGuard aGuard;
9367 if (pDocShell)
9368 return new ScCellFormatsEnumeration( pDocShell, aTotalRange );
9369 return NULL;
9372 //------------------------------------------------------------------------
9374 ScCellFormatsEnumeration::ScCellFormatsEnumeration(ScDocShell* pDocSh, const ScRange& rRange) :
9375 pDocShell( pDocSh ),
9376 nTab( rRange.aStart.Tab() ),
9377 pIter( NULL ),
9378 bAtEnd( FALSE ),
9379 bDirty( FALSE )
9381 ScDocument* pDoc = pDocShell->GetDocument();
9382 pDoc->AddUnoObject(*this);
9384 DBG_ASSERT( rRange.aStart.Tab() == rRange.aEnd.Tab(),
9385 "CellFormatsEnumeration: unterschiedliche Tabellen" );
9387 pIter = new ScAttrRectIterator( pDoc, nTab,
9388 rRange.aStart.Col(), rRange.aStart.Row(),
9389 rRange.aEnd.Col(), rRange.aEnd.Row() );
9390 Advance_Impl();
9393 ScCellFormatsEnumeration::~ScCellFormatsEnumeration()
9395 if (pDocShell)
9396 pDocShell->GetDocument()->RemoveUnoObject(*this);
9397 delete pIter;
9400 void ScCellFormatsEnumeration::Advance_Impl()
9402 DBG_ASSERT(!bAtEnd,"zuviel Advance_Impl");
9404 if ( pIter )
9406 if ( bDirty )
9408 pIter->DataChanged(); // AttrArray-Index neu suchen
9409 bDirty = FALSE;
9412 SCCOL nCol1, nCol2;
9413 SCROW nRow1, nRow2;
9414 if ( pIter->GetNext( nCol1, nCol2, nRow1, nRow2 ) )
9415 aNext = ScRange( nCol1, nRow1, nTab, nCol2, nRow2, nTab );
9416 else
9417 bAtEnd = TRUE; // kommt nix mehr
9419 else
9420 bAtEnd = TRUE; // Dok weggekommen oder so
9423 ScCellRangeObj* ScCellFormatsEnumeration::NextObject_Impl()
9425 ScCellRangeObj* pRet = NULL;
9426 if (pDocShell && !bAtEnd)
9428 if ( aNext.aStart == aNext.aEnd )
9429 pRet = new ScCellObj( pDocShell, aNext.aStart );
9430 else
9431 pRet = new ScCellRangeObj( pDocShell, aNext );
9432 Advance_Impl();
9434 return pRet;
9437 void ScCellFormatsEnumeration::Notify( SfxBroadcaster&, const SfxHint& rHint )
9439 if ( rHint.ISA( ScUpdateRefHint ) )
9441 //! und nun ???
9443 else if ( rHint.ISA( SfxSimpleHint ) )
9445 ULONG nId = ((const SfxSimpleHint&)rHint).GetId();
9446 if ( nId == SFX_HINT_DYING )
9448 pDocShell = NULL; // ungueltig geworden
9449 delete pIter;
9450 pIter = NULL;
9452 else if ( nId == SFX_HINT_DATACHANGED )
9454 bDirty = TRUE; // AttrArray-Index evtl. ungueltig geworden
9459 // XEnumeration
9461 sal_Bool SAL_CALL ScCellFormatsEnumeration::hasMoreElements() throw(uno::RuntimeException)
9463 ScUnoGuard aGuard;
9464 return !bAtEnd;
9467 uno::Any SAL_CALL ScCellFormatsEnumeration::nextElement() throw(container::NoSuchElementException,
9468 lang::WrappedTargetException, uno::RuntimeException)
9470 ScUnoGuard aGuard;
9472 if ( bAtEnd || !pDocShell )
9473 throw container::NoSuchElementException(); // no more elements
9475 // Interface-Typ muss zu ScCellFormatsObj::getElementType passen
9477 return uno::makeAny(uno::Reference<table::XCellRange> (NextObject_Impl()));
9480 //------------------------------------------------------------------------
9482 ScUniqueCellFormatsObj::ScUniqueCellFormatsObj(ScDocShell* pDocSh, const ScRange& rRange) :
9483 pDocShell( pDocSh ),
9484 aTotalRange( rRange ),
9485 aRangeLists()
9487 pDocShell->GetDocument()->AddUnoObject(*this);
9489 DBG_ASSERT( aTotalRange.aStart.Tab() == aTotalRange.aEnd.Tab(), "unterschiedliche Tabellen" );
9491 GetObjects_Impl();
9494 ScUniqueCellFormatsObj::~ScUniqueCellFormatsObj()
9496 if (pDocShell)
9497 pDocShell->GetDocument()->RemoveUnoObject(*this);
9500 void ScUniqueCellFormatsObj::Notify( SfxBroadcaster&, const SfxHint& rHint )
9502 if ( rHint.ISA( ScUpdateRefHint ) )
9504 //! aTotalRange...
9506 else if ( rHint.ISA( SfxSimpleHint ) )
9508 ULONG nId = ((const SfxSimpleHint&)rHint).GetId();
9509 if ( nId == SFX_HINT_DYING )
9510 pDocShell = NULL; // ungueltig geworden
9515 // Fill the list of formats from the document
9518 // hash code to access the range lists by ScPatternAttr pointer
9519 struct ScPatternHashCode
9521 size_t operator()( const ScPatternAttr* pPattern ) const
9523 return reinterpret_cast<size_t>(pPattern);
9527 // Hash map to find a range by its start row
9528 typedef ::std::hash_map< SCROW, ScRange > ScRowRangeHashMap;
9530 typedef ::std::vector<ScRange> ScRangeVector;
9532 // Hash map entry.
9533 // The Join method depends on the column-wise order of ScAttrRectIterator
9534 class ScUniqueFormatsEntry
9536 enum EntryState { STATE_EMPTY, STATE_SINGLE, STATE_COMPLEX };
9538 EntryState eState;
9539 ScRange aSingleRange;
9540 ScRowRangeHashMap aJoinedRanges; // "active" ranges to be merged
9541 ScRangeVector aCompletedRanges; // ranges that will no longer be touched
9542 ScRangeListRef aReturnRanges; // result as ScRangeList for further use
9544 public:
9545 ScUniqueFormatsEntry() : eState( STATE_EMPTY ) {}
9546 ScUniqueFormatsEntry( const ScUniqueFormatsEntry& r ) :
9547 eState( r.eState ),
9548 aSingleRange( r.aSingleRange ),
9549 aJoinedRanges( r.aJoinedRanges ),
9550 aCompletedRanges( r.aCompletedRanges ),
9551 aReturnRanges( r.aReturnRanges ) {}
9552 ~ScUniqueFormatsEntry() {}
9554 void Join( const ScRange& rNewRange );
9555 const ScRangeList& GetRanges();
9556 void Clear() { aReturnRanges.Clear(); } // aJoinedRanges and aCompletedRanges are cleared in GetRanges
9559 void ScUniqueFormatsEntry::Join( const ScRange& rNewRange )
9561 // Special-case handling for single range
9563 if ( eState == STATE_EMPTY )
9565 aSingleRange = rNewRange;
9566 eState = STATE_SINGLE;
9567 return;
9569 if ( eState == STATE_SINGLE )
9571 if ( aSingleRange.aStart.Row() == rNewRange.aStart.Row() &&
9572 aSingleRange.aEnd.Row() == rNewRange.aEnd.Row() &&
9573 aSingleRange.aEnd.Col() + 1 == rNewRange.aStart.Col() )
9575 aSingleRange.aEnd.SetCol( rNewRange.aEnd.Col() );
9576 return; // still a single range
9579 SCROW nSingleRow = aSingleRange.aStart.Row();
9580 aJoinedRanges.insert( ScRowRangeHashMap::value_type( nSingleRow, aSingleRange ) );
9581 eState = STATE_COMPLEX;
9582 // continue normally
9585 // This is called in the order of ScAttrRectIterator results.
9586 // rNewRange can only be joined with an existing entry if it's the same rows, starting in the next column.
9587 // If the old entry for the start row extends to a different end row, or ends in a different column, it
9588 // can be moved to aCompletedRanges because it can't be joined with following iterator results.
9589 // Everything happens within one sheet, so Tab can be ignored.
9591 SCROW nStartRow = rNewRange.aStart.Row();
9592 ScRowRangeHashMap::iterator aIter( aJoinedRanges.find( nStartRow ) ); // find the active entry for the start row
9593 if ( aIter != aJoinedRanges.end() )
9595 ScRange& rOldRange = aIter->second;
9596 if ( rOldRange.aEnd.Row() == rNewRange.aEnd.Row() &&
9597 rOldRange.aEnd.Col() + 1 == rNewRange.aStart.Col() )
9599 // extend existing range
9600 rOldRange.aEnd.SetCol( rNewRange.aEnd.Col() );
9602 else
9604 // move old range to aCompletedRanges, keep rNewRange for joining
9605 aCompletedRanges.push_back( rOldRange );
9606 rOldRange = rNewRange; // replace in hash map
9609 else
9611 // keep rNewRange for joining
9612 aJoinedRanges.insert( ScRowRangeHashMap::value_type( nStartRow, rNewRange ) );
9616 const ScRangeList& ScUniqueFormatsEntry::GetRanges()
9618 if ( eState == STATE_SINGLE )
9620 aReturnRanges = new ScRangeList;
9621 aReturnRanges->Append( aSingleRange );
9622 return *aReturnRanges;
9625 // move remaining entries from aJoinedRanges to aCompletedRanges
9627 ScRowRangeHashMap::const_iterator aJoinedEnd = aJoinedRanges.end();
9628 for ( ScRowRangeHashMap::const_iterator aJoinedIter = aJoinedRanges.begin(); aJoinedIter != aJoinedEnd; ++aJoinedIter )
9629 aCompletedRanges.push_back( aJoinedIter->second );
9630 aJoinedRanges.clear();
9632 // sort all ranges for a predictable API result
9634 std::sort( aCompletedRanges.begin(), aCompletedRanges.end() );
9636 // fill and return ScRangeList
9638 aReturnRanges = new ScRangeList;
9639 ScRangeVector::const_iterator aCompEnd( aCompletedRanges.end() );
9640 for ( ScRangeVector::const_iterator aCompIter( aCompletedRanges.begin() ); aCompIter != aCompEnd; ++aCompIter )
9641 aReturnRanges->Append( *aCompIter );
9642 aCompletedRanges.clear();
9644 return *aReturnRanges;
9647 typedef ::std::hash_map< const ScPatternAttr*, ScUniqueFormatsEntry, ScPatternHashCode > ScUniqueFormatsHashMap;
9649 // function object to sort the range lists by start of first range
9650 struct ScUniqueFormatsOrder
9652 bool operator()( const ScRangeList& rList1, const ScRangeList& rList2 ) const
9654 // all range lists have at least one entry
9655 DBG_ASSERT( rList1.Count() > 0 && rList2.Count() > 0, "ScUniqueFormatsOrder: empty list" );
9657 // compare start positions using ScAddress comparison operator
9658 return ( rList1.GetObject(0)->aStart < rList2.GetObject(0)->aStart );
9662 void ScUniqueCellFormatsObj::GetObjects_Impl()
9664 if (pDocShell)
9666 ScDocument* pDoc = pDocShell->GetDocument();
9667 SCTAB nTab = aTotalRange.aStart.Tab();
9668 ScAttrRectIterator aIter( pDoc, nTab,
9669 aTotalRange.aStart.Col(), aTotalRange.aStart.Row(),
9670 aTotalRange.aEnd.Col(), aTotalRange.aEnd.Row() );
9671 SCCOL nCol1, nCol2;
9672 SCROW nRow1, nRow2;
9674 // Collect the ranges for each format in a hash map, to avoid nested loops
9676 ScUniqueFormatsHashMap aHashMap;
9677 while (aIter.GetNext( nCol1, nCol2, nRow1, nRow2 ) )
9679 ScRange aRange( nCol1, nRow1, nTab, nCol2, nRow2, nTab );
9680 const ScPatternAttr* pPattern = pDoc->GetPattern(nCol1, nRow1, nTab);
9681 aHashMap[pPattern].Join( aRange );
9684 // Fill the vector aRangeLists with the range lists from the hash map
9686 aRangeLists.reserve( aHashMap.size() );
9687 ScUniqueFormatsHashMap::iterator aMapIter( aHashMap.begin() );
9688 ScUniqueFormatsHashMap::iterator aMapEnd( aHashMap.end() );
9689 while ( aMapIter != aMapEnd )
9691 ScUniqueFormatsEntry& rEntry = aMapIter->second;
9692 const ScRangeList& rRanges = rEntry.GetRanges();
9693 aRangeLists.push_back( rRanges ); // copy ScRangeList
9694 rEntry.Clear(); // free memory, don't hold both copies of all ranges
9695 ++aMapIter;
9698 // Sort the vector by first range's start position, to avoid random shuffling
9699 // due to using the ScPatterAttr pointers
9701 ScUniqueFormatsOrder aComp;
9702 ::std::sort( aRangeLists.begin(), aRangeLists.end(), aComp );
9706 // XIndexAccess
9708 sal_Int32 SAL_CALL ScUniqueCellFormatsObj::getCount() throw(uno::RuntimeException)
9710 ScUnoGuard aGuard;
9712 return aRangeLists.size();
9715 uno::Any SAL_CALL ScUniqueCellFormatsObj::getByIndex( sal_Int32 nIndex )
9716 throw(lang::IndexOutOfBoundsException,
9717 lang::WrappedTargetException, uno::RuntimeException)
9719 ScUnoGuard aGuard;
9721 if(static_cast<sal_uInt32>(nIndex) < aRangeLists.size())
9722 return uno::makeAny(uno::Reference<sheet::XSheetCellRangeContainer>(new ScCellRangesObj(pDocShell, aRangeLists[nIndex])));
9723 else
9724 throw lang::IndexOutOfBoundsException();
9725 // return uno::Any();
9728 uno::Type SAL_CALL ScUniqueCellFormatsObj::getElementType() throw(uno::RuntimeException)
9730 ScUnoGuard aGuard;
9731 return getCppuType((uno::Reference<sheet::XSheetCellRangeContainer>*)0);
9734 sal_Bool SAL_CALL ScUniqueCellFormatsObj::hasElements() throw(uno::RuntimeException)
9736 ScUnoGuard aGuard;
9737 return ( aRangeLists.size() != 0 );
9740 // XEnumerationAccess
9742 uno::Reference<container::XEnumeration> SAL_CALL ScUniqueCellFormatsObj::createEnumeration()
9743 throw(uno::RuntimeException)
9745 ScUnoGuard aGuard;
9746 if (pDocShell)
9747 return new ScUniqueCellFormatsEnumeration( pDocShell, aRangeLists );
9748 return NULL;
9751 //------------------------------------------------------------------------
9753 ScUniqueCellFormatsEnumeration::ScUniqueCellFormatsEnumeration(ScDocShell* pDocSh, const ScMyRangeLists& rRangeLists) :
9754 aRangeLists(rRangeLists),
9755 pDocShell( pDocSh ),
9756 nCurrentPosition(0)
9758 pDocShell->GetDocument()->AddUnoObject(*this);
9761 ScUniqueCellFormatsEnumeration::~ScUniqueCellFormatsEnumeration()
9763 if (pDocShell)
9764 pDocShell->GetDocument()->RemoveUnoObject(*this);
9767 void ScUniqueCellFormatsEnumeration::Notify( SfxBroadcaster&, const SfxHint& rHint )
9769 if ( rHint.ISA( ScUpdateRefHint ) )
9771 //! und nun ???
9773 else if ( rHint.ISA( SfxSimpleHint ) )
9775 ULONG nId = ((const SfxSimpleHint&)rHint).GetId();
9776 if ( nId == SFX_HINT_DYING )
9777 pDocShell = NULL; // ungueltig geworden
9781 // XEnumeration
9783 sal_Bool SAL_CALL ScUniqueCellFormatsEnumeration::hasMoreElements() throw(uno::RuntimeException)
9785 ScUnoGuard aGuard;
9786 return static_cast<sal_uInt32>(nCurrentPosition) < aRangeLists.size();
9789 uno::Any SAL_CALL ScUniqueCellFormatsEnumeration::nextElement() throw(container::NoSuchElementException,
9790 lang::WrappedTargetException, uno::RuntimeException)
9792 ScUnoGuard aGuard;
9794 if ( !hasMoreElements() || !pDocShell )
9795 throw container::NoSuchElementException(); // no more elements
9797 // Interface-Typ muss zu ScCellFormatsObj::getElementType passen
9799 return uno::makeAny(uno::Reference<sheet::XSheetCellRangeContainer>(new ScCellRangesObj(pDocShell, aRangeLists[nCurrentPosition++])));