Bump version to 4.3-4
[LibreOffice.git] / sc / source / ui / unoobj / cellsuno.cxx
blobee1d7438dae156aae7e80239c95844f31873f248
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3 * This file is part of the LibreOffice project.
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
9 * This file incorporates work covered by the following license notice:
11 * Licensed to the Apache Software Foundation (ASF) under one or more
12 * contributor license agreements. See the NOTICE file distributed
13 * with this work for additional information regarding copyright
14 * ownership. The ASF licenses this file to you under the Apache
15 * License, Version 2.0 (the "License"); you may not use this file
16 * except in compliance with the License. You may obtain a copy of
17 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
20 #include "scitems.hxx"
21 #include <editeng/eeitem.hxx>
22 #include <svx/svdpool.hxx>
24 #include <svx/algitem.hxx>
25 #include <editeng/boxitem.hxx>
26 #include <editeng/brushitem.hxx>
27 #include <editeng/editeng.hxx>
28 #include <editeng/flditem.hxx>
29 #include <editeng/justifyitem.hxx>
30 #include <editeng/editobj.hxx>
31 #include <svx/fmdpage.hxx>
32 #include <editeng/langitem.hxx>
33 #include <sfx2/linkmgr.hxx>
34 #include <svl/srchitem.hxx>
35 #include <svl/sharedstringpool.hxx>
36 #include <svx/unomid.hxx>
37 #include <editeng/unoprnms.hxx>
38 #include <editeng/unotext.hxx>
39 #include <svx/svdpage.hxx>
40 #include <sfx2/bindings.hxx>
41 #include <svl/zforlist.hxx>
42 #include <svl/zformat.hxx>
43 #include <comphelper/servicehelper.hxx>
44 #include <cppuhelper/supportsservice.hxx>
45 #include <float.h>
47 #include <com/sun/star/awt/XBitmap.hpp>
48 #include <com/sun/star/util/CellProtection.hpp>
49 #include <com/sun/star/table/CellHoriJustify.hpp>
50 #include <com/sun/star/table/CellOrientation.hpp>
51 #include <com/sun/star/table/CellVertJustify2.hpp>
52 #include <com/sun/star/table/ShadowFormat.hpp>
53 #include <com/sun/star/table/TableBorder.hpp>
54 #include <com/sun/star/table/BorderLineStyle.hpp>
55 #include <com/sun/star/sheet/CellFlags.hpp>
56 #include <com/sun/star/sheet/FormulaResult.hpp>
57 #include <com/sun/star/beans/PropertyAttribute.hpp>
58 #include <com/sun/star/lang/Locale.hpp>
59 #include <com/sun/star/beans/TolerantPropertySetResultType.hpp>
60 #include <com/sun/star/beans/SetPropertyTolerantFailed.hpp>
61 #include <com/sun/star/text/WritingMode2.hpp>
62 #include <com/sun/star/text/textfield/Type.hpp>
64 #include "autoform.hxx"
65 #include "cellmergeoption.hxx"
66 #include "cellsuno.hxx"
67 #include "cursuno.hxx"
68 #include "textuno.hxx"
69 #include "editsrc.hxx"
70 #include "notesuno.hxx"
71 #include "fielduno.hxx"
72 #include "docuno.hxx"
73 #include "datauno.hxx"
74 #include "dapiuno.hxx"
75 #include "chartuno.hxx"
76 #include "fmtuno.hxx"
77 #include "miscuno.hxx"
78 #include "convuno.hxx"
79 #include "srchuno.hxx"
80 #include "nameuno.hxx"
81 #include "targuno.hxx"
82 #include "tokenuno.hxx"
83 #include "eventuno.hxx"
84 #include "docsh.hxx"
85 #include "markdata.hxx"
86 #include "patattr.hxx"
87 #include "docpool.hxx"
88 #include "docfunc.hxx"
89 #include "dbdocfun.hxx"
90 #include "olinefun.hxx"
91 #include "hints.hxx"
92 #include "formulacell.hxx"
93 #include "undocell.hxx"
94 #include "undotab.hxx"
95 #include "undoblk.hxx"
96 #include "stlsheet.hxx"
97 #include "dbdata.hxx"
98 #include "attrib.hxx"
99 #include "chartarr.hxx"
100 #include "chartlis.hxx"
101 #include "drwlayer.hxx"
102 #include "printfun.hxx"
103 #include "prnsave.hxx"
104 #include "tablink.hxx"
105 #include "dociter.hxx"
106 #include "rangeutl.hxx"
107 #include "conditio.hxx"
108 #include "validat.hxx"
109 #include "sc.hrc"
110 #include "brdcst.hxx"
111 #include "cellform.hxx"
112 #include "globstr.hrc"
113 #include "unonames.hxx"
114 #include "styleuno.hxx"
115 #include "rangeseq.hxx"
116 #include "unowids.hxx"
117 #include "paramisc.hxx"
118 #include "queryentry.hxx"
119 #include <formula/errorcodes.hxx>
120 #include "unoreflist.hxx"
121 #include <formula/grammar.hxx>
122 #include <editeng/escapementitem.hxx>
123 #include "stringutil.hxx"
124 #include "formulaiter.hxx"
125 #include "tokenarray.hxx"
126 #include "stylehelper.hxx"
127 #include "dputil.hxx"
128 #include <sortparam.hxx>
130 #include <list>
131 #include <boost/scoped_array.hpp>
132 #include <boost/scoped_ptr.hpp>
134 using namespace com::sun::star;
136 class ScNamedEntry
138 OUString aName;
139 ScRange aRange;
141 public:
142 ScNamedEntry(const OUString& rN, const ScRange& rR) :
143 aName(rN), aRange(rR) {}
145 const OUString& GetName() const { return aName; }
146 const ScRange& GetRange() const { return aRange; }
149 // The names in the maps must be sorted according to strcmp!
150 //! Instead of Which-ID 0 use special IDs and do not compare via names!
152 // Left/Right/Top/BottomBorder are mapped directly to the core items,
153 // not collected/applied to the borders of a range -> ATTR_BORDER can be used directly
155 static const SfxItemPropertySet* lcl_GetCellsPropertySet()
157 static const SfxItemPropertyMapEntry aCellsPropertyMap_Impl[] =
159 {OUString(SC_UNONAME_ABSNAME), SC_WID_UNO_ABSNAME, cppu::UnoType<OUString>::get(), 0 | beans::PropertyAttribute::READONLY, 0 },
160 {OUString(SC_UNONAME_ASIANVERT),ATTR_VERTICAL_ASIAN,getBooleanCppuType(), 0, 0 },
161 {OUString(SC_UNONAME_BOTTBORDER),ATTR_BORDER, ::cppu::UnoType<table::BorderLine>::get(), 0, BOTTOM_BORDER | CONVERT_TWIPS },
162 {OUString(SC_UNONAME_BOTTBORDER2),ATTR_BORDER, ::cppu::UnoType<table::BorderLine2>::get(), 0, BOTTOM_BORDER | CONVERT_TWIPS },
163 {OUString(SC_UNONAME_CELLBACK), ATTR_BACKGROUND, cppu::UnoType<sal_Int32>::get(), 0, MID_BACK_COLOR },
164 {OUString(SC_UNONAME_CELLPRO), ATTR_PROTECTION, cppu::UnoType<util::CellProtection>::get(), 0, 0 },
165 {OUString(SC_UNONAME_CELLSTYL), SC_WID_UNO_CELLSTYL,cppu::UnoType<OUString>::get(), 0, 0 },
166 {OUString(SC_UNONAME_CCOLOR), ATTR_FONT_COLOR, cppu::UnoType<sal_Int32>::get(), 0, 0 },
167 {OUString(SC_UNONAME_COUTL), ATTR_FONT_CONTOUR, getBooleanCppuType(), 0, 0 },
168 {OUString(SC_UNONAME_CCROSS), ATTR_FONT_CROSSEDOUT,getBooleanCppuType(), 0, MID_CROSSED_OUT },
169 {OUString(SC_UNONAME_CEMPHAS), ATTR_FONT_EMPHASISMARK,cppu::UnoType<sal_Int16>::get(), 0, MID_EMPHASIS },
170 {OUString(SC_UNONAME_CFONT), ATTR_FONT, cppu::UnoType<sal_Int16>::get(), 0, MID_FONT_FAMILY },
171 {OUString(SC_UNONAME_CFCHARS), ATTR_FONT, cppu::UnoType<sal_Int16>::get(), 0, MID_FONT_CHAR_SET },
172 {OUString(SC_UNO_CJK_CFCHARS), ATTR_CJK_FONT, cppu::UnoType<sal_Int16>::get(), 0, MID_FONT_CHAR_SET },
173 {OUString(SC_UNO_CTL_CFCHARS), ATTR_CTL_FONT, cppu::UnoType<sal_Int16>::get(), 0, MID_FONT_CHAR_SET },
174 {OUString(SC_UNONAME_CFFAMIL), ATTR_FONT, cppu::UnoType<sal_Int16>::get(), 0, MID_FONT_FAMILY },
175 {OUString(SC_UNO_CJK_CFFAMIL), ATTR_CJK_FONT, cppu::UnoType<sal_Int16>::get(), 0, MID_FONT_FAMILY },
176 {OUString(SC_UNO_CTL_CFFAMIL), ATTR_CTL_FONT, cppu::UnoType<sal_Int16>::get(), 0, MID_FONT_FAMILY },
177 {OUString(SC_UNONAME_CFNAME), ATTR_FONT, cppu::UnoType<OUString>::get(), 0, MID_FONT_FAMILY_NAME },
178 {OUString(SC_UNO_CJK_CFNAME), ATTR_CJK_FONT, cppu::UnoType<OUString>::get(), 0, MID_FONT_FAMILY_NAME },
179 {OUString(SC_UNO_CTL_CFNAME), ATTR_CTL_FONT, cppu::UnoType<OUString>::get(), 0, MID_FONT_FAMILY_NAME },
180 {OUString(SC_UNONAME_CFPITCH), ATTR_FONT, cppu::UnoType<sal_Int16>::get(), 0, MID_FONT_PITCH },
181 {OUString(SC_UNO_CJK_CFPITCH), ATTR_CJK_FONT, cppu::UnoType<sal_Int16>::get(), 0, MID_FONT_PITCH },
182 {OUString(SC_UNO_CTL_CFPITCH), ATTR_CTL_FONT, cppu::UnoType<sal_Int16>::get(), 0, MID_FONT_PITCH },
183 {OUString(SC_UNONAME_CFSTYLE), ATTR_FONT, cppu::UnoType<OUString>::get(), 0, MID_FONT_STYLE_NAME },
184 {OUString(SC_UNO_CJK_CFSTYLE), ATTR_CJK_FONT, cppu::UnoType<OUString>::get(), 0, MID_FONT_STYLE_NAME },
185 {OUString(SC_UNO_CTL_CFSTYLE), ATTR_CTL_FONT, cppu::UnoType<OUString>::get(), 0, MID_FONT_STYLE_NAME },
186 {OUString(SC_UNONAME_CHEIGHT), ATTR_FONT_HEIGHT, cppu::UnoType<float>::get(), 0, MID_FONTHEIGHT | CONVERT_TWIPS },
187 {OUString(SC_UNO_CJK_CHEIGHT), ATTR_CJK_FONT_HEIGHT,cppu::UnoType<float>::get(), 0, MID_FONTHEIGHT | CONVERT_TWIPS },
188 {OUString(SC_UNO_CTL_CHEIGHT), ATTR_CTL_FONT_HEIGHT,cppu::UnoType<float>::get(), 0, MID_FONTHEIGHT | CONVERT_TWIPS },
189 {OUString(SC_UNONAME_CLOCAL), ATTR_FONT_LANGUAGE, cppu::UnoType<lang::Locale>::get(), 0, MID_LANG_LOCALE },
190 {OUString(SC_UNO_CJK_CLOCAL), ATTR_CJK_FONT_LANGUAGE,cppu::UnoType<lang::Locale>::get(), 0, MID_LANG_LOCALE },
191 {OUString(SC_UNO_CTL_CLOCAL), ATTR_CTL_FONT_LANGUAGE,cppu::UnoType<lang::Locale>::get(), 0, MID_LANG_LOCALE },
192 {OUString(SC_UNONAME_COVER), ATTR_FONT_OVERLINE, cppu::UnoType<sal_Int16>::get(), 0, MID_TL_STYLE },
193 {OUString(SC_UNONAME_COVRLCOL), ATTR_FONT_OVERLINE, cppu::UnoType<sal_Int32>::get(), 0, MID_TL_COLOR },
194 {OUString(SC_UNONAME_COVRLHAS), ATTR_FONT_OVERLINE, getBooleanCppuType(), 0, MID_TL_HASCOLOR },
195 {OUString(SC_UNONAME_CPOST), ATTR_FONT_POSTURE, cppu::UnoType<awt::FontSlant>::get(), 0, MID_POSTURE },
196 {OUString(SC_UNO_CJK_CPOST), ATTR_CJK_FONT_POSTURE,cppu::UnoType<awt::FontSlant>::get(), 0, MID_POSTURE },
197 {OUString(SC_UNO_CTL_CPOST), ATTR_CTL_FONT_POSTURE,cppu::UnoType<awt::FontSlant>::get(), 0, MID_POSTURE },
198 {OUString(SC_UNONAME_CRELIEF), ATTR_FONT_RELIEF, cppu::UnoType<sal_Int16>::get(), 0, MID_RELIEF },
199 {OUString(SC_UNONAME_CSHADD), ATTR_FONT_SHADOWED, getBooleanCppuType(), 0, 0 },
200 {OUString(SC_UNONAME_CSTRIKE), ATTR_FONT_CROSSEDOUT,cppu::UnoType<sal_Int16>::get(), 0, MID_CROSS_OUT },
201 {OUString(SC_UNONAME_CUNDER), ATTR_FONT_UNDERLINE,cppu::UnoType<sal_Int16>::get(), 0, MID_TL_STYLE },
202 {OUString(SC_UNONAME_CUNDLCOL), ATTR_FONT_UNDERLINE,cppu::UnoType<sal_Int32>::get(), 0, MID_TL_COLOR },
203 {OUString(SC_UNONAME_CUNDLHAS), ATTR_FONT_UNDERLINE,getBooleanCppuType(), 0, MID_TL_HASCOLOR },
204 {OUString(SC_UNONAME_CWEIGHT), ATTR_FONT_WEIGHT, cppu::UnoType<float>::get(), 0, MID_WEIGHT },
205 {OUString(SC_UNO_CJK_CWEIGHT), ATTR_CJK_FONT_WEIGHT,cppu::UnoType<float>::get(), 0, MID_WEIGHT },
206 {OUString(SC_UNO_CTL_CWEIGHT), ATTR_CTL_FONT_WEIGHT,cppu::UnoType<float>::get(), 0, MID_WEIGHT },
207 {OUString(SC_UNONAME_CWORDMOD), ATTR_FONT_WORDLINE, getBooleanCppuType(), 0, 0 },
208 {OUString(SC_UNONAME_CHCOLHDR), SC_WID_UNO_CHCOLHDR,getBooleanCppuType(), 0, 0 },
209 {OUString(SC_UNONAME_CHROWHDR), SC_WID_UNO_CHROWHDR,getBooleanCppuType(), 0, 0 },
210 {OUString(SC_UNONAME_CONDFMT), SC_WID_UNO_CONDFMT, cppu::UnoType<sheet::XSheetConditionalEntries>::get(), 0, 0 },
211 {OUString(SC_UNONAME_CONDLOC), SC_WID_UNO_CONDLOC, cppu::UnoType<sheet::XSheetConditionalEntries>::get(), 0, 0 },
212 {OUString(SC_UNONAME_CONDXML), SC_WID_UNO_CONDXML, cppu::UnoType<sheet::XSheetConditionalEntries>::get(), 0, 0 },
213 {OUString(SC_UNONAME_DIAGONAL_BLTR), ATTR_BORDER_BLTR, ::cppu::UnoType<table::BorderLine>::get(), 0, 0 | CONVERT_TWIPS },
214 {OUString(SC_UNONAME_DIAGONAL_BLTR2), ATTR_BORDER_BLTR, ::cppu::UnoType<table::BorderLine2>::get(), 0, 0 | CONVERT_TWIPS },
215 {OUString(SC_UNONAME_DIAGONAL_TLBR), ATTR_BORDER_TLBR, ::cppu::UnoType<table::BorderLine>::get(), 0, 0 | CONVERT_TWIPS },
216 {OUString(SC_UNONAME_DIAGONAL_TLBR2), ATTR_BORDER_TLBR, ::cppu::UnoType<table::BorderLine2>::get(), 0, 0 | CONVERT_TWIPS },
217 {OUString(SC_UNONAME_CELLHJUS), ATTR_HOR_JUSTIFY, cppu::UnoType<table::CellHoriJustify>::get(), 0, MID_HORJUST_HORJUST },
218 {OUString(SC_UNONAME_CELLHJUS_METHOD), ATTR_HOR_JUSTIFY_METHOD, ::cppu::UnoType<sal_Int32>::get(), 0, 0 },
219 {OUString(SC_UNONAME_CELLTRAN), ATTR_BACKGROUND, getBooleanCppuType(), 0, MID_GRAPHIC_TRANSPARENT },
220 {OUString(SC_UNONAME_WRAP), ATTR_LINEBREAK, getBooleanCppuType(), 0, 0 },
221 {OUString(SC_UNONAME_LEFTBORDER),ATTR_BORDER, ::cppu::UnoType<table::BorderLine>::get(), 0, LEFT_BORDER | CONVERT_TWIPS },
222 {OUString(SC_UNONAME_LEFTBORDER2),ATTR_BORDER, ::cppu::UnoType<table::BorderLine2>::get(), 0, LEFT_BORDER | CONVERT_TWIPS },
223 {OUString(SC_UNONAME_NUMFMT), ATTR_VALUE_FORMAT, cppu::UnoType<sal_Int32>::get(), 0, 0 },
224 {OUString(SC_UNONAME_NUMRULES), SC_WID_UNO_NUMRULES,cppu::UnoType<container::XIndexReplace>::get(), 0, 0 },
225 {OUString(SC_UNONAME_CELLORI), ATTR_STACKED, cppu::UnoType<table::CellOrientation>::get(), 0, 0 },
226 {OUString(SC_UNONAME_PADJUST), ATTR_HOR_JUSTIFY, ::cppu::UnoType<sal_Int16>::get(), 0, MID_HORJUST_ADJUST },
227 {OUString(SC_UNONAME_PBMARGIN), ATTR_MARGIN, cppu::UnoType<sal_Int32>::get(), 0, MID_MARGIN_LO_MARGIN | CONVERT_TWIPS },
228 {OUString(SC_UNONAME_PINDENT), ATTR_INDENT, cppu::UnoType<sal_Int16>::get(), 0, 0 }, //! CONVERT_TWIPS
229 {OUString(SC_UNONAME_PISCHDIST),ATTR_SCRIPTSPACE, getBooleanCppuType(), 0, 0 },
230 {OUString(SC_UNONAME_PISFORBID),ATTR_FORBIDDEN_RULES,getBooleanCppuType(), 0, 0 },
231 {OUString(SC_UNONAME_PISHANG), ATTR_HANGPUNCTUATION,getBooleanCppuType(), 0, 0 },
232 {OUString(SC_UNONAME_PISHYPHEN),ATTR_HYPHENATE, getBooleanCppuType(), 0, 0 },
233 {OUString(SC_UNONAME_PLASTADJ), ATTR_HOR_JUSTIFY, ::cppu::UnoType<sal_Int16>::get(), 0, MID_HORJUST_ADJUST },
234 {OUString(SC_UNONAME_PLMARGIN), ATTR_MARGIN, cppu::UnoType<sal_Int32>::get(), 0, MID_MARGIN_L_MARGIN | CONVERT_TWIPS },
235 {OUString(SC_UNONAME_PRMARGIN), ATTR_MARGIN, cppu::UnoType<sal_Int32>::get(), 0, MID_MARGIN_R_MARGIN | CONVERT_TWIPS },
236 {OUString(SC_UNONAME_PTMARGIN), ATTR_MARGIN, cppu::UnoType<sal_Int32>::get(), 0, MID_MARGIN_UP_MARGIN | CONVERT_TWIPS },
237 {OUString(SC_UNONAME_RIGHTBORDER),ATTR_BORDER, ::cppu::UnoType<table::BorderLine>::get(), 0, RIGHT_BORDER | CONVERT_TWIPS },
238 {OUString(SC_UNONAME_RIGHTBORDER2),ATTR_BORDER, ::cppu::UnoType<table::BorderLine2>::get(), 0, RIGHT_BORDER | CONVERT_TWIPS },
239 {OUString(SC_UNONAME_ROTANG), ATTR_ROTATE_VALUE, cppu::UnoType<sal_Int32>::get(), 0, 0 },
240 {OUString(SC_UNONAME_ROTREF), ATTR_ROTATE_MODE, cppu::UnoType<sal_Int32>::get(), 0, 0 },
241 {OUString(SC_UNONAME_SHADOW), ATTR_SHADOW, cppu::UnoType<table::ShadowFormat>::get(), 0, 0 | CONVERT_TWIPS },
242 {OUString(SC_UNONAME_SHRINK_TO_FIT), ATTR_SHRINKTOFIT, getBooleanCppuType(), 0, 0 },
243 {OUString(SC_UNONAME_TBLBORD), SC_WID_UNO_TBLBORD, cppu::UnoType<table::TableBorder>::get(), 0, 0 | CONVERT_TWIPS },
244 {OUString(SC_UNONAME_TBLBORD2), SC_WID_UNO_TBLBORD2, cppu::UnoType<table::TableBorder2>::get(), 0, 0 | CONVERT_TWIPS },
245 {OUString(SC_UNONAME_TOPBORDER),ATTR_BORDER, ::cppu::UnoType<table::BorderLine>::get(), 0, TOP_BORDER | CONVERT_TWIPS },
246 {OUString(SC_UNONAME_TOPBORDER2),ATTR_BORDER, ::cppu::UnoType<table::BorderLine2>::get(), 0, TOP_BORDER | CONVERT_TWIPS },
247 {OUString(SC_UNONAME_USERDEF), ATTR_USERDEF, cppu::UnoType<container::XNameContainer>::get(), 0, 0 },
248 {OUString(SC_UNONAME_VALIDAT), SC_WID_UNO_VALIDAT, cppu::UnoType<beans::XPropertySet>::get(), 0, 0 },
249 {OUString(SC_UNONAME_VALILOC), SC_WID_UNO_VALILOC, cppu::UnoType<beans::XPropertySet>::get(), 0, 0 },
250 {OUString(SC_UNONAME_VALIXML), SC_WID_UNO_VALIXML, cppu::UnoType<beans::XPropertySet>::get(), 0, 0 },
251 {OUString(SC_UNONAME_CELLVJUS), ATTR_VER_JUSTIFY, cppu::UnoType<sal_Int32>::get(), 0, 0 },
252 {OUString(SC_UNONAME_CELLVJUS_METHOD), ATTR_VER_JUSTIFY_METHOD, ::cppu::UnoType<sal_Int32>::get(), 0, 0 },
253 {OUString(SC_UNONAME_WRITING), ATTR_WRITINGDIR, cppu::UnoType<sal_Int16>::get(), 0, 0 },
254 {OUString(SC_UNONAME_HYPERLINK), ATTR_HYPERLINK, cppu::UnoType<OUString>::get(), 0, 0 },
255 { OUString(), 0, css::uno::Type(), 0, 0 }
257 static SfxItemPropertySet aCellsPropertySet( aCellsPropertyMap_Impl );
258 return &aCellsPropertySet;
261 // CellRange enthaelt alle Eintraege von Cells, zusaetzlich eigene Eintraege
262 // mit Which-ID 0 (werden nur fuer getPropertySetInfo benoetigt).
264 static const SfxItemPropertySet* lcl_GetRangePropertySet()
266 static const SfxItemPropertyMapEntry aRangePropertyMap_Impl[] =
268 {OUString(SC_UNONAME_ABSNAME), SC_WID_UNO_ABSNAME, cppu::UnoType<OUString>::get(), 0 | beans::PropertyAttribute::READONLY, 0 },
269 {OUString(SC_UNONAME_ASIANVERT),ATTR_VERTICAL_ASIAN,getBooleanCppuType(), 0, 0 },
270 {OUString(SC_UNONAME_BOTTBORDER),ATTR_BORDER, ::cppu::UnoType<table::BorderLine>::get(), 0, BOTTOM_BORDER | CONVERT_TWIPS },
271 {OUString(SC_UNONAME_BOTTBORDER2),ATTR_BORDER, ::cppu::UnoType<table::BorderLine2>::get(), 0, BOTTOM_BORDER | CONVERT_TWIPS },
272 {OUString(SC_UNONAME_CELLBACK), ATTR_BACKGROUND, cppu::UnoType<sal_Int32>::get(), 0, MID_BACK_COLOR },
273 {OUString(SC_UNONAME_CELLPRO), ATTR_PROTECTION, cppu::UnoType<util::CellProtection>::get(), 0, 0 },
274 {OUString(SC_UNONAME_CELLSTYL), SC_WID_UNO_CELLSTYL,cppu::UnoType<OUString>::get(), 0, 0 },
275 {OUString(SC_UNONAME_CCOLOR), ATTR_FONT_COLOR, cppu::UnoType<sal_Int32>::get(), 0, 0 },
276 {OUString(SC_UNONAME_COUTL), ATTR_FONT_CONTOUR, getBooleanCppuType(), 0, 0 },
277 {OUString(SC_UNONAME_CCROSS), ATTR_FONT_CROSSEDOUT,getBooleanCppuType(), 0, MID_CROSSED_OUT },
278 {OUString(SC_UNONAME_CEMPHAS), ATTR_FONT_EMPHASISMARK,cppu::UnoType<sal_Int16>::get(), 0, MID_EMPHASIS },
279 {OUString(SC_UNONAME_CFONT), ATTR_FONT, cppu::UnoType<sal_Int16>::get(), 0, MID_FONT_FAMILY },
280 {OUString(SC_UNONAME_CFCHARS), ATTR_FONT, cppu::UnoType<sal_Int16>::get(), 0, MID_FONT_CHAR_SET },
281 {OUString(SC_UNO_CJK_CFCHARS), ATTR_CJK_FONT, cppu::UnoType<sal_Int16>::get(), 0, MID_FONT_CHAR_SET },
282 {OUString(SC_UNO_CTL_CFCHARS), ATTR_CTL_FONT, cppu::UnoType<sal_Int16>::get(), 0, MID_FONT_CHAR_SET },
283 {OUString(SC_UNONAME_CFFAMIL), ATTR_FONT, cppu::UnoType<sal_Int16>::get(), 0, MID_FONT_FAMILY },
284 {OUString(SC_UNO_CJK_CFFAMIL), ATTR_CJK_FONT, cppu::UnoType<sal_Int16>::get(), 0, MID_FONT_FAMILY },
285 {OUString(SC_UNO_CTL_CFFAMIL), ATTR_CTL_FONT, cppu::UnoType<sal_Int16>::get(), 0, MID_FONT_FAMILY },
286 {OUString(SC_UNONAME_CFNAME), ATTR_FONT, cppu::UnoType<OUString>::get(), 0, MID_FONT_FAMILY_NAME },
287 {OUString(SC_UNO_CJK_CFNAME), ATTR_CJK_FONT, cppu::UnoType<OUString>::get(), 0, MID_FONT_FAMILY_NAME },
288 {OUString(SC_UNO_CTL_CFNAME), ATTR_CTL_FONT, cppu::UnoType<OUString>::get(), 0, MID_FONT_FAMILY_NAME },
289 {OUString(SC_UNONAME_CFPITCH), ATTR_FONT, cppu::UnoType<sal_Int16>::get(), 0, MID_FONT_PITCH },
290 {OUString(SC_UNO_CJK_CFPITCH), ATTR_CJK_FONT, cppu::UnoType<sal_Int16>::get(), 0, MID_FONT_PITCH },
291 {OUString(SC_UNO_CTL_CFPITCH), ATTR_CTL_FONT, cppu::UnoType<sal_Int16>::get(), 0, MID_FONT_PITCH },
292 {OUString(SC_UNONAME_CFSTYLE), ATTR_FONT, cppu::UnoType<OUString>::get(), 0, MID_FONT_STYLE_NAME },
293 {OUString(SC_UNO_CJK_CFSTYLE), ATTR_CJK_FONT, cppu::UnoType<OUString>::get(), 0, MID_FONT_STYLE_NAME },
294 {OUString(SC_UNO_CTL_CFSTYLE), ATTR_CTL_FONT, cppu::UnoType<OUString>::get(), 0, MID_FONT_STYLE_NAME },
295 {OUString(SC_UNONAME_CHEIGHT), ATTR_FONT_HEIGHT, cppu::UnoType<float>::get(), 0, MID_FONTHEIGHT | CONVERT_TWIPS },
296 {OUString(SC_UNO_CJK_CHEIGHT), ATTR_CJK_FONT_HEIGHT,cppu::UnoType<float>::get(), 0, MID_FONTHEIGHT | CONVERT_TWIPS },
297 {OUString(SC_UNO_CTL_CHEIGHT), ATTR_CTL_FONT_HEIGHT,cppu::UnoType<float>::get(), 0, MID_FONTHEIGHT | CONVERT_TWIPS },
298 {OUString(SC_UNONAME_CLOCAL), ATTR_FONT_LANGUAGE, cppu::UnoType<lang::Locale>::get(), 0, MID_LANG_LOCALE },
299 {OUString(SC_UNO_CJK_CLOCAL), ATTR_CJK_FONT_LANGUAGE,cppu::UnoType<lang::Locale>::get(), 0, MID_LANG_LOCALE },
300 {OUString(SC_UNO_CTL_CLOCAL), ATTR_CTL_FONT_LANGUAGE,cppu::UnoType<lang::Locale>::get(), 0, MID_LANG_LOCALE },
301 {OUString(SC_UNONAME_COVER), ATTR_FONT_OVERLINE, cppu::UnoType<sal_Int16>::get(), 0, MID_TL_STYLE },
302 {OUString(SC_UNONAME_COVRLCOL), ATTR_FONT_OVERLINE, cppu::UnoType<sal_Int32>::get(), 0, MID_TL_COLOR },
303 {OUString(SC_UNONAME_COVRLHAS), ATTR_FONT_OVERLINE, getBooleanCppuType(), 0, MID_TL_HASCOLOR },
304 {OUString(SC_UNONAME_CPOST), ATTR_FONT_POSTURE, cppu::UnoType<awt::FontSlant>::get(), 0, MID_POSTURE },
305 {OUString(SC_UNO_CJK_CPOST), ATTR_CJK_FONT_POSTURE,cppu::UnoType<awt::FontSlant>::get(), 0, MID_POSTURE },
306 {OUString(SC_UNO_CTL_CPOST), ATTR_CTL_FONT_POSTURE,cppu::UnoType<awt::FontSlant>::get(), 0, MID_POSTURE },
307 {OUString(SC_UNONAME_CRELIEF), ATTR_FONT_RELIEF, cppu::UnoType<sal_Int16>::get(), 0, MID_RELIEF },
308 {OUString(SC_UNONAME_CSHADD), ATTR_FONT_SHADOWED, getBooleanCppuType(), 0, 0 },
309 {OUString(SC_UNONAME_CSTRIKE), ATTR_FONT_CROSSEDOUT,cppu::UnoType<sal_Int16>::get(), 0, MID_CROSS_OUT },
310 {OUString(SC_UNONAME_CUNDER), ATTR_FONT_UNDERLINE,cppu::UnoType<sal_Int16>::get(), 0, MID_TL_STYLE },
311 {OUString(SC_UNONAME_CUNDLCOL), ATTR_FONT_UNDERLINE,cppu::UnoType<sal_Int32>::get(), 0, MID_TL_COLOR },
312 {OUString(SC_UNONAME_CUNDLHAS), ATTR_FONT_UNDERLINE,getBooleanCppuType(), 0, MID_TL_HASCOLOR },
313 {OUString(SC_UNONAME_CWEIGHT), ATTR_FONT_WEIGHT, cppu::UnoType<float>::get(), 0, MID_WEIGHT },
314 {OUString(SC_UNO_CJK_CWEIGHT), ATTR_CJK_FONT_WEIGHT,cppu::UnoType<float>::get(), 0, MID_WEIGHT },
315 {OUString(SC_UNO_CTL_CWEIGHT), ATTR_CTL_FONT_WEIGHT,cppu::UnoType<float>::get(), 0, MID_WEIGHT },
316 {OUString(SC_UNONAME_CWORDMOD), ATTR_FONT_WORDLINE, getBooleanCppuType(), 0, 0 },
317 {OUString(SC_UNONAME_CHCOLHDR), SC_WID_UNO_CHCOLHDR,getBooleanCppuType(), 0, 0 },
318 {OUString(SC_UNONAME_CHROWHDR), SC_WID_UNO_CHROWHDR,getBooleanCppuType(), 0, 0 },
319 {OUString(SC_UNONAME_CONDFMT), SC_WID_UNO_CONDFMT, cppu::UnoType<sheet::XSheetConditionalEntries>::get(), 0, 0 },
320 {OUString(SC_UNONAME_CONDLOC), SC_WID_UNO_CONDLOC, cppu::UnoType<sheet::XSheetConditionalEntries>::get(), 0, 0 },
321 {OUString(SC_UNONAME_CONDXML), SC_WID_UNO_CONDXML, cppu::UnoType<sheet::XSheetConditionalEntries>::get(), 0, 0 },
322 {OUString(SC_UNONAME_DIAGONAL_BLTR), ATTR_BORDER_BLTR, ::cppu::UnoType<table::BorderLine>::get(), 0, 0 | CONVERT_TWIPS },
323 {OUString(SC_UNONAME_DIAGONAL_BLTR2), ATTR_BORDER_BLTR, ::cppu::UnoType<table::BorderLine2>::get(), 0, 0 | CONVERT_TWIPS },
324 {OUString(SC_UNONAME_DIAGONAL_TLBR), ATTR_BORDER_TLBR, ::cppu::UnoType<table::BorderLine>::get(), 0, 0 | CONVERT_TWIPS },
325 {OUString(SC_UNONAME_DIAGONAL_TLBR2), ATTR_BORDER_TLBR, ::cppu::UnoType<table::BorderLine2>::get(), 0, 0 | CONVERT_TWIPS },
326 {OUString(SC_UNONAME_CELLHJUS), ATTR_HOR_JUSTIFY, cppu::UnoType<table::CellHoriJustify>::get(), 0, MID_HORJUST_HORJUST },
327 {OUString(SC_UNONAME_CELLHJUS_METHOD), ATTR_HOR_JUSTIFY_METHOD, ::cppu::UnoType<sal_Int32>::get(), 0, 0 },
328 {OUString(SC_UNONAME_CELLTRAN), ATTR_BACKGROUND, getBooleanCppuType(), 0, MID_GRAPHIC_TRANSPARENT },
329 {OUString(SC_UNONAME_WRAP), ATTR_LINEBREAK, getBooleanCppuType(), 0, 0 },
330 {OUString(SC_UNONAME_LEFTBORDER),ATTR_BORDER, ::cppu::UnoType<table::BorderLine>::get(), 0, LEFT_BORDER | CONVERT_TWIPS },
331 {OUString(SC_UNONAME_LEFTBORDER2),ATTR_BORDER, ::cppu::UnoType<table::BorderLine2>::get(), 0, LEFT_BORDER | CONVERT_TWIPS },
332 {OUString(SC_UNONAME_NUMFMT), ATTR_VALUE_FORMAT, cppu::UnoType<sal_Int32>::get(), 0, 0 },
333 {OUString(SC_UNONAME_NUMRULES), SC_WID_UNO_NUMRULES,cppu::UnoType<container::XIndexReplace>::get(), 0, 0 },
334 {OUString(SC_UNONAME_CELLORI), ATTR_STACKED, cppu::UnoType<table::CellOrientation>::get(), 0, 0 },
335 {OUString(SC_UNONAME_PADJUST), ATTR_HOR_JUSTIFY, ::cppu::UnoType<sal_Int16>::get(), 0, MID_HORJUST_ADJUST },
336 {OUString(SC_UNONAME_PBMARGIN), ATTR_MARGIN, cppu::UnoType<sal_Int32>::get(), 0, MID_MARGIN_LO_MARGIN | CONVERT_TWIPS },
337 {OUString(SC_UNONAME_PINDENT), ATTR_INDENT, cppu::UnoType<sal_Int16>::get(), 0, 0 }, //! CONVERT_TWIPS
338 {OUString(SC_UNONAME_PISCHDIST),ATTR_SCRIPTSPACE, getBooleanCppuType(), 0, 0 },
339 {OUString(SC_UNONAME_PISFORBID),ATTR_FORBIDDEN_RULES,getBooleanCppuType(), 0, 0 },
340 {OUString(SC_UNONAME_PISHANG), ATTR_HANGPUNCTUATION,getBooleanCppuType(), 0, 0 },
341 {OUString(SC_UNONAME_PISHYPHEN),ATTR_HYPHENATE, getBooleanCppuType(), 0, 0 },
342 {OUString(SC_UNONAME_PLASTADJ), ATTR_HOR_JUSTIFY, ::cppu::UnoType<sal_Int16>::get(), 0, MID_HORJUST_ADJUST },
343 {OUString(SC_UNONAME_PLMARGIN), ATTR_MARGIN, cppu::UnoType<sal_Int32>::get(), 0, MID_MARGIN_L_MARGIN | CONVERT_TWIPS },
344 {OUString(SC_UNONAME_PRMARGIN), ATTR_MARGIN, cppu::UnoType<sal_Int32>::get(), 0, MID_MARGIN_R_MARGIN | CONVERT_TWIPS },
345 {OUString(SC_UNONAME_PTMARGIN), ATTR_MARGIN, cppu::UnoType<sal_Int32>::get(), 0, MID_MARGIN_UP_MARGIN | CONVERT_TWIPS },
346 {OUString(SC_UNONAME_POS), SC_WID_UNO_POS, cppu::UnoType<awt::Point>::get(), 0 | beans::PropertyAttribute::READONLY, 0 },
347 {OUString(SC_UNONAME_RIGHTBORDER),ATTR_BORDER, ::cppu::UnoType<table::BorderLine>::get(), 0, RIGHT_BORDER | CONVERT_TWIPS },
348 {OUString(SC_UNONAME_RIGHTBORDER2),ATTR_BORDER, ::cppu::UnoType<table::BorderLine2>::get(), 0, RIGHT_BORDER | CONVERT_TWIPS },
349 {OUString(SC_UNONAME_ROTANG), ATTR_ROTATE_VALUE, cppu::UnoType<sal_Int32>::get(), 0, 0 },
350 {OUString(SC_UNONAME_ROTREF), ATTR_ROTATE_MODE, cppu::UnoType<sal_Int32>::get(), 0, 0 },
351 {OUString(SC_UNONAME_SHADOW), ATTR_SHADOW, cppu::UnoType<table::ShadowFormat>::get(), 0, 0 | CONVERT_TWIPS },
352 {OUString(SC_UNONAME_SHRINK_TO_FIT), ATTR_SHRINKTOFIT, getBooleanCppuType(), 0, 0 },
353 {OUString(SC_UNONAME_SIZE), SC_WID_UNO_SIZE, cppu::UnoType<awt::Size>::get(), 0 | beans::PropertyAttribute::READONLY, 0 },
354 {OUString(SC_UNONAME_TBLBORD), SC_WID_UNO_TBLBORD, cppu::UnoType<table::TableBorder>::get(), 0, 0 | CONVERT_TWIPS },
355 {OUString(SC_UNONAME_TBLBORD2), SC_WID_UNO_TBLBORD2, cppu::UnoType<table::TableBorder2>::get(), 0, 0 | CONVERT_TWIPS },
356 {OUString(SC_UNONAME_TOPBORDER),ATTR_BORDER, ::cppu::UnoType<table::BorderLine>::get(), 0, TOP_BORDER | CONVERT_TWIPS },
357 {OUString(SC_UNONAME_TOPBORDER2),ATTR_BORDER, ::cppu::UnoType<table::BorderLine2>::get(), 0, TOP_BORDER | CONVERT_TWIPS },
358 {OUString(SC_UNONAME_USERDEF), ATTR_USERDEF, cppu::UnoType<container::XNameContainer>::get(), 0, 0 },
359 {OUString(SC_UNONAME_VALIDAT), SC_WID_UNO_VALIDAT, cppu::UnoType<beans::XPropertySet>::get(), 0, 0 },
360 {OUString(SC_UNONAME_VALILOC), SC_WID_UNO_VALILOC, cppu::UnoType<beans::XPropertySet>::get(), 0, 0 },
361 {OUString(SC_UNONAME_VALIXML), SC_WID_UNO_VALIXML, cppu::UnoType<beans::XPropertySet>::get(), 0, 0 },
362 {OUString(SC_UNONAME_CELLVJUS), ATTR_VER_JUSTIFY, cppu::UnoType<sal_Int32>::get(), 0, 0 },
363 {OUString(SC_UNONAME_CELLVJUS_METHOD), ATTR_VER_JUSTIFY_METHOD, ::cppu::UnoType<sal_Int32>::get(), 0, 0 },
364 {OUString(SC_UNONAME_WRITING), ATTR_WRITINGDIR, cppu::UnoType<sal_Int16>::get(), 0, 0 },
365 { OUString(), 0, css::uno::Type(), 0, 0 }
367 static SfxItemPropertySet aRangePropertySet( aRangePropertyMap_Impl );
368 return &aRangePropertySet;
371 // Cell enthaelt alle Eintraege von CellRange, zusaetzlich eigene Eintraege
372 // mit Which-ID 0 (werden nur fuer getPropertySetInfo benoetigt).
374 static const SfxItemPropertySet* lcl_GetCellPropertySet()
376 static const SfxItemPropertyMapEntry aCellPropertyMap_Impl[] =
378 {OUString(SC_UNONAME_ABSNAME), SC_WID_UNO_ABSNAME, cppu::UnoType<OUString>::get(), 0 | beans::PropertyAttribute::READONLY, 0 },
379 {OUString(SC_UNONAME_ASIANVERT),ATTR_VERTICAL_ASIAN,getBooleanCppuType(), 0, 0 },
380 {OUString(SC_UNONAME_BOTTBORDER),ATTR_BORDER, ::cppu::UnoType<table::BorderLine>::get(), 0, BOTTOM_BORDER | CONVERT_TWIPS },
381 {OUString(SC_UNONAME_BOTTBORDER2),ATTR_BORDER, ::cppu::UnoType<table::BorderLine2>::get(), 0, BOTTOM_BORDER | CONVERT_TWIPS },
382 {OUString(SC_UNONAME_CELLBACK), ATTR_BACKGROUND, cppu::UnoType<sal_Int32>::get(), 0, MID_BACK_COLOR },
383 {OUString(SC_UNONAME_CELLPRO), ATTR_PROTECTION, cppu::UnoType<util::CellProtection>::get(), 0, 0 },
384 {OUString(SC_UNONAME_CELLSTYL), SC_WID_UNO_CELLSTYL,cppu::UnoType<OUString>::get(), 0, 0 },
385 {OUString(SC_UNONAME_CCOLOR), ATTR_FONT_COLOR, cppu::UnoType<sal_Int32>::get(), 0, 0 },
386 {OUString(SC_UNONAME_COUTL), ATTR_FONT_CONTOUR, getBooleanCppuType(), 0, 0 },
387 {OUString(SC_UNONAME_CCROSS), ATTR_FONT_CROSSEDOUT,getBooleanCppuType(), 0, MID_CROSSED_OUT },
388 {OUString(SC_UNONAME_CEMPHAS), ATTR_FONT_EMPHASISMARK,cppu::UnoType<sal_Int16>::get(), 0, MID_EMPHASIS },
389 {OUString(SC_UNONAME_CFONT), ATTR_FONT, cppu::UnoType<sal_Int16>::get(), 0, MID_FONT_FAMILY },
390 {OUString(SC_UNONAME_CFCHARS), ATTR_FONT, cppu::UnoType<sal_Int16>::get(), 0, MID_FONT_CHAR_SET },
391 {OUString(SC_UNO_CJK_CFCHARS), ATTR_CJK_FONT, cppu::UnoType<sal_Int16>::get(), 0, MID_FONT_CHAR_SET },
392 {OUString(SC_UNO_CTL_CFCHARS), ATTR_CTL_FONT, cppu::UnoType<sal_Int16>::get(), 0, MID_FONT_CHAR_SET },
393 {OUString(SC_UNONAME_CFFAMIL), ATTR_FONT, cppu::UnoType<sal_Int16>::get(), 0, MID_FONT_FAMILY },
394 {OUString(SC_UNO_CJK_CFFAMIL), ATTR_CJK_FONT, cppu::UnoType<sal_Int16>::get(), 0, MID_FONT_FAMILY },
395 {OUString(SC_UNO_CTL_CFFAMIL), ATTR_CTL_FONT, cppu::UnoType<sal_Int16>::get(), 0, MID_FONT_FAMILY },
396 {OUString(SC_UNONAME_CFNAME), ATTR_FONT, cppu::UnoType<OUString>::get(), 0, MID_FONT_FAMILY_NAME },
397 {OUString(SC_UNO_CJK_CFNAME), ATTR_CJK_FONT, cppu::UnoType<OUString>::get(), 0, MID_FONT_FAMILY_NAME },
398 {OUString(SC_UNO_CTL_CFNAME), ATTR_CTL_FONT, cppu::UnoType<OUString>::get(), 0, MID_FONT_FAMILY_NAME },
399 {OUString(SC_UNONAME_CFPITCH), ATTR_FONT, cppu::UnoType<sal_Int16>::get(), 0, MID_FONT_PITCH },
400 {OUString(SC_UNO_CJK_CFPITCH), ATTR_CJK_FONT, cppu::UnoType<sal_Int16>::get(), 0, MID_FONT_PITCH },
401 {OUString(SC_UNO_CTL_CFPITCH), ATTR_CTL_FONT, cppu::UnoType<sal_Int16>::get(), 0, MID_FONT_PITCH },
402 {OUString(SC_UNONAME_CFSTYLE), ATTR_FONT, cppu::UnoType<OUString>::get(), 0, MID_FONT_STYLE_NAME },
403 {OUString(SC_UNO_CJK_CFSTYLE), ATTR_CJK_FONT, cppu::UnoType<OUString>::get(), 0, MID_FONT_STYLE_NAME },
404 {OUString(SC_UNO_CTL_CFSTYLE), ATTR_CTL_FONT, cppu::UnoType<OUString>::get(), 0, MID_FONT_STYLE_NAME },
405 {OUString(SC_UNONAME_CHEIGHT), ATTR_FONT_HEIGHT, cppu::UnoType<float>::get(), 0, MID_FONTHEIGHT | CONVERT_TWIPS },
406 {OUString(SC_UNO_CJK_CHEIGHT), ATTR_CJK_FONT_HEIGHT,cppu::UnoType<float>::get(), 0, MID_FONTHEIGHT | CONVERT_TWIPS },
407 {OUString(SC_UNO_CTL_CHEIGHT), ATTR_CTL_FONT_HEIGHT,cppu::UnoType<float>::get(), 0, MID_FONTHEIGHT | CONVERT_TWIPS },
408 {OUString(SC_UNONAME_CLOCAL), ATTR_FONT_LANGUAGE, cppu::UnoType<lang::Locale>::get(), 0, MID_LANG_LOCALE },
409 {OUString(SC_UNO_CJK_CLOCAL), ATTR_CJK_FONT_LANGUAGE,cppu::UnoType<lang::Locale>::get(), 0, MID_LANG_LOCALE },
410 {OUString(SC_UNO_CTL_CLOCAL), ATTR_CTL_FONT_LANGUAGE,cppu::UnoType<lang::Locale>::get(), 0, MID_LANG_LOCALE },
411 {OUString(SC_UNONAME_COVER), ATTR_FONT_OVERLINE, cppu::UnoType<sal_Int16>::get(), 0, MID_TL_STYLE },
412 {OUString(SC_UNONAME_COVRLCOL), ATTR_FONT_OVERLINE, cppu::UnoType<sal_Int32>::get(), 0, MID_TL_COLOR },
413 {OUString(SC_UNONAME_COVRLHAS), ATTR_FONT_OVERLINE, getBooleanCppuType(), 0, MID_TL_HASCOLOR },
414 {OUString(SC_UNONAME_CPOST), ATTR_FONT_POSTURE, cppu::UnoType<awt::FontSlant>::get(), 0, MID_POSTURE },
415 {OUString(SC_UNO_CJK_CPOST), ATTR_CJK_FONT_POSTURE,cppu::UnoType<awt::FontSlant>::get(), 0, MID_POSTURE },
416 {OUString(SC_UNO_CTL_CPOST), ATTR_CTL_FONT_POSTURE,cppu::UnoType<awt::FontSlant>::get(), 0, MID_POSTURE },
417 {OUString(SC_UNONAME_CRELIEF), ATTR_FONT_RELIEF, cppu::UnoType<sal_Int16>::get(), 0, MID_RELIEF },
418 {OUString(SC_UNONAME_CSHADD), ATTR_FONT_SHADOWED, getBooleanCppuType(), 0, 0 },
419 {OUString(SC_UNONAME_CSTRIKE), ATTR_FONT_CROSSEDOUT,cppu::UnoType<sal_Int16>::get(), 0, MID_CROSS_OUT },
420 {OUString(SC_UNONAME_CUNDER), ATTR_FONT_UNDERLINE,cppu::UnoType<sal_Int16>::get(), 0, MID_TL_STYLE },
421 {OUString(SC_UNONAME_CUNDLCOL), ATTR_FONT_UNDERLINE,cppu::UnoType<sal_Int32>::get(), 0, MID_TL_COLOR },
422 {OUString(SC_UNONAME_CUNDLHAS), ATTR_FONT_UNDERLINE,getBooleanCppuType(), 0, MID_TL_HASCOLOR },
423 {OUString(SC_UNONAME_CWEIGHT), ATTR_FONT_WEIGHT, cppu::UnoType<float>::get(), 0, MID_WEIGHT },
424 {OUString(SC_UNO_CJK_CWEIGHT), ATTR_CJK_FONT_WEIGHT,cppu::UnoType<float>::get(), 0, MID_WEIGHT },
425 {OUString(SC_UNO_CTL_CWEIGHT), ATTR_CTL_FONT_WEIGHT,cppu::UnoType<float>::get(), 0, MID_WEIGHT },
426 {OUString(SC_UNONAME_CWORDMOD), ATTR_FONT_WORDLINE, getBooleanCppuType(), 0, 0 },
427 {OUString(SC_UNONAME_CHCOLHDR), SC_WID_UNO_CHCOLHDR,getBooleanCppuType(), 0, 0 },
428 {OUString(SC_UNONAME_CHROWHDR), SC_WID_UNO_CHROWHDR,getBooleanCppuType(), 0, 0 },
429 {OUString(SC_UNONAME_CONDFMT), SC_WID_UNO_CONDFMT, cppu::UnoType<sheet::XSheetConditionalEntries>::get(), 0, 0 },
430 {OUString(SC_UNONAME_CONDLOC), SC_WID_UNO_CONDLOC, cppu::UnoType<sheet::XSheetConditionalEntries>::get(), 0, 0 },
431 {OUString(SC_UNONAME_CONDXML), SC_WID_UNO_CONDXML, cppu::UnoType<sheet::XSheetConditionalEntries>::get(), 0, 0 },
432 {OUString(SC_UNONAME_DIAGONAL_BLTR), ATTR_BORDER_BLTR, ::cppu::UnoType<table::BorderLine>::get(), 0, 0 | CONVERT_TWIPS },
433 {OUString(SC_UNONAME_DIAGONAL_BLTR2), ATTR_BORDER_BLTR, ::cppu::UnoType<table::BorderLine2>::get(), 0, 0 | CONVERT_TWIPS },
434 {OUString(SC_UNONAME_DIAGONAL_TLBR), ATTR_BORDER_TLBR, ::cppu::UnoType<table::BorderLine>::get(), 0, 0 | CONVERT_TWIPS },
435 {OUString(SC_UNONAME_DIAGONAL_TLBR2), ATTR_BORDER_TLBR, ::cppu::UnoType<table::BorderLine2>::get(), 0, 0 | CONVERT_TWIPS },
436 {OUString(SC_UNONAME_FORMLOC), SC_WID_UNO_FORMLOC, cppu::UnoType<OUString>::get(), 0, 0 },
437 {OUString(SC_UNONAME_FORMRT), SC_WID_UNO_FORMRT, cppu::UnoType<table::CellContentType>::get(), 0 | beans::PropertyAttribute::READONLY, 0 },
438 {OUString(SC_UNONAME_CELLHJUS), ATTR_HOR_JUSTIFY, cppu::UnoType<table::CellHoriJustify>::get(), 0, MID_HORJUST_HORJUST },
439 {OUString(SC_UNONAME_CELLHJUS_METHOD), ATTR_HOR_JUSTIFY_METHOD, ::cppu::UnoType<sal_Int32>::get(), 0, 0 },
440 {OUString(SC_UNONAME_CELLTRAN), ATTR_BACKGROUND, getBooleanCppuType(), 0, MID_GRAPHIC_TRANSPARENT },
441 {OUString(SC_UNONAME_WRAP), ATTR_LINEBREAK, getBooleanCppuType(), 0, 0 },
442 {OUString(SC_UNONAME_LEFTBORDER),ATTR_BORDER, ::cppu::UnoType<table::BorderLine>::get(), 0, LEFT_BORDER | CONVERT_TWIPS },
443 {OUString(SC_UNONAME_LEFTBORDER2),ATTR_BORDER, ::cppu::UnoType<table::BorderLine2>::get(), 0, LEFT_BORDER | CONVERT_TWIPS },
444 {OUString(SC_UNONAME_NUMFMT), ATTR_VALUE_FORMAT, cppu::UnoType<sal_Int32>::get(), 0, 0 },
445 {OUString(SC_UNONAME_NUMRULES), SC_WID_UNO_NUMRULES,cppu::UnoType<container::XIndexReplace>::get(), 0, 0 },
446 {OUString(SC_UNONAME_CELLORI), ATTR_STACKED, cppu::UnoType<table::CellOrientation>::get(), 0, 0 },
447 {OUString(SC_UNONAME_PADJUST), ATTR_HOR_JUSTIFY, ::cppu::UnoType<sal_Int16>::get(), 0, MID_HORJUST_ADJUST },
448 {OUString(SC_UNONAME_PBMARGIN), ATTR_MARGIN, cppu::UnoType<sal_Int32>::get(), 0, MID_MARGIN_LO_MARGIN | CONVERT_TWIPS },
449 {OUString(SC_UNONAME_PINDENT), ATTR_INDENT, cppu::UnoType<sal_Int16>::get(), 0, 0 }, //! CONVERT_TWIPS
450 {OUString(SC_UNONAME_PISCHDIST),ATTR_SCRIPTSPACE, getBooleanCppuType(), 0, 0 },
451 {OUString(SC_UNONAME_PISFORBID),ATTR_FORBIDDEN_RULES,getBooleanCppuType(), 0, 0 },
452 {OUString(SC_UNONAME_PISHANG), ATTR_HANGPUNCTUATION,getBooleanCppuType(), 0, 0 },
453 {OUString(SC_UNONAME_PISHYPHEN),ATTR_HYPHENATE, getBooleanCppuType(), 0, 0 },
454 {OUString(SC_UNONAME_PLASTADJ), ATTR_HOR_JUSTIFY, ::cppu::UnoType<sal_Int16>::get(), 0, MID_HORJUST_ADJUST },
455 {OUString(SC_UNONAME_PLMARGIN), ATTR_MARGIN, cppu::UnoType<sal_Int32>::get(), 0, MID_MARGIN_L_MARGIN | CONVERT_TWIPS },
456 {OUString(SC_UNONAME_PRMARGIN), ATTR_MARGIN, cppu::UnoType<sal_Int32>::get(), 0, MID_MARGIN_R_MARGIN | CONVERT_TWIPS },
457 {OUString(SC_UNONAME_PTMARGIN), ATTR_MARGIN, cppu::UnoType<sal_Int32>::get(), 0, MID_MARGIN_UP_MARGIN | CONVERT_TWIPS },
458 {OUString(SC_UNONAME_POS), SC_WID_UNO_POS, cppu::UnoType<awt::Point>::get(), 0 | beans::PropertyAttribute::READONLY, 0 },
459 {OUString(SC_UNONAME_RIGHTBORDER),ATTR_BORDER, ::cppu::UnoType<table::BorderLine>::get(), 0, RIGHT_BORDER | CONVERT_TWIPS },
460 {OUString(SC_UNONAME_RIGHTBORDER2),ATTR_BORDER, ::cppu::UnoType<table::BorderLine2>::get(), 0, RIGHT_BORDER | CONVERT_TWIPS },
461 {OUString(SC_UNONAME_ROTANG), ATTR_ROTATE_VALUE, cppu::UnoType<sal_Int32>::get(), 0, 0 },
462 {OUString(SC_UNONAME_ROTREF), ATTR_ROTATE_MODE, cppu::UnoType<sal_Int32>::get(), 0, 0 },
463 {OUString(SC_UNONAME_SHADOW), ATTR_SHADOW, cppu::UnoType<table::ShadowFormat>::get(), 0, 0 | CONVERT_TWIPS },
464 {OUString(SC_UNONAME_SHRINK_TO_FIT), ATTR_SHRINKTOFIT, getBooleanCppuType(), 0, 0 },
465 {OUString(SC_UNONAME_SIZE), SC_WID_UNO_SIZE, cppu::UnoType<awt::Size>::get(), 0 | beans::PropertyAttribute::READONLY, 0 },
466 {OUString(SC_UNONAME_TBLBORD), SC_WID_UNO_TBLBORD, cppu::UnoType<table::TableBorder>::get(), 0, 0 | CONVERT_TWIPS },
467 {OUString(SC_UNONAME_TBLBORD2), SC_WID_UNO_TBLBORD2, cppu::UnoType<table::TableBorder2>::get(), 0, 0 | CONVERT_TWIPS },
468 {OUString(SC_UNONAME_TOPBORDER),ATTR_BORDER, ::cppu::UnoType<table::BorderLine>::get(), 0, TOP_BORDER | CONVERT_TWIPS },
469 {OUString(SC_UNONAME_TOPBORDER2),ATTR_BORDER, ::cppu::UnoType<table::BorderLine2>::get(), 0, TOP_BORDER | CONVERT_TWIPS },
470 {OUString(SC_UNONAME_USERDEF), ATTR_USERDEF, cppu::UnoType<container::XNameContainer>::get(), 0, 0 },
471 {OUString(SC_UNONAME_VALIDAT), SC_WID_UNO_VALIDAT, cppu::UnoType<beans::XPropertySet>::get(), 0, 0 },
472 {OUString(SC_UNONAME_VALILOC), SC_WID_UNO_VALILOC, cppu::UnoType<beans::XPropertySet>::get(), 0, 0 },
473 {OUString(SC_UNONAME_VALIXML), SC_WID_UNO_VALIXML, cppu::UnoType<beans::XPropertySet>::get(), 0, 0 },
474 {OUString(SC_UNONAME_CELLVJUS), ATTR_VER_JUSTIFY, cppu::UnoType<sal_Int32>::get(), 0, 0 },
475 {OUString(SC_UNONAME_CELLVJUS_METHOD), ATTR_VER_JUSTIFY_METHOD, ::cppu::UnoType<sal_Int32>::get(), 0, 0 },
476 {OUString(SC_UNONAME_WRITING), ATTR_WRITINGDIR, cppu::UnoType<sal_Int16>::get(), 0, 0 },
477 {OUString(UNO_NAME_EDIT_CHAR_ESCAPEMENT), EE_CHAR_ESCAPEMENT, cppu::UnoType<sal_Int32>::get(), 0, 0 },
478 {OUString(SC_UNONAME_HYPERLINK), ATTR_HYPERLINK, cppu::UnoType<OUString>::get(), 0, 0 },
479 { OUString(), 0, css::uno::Type(), 0, 0 }
481 static SfxItemPropertySet aCellPropertySet( aCellPropertyMap_Impl );
482 return &aCellPropertySet;
485 // Column und Row enthalten alle Eintraege von CellRange, zusaetzlich eigene Eintraege
486 // mit Which-ID 0 (werden nur fuer getPropertySetInfo benoetigt).
488 static const SfxItemPropertySet* lcl_GetColumnPropertySet()
490 static const SfxItemPropertyMapEntry aColumnPropertyMap_Impl[] =
492 {OUString(SC_UNONAME_ABSNAME), SC_WID_UNO_ABSNAME, cppu::UnoType<OUString>::get(), 0 | beans::PropertyAttribute::READONLY, 0 },
493 {OUString(SC_UNONAME_ASIANVERT),ATTR_VERTICAL_ASIAN,getBooleanCppuType(), 0, 0 },
494 {OUString(SC_UNONAME_BOTTBORDER),ATTR_BORDER, ::cppu::UnoType<table::BorderLine>::get(), 0, BOTTOM_BORDER | CONVERT_TWIPS },
495 {OUString(SC_UNONAME_BOTTBORDER2),ATTR_BORDER, ::cppu::UnoType<table::BorderLine2>::get(), 0, BOTTOM_BORDER | CONVERT_TWIPS },
496 {OUString(SC_UNONAME_CELLBACK), ATTR_BACKGROUND, cppu::UnoType<sal_Int32>::get(), 0, MID_BACK_COLOR },
497 {OUString(SC_UNONAME_CELLPRO), ATTR_PROTECTION, cppu::UnoType<util::CellProtection>::get(), 0, 0 },
498 {OUString(SC_UNONAME_CELLSTYL), SC_WID_UNO_CELLSTYL,cppu::UnoType<OUString>::get(), 0, 0 },
499 {OUString(SC_UNONAME_CCOLOR), ATTR_FONT_COLOR, cppu::UnoType<sal_Int32>::get(), 0, 0 },
500 {OUString(SC_UNONAME_COUTL), ATTR_FONT_CONTOUR, getBooleanCppuType(), 0, 0 },
501 {OUString(SC_UNONAME_CCROSS), ATTR_FONT_CROSSEDOUT,getBooleanCppuType(), 0, MID_CROSSED_OUT },
502 {OUString(SC_UNONAME_CEMPHAS), ATTR_FONT_EMPHASISMARK,cppu::UnoType<sal_Int16>::get(), 0, MID_EMPHASIS },
503 {OUString(SC_UNONAME_CFONT), ATTR_FONT, cppu::UnoType<sal_Int16>::get(), 0, MID_FONT_FAMILY },
504 {OUString(SC_UNONAME_CFCHARS), ATTR_FONT, cppu::UnoType<sal_Int16>::get(), 0, MID_FONT_CHAR_SET },
505 {OUString(SC_UNO_CJK_CFCHARS), ATTR_CJK_FONT, cppu::UnoType<sal_Int16>::get(), 0, MID_FONT_CHAR_SET },
506 {OUString(SC_UNO_CTL_CFCHARS), ATTR_CTL_FONT, cppu::UnoType<sal_Int16>::get(), 0, MID_FONT_CHAR_SET },
507 {OUString(SC_UNONAME_CFFAMIL), ATTR_FONT, cppu::UnoType<sal_Int16>::get(), 0, MID_FONT_FAMILY },
508 {OUString(SC_UNO_CJK_CFFAMIL), ATTR_CJK_FONT, cppu::UnoType<sal_Int16>::get(), 0, MID_FONT_FAMILY },
509 {OUString(SC_UNO_CTL_CFFAMIL), ATTR_CTL_FONT, cppu::UnoType<sal_Int16>::get(), 0, MID_FONT_FAMILY },
510 {OUString(SC_UNONAME_CFNAME), ATTR_FONT, cppu::UnoType<OUString>::get(), 0, MID_FONT_FAMILY_NAME },
511 {OUString(SC_UNO_CJK_CFNAME), ATTR_CJK_FONT, cppu::UnoType<OUString>::get(), 0, MID_FONT_FAMILY_NAME },
512 {OUString(SC_UNO_CTL_CFNAME), ATTR_CTL_FONT, cppu::UnoType<OUString>::get(), 0, MID_FONT_FAMILY_NAME },
513 {OUString(SC_UNONAME_CFPITCH), ATTR_FONT, cppu::UnoType<sal_Int16>::get(), 0, MID_FONT_PITCH },
514 {OUString(SC_UNO_CJK_CFPITCH), ATTR_CJK_FONT, cppu::UnoType<sal_Int16>::get(), 0, MID_FONT_PITCH },
515 {OUString(SC_UNO_CTL_CFPITCH), ATTR_CTL_FONT, cppu::UnoType<sal_Int16>::get(), 0, MID_FONT_PITCH },
516 {OUString(SC_UNONAME_CFSTYLE), ATTR_FONT, cppu::UnoType<OUString>::get(), 0, MID_FONT_STYLE_NAME },
517 {OUString(SC_UNO_CJK_CFSTYLE), ATTR_CJK_FONT, cppu::UnoType<OUString>::get(), 0, MID_FONT_STYLE_NAME },
518 {OUString(SC_UNO_CTL_CFSTYLE), ATTR_CTL_FONT, cppu::UnoType<OUString>::get(), 0, MID_FONT_STYLE_NAME },
519 {OUString(SC_UNONAME_CHEIGHT), ATTR_FONT_HEIGHT, cppu::UnoType<float>::get(), 0, MID_FONTHEIGHT | CONVERT_TWIPS },
520 {OUString(SC_UNO_CJK_CHEIGHT), ATTR_CJK_FONT_HEIGHT,cppu::UnoType<float>::get(), 0, MID_FONTHEIGHT | CONVERT_TWIPS },
521 {OUString(SC_UNO_CTL_CHEIGHT), ATTR_CTL_FONT_HEIGHT,cppu::UnoType<float>::get(), 0, MID_FONTHEIGHT | CONVERT_TWIPS },
522 {OUString(SC_UNONAME_CLOCAL), ATTR_FONT_LANGUAGE, cppu::UnoType<lang::Locale>::get(), 0, MID_LANG_LOCALE },
523 {OUString(SC_UNO_CJK_CLOCAL), ATTR_CJK_FONT_LANGUAGE,cppu::UnoType<lang::Locale>::get(), 0, MID_LANG_LOCALE },
524 {OUString(SC_UNO_CTL_CLOCAL), ATTR_CTL_FONT_LANGUAGE,cppu::UnoType<lang::Locale>::get(), 0, MID_LANG_LOCALE },
525 {OUString(SC_UNONAME_COVER), ATTR_FONT_OVERLINE, cppu::UnoType<sal_Int16>::get(), 0, MID_TL_STYLE },
526 {OUString(SC_UNONAME_COVRLCOL), ATTR_FONT_OVERLINE, cppu::UnoType<sal_Int32>::get(), 0, MID_TL_COLOR },
527 {OUString(SC_UNONAME_COVRLHAS), ATTR_FONT_OVERLINE, getBooleanCppuType(), 0, MID_TL_HASCOLOR },
528 {OUString(SC_UNONAME_CPOST), ATTR_FONT_POSTURE, cppu::UnoType<awt::FontSlant>::get(), 0, MID_POSTURE },
529 {OUString(SC_UNO_CJK_CPOST), ATTR_CJK_FONT_POSTURE,cppu::UnoType<awt::FontSlant>::get(), 0, MID_POSTURE },
530 {OUString(SC_UNO_CTL_CPOST), ATTR_CTL_FONT_POSTURE,cppu::UnoType<awt::FontSlant>::get(), 0, MID_POSTURE },
531 {OUString(SC_UNONAME_CRELIEF), ATTR_FONT_RELIEF, cppu::UnoType<sal_Int16>::get(), 0, MID_RELIEF },
532 {OUString(SC_UNONAME_CSHADD), ATTR_FONT_SHADOWED, getBooleanCppuType(), 0, 0 },
533 {OUString(SC_UNONAME_CSTRIKE), ATTR_FONT_CROSSEDOUT,cppu::UnoType<sal_Int16>::get(), 0, MID_CROSS_OUT },
534 {OUString(SC_UNONAME_CUNDER), ATTR_FONT_UNDERLINE,cppu::UnoType<sal_Int16>::get(), 0, MID_TL_STYLE },
535 {OUString(SC_UNONAME_CUNDLCOL), ATTR_FONT_UNDERLINE,cppu::UnoType<sal_Int32>::get(), 0, MID_TL_COLOR },
536 {OUString(SC_UNONAME_CUNDLHAS), ATTR_FONT_UNDERLINE,getBooleanCppuType(), 0, MID_TL_HASCOLOR },
537 {OUString(SC_UNONAME_CWEIGHT), ATTR_FONT_WEIGHT, cppu::UnoType<float>::get(), 0, MID_WEIGHT },
538 {OUString(SC_UNO_CJK_CWEIGHT), ATTR_CJK_FONT_WEIGHT,cppu::UnoType<float>::get(), 0, MID_WEIGHT },
539 {OUString(SC_UNO_CTL_CWEIGHT), ATTR_CTL_FONT_WEIGHT,cppu::UnoType<float>::get(), 0, MID_WEIGHT },
540 {OUString(SC_UNONAME_CWORDMOD), ATTR_FONT_WORDLINE, getBooleanCppuType(), 0, 0 },
541 {OUString(SC_UNONAME_CHCOLHDR), SC_WID_UNO_CHCOLHDR,getBooleanCppuType(), 0, 0 },
542 {OUString(SC_UNONAME_CHROWHDR), SC_WID_UNO_CHROWHDR,getBooleanCppuType(), 0, 0 },
543 {OUString(SC_UNONAME_CONDFMT), SC_WID_UNO_CONDFMT, cppu::UnoType<sheet::XSheetConditionalEntries>::get(), 0, 0 },
544 {OUString(SC_UNONAME_CONDLOC), SC_WID_UNO_CONDLOC, cppu::UnoType<sheet::XSheetConditionalEntries>::get(), 0, 0 },
545 {OUString(SC_UNONAME_CONDXML), SC_WID_UNO_CONDXML, cppu::UnoType<sheet::XSheetConditionalEntries>::get(), 0, 0 },
546 {OUString(SC_UNONAME_DIAGONAL_BLTR), ATTR_BORDER_BLTR, ::cppu::UnoType<table::BorderLine>::get(), 0, 0 | CONVERT_TWIPS },
547 {OUString(SC_UNONAME_DIAGONAL_BLTR2), ATTR_BORDER_BLTR, ::cppu::UnoType<table::BorderLine2>::get(), 0, 0 | CONVERT_TWIPS },
548 {OUString(SC_UNONAME_DIAGONAL_TLBR), ATTR_BORDER_TLBR, ::cppu::UnoType<table::BorderLine>::get(), 0, 0 | CONVERT_TWIPS },
549 {OUString(SC_UNONAME_DIAGONAL_TLBR2), ATTR_BORDER_TLBR, ::cppu::UnoType<table::BorderLine2>::get(), 0, 0 | CONVERT_TWIPS },
550 {OUString(SC_UNONAME_CELLHJUS), ATTR_HOR_JUSTIFY, cppu::UnoType<table::CellHoriJustify>::get(), 0, MID_HORJUST_HORJUST },
551 {OUString(SC_UNONAME_CELLHJUS_METHOD), ATTR_HOR_JUSTIFY_METHOD, ::cppu::UnoType<sal_Int32>::get(), 0, 0 },
552 {OUString(SC_UNONAME_CELLTRAN), ATTR_BACKGROUND, getBooleanCppuType(), 0, MID_GRAPHIC_TRANSPARENT },
553 {OUString(SC_UNONAME_MANPAGE), SC_WID_UNO_MANPAGE, getBooleanCppuType(), 0, 0 },
554 {OUString(SC_UNONAME_NEWPAGE), SC_WID_UNO_NEWPAGE, getBooleanCppuType(), 0, 0 },
555 {OUString(SC_UNONAME_WRAP), ATTR_LINEBREAK, getBooleanCppuType(), 0, 0 },
556 {OUString(SC_UNONAME_CELLVIS), SC_WID_UNO_CELLVIS, getBooleanCppuType(), 0, 0 },
557 {OUString(SC_UNONAME_LEFTBORDER),ATTR_BORDER, ::cppu::UnoType<table::BorderLine>::get(), 0, LEFT_BORDER | CONVERT_TWIPS },
558 {OUString(SC_UNONAME_LEFTBORDER2),ATTR_BORDER, ::cppu::UnoType<table::BorderLine2>::get(), 0, LEFT_BORDER | CONVERT_TWIPS },
559 {OUString(SC_UNONAME_NUMFMT), ATTR_VALUE_FORMAT, cppu::UnoType<sal_Int32>::get(), 0, 0 },
560 {OUString(SC_UNONAME_NUMRULES), SC_WID_UNO_NUMRULES,cppu::UnoType<container::XIndexReplace>::get(), 0, 0 },
561 {OUString(SC_UNONAME_OWIDTH), SC_WID_UNO_OWIDTH, getBooleanCppuType(), 0, 0 },
562 {OUString(SC_UNONAME_CELLORI), ATTR_STACKED, cppu::UnoType<table::CellOrientation>::get(), 0, 0 },
563 {OUString(SC_UNONAME_PADJUST), ATTR_HOR_JUSTIFY, ::cppu::UnoType<sal_Int16>::get(), 0, MID_HORJUST_ADJUST },
564 {OUString(SC_UNONAME_PBMARGIN), ATTR_MARGIN, cppu::UnoType<sal_Int32>::get(), 0, MID_MARGIN_LO_MARGIN | CONVERT_TWIPS },
565 {OUString(SC_UNONAME_PINDENT), ATTR_INDENT, cppu::UnoType<sal_Int16>::get(), 0, 0 }, //! CONVERT_TWIPS
566 {OUString(SC_UNONAME_PISCHDIST),ATTR_SCRIPTSPACE, getBooleanCppuType(), 0, 0 },
567 {OUString(SC_UNONAME_PISFORBID),ATTR_FORBIDDEN_RULES,getBooleanCppuType(), 0, 0 },
568 {OUString(SC_UNONAME_PISHANG), ATTR_HANGPUNCTUATION,getBooleanCppuType(), 0, 0 },
569 {OUString(SC_UNONAME_PISHYPHEN),ATTR_HYPHENATE, getBooleanCppuType(), 0, 0 },
570 {OUString(SC_UNONAME_PLASTADJ), ATTR_HOR_JUSTIFY, ::cppu::UnoType<sal_Int16>::get(), 0, MID_HORJUST_ADJUST },
571 {OUString(SC_UNONAME_PLMARGIN), ATTR_MARGIN, cppu::UnoType<sal_Int32>::get(), 0, MID_MARGIN_L_MARGIN | CONVERT_TWIPS },
572 {OUString(SC_UNONAME_PRMARGIN), ATTR_MARGIN, cppu::UnoType<sal_Int32>::get(), 0, MID_MARGIN_R_MARGIN | CONVERT_TWIPS },
573 {OUString(SC_UNONAME_PTMARGIN), ATTR_MARGIN, cppu::UnoType<sal_Int32>::get(), 0, MID_MARGIN_UP_MARGIN | CONVERT_TWIPS },
574 {OUString(SC_UNONAME_POS), SC_WID_UNO_POS, cppu::UnoType<awt::Point>::get(), 0 | beans::PropertyAttribute::READONLY, 0 },
575 {OUString(SC_UNONAME_RIGHTBORDER),ATTR_BORDER, ::cppu::UnoType<table::BorderLine>::get(), 0, RIGHT_BORDER | CONVERT_TWIPS },
576 {OUString(SC_UNONAME_RIGHTBORDER2),ATTR_BORDER, ::cppu::UnoType<table::BorderLine2>::get(), 0, RIGHT_BORDER | CONVERT_TWIPS },
577 {OUString(SC_UNONAME_ROTANG), ATTR_ROTATE_VALUE, cppu::UnoType<sal_Int32>::get(), 0, 0 },
578 {OUString(SC_UNONAME_ROTREF), ATTR_ROTATE_MODE, cppu::UnoType<sal_Int32>::get(), 0, 0 },
579 {OUString(SC_UNONAME_SHADOW), ATTR_SHADOW, cppu::UnoType<table::ShadowFormat>::get(), 0, 0 | CONVERT_TWIPS },
580 {OUString(SC_UNONAME_SHRINK_TO_FIT), ATTR_SHRINKTOFIT, getBooleanCppuType(), 0, 0 },
581 {OUString(SC_UNONAME_SIZE), SC_WID_UNO_SIZE, cppu::UnoType<awt::Size>::get(), 0 | beans::PropertyAttribute::READONLY, 0 },
582 {OUString(SC_UNONAME_TBLBORD), SC_WID_UNO_TBLBORD, cppu::UnoType<table::TableBorder>::get(), 0, 0 | CONVERT_TWIPS },
583 {OUString(SC_UNONAME_TBLBORD2), SC_WID_UNO_TBLBORD2, cppu::UnoType<table::TableBorder2>::get(), 0, 0 | CONVERT_TWIPS },
584 {OUString(SC_UNONAME_TOPBORDER),ATTR_BORDER, ::cppu::UnoType<table::BorderLine>::get(), 0, TOP_BORDER | CONVERT_TWIPS },
585 {OUString(SC_UNONAME_TOPBORDER2),ATTR_BORDER, ::cppu::UnoType<table::BorderLine2>::get(), 0, TOP_BORDER | CONVERT_TWIPS },
586 {OUString(SC_UNONAME_USERDEF), ATTR_USERDEF, cppu::UnoType<container::XNameContainer>::get(), 0, 0 },
587 {OUString(SC_UNONAME_VALIDAT), SC_WID_UNO_VALIDAT, cppu::UnoType<beans::XPropertySet>::get(), 0, 0 },
588 {OUString(SC_UNONAME_VALILOC), SC_WID_UNO_VALILOC, cppu::UnoType<beans::XPropertySet>::get(), 0, 0 },
589 {OUString(SC_UNONAME_VALIXML), SC_WID_UNO_VALIXML, cppu::UnoType<beans::XPropertySet>::get(), 0, 0 },
590 {OUString(SC_UNONAME_CELLVJUS), ATTR_VER_JUSTIFY, cppu::UnoType<sal_Int32>::get(), 0, 0 },
591 {OUString(SC_UNONAME_CELLVJUS_METHOD), ATTR_VER_JUSTIFY_METHOD, ::cppu::UnoType<sal_Int32>::get(), 0, 0 },
592 {OUString(SC_UNONAME_CELLWID), SC_WID_UNO_CELLWID, cppu::UnoType<sal_Int32>::get(), 0, 0 },
593 {OUString(SC_UNONAME_WRITING), ATTR_WRITINGDIR, cppu::UnoType<sal_Int16>::get(), 0, 0 },
594 { OUString(), 0, css::uno::Type(), 0, 0 }
596 static SfxItemPropertySet aColumnPropertySet( aColumnPropertyMap_Impl );
597 return &aColumnPropertySet;
600 static const SfxItemPropertySet* lcl_GetRowPropertySet()
602 static const SfxItemPropertyMapEntry aRowPropertyMap_Impl[] =
604 {OUString(SC_UNONAME_ABSNAME), SC_WID_UNO_ABSNAME, cppu::UnoType<OUString>::get(), 0 | beans::PropertyAttribute::READONLY, 0 },
605 {OUString(SC_UNONAME_ASIANVERT),ATTR_VERTICAL_ASIAN,getBooleanCppuType(), 0, 0 },
606 {OUString(SC_UNONAME_BOTTBORDER),ATTR_BORDER, ::cppu::UnoType<table::BorderLine>::get(), 0, BOTTOM_BORDER | CONVERT_TWIPS },
607 {OUString(SC_UNONAME_BOTTBORDER2),ATTR_BORDER, ::cppu::UnoType<table::BorderLine2>::get(), 0, BOTTOM_BORDER | CONVERT_TWIPS },
608 {OUString(SC_UNONAME_CELLBACK), ATTR_BACKGROUND, cppu::UnoType<sal_Int32>::get(), 0, MID_BACK_COLOR },
609 {OUString(SC_UNONAME_CELLPRO), ATTR_PROTECTION, cppu::UnoType<util::CellProtection>::get(), 0, 0 },
610 {OUString(SC_UNONAME_CELLSTYL), SC_WID_UNO_CELLSTYL,cppu::UnoType<OUString>::get(), 0, 0 },
611 {OUString(SC_UNONAME_CCOLOR), ATTR_FONT_COLOR, cppu::UnoType<sal_Int32>::get(), 0, 0 },
612 {OUString(SC_UNONAME_COUTL), ATTR_FONT_CONTOUR, getBooleanCppuType(), 0, 0 },
613 {OUString(SC_UNONAME_CCROSS), ATTR_FONT_CROSSEDOUT,getBooleanCppuType(), 0, MID_CROSSED_OUT },
614 {OUString(SC_UNONAME_CEMPHAS), ATTR_FONT_EMPHASISMARK,cppu::UnoType<sal_Int16>::get(), 0, MID_EMPHASIS },
615 {OUString(SC_UNONAME_CFONT), ATTR_FONT, cppu::UnoType<sal_Int16>::get(), 0, MID_FONT_FAMILY },
616 {OUString(SC_UNONAME_CFCHARS), ATTR_FONT, cppu::UnoType<sal_Int16>::get(), 0, MID_FONT_CHAR_SET },
617 {OUString(SC_UNO_CJK_CFCHARS), ATTR_CJK_FONT, cppu::UnoType<sal_Int16>::get(), 0, MID_FONT_CHAR_SET },
618 {OUString(SC_UNO_CTL_CFCHARS), ATTR_CTL_FONT, cppu::UnoType<sal_Int16>::get(), 0, MID_FONT_CHAR_SET },
619 {OUString(SC_UNONAME_CFFAMIL), ATTR_FONT, cppu::UnoType<sal_Int16>::get(), 0, MID_FONT_FAMILY },
620 {OUString(SC_UNO_CJK_CFFAMIL), ATTR_CJK_FONT, cppu::UnoType<sal_Int16>::get(), 0, MID_FONT_FAMILY },
621 {OUString(SC_UNO_CTL_CFFAMIL), ATTR_CTL_FONT, cppu::UnoType<sal_Int16>::get(), 0, MID_FONT_FAMILY },
622 {OUString(SC_UNONAME_CFNAME), ATTR_FONT, cppu::UnoType<OUString>::get(), 0, MID_FONT_FAMILY_NAME },
623 {OUString(SC_UNO_CJK_CFNAME), ATTR_CJK_FONT, cppu::UnoType<OUString>::get(), 0, MID_FONT_FAMILY_NAME },
624 {OUString(SC_UNO_CTL_CFNAME), ATTR_CTL_FONT, cppu::UnoType<OUString>::get(), 0, MID_FONT_FAMILY_NAME },
625 {OUString(SC_UNONAME_CFPITCH), ATTR_FONT, cppu::UnoType<sal_Int16>::get(), 0, MID_FONT_PITCH },
626 {OUString(SC_UNO_CJK_CFPITCH), ATTR_CJK_FONT, cppu::UnoType<sal_Int16>::get(), 0, MID_FONT_PITCH },
627 {OUString(SC_UNO_CTL_CFPITCH), ATTR_CTL_FONT, cppu::UnoType<sal_Int16>::get(), 0, MID_FONT_PITCH },
628 {OUString(SC_UNONAME_CFSTYLE), ATTR_FONT, cppu::UnoType<OUString>::get(), 0, MID_FONT_STYLE_NAME },
629 {OUString(SC_UNO_CJK_CFSTYLE), ATTR_CJK_FONT, cppu::UnoType<OUString>::get(), 0, MID_FONT_STYLE_NAME },
630 {OUString(SC_UNO_CTL_CFSTYLE), ATTR_CTL_FONT, cppu::UnoType<OUString>::get(), 0, MID_FONT_STYLE_NAME },
631 {OUString(SC_UNONAME_CHEIGHT), ATTR_FONT_HEIGHT, cppu::UnoType<float>::get(), 0, MID_FONTHEIGHT | CONVERT_TWIPS },
632 {OUString(SC_UNO_CJK_CHEIGHT), ATTR_CJK_FONT_HEIGHT,cppu::UnoType<float>::get(), 0, MID_FONTHEIGHT | CONVERT_TWIPS },
633 {OUString(SC_UNO_CTL_CHEIGHT), ATTR_CTL_FONT_HEIGHT,cppu::UnoType<float>::get(), 0, MID_FONTHEIGHT | CONVERT_TWIPS },
634 {OUString(SC_UNONAME_CLOCAL), ATTR_FONT_LANGUAGE, cppu::UnoType<lang::Locale>::get(), 0, MID_LANG_LOCALE },
635 {OUString(SC_UNO_CJK_CLOCAL), ATTR_CJK_FONT_LANGUAGE,cppu::UnoType<lang::Locale>::get(), 0, MID_LANG_LOCALE },
636 {OUString(SC_UNO_CTL_CLOCAL), ATTR_CTL_FONT_LANGUAGE,cppu::UnoType<lang::Locale>::get(), 0, MID_LANG_LOCALE },
637 {OUString(SC_UNONAME_COVER), ATTR_FONT_OVERLINE, cppu::UnoType<sal_Int16>::get(), 0, MID_TL_STYLE },
638 {OUString(SC_UNONAME_COVRLCOL), ATTR_FONT_OVERLINE, cppu::UnoType<sal_Int32>::get(), 0, MID_TL_COLOR },
639 {OUString(SC_UNONAME_COVRLHAS), ATTR_FONT_OVERLINE, getBooleanCppuType(), 0, MID_TL_HASCOLOR },
640 {OUString(SC_UNONAME_CPOST), ATTR_FONT_POSTURE, cppu::UnoType<awt::FontSlant>::get(), 0, MID_POSTURE },
641 {OUString(SC_UNO_CJK_CPOST), ATTR_CJK_FONT_POSTURE,cppu::UnoType<awt::FontSlant>::get(), 0, MID_POSTURE },
642 {OUString(SC_UNO_CTL_CPOST), ATTR_CTL_FONT_POSTURE,cppu::UnoType<awt::FontSlant>::get(), 0, MID_POSTURE },
643 {OUString(SC_UNONAME_CRELIEF), ATTR_FONT_RELIEF, cppu::UnoType<sal_Int16>::get(), 0, MID_RELIEF },
644 {OUString(SC_UNONAME_CSHADD), ATTR_FONT_SHADOWED, getBooleanCppuType(), 0, 0 },
645 {OUString(SC_UNONAME_CSTRIKE), ATTR_FONT_CROSSEDOUT,cppu::UnoType<sal_Int16>::get(), 0, MID_CROSS_OUT },
646 {OUString(SC_UNONAME_CUNDER), ATTR_FONT_UNDERLINE,cppu::UnoType<sal_Int16>::get(), 0, MID_TL_STYLE },
647 {OUString(SC_UNONAME_CUNDLCOL), ATTR_FONT_UNDERLINE,cppu::UnoType<sal_Int32>::get(), 0, MID_TL_COLOR },
648 {OUString(SC_UNONAME_CUNDLHAS), ATTR_FONT_UNDERLINE,getBooleanCppuType(), 0, MID_TL_HASCOLOR },
649 {OUString(SC_UNONAME_CWEIGHT), ATTR_FONT_WEIGHT, cppu::UnoType<float>::get(), 0, MID_WEIGHT },
650 {OUString(SC_UNO_CJK_CWEIGHT), ATTR_CJK_FONT_WEIGHT,cppu::UnoType<float>::get(), 0, MID_WEIGHT },
651 {OUString(SC_UNO_CTL_CWEIGHT), ATTR_CTL_FONT_WEIGHT,cppu::UnoType<float>::get(), 0, MID_WEIGHT },
652 {OUString(SC_UNONAME_CWORDMOD), ATTR_FONT_WORDLINE, getBooleanCppuType(), 0, 0 },
653 {OUString(SC_UNONAME_CHCOLHDR), SC_WID_UNO_CHCOLHDR,getBooleanCppuType(), 0, 0 },
654 {OUString(SC_UNONAME_CHROWHDR), SC_WID_UNO_CHROWHDR,getBooleanCppuType(), 0, 0 },
655 {OUString(SC_UNONAME_CONDFMT), SC_WID_UNO_CONDFMT, cppu::UnoType<sheet::XSheetConditionalEntries>::get(), 0, 0 },
656 {OUString(SC_UNONAME_CONDLOC), SC_WID_UNO_CONDLOC, cppu::UnoType<sheet::XSheetConditionalEntries>::get(), 0, 0 },
657 {OUString(SC_UNONAME_CONDXML), SC_WID_UNO_CONDXML, cppu::UnoType<sheet::XSheetConditionalEntries>::get(), 0, 0 },
658 {OUString(SC_UNONAME_DIAGONAL_BLTR), ATTR_BORDER_BLTR, ::cppu::UnoType<table::BorderLine>::get(), 0, 0 | CONVERT_TWIPS },
659 {OUString(SC_UNONAME_DIAGONAL_BLTR2), ATTR_BORDER_BLTR, ::cppu::UnoType<table::BorderLine2>::get(), 0, 0 | CONVERT_TWIPS },
660 {OUString(SC_UNONAME_DIAGONAL_TLBR), ATTR_BORDER_TLBR, ::cppu::UnoType<table::BorderLine>::get(), 0, 0 | CONVERT_TWIPS },
661 {OUString(SC_UNONAME_DIAGONAL_TLBR2), ATTR_BORDER_TLBR, ::cppu::UnoType<table::BorderLine2>::get(), 0, 0 | CONVERT_TWIPS },
662 {OUString(SC_UNONAME_CELLHGT), SC_WID_UNO_CELLHGT, cppu::UnoType<sal_Int32>::get(), 0, 0 },
663 {OUString(SC_UNONAME_CELLHJUS), ATTR_HOR_JUSTIFY, cppu::UnoType<table::CellHoriJustify>::get(), 0, MID_HORJUST_HORJUST },
664 {OUString(SC_UNONAME_CELLHJUS_METHOD), ATTR_HOR_JUSTIFY_METHOD, ::cppu::UnoType<sal_Int32>::get(), 0, 0 },
665 {OUString(SC_UNONAME_CELLTRAN), ATTR_BACKGROUND, getBooleanCppuType(), 0, MID_GRAPHIC_TRANSPARENT },
666 {OUString(SC_UNONAME_CELLFILT), SC_WID_UNO_CELLFILT,getBooleanCppuType(), 0, 0 },
667 {OUString(SC_UNONAME_MANPAGE), SC_WID_UNO_MANPAGE, getBooleanCppuType(), 0, 0 },
668 {OUString(SC_UNONAME_NEWPAGE), SC_WID_UNO_NEWPAGE, getBooleanCppuType(), 0, 0 },
669 {OUString(SC_UNONAME_WRAP), ATTR_LINEBREAK, getBooleanCppuType(), 0, 0 },
670 {OUString(SC_UNONAME_CELLVIS), SC_WID_UNO_CELLVIS, getBooleanCppuType(), 0, 0 },
671 {OUString(SC_UNONAME_LEFTBORDER),ATTR_BORDER, ::cppu::UnoType<table::BorderLine>::get(), 0, LEFT_BORDER | CONVERT_TWIPS },
672 {OUString(SC_UNONAME_LEFTBORDER2),ATTR_BORDER, ::cppu::UnoType<table::BorderLine2>::get(), 0, LEFT_BORDER | CONVERT_TWIPS },
673 {OUString(SC_UNONAME_NUMFMT), ATTR_VALUE_FORMAT, cppu::UnoType<sal_Int32>::get(), 0, 0 },
674 {OUString(SC_UNONAME_NUMRULES), SC_WID_UNO_NUMRULES,cppu::UnoType<container::XIndexReplace>::get(), 0, 0 },
675 {OUString(SC_UNONAME_OHEIGHT), SC_WID_UNO_OHEIGHT, getBooleanCppuType(), 0, 0 },
676 {OUString(SC_UNONAME_CELLORI), ATTR_STACKED, cppu::UnoType<table::CellOrientation>::get(), 0, 0 },
677 {OUString(SC_UNONAME_PADJUST), ATTR_HOR_JUSTIFY, ::cppu::UnoType<sal_Int16>::get(), 0, MID_HORJUST_ADJUST },
678 {OUString(SC_UNONAME_PBMARGIN), ATTR_MARGIN, cppu::UnoType<sal_Int32>::get(), 0, MID_MARGIN_LO_MARGIN | CONVERT_TWIPS },
679 {OUString(SC_UNONAME_PINDENT), ATTR_INDENT, cppu::UnoType<sal_Int16>::get(), 0, 0 }, //! CONVERT_TWIPS
680 {OUString(SC_UNONAME_PISCHDIST),ATTR_SCRIPTSPACE, getBooleanCppuType(), 0, 0 },
681 {OUString(SC_UNONAME_PISFORBID),ATTR_FORBIDDEN_RULES,getBooleanCppuType(), 0, 0 },
682 {OUString(SC_UNONAME_PISHANG), ATTR_HANGPUNCTUATION,getBooleanCppuType(), 0, 0 },
683 {OUString(SC_UNONAME_PISHYPHEN),ATTR_HYPHENATE, getBooleanCppuType(), 0, 0 },
684 {OUString(SC_UNONAME_PLASTADJ), ATTR_HOR_JUSTIFY, ::cppu::UnoType<sal_Int16>::get(), 0, MID_HORJUST_ADJUST },
685 {OUString(SC_UNONAME_PLMARGIN), ATTR_MARGIN, cppu::UnoType<sal_Int32>::get(), 0, MID_MARGIN_L_MARGIN | CONVERT_TWIPS },
686 {OUString(SC_UNONAME_PRMARGIN), ATTR_MARGIN, cppu::UnoType<sal_Int32>::get(), 0, MID_MARGIN_R_MARGIN | CONVERT_TWIPS },
687 {OUString(SC_UNONAME_PTMARGIN), ATTR_MARGIN, cppu::UnoType<sal_Int32>::get(), 0, MID_MARGIN_UP_MARGIN | CONVERT_TWIPS },
688 {OUString(SC_UNONAME_POS), SC_WID_UNO_POS, cppu::UnoType<awt::Point>::get(), 0 | beans::PropertyAttribute::READONLY, 0 },
689 {OUString(SC_UNONAME_RIGHTBORDER),ATTR_BORDER, ::cppu::UnoType<table::BorderLine>::get(), 0, RIGHT_BORDER | CONVERT_TWIPS },
690 {OUString(SC_UNONAME_RIGHTBORDER2),ATTR_BORDER, ::cppu::UnoType<table::BorderLine2>::get(), 0, RIGHT_BORDER | CONVERT_TWIPS },
691 {OUString(SC_UNONAME_ROTANG), ATTR_ROTATE_VALUE, cppu::UnoType<sal_Int32>::get(), 0, 0 },
692 {OUString(SC_UNONAME_ROTREF), ATTR_ROTATE_MODE, cppu::UnoType<sal_Int32>::get(), 0, 0 },
693 {OUString(SC_UNONAME_SHADOW), ATTR_SHADOW, cppu::UnoType<table::ShadowFormat>::get(), 0, 0 | CONVERT_TWIPS },
694 {OUString(SC_UNONAME_SHRINK_TO_FIT), ATTR_SHRINKTOFIT, getBooleanCppuType(), 0, 0 },
695 {OUString(SC_UNONAME_SIZE), SC_WID_UNO_SIZE, cppu::UnoType<awt::Size>::get(), 0 | beans::PropertyAttribute::READONLY, 0 },
696 {OUString(SC_UNONAME_TBLBORD), SC_WID_UNO_TBLBORD, cppu::UnoType<table::TableBorder>::get(), 0, 0 | CONVERT_TWIPS },
697 {OUString(SC_UNONAME_TBLBORD2), SC_WID_UNO_TBLBORD2, cppu::UnoType<table::TableBorder2>::get(), 0, 0 | CONVERT_TWIPS },
698 {OUString(SC_UNONAME_TOPBORDER),ATTR_BORDER, ::cppu::UnoType<table::BorderLine>::get(), 0, TOP_BORDER | CONVERT_TWIPS },
699 {OUString(SC_UNONAME_TOPBORDER2),ATTR_BORDER, ::cppu::UnoType<table::BorderLine2>::get(), 0, TOP_BORDER | CONVERT_TWIPS },
700 {OUString(SC_UNONAME_USERDEF), ATTR_USERDEF, cppu::UnoType<container::XNameContainer>::get(), 0, 0 },
701 {OUString(SC_UNONAME_VALIDAT), SC_WID_UNO_VALIDAT, cppu::UnoType<beans::XPropertySet>::get(), 0, 0 },
702 {OUString(SC_UNONAME_VALILOC), SC_WID_UNO_VALILOC, cppu::UnoType<beans::XPropertySet>::get(), 0, 0 },
703 {OUString(SC_UNONAME_VALIXML), SC_WID_UNO_VALIXML, cppu::UnoType<beans::XPropertySet>::get(), 0, 0 },
704 {OUString(SC_UNONAME_CELLVJUS), ATTR_VER_JUSTIFY, cppu::UnoType<sal_Int32>::get(), 0, 0 },
705 {OUString(SC_UNONAME_CELLVJUS_METHOD), ATTR_VER_JUSTIFY_METHOD, ::cppu::UnoType<sal_Int32>::get(), 0, 0 },
706 {OUString(SC_UNONAME_WRITING), ATTR_WRITINGDIR, cppu::UnoType<sal_Int16>::get(), 0, 0 },
707 { OUString(), 0, css::uno::Type(), 0, 0 }
709 static SfxItemPropertySet aRowPropertySet( aRowPropertyMap_Impl );
710 return &aRowPropertySet;
713 static const SfxItemPropertySet* lcl_GetSheetPropertySet()
715 static const SfxItemPropertyMapEntry aSheetPropertyMap_Impl[] =
717 {OUString(SC_UNONAME_ABSNAME), SC_WID_UNO_ABSNAME, cppu::UnoType<OUString>::get(), 0 | beans::PropertyAttribute::READONLY, 0 },
718 {OUString(SC_UNONAME_ASIANVERT),ATTR_VERTICAL_ASIAN,getBooleanCppuType(), 0, 0 },
719 {OUString(SC_UNONAME_AUTOPRINT),SC_WID_UNO_AUTOPRINT,getBooleanCppuType(), 0, 0 },
720 {OUString(SC_UNONAME_BORDCOL), SC_WID_UNO_BORDCOL, cppu::UnoType<sal_Int32>::get(), 0, 0 },
721 {OUString(SC_UNONAME_BOTTBORDER),ATTR_BORDER, ::cppu::UnoType<table::BorderLine>::get(), 0, BOTTOM_BORDER | CONVERT_TWIPS },
722 {OUString(SC_UNONAME_BOTTBORDER2),ATTR_BORDER, ::cppu::UnoType<table::BorderLine2>::get(), 0, BOTTOM_BORDER | CONVERT_TWIPS },
723 {OUString(SC_UNONAME_CELLBACK), ATTR_BACKGROUND, cppu::UnoType<sal_Int32>::get(), 0, MID_BACK_COLOR },
724 {OUString(SC_UNONAME_CELLPRO), ATTR_PROTECTION, cppu::UnoType<util::CellProtection>::get(), 0, 0 },
725 {OUString(SC_UNONAME_CELLSTYL), SC_WID_UNO_CELLSTYL,cppu::UnoType<OUString>::get(), 0, 0 },
726 {OUString(SC_UNONAME_CCOLOR), ATTR_FONT_COLOR, cppu::UnoType<sal_Int32>::get(), 0, 0 },
727 {OUString(SC_UNONAME_COUTL), ATTR_FONT_CONTOUR, getBooleanCppuType(), 0, 0 },
728 {OUString(SC_UNONAME_CCROSS), ATTR_FONT_CROSSEDOUT,getBooleanCppuType(), 0, MID_CROSSED_OUT },
729 {OUString(SC_UNONAME_CEMPHAS), ATTR_FONT_EMPHASISMARK,cppu::UnoType<sal_Int16>::get(), 0, MID_EMPHASIS },
730 {OUString(SC_UNONAME_CFONT), ATTR_FONT, cppu::UnoType<sal_Int16>::get(), 0, MID_FONT_FAMILY },
731 {OUString(SC_UNONAME_CFCHARS), ATTR_FONT, cppu::UnoType<sal_Int16>::get(), 0, MID_FONT_CHAR_SET },
732 {OUString(SC_UNO_CJK_CFCHARS), ATTR_CJK_FONT, cppu::UnoType<sal_Int16>::get(), 0, MID_FONT_CHAR_SET },
733 {OUString(SC_UNO_CTL_CFCHARS), ATTR_CTL_FONT, cppu::UnoType<sal_Int16>::get(), 0, MID_FONT_CHAR_SET },
734 {OUString(SC_UNONAME_CFFAMIL), ATTR_FONT, cppu::UnoType<sal_Int16>::get(), 0, MID_FONT_FAMILY },
735 {OUString(SC_UNO_CJK_CFFAMIL), ATTR_CJK_FONT, cppu::UnoType<sal_Int16>::get(), 0, MID_FONT_FAMILY },
736 {OUString(SC_UNO_CTL_CFFAMIL), ATTR_CTL_FONT, cppu::UnoType<sal_Int16>::get(), 0, MID_FONT_FAMILY },
737 {OUString(SC_UNONAME_CFNAME), ATTR_FONT, cppu::UnoType<OUString>::get(), 0, MID_FONT_FAMILY_NAME },
738 {OUString(SC_UNO_CJK_CFNAME), ATTR_CJK_FONT, cppu::UnoType<OUString>::get(), 0, MID_FONT_FAMILY_NAME },
739 {OUString(SC_UNO_CTL_CFNAME), ATTR_CTL_FONT, cppu::UnoType<OUString>::get(), 0, MID_FONT_FAMILY_NAME },
740 {OUString(SC_UNONAME_CFPITCH), ATTR_FONT, cppu::UnoType<sal_Int16>::get(), 0, MID_FONT_PITCH },
741 {OUString(SC_UNO_CJK_CFPITCH), ATTR_CJK_FONT, cppu::UnoType<sal_Int16>::get(), 0, MID_FONT_PITCH },
742 {OUString(SC_UNO_CTL_CFPITCH), ATTR_CTL_FONT, cppu::UnoType<sal_Int16>::get(), 0, MID_FONT_PITCH },
743 {OUString(SC_UNONAME_CFSTYLE), ATTR_FONT, cppu::UnoType<OUString>::get(), 0, MID_FONT_STYLE_NAME },
744 {OUString(SC_UNO_CJK_CFSTYLE), ATTR_CJK_FONT, cppu::UnoType<OUString>::get(), 0, MID_FONT_STYLE_NAME },
745 {OUString(SC_UNO_CTL_CFSTYLE), ATTR_CTL_FONT, cppu::UnoType<OUString>::get(), 0, MID_FONT_STYLE_NAME },
746 {OUString(SC_UNONAME_CHEIGHT), ATTR_FONT_HEIGHT, cppu::UnoType<float>::get(), 0, MID_FONTHEIGHT | CONVERT_TWIPS },
747 {OUString(SC_UNO_CJK_CHEIGHT), ATTR_CJK_FONT_HEIGHT,cppu::UnoType<float>::get(), 0, MID_FONTHEIGHT | CONVERT_TWIPS },
748 {OUString(SC_UNO_CTL_CHEIGHT), ATTR_CTL_FONT_HEIGHT,cppu::UnoType<float>::get(), 0, MID_FONTHEIGHT | CONVERT_TWIPS },
749 {OUString(SC_UNONAME_CLOCAL), ATTR_FONT_LANGUAGE, cppu::UnoType<lang::Locale>::get(), 0, MID_LANG_LOCALE },
750 {OUString(SC_UNO_CJK_CLOCAL), ATTR_CJK_FONT_LANGUAGE,cppu::UnoType<lang::Locale>::get(), 0, MID_LANG_LOCALE },
751 {OUString(SC_UNO_CTL_CLOCAL), ATTR_CTL_FONT_LANGUAGE,cppu::UnoType<lang::Locale>::get(), 0, MID_LANG_LOCALE },
752 {OUString(SC_UNONAME_COVER), ATTR_FONT_OVERLINE, cppu::UnoType<sal_Int16>::get(), 0, MID_TL_STYLE },
753 {OUString(SC_UNONAME_COVRLCOL), ATTR_FONT_OVERLINE, cppu::UnoType<sal_Int32>::get(), 0, MID_TL_COLOR },
754 {OUString(SC_UNONAME_COVRLHAS), ATTR_FONT_OVERLINE, getBooleanCppuType(), 0, MID_TL_HASCOLOR },
755 {OUString(SC_UNONAME_CPOST), ATTR_FONT_POSTURE, cppu::UnoType<awt::FontSlant>::get(), 0, MID_POSTURE },
756 {OUString(SC_UNO_CJK_CPOST), ATTR_CJK_FONT_POSTURE,cppu::UnoType<awt::FontSlant>::get(), 0, MID_POSTURE },
757 {OUString(SC_UNO_CTL_CPOST), ATTR_CTL_FONT_POSTURE,cppu::UnoType<awt::FontSlant>::get(), 0, MID_POSTURE },
758 {OUString(SC_UNONAME_CRELIEF), ATTR_FONT_RELIEF, cppu::UnoType<sal_Int16>::get(), 0, MID_RELIEF },
759 {OUString(SC_UNONAME_CSHADD), ATTR_FONT_SHADOWED, getBooleanCppuType(), 0, 0 },
760 {OUString(SC_UNONAME_CSTRIKE), ATTR_FONT_CROSSEDOUT,cppu::UnoType<sal_Int16>::get(), 0, MID_CROSS_OUT },
761 {OUString(SC_UNONAME_CUNDER), ATTR_FONT_UNDERLINE,cppu::UnoType<sal_Int16>::get(), 0, MID_TL_STYLE },
762 {OUString(SC_UNONAME_CUNDLCOL), ATTR_FONT_UNDERLINE,cppu::UnoType<sal_Int32>::get(), 0, MID_TL_COLOR },
763 {OUString(SC_UNONAME_CUNDLHAS), ATTR_FONT_UNDERLINE,getBooleanCppuType(), 0, MID_TL_HASCOLOR },
764 {OUString(SC_UNONAME_CWEIGHT), ATTR_FONT_WEIGHT, cppu::UnoType<float>::get(), 0, MID_WEIGHT },
765 {OUString(SC_UNO_CJK_CWEIGHT), ATTR_CJK_FONT_WEIGHT,cppu::UnoType<float>::get(), 0, MID_WEIGHT },
766 {OUString(SC_UNO_CTL_CWEIGHT), ATTR_CTL_FONT_WEIGHT,cppu::UnoType<float>::get(), 0, MID_WEIGHT },
767 {OUString(SC_UNONAME_CWORDMOD), ATTR_FONT_WORDLINE, getBooleanCppuType(), 0, 0 },
768 {OUString(SC_UNONAME_CHCOLHDR), SC_WID_UNO_CHCOLHDR,getBooleanCppuType(), 0, 0 },
769 {OUString(SC_UNONAME_CHROWHDR), SC_WID_UNO_CHROWHDR,getBooleanCppuType(), 0, 0 },
770 {OUString(SC_UNONAME_CONDFMT), SC_WID_UNO_CONDFMT, cppu::UnoType<sheet::XSheetConditionalEntries>::get(), 0, 0 },
771 {OUString(SC_UNONAME_CONDLOC), SC_WID_UNO_CONDLOC, cppu::UnoType<sheet::XSheetConditionalEntries>::get(), 0, 0 },
772 {OUString(SC_UNONAME_CONDXML), SC_WID_UNO_CONDXML, cppu::UnoType<sheet::XSheetConditionalEntries>::get(), 0, 0 },
773 {OUString(SC_UNONAME_COPYBACK), SC_WID_UNO_COPYBACK,getBooleanCppuType(), 0, 0 },
774 {OUString(SC_UNONAME_COPYFORM), SC_WID_UNO_COPYFORM,getBooleanCppuType(), 0, 0 },
775 {OUString(SC_UNONAME_COPYSTYL), SC_WID_UNO_COPYSTYL,getBooleanCppuType(), 0, 0 },
776 {OUString(SC_UNONAME_DIAGONAL_BLTR), ATTR_BORDER_BLTR, ::cppu::UnoType<table::BorderLine>::get(), 0, 0 | CONVERT_TWIPS },
777 {OUString(SC_UNONAME_DIAGONAL_BLTR2), ATTR_BORDER_BLTR, ::cppu::UnoType<table::BorderLine2>::get(), 0, 0 | CONVERT_TWIPS },
778 {OUString(SC_UNONAME_DIAGONAL_TLBR), ATTR_BORDER_TLBR, ::cppu::UnoType<table::BorderLine>::get(), 0, 0 | CONVERT_TWIPS },
779 {OUString(SC_UNONAME_DIAGONAL_TLBR2), ATTR_BORDER_TLBR, ::cppu::UnoType<table::BorderLine2>::get(), 0, 0 | CONVERT_TWIPS },
780 {OUString(SC_UNONAME_CELLHJUS), ATTR_HOR_JUSTIFY, cppu::UnoType<table::CellHoriJustify>::get(), 0, MID_HORJUST_HORJUST },
781 {OUString(SC_UNONAME_CELLHJUS_METHOD), ATTR_HOR_JUSTIFY_METHOD, ::cppu::UnoType<sal_Int32>::get(), 0, 0 },
782 {OUString(SC_UNONAME_ISACTIVE), SC_WID_UNO_ISACTIVE,getBooleanCppuType(), 0, 0 },
783 {OUString(SC_UNONAME_CELLTRAN), ATTR_BACKGROUND, getBooleanCppuType(), 0, MID_GRAPHIC_TRANSPARENT },
784 {OUString(SC_UNONAME_WRAP), ATTR_LINEBREAK, getBooleanCppuType(), 0, 0 },
785 {OUString(SC_UNONAME_CELLVIS), SC_WID_UNO_CELLVIS, getBooleanCppuType(), 0, 0 },
786 {OUString(SC_UNONAME_LEFTBORDER),ATTR_BORDER, ::cppu::UnoType<table::BorderLine>::get(), 0, LEFT_BORDER | CONVERT_TWIPS },
787 {OUString(SC_UNONAME_LEFTBORDER2),ATTR_BORDER, ::cppu::UnoType<table::BorderLine2>::get(), 0, LEFT_BORDER | CONVERT_TWIPS },
788 {OUString(SC_UNO_LINKDISPBIT), SC_WID_UNO_LINKDISPBIT,cppu::UnoType<awt::XBitmap>::get(), 0 | beans::PropertyAttribute::READONLY, 0 },
789 {OUString(SC_UNO_LINKDISPNAME), SC_WID_UNO_LINKDISPNAME,cppu::UnoType<OUString>::get(), 0 | beans::PropertyAttribute::READONLY, 0 },
790 {OUString(SC_UNONAME_NUMFMT), ATTR_VALUE_FORMAT, cppu::UnoType<sal_Int32>::get(), 0, 0 },
791 {OUString(SC_UNONAME_NUMRULES), SC_WID_UNO_NUMRULES,cppu::UnoType<container::XIndexReplace>::get(), 0, 0 },
792 {OUString(SC_UNONAME_CELLORI), ATTR_STACKED, cppu::UnoType<table::CellOrientation>::get(), 0, 0 },
793 {OUString(SC_UNONAME_PAGESTL), SC_WID_UNO_PAGESTL, cppu::UnoType<OUString>::get(), 0, 0 },
794 {OUString(SC_UNONAME_PADJUST), ATTR_HOR_JUSTIFY, ::cppu::UnoType<sal_Int16>::get(), 0, MID_HORJUST_ADJUST },
795 {OUString(SC_UNONAME_PBMARGIN), ATTR_MARGIN, cppu::UnoType<sal_Int32>::get(), 0, MID_MARGIN_LO_MARGIN | CONVERT_TWIPS },
796 {OUString(SC_UNONAME_PINDENT), ATTR_INDENT, cppu::UnoType<sal_Int16>::get(), 0, 0 }, //! CONVERT_TWIPS
797 {OUString(SC_UNONAME_PISCHDIST),ATTR_SCRIPTSPACE, getBooleanCppuType(), 0, 0 },
798 {OUString(SC_UNONAME_PISFORBID),ATTR_FORBIDDEN_RULES,getBooleanCppuType(), 0, 0 },
799 {OUString(SC_UNONAME_PISHANG), ATTR_HANGPUNCTUATION,getBooleanCppuType(), 0, 0 },
800 {OUString(SC_UNONAME_PISHYPHEN),ATTR_HYPHENATE, getBooleanCppuType(), 0, 0 },
801 {OUString(SC_UNONAME_PLASTADJ), ATTR_HOR_JUSTIFY, ::cppu::UnoType<sal_Int16>::get(), 0, MID_HORJUST_ADJUST },
802 {OUString(SC_UNONAME_PLMARGIN), ATTR_MARGIN, cppu::UnoType<sal_Int32>::get(), 0, MID_MARGIN_L_MARGIN | CONVERT_TWIPS },
803 {OUString(SC_UNONAME_PRMARGIN), ATTR_MARGIN, cppu::UnoType<sal_Int32>::get(), 0, MID_MARGIN_R_MARGIN | CONVERT_TWIPS },
804 {OUString(SC_UNONAME_PTMARGIN), ATTR_MARGIN, cppu::UnoType<sal_Int32>::get(), 0, MID_MARGIN_UP_MARGIN | CONVERT_TWIPS },
805 {OUString(SC_UNONAME_POS), SC_WID_UNO_POS, cppu::UnoType<awt::Point>::get(), 0 | beans::PropertyAttribute::READONLY, 0 },
806 {OUString(SC_UNONAME_PRINTBORD),SC_WID_UNO_PRINTBORD,getBooleanCppuType(), 0, 0 },
807 {OUString(SC_UNONAME_PROTECT), SC_WID_UNO_PROTECT, getBooleanCppuType(), 0, 0 },
808 {OUString(SC_UNONAME_RIGHTBORDER),ATTR_BORDER, ::cppu::UnoType<table::BorderLine>::get(), 0, RIGHT_BORDER | CONVERT_TWIPS },
809 {OUString(SC_UNONAME_RIGHTBORDER2),ATTR_BORDER, ::cppu::UnoType<table::BorderLine2>::get(), 0, RIGHT_BORDER | CONVERT_TWIPS },
810 {OUString(SC_UNONAME_ROTANG), ATTR_ROTATE_VALUE, cppu::UnoType<sal_Int32>::get(), 0, 0 },
811 {OUString(SC_UNONAME_ROTREF), ATTR_ROTATE_MODE, cppu::UnoType<sal_Int32>::get(), 0, 0 },
812 {OUString(SC_UNONAME_SHADOW), ATTR_SHADOW, cppu::UnoType<table::ShadowFormat>::get(), 0, 0 | CONVERT_TWIPS },
813 {OUString(SC_UNONAME_SHOWBORD), SC_WID_UNO_SHOWBORD,getBooleanCppuType(), 0, 0 },
814 {OUString(SC_UNONAME_SHRINK_TO_FIT), ATTR_SHRINKTOFIT, getBooleanCppuType(), 0, 0 },
815 {OUString(SC_UNONAME_SIZE), SC_WID_UNO_SIZE, cppu::UnoType<awt::Size>::get(), 0 | beans::PropertyAttribute::READONLY, 0 },
816 {OUString(SC_UNONAME_TBLBORD), SC_WID_UNO_TBLBORD, cppu::UnoType<table::TableBorder>::get(), 0, 0 | CONVERT_TWIPS },
817 {OUString(SC_UNONAME_TBLBORD2), SC_WID_UNO_TBLBORD2, cppu::UnoType<table::TableBorder2>::get(), 0, 0 | CONVERT_TWIPS },
818 {OUString(SC_UNONAME_TABLAYOUT),SC_WID_UNO_TABLAYOUT,cppu::UnoType<sal_Int16>::get(), 0, 0 },
819 {OUString(SC_UNONAME_TOPBORDER),ATTR_BORDER, ::cppu::UnoType<table::BorderLine>::get(), 0, TOP_BORDER | CONVERT_TWIPS },
820 {OUString(SC_UNONAME_TOPBORDER2),ATTR_BORDER, ::cppu::UnoType<table::BorderLine2>::get(), 0, TOP_BORDER | CONVERT_TWIPS },
821 {OUString(SC_UNONAME_USERDEF), ATTR_USERDEF, cppu::UnoType<container::XNameContainer>::get(), 0, 0 },
822 {OUString(SC_UNONAME_VALIDAT), SC_WID_UNO_VALIDAT, cppu::UnoType<beans::XPropertySet>::get(), 0, 0 },
823 {OUString(SC_UNONAME_VALILOC), SC_WID_UNO_VALILOC, cppu::UnoType<beans::XPropertySet>::get(), 0, 0 },
824 {OUString(SC_UNONAME_VALIXML), SC_WID_UNO_VALIXML, cppu::UnoType<beans::XPropertySet>::get(), 0, 0 },
825 {OUString(SC_UNONAME_CELLVJUS), ATTR_VER_JUSTIFY, cppu::UnoType<sal_Int32>::get(), 0, 0 },
826 {OUString(SC_UNONAME_CELLVJUS_METHOD), ATTR_VER_JUSTIFY_METHOD, ::cppu::UnoType<sal_Int32>::get(), 0, 0 },
827 {OUString(SC_UNONAME_WRITING), ATTR_WRITINGDIR, cppu::UnoType<sal_Int16>::get(), 0, 0 },
828 {OUString(SC_UNONAME_TABCOLOR), SC_WID_UNO_TABCOLOR, cppu::UnoType<sal_Int32>::get(), 0, 0 },
829 {OUString(SC_UNO_CODENAME), SC_WID_UNO_CODENAME, cppu::UnoType<OUString>::get(), 0, 0},
830 {OUString(SC_UNO_NAMEDRANGES), SC_WID_UNO_NAMES, cppu::UnoType<sheet::XNamedRanges>::get(), 0, 0 },
831 { OUString(), 0, css::uno::Type(), 0, 0 }
833 static SfxItemPropertySet aSheetPropertySet( aSheetPropertyMap_Impl );
834 return &aSheetPropertySet;
837 static const SfxItemPropertyMapEntry* lcl_GetEditPropertyMap()
839 static const SfxItemPropertyMapEntry aEditPropertyMap_Impl[] =
841 SVX_UNOEDIT_CHAR_PROPERTIES,
842 SVX_UNOEDIT_FONT_PROPERTIES,
843 SVX_UNOEDIT_PARA_PROPERTIES,
844 SVX_UNOEDIT_NUMBERING_PROPERTIE, // for completeness of service ParagraphProperties
845 {OUString(SC_UNONAME_TEXTUSER), EE_CHAR_XMLATTRIBS, cppu::UnoType<container::XNameContainer>::get(), 0, 0},
846 {OUString(SC_UNONAME_USERDEF), EE_PARA_XMLATTRIBS, cppu::UnoType<container::XNameContainer>::get(), 0, 0},
847 { OUString(), 0, css::uno::Type(), 0, 0 }
849 return aEditPropertyMap_Impl;
851 static const SvxItemPropertySet* lcl_GetEditPropertySet()
853 static SvxItemPropertySet aEditPropertySet( lcl_GetEditPropertyMap(), SdrObject::GetGlobalDrawObjectItemPool() );
854 return &aEditPropertySet;
857 using sc::HMMToTwips;
858 using sc::TwipsToHMM;
860 #define SCCHARPROPERTIES_SERVICE "com.sun.star.style.CharacterProperties"
861 #define SCPARAPROPERTIES_SERVICE "com.sun.star.style.ParagraphProperties"
862 #define SCCELLPROPERTIES_SERVICE "com.sun.star.table.CellProperties"
863 #define SCCELLRANGE_SERVICE "com.sun.star.table.CellRange"
864 #define SCCELL_SERVICE "com.sun.star.table.Cell"
865 #define SCSHEETCELLRANGES_SERVICE "com.sun.star.sheet.SheetCellRanges"
866 #define SCSHEETCELLRANGE_SERVICE "com.sun.star.sheet.SheetCellRange"
867 #define SCSPREADSHEET_SERVICE "com.sun.star.sheet.Spreadsheet"
868 #define SCSHEETCELL_SERVICE "com.sun.star.sheet.SheetCell"
870 SC_SIMPLE_SERVICE_INFO( ScCellFormatsEnumeration, "ScCellFormatsEnumeration", "com.sun.star.sheet.CellFormatRangesEnumeration" )
871 SC_SIMPLE_SERVICE_INFO( ScCellFormatsObj, "ScCellFormatsObj", "com.sun.star.sheet.CellFormatRanges" )
872 SC_SIMPLE_SERVICE_INFO( ScUniqueCellFormatsEnumeration, "ScUniqueCellFormatsEnumeration", "com.sun.star.sheet.UniqueCellFormatRangesEnumeration" )
873 SC_SIMPLE_SERVICE_INFO( ScUniqueCellFormatsObj, "ScUniqueCellFormatsObj", "com.sun.star.sheet.UniqueCellFormatRanges" )
874 SC_SIMPLE_SERVICE_INFO( ScCellRangesBase, "ScCellRangesBase", "stardiv.unknown" )
875 SC_SIMPLE_SERVICE_INFO( ScCellsEnumeration, "ScCellsEnumeration", "com.sun.star.sheet.CellsEnumeration" )
876 SC_SIMPLE_SERVICE_INFO( ScCellsObj, "ScCellsObj", "com.sun.star.sheet.Cells" )
877 SC_SIMPLE_SERVICE_INFO( ScTableColumnObj, "ScTableColumnObj", "com.sun.star.table.TableColumn" )
878 SC_SIMPLE_SERVICE_INFO( ScTableRowObj, "ScTableRowObj", "com.sun.star.table.TableRow" )
880 //! ScLinkListener in anderes File verschieben !!!
882 ScLinkListener::~ScLinkListener()
886 void ScLinkListener::Notify( const SfxHint& rHint )
888 aLink.Call( (SfxHint*)&rHint );
891 static void lcl_CopyProperties( beans::XPropertySet& rDest, beans::XPropertySet& rSource )
893 uno::Reference<beans::XPropertySetInfo> xInfo(rSource.getPropertySetInfo());
894 if (xInfo.is())
896 uno::Sequence<beans::Property> aSeq(xInfo->getProperties());
897 const beans::Property* pAry = aSeq.getConstArray();
898 sal_uLong nCount = aSeq.getLength();
899 for (sal_uLong i=0; i<nCount; i++)
901 OUString aName(pAry[i].Name);
902 rDest.setPropertyValue( aName, rSource.getPropertyValue( aName ) );
907 static SCTAB lcl_FirstTab( const ScRangeList& rRanges )
909 OSL_ENSURE(rRanges.size() >= 1, "was fuer Ranges ?!?!");
910 const ScRange* pFirst = rRanges[ 0 ];
911 if (pFirst)
912 return pFirst->aStart.Tab();
914 return 0; // soll nicht sein
917 static bool lcl_WholeSheet( const ScRangeList& rRanges )
919 if ( rRanges.size() == 1 )
921 const ScRange* pRange = rRanges[0];
922 if ( pRange && pRange->aStart.Col() == 0 && pRange->aEnd.Col() == MAXCOL &&
923 pRange->aStart.Row() == 0 && pRange->aEnd.Row() == MAXROW )
924 return true;
926 return false;
929 namespace {
930 template<typename BorderLineType>
931 const ::editeng::SvxBorderLine* lcl_getBorderLine(
932 ::editeng::SvxBorderLine& rLine, const BorderLineType& rStruct )
934 // Convert from 1/100mm to Twips.
935 if (!SvxBoxItem::LineToSvxLine( rStruct, rLine, true))
936 return NULL;
938 if ( rLine.GetOutWidth() || rLine.GetInWidth() || rLine.GetDistance() )
939 return &rLine;
940 else
941 return NULL;
945 const ::editeng::SvxBorderLine* ScHelperFunctions::GetBorderLine(
946 ::editeng::SvxBorderLine& rLine, const table::BorderLine& rStruct )
948 return lcl_getBorderLine( rLine, rStruct);
951 const ::editeng::SvxBorderLine* ScHelperFunctions::GetBorderLine(
952 ::editeng::SvxBorderLine& rLine, const table::BorderLine2& rStruct )
954 return lcl_getBorderLine( rLine, rStruct);
958 namespace {
959 template<typename TableBorderType>
960 void lcl_fillBoxItems( SvxBoxItem& rOuter, SvxBoxInfoItem& rInner, const TableBorderType& rBorder )
962 ::editeng::SvxBorderLine aLine;
963 rOuter.SetDistance( (sal_uInt16)HMMToTwips( rBorder.Distance ) );
964 rOuter.SetLine( ScHelperFunctions::GetBorderLine( aLine, rBorder.TopLine ), BOX_LINE_TOP );
965 rOuter.SetLine( ScHelperFunctions::GetBorderLine( aLine, rBorder.BottomLine ), BOX_LINE_BOTTOM );
966 rOuter.SetLine( ScHelperFunctions::GetBorderLine( aLine, rBorder.LeftLine ), BOX_LINE_LEFT );
967 rOuter.SetLine( ScHelperFunctions::GetBorderLine( aLine, rBorder.RightLine ), BOX_LINE_RIGHT );
968 rInner.SetLine( ScHelperFunctions::GetBorderLine( aLine, rBorder.HorizontalLine ), BOXINFO_LINE_HORI );
969 rInner.SetLine( ScHelperFunctions::GetBorderLine( aLine, rBorder.VerticalLine ), BOXINFO_LINE_VERT );
970 rInner.SetValid( VALID_TOP, rBorder.IsTopLineValid );
971 rInner.SetValid( VALID_BOTTOM, rBorder.IsBottomLineValid );
972 rInner.SetValid( VALID_LEFT, rBorder.IsLeftLineValid );
973 rInner.SetValid( VALID_RIGHT, rBorder.IsRightLineValid );
974 rInner.SetValid( VALID_HORI, rBorder.IsHorizontalLineValid );
975 rInner.SetValid( VALID_VERT, rBorder.IsVerticalLineValid );
976 rInner.SetValid( VALID_DISTANCE, rBorder.IsDistanceValid );
977 rInner.SetTable( true );
981 void ScHelperFunctions::FillBoxItems( SvxBoxItem& rOuter, SvxBoxInfoItem& rInner, const table::TableBorder& rBorder )
983 lcl_fillBoxItems( rOuter, rInner, rBorder);
986 void ScHelperFunctions::FillBoxItems( SvxBoxItem& rOuter, SvxBoxInfoItem& rInner, const table::TableBorder2& rBorder )
988 lcl_fillBoxItems( rOuter, rInner, rBorder);
992 void ScHelperFunctions::FillBorderLine( table::BorderLine& rStruct, const ::editeng::SvxBorderLine* pLine )
994 // Convert from Twips to 1/100mm.
995 table::BorderLine2 aStruct( SvxBoxItem::SvxLineToLine( pLine, true));
996 rStruct = aStruct;
999 void ScHelperFunctions::FillBorderLine( table::BorderLine2& rStruct, const ::editeng::SvxBorderLine* pLine )
1001 rStruct = SvxBoxItem::SvxLineToLine( pLine, true);
1005 namespace {
1006 template<typename TableBorderItem>
1007 void lcl_fillTableBorder( TableBorderItem& rBorder, const SvxBoxItem& rOuter, const SvxBoxInfoItem& rInner,
1008 bool bInvalidateHorVerDist )
1010 ScHelperFunctions::FillBorderLine( rBorder.TopLine, rOuter.GetTop() );
1011 ScHelperFunctions::FillBorderLine( rBorder.BottomLine, rOuter.GetBottom() );
1012 ScHelperFunctions::FillBorderLine( rBorder.LeftLine, rOuter.GetLeft() );
1013 ScHelperFunctions::FillBorderLine( rBorder.RightLine, rOuter.GetRight() );
1014 ScHelperFunctions::FillBorderLine( rBorder.HorizontalLine, rInner.GetHori() );
1015 ScHelperFunctions::FillBorderLine( rBorder.VerticalLine, rInner.GetVert() );
1017 rBorder.Distance = rOuter.GetDistance();
1018 rBorder.IsTopLineValid = rInner.IsValid(VALID_TOP);
1019 rBorder.IsBottomLineValid = rInner.IsValid(VALID_BOTTOM);
1020 rBorder.IsLeftLineValid = rInner.IsValid(VALID_LEFT);
1021 rBorder.IsRightLineValid = rInner.IsValid(VALID_RIGHT);
1022 rBorder.IsHorizontalLineValid = !bInvalidateHorVerDist && rInner.IsValid(VALID_HORI);
1023 rBorder.IsVerticalLineValid = !bInvalidateHorVerDist && rInner.IsValid(VALID_VERT);
1024 rBorder.IsDistanceValid = !bInvalidateHorVerDist && rInner.IsValid(VALID_DISTANCE);
1028 void ScHelperFunctions::AssignTableBorderToAny( uno::Any& rAny,
1029 const SvxBoxItem& rOuter, const SvxBoxInfoItem& rInner, bool bInvalidateHorVerDist )
1031 table::TableBorder aBorder;
1032 lcl_fillTableBorder( aBorder, rOuter, rInner, bInvalidateHorVerDist);
1033 rAny <<= aBorder;
1036 void ScHelperFunctions::AssignTableBorder2ToAny( uno::Any& rAny,
1037 const SvxBoxItem& rOuter, const SvxBoxInfoItem& rInner, bool bInvalidateHorVerDist )
1039 table::TableBorder2 aBorder;
1040 lcl_fillTableBorder( aBorder, rOuter, rInner, bInvalidateHorVerDist);
1041 rAny <<= aBorder;
1044 //! lcl_ApplyBorder nach docfunc verschieben!
1046 void ScHelperFunctions::ApplyBorder( ScDocShell* pDocShell, const ScRangeList& rRanges,
1047 const SvxBoxItem& rOuter, const SvxBoxInfoItem& rInner )
1049 ScDocument* pDoc = pDocShell->GetDocument();
1050 bool bUndo(pDoc->IsUndoEnabled());
1051 ScDocument* pUndoDoc = NULL;
1052 if (bUndo)
1053 pUndoDoc = new ScDocument( SCDOCMODE_UNDO );
1054 size_t nCount = rRanges.size();
1055 for (size_t i = 0; i < nCount; ++i)
1057 ScRange aRange( *rRanges[ i ] );
1058 SCTAB nTab = aRange.aStart.Tab();
1060 if (bUndo)
1062 if ( i==0 )
1063 pUndoDoc->InitUndo( pDoc, nTab, nTab );
1064 else
1065 pUndoDoc->AddUndoTab( nTab, nTab );
1066 pDoc->CopyToDocument( aRange, IDF_ATTRIB, false, pUndoDoc );
1069 ScMarkData aMark;
1070 aMark.SetMarkArea( aRange );
1071 aMark.SelectTable( nTab, true );
1073 pDoc->ApplySelectionFrame( aMark, &rOuter, &rInner );
1074 // RowHeight bei Umrandung alleine nicht noetig
1077 if (bUndo)
1079 pDocShell->GetUndoManager()->AddUndoAction(
1080 new ScUndoBorder( pDocShell, rRanges, pUndoDoc, rOuter, rInner ) );
1083 for (size_t i = 0; i < nCount; ++i )
1084 pDocShell->PostPaint( *rRanges[ i ], PAINT_GRID, SC_PF_LINES | SC_PF_TESTMERGE );
1086 pDocShell->SetDocumentModified();
1089 //! move lcl_PutDataArray to docfunc?
1090 //! merge loop with ScFunctionAccess::callFunction
1092 static bool lcl_PutDataArray( ScDocShell& rDocShell, const ScRange& rRange,
1093 const uno::Sequence< uno::Sequence<uno::Any> >& aData )
1095 ScDocument* pDoc = rDocShell.GetDocument();
1096 SCTAB nTab = rRange.aStart.Tab();
1097 SCCOL nStartCol = rRange.aStart.Col();
1098 SCROW nStartRow = rRange.aStart.Row();
1099 SCCOL nEndCol = rRange.aEnd.Col();
1100 SCROW nEndRow = rRange.aEnd.Row();
1101 bool bUndo(pDoc->IsUndoEnabled());
1103 if ( !pDoc->IsBlockEditable( nTab, nStartCol,nStartRow, nEndCol,nEndRow ) )
1105 //! error message
1106 return false;
1109 long nCols = 0;
1110 long nRows = aData.getLength();
1111 const uno::Sequence<uno::Any>* pArray = aData.getConstArray();
1112 if ( nRows )
1113 nCols = pArray[0].getLength();
1115 if ( nCols != nEndCol-nStartCol+1 || nRows != nEndRow-nStartRow+1 )
1117 //! error message?
1118 return false;
1121 ScDocument* pUndoDoc = NULL;
1122 if ( bUndo )
1124 pUndoDoc = new ScDocument( SCDOCMODE_UNDO );
1125 pUndoDoc->InitUndo( pDoc, nTab, nTab );
1126 pDoc->CopyToDocument( rRange, IDF_CONTENTS|IDF_NOCAPTIONS, false, pUndoDoc );
1129 pDoc->DeleteAreaTab( nStartCol, nStartRow, nEndCol, nEndRow, nTab, IDF_CONTENTS );
1131 bool bError = false;
1132 SCROW nDocRow = nStartRow;
1133 for (long nRow=0; nRow<nRows; nRow++)
1135 const uno::Sequence<uno::Any>& rColSeq = pArray[nRow];
1136 if ( rColSeq.getLength() == nCols )
1138 SCCOL nDocCol = nStartCol;
1139 const uno::Any* pColArr = rColSeq.getConstArray();
1140 for (long nCol=0; nCol<nCols; nCol++)
1142 ScAddress aPos(nDocCol, nDocRow, nTab);
1144 const uno::Any& rElement = pColArr[nCol];
1145 switch( rElement.getValueTypeClass() )
1147 case uno::TypeClass_VOID:
1149 // void = "no value"
1150 pDoc->SetError( nDocCol, nDocRow, nTab, NOTAVAILABLE );
1152 break;
1154 // #87871# accept integer types because Basic passes a floating point
1155 // variable as byte, short or long if it's an integer number.
1156 case uno::TypeClass_BYTE:
1157 case uno::TypeClass_SHORT:
1158 case uno::TypeClass_UNSIGNED_SHORT:
1159 case uno::TypeClass_LONG:
1160 case uno::TypeClass_UNSIGNED_LONG:
1161 case uno::TypeClass_FLOAT:
1162 case uno::TypeClass_DOUBLE:
1164 double fVal(0.0);
1165 rElement >>= fVal;
1166 pDoc->SetValue(aPos, fVal);
1168 break;
1170 case uno::TypeClass_STRING:
1172 OUString aUStr;
1173 rElement >>= aUStr;
1174 if ( !aUStr.isEmpty() )
1176 ScSetStringParam aParam;
1177 aParam.setTextInput();
1178 pDoc->SetString(aPos, aUStr, &aParam);
1181 break;
1183 // accept Sequence<FormulaToken> for formula cells
1184 case uno::TypeClass_SEQUENCE:
1186 uno::Sequence< sheet::FormulaToken > aTokens;
1187 if ( rElement >>= aTokens )
1189 ScTokenArray aTokenArray;
1190 ScTokenConversion::ConvertToTokenArray( *pDoc, aTokenArray, aTokens );
1191 pDoc->SetFormula(aPos, aTokenArray);
1193 else
1194 bError = true;
1196 break;
1198 default:
1199 bError = true; // invalid type
1201 ++nDocCol;
1204 else
1205 bError = true; // wrong size
1207 ++nDocRow;
1210 bool bHeight = rDocShell.AdjustRowHeight( nStartRow, nEndRow, nTab );
1212 if ( pUndoDoc )
1214 ScMarkData aDestMark;
1215 aDestMark.SelectOneTable( nTab );
1216 rDocShell.GetUndoManager()->AddUndoAction(
1217 new ScUndoPaste(
1218 &rDocShell, ScRange(nStartCol, nStartRow, nTab, nEndCol, nEndRow, nTab),
1219 aDestMark, pUndoDoc, NULL, IDF_CONTENTS, NULL, false));
1222 if (!bHeight)
1223 rDocShell.PostPaint( rRange, PAINT_GRID ); // AdjustRowHeight may have painted already
1225 rDocShell.SetDocumentModified();
1227 return !bError;
1230 static bool lcl_PutFormulaArray( ScDocShell& rDocShell, const ScRange& rRange,
1231 const uno::Sequence< uno::Sequence<OUString> >& aData,
1232 const formula::FormulaGrammar::Grammar eGrammar )
1234 ScDocument* pDoc = rDocShell.GetDocument();
1235 SCTAB nTab = rRange.aStart.Tab();
1236 SCCOL nStartCol = rRange.aStart.Col();
1237 SCROW nStartRow = rRange.aStart.Row();
1238 SCCOL nEndCol = rRange.aEnd.Col();
1239 SCROW nEndRow = rRange.aEnd.Row();
1240 bool bUndo(pDoc->IsUndoEnabled());
1242 if ( !pDoc->IsBlockEditable( nTab, nStartCol,nStartRow, nEndCol,nEndRow ) )
1244 //! error message
1245 return false;
1248 long nCols = 0;
1249 long nRows = aData.getLength();
1250 const uno::Sequence<OUString>* pArray = aData.getConstArray();
1251 if ( nRows )
1252 nCols = pArray[0].getLength();
1254 if ( nCols != nEndCol-nStartCol+1 || nRows != nEndRow-nStartRow+1 )
1256 //! error message?
1257 return false;
1260 ScDocument* pUndoDoc = NULL;
1261 if ( bUndo )
1263 pUndoDoc = new ScDocument( SCDOCMODE_UNDO );
1264 pUndoDoc->InitUndo( pDoc, nTab, nTab );
1265 pDoc->CopyToDocument( rRange, IDF_CONTENTS, false, pUndoDoc );
1268 pDoc->DeleteAreaTab( nStartCol, nStartRow, nEndCol, nEndRow, nTab, IDF_CONTENTS );
1270 bool bError = false;
1271 SCROW nDocRow = nStartRow;
1272 for (long nRow=0; nRow<nRows; nRow++)
1274 const uno::Sequence<OUString>& rColSeq = pArray[nRow];
1275 if ( rColSeq.getLength() == nCols )
1277 SCCOL nDocCol = nStartCol;
1278 const OUString* pColArr = rColSeq.getConstArray();
1279 for (long nCol=0; nCol<nCols; nCol++)
1281 OUString aText(pColArr[nCol]);
1282 ScAddress aPos( nDocCol, nDocRow, nTab );
1284 ScInputStringType aRes =
1285 ScStringUtil::parseInputString(
1286 *pDoc->GetFormatTable(), aText, LANGUAGE_ENGLISH_US);
1287 switch (aRes.meType)
1289 case ScInputStringType::Formula:
1290 pDoc->SetFormula(aPos, aRes.maText, eGrammar);
1291 break;
1292 case ScInputStringType::Number:
1293 pDoc->SetValue(aPos, aRes.mfValue);
1294 break;
1295 case ScInputStringType::Text:
1296 pDoc->SetTextCell(aPos, aRes.maText);
1297 break;
1298 default:
1302 ++nDocCol;
1305 else
1306 bError = true; // wrong size
1308 ++nDocRow;
1311 bool bHeight = rDocShell.AdjustRowHeight( nStartRow, nEndRow, nTab );
1313 if ( pUndoDoc )
1315 ScMarkData aDestMark;
1316 aDestMark.SelectOneTable( nTab );
1317 rDocShell.GetUndoManager()->AddUndoAction(
1318 new ScUndoPaste( &rDocShell,
1319 ScRange(nStartCol, nStartRow, nTab, nEndCol, nEndRow, nTab), aDestMark,
1320 pUndoDoc, NULL, IDF_CONTENTS, NULL, false));
1323 if (!bHeight)
1324 rDocShell.PostPaint( rRange, PAINT_GRID ); // AdjustRowHeight may have painted already
1326 rDocShell.SetDocumentModified();
1328 return !bError;
1331 // used in ScCellRangeObj::getFormulaArray and ScCellObj::GetInputString_Impl
1332 static OUString lcl_GetInputString( ScDocument* pDoc, const ScAddress& rPos, bool bEnglish )
1334 if (!pDoc)
1335 return EMPTY_OUSTRING;
1337 ScRefCellValue aCell;
1338 aCell.assign(*pDoc, rPos);
1339 if (aCell.isEmpty())
1340 return EMPTY_OUSTRING;
1342 OUString aVal;
1344 CellType eType = aCell.meType;
1345 if (eType == CELLTYPE_FORMULA)
1347 ScFormulaCell* pForm = aCell.mpFormula;
1348 pForm->GetFormula( aVal, formula::FormulaGrammar::mapAPItoGrammar( bEnglish, false));
1349 return aVal;
1352 SvNumberFormatter* pFormatter = bEnglish ? ScGlobal::GetEnglishFormatter() :
1353 pDoc->GetFormatTable();
1354 // Since the English formatter was constructed with
1355 // LANGUAGE_ENGLISH_US the "General" format has index key 0,
1356 // we don't have to query.
1357 sal_uInt32 nNumFmt = bEnglish ? 0 : pDoc->GetNumberFormat(rPos);
1359 if (eType == CELLTYPE_EDIT)
1361 // GetString an der EditCell macht Leerzeichen aus Umbruechen,
1362 // hier werden die Umbrueche aber gebraucht
1363 const EditTextObject* pData = aCell.mpEditText;
1364 if (pData)
1366 EditEngine& rEngine = pDoc->GetEditEngine();
1367 rEngine.SetText(*pData);
1368 aVal = rEngine.GetText(LINEEND_LF);
1371 else
1372 ScCellFormat::GetInputString(aCell, nNumFmt, aVal, *pFormatter, pDoc);
1374 // ggf. ein ' davorhaengen wie in ScTabViewShell::UpdateInputHandler
1375 if ( eType == CELLTYPE_STRING || eType == CELLTYPE_EDIT )
1377 double fDummy;
1378 OUString aTempString = aVal;
1379 bool bIsNumberFormat(pFormatter->IsNumberFormat(aTempString, nNumFmt, fDummy));
1380 if ( bIsNumberFormat )
1381 aTempString = "'" + aTempString;
1382 else if ( aTempString.startsWith("'") )
1384 // if the string starts with a "'", add another one because setFormula
1385 // strips one (like text input, except for "text" number formats)
1386 if ( bEnglish || ( pFormatter->GetType(nNumFmt) != NUMBERFORMAT_TEXT ) )
1387 aTempString = "'" + aTempString;
1389 aVal = aTempString;
1391 return aVal;
1394 ScCellRangesBase::ScCellRangesBase(ScDocShell* pDocSh, const ScRange& rR) :
1395 pPropSet(lcl_GetCellsPropertySet()),
1396 pDocShell( pDocSh ),
1397 pValueListener( NULL ),
1398 pCurrentFlat( NULL ),
1399 pCurrentDeep( NULL ),
1400 pCurrentDataSet( NULL ),
1401 pNoDfltCurrentDataSet( NULL ),
1402 pMarkData( NULL ),
1403 nObjectId( 0 ),
1404 bChartColAsHdr( false ),
1405 bChartRowAsHdr( false ),
1406 bCursorOnly( false ),
1407 bGotDataChangedHint( false ),
1408 aValueListeners( 0 )
1410 ScRange aCellRange(rR);
1411 aCellRange.Justify();
1412 aRanges.Append( aCellRange );
1414 if (pDocShell) // Null if created with createInstance
1416 ScDocument* pDoc = pDocShell->GetDocument();
1417 pDoc->AddUnoObject(*this);
1418 nObjectId = pDoc->GetNewUnoId();
1422 ScCellRangesBase::ScCellRangesBase(ScDocShell* pDocSh, const ScRangeList& rR) :
1423 pPropSet(lcl_GetCellsPropertySet()),
1424 pDocShell( pDocSh ),
1425 pValueListener( NULL ),
1426 pCurrentFlat( NULL ),
1427 pCurrentDeep( NULL ),
1428 pCurrentDataSet( NULL ),
1429 pNoDfltCurrentDataSet( NULL ),
1430 pMarkData( NULL ),
1431 aRanges( rR ),
1432 nObjectId( 0 ),
1433 bChartColAsHdr( false ),
1434 bChartRowAsHdr( false ),
1435 bCursorOnly( false ),
1436 bGotDataChangedHint( false ),
1437 aValueListeners( 0 )
1439 if (pDocShell) // Null if created with createInstance
1441 ScDocument* pDoc = pDocShell->GetDocument();
1442 pDoc->AddUnoObject(*this);
1443 nObjectId = pDoc->GetNewUnoId();
1447 ScCellRangesBase::~ScCellRangesBase()
1449 // call RemoveUnoObject first, so no notification can happen
1450 // during ForgetCurrentAttrs
1452 if (pDocShell)
1453 pDocShell->GetDocument()->RemoveUnoObject(*this);
1455 ForgetCurrentAttrs();
1456 ForgetMarkData();
1458 delete pValueListener;
1460 //! XChartDataChangeEventListener abmelden ??
1461 //! (ChartCollection haelt dann auch dieses Objekt fest!)
1464 void ScCellRangesBase::ForgetCurrentAttrs()
1466 delete pCurrentFlat;
1467 delete pCurrentDeep;
1468 delete pCurrentDataSet;
1469 delete pNoDfltCurrentDataSet;
1470 pCurrentFlat = NULL;
1471 pCurrentDeep = NULL;
1472 pCurrentDataSet = NULL;
1473 pNoDfltCurrentDataSet = NULL;
1475 // #i62483# pMarkData can remain unchanged, is deleted only if the range changes (RefChanged)
1478 void ScCellRangesBase::ForgetMarkData()
1480 delete pMarkData;
1481 pMarkData = NULL;
1484 const ScPatternAttr* ScCellRangesBase::GetCurrentAttrsFlat()
1486 // get and cache direct cell attributes for this object's range
1488 if ( !pCurrentFlat && pDocShell )
1490 ScDocument* pDoc = pDocShell->GetDocument();
1491 pCurrentFlat = pDoc->CreateSelectionPattern( *GetMarkData(), false );
1493 return pCurrentFlat;
1496 const ScPatternAttr* ScCellRangesBase::GetCurrentAttrsDeep()
1498 // get and cache cell attributes (incl. styles) for this object's range
1500 if ( !pCurrentDeep && pDocShell )
1502 ScDocument* pDoc = pDocShell->GetDocument();
1503 pCurrentDeep = pDoc->CreateSelectionPattern( *GetMarkData(), true );
1505 return pCurrentDeep;
1508 SfxItemSet* ScCellRangesBase::GetCurrentDataSet(bool bNoDflt)
1510 if(!pCurrentDataSet)
1512 const ScPatternAttr* pPattern = GetCurrentAttrsDeep();
1513 if ( pPattern )
1515 // Dontcare durch Default ersetzen, damit man immer eine Reflection hat
1516 pCurrentDataSet = new SfxItemSet( pPattern->GetItemSet() );
1517 pNoDfltCurrentDataSet = new SfxItemSet( pPattern->GetItemSet() );
1518 pCurrentDataSet->ClearInvalidItems();
1521 return bNoDflt ? pNoDfltCurrentDataSet : pCurrentDataSet;
1524 const ScMarkData* ScCellRangesBase::GetMarkData()
1526 if (!pMarkData)
1528 pMarkData = new ScMarkData();
1529 pMarkData->MarkFromRangeList( aRanges, false );
1531 return pMarkData;
1534 void ScCellRangesBase::Notify( SfxBroadcaster&, const SfxHint& rHint )
1536 if ( rHint.ISA( ScUpdateRefHint ) )
1538 const ScUpdateRefHint& rRef = (const ScUpdateRefHint&)rHint;
1540 ScDocument* pDoc = pDocShell->GetDocument();
1541 boost::scoped_ptr<ScRangeList> pUndoRanges;
1542 if ( pDoc->HasUnoRefUndo() )
1543 pUndoRanges.reset(new ScRangeList( aRanges ));
1545 if ( aRanges.UpdateReference( rRef.GetMode(), pDoc, rRef.GetRange(),
1546 rRef.GetDx(), rRef.GetDy(), rRef.GetDz() ) )
1548 // i#90076; the object "this" was destroyed after calling ScTableSheetObj::getImplementation
1549 // this hack make sure that the object lives a bit longer
1550 uno::Reference<uno::XInterface> xInterface((cppu::OWeakObject*)this, uno::UNO_QUERY);
1551 if ( rRef.GetMode() == URM_INSDEL
1552 && aRanges.size() == 1
1553 && ScTableSheetObj::getImplementation( xInterface )
1556 // #101755#; the range size of a sheet does not change
1557 ScRange* pR = aRanges.front();
1558 if (pR)
1560 pR->aStart.SetCol(0);
1561 pR->aStart.SetRow(0);
1562 pR->aEnd.SetCol(MAXCOL);
1563 pR->aEnd.SetRow(MAXROW);
1566 RefChanged();
1568 // any change of the range address is broadcast to value (modify) listeners
1569 if ( !aValueListeners.empty() )
1570 bGotDataChangedHint = true;
1572 if ( pUndoRanges )
1573 pDoc->AddUnoRefChange( nObjectId, *pUndoRanges );
1576 else if ( rHint.ISA( SfxSimpleHint ) )
1578 sal_uLong nId = ((const SfxSimpleHint&)rHint).GetId();
1579 if ( nId == SFX_HINT_DYING )
1581 ForgetCurrentAttrs();
1582 pDocShell = NULL; // invalid
1584 if ( !aValueListeners.empty() )
1586 // dispose listeners
1588 lang::EventObject aEvent;
1589 aEvent.Source.set(static_cast<cppu::OWeakObject*>(this));
1590 for ( sal_uInt16 n=0; n<aValueListeners.size(); n++ )
1591 aValueListeners[n]->disposing( aEvent );
1593 aValueListeners.clear();
1595 // The listeners can't have the last ref to this, as it's still held
1596 // by the DocShell.
1599 else if ( nId == SFX_HINT_DATACHANGED )
1601 // document content changed -> forget cached attributes
1602 ForgetCurrentAttrs();
1604 if ( bGotDataChangedHint && pDocShell )
1606 // This object was notified of content changes, so one call
1607 // for each listener is generated now.
1608 // The calls can't be executed directly because the document's
1609 // UNO broadcaster list must not be modified.
1610 // Instead, add to the document's list of listener calls,
1611 // which will be executed directly after the broadcast of
1612 // SFX_HINT_DATACHANGED.
1614 lang::EventObject aEvent;
1615 aEvent.Source.set((cppu::OWeakObject*)this);
1617 // the EventObject holds a Ref to this object until after the listener calls
1619 ScDocument* pDoc = pDocShell->GetDocument();
1620 for ( sal_uInt16 n=0; n<aValueListeners.size(); n++ )
1621 pDoc->AddUnoListenerCall( aValueListeners[n], aEvent );
1623 bGotDataChangedHint = false;
1626 else if ( nId == SC_HINT_CALCALL )
1628 // broadcast from DoHardRecalc - set bGotDataChangedHint
1629 // (SFX_HINT_DATACHANGED follows separately)
1631 if ( !aValueListeners.empty() )
1632 bGotDataChangedHint = true;
1635 else if ( rHint.ISA( ScUnoRefUndoHint ) )
1637 const ScUnoRefUndoHint& rUndoHint = static_cast<const ScUnoRefUndoHint&>(rHint);
1638 if ( rUndoHint.GetObjectId() == nObjectId )
1640 // restore ranges from hint
1642 aRanges = rUndoHint.GetRanges();
1644 RefChanged();
1645 if ( !aValueListeners.empty() )
1646 bGotDataChangedHint = true; // need to broadcast the undo, too
1651 void ScCellRangesBase::RefChanged()
1653 //! adjust XChartDataChangeEventListener
1655 if ( pValueListener && !aValueListeners.empty() )
1657 pValueListener->EndListeningAll();
1659 ScDocument* pDoc = pDocShell->GetDocument();
1660 for ( size_t i = 0, nCount = aRanges.size(); i < nCount; ++i )
1661 pDoc->StartListeningArea( *aRanges[ i ], pValueListener );
1664 ForgetCurrentAttrs();
1665 ForgetMarkData();
1668 ScDocument* ScCellRangesBase::GetDocument() const
1670 if (pDocShell)
1671 return pDocShell->GetDocument();
1672 else
1673 return NULL;
1676 void ScCellRangesBase::InitInsertRange(ScDocShell* pDocSh, const ScRange& rR)
1678 if ( !pDocShell && pDocSh )
1680 pDocShell = pDocSh;
1682 ScRange aCellRange(rR);
1683 aCellRange.Justify();
1684 aRanges.RemoveAll();
1685 aRanges.Append( aCellRange );
1687 pDocShell->GetDocument()->AddUnoObject(*this);
1689 RefChanged(); // Range im Range-Objekt anpassen
1693 void ScCellRangesBase::AddRange(const ScRange& rRange, const bool bMergeRanges)
1695 if (bMergeRanges)
1696 aRanges.Join(rRange);
1697 else
1698 aRanges.Append(rRange);
1699 RefChanged();
1702 void ScCellRangesBase::SetNewRange(const ScRange& rNew)
1704 ScRange aCellRange(rNew);
1705 aCellRange.Justify();
1707 aRanges.RemoveAll();
1708 aRanges.Append( aCellRange );
1709 RefChanged();
1712 void ScCellRangesBase::SetNewRanges(const ScRangeList& rNew)
1714 aRanges = rNew;
1715 RefChanged();
1718 void ScCellRangesBase::SetCursorOnly( bool bSet )
1720 // set for a selection object that is created from the cursor position
1721 // without anything selected (may contain several sheets)
1723 bCursorOnly = bSet;
1726 uno::Any SAL_CALL ScCellRangesBase::queryInterface( const uno::Type& rType )
1727 throw(uno::RuntimeException, std::exception)
1729 SC_QUERYINTERFACE( beans::XPropertySet )
1730 SC_QUERYINTERFACE( beans::XMultiPropertySet )
1731 SC_QUERYINTERFACE( beans::XTolerantMultiPropertySet )
1732 SC_QUERYINTERFACE( beans::XPropertyState )
1733 SC_QUERYINTERFACE( sheet::XSheetOperation )
1734 SC_QUERYINTERFACE( chart::XChartDataArray )
1735 SC_QUERYINTERFACE( chart::XChartData )
1736 SC_QUERYINTERFACE( util::XIndent )
1737 SC_QUERYINTERFACE( sheet::XCellRangesQuery )
1738 SC_QUERYINTERFACE( sheet::XFormulaQuery )
1739 SC_QUERYINTERFACE( util::XReplaceable )
1740 SC_QUERYINTERFACE( util::XSearchable )
1741 SC_QUERYINTERFACE( util::XModifyBroadcaster )
1742 SC_QUERYINTERFACE( lang::XServiceInfo )
1743 SC_QUERYINTERFACE( lang::XUnoTunnel )
1744 SC_QUERYINTERFACE( lang::XTypeProvider )
1746 return OWeakObject::queryInterface( rType );
1749 void SAL_CALL ScCellRangesBase::acquire() throw()
1751 OWeakObject::acquire();
1754 void SAL_CALL ScCellRangesBase::release() throw()
1756 OWeakObject::release();
1759 uno::Sequence<uno::Type> SAL_CALL ScCellRangesBase::getTypes() throw(uno::RuntimeException, std::exception)
1761 static uno::Sequence<uno::Type> aTypes;
1762 if ( aTypes.getLength() == 0 )
1764 aTypes.realloc(13);
1765 uno::Type* pPtr = aTypes.getArray();
1766 pPtr[0] = cppu::UnoType<beans::XPropertySet>::get();
1767 pPtr[1] = cppu::UnoType<beans::XMultiPropertySet>::get();
1768 pPtr[2] = cppu::UnoType<beans::XPropertyState>::get();
1769 pPtr[3] = cppu::UnoType<sheet::XSheetOperation>::get();
1770 pPtr[4] = cppu::UnoType<chart::XChartDataArray>::get();
1771 pPtr[5] = cppu::UnoType<util::XIndent>::get();
1772 pPtr[6] = cppu::UnoType<sheet::XCellRangesQuery>::get();
1773 pPtr[7] = cppu::UnoType<sheet::XFormulaQuery>::get();
1774 pPtr[8] = cppu::UnoType<util::XReplaceable>::get();
1775 pPtr[9] = cppu::UnoType<util::XModifyBroadcaster>::get();
1776 pPtr[10]= cppu::UnoType<lang::XServiceInfo>::get();
1777 pPtr[11]= cppu::UnoType<lang::XUnoTunnel>::get();
1778 pPtr[12]= cppu::UnoType<lang::XTypeProvider>::get();
1780 return aTypes;
1783 uno::Sequence<sal_Int8> SAL_CALL ScCellRangesBase::getImplementationId()
1784 throw(uno::RuntimeException, std::exception)
1786 return css::uno::Sequence<sal_Int8>();
1789 void ScCellRangesBase::PaintRanges_Impl( sal_uInt16 nPart )
1791 for (size_t i = 0, nCount = aRanges.size(); i < nCount; ++i)
1792 pDocShell->PostPaint( *aRanges[ i ], nPart );
1795 // XSheetOperation
1797 double SAL_CALL ScCellRangesBase::computeFunction( sheet::GeneralFunction nFunction )
1798 throw(uno::Exception, uno::RuntimeException, std::exception)
1800 SolarMutexGuard aGuard;
1801 ScMarkData aMark(*GetMarkData());
1802 aMark.MarkToSimple();
1803 if (!aMark.IsMarked())
1804 aMark.SetMarkNegative(true); // um Dummy Position angeben zu koennen
1806 ScAddress aDummy; // wenn nicht Marked, ignoriert wegen Negative
1807 double fVal;
1808 ScSubTotalFunc eFunc = ScDPUtil::toSubTotalFunc(nFunction);
1809 ScDocument* pDoc = pDocShell->GetDocument();
1810 if ( !pDoc->GetSelectionFunction( eFunc, aDummy, aMark, fVal ) )
1812 throw uno::RuntimeException(); //! own exception?
1815 return fVal;
1818 void SAL_CALL ScCellRangesBase::clearContents( sal_Int32 nContentFlags ) throw(uno::RuntimeException, std::exception)
1820 SolarMutexGuard aGuard;
1821 if ( !aRanges.empty() )
1823 // only for clearContents: EDITATTR is only used if no contents are deleted
1824 sal_uInt16 nDelFlags = static_cast< sal_uInt16 >( nContentFlags & IDF_ALL );
1825 if ( ( nContentFlags & IDF_EDITATTR ) && ( nContentFlags & IDF_CONTENTS ) == 0 )
1826 nDelFlags |= IDF_EDITATTR;
1828 pDocShell->GetDocFunc().DeleteContents( *GetMarkData(), nDelFlags, true, true );
1830 // sonst ist nichts zu tun
1833 // XPropertyState
1835 const SfxItemPropertyMap& ScCellRangesBase::GetItemPropertyMap()
1837 return pPropSet->getPropertyMap();
1840 static void lcl_GetPropertyWhich( const SfxItemPropertySimpleEntry* pEntry,
1841 sal_uInt16& rItemWhich )
1843 // Which-ID des betroffenen Items, auch wenn das Item die Property
1844 // nicht alleine behandeln kann
1845 if ( pEntry )
1847 if ( IsScItemWid( pEntry->nWID ) )
1848 rItemWhich = pEntry->nWID;
1849 else
1850 switch ( pEntry->nWID )
1852 case SC_WID_UNO_TBLBORD:
1853 case SC_WID_UNO_TBLBORD2:
1854 rItemWhich = ATTR_BORDER;
1855 break;
1856 case SC_WID_UNO_CONDFMT:
1857 case SC_WID_UNO_CONDLOC:
1858 case SC_WID_UNO_CONDXML:
1859 rItemWhich = ATTR_CONDITIONAL;
1860 break;
1861 case SC_WID_UNO_VALIDAT:
1862 case SC_WID_UNO_VALILOC:
1863 case SC_WID_UNO_VALIXML:
1864 rItemWhich = ATTR_VALIDDATA;
1865 break;
1871 beans::PropertyState ScCellRangesBase::GetOnePropertyState( sal_uInt16 nItemWhich, const SfxItemPropertySimpleEntry* pEntry )
1873 beans::PropertyState eRet = beans::PropertyState_DIRECT_VALUE;
1874 if ( nItemWhich ) // item wid (from map or special case)
1876 // For items that contain several properties (like background),
1877 // "ambiguous" is returned too often here
1879 // for PropertyState, don't look at styles
1880 const ScPatternAttr* pPattern = GetCurrentAttrsFlat();
1881 if ( pPattern )
1883 SfxItemState eState = pPattern->GetItemSet().GetItemState( nItemWhich, false );
1885 if ( nItemWhich == ATTR_VALUE_FORMAT && eState == SFX_ITEM_DEFAULT )
1886 eState = pPattern->GetItemSet().GetItemState( ATTR_LANGUAGE_FORMAT, false );
1888 if ( eState == SFX_ITEM_SET )
1889 eRet = beans::PropertyState_DIRECT_VALUE;
1890 else if ( eState == SFX_ITEM_DEFAULT )
1891 eRet = beans::PropertyState_DEFAULT_VALUE;
1892 else if ( eState == SFX_ITEM_DONTCARE )
1893 eRet = beans::PropertyState_AMBIGUOUS_VALUE;
1894 else
1896 OSL_FAIL("unbekannter ItemState");
1900 else if ( pEntry )
1902 if ( pEntry->nWID == SC_WID_UNO_CHCOLHDR || pEntry->nWID == SC_WID_UNO_CHROWHDR || pEntry->nWID == SC_WID_UNO_ABSNAME )
1903 eRet = beans::PropertyState_DIRECT_VALUE;
1904 else if ( pEntry->nWID == SC_WID_UNO_CELLSTYL )
1906 // a style is always set, there's no default state
1907 const ScStyleSheet* pStyle = pDocShell->GetDocument()->GetSelectionStyle(*GetMarkData());
1908 if (pStyle)
1909 eRet = beans::PropertyState_DIRECT_VALUE;
1910 else
1911 eRet = beans::PropertyState_AMBIGUOUS_VALUE;
1913 else if ( pEntry->nWID == SC_WID_UNO_NUMRULES )
1914 eRet = beans::PropertyState_DEFAULT_VALUE; // numbering rules are always default
1916 return eRet;
1919 beans::PropertyState SAL_CALL ScCellRangesBase::getPropertyState( const OUString& aPropertyName )
1920 throw(beans::UnknownPropertyException, uno::RuntimeException, std::exception)
1922 SolarMutexGuard aGuard;
1923 if ( aRanges.empty() )
1924 throw uno::RuntimeException();
1926 const SfxItemPropertyMap& rMap = GetItemPropertyMap(); // from derived class
1927 sal_uInt16 nItemWhich = 0;
1928 const SfxItemPropertySimpleEntry* pEntry = rMap.getByName( aPropertyName );
1929 lcl_GetPropertyWhich( pEntry, nItemWhich );
1930 return GetOnePropertyState( nItemWhich, pEntry );
1933 uno::Sequence<beans::PropertyState> SAL_CALL ScCellRangesBase::getPropertyStates(
1934 const uno::Sequence<OUString>& aPropertyNames )
1935 throw(beans::UnknownPropertyException, uno::RuntimeException, std::exception)
1937 SolarMutexGuard aGuard;
1939 const SfxItemPropertyMap& rPropertyMap = GetItemPropertyMap(); // from derived class
1941 uno::Sequence<beans::PropertyState> aRet(aPropertyNames.getLength());
1942 beans::PropertyState* pStates = aRet.getArray();
1943 for(sal_Int32 i = 0; i < aPropertyNames.getLength(); i++)
1945 sal_uInt16 nItemWhich = 0;
1946 const SfxItemPropertySimpleEntry* pEntry = rPropertyMap.getByName( aPropertyNames[i] );
1947 lcl_GetPropertyWhich( pEntry, nItemWhich );
1948 pStates[i] = GetOnePropertyState(nItemWhich, pEntry);
1950 return aRet;
1953 void SAL_CALL ScCellRangesBase::setPropertyToDefault( const OUString& aPropertyName )
1954 throw(beans::UnknownPropertyException, uno::RuntimeException, std::exception)
1956 SolarMutexGuard aGuard;
1957 if ( pDocShell )
1959 const SfxItemPropertyMap& rPropertyMap = GetItemPropertyMap(); // from derived class
1960 sal_uInt16 nItemWhich = 0;
1961 const SfxItemPropertySimpleEntry* pEntry = rPropertyMap.getByName( aPropertyName );
1962 lcl_GetPropertyWhich( pEntry, nItemWhich );
1963 if ( nItemWhich ) // item wid (from map or special case)
1965 if ( !aRanges.empty() ) // leer = nichts zu tun
1967 //! Bei Items, die mehrere Properties enthalten (z.B. Hintergrund)
1968 //! wird hier zuviel zurueckgesetzt
1969 //! for ATTR_ROTATE_VALUE, also reset ATTR_ORIENTATION?
1971 sal_uInt16 aWIDs[3];
1972 aWIDs[0] = nItemWhich;
1973 if ( nItemWhich == ATTR_VALUE_FORMAT )
1975 aWIDs[1] = ATTR_LANGUAGE_FORMAT; // language for number formats
1976 aWIDs[2] = 0;
1978 else
1979 aWIDs[1] = 0;
1980 pDocShell->GetDocFunc().ClearItems( *GetMarkData(), aWIDs, true );
1983 else if ( pEntry )
1985 if ( pEntry->nWID == SC_WID_UNO_CHCOLHDR )
1986 bChartColAsHdr = false;
1987 else if ( pEntry->nWID == SC_WID_UNO_CHROWHDR )
1988 bChartRowAsHdr = false;
1989 else if ( pEntry->nWID == SC_WID_UNO_CELLSTYL )
1991 OUString aStyleName( ScGlobal::GetRscString( STR_STYLENAME_STANDARD ) );
1992 pDocShell->GetDocFunc().ApplyStyle( *GetMarkData(), aStyleName, true, true );
1998 uno::Any SAL_CALL ScCellRangesBase::getPropertyDefault( const OUString& aPropertyName )
1999 throw(beans::UnknownPropertyException, lang::WrappedTargetException,
2000 uno::RuntimeException, std::exception)
2002 //! mit getPropertyValue zusammenfassen
2004 SolarMutexGuard aGuard;
2005 uno::Any aAny;
2007 if ( pDocShell )
2009 ScDocument* pDoc = pDocShell->GetDocument();
2010 const SfxItemPropertyMap& rPropertyMap = GetItemPropertyMap(); // from derived class
2011 const SfxItemPropertySimpleEntry* pEntry = rPropertyMap.getByName( aPropertyName );
2012 if ( pEntry )
2014 if ( IsScItemWid( pEntry->nWID ) )
2016 const ScPatternAttr* pPattern = pDoc->GetDefPattern();
2017 if ( pPattern )
2019 const SfxItemSet& rSet = pPattern->GetItemSet();
2021 switch ( pEntry->nWID ) // fuer Item-Spezial-Behandlungen
2023 case ATTR_VALUE_FORMAT:
2024 // default has no language set
2025 aAny <<= (sal_Int32)( ((const SfxUInt32Item&)rSet.Get(pEntry->nWID)).GetValue() );
2026 break;
2027 case ATTR_INDENT:
2028 aAny <<= (sal_Int16)( TwipsToHMM(((const SfxUInt16Item&)
2029 rSet.Get(pEntry->nWID)).GetValue()) );
2030 break;
2031 default:
2032 pPropSet->getPropertyValue(aPropertyName, rSet, aAny);
2036 else
2037 switch ( pEntry->nWID )
2039 case SC_WID_UNO_CHCOLHDR:
2040 case SC_WID_UNO_CHROWHDR:
2041 ScUnoHelpFunctions::SetBoolInAny( aAny, false );
2042 break;
2043 case SC_WID_UNO_CELLSTYL:
2044 aAny <<= OUString( ScStyleNameConversion::DisplayToProgrammaticName(
2045 ScGlobal::GetRscString(STR_STYLENAME_STANDARD), SFX_STYLE_FAMILY_PARA ) );
2046 break;
2047 case SC_WID_UNO_TBLBORD:
2048 case SC_WID_UNO_TBLBORD2:
2050 const ScPatternAttr* pPattern = pDoc->GetDefPattern();
2051 if ( pPattern )
2053 if (pEntry->nWID == SC_WID_UNO_TBLBORD2)
2054 ScHelperFunctions::AssignTableBorder2ToAny( aAny,
2055 (const SvxBoxItem&)pPattern->GetItem(ATTR_BORDER),
2056 (const SvxBoxInfoItem&)pPattern->GetItem(ATTR_BORDER_INNER) );
2057 else
2058 ScHelperFunctions::AssignTableBorderToAny( aAny,
2059 (const SvxBoxItem&)pPattern->GetItem(ATTR_BORDER),
2060 (const SvxBoxInfoItem&)pPattern->GetItem(ATTR_BORDER_INNER) );
2063 break;
2064 case SC_WID_UNO_CONDFMT:
2065 case SC_WID_UNO_CONDLOC:
2066 case SC_WID_UNO_CONDXML:
2068 bool bEnglish = ( pEntry->nWID != SC_WID_UNO_CONDLOC );
2069 bool bXML = ( pEntry->nWID == SC_WID_UNO_CONDXML );
2070 formula::FormulaGrammar::Grammar eGrammar = (bXML ?
2071 pDoc->GetStorageGrammar() :
2072 formula::FormulaGrammar::mapAPItoGrammar( bEnglish, bXML));
2074 aAny <<= uno::Reference<sheet::XSheetConditionalEntries>(
2075 new ScTableConditionalFormat( pDoc, 0, aRanges[0]->aStart.Tab(), eGrammar ));
2077 break;
2078 case SC_WID_UNO_VALIDAT:
2079 case SC_WID_UNO_VALILOC:
2080 case SC_WID_UNO_VALIXML:
2082 bool bEnglish = ( pEntry->nWID != SC_WID_UNO_VALILOC );
2083 bool bXML = ( pEntry->nWID == SC_WID_UNO_VALIXML );
2084 formula::FormulaGrammar::Grammar eGrammar = (bXML ?
2085 pDoc->GetStorageGrammar() :
2086 formula::FormulaGrammar::mapAPItoGrammar( bEnglish, bXML));
2088 aAny <<= uno::Reference<beans::XPropertySet>(
2089 new ScTableValidationObj( pDoc, 0, eGrammar ));
2091 break;
2092 case SC_WID_UNO_NUMRULES:
2094 aAny <<= uno::Reference<container::XIndexReplace>(ScStyleObj::CreateEmptyNumberingRules());
2096 break;
2101 return aAny;
2104 // XPropertySet
2106 uno::Reference<beans::XPropertySetInfo> SAL_CALL ScCellRangesBase::getPropertySetInfo()
2107 throw(uno::RuntimeException, std::exception)
2109 SolarMutexGuard aGuard;
2110 static uno::Reference<beans::XPropertySetInfo> aRef(
2111 new SfxItemPropertySetInfo( pPropSet->getPropertyMap() ));
2112 return aRef;
2115 static void lcl_SetCellProperty( const SfxItemPropertySimpleEntry& rEntry, const uno::Any& rValue,
2116 ScPatternAttr& rPattern, ScDocument* pDoc,
2117 sal_uInt16& rFirstItemId, sal_uInt16& rSecondItemId )
2119 rFirstItemId = rEntry.nWID;
2120 rSecondItemId = 0;
2122 SfxItemSet& rSet = rPattern.GetItemSet();
2123 switch ( rEntry.nWID )
2125 case ATTR_VALUE_FORMAT:
2127 // language for number formats
2128 SvNumberFormatter* pFormatter = pDoc->GetFormatTable();
2129 sal_uLong nOldFormat = ((const SfxUInt32Item&)rSet.Get( ATTR_VALUE_FORMAT )).GetValue();
2130 LanguageType eOldLang = ((const SvxLanguageItem&)rSet.Get( ATTR_LANGUAGE_FORMAT )).GetLanguage();
2131 nOldFormat = pFormatter->GetFormatForLanguageIfBuiltIn( nOldFormat, eOldLang );
2133 sal_Int32 nIntVal = 0;
2134 if ( rValue >>= nIntVal )
2136 sal_uLong nNewFormat = (sal_uLong)nIntVal;
2137 rSet.Put( SfxUInt32Item( ATTR_VALUE_FORMAT, nNewFormat ) );
2139 const SvNumberformat* pNewEntry = pFormatter->GetEntry( nNewFormat );
2140 LanguageType eNewLang =
2141 pNewEntry ? pNewEntry->GetLanguage() : LANGUAGE_DONTKNOW;
2142 if ( eNewLang != eOldLang && eNewLang != LANGUAGE_DONTKNOW )
2144 rSet.Put( SvxLanguageItem( eNewLang, ATTR_LANGUAGE_FORMAT ) );
2146 // if only language is changed,
2147 // don't touch number format attribute
2148 sal_uLong nNewMod = nNewFormat % SV_COUNTRY_LANGUAGE_OFFSET;
2149 if ( nNewMod == ( nOldFormat % SV_COUNTRY_LANGUAGE_OFFSET ) &&
2150 nNewMod <= SV_MAX_ANZ_STANDARD_FORMATE )
2152 rFirstItemId = 0; // don't use ATTR_VALUE_FORMAT value
2155 rSecondItemId = ATTR_LANGUAGE_FORMAT;
2158 else
2159 throw lang::IllegalArgumentException();
2161 break;
2162 case ATTR_INDENT:
2164 sal_Int16 nIntVal = 0;
2165 if ( rValue >>= nIntVal )
2166 rSet.Put( SfxUInt16Item( rEntry.nWID, (sal_uInt16)HMMToTwips(nIntVal) ) );
2167 else
2168 throw lang::IllegalArgumentException();
2170 break;
2171 case ATTR_ROTATE_VALUE:
2173 sal_Int32 nRotVal = 0;
2174 if ( rValue >>= nRotVal )
2176 // stored value is always between 0 and 360 deg.
2177 nRotVal %= 36000;
2178 if ( nRotVal < 0 )
2179 nRotVal += 36000;
2181 rSet.Put( SfxInt32Item( ATTR_ROTATE_VALUE, nRotVal ) );
2183 else
2184 throw lang::IllegalArgumentException();
2186 break;
2187 case ATTR_STACKED:
2189 table::CellOrientation eOrient;
2190 if( rValue >>= eOrient )
2192 switch( eOrient )
2194 case table::CellOrientation_STANDARD:
2195 rSet.Put( SfxBoolItem( ATTR_STACKED, false ) );
2196 break;
2197 case table::CellOrientation_TOPBOTTOM:
2198 rSet.Put( SfxBoolItem( ATTR_STACKED, false ) );
2199 rSet.Put( SfxInt32Item( ATTR_ROTATE_VALUE, 27000 ) );
2200 rSecondItemId = ATTR_ROTATE_VALUE;
2201 break;
2202 case table::CellOrientation_BOTTOMTOP:
2203 rSet.Put( SfxBoolItem( ATTR_STACKED, false ) );
2204 rSet.Put( SfxInt32Item( ATTR_ROTATE_VALUE, 9000 ) );
2205 rSecondItemId = ATTR_ROTATE_VALUE;
2206 break;
2207 case table::CellOrientation_STACKED:
2208 rSet.Put( SfxBoolItem( ATTR_STACKED, true ) );
2209 break;
2210 default:
2212 // added to avoid warnings
2217 break;
2218 default:
2220 lcl_GetCellsPropertySet()->setPropertyValue(rEntry, rValue, rSet);
2225 void SAL_CALL ScCellRangesBase::setPropertyValue(
2226 const OUString& aPropertyName, const uno::Any& aValue )
2227 throw(beans::UnknownPropertyException, beans::PropertyVetoException,
2228 lang::IllegalArgumentException, lang::WrappedTargetException,
2229 uno::RuntimeException, std::exception)
2231 SolarMutexGuard aGuard;
2233 if ( !pDocShell || aRanges.empty() )
2234 throw uno::RuntimeException();
2236 const SfxItemPropertyMap& rPropertyMap = GetItemPropertyMap(); // from derived class
2237 const SfxItemPropertySimpleEntry* pEntry = rPropertyMap.getByName( aPropertyName );
2238 if ( !pEntry )
2239 throw beans::UnknownPropertyException();
2241 SetOnePropertyValue( pEntry, aValue );
2244 void ScCellRangesBase::SetOnePropertyValue( const SfxItemPropertySimpleEntry* pEntry, const uno::Any& aValue )
2245 throw(lang::IllegalArgumentException, uno::RuntimeException, std::exception)
2247 if ( pEntry )
2249 if ( IsScItemWid( pEntry->nWID ) )
2251 if ( !aRanges.empty() ) // leer = nichts zu tun
2253 ScDocument* pDoc = pDocShell->GetDocument();
2255 // Fuer Teile von zusammengesetzten Items mit mehreren Properties (z.B. Hintergrund)
2256 // muss vorher das alte Item aus dem Dokument geholt werden
2257 //! Das kann hier aber nicht erkannt werden
2258 //! -> eigenes Flag im PropertyMap-Eintrag, oder was ???
2259 //! Item direkt von einzelner Position im Bereich holen?
2260 // ClearInvalidItems, damit auf jeden Fall ein Item vom richtigen Typ da ist
2262 ScPatternAttr aPattern( *GetCurrentAttrsDeep() );
2263 SfxItemSet& rSet = aPattern.GetItemSet();
2264 rSet.ClearInvalidItems();
2266 sal_uInt16 nFirstItem, nSecondItem;
2267 lcl_SetCellProperty( *pEntry, aValue, aPattern, pDoc, nFirstItem, nSecondItem );
2269 for (sal_uInt16 nWhich = ATTR_PATTERN_START; nWhich <= ATTR_PATTERN_END; nWhich++)
2270 if ( nWhich != nFirstItem && nWhich != nSecondItem )
2271 rSet.ClearItem(nWhich);
2273 pDocShell->GetDocFunc().ApplyAttributes( *GetMarkData(), aPattern, true, true );
2276 else // implemented here
2277 switch ( pEntry->nWID )
2279 case EE_CHAR_ESCAPEMENT: // Specifically for xlsx import
2281 sal_Int32 nValue = 0;
2282 aValue >>= nValue;
2283 if (nValue)
2285 for (size_t i = 0, n = aRanges.size(); i < n; ++i)
2287 ScRange aRange = *aRanges[i];
2289 /* TODO: Iterate through the range */
2290 ScAddress aAddr = aRange.aStart;
2291 ScDocument *pDoc = pDocShell->GetDocument();
2292 ScRefCellValue aCell;
2293 aCell.assign(*pDoc, aAddr);
2295 OUString aStr = aCell.getString(pDoc);
2296 EditEngine aEngine( pDoc->GetEnginePool() );
2297 aEngine.SetEditTextObjectPool(pDoc->GetEditPool());
2299 /* EE_CHAR_ESCAPEMENT seems to be set on the cell _only_ when
2300 * there are no other attribs for the cell.
2301 * So, it is safe to overwrite the complete attribute set.
2302 * If there is a need - getting CellType and processing
2303 * the attributes could be considered.
2305 SfxItemSet aAttr = aEngine.GetEmptyItemSet();
2306 aEngine.SetText(aStr);
2307 if( nValue < 0 ) // Subscript
2308 aAttr.Put( SvxEscapementItem( SVX_ESCAPEMENT_SUBSCRIPT, EE_CHAR_ESCAPEMENT ) );
2309 else // Superscript
2310 aAttr.Put( SvxEscapementItem( SVX_ESCAPEMENT_SUPERSCRIPT, EE_CHAR_ESCAPEMENT ) );
2311 aEngine.QuickSetAttribs(aAttr, ESelection(0, 0, 0, aStr.getLength()));
2313 // The cell will own the text object instance.
2314 pDoc->SetEditText(aRanges[0]->aStart, aEngine.CreateTextObject());
2318 break;
2319 case SC_WID_UNO_CHCOLHDR:
2320 // chart header flags are set for this object, not stored with document
2321 bChartColAsHdr = ScUnoHelpFunctions::GetBoolFromAny( aValue );
2322 break;
2323 case SC_WID_UNO_CHROWHDR:
2324 bChartRowAsHdr = ScUnoHelpFunctions::GetBoolFromAny( aValue );
2325 break;
2326 case SC_WID_UNO_CELLSTYL:
2328 OUString aStrVal;
2329 aValue >>= aStrVal;
2330 OUString aString(ScStyleNameConversion::ProgrammaticToDisplayName(
2331 aStrVal, SFX_STYLE_FAMILY_PARA ));
2332 pDocShell->GetDocFunc().ApplyStyle( *GetMarkData(), aString, true, true );
2334 break;
2335 case SC_WID_UNO_TBLBORD:
2337 table::TableBorder aBorder;
2338 if ( !aRanges.empty() && ( aValue >>= aBorder ) ) // empty = nothing to do
2340 SvxBoxItem aOuter(ATTR_BORDER);
2341 SvxBoxInfoItem aInner(ATTR_BORDER_INNER);
2342 ScHelperFunctions::FillBoxItems( aOuter, aInner, aBorder );
2344 ScHelperFunctions::ApplyBorder( pDocShell, aRanges, aOuter, aInner ); //! docfunc
2347 break;
2348 case SC_WID_UNO_TBLBORD2:
2350 table::TableBorder2 aBorder2;
2351 if ( !aRanges.empty() && ( aValue >>= aBorder2 ) ) // empty = nothing to do
2353 SvxBoxItem aOuter(ATTR_BORDER);
2354 SvxBoxInfoItem aInner(ATTR_BORDER_INNER);
2355 ScHelperFunctions::FillBoxItems( aOuter, aInner, aBorder2 );
2357 ScHelperFunctions::ApplyBorder( pDocShell, aRanges, aOuter, aInner ); //! docfunc
2360 break;
2361 case SC_WID_UNO_CONDFMT:
2362 case SC_WID_UNO_CONDLOC:
2363 case SC_WID_UNO_CONDXML:
2365 uno::Reference<sheet::XSheetConditionalEntries> xInterface(aValue, uno::UNO_QUERY);
2366 if ( !aRanges.empty() && xInterface.is() ) // leer = nichts zu tun
2368 ScTableConditionalFormat* pFormat =
2369 ScTableConditionalFormat::getImplementation( xInterface );
2370 if (pFormat)
2372 ScDocument* pDoc = pDocShell->GetDocument();
2373 bool bEnglish = ( pEntry->nWID != SC_WID_UNO_CONDLOC );
2374 bool bXML = ( pEntry->nWID == SC_WID_UNO_CONDXML );
2375 formula::FormulaGrammar::Grammar eGrammar = (bXML ?
2376 formula::FormulaGrammar::GRAM_UNSPECIFIED :
2377 formula::FormulaGrammar::mapAPItoGrammar( bEnglish, bXML));
2379 ScConditionalFormat* pNew = new ScConditionalFormat( 0, pDoc ); // Index wird beim Einfuegen gesetzt
2380 pFormat->FillFormat( *pNew, pDoc, eGrammar );
2381 pNew->AddRange( aRanges );
2382 SCTAB nTab = aRanges.front()->aStart.Tab();
2383 pDocShell->GetDocFunc().ReplaceConditionalFormat( 0, pNew, nTab, aRanges );
2387 break;
2388 case SC_WID_UNO_VALIDAT:
2389 case SC_WID_UNO_VALILOC:
2390 case SC_WID_UNO_VALIXML:
2392 uno::Reference<beans::XPropertySet> xInterface(aValue, uno::UNO_QUERY);
2393 if ( !aRanges.empty() && xInterface.is() ) // leer = nichts zu tun
2395 ScTableValidationObj* pValidObj =
2396 ScTableValidationObj::getImplementation( xInterface );
2397 if (pValidObj)
2399 ScDocument* pDoc = pDocShell->GetDocument();
2400 bool bEnglish = ( pEntry->nWID != SC_WID_UNO_VALILOC );
2401 bool bXML = ( pEntry->nWID == SC_WID_UNO_VALIXML );
2402 formula::FormulaGrammar::Grammar eGrammar = (bXML ?
2403 formula::FormulaGrammar::GRAM_UNSPECIFIED :
2404 formula::FormulaGrammar::mapAPItoGrammar( bEnglish, bXML));
2406 boost::scoped_ptr<ScValidationData> pNewData(
2407 pValidObj->CreateValidationData( pDoc, eGrammar ));
2408 sal_uLong nIndex = pDoc->AddValidationEntry( *pNewData );
2409 pNewData.reset();
2411 ScPatternAttr aPattern( pDoc->GetPool() );
2412 aPattern.GetItemSet().Put( SfxUInt32Item( ATTR_VALIDDATA, nIndex ) );
2413 pDocShell->GetDocFunc().ApplyAttributes( *GetMarkData(), aPattern, true, true );
2417 break;
2418 // SC_WID_UNO_NUMRULES is ignored...
2423 uno::Any SAL_CALL ScCellRangesBase::getPropertyValue( const OUString& aPropertyName )
2424 throw(beans::UnknownPropertyException, lang::WrappedTargetException,
2425 uno::RuntimeException, std::exception)
2427 SolarMutexGuard aGuard;
2429 if ( !pDocShell || aRanges.empty() )
2430 throw uno::RuntimeException();
2432 const SfxItemPropertyMap& rPropertyMap = GetItemPropertyMap(); // from derived class
2433 const SfxItemPropertySimpleEntry* pEntry = rPropertyMap.getByName( aPropertyName );
2434 if ( !pEntry )
2435 throw beans::UnknownPropertyException();
2437 uno::Any aAny;
2438 GetOnePropertyValue( pEntry, aAny );
2439 return aAny;
2442 void ScCellRangesBase::GetOnePropertyValue( const SfxItemPropertySimpleEntry* pEntry, uno::Any& rAny )
2443 throw(uno::RuntimeException, std::exception)
2445 if ( pEntry )
2447 if ( IsScItemWid( pEntry->nWID ) )
2449 SfxItemSet* pDataSet = GetCurrentDataSet();
2450 if ( pDataSet )
2452 switch ( pEntry->nWID ) // fuer Item-Spezial-Behandlungen
2454 case ATTR_VALUE_FORMAT:
2456 ScDocument* pDoc = pDocShell->GetDocument();
2458 sal_uLong nOldFormat = ((const SfxUInt32Item&)
2459 pDataSet->Get( ATTR_VALUE_FORMAT )).GetValue();
2460 LanguageType eOldLang = ((const SvxLanguageItem&)
2461 pDataSet->Get( ATTR_LANGUAGE_FORMAT )).GetLanguage();
2462 nOldFormat = pDoc->GetFormatTable()->
2463 GetFormatForLanguageIfBuiltIn( nOldFormat, eOldLang );
2464 rAny <<= (sal_Int32)( nOldFormat );
2466 break;
2467 case ATTR_INDENT:
2468 rAny <<= (sal_Int16)( TwipsToHMM(((const SfxUInt16Item&)
2469 pDataSet->Get(pEntry->nWID)).GetValue()) );
2470 break;
2471 case ATTR_STACKED:
2473 sal_Int32 nRot = ((const SfxInt32Item&)pDataSet->Get(ATTR_ROTATE_VALUE)).GetValue();
2474 bool bStacked = ((const SfxBoolItem&)pDataSet->Get(pEntry->nWID)).GetValue();
2475 SvxOrientationItem( nRot, bStacked, 0 ).QueryValue( rAny );
2477 break;
2478 default:
2479 pPropSet->getPropertyValue(*pEntry, *pDataSet, rAny);
2483 else // implemented here
2484 switch ( pEntry->nWID )
2486 case SC_WID_UNO_CHCOLHDR:
2487 ScUnoHelpFunctions::SetBoolInAny( rAny, bChartColAsHdr );
2488 break;
2489 case SC_WID_UNO_CHROWHDR:
2490 ScUnoHelpFunctions::SetBoolInAny( rAny, bChartRowAsHdr );
2491 break;
2492 case SC_WID_UNO_CELLSTYL:
2494 OUString aStyleName;
2495 const ScStyleSheet* pStyle = pDocShell->GetDocument()->GetSelectionStyle(*GetMarkData());
2496 if (pStyle)
2497 aStyleName = pStyle->GetName();
2498 rAny <<= OUString( ScStyleNameConversion::DisplayToProgrammaticName(
2499 aStyleName, SFX_STYLE_FAMILY_PARA ) );
2501 break;
2502 case SC_WID_UNO_TBLBORD:
2503 case SC_WID_UNO_TBLBORD2:
2505 //! loop throgh all ranges
2506 if ( !aRanges.empty() )
2508 const ScRange* pFirst = aRanges[ 0 ];
2509 SvxBoxItem aOuter(ATTR_BORDER);
2510 SvxBoxInfoItem aInner(ATTR_BORDER_INNER);
2512 ScDocument* pDoc = pDocShell->GetDocument();
2513 ScMarkData aMark;
2514 aMark.SetMarkArea( *pFirst );
2515 aMark.SelectTable( pFirst->aStart.Tab(), true );
2516 pDoc->GetSelectionFrame( aMark, aOuter, aInner );
2518 if (pEntry->nWID == SC_WID_UNO_TBLBORD2)
2519 ScHelperFunctions::AssignTableBorder2ToAny( rAny, aOuter, aInner);
2520 else
2521 ScHelperFunctions::AssignTableBorderToAny( rAny, aOuter, aInner);
2524 break;
2525 case SC_WID_UNO_CONDFMT:
2526 case SC_WID_UNO_CONDLOC:
2527 case SC_WID_UNO_CONDXML:
2529 const ScPatternAttr* pPattern = GetCurrentAttrsDeep();
2530 if ( pPattern )
2532 ScDocument* pDoc = pDocShell->GetDocument();
2533 bool bEnglish = ( pEntry->nWID != SC_WID_UNO_CONDLOC );
2534 bool bXML = ( pEntry->nWID == SC_WID_UNO_CONDXML );
2535 formula::FormulaGrammar::Grammar eGrammar = (bXML ?
2536 pDoc->GetStorageGrammar() :
2537 formula::FormulaGrammar::mapAPItoGrammar( bEnglish, bXML));
2538 const std::vector<sal_uInt32>& rIndex = ((const ScCondFormatItem&)
2539 pPattern->GetItem(ATTR_CONDITIONAL)).GetCondFormatData();
2540 sal_uLong nIndex = 0;
2541 if(!rIndex.empty())
2542 nIndex = rIndex[0];
2543 rAny <<= uno::Reference<sheet::XSheetConditionalEntries>(
2544 new ScTableConditionalFormat( pDoc, nIndex, aRanges.front()->aStart.Tab(), eGrammar ));
2547 break;
2548 case SC_WID_UNO_VALIDAT:
2549 case SC_WID_UNO_VALILOC:
2550 case SC_WID_UNO_VALIXML:
2552 const ScPatternAttr* pPattern = GetCurrentAttrsDeep();
2553 if ( pPattern )
2555 ScDocument* pDoc = pDocShell->GetDocument();
2556 bool bEnglish = ( pEntry->nWID != SC_WID_UNO_VALILOC );
2557 bool bXML = ( pEntry->nWID == SC_WID_UNO_VALIXML );
2558 formula::FormulaGrammar::Grammar eGrammar = (bXML ?
2559 pDoc->GetStorageGrammar() :
2560 formula::FormulaGrammar::mapAPItoGrammar( bEnglish, bXML));
2561 sal_uLong nIndex = ((const SfxUInt32Item&)
2562 pPattern->GetItem(ATTR_VALIDDATA)).GetValue();
2563 rAny <<= uno::Reference<beans::XPropertySet>(
2564 new ScTableValidationObj( pDoc, nIndex, eGrammar ));
2567 break;
2568 case SC_WID_UNO_NUMRULES:
2570 // always return empty numbering rules object
2571 rAny <<= uno::Reference<container::XIndexReplace>(ScStyleObj::CreateEmptyNumberingRules());
2573 break;
2574 case SC_WID_UNO_ABSNAME:
2576 OUString sRet;
2577 aRanges.Format(sRet, SCR_ABS_3D, pDocShell->GetDocument());
2578 rAny <<= sRet;
2584 void SAL_CALL ScCellRangesBase::addPropertyChangeListener( const OUString& /* aPropertyName */,
2585 const uno::Reference<beans::XPropertyChangeListener>& /* aListener */)
2586 throw(beans::UnknownPropertyException,
2587 lang::WrappedTargetException, uno::RuntimeException, std::exception)
2589 SolarMutexGuard aGuard;
2590 if ( aRanges.empty() )
2591 throw uno::RuntimeException();
2593 OSL_FAIL("not implemented");
2596 void SAL_CALL ScCellRangesBase::removePropertyChangeListener( const OUString& /* aPropertyName */,
2597 const uno::Reference<beans::XPropertyChangeListener>& /* aListener */)
2598 throw(beans::UnknownPropertyException,
2599 lang::WrappedTargetException, uno::RuntimeException, std::exception)
2601 SolarMutexGuard aGuard;
2602 if ( aRanges.empty() )
2603 throw uno::RuntimeException();
2605 OSL_FAIL("not implemented");
2608 void SAL_CALL ScCellRangesBase::addVetoableChangeListener( const OUString&,
2609 const uno::Reference<beans::XVetoableChangeListener>&)
2610 throw(beans::UnknownPropertyException,
2611 lang::WrappedTargetException, uno::RuntimeException, std::exception)
2613 OSL_FAIL("not implemented");
2616 void SAL_CALL ScCellRangesBase::removeVetoableChangeListener( const OUString&,
2617 const uno::Reference<beans::XVetoableChangeListener>&)
2618 throw(beans::UnknownPropertyException,
2619 lang::WrappedTargetException, uno::RuntimeException, std::exception)
2621 OSL_FAIL("not implemented");
2624 // XMultiPropertySet
2626 void SAL_CALL ScCellRangesBase::setPropertyValues( const uno::Sequence< OUString >& aPropertyNames,
2627 const uno::Sequence< uno::Any >& aValues )
2628 throw (beans::PropertyVetoException,
2629 lang::IllegalArgumentException,
2630 lang::WrappedTargetException,
2631 uno::RuntimeException, std::exception)
2633 SolarMutexGuard aGuard;
2635 sal_Int32 nCount(aPropertyNames.getLength());
2636 sal_Int32 nValues(aValues.getLength());
2637 if (nCount != nValues)
2638 throw lang::IllegalArgumentException();
2640 if ( pDocShell && nCount )
2642 const SfxItemPropertyMap& rPropertyMap = GetItemPropertyMap(); // from derived class
2643 const OUString* pNames = aPropertyNames.getConstArray();
2644 const uno::Any* pValues = aValues.getConstArray();
2646 boost::scoped_array<const SfxItemPropertySimpleEntry*> pEntryArray(new const SfxItemPropertySimpleEntry*[nCount]);
2648 sal_Int32 i;
2649 for(i = 0; i < nCount; i++)
2651 // first loop: find all properties in map, but handle only CellStyle
2652 // (CellStyle must be set before any other cell properties)
2654 const SfxItemPropertySimpleEntry* pEntry = rPropertyMap.getByName( pNames[i] );
2655 pEntryArray[i] = pEntry;
2656 if (pEntry)
2658 if ( pEntry->nWID == SC_WID_UNO_CELLSTYL )
2662 SetOnePropertyValue( pEntry, pValues[i] );
2664 catch ( lang::IllegalArgumentException& )
2666 OSL_FAIL("exception when setting cell style"); // not supposed to happen
2672 ScDocument* pDoc = pDocShell->GetDocument();
2673 boost::scoped_ptr<ScPatternAttr> pOldPattern;
2674 boost::scoped_ptr<ScPatternAttr> pNewPattern;
2676 for(i = 0; i < nCount; i++)
2678 // second loop: handle other properties
2680 const SfxItemPropertySimpleEntry* pEntry = pEntryArray[i];
2681 if ( pEntry )
2683 if ( IsScItemWid( pEntry->nWID ) ) // can be handled by SfxItemPropertySet
2685 if ( !pOldPattern )
2687 pOldPattern.reset(new ScPatternAttr( *GetCurrentAttrsDeep() ));
2688 pOldPattern->GetItemSet().ClearInvalidItems();
2689 pNewPattern.reset(new ScPatternAttr( pDoc->GetPool() ));
2692 // collect items in pNewPattern, apply with one call after the loop
2694 sal_uInt16 nFirstItem, nSecondItem;
2695 lcl_SetCellProperty( *pEntry, pValues[i], *pOldPattern, pDoc, nFirstItem, nSecondItem );
2697 // put only affected items into new set
2698 if ( nFirstItem )
2699 pNewPattern->GetItemSet().Put( pOldPattern->GetItemSet().Get( nFirstItem ) );
2700 if ( nSecondItem )
2701 pNewPattern->GetItemSet().Put( pOldPattern->GetItemSet().Get( nSecondItem ) );
2703 else if ( pEntry->nWID != SC_WID_UNO_CELLSTYL ) // CellStyle is handled above
2705 // call virtual method to set a single property
2706 SetOnePropertyValue( pEntry, pValues[i] );
2711 if ( pNewPattern && !aRanges.empty() )
2712 pDocShell->GetDocFunc().ApplyAttributes( *GetMarkData(), *pNewPattern, true, true );
2716 uno::Sequence<uno::Any> SAL_CALL ScCellRangesBase::getPropertyValues(
2717 const uno::Sequence< OUString >& aPropertyNames )
2718 throw (uno::RuntimeException, std::exception)
2720 SolarMutexGuard aGuard;
2722 const SfxItemPropertyMap& rPropertyMap = GetItemPropertyMap(); // from derived class
2724 uno::Sequence<uno::Any> aRet(aPropertyNames.getLength());
2725 uno::Any* pProperties = aRet.getArray();
2726 for(sal_Int32 i = 0; i < aPropertyNames.getLength(); i++)
2728 const SfxItemPropertySimpleEntry* pEntry = rPropertyMap.getByName( aPropertyNames[i] );
2729 GetOnePropertyValue( pEntry, pProperties[i] );
2731 return aRet;
2734 void SAL_CALL ScCellRangesBase::addPropertiesChangeListener( const uno::Sequence< OUString >& /* aPropertyNames */,
2735 const uno::Reference< beans::XPropertiesChangeListener >& /* xListener */ )
2736 throw (uno::RuntimeException, std::exception)
2738 OSL_FAIL("not implemented");
2741 void SAL_CALL ScCellRangesBase::removePropertiesChangeListener( const uno::Reference< beans::XPropertiesChangeListener >& /* xListener */ )
2742 throw (uno::RuntimeException, std::exception)
2744 OSL_FAIL("not implemented");
2747 void SAL_CALL ScCellRangesBase::firePropertiesChangeEvent( const uno::Sequence< OUString >& /* aPropertyNames */,
2748 const uno::Reference< beans::XPropertiesChangeListener >& /* xListener */ )
2749 throw (uno::RuntimeException, std::exception)
2751 OSL_FAIL("not implemented");
2754 IMPL_LINK( ScCellRangesBase, ValueListenerHdl, SfxHint*, pHint )
2756 if ( pDocShell && pHint && pHint->ISA( SfxSimpleHint ) &&
2757 (((const SfxSimpleHint*)pHint)->GetId() & SC_HINT_DATACHANGED))
2759 // This may be called several times for a single change, if several formulas
2760 // in the range are notified. So only a flag is set that is checked when
2761 // SFX_HINT_DATACHANGED is received.
2763 bGotDataChangedHint = true;
2765 return 0;
2768 // XTolerantMultiPropertySet
2769 uno::Sequence< beans::SetPropertyTolerantFailed > SAL_CALL ScCellRangesBase::setPropertyValuesTolerant( const uno::Sequence< OUString >& aPropertyNames,
2770 const uno::Sequence< uno::Any >& aValues )
2771 throw (lang::IllegalArgumentException, uno::RuntimeException, std::exception)
2773 SolarMutexGuard aGuard;
2775 sal_Int32 nCount(aPropertyNames.getLength());
2776 sal_Int32 nValues(aValues.getLength());
2777 if (nCount != nValues)
2778 throw lang::IllegalArgumentException();
2780 if ( pDocShell && nCount )
2782 uno::Sequence < beans::SetPropertyTolerantFailed > aReturns(nCount);
2783 beans::SetPropertyTolerantFailed* pReturns = aReturns.getArray();
2785 const SfxItemPropertyMap& rPropertyMap = GetItemPropertyMap(); // from derived class
2786 const OUString* pNames = aPropertyNames.getConstArray();
2787 const uno::Any* pValues = aValues.getConstArray();
2789 boost::scoped_array<const SfxItemPropertySimpleEntry*> pMapArray(new const SfxItemPropertySimpleEntry*[nCount]);
2791 sal_Int32 i;
2792 for(i = 0; i < nCount; i++)
2794 // first loop: find all properties in map, but handle only CellStyle
2795 // (CellStyle must be set before any other cell properties)
2797 const SfxItemPropertySimpleEntry* pEntry = rPropertyMap.getByName( pNames[i] );
2798 pMapArray[i] = pEntry;
2799 if (pEntry)
2801 if ( pEntry->nWID == SC_WID_UNO_CELLSTYL )
2805 SetOnePropertyValue( pEntry, pValues[i] );
2807 catch ( lang::IllegalArgumentException& )
2809 OSL_FAIL("exception when setting cell style"); // not supposed to happen
2815 ScDocument* pDoc = pDocShell->GetDocument();
2816 boost::scoped_ptr<ScPatternAttr> pOldPattern;
2817 boost::scoped_ptr<ScPatternAttr> pNewPattern;
2819 sal_Int32 nFailed(0);
2820 for(i = 0; i < nCount; i++)
2822 // second loop: handle other properties
2824 const SfxItemPropertySimpleEntry* pEntry = pMapArray[i];
2825 if ( pEntry && ((pEntry->nFlags & beans::PropertyAttribute::READONLY) == 0))
2827 if ( IsScItemWid( pEntry->nWID ) ) // can be handled by SfxItemPropertySet
2829 if ( !pOldPattern )
2831 pOldPattern.reset(new ScPatternAttr( *GetCurrentAttrsDeep() ));
2832 pOldPattern->GetItemSet().ClearInvalidItems();
2833 pNewPattern.reset(new ScPatternAttr( pDoc->GetPool() ));
2836 // collect items in pNewPattern, apply with one call after the loop
2838 sal_uInt16 nFirstItem, nSecondItem;
2841 lcl_SetCellProperty( *pEntry, pValues[i], *pOldPattern, pDoc, nFirstItem, nSecondItem );
2843 // put only affected items into new set
2844 if ( nFirstItem )
2845 pNewPattern->GetItemSet().Put( pOldPattern->GetItemSet().Get( nFirstItem ) );
2846 if ( nSecondItem )
2847 pNewPattern->GetItemSet().Put( pOldPattern->GetItemSet().Get( nSecondItem ) );
2849 catch ( lang::IllegalArgumentException& )
2851 pReturns[nFailed].Name = pNames[i];
2852 pReturns[nFailed++].Result = beans::TolerantPropertySetResultType::ILLEGAL_ARGUMENT;
2855 else if ( pEntry->nWID != SC_WID_UNO_CELLSTYL ) // CellStyle is handled above
2857 // call virtual method to set a single property
2860 SetOnePropertyValue( pEntry, pValues[i] );
2862 catch ( lang::IllegalArgumentException& )
2864 pReturns[nFailed].Name = pNames[i];
2865 pReturns[nFailed++].Result = beans::TolerantPropertySetResultType::ILLEGAL_ARGUMENT;
2869 else
2871 pReturns[nFailed].Name = pNames[i];
2872 if (pEntry)
2873 pReturns[nFailed++].Result = beans::TolerantPropertySetResultType::PROPERTY_VETO;
2874 else
2875 pReturns[nFailed++].Result = beans::TolerantPropertySetResultType::UNKNOWN_PROPERTY;
2879 if ( pNewPattern && !aRanges.empty() )
2880 pDocShell->GetDocFunc().ApplyAttributes( *GetMarkData(), *pNewPattern, true, true );
2882 aReturns.realloc(nFailed);
2884 return aReturns;
2886 return uno::Sequence < beans::SetPropertyTolerantFailed >();
2889 uno::Sequence< beans::GetPropertyTolerantResult > SAL_CALL ScCellRangesBase::getPropertyValuesTolerant( const uno::Sequence< OUString >& aPropertyNames )
2890 throw (uno::RuntimeException, std::exception)
2892 SolarMutexGuard aGuard;
2894 sal_Int32 nCount(aPropertyNames.getLength());
2895 uno::Sequence < beans::GetPropertyTolerantResult > aReturns(nCount);
2896 beans::GetPropertyTolerantResult* pReturns = aReturns.getArray();
2898 const SfxItemPropertyMap& rPropertyMap = GetItemPropertyMap(); // from derived class
2900 for(sal_Int32 i = 0; i < nCount; i++)
2902 const SfxItemPropertySimpleEntry* pEntry = rPropertyMap.getByName( aPropertyNames[i] );
2903 if (!pEntry)
2905 pReturns[i].Result = beans::TolerantPropertySetResultType::UNKNOWN_PROPERTY;
2907 else
2909 sal_uInt16 nItemWhich = 0;
2910 lcl_GetPropertyWhich( pEntry, nItemWhich );
2911 pReturns[i].State = GetOnePropertyState( nItemWhich, pEntry );
2912 GetOnePropertyValue( pEntry, pReturns[i].Value );
2913 pReturns[i].Result = beans::TolerantPropertySetResultType::SUCCESS;
2916 return aReturns;
2919 uno::Sequence< beans::GetDirectPropertyTolerantResult > SAL_CALL ScCellRangesBase::getDirectPropertyValuesTolerant( const uno::Sequence< OUString >& aPropertyNames )
2920 throw (uno::RuntimeException, std::exception)
2922 SolarMutexGuard aGuard;
2924 sal_Int32 nCount(aPropertyNames.getLength());
2925 uno::Sequence < beans::GetDirectPropertyTolerantResult > aReturns(nCount);
2926 beans::GetDirectPropertyTolerantResult* pReturns = aReturns.getArray();
2928 const SfxItemPropertyMap& rPropertyMap = GetItemPropertyMap(); // from derived class
2930 sal_Int32 j = 0;
2931 for(sal_Int32 i = 0; i < nCount; i++)
2933 const SfxItemPropertySimpleEntry* pEntry = rPropertyMap.getByName( aPropertyNames[i] );
2934 if (!pEntry)
2936 pReturns[i].Result = beans::TolerantPropertySetResultType::UNKNOWN_PROPERTY;
2938 else
2940 sal_uInt16 nItemWhich = 0;
2941 lcl_GetPropertyWhich( pEntry, nItemWhich );
2942 pReturns[j].State = GetOnePropertyState( nItemWhich, pEntry );
2943 if (pReturns[j].State == beans::PropertyState_DIRECT_VALUE)
2945 GetOnePropertyValue( pEntry, pReturns[j].Value );
2946 pReturns[j].Result = beans::TolerantPropertySetResultType::SUCCESS;
2947 pReturns[j].Name = aPropertyNames[i];
2948 ++j;
2952 if (j < nCount)
2953 aReturns.realloc(j);
2954 return aReturns;
2957 // XIndent
2959 void SAL_CALL ScCellRangesBase::decrementIndent() throw(::com::sun::star::uno::RuntimeException, std::exception)
2961 SolarMutexGuard aGuard;
2962 if ( pDocShell && !aRanges.empty() ) // leer = nichts zu tun
2964 //#97041#; put only MultiMarked ScMarkData in ChangeIndent
2965 ScMarkData aMarkData(*GetMarkData());
2966 aMarkData.MarkToMulti();
2967 pDocShell->GetDocFunc().ChangeIndent( aMarkData, false, true );
2971 void SAL_CALL ScCellRangesBase::incrementIndent() throw(::com::sun::star::uno::RuntimeException, std::exception)
2973 SolarMutexGuard aGuard;
2974 if ( pDocShell && !aRanges.empty() ) // leer = nichts zu tun
2976 //#97041#; put only MultiMarked ScMarkData in ChangeIndent
2977 ScMarkData aMarkData(*GetMarkData());
2978 aMarkData.MarkToMulti();
2979 pDocShell->GetDocFunc().ChangeIndent( aMarkData, true, true );
2983 // XChartData
2985 ScMemChart* ScCellRangesBase::CreateMemChart_Impl() const
2987 if ( pDocShell && !aRanges.empty() )
2989 ScRangeListRef xChartRanges;
2990 if ( aRanges.size() == 1 )
2992 // ganze Tabelle sinnvoll begrenzen (auf belegten Datenbereich)
2993 // (nur hier, Listener werden auf den ganzen Bereich angemeldet)
2994 //! direkt testen, ob es ein ScTableSheetObj ist?
2996 const ScRange* pRange = aRanges[0];
2997 if ( pRange->aStart.Col() == 0 && pRange->aEnd.Col() == MAXCOL &&
2998 pRange->aStart.Row() == 0 && pRange->aEnd.Row() == MAXROW )
3000 SCTAB nTab = pRange->aStart.Tab();
3002 SCCOL nStartX;
3003 SCROW nStartY; // Anfang holen
3004 if (!pDocShell->GetDocument()->GetDataStart( nTab, nStartX, nStartY ))
3006 nStartX = 0;
3007 nStartY = 0;
3010 SCCOL nEndX;
3011 SCROW nEndY; // Ende holen
3012 if (!pDocShell->GetDocument()->GetTableArea( nTab, nEndX, nEndY ))
3014 nEndX = 0;
3015 nEndY = 0;
3018 xChartRanges = new ScRangeList;
3019 xChartRanges->Append( ScRange( nStartX, nStartY, nTab, nEndX, nEndY, nTab ) );
3022 if (!xChartRanges.Is()) // sonst Ranges direkt uebernehmen
3023 xChartRanges = new ScRangeList(aRanges);
3024 ScChartArray aArr( pDocShell->GetDocument(), xChartRanges, OUString() );
3026 // RowAsHdr = ColHeaders und umgekehrt
3027 aArr.SetHeaders( bChartRowAsHdr, bChartColAsHdr );
3029 return aArr.CreateMemChart();
3031 return NULL;
3034 uno::Sequence< uno::Sequence<double> > SAL_CALL ScCellRangesBase::getData()
3035 throw(uno::RuntimeException, std::exception)
3037 SolarMutexGuard aGuard;
3038 boost::scoped_ptr<ScMemChart> pMemChart(CreateMemChart_Impl());
3039 if ( pMemChart )
3041 sal_Int32 nColCount = pMemChart->GetColCount();
3042 sal_Int32 nRowCount = static_cast<sal_Int32>(pMemChart->GetRowCount());
3044 uno::Sequence< uno::Sequence<double> > aRowSeq( nRowCount );
3045 uno::Sequence<double>* pRowAry = aRowSeq.getArray();
3046 for (sal_Int32 nRow = 0; nRow < nRowCount; nRow++)
3048 uno::Sequence<double> aColSeq( nColCount );
3049 double* pColAry = aColSeq.getArray();
3050 for (sal_Int32 nCol = 0; nCol < nColCount; nCol++)
3051 pColAry[nCol] = pMemChart->GetData( nCol, nRow );
3053 pRowAry[nRow] = aColSeq;
3056 return aRowSeq;
3059 return uno::Sequence< uno::Sequence<double> >(0);
3062 ScRangeListRef ScCellRangesBase::GetLimitedChartRanges_Impl( long nDataColumns, long nDataRows ) const
3064 if ( aRanges.size() == 1 )
3066 const ScRange* pRange = aRanges[0];
3067 if ( pRange->aStart.Col() == 0 && pRange->aEnd.Col() == MAXCOL &&
3068 pRange->aStart.Row() == 0 && pRange->aEnd.Row() == MAXROW )
3070 // if aRanges is a complete sheet, limit to given size
3072 SCTAB nTab = pRange->aStart.Tab();
3074 long nEndColumn = nDataColumns - 1 + ( bChartColAsHdr ? 1 : 0 );
3075 if ( nEndColumn < 0 )
3076 nEndColumn = 0;
3077 if ( nEndColumn > MAXCOL )
3078 nEndColumn = MAXCOL;
3080 long nEndRow = nDataRows - 1 + ( bChartRowAsHdr ? 1 : 0 );
3081 if ( nEndRow < 0 )
3082 nEndRow = 0;
3083 if ( nEndRow > MAXROW )
3084 nEndRow = MAXROW;
3086 ScRangeListRef xChartRanges = new ScRangeList;
3087 xChartRanges->Append( ScRange( 0, 0, nTab, (SCCOL)nEndColumn, (SCROW)nEndRow, nTab ) );
3088 return xChartRanges;
3092 return new ScRangeList(aRanges); // as-is
3095 void SAL_CALL ScCellRangesBase::setData( const uno::Sequence< uno::Sequence<double> >& aData )
3096 throw(uno::RuntimeException, std::exception)
3098 SolarMutexGuard aGuard;
3099 bool bDone = false;
3100 long nRowCount = aData.getLength();
3101 long nColCount = nRowCount ? aData[0].getLength() : 0;
3102 ScRangeListRef xChartRanges = GetLimitedChartRanges_Impl( nColCount, nRowCount );
3103 if ( pDocShell && xChartRanges.Is() )
3105 ScDocument* pDoc = pDocShell->GetDocument();
3106 ScChartArray aArr( pDoc, xChartRanges, OUString() );
3107 aArr.SetHeaders( bChartRowAsHdr, bChartColAsHdr ); // RowAsHdr = ColHeaders
3108 const ScChartPositionMap* pPosMap = aArr.GetPositionMap();
3109 if (pPosMap)
3111 if ( pPosMap->GetColCount() == static_cast<SCCOL>(nColCount) &&
3112 pPosMap->GetRowCount() == static_cast<SCROW>(nRowCount) )
3114 for (long nRow=0; nRow<nRowCount; nRow++)
3116 const uno::Sequence<double>& rRowSeq = aData[nRow];
3117 const double* pArray = rRowSeq.getConstArray();
3118 nColCount = rRowSeq.getLength();
3119 for (long nCol=0; nCol<nColCount; nCol++)
3121 const ScAddress* pPos = pPosMap->GetPosition(
3122 sal::static_int_cast<SCCOL>(nCol),
3123 sal::static_int_cast<SCROW>(nRow) );
3124 if (pPos)
3126 double fVal = pArray[nCol];
3127 if ( fVal == DBL_MIN )
3128 pDoc->SetEmptyCell(*pPos);
3129 else
3130 pDoc->SetValue(*pPos, pArray[nCol]);
3135 //! undo
3136 PaintRanges_Impl( PAINT_GRID );
3137 pDocShell->SetDocumentModified();
3138 ForceChartListener_Impl(); // call listeners for this object synchronously
3139 bDone = true;
3144 if (!bDone)
3145 throw uno::RuntimeException();
3148 uno::Sequence<OUString> SAL_CALL ScCellRangesBase::getRowDescriptions()
3149 throw(uno::RuntimeException, std::exception)
3151 SolarMutexGuard aGuard;
3152 boost::scoped_ptr<ScMemChart> pMemChart(CreateMemChart_Impl());
3153 if ( pMemChart )
3155 sal_Int32 nRowCount = static_cast<sal_Int32>(pMemChart->GetRowCount());
3156 uno::Sequence<OUString> aSeq( nRowCount );
3157 OUString* pAry = aSeq.getArray();
3158 for (sal_Int32 nRow = 0; nRow < nRowCount; nRow++)
3159 pAry[nRow] = pMemChart->GetRowText(nRow);
3161 return aSeq;
3163 return uno::Sequence<OUString>(0);
3166 void SAL_CALL ScCellRangesBase::setRowDescriptions(
3167 const uno::Sequence<OUString>& aRowDescriptions )
3168 throw(uno::RuntimeException, std::exception)
3170 SolarMutexGuard aGuard;
3171 bool bDone = false;
3172 if ( bChartColAsHdr )
3174 long nRowCount = aRowDescriptions.getLength();
3175 ScRangeListRef xChartRanges = GetLimitedChartRanges_Impl( 1, nRowCount );
3176 if ( pDocShell && xChartRanges.Is() )
3178 ScDocument* pDoc = pDocShell->GetDocument();
3179 ScChartArray aArr( pDoc, xChartRanges, OUString() );
3180 aArr.SetHeaders( bChartRowAsHdr, bChartColAsHdr ); // RowAsHdr = ColHeaders
3181 const ScChartPositionMap* pPosMap = aArr.GetPositionMap();
3182 if (pPosMap)
3184 if ( pPosMap->GetRowCount() == static_cast<SCROW>(nRowCount) )
3186 const OUString* pArray = aRowDescriptions.getConstArray();
3187 for (long nRow=0; nRow<nRowCount; nRow++)
3189 const ScAddress* pPos = pPosMap->GetRowHeaderPosition(
3190 static_cast<SCSIZE>(nRow) );
3191 if (pPos)
3193 const OUString& aStr = pArray[nRow];
3194 if (aStr.isEmpty())
3195 pDoc->SetEmptyCell(*pPos);
3196 else
3198 ScSetStringParam aParam;
3199 aParam.setTextInput();
3200 pDoc->SetString(*pPos, aStr, &aParam);
3205 //! undo
3206 PaintRanges_Impl( PAINT_GRID );
3207 pDocShell->SetDocumentModified();
3208 ForceChartListener_Impl(); // call listeners for this object synchronously
3209 bDone = true;
3215 if (!bDone)
3216 throw uno::RuntimeException();
3219 uno::Sequence<OUString> SAL_CALL ScCellRangesBase::getColumnDescriptions()
3220 throw(uno::RuntimeException, std::exception)
3222 SolarMutexGuard aGuard;
3223 boost::scoped_ptr<ScMemChart> pMemChart(CreateMemChart_Impl());
3224 if ( pMemChart )
3226 sal_Int32 nColCount = pMemChart->GetColCount();
3227 uno::Sequence<OUString> aSeq( nColCount );
3228 OUString* pAry = aSeq.getArray();
3229 for (sal_Int32 nCol = 0; nCol < nColCount; nCol++)
3230 pAry[nCol] = pMemChart->GetColText(nCol);
3232 return aSeq;
3234 return uno::Sequence<OUString>(0);
3237 void SAL_CALL ScCellRangesBase::setColumnDescriptions(
3238 const uno::Sequence<OUString>& aColumnDescriptions )
3239 throw(uno::RuntimeException, std::exception)
3241 SolarMutexGuard aGuard;
3242 bool bDone = false;
3243 if ( bChartRowAsHdr )
3245 long nColCount = aColumnDescriptions.getLength();
3246 ScRangeListRef xChartRanges = GetLimitedChartRanges_Impl( nColCount, 1 );
3247 if ( pDocShell && xChartRanges.Is() )
3249 ScDocument* pDoc = pDocShell->GetDocument();
3250 ScChartArray aArr( pDoc, xChartRanges, OUString() );
3251 aArr.SetHeaders( bChartRowAsHdr, bChartColAsHdr ); // RowAsHdr = ColHeaders
3252 const ScChartPositionMap* pPosMap = aArr.GetPositionMap();
3253 if (pPosMap)
3255 if ( pPosMap->GetColCount() == static_cast<SCCOL>(nColCount) )
3257 const OUString* pArray = aColumnDescriptions.getConstArray();
3258 for (long nCol=0; nCol<nColCount; nCol++)
3260 const ScAddress* pPos = pPosMap->GetColHeaderPosition(
3261 sal::static_int_cast<SCCOL>(nCol) );
3262 if (pPos)
3264 const OUString& aStr = pArray[nCol];
3265 if (aStr.isEmpty())
3266 pDoc->SetEmptyCell(*pPos);
3267 else
3269 ScSetStringParam aParam;
3270 aParam.setTextInput();
3271 pDoc->SetString(*pPos, aStr, &aParam);
3276 //! undo
3277 PaintRanges_Impl( PAINT_GRID );
3278 pDocShell->SetDocumentModified();
3279 ForceChartListener_Impl(); // call listeners for this object synchronously
3280 bDone = true;
3286 if (!bDone)
3287 throw uno::RuntimeException();
3290 void ScCellRangesBase::ForceChartListener_Impl()
3292 // call Update immediately so the caller to setData etc. can
3293 // regognize the listener call
3295 if (!pDocShell)
3296 return;
3298 ScChartListenerCollection* pColl = pDocShell->GetDocument()->GetChartListenerCollection();
3299 if (!pColl)
3300 return;
3302 ScChartListenerCollection::ListenersType& rListeners = pColl->getListeners();
3303 ScChartListenerCollection::ListenersType::iterator it = rListeners.begin(), itEnd = rListeners.end();
3304 for (; it != itEnd; ++it)
3306 ScChartListener* p = it->second;
3307 OSL_ASSERT(p);
3308 if (p->GetUnoSource() == static_cast<chart::XChartData*>(this) && p->IsDirty())
3309 p->Update();
3313 void SAL_CALL ScCellRangesBase::addChartDataChangeEventListener( const uno::Reference<
3314 chart::XChartDataChangeEventListener >& aListener )
3315 throw(uno::RuntimeException, std::exception)
3317 SolarMutexGuard aGuard;
3318 if ( pDocShell && !aRanges.empty() )
3320 //! auf doppelte testen?
3322 ScDocument* pDoc = pDocShell->GetDocument();
3323 ScRangeListRef aRangesRef( new ScRangeList(aRanges) );
3324 ScChartListenerCollection* pColl = pDoc->GetChartListenerCollection();
3325 OUString aName = pColl->getUniqueName(OUString("__Uno"));
3326 if (aName.isEmpty())
3327 // failed to create unique name.
3328 return;
3330 ScChartListener* pListener = new ScChartListener( aName, pDoc, aRangesRef );
3331 pListener->SetUno( aListener, this );
3332 pColl->insert( pListener );
3333 pListener->StartListeningTo();
3337 void SAL_CALL ScCellRangesBase::removeChartDataChangeEventListener( const uno::Reference<
3338 chart::XChartDataChangeEventListener >& aListener )
3339 throw (uno::RuntimeException, std::exception)
3341 SolarMutexGuard aGuard;
3342 if ( pDocShell && !aRanges.empty() )
3344 ScDocument* pDoc = pDocShell->GetDocument();
3345 ScChartListenerCollection* pColl = pDoc->GetChartListenerCollection();
3346 pColl->FreeUno( aListener, this );
3350 double SAL_CALL ScCellRangesBase::getNotANumber() throw(::com::sun::star::uno::RuntimeException, std::exception)
3352 // im ScChartArray wird DBL_MIN verwendet, weil das Chart es so will
3353 return DBL_MIN;
3356 sal_Bool SAL_CALL ScCellRangesBase::isNotANumber( double nNumber ) throw(uno::RuntimeException, std::exception)
3358 // im ScChartArray wird DBL_MIN verwendet, weil das Chart es so will
3359 return (nNumber == DBL_MIN);
3362 // XModifyBroadcaster
3364 void SAL_CALL ScCellRangesBase::addModifyListener(const uno::Reference<util::XModifyListener>& aListener)
3365 throw (uno::RuntimeException, std::exception)
3367 SolarMutexGuard aGuard;
3368 if ( aRanges.empty() )
3369 throw uno::RuntimeException();
3371 uno::Reference<util::XModifyListener> *pObj =
3372 new uno::Reference<util::XModifyListener>( aListener );
3373 aValueListeners.push_back( pObj );
3375 if ( aValueListeners.size() == 1 )
3377 if (!pValueListener)
3378 pValueListener = new ScLinkListener( LINK( this, ScCellRangesBase, ValueListenerHdl ) );
3380 ScDocument* pDoc = pDocShell->GetDocument();
3381 for ( size_t i = 0, nCount = aRanges.size(); i < nCount; i++)
3382 pDoc->StartListeningArea( *aRanges[ i ], pValueListener );
3384 acquire(); // don't lose this object (one ref for all listeners)
3388 void SAL_CALL ScCellRangesBase::removeModifyListener( const uno::Reference<util::XModifyListener>& aListener )
3389 throw(uno::RuntimeException, std::exception)
3392 SolarMutexGuard aGuard;
3393 if ( aRanges.empty() )
3394 throw uno::RuntimeException();
3396 acquire(); // in case the listeners have the last ref - released below
3398 sal_uInt16 nCount = aValueListeners.size();
3399 for ( sal_uInt16 n=nCount; n--; )
3401 uno::Reference<util::XModifyListener>& rObj = aValueListeners[n];
3402 if ( rObj == aListener )
3404 aValueListeners.erase( aValueListeners.begin() + n );
3406 if ( aValueListeners.empty() )
3408 if (pValueListener)
3409 pValueListener->EndListeningAll();
3411 release(); // release the ref for the listeners
3414 break;
3418 release(); // might delete this object
3421 // XCellRangesQuery
3423 uno::Reference<sheet::XSheetCellRanges> SAL_CALL ScCellRangesBase::queryVisibleCells()
3424 throw(uno::RuntimeException, std::exception)
3426 SolarMutexGuard aGuard;
3427 if (pDocShell)
3429 //! fuer alle Tabellen getrennt, wenn Markierungen pro Tabelle getrennt sind!
3430 SCTAB nTab = lcl_FirstTab(aRanges);
3432 ScMarkData aMarkData(*GetMarkData());
3434 ScDocument* pDoc = pDocShell->GetDocument();
3435 SCCOL nCol = 0, nLastCol;
3436 while (nCol <= MAXCOL)
3438 if (pDoc->ColHidden(nCol, nTab, NULL, &nLastCol))
3439 // hidden columns. Unselect them.
3440 aMarkData.SetMultiMarkArea(ScRange(nCol, 0, nTab, nLastCol, MAXROW, nTab), false);
3442 nCol = nLastCol + 1;
3445 SCROW nRow = 0, nLastRow;
3446 while (nRow <= MAXROW)
3448 if (pDoc->RowHidden(nRow, nTab, NULL, &nLastRow))
3449 // These rows are hidden. Unselect them.
3450 aMarkData.SetMultiMarkArea(ScRange(0, nRow, nTab, MAXCOL, nLastRow, nTab), false);
3452 nRow = nLastRow + 1;
3455 ScRangeList aNewRanges;
3456 aMarkData.FillRangeListWithMarks( &aNewRanges, false );
3457 return new ScCellRangesObj( pDocShell, aNewRanges );
3460 return NULL;
3463 uno::Reference<sheet::XSheetCellRanges> SAL_CALL ScCellRangesBase::queryEmptyCells()
3464 throw(uno::RuntimeException, std::exception)
3466 SolarMutexGuard aGuard;
3467 if (pDocShell)
3469 ScDocument* pDoc = pDocShell->GetDocument();
3471 ScMarkData aMarkData(*GetMarkData());
3473 // belegte Zellen wegmarkieren
3474 for (size_t i = 0, nCount = aRanges.size(); i < nCount; ++i)
3476 ScRange aRange = *aRanges[ i ];
3478 ScCellIterator aIter( pDoc, aRange );
3479 for (bool bHasCell = aIter.first(); bHasCell; bHasCell = aIter.next())
3481 // Notizen zaehlen als nicht-leer
3482 if (!aIter.isEmpty())
3483 aMarkData.SetMultiMarkArea(aIter.GetPos(), false);
3487 ScRangeList aNewRanges;
3488 // IsMultiMarked reicht hier nicht (wird beim deselektieren nicht zurueckgesetzt)
3489 //if (aMarkData.HasAnyMultiMarks()) // #i20044# should be set for all empty range
3490 aMarkData.FillRangeListWithMarks( &aNewRanges, false );
3492 return new ScCellRangesObj( pDocShell, aNewRanges ); // aNewRanges kann leer sein
3495 return NULL;
3498 uno::Reference<sheet::XSheetCellRanges> SAL_CALL ScCellRangesBase::queryContentCells(
3499 sal_Int16 nContentFlags )
3500 throw(uno::RuntimeException, std::exception)
3502 SolarMutexGuard aGuard;
3503 if (pDocShell)
3505 ScDocument* pDoc = pDocShell->GetDocument();
3507 ScMarkData aMarkData;
3509 // passende Zellen selektieren
3510 for ( size_t i = 0, nCount = aRanges.size(); i < nCount; ++i )
3512 ScRange aRange = *aRanges[ i ];
3514 ScCellIterator aIter( pDoc, aRange );
3515 for (bool bHasCell = aIter.first(); bHasCell; bHasCell = aIter.next())
3517 bool bAdd = false;
3518 switch (aIter.getType())
3520 case CELLTYPE_STRING:
3521 if ( nContentFlags & sheet::CellFlags::STRING )
3522 bAdd = true;
3523 break;
3524 case CELLTYPE_EDIT:
3525 if ( (nContentFlags & sheet::CellFlags::STRING) || (nContentFlags & sheet::CellFlags::FORMATTED) )
3526 bAdd = true;
3527 break;
3528 case CELLTYPE_FORMULA:
3529 if ( nContentFlags & sheet::CellFlags::FORMULA )
3530 bAdd = true;
3531 break;
3532 case CELLTYPE_VALUE:
3533 if ( (nContentFlags & (sheet::CellFlags::VALUE|sheet::CellFlags::DATETIME))
3534 == (sheet::CellFlags::VALUE|sheet::CellFlags::DATETIME) )
3535 bAdd = true;
3536 else
3538 // Date/Time Erkennung
3540 sal_uLong nIndex = (sal_uLong)((SfxUInt32Item*)pDoc->GetAttr(
3541 aIter.GetPos(), ATTR_VALUE_FORMAT))->GetValue();
3542 short nTyp = pDoc->GetFormatTable()->GetType(nIndex);
3543 if ((nTyp == NUMBERFORMAT_DATE) || (nTyp == NUMBERFORMAT_TIME) ||
3544 (nTyp == NUMBERFORMAT_DATETIME))
3546 if ( nContentFlags & sheet::CellFlags::DATETIME )
3547 bAdd = true;
3549 else
3551 if ( nContentFlags & sheet::CellFlags::VALUE )
3552 bAdd = true;
3555 break;
3556 default:
3558 // added to avoid warnings
3562 if (bAdd)
3563 aMarkData.SetMultiMarkArea(aIter.GetPos(), true);
3568 ScRangeList aNewRanges;
3569 if (aMarkData.IsMultiMarked())
3570 aMarkData.FillRangeListWithMarks( &aNewRanges, false );
3572 return new ScCellRangesObj( pDocShell, aNewRanges ); // aNewRanges kann leer sein
3575 return NULL;
3578 uno::Reference<sheet::XSheetCellRanges> SAL_CALL ScCellRangesBase::queryFormulaCells(
3579 sal_Int32 nResultFlags )
3580 throw(uno::RuntimeException, std::exception)
3582 SolarMutexGuard aGuard;
3583 if (pDocShell)
3585 ScDocument* pDoc = pDocShell->GetDocument();
3587 ScMarkData aMarkData;
3589 // passende Zellen selektieren
3590 for ( size_t i = 0, nCount = aRanges.size(); i < nCount; ++i )
3592 ScRange aRange = *aRanges[ i ];
3594 ScCellIterator aIter( pDoc, aRange );
3595 for (bool bHasCell = aIter.first(); bHasCell; bHasCell = aIter.next())
3597 if (aIter.getType() == CELLTYPE_FORMULA)
3599 ScFormulaCell* pFCell = aIter.getFormulaCell();
3600 bool bAdd = false;
3601 if (pFCell->GetErrCode())
3603 if ( nResultFlags & sheet::FormulaResult::ERROR )
3604 bAdd = true;
3606 else if (pFCell->IsValue())
3608 if ( nResultFlags & sheet::FormulaResult::VALUE )
3609 bAdd = true;
3611 else // String
3613 if ( nResultFlags & sheet::FormulaResult::STRING )
3614 bAdd = true;
3617 if (bAdd)
3618 aMarkData.SetMultiMarkArea(aIter.GetPos(), true);
3623 ScRangeList aNewRanges;
3624 if (aMarkData.IsMultiMarked())
3625 aMarkData.FillRangeListWithMarks( &aNewRanges, false );
3627 return new ScCellRangesObj( pDocShell, aNewRanges ); // aNewRanges kann leer sein
3630 return NULL;
3633 uno::Reference<sheet::XSheetCellRanges> ScCellRangesBase::QueryDifferences_Impl(
3634 const table::CellAddress& aCompare, bool bColumnDiff)
3636 if (pDocShell)
3638 size_t nRangeCount = aRanges.size();
3639 size_t i;
3640 ScDocument* pDoc = pDocShell->GetDocument();
3641 ScMarkData aMarkData;
3643 SCCOLROW nCmpPos = bColumnDiff ? (SCCOLROW)aCompare.Row : (SCCOLROW)aCompare.Column;
3645 // zuerst alles selektieren, wo ueberhaupt etwas in der Vergleichsspalte steht
3646 // (fuer gleiche Zellen wird die Selektion im zweiten Schritt aufgehoben)
3648 SCTAB nTab = lcl_FirstTab(aRanges); //! fuer alle Tabellen, wenn Markierungen pro Tabelle!
3649 ScRange aCmpRange, aCellRange;
3650 if (bColumnDiff)
3651 aCmpRange = ScRange( 0,nCmpPos,nTab, MAXCOL,nCmpPos,nTab );
3652 else
3653 aCmpRange = ScRange( static_cast<SCCOL>(nCmpPos),0,nTab, static_cast<SCCOL>(nCmpPos),MAXROW,nTab );
3654 ScCellIterator aCmpIter( pDoc, aCmpRange );
3655 for (bool bHasCell = aCmpIter.first(); bHasCell; bHasCell = aCmpIter.next())
3657 SCCOLROW nCellPos = bColumnDiff ? static_cast<SCCOLROW>(aCmpIter.GetPos().Col()) : static_cast<SCCOLROW>(aCmpIter.GetPos().Row());
3658 if (bColumnDiff)
3659 aCellRange = ScRange( static_cast<SCCOL>(nCellPos),0,nTab,
3660 static_cast<SCCOL>(nCellPos),MAXROW,nTab );
3661 else
3662 aCellRange = ScRange( 0,nCellPos,nTab, MAXCOL,nCellPos,nTab );
3664 for (i=0; i<nRangeCount; i++)
3666 ScRange aRange( *aRanges[ i ] );
3667 if ( aRange.Intersects( aCellRange ) )
3669 if (bColumnDiff)
3671 aRange.aStart.SetCol(static_cast<SCCOL>(nCellPos));
3672 aRange.aEnd.SetCol(static_cast<SCCOL>(nCellPos));
3674 else
3676 aRange.aStart.SetRow(nCellPos);
3677 aRange.aEnd.SetRow(nCellPos);
3679 aMarkData.SetMultiMarkArea( aRange );
3684 // alle nichtleeren Zellen mit der Vergleichsspalte vergleichen und entsprechend
3685 // selektieren oder aufheben
3687 ScAddress aCmpAddr;
3688 for (i=0; i<nRangeCount; i++)
3690 ScRange aRange( *aRanges[ i ] );
3692 ScCellIterator aIter( pDoc, aRange );
3693 for (bool bHasCell = aIter.first(); bHasCell; bHasCell = aIter.next())
3695 if (bColumnDiff)
3696 aCmpAddr = ScAddress( aIter.GetPos().Col(), nCmpPos, aIter.GetPos().Tab() );
3697 else
3698 aCmpAddr = ScAddress( static_cast<SCCOL>(nCmpPos), aIter.GetPos().Row(), aIter.GetPos().Tab() );
3700 ScRange aOneRange(aIter.GetPos());
3701 if (!aIter.equalsWithoutFormat(aCmpAddr))
3702 aMarkData.SetMultiMarkArea( aOneRange );
3703 else
3704 aMarkData.SetMultiMarkArea( aOneRange, false ); // deselect
3708 ScRangeList aNewRanges;
3709 if (aMarkData.IsMultiMarked())
3710 aMarkData.FillRangeListWithMarks( &aNewRanges, false );
3712 return new ScCellRangesObj( pDocShell, aNewRanges ); // aNewRanges kann leer sein
3714 return NULL;
3717 uno::Reference<sheet::XSheetCellRanges > SAL_CALL ScCellRangesBase::queryColumnDifferences(
3718 const table::CellAddress& aCompare ) throw(uno::RuntimeException, std::exception)
3720 SolarMutexGuard aGuard;
3721 return QueryDifferences_Impl( aCompare, true );
3724 uno::Reference<sheet::XSheetCellRanges> SAL_CALL ScCellRangesBase::queryRowDifferences(
3725 const table::CellAddress& aCompare ) throw(uno::RuntimeException, std::exception)
3727 SolarMutexGuard aGuard;
3728 return QueryDifferences_Impl( aCompare, false );
3731 uno::Reference<sheet::XSheetCellRanges> SAL_CALL ScCellRangesBase::queryIntersection(
3732 const table::CellRangeAddress& aRange ) throw(uno::RuntimeException, std::exception)
3734 SolarMutexGuard aGuard;
3735 ScRange aMask( (SCCOL)aRange.StartColumn, (SCROW)aRange.StartRow, aRange.Sheet,
3736 (SCCOL)aRange.EndColumn, (SCROW)aRange.EndRow, aRange.Sheet );
3738 ScRangeList aNew;
3739 for ( size_t i = 0, nCount = aRanges.size(); i < nCount; ++i )
3741 ScRange aTemp( *aRanges[ i ] );
3742 if ( aTemp.Intersects( aMask ) )
3743 aNew.Join( ScRange( std::max( aTemp.aStart.Col(), aMask.aStart.Col() ),
3744 std::max( aTemp.aStart.Row(), aMask.aStart.Row() ),
3745 std::max( aTemp.aStart.Tab(), aMask.aStart.Tab() ),
3746 std::min( aTemp.aEnd.Col(), aMask.aEnd.Col() ),
3747 std::min( aTemp.aEnd.Row(), aMask.aEnd.Row() ),
3748 std::min( aTemp.aEnd.Tab(), aMask.aEnd.Tab() ) ) );
3751 return new ScCellRangesObj( pDocShell, aNew ); // kann leer sein
3754 // XFormulaQuery
3756 uno::Reference<sheet::XSheetCellRanges> SAL_CALL ScCellRangesBase::queryPrecedents(
3757 sal_Bool bRecursive ) throw(uno::RuntimeException, std::exception)
3759 SolarMutexGuard aGuard;
3760 if ( pDocShell )
3762 ScDocument* pDoc = pDocShell->GetDocument();
3764 ScRangeList aNewRanges(aRanges);
3765 bool bFound;
3768 bFound = false;
3770 // aMarkData uses aNewRanges, not aRanges, so GetMarkData can't be used
3771 ScMarkData aMarkData;
3772 aMarkData.MarkFromRangeList( aNewRanges, false );
3773 aMarkData.MarkToMulti(); // needed for IsAllMarked
3775 for (size_t nR = 0, nCount = aNewRanges.size(); nR<nCount; ++nR)
3777 ScRange aRange( *aNewRanges[ nR] );
3778 ScCellIterator aIter( pDoc, aRange );
3779 for (bool bHasCell = aIter.first(); bHasCell; bHasCell = aIter.next())
3781 if (aIter.getType() != CELLTYPE_FORMULA)
3782 continue;
3784 ScDetectiveRefIter aRefIter(aIter.getFormulaCell());
3785 ScRange aRefRange;
3786 while ( aRefIter.GetNextRef( aRefRange) )
3788 if ( bRecursive && !bFound && !aMarkData.IsAllMarked( aRefRange ) )
3789 bFound = true;
3790 aMarkData.SetMultiMarkArea(aRefRange, true);
3795 aMarkData.FillRangeListWithMarks( &aNewRanges, true );
3797 while ( bRecursive && bFound );
3799 return new ScCellRangesObj( pDocShell, aNewRanges );
3802 return NULL;
3805 uno::Reference<sheet::XSheetCellRanges> SAL_CALL ScCellRangesBase::queryDependents(
3806 sal_Bool bRecursive ) throw(uno::RuntimeException, std::exception)
3808 SolarMutexGuard aGuard;
3809 if ( pDocShell )
3811 ScDocument* pDoc = pDocShell->GetDocument();
3813 ScRangeList aNewRanges(aRanges);
3814 bool bFound;
3817 bFound = false;
3819 // aMarkData uses aNewRanges, not aRanges, so GetMarkData can't be used
3820 ScMarkData aMarkData;
3821 aMarkData.MarkFromRangeList( aNewRanges, false );
3822 aMarkData.MarkToMulti(); // needed for IsAllMarked
3824 SCTAB nTab = lcl_FirstTab(aNewRanges); //! alle Tabellen
3826 ScCellIterator aCellIter( pDoc, ScRange(0, 0, nTab, MAXCOL, MAXROW, nTab) );
3827 for (bool bHasCell = aCellIter.first(); bHasCell; bHasCell = aCellIter.next())
3829 if (aCellIter.getType() != CELLTYPE_FORMULA)
3830 continue;
3832 bool bMark = false;
3833 ScDetectiveRefIter aIter(aCellIter.getFormulaCell());
3834 ScRange aRefRange;
3835 while ( aIter.GetNextRef( aRefRange) )
3837 size_t nRangesCount = aNewRanges.size();
3838 for (size_t nR = 0; nR < nRangesCount; ++nR)
3840 ScRange aRange( *aNewRanges[ nR ] );
3841 if (aRange.Intersects(aRefRange))
3842 bMark = true; // von Teil des Ranges abhaengig
3845 if (bMark)
3847 ScRange aCellRange(aCellIter.GetPos());
3848 if ( bRecursive && !bFound && !aMarkData.IsAllMarked( aCellRange ) )
3849 bFound = true;
3850 aMarkData.SetMultiMarkArea(aCellRange, true);
3854 aMarkData.FillRangeListWithMarks( &aNewRanges, true );
3856 while ( bRecursive && bFound );
3858 return new ScCellRangesObj( pDocShell, aNewRanges );
3861 return NULL;
3864 // XSearchable
3866 uno::Reference<util::XSearchDescriptor> SAL_CALL ScCellRangesBase::createSearchDescriptor()
3867 throw(uno::RuntimeException, std::exception)
3869 SolarMutexGuard aGuard;
3870 return new ScCellSearchObj;
3873 uno::Reference<container::XIndexAccess> SAL_CALL ScCellRangesBase::findAll(
3874 const uno::Reference<util::XSearchDescriptor>& xDesc )
3875 throw(uno::RuntimeException,
3876 std::exception)
3878 SolarMutexGuard aGuard;
3879 // Wenn nichts gefunden wird, soll Null zurueckgegeben werden (?)
3880 uno::Reference<container::XIndexAccess> xRet;
3881 if ( pDocShell && xDesc.is() )
3883 ScCellSearchObj* pSearch = ScCellSearchObj::getImplementation( xDesc );
3884 if (pSearch)
3886 SvxSearchItem* pSearchItem = pSearch->GetSearchItem();
3887 if (pSearchItem)
3889 ScDocument* pDoc = pDocShell->GetDocument();
3890 pSearchItem->SetCommand( SVX_SEARCHCMD_FIND_ALL );
3891 // immer nur innerhalb dieses Objekts
3892 pSearchItem->SetSelection( !lcl_WholeSheet(aRanges) );
3894 ScMarkData aMark(*GetMarkData());
3896 OUString aDummyUndo;
3897 ScRangeList aMatchedRanges;
3898 SCCOL nCol = 0;
3899 SCROW nRow = 0;
3900 SCTAB nTab = 0;
3901 bool bFound = pDoc->SearchAndReplace(
3902 *pSearchItem, nCol, nRow, nTab, aMark, aMatchedRanges, aDummyUndo, NULL);
3903 if (bFound)
3905 // bei findAll immer CellRanges, egal wieviel gefunden wurde
3906 xRet.set(new ScCellRangesObj( pDocShell, aMatchedRanges ));
3911 return xRet;
3914 uno::Reference<uno::XInterface> ScCellRangesBase::Find_Impl(
3915 const uno::Reference<util::XSearchDescriptor>& xDesc,
3916 const ScAddress* pLastPos )
3918 uno::Reference<uno::XInterface> xRet;
3919 if ( pDocShell && xDesc.is() )
3921 ScCellSearchObj* pSearch = ScCellSearchObj::getImplementation( xDesc );
3922 if (pSearch)
3924 SvxSearchItem* pSearchItem = pSearch->GetSearchItem();
3925 if (pSearchItem)
3927 ScDocument* pDoc = pDocShell->GetDocument();
3928 pSearchItem->SetCommand( SVX_SEARCHCMD_FIND );
3929 // immer nur innerhalb dieses Objekts
3930 pSearchItem->SetSelection( !lcl_WholeSheet(aRanges) );
3932 ScMarkData aMark(*GetMarkData());
3934 SCCOL nCol;
3935 SCROW nRow;
3936 SCTAB nTab;
3937 if (pLastPos)
3938 pLastPos->GetVars( nCol, nRow, nTab );
3939 else
3941 nTab = lcl_FirstTab(aRanges); //! mehrere Tabellen?
3942 ScDocument::GetSearchAndReplaceStart( *pSearchItem, nCol, nRow );
3945 OUString aDummyUndo;
3946 ScRangeList aMatchedRanges;
3947 bool bFound = pDoc->SearchAndReplace(
3948 *pSearchItem, nCol, nRow, nTab, aMark, aMatchedRanges, aDummyUndo, NULL);
3949 if (bFound)
3951 ScAddress aFoundPos( nCol, nRow, nTab );
3952 xRet.set((cppu::OWeakObject*) new ScCellObj( pDocShell, aFoundPos ));
3957 return xRet;
3960 uno::Reference<uno::XInterface> SAL_CALL ScCellRangesBase::findFirst(
3961 const uno::Reference<util::XSearchDescriptor>& xDesc )
3962 throw(uno::RuntimeException, std::exception)
3964 SolarMutexGuard aGuard;
3965 return Find_Impl( xDesc, NULL );
3968 uno::Reference<uno::XInterface> SAL_CALL ScCellRangesBase::findNext(
3969 const uno::Reference<uno::XInterface>& xStartAt,
3970 const uno::Reference<util::XSearchDescriptor >& xDesc )
3971 throw(uno::RuntimeException, std::exception)
3973 SolarMutexGuard aGuard;
3974 if ( xStartAt.is() )
3976 ScCellRangesBase* pRangesImp = ScCellRangesBase::getImplementation( xStartAt );
3977 if ( pRangesImp && pRangesImp->GetDocShell() == pDocShell )
3979 const ScRangeList& rStartRanges = pRangesImp->GetRangeList();
3980 if ( rStartRanges.size() == 1 )
3982 ScAddress aStartPos = rStartRanges[ 0 ]->aStart;
3983 return Find_Impl( xDesc, &aStartPos );
3987 return NULL;
3990 // XReplaceable
3992 uno::Reference<util::XReplaceDescriptor> SAL_CALL ScCellRangesBase::createReplaceDescriptor()
3993 throw(uno::RuntimeException, std::exception)
3995 SolarMutexGuard aGuard;
3996 return new ScCellSearchObj;
3999 sal_Int32 SAL_CALL ScCellRangesBase::replaceAll( const uno::Reference<util::XSearchDescriptor>& xDesc )
4000 throw(uno::RuntimeException,
4001 std::exception)
4003 SolarMutexGuard aGuard;
4004 sal_Int32 nReplaced = 0;
4005 if ( pDocShell && xDesc.is() )
4007 ScCellSearchObj* pSearch = ScCellSearchObj::getImplementation( xDesc );
4008 if (pSearch)
4010 SvxSearchItem* pSearchItem = pSearch->GetSearchItem();
4011 if (pSearchItem)
4013 ScDocument* pDoc = pDocShell->GetDocument();
4014 bool bUndo(pDoc->IsUndoEnabled());
4015 pSearchItem->SetCommand( SVX_SEARCHCMD_REPLACE_ALL );
4016 // immer nur innerhalb dieses Objekts
4017 pSearchItem->SetSelection( !lcl_WholeSheet(aRanges) );
4019 ScMarkData aMark(*GetMarkData());
4021 SCTAB nTabCount = pDoc->GetTableCount();
4022 bool bProtected = !pDocShell->IsEditable();
4023 ScMarkData::iterator itr = aMark.begin(), itrEnd = aMark.end();
4024 for (; itr != itrEnd && *itr < nTabCount; ++itr)
4025 if ( pDoc->IsTabProtected(*itr) )
4026 bProtected = true;
4027 if (bProtected)
4029 //! Exception, oder was?
4031 else
4033 SCTAB nTab = aMark.GetFirstSelected(); // bei SearchAndReplace nicht benutzt
4034 SCCOL nCol = 0;
4035 SCROW nRow = 0;
4037 OUString aUndoStr;
4038 ScDocument* pUndoDoc = NULL;
4039 if (bUndo)
4041 pUndoDoc = new ScDocument( SCDOCMODE_UNDO );
4042 pUndoDoc->InitUndo( pDoc, nTab, nTab );
4044 itr = aMark.begin();
4045 for (; itr != itrEnd && *itr < nTabCount; ++itr)
4046 if ( *itr != nTab && bUndo)
4047 pUndoDoc->AddUndoTab( *itr, *itr );
4048 boost::scoped_ptr<ScMarkData> pUndoMark;
4049 if (bUndo)
4050 pUndoMark.reset(new ScMarkData(aMark));
4052 bool bFound = false;
4053 if (bUndo)
4055 ScRangeList aMatchedRanges;
4056 bFound = pDoc->SearchAndReplace(
4057 *pSearchItem, nCol, nRow, nTab, aMark, aMatchedRanges, aUndoStr, pUndoDoc );
4059 if (bFound)
4061 nReplaced = pUndoDoc->GetCellCount();
4063 pDocShell->GetUndoManager()->AddUndoAction(
4064 new ScUndoReplace( pDocShell, *pUndoMark, nCol, nRow, nTab,
4065 aUndoStr, pUndoDoc, pSearchItem ) );
4067 pDocShell->PostPaintGridAll();
4068 pDocShell->SetDocumentModified();
4070 else
4072 delete pUndoDoc;
4073 // nReplaced bleibt 0
4079 return nReplaced;
4082 // XUnoTunnel
4084 sal_Int64 SAL_CALL ScCellRangesBase::getSomething(
4085 const uno::Sequence<sal_Int8 >& rId ) throw(uno::RuntimeException, std::exception)
4087 if ( rId.getLength() == 16 &&
4088 0 == memcmp( getUnoTunnelId().getConstArray(),
4089 rId.getConstArray(), 16 ) )
4091 return sal::static_int_cast<sal_Int64>(reinterpret_cast<sal_IntPtr>(this));
4093 return 0;
4096 namespace
4098 class theScCellRangesBaseUnoTunnelId : public rtl::Static< UnoTunnelIdInit, theScCellRangesBaseUnoTunnelId> {};
4101 const uno::Sequence<sal_Int8>& ScCellRangesBase::getUnoTunnelId()
4103 return theScCellRangesBaseUnoTunnelId::get().getSeq();
4106 ScCellRangesBase* ScCellRangesBase::getImplementation( const uno::Reference<uno::XInterface> xObj )
4108 ScCellRangesBase* pRet = NULL;
4109 uno::Reference<lang::XUnoTunnel> xUT( xObj, uno::UNO_QUERY );
4110 if (xUT.is())
4111 pRet = reinterpret_cast<ScCellRangesBase*>(sal::static_int_cast<sal_IntPtr>(xUT->getSomething(getUnoTunnelId())));
4112 return pRet;
4115 typedef boost::ptr_vector<ScNamedEntry> ScNamedEntryArr_Impl;
4117 struct ScCellRangesObj::Impl
4119 ScNamedEntryArr_Impl m_aNamedEntries;
4122 ScCellRangesObj::ScCellRangesObj(ScDocShell* pDocSh, const ScRangeList& rR)
4123 : ScCellRangesBase(pDocSh, rR)
4124 , m_pImpl(new Impl)
4128 ScCellRangesObj::~ScCellRangesObj()
4132 void ScCellRangesObj::RefChanged()
4134 ScCellRangesBase::RefChanged();
4136 // nix weiter...
4139 uno::Any SAL_CALL ScCellRangesObj::queryInterface( const uno::Type& rType )
4140 throw(uno::RuntimeException, std::exception)
4142 SC_QUERYINTERFACE( sheet::XSheetCellRangeContainer )
4143 SC_QUERYINTERFACE( sheet::XSheetCellRanges )
4144 SC_QUERYINTERFACE( container::XIndexAccess )
4145 SC_QUERY_MULTIPLE( container::XElementAccess, container::XIndexAccess )
4146 SC_QUERYINTERFACE( container::XEnumerationAccess )
4147 SC_QUERYINTERFACE( container::XNameContainer )
4148 SC_QUERYINTERFACE( container::XNameReplace )
4149 SC_QUERYINTERFACE( container::XNameAccess )
4151 return ScCellRangesBase::queryInterface( rType );
4154 void SAL_CALL ScCellRangesObj::acquire() throw()
4156 ScCellRangesBase::acquire();
4159 void SAL_CALL ScCellRangesObj::release() throw()
4161 ScCellRangesBase::release();
4164 uno::Sequence<uno::Type> SAL_CALL ScCellRangesObj::getTypes() throw(uno::RuntimeException, std::exception)
4166 static uno::Sequence<uno::Type> aTypes;
4167 if ( aTypes.getLength() == 0 )
4169 uno::Sequence<uno::Type> aParentTypes(ScCellRangesBase::getTypes());
4170 long nParentLen = aParentTypes.getLength();
4171 const uno::Type* pParentPtr = aParentTypes.getConstArray();
4173 aTypes.realloc( nParentLen + 3 );
4174 uno::Type* pPtr = aTypes.getArray();
4175 pPtr[nParentLen + 0] = cppu::UnoType<sheet::XSheetCellRangeContainer>::get();
4176 pPtr[nParentLen + 1] = cppu::UnoType<container::XNameContainer>::get();
4177 pPtr[nParentLen + 2] = cppu::UnoType<container::XEnumerationAccess>::get();
4179 for (long i=0; i<nParentLen; i++)
4180 pPtr[i] = pParentPtr[i]; // parent types first
4182 return aTypes;
4185 uno::Sequence<sal_Int8> SAL_CALL ScCellRangesObj::getImplementationId()
4186 throw(uno::RuntimeException, std::exception)
4188 return css::uno::Sequence<sal_Int8>();
4191 // XCellRanges
4193 ScCellRangeObj* ScCellRangesObj::GetObjectByIndex_Impl(sal_Int32 nIndex) const
4195 ScDocShell* pDocSh = GetDocShell();
4196 const ScRangeList& rRanges = GetRangeList();
4197 if ( pDocSh && nIndex >= 0 && nIndex < sal::static_int_cast<sal_Int32>(rRanges.size()) )
4199 ScRange aRange( *rRanges[ nIndex ] );
4200 if ( aRange.aStart == aRange.aEnd )
4201 return new ScCellObj( pDocSh, aRange.aStart );
4202 else
4203 return new ScCellRangeObj( pDocSh, aRange );
4206 return NULL; // keine DocShell oder falscher Index
4209 uno::Sequence<table::CellRangeAddress> SAL_CALL ScCellRangesObj::getRangeAddresses()
4210 throw(uno::RuntimeException, std::exception)
4212 SolarMutexGuard aGuard;
4213 ScDocShell* pDocSh = GetDocShell();
4214 const ScRangeList& rRanges = GetRangeList();
4215 size_t nCount = rRanges.size();
4216 if ( pDocSh && nCount )
4218 table::CellRangeAddress aRangeAddress;
4219 uno::Sequence<table::CellRangeAddress> aSeq(nCount);
4220 table::CellRangeAddress* pAry = aSeq.getArray();
4221 for ( size_t i=0; i < nCount; i++)
4223 ScUnoConversion::FillApiRange( aRangeAddress, *rRanges[ i ] );
4224 pAry[i] = aRangeAddress;
4226 return aSeq;
4229 return uno::Sequence<table::CellRangeAddress>(0); // leer ist moeglich
4232 uno::Reference<container::XEnumerationAccess> SAL_CALL ScCellRangesObj::getCells()
4233 throw(uno::RuntimeException, std::exception)
4235 SolarMutexGuard aGuard;
4237 // getCells with empty range list is possible (no exception),
4238 // the resulting enumeration just has no elements
4239 // (same behaviour as a valid range with no cells)
4240 // This is handled in ScCellsEnumeration ctor.
4242 const ScRangeList& rRanges = GetRangeList();
4243 ScDocShell* pDocSh = GetDocShell();
4244 if (pDocSh)
4245 return new ScCellsObj( pDocSh, rRanges );
4246 return NULL;
4249 OUString SAL_CALL ScCellRangesObj::getRangeAddressesAsString()
4250 throw(uno::RuntimeException, std::exception)
4252 SolarMutexGuard aGuard;
4253 OUString aString;
4254 ScDocShell* pDocSh = GetDocShell();
4255 const ScRangeList& rRanges = GetRangeList();
4256 if (pDocSh)
4257 rRanges.Format( aString, SCA_VALID | SCA_TAB_3D, pDocSh->GetDocument() );
4258 return aString;
4261 // XSheetCellRangeContainer
4263 void SAL_CALL ScCellRangesObj::addRangeAddress( const table::CellRangeAddress& rRange,
4264 sal_Bool bMergeRanges )
4265 throw(::com::sun::star::uno::RuntimeException, std::exception)
4267 SolarMutexGuard aGuard;
4268 ScRange aRange(static_cast<SCCOL>(rRange.StartColumn),
4269 static_cast<SCROW>(rRange.StartRow),
4270 static_cast<SCTAB>(rRange.Sheet),
4271 static_cast<SCCOL>(rRange.EndColumn),
4272 static_cast<SCROW>(rRange.EndRow),
4273 static_cast<SCTAB>(rRange.Sheet));
4274 AddRange(aRange, bMergeRanges);
4277 static void lcl_RemoveNamedEntry( ScNamedEntryArr_Impl& rNamedEntries, const ScRange& rRange )
4279 sal_uInt16 nCount = rNamedEntries.size();
4280 for ( sal_uInt16 n=nCount; n--; )
4281 if ( rNamedEntries[n].GetRange() == rRange )
4282 rNamedEntries.erase( rNamedEntries.begin() + n );
4285 void SAL_CALL ScCellRangesObj::removeRangeAddress( const table::CellRangeAddress& rRange )
4286 throw(::com::sun::star::container::NoSuchElementException,
4287 ::com::sun::star::uno::RuntimeException, std::exception)
4289 SolarMutexGuard aGuard;
4290 const ScRangeList& rRanges = GetRangeList();
4292 ScRangeList aSheetRanges;
4293 ScRangeList aNotSheetRanges;
4294 for (size_t i = 0; i < rRanges.size(); ++i)
4296 if (rRanges[ i]->aStart.Tab() == rRange.Sheet)
4298 aSheetRanges.Append( *rRanges[ i ] );
4300 else
4302 aNotSheetRanges.Append( *rRanges[ i ] );
4305 ScMarkData aMarkData;
4306 aMarkData.MarkFromRangeList( aSheetRanges, false );
4307 ScRange aRange(static_cast<SCCOL>(rRange.StartColumn),
4308 static_cast<SCROW>(rRange.StartRow),
4309 static_cast<SCTAB>(rRange.Sheet),
4310 static_cast<SCCOL>(rRange.EndColumn),
4311 static_cast<SCROW>(rRange.EndRow),
4312 static_cast<SCTAB>(rRange.Sheet));
4313 if (aMarkData.GetTableSelect( aRange.aStart.Tab() ))
4315 aMarkData.MarkToMulti();
4316 if (aMarkData.IsAllMarked( aRange ) )
4318 aMarkData.SetMultiMarkArea( aRange, false );
4319 lcl_RemoveNamedEntry(m_pImpl->m_aNamedEntries, aRange);
4321 else
4322 throw container::NoSuchElementException();
4324 SetNewRanges(aNotSheetRanges);
4325 ScRangeList aNew;
4326 aMarkData.FillRangeListWithMarks( &aNew, false );
4327 for ( size_t j = 0; j < aNew.size(); ++j)
4329 AddRange(*aNew[ j ], false);
4333 void SAL_CALL ScCellRangesObj::addRangeAddresses( const uno::Sequence<table::CellRangeAddress >& rRanges,
4334 sal_Bool bMergeRanges )
4335 throw(::com::sun::star::uno::RuntimeException, std::exception)
4337 SolarMutexGuard aGuard;
4338 sal_Int32 nCount(rRanges.getLength());
4339 if (nCount)
4341 const table::CellRangeAddress* pRanges = rRanges.getConstArray();
4342 for (sal_Int32 i = 0; i < rRanges.getLength(); i++, pRanges++)
4344 ScRange aRange(static_cast<SCCOL>(pRanges->StartColumn),
4345 static_cast<SCROW>(pRanges->StartRow),
4346 static_cast<SCTAB>(pRanges->Sheet),
4347 static_cast<SCCOL>(pRanges->EndColumn),
4348 static_cast<SCROW>(pRanges->EndRow),
4349 static_cast<SCTAB>(pRanges->Sheet));
4350 AddRange(aRange, bMergeRanges);
4355 void SAL_CALL ScCellRangesObj::removeRangeAddresses( const uno::Sequence<table::CellRangeAddress >& rRangeSeq )
4356 throw(::com::sun::star::container::NoSuchElementException,
4357 ::com::sun::star::uno::RuntimeException, std::exception)
4359 // use sometimes a better/faster implementation
4360 sal_uInt32 nCount(rRangeSeq.getLength());
4361 if (nCount)
4363 const table::CellRangeAddress* pRanges = rRangeSeq.getConstArray();
4364 for (sal_uInt32 i=0; i < nCount; ++i, ++pRanges)
4366 removeRangeAddress(*pRanges);
4371 // XNameContainer
4373 static void lcl_RemoveNamedEntry( ScNamedEntryArr_Impl& rNamedEntries, const OUString& rName )
4375 sal_uInt16 nCount = rNamedEntries.size();
4376 for ( sal_uInt16 n=nCount; n--; )
4377 if ( rNamedEntries[n].GetName() == rName )
4378 rNamedEntries.erase( rNamedEntries.begin() + n );
4381 void SAL_CALL ScCellRangesObj::insertByName( const OUString& aName, const uno::Any& aElement )
4382 throw (lang::IllegalArgumentException, container::ElementExistException,
4383 lang::WrappedTargetException, uno::RuntimeException,
4384 std::exception)
4386 SolarMutexGuard aGuard;
4387 ScDocShell* pDocSh = GetDocShell();
4388 bool bDone = false;
4390 //! Type of aElement can be some specific interface instead of XInterface
4392 uno::Reference<uno::XInterface> xInterface(aElement, uno::UNO_QUERY);
4393 if ( pDocSh && xInterface.is() )
4395 ScCellRangesBase* pRangesImp = ScCellRangesBase::getImplementation( xInterface );
4396 if ( pRangesImp && pRangesImp->GetDocShell() == pDocSh )
4398 // if explicit name is given and already existing, throw exception
4400 OUString aNamStr(aName);
4401 if ( !aNamStr.isEmpty() )
4403 size_t nNamedCount = m_pImpl->m_aNamedEntries.size();
4404 for (size_t n = 0; n < nNamedCount; n++)
4406 if (m_pImpl->m_aNamedEntries[n].GetName() == aNamStr)
4407 throw container::ElementExistException();
4411 ScRangeList aNew(GetRangeList());
4412 const ScRangeList& rAddRanges = pRangesImp->GetRangeList();
4413 size_t nAddCount = rAddRanges.size();
4414 for ( size_t i = 0; i < nAddCount; i++ )
4415 aNew.Join( *rAddRanges[ i ] );
4416 SetNewRanges(aNew);
4417 bDone = true;
4419 if ( !aName.isEmpty() && nAddCount == 1 )
4421 // if a name is given, also insert into list of named entries
4422 // (only possible for a single range)
4423 // name is not in m_pImpl->m_aNamedEntries (tested above)
4425 ScNamedEntry* pEntry = new ScNamedEntry( aNamStr, *rAddRanges[ 0 ] );
4426 m_pImpl->m_aNamedEntries.push_back(pEntry);
4431 if (!bDone)
4433 // invalid element - double names are handled above
4434 throw lang::IllegalArgumentException();
4438 static bool lcl_FindRangeByName( const ScRangeList& rRanges, ScDocShell* pDocSh,
4439 const OUString& rName, size_t& rIndex )
4441 if (pDocSh)
4443 OUString aRangeStr;
4444 ScDocument* pDoc = pDocSh->GetDocument();
4445 for ( size_t i = 0, nCount = rRanges.size(); i < nCount; i++ )
4447 aRangeStr = rRanges[ i ]->Format(SCA_VALID | SCA_TAB_3D, pDoc);
4448 if ( aRangeStr == rName )
4450 rIndex = i;
4451 return true;
4455 return false; // nicht gefunden
4458 static bool lcl_FindRangeOrEntry( const ScNamedEntryArr_Impl& rNamedEntries,
4459 const ScRangeList& rRanges, ScDocShell* pDocSh,
4460 const OUString& rName, ScRange& rFound )
4462 // exact range in list?
4464 size_t nIndex = 0;
4465 if ( lcl_FindRangeByName( rRanges, pDocSh, rName, nIndex ) )
4467 rFound = *rRanges[ nIndex ];
4468 return true;
4471 // range contained in selection? (sheet must be specified)
4473 ScRange aCellRange;
4474 sal_uInt16 nParse = aCellRange.ParseAny( rName, pDocSh->GetDocument() );
4475 if ( ( nParse & ( SCA_VALID | SCA_TAB_3D ) ) == ( SCA_VALID | SCA_TAB_3D ) )
4477 ScMarkData aMarkData;
4478 aMarkData.MarkFromRangeList( rRanges, false );
4479 aMarkData.MarkToMulti(); // needed for IsAllMarked
4480 if ( aMarkData.IsAllMarked( aCellRange ) )
4482 rFound = aCellRange;
4483 return true;
4487 // named entry in this object?
4489 if ( !rNamedEntries.empty() )
4491 for ( sal_uInt16 n=0; n<rNamedEntries.size(); n++ )
4492 if ( rNamedEntries[n].GetName() == rName )
4494 // test if named entry is contained in rRanges
4496 const ScRange& rComp = rNamedEntries[n].GetRange();
4497 ScMarkData aMarkData;
4498 aMarkData.MarkFromRangeList( rRanges, false );
4499 aMarkData.MarkToMulti(); // needed for IsAllMarked
4500 if ( aMarkData.IsAllMarked( rComp ) )
4502 rFound = rComp;
4503 return true;
4508 return false; // not found
4511 void SAL_CALL ScCellRangesObj::removeByName( const OUString& aName )
4512 throw(container::NoSuchElementException,
4513 lang::WrappedTargetException, uno::RuntimeException, std::exception)
4515 SolarMutexGuard aGuard;
4516 bool bDone = false;
4517 OUString aNameStr(aName);
4518 ScDocShell* pDocSh = GetDocShell();
4519 const ScRangeList& rRanges = GetRangeList();
4520 size_t nIndex = 0;
4521 if ( lcl_FindRangeByName( rRanges, pDocSh, aNameStr, nIndex ) )
4523 // einzelnen Range weglassen
4524 ScRangeList aNew;
4525 for ( size_t i = 0, nCount = rRanges.size(); i < nCount; i++ )
4526 if (i != nIndex)
4527 aNew.Append( *rRanges[ i ] );
4528 SetNewRanges(aNew);
4529 bDone = true;
4531 else if (pDocSh)
4533 // deselect any ranges (parsed or named entry)
4534 ScRangeList aDiff;
4535 bool bValid = ( aDiff.Parse( aNameStr, pDocSh->GetDocument() ) & SCA_VALID ) != 0;
4536 if (!bValid && !m_pImpl->m_aNamedEntries.empty())
4538 sal_uInt16 nCount = m_pImpl->m_aNamedEntries.size();
4539 for (sal_uInt16 n=0; n<nCount && !bValid; n++)
4540 if (m_pImpl->m_aNamedEntries[n].GetName() == aNameStr)
4542 aDiff.RemoveAll();
4543 aDiff.Append(m_pImpl->m_aNamedEntries[n].GetRange());
4544 bValid = true;
4547 if ( bValid )
4549 ScMarkData aMarkData;
4550 aMarkData.MarkFromRangeList( rRanges, false );
4552 for ( size_t i = 0, nDiffCount = aDiff.size(); i < nDiffCount; i++ )
4554 ScRange* pDiffRange = aDiff[ i ];
4555 if (aMarkData.GetTableSelect( pDiffRange->aStart.Tab() ))
4556 aMarkData.SetMultiMarkArea( *pDiffRange, false );
4559 ScRangeList aNew;
4560 aMarkData.FillRangeListWithMarks( &aNew, false );
4561 SetNewRanges(aNew);
4563 bDone = true; //! error if range was not selected before?
4567 if (!m_pImpl->m_aNamedEntries.empty())
4568 lcl_RemoveNamedEntry(m_pImpl->m_aNamedEntries, aNameStr);
4570 if (!bDone)
4571 throw container::NoSuchElementException(); // not found
4574 // XNameReplace
4576 void SAL_CALL ScCellRangesObj::replaceByName( const OUString& aName, const uno::Any& aElement )
4577 throw(lang::IllegalArgumentException, container::NoSuchElementException,
4578 lang::WrappedTargetException, uno::RuntimeException, std::exception)
4580 SolarMutexGuard aGuard;
4581 //! zusammenfassen?
4582 removeByName( aName );
4583 insertByName( aName, aElement );
4586 // XNameAccess
4588 uno::Any SAL_CALL ScCellRangesObj::getByName( const OUString& aName )
4589 throw(container::NoSuchElementException,
4590 lang::WrappedTargetException, uno::RuntimeException, std::exception)
4592 SolarMutexGuard aGuard;
4593 uno::Any aRet;
4595 OUString aNameStr(aName);
4596 ScDocShell* pDocSh = GetDocShell();
4597 const ScRangeList& rRanges = GetRangeList();
4598 ScRange aRange;
4599 if (lcl_FindRangeOrEntry(m_pImpl->m_aNamedEntries, rRanges,
4600 pDocSh, aNameStr, aRange))
4602 uno::Reference<table::XCellRange> xRange;
4603 if ( aRange.aStart == aRange.aEnd )
4604 xRange.set(new ScCellObj( pDocSh, aRange.aStart ));
4605 else
4606 xRange.set(new ScCellRangeObj( pDocSh, aRange ));
4607 aRet <<= xRange;
4609 else
4610 throw container::NoSuchElementException();
4611 return aRet;
4614 static bool lcl_FindEntryName( const ScNamedEntryArr_Impl& rNamedEntries,
4615 const ScRange& rRange, OUString& rName )
4617 sal_uInt16 nCount = rNamedEntries.size();
4618 for (sal_uInt16 i=0; i<nCount; i++)
4619 if (rNamedEntries[i].GetRange() == rRange)
4621 rName = rNamedEntries[i].GetName();
4622 return true;
4624 return false;
4627 uno::Sequence<OUString> SAL_CALL ScCellRangesObj::getElementNames()
4628 throw(uno::RuntimeException, std::exception)
4630 SolarMutexGuard aGuard;
4632 ScDocShell* pDocSh = GetDocShell();
4633 const ScRangeList& rRanges = GetRangeList();
4634 if (pDocSh)
4636 OUString aRangeStr;
4637 ScDocument* pDoc = pDocSh->GetDocument();
4638 size_t nCount = rRanges.size();
4640 uno::Sequence<OUString> aSeq(nCount);
4641 OUString* pAry = aSeq.getArray();
4642 for (size_t i=0; i < nCount; i++)
4644 // use given name if for exactly this range, otherwise just format
4645 ScRange aRange = *rRanges[ i ];
4646 if (m_pImpl->m_aNamedEntries.empty() ||
4647 !lcl_FindEntryName(m_pImpl->m_aNamedEntries, aRange, aRangeStr))
4649 aRangeStr = aRange.Format(SCA_VALID | SCA_TAB_3D, pDoc);
4651 pAry[i] = aRangeStr;
4653 return aSeq;
4655 return uno::Sequence<OUString>(0);
4658 sal_Bool SAL_CALL ScCellRangesObj::hasByName( const OUString& aName )
4659 throw(uno::RuntimeException, std::exception)
4661 SolarMutexGuard aGuard;
4662 OUString aNameStr(aName);
4663 ScDocShell* pDocSh = GetDocShell();
4664 const ScRangeList& rRanges = GetRangeList();
4665 ScRange aRange;
4666 return lcl_FindRangeOrEntry(m_pImpl->m_aNamedEntries, rRanges, pDocSh,
4667 aNameStr, aRange);
4670 // XEnumerationAccess
4672 uno::Reference<container::XEnumeration> SAL_CALL ScCellRangesObj::createEnumeration()
4673 throw(uno::RuntimeException, std::exception)
4675 SolarMutexGuard aGuard;
4676 return new ScIndexEnumeration(this, OUString("com.sun.star.sheet.SheetCellRangesEnumeration"));
4679 // XIndexAccess
4681 sal_Int32 SAL_CALL ScCellRangesObj::getCount() throw(uno::RuntimeException, std::exception)
4683 SolarMutexGuard aGuard;
4684 const ScRangeList& rRanges = GetRangeList();
4685 return rRanges.size();
4688 uno::Any SAL_CALL ScCellRangesObj::getByIndex( sal_Int32 nIndex )
4689 throw(lang::IndexOutOfBoundsException,
4690 lang::WrappedTargetException, uno::RuntimeException, std::exception)
4692 SolarMutexGuard aGuard;
4693 uno::Reference<table::XCellRange> xRange(GetObjectByIndex_Impl(nIndex));
4694 if (xRange.is())
4695 return uno::makeAny(xRange);
4696 else
4697 throw lang::IndexOutOfBoundsException();
4700 uno::Type SAL_CALL ScCellRangesObj::getElementType() throw(uno::RuntimeException, std::exception)
4702 SolarMutexGuard aGuard;
4703 return cppu::UnoType<table::XCellRange>::get();
4706 sal_Bool SAL_CALL ScCellRangesObj::hasElements() throw(uno::RuntimeException, std::exception)
4708 SolarMutexGuard aGuard;
4709 const ScRangeList& rRanges = GetRangeList();
4710 return !rRanges.empty();
4713 // XServiceInfo
4714 OUString SAL_CALL ScCellRangesObj::getImplementationName() throw(uno::RuntimeException, std::exception)
4716 return OUString( "ScCellRangesObj" );
4719 sal_Bool SAL_CALL ScCellRangesObj::supportsService( const OUString& rServiceName )
4720 throw(uno::RuntimeException, std::exception)
4722 return cppu::supportsService(this, rServiceName);
4725 uno::Sequence<OUString> SAL_CALL ScCellRangesObj::getSupportedServiceNames()
4726 throw(uno::RuntimeException, std::exception)
4728 uno::Sequence<OUString> aRet(4);
4729 OUString* pArray = aRet.getArray();
4730 pArray[0] = OUString( SCSHEETCELLRANGES_SERVICE );
4731 pArray[1] = OUString( SCCELLPROPERTIES_SERVICE );
4732 pArray[2] = OUString( SCCHARPROPERTIES_SERVICE );
4733 pArray[3] = OUString( SCPARAPROPERTIES_SERVICE );
4734 return aRet;
4737 uno::Reference<table::XCellRange> ScCellRangeObj::CreateRangeFromDoc( ScDocument* pDoc, const ScRange& rR )
4739 SfxObjectShell* pObjSh = pDoc->GetDocumentShell();
4740 if ( pObjSh && pObjSh->ISA(ScDocShell) )
4741 return new ScCellRangeObj( (ScDocShell*) pObjSh, rR );
4742 return NULL;
4745 ScCellRangeObj::ScCellRangeObj(ScDocShell* pDocSh, const ScRange& rR) :
4746 ScCellRangesBase( pDocSh, rR ),
4747 pRangePropSet( lcl_GetRangePropertySet() ),
4748 aRange( rR )
4750 aRange.Justify(); // Anfang / Ende richtig
4753 ScCellRangeObj::~ScCellRangeObj()
4757 void ScCellRangeObj::RefChanged()
4759 ScCellRangesBase::RefChanged();
4761 const ScRangeList& rRanges = GetRangeList();
4762 OSL_ENSURE(rRanges.size() == 1, "was fuer Ranges ?!?!");
4763 if ( !rRanges.empty() )
4765 const ScRange* pFirst = rRanges[0];
4766 aRange = ScRange(*pFirst);
4767 aRange.Justify();
4771 uno::Any SAL_CALL ScCellRangeObj::queryInterface( const uno::Type& rType )
4772 throw(uno::RuntimeException, std::exception)
4774 SC_QUERYINTERFACE( sheet::XCellRangeAddressable )
4775 SC_QUERYINTERFACE( table::XCellRange )
4776 SC_QUERYINTERFACE( sheet::XSheetCellRange )
4777 SC_QUERYINTERFACE( sheet::XArrayFormulaRange )
4778 SC_QUERYINTERFACE( sheet::XArrayFormulaTokens )
4779 SC_QUERYINTERFACE( sheet::XCellRangeData )
4780 SC_QUERYINTERFACE( sheet::XCellRangeFormula )
4781 SC_QUERYINTERFACE( sheet::XMultipleOperation )
4782 SC_QUERYINTERFACE( util::XMergeable )
4783 SC_QUERYINTERFACE( sheet::XCellSeries )
4784 SC_QUERYINTERFACE( table::XAutoFormattable )
4785 SC_QUERYINTERFACE( util::XSortable )
4786 SC_QUERYINTERFACE( sheet::XSheetFilterableEx )
4787 SC_QUERYINTERFACE( sheet::XSheetFilterable )
4788 SC_QUERYINTERFACE( sheet::XSubTotalCalculatable )
4789 SC_QUERYINTERFACE( table::XColumnRowRange )
4790 SC_QUERYINTERFACE( util::XImportable )
4791 SC_QUERYINTERFACE( sheet::XCellFormatRangesSupplier )
4792 SC_QUERYINTERFACE( sheet::XUniqueCellFormatRangesSupplier )
4794 return ScCellRangesBase::queryInterface( rType );
4797 void SAL_CALL ScCellRangeObj::acquire() throw()
4799 ScCellRangesBase::acquire();
4802 void SAL_CALL ScCellRangeObj::release() throw()
4804 ScCellRangesBase::release();
4807 uno::Sequence<uno::Type> SAL_CALL ScCellRangeObj::getTypes() throw(uno::RuntimeException, std::exception)
4809 static uno::Sequence<uno::Type> aTypes;
4810 if ( aTypes.getLength() == 0 )
4812 uno::Sequence<uno::Type> aParentTypes(ScCellRangesBase::getTypes());
4813 long nParentLen = aParentTypes.getLength();
4814 const uno::Type* pParentPtr = aParentTypes.getConstArray();
4816 aTypes.realloc( nParentLen + 17 );
4817 uno::Type* pPtr = aTypes.getArray();
4818 pPtr[nParentLen + 0] = cppu::UnoType<sheet::XCellRangeAddressable>::get();
4819 pPtr[nParentLen + 1] = cppu::UnoType<sheet::XSheetCellRange>::get();
4820 pPtr[nParentLen + 2] = cppu::UnoType<sheet::XArrayFormulaRange>::get();
4821 pPtr[nParentLen + 3] = cppu::UnoType<sheet::XArrayFormulaTokens>::get();
4822 pPtr[nParentLen + 4] = cppu::UnoType<sheet::XCellRangeData>::get();
4823 pPtr[nParentLen + 5] = cppu::UnoType<sheet::XCellRangeFormula>::get();
4824 pPtr[nParentLen + 6] = cppu::UnoType<sheet::XMultipleOperation>::get();
4825 pPtr[nParentLen + 7] = cppu::UnoType<util::XMergeable>::get();
4826 pPtr[nParentLen + 8] = cppu::UnoType<sheet::XCellSeries>::get();
4827 pPtr[nParentLen + 9] = cppu::UnoType<table::XAutoFormattable>::get();
4828 pPtr[nParentLen +10] = cppu::UnoType<util::XSortable>::get();
4829 pPtr[nParentLen +11] = cppu::UnoType<sheet::XSheetFilterableEx>::get();
4830 pPtr[nParentLen +12] = cppu::UnoType<sheet::XSubTotalCalculatable>::get();
4831 pPtr[nParentLen +13] = cppu::UnoType<table::XColumnRowRange>::get();
4832 pPtr[nParentLen +14] = cppu::UnoType<util::XImportable>::get();
4833 pPtr[nParentLen +15] = cppu::UnoType<sheet::XCellFormatRangesSupplier>::get();
4834 pPtr[nParentLen +16] = cppu::UnoType<sheet::XUniqueCellFormatRangesSupplier>::get();
4836 for (long i=0; i<nParentLen; i++)
4837 pPtr[i] = pParentPtr[i]; // parent types first
4839 return aTypes;
4842 uno::Sequence<sal_Int8> SAL_CALL ScCellRangeObj::getImplementationId()
4843 throw(uno::RuntimeException, std::exception)
4845 return css::uno::Sequence<sal_Int8>();
4848 // XCellRange
4850 // ColumnCount / RowCount sind weggefallen
4851 //! werden im Writer fuer Tabellen noch gebraucht ???
4853 uno::Reference<table::XCell> ScCellRangeObj::GetCellByPosition_Impl(
4854 sal_Int32 nColumn, sal_Int32 nRow )
4855 throw(lang::IndexOutOfBoundsException, uno::RuntimeException)
4857 ScDocShell* pDocSh = GetDocShell();
4858 if (!pDocSh)
4859 throw uno::RuntimeException();
4861 if ( nColumn >= 0 && nRow >= 0 )
4863 sal_Int32 nPosX = aRange.aStart.Col() + nColumn;
4864 sal_Int32 nPosY = aRange.aStart.Row() + nRow;
4866 if ( nPosX <= aRange.aEnd.Col() && nPosY <= aRange.aEnd.Row() )
4868 ScAddress aNew( (SCCOL)nPosX, (SCROW)nPosY, aRange.aStart.Tab() );
4869 return new ScCellObj( pDocSh, aNew );
4873 throw lang::IndexOutOfBoundsException();
4876 uno::Reference<table::XCell> SAL_CALL ScCellRangeObj::getCellByPosition(
4877 sal_Int32 nColumn, sal_Int32 nRow )
4878 throw(lang::IndexOutOfBoundsException, uno::RuntimeException, std::exception)
4880 SolarMutexGuard aGuard;
4882 return GetCellByPosition_Impl(nColumn, nRow);
4885 uno::Reference<table::XCellRange> SAL_CALL ScCellRangeObj::getCellRangeByPosition(
4886 sal_Int32 nLeft, sal_Int32 nTop, sal_Int32 nRight, sal_Int32 nBottom )
4887 throw(lang::IndexOutOfBoundsException, uno::RuntimeException, std::exception)
4889 SolarMutexGuard aGuard;
4891 ScDocShell* pDocSh = GetDocShell();
4892 if (!pDocSh)
4893 throw uno::RuntimeException();
4895 if ( nLeft >= 0 && nTop >= 0 && nRight >= 0 && nBottom >= 0 )
4897 sal_Int32 nStartX = aRange.aStart.Col() + nLeft;
4898 sal_Int32 nStartY = aRange.aStart.Row() + nTop;
4899 sal_Int32 nEndX = aRange.aStart.Col() + nRight;
4900 sal_Int32 nEndY = aRange.aStart.Row() + nBottom;
4902 if ( nStartX <= nEndX && nEndX <= aRange.aEnd.Col() &&
4903 nStartY <= nEndY && nEndY <= aRange.aEnd.Row() )
4905 ScRange aNew( (SCCOL)nStartX, (SCROW)nStartY, aRange.aStart.Tab(),
4906 (SCCOL)nEndX, (SCROW)nEndY, aRange.aEnd.Tab() );
4907 return new ScCellRangeObj( pDocSh, aNew );
4911 throw lang::IndexOutOfBoundsException();
4914 uno::Reference<table::XCellRange> SAL_CALL ScCellRangeObj::getCellRangeByName(
4915 const OUString& aName ) throw(uno::RuntimeException, std::exception)
4917 return getCellRangeByName( aName, ScAddress::detailsOOOa1 );
4920 uno::Reference<table::XCellRange> ScCellRangeObj::getCellRangeByName(
4921 const OUString& aName, const ScAddress::Details& rDetails ) throw(uno::RuntimeException)
4923 // name refers to the whole document (with the range's table as default),
4924 // valid only if the range is within this range
4926 SolarMutexGuard aGuard;
4927 ScDocShell* pDocSh = GetDocShell();
4928 if ( pDocSh )
4930 ScDocument* pDoc = pDocSh->GetDocument();
4931 SCTAB nTab = aRange.aStart.Tab();
4933 ScRange aCellRange;
4934 bool bFound = false;
4935 OUString aString(aName);
4936 sal_uInt16 nParse = aCellRange.ParseAny( aString, pDoc, rDetails );
4937 if ( nParse & SCA_VALID )
4939 if ( !(nParse & SCA_TAB_3D) ) // keine Tabelle angegeben -> auf dieser Tabelle
4941 aCellRange.aStart.SetTab(nTab);
4942 aCellRange.aEnd.SetTab(nTab);
4944 bFound = true;
4946 else
4948 ScRangeUtil aRangeUtil;
4949 if ( aRangeUtil.MakeRangeFromName( aString, pDoc, nTab, aCellRange, RUTL_NAMES ) ||
4950 aRangeUtil.MakeRangeFromName( aString, pDoc, nTab, aCellRange, RUTL_DBASE ) )
4951 bFound = true;
4954 if (bFound) // valid only if within this object's range
4956 if (!aRange.In(aCellRange))
4957 bFound = false;
4960 if (bFound)
4962 if ( aCellRange.aStart == aCellRange.aEnd )
4963 return new ScCellObj( pDocSh, aCellRange.aStart );
4964 else
4965 return new ScCellRangeObj( pDocSh, aCellRange );
4969 throw uno::RuntimeException();
4972 // XColumnRowRange
4974 uno::Reference<table::XTableColumns> SAL_CALL ScCellRangeObj::getColumns() throw(uno::RuntimeException, std::exception)
4976 SolarMutexGuard aGuard;
4977 ScDocShell* pDocSh = GetDocShell();
4978 if (pDocSh)
4979 return new ScTableColumnsObj( pDocSh, aRange.aStart.Tab(),
4980 aRange.aStart.Col(), aRange.aEnd.Col() );
4982 OSL_FAIL("Dokument ungueltig");
4983 return NULL;
4986 uno::Reference<table::XTableRows> SAL_CALL ScCellRangeObj::getRows() throw(uno::RuntimeException, std::exception)
4988 SolarMutexGuard aGuard;
4989 ScDocShell* pDocSh = GetDocShell();
4990 if (pDocSh)
4991 return new ScTableRowsObj( pDocSh, aRange.aStart.Tab(),
4992 aRange.aStart.Row(), aRange.aEnd.Row() );
4994 OSL_FAIL("Dokument ungueltig");
4995 return NULL;
4998 // XAddressableCellRange
5000 table::CellRangeAddress SAL_CALL ScCellRangeObj::getRangeAddress() throw(uno::RuntimeException, std::exception)
5002 SolarMutexGuard aGuard;
5003 table::CellRangeAddress aRet;
5004 ScUnoConversion::FillApiRange( aRet, aRange );
5005 return aRet;
5008 // XSheetCellRange
5010 uno::Reference<sheet::XSpreadsheet> SAL_CALL ScCellRangeObj::getSpreadsheet()
5011 throw(uno::RuntimeException, std::exception)
5013 SolarMutexGuard aGuard;
5014 ScDocShell* pDocSh = GetDocShell();
5015 if (pDocSh)
5016 return new ScTableSheetObj( pDocSh, aRange.aStart.Tab() );
5018 OSL_FAIL("Dokument ungueltig");
5019 return NULL;
5022 // XArrayFormulaRange
5024 OUString SAL_CALL ScCellRangeObj::getArrayFormula() throw(uno::RuntimeException, std::exception)
5026 SolarMutexGuard aGuard;
5028 // Matrix-Formel, wenn eindeutig Teil einer Matrix,
5029 // also wenn Anfang und Ende des Blocks zur selben Matrix gehoeren.
5030 // Sonst Leerstring.
5032 ScDocShell* pDocSh = GetDocShell();
5033 if (!pDocSh)
5034 return EMPTY_OUSTRING;
5036 OUString aFormula;
5038 ScDocument* pDoc = pDocSh->GetDocument();
5039 ScRefCellValue aCell1;
5040 ScRefCellValue aCell2;
5041 aCell1.assign(*pDoc, aRange.aStart);
5042 aCell2.assign(*pDoc, aRange.aEnd);
5043 if (aCell1.meType == CELLTYPE_FORMULA && aCell2.meType == CELLTYPE_FORMULA)
5045 const ScFormulaCell* pFCell1 = aCell1.mpFormula;
5046 const ScFormulaCell* pFCell2 = aCell2.mpFormula;
5047 ScAddress aStart1;
5048 ScAddress aStart2;
5049 if (pFCell1->GetMatrixOrigin(aStart1) && pFCell2->GetMatrixOrigin(aStart2))
5051 if (aStart1 == aStart2) // beides dieselbe Matrix
5052 pFCell1->GetFormula(aFormula); // egal, von welcher Zelle
5055 return aFormula;
5058 void ScCellRangeObj::SetArrayFormula_Impl( const OUString& rFormula,
5059 const OUString& rFormulaNmsp, const formula::FormulaGrammar::Grammar eGrammar ) throw(uno::RuntimeException)
5061 ScDocShell* pDocSh = GetDocShell();
5062 if (pDocSh)
5064 if ( !rFormula.isEmpty() )
5066 if ( ScTableSheetObj::getImplementation( (cppu::OWeakObject*)this ) )
5068 // don't set array formula for sheet object
5069 throw uno::RuntimeException();
5072 pDocSh->GetDocFunc().EnterMatrix( aRange, NULL, NULL, rFormula, true, true, rFormulaNmsp, eGrammar );
5074 else
5076 // empty string -> erase array formula
5077 ScMarkData aMark;
5078 aMark.SetMarkArea( aRange );
5079 aMark.SelectTable( aRange.aStart.Tab(), true );
5080 pDocSh->GetDocFunc().DeleteContents( aMark, IDF_CONTENTS, true, true );
5085 void SAL_CALL ScCellRangeObj::setArrayFormula( const OUString& aFormula )
5086 throw(uno::RuntimeException, std::exception)
5088 SolarMutexGuard aGuard;
5089 // GRAM_PODF_A1 for API compatibility.
5090 SetArrayFormula_Impl( aFormula, OUString(), formula::FormulaGrammar::GRAM_PODF_A1);
5093 void ScCellRangeObj::SetArrayFormulaWithGrammar( const OUString& rFormula,
5094 const OUString& rFormulaNmsp, const formula::FormulaGrammar::Grammar eGrammar ) throw(uno::RuntimeException)
5096 SolarMutexGuard aGuard;
5097 SetArrayFormula_Impl( rFormula, rFormulaNmsp, eGrammar);
5100 // XArrayFormulaTokens
5102 uno::Sequence<sheet::FormulaToken> SAL_CALL ScCellRangeObj::getArrayTokens()
5103 throw (uno::RuntimeException, std::exception)
5105 SolarMutexGuard aGuard;
5107 // same cell logic as in getArrayFormula
5109 uno::Sequence<sheet::FormulaToken> aSequence;
5110 ScDocShell* pDocSh = GetDocShell();
5111 if (!pDocSh)
5112 return aSequence;
5114 ScDocument* pDoc = pDocSh->GetDocument();
5115 ScRefCellValue aCell1;
5116 ScRefCellValue aCell2;
5117 aCell1.assign(*pDoc, aRange.aStart);
5118 aCell2.assign(*pDoc, aRange.aEnd);
5119 if (aCell1.meType == CELLTYPE_FORMULA && aCell2.meType == CELLTYPE_FORMULA)
5121 const ScFormulaCell* pFCell1 = aCell1.mpFormula;
5122 const ScFormulaCell* pFCell2 = aCell2.mpFormula;
5123 ScAddress aStart1;
5124 ScAddress aStart2;
5125 if (pFCell1->GetMatrixOrigin(aStart1) && pFCell2->GetMatrixOrigin(aStart2))
5127 if (aStart1 == aStart2)
5129 const ScTokenArray* pTokenArray = pFCell1->GetCode();
5130 if (pTokenArray)
5131 (void)ScTokenConversion::ConvertToTokenSequence(*pDoc, aSequence, *pTokenArray);
5136 return aSequence;
5139 void SAL_CALL ScCellRangeObj::setArrayTokens( const uno::Sequence<sheet::FormulaToken>& rTokens ) throw(uno::RuntimeException, std::exception)
5141 SolarMutexGuard aGuard;
5142 ScDocShell* pDocSh = GetDocShell();
5143 if ( pDocSh )
5145 if ( rTokens.getLength() )
5147 if ( ScTableSheetObj::getImplementation( (cppu::OWeakObject*)this ) )
5149 throw uno::RuntimeException();
5152 ScDocument* pDoc = pDocSh->GetDocument();
5153 ScTokenArray aTokenArray;
5154 (void)ScTokenConversion::ConvertToTokenArray( *pDoc, aTokenArray, rTokens );
5156 // Actually GRAM_PODF_A1 is a don't-care here because of the token
5157 // array being set, it fits with other API compatibility grammars
5158 // though.
5159 pDocSh->GetDocFunc().EnterMatrix( aRange, NULL, &aTokenArray, EMPTY_OUSTRING, true, true, EMPTY_OUSTRING, formula::FormulaGrammar::GRAM_PODF_A1 );
5161 else
5163 // empty sequence -> erase array formula
5164 ScMarkData aMark;
5165 aMark.SetMarkArea( aRange );
5166 aMark.SelectTable( aRange.aStart.Tab(), true );
5167 pDocSh->GetDocFunc().DeleteContents( aMark, IDF_CONTENTS, true, true );
5172 // XCellRangeData
5174 uno::Sequence< uno::Sequence<uno::Any> > SAL_CALL ScCellRangeObj::getDataArray()
5175 throw(uno::RuntimeException, std::exception)
5177 SolarMutexGuard aGuard;
5179 if ( ScTableSheetObj::getImplementation( (cppu::OWeakObject*)this ) )
5181 // don't create a data array for the sheet
5182 throw uno::RuntimeException();
5185 ScDocShell* pDocSh = GetDocShell();
5186 if (pDocSh)
5188 uno::Any aAny;
5189 // bAllowNV = TRUE: errors as void
5190 if ( ScRangeToSequence::FillMixedArray( aAny, pDocSh->GetDocument(), aRange, true ) )
5192 uno::Sequence< uno::Sequence<uno::Any> > aSeq;
5193 if ( aAny >>= aSeq )
5194 return aSeq; // success
5198 throw uno::RuntimeException(); // no other exceptions specified
5201 void SAL_CALL ScCellRangeObj::setDataArray(
5202 const uno::Sequence< uno::Sequence<uno::Any> >& aArray )
5203 throw(uno::RuntimeException, std::exception)
5205 SolarMutexGuard aGuard;
5207 bool bDone = false;
5208 ScDocShell* pDocSh = GetDocShell();
5209 if (pDocSh)
5211 //! move lcl_PutDataArray to docfunc?
5212 bDone = lcl_PutDataArray( *pDocSh, aRange, aArray );
5215 if (!bDone)
5216 throw uno::RuntimeException(); // no other exceptions specified
5219 // XCellRangeFormula
5221 uno::Sequence< uno::Sequence<OUString> > SAL_CALL ScCellRangeObj::getFormulaArray()
5222 throw(uno::RuntimeException, std::exception)
5224 SolarMutexGuard aGuard;
5226 if ( ScTableSheetObj::getImplementation( (cppu::OWeakObject*)this ) )
5228 // don't create a data array for the sheet
5229 throw uno::RuntimeException();
5232 ScDocShell* pDocSh = GetDocShell();
5233 if (pDocSh)
5235 SCCOL nStartCol = aRange.aStart.Col();
5236 SCROW nStartRow = aRange.aStart.Row();
5237 SCCOL nEndCol = aRange.aEnd.Col();
5238 SCROW nEndRow = aRange.aEnd.Row();
5239 SCCOL nColCount = nEndCol + 1 - nStartCol;
5240 SCROW nRowCount = nEndRow + 1 - nStartRow;
5241 SCTAB nTab = aRange.aStart.Tab();
5243 uno::Sequence< uno::Sequence<OUString> > aRowSeq( nRowCount );
5244 uno::Sequence<OUString>* pRowAry = aRowSeq.getArray();
5245 for (SCROW nRowIndex = 0; nRowIndex < nRowCount; nRowIndex++)
5247 uno::Sequence<OUString> aColSeq( nColCount );
5248 OUString* pColAry = aColSeq.getArray();
5249 for (SCCOL nColIndex = 0; nColIndex < nColCount; nColIndex++)
5250 pColAry[nColIndex] = lcl_GetInputString( pDocSh->GetDocument(),
5251 ScAddress( nStartCol+nColIndex, nStartRow+nRowIndex, nTab ), true );
5253 pRowAry[nRowIndex] = aColSeq;
5256 return aRowSeq;
5259 throw uno::RuntimeException(); // no other exceptions specified
5262 void SAL_CALL ScCellRangeObj::setFormulaArray(
5263 const uno::Sequence< uno::Sequence<OUString> >& aArray )
5264 throw(uno::RuntimeException, std::exception)
5266 SolarMutexGuard aGuard;
5268 bool bDone = false;
5269 ScDocShell* pDocSh = GetDocShell();
5270 if (pDocSh)
5272 ScExternalRefManager::ApiGuard aExtRefGuard(pDocSh->GetDocument());
5274 // GRAM_PODF_A1 for API compatibility.
5275 bDone = lcl_PutFormulaArray( *pDocSh, aRange, aArray, formula::FormulaGrammar::GRAM_PODF_A1 );
5278 if (!bDone)
5279 throw uno::RuntimeException(); // no other exceptions specified
5282 // XMultipleOperation
5284 void SAL_CALL ScCellRangeObj::setTableOperation( const table::CellRangeAddress& aFormulaRange,
5285 sheet::TableOperationMode nMode,
5286 const table::CellAddress& aColumnCell,
5287 const table::CellAddress& aRowCell )
5288 throw(uno::RuntimeException, std::exception)
5290 SolarMutexGuard aGuard;
5291 ScDocShell* pDocSh = GetDocShell();
5292 if (pDocSh)
5294 bool bError = false;
5295 ScTabOpParam aParam;
5296 aParam.aRefFormulaCell = ScRefAddress( (SCCOL)aFormulaRange.StartColumn,
5297 (SCROW)aFormulaRange.StartRow, aFormulaRange.Sheet,
5298 false, false, false );
5299 aParam.aRefFormulaEnd = ScRefAddress( (SCCOL)aFormulaRange.EndColumn,
5300 (SCROW)aFormulaRange.EndRow, aFormulaRange.Sheet,
5301 false, false, false );
5302 aParam.aRefRowCell = ScRefAddress( (SCCOL)aRowCell.Column,
5303 (SCROW)aRowCell.Row, aRowCell.Sheet,
5304 false, false, false );
5305 aParam.aRefColCell = ScRefAddress( (SCCOL)aColumnCell.Column,
5306 (SCROW)aColumnCell.Row, aColumnCell.Sheet,
5307 false, false, false );
5309 switch (nMode)
5311 case sheet::TableOperationMode_COLUMN:
5312 aParam.meMode = ScTabOpParam::Column;
5313 break;
5314 case sheet::TableOperationMode_ROW:
5315 aParam.meMode = ScTabOpParam::Row;
5316 break;
5317 case sheet::TableOperationMode_BOTH:
5318 aParam.meMode = ScTabOpParam::Both;
5319 break;
5320 default:
5321 bError = true;
5324 if (!bError)
5325 pDocSh->GetDocFunc().TabOp( aRange, NULL, aParam, true, true );
5329 // XMergeable
5331 void SAL_CALL ScCellRangeObj::merge( sal_Bool bMerge ) throw(uno::RuntimeException, std::exception)
5333 SolarMutexGuard aGuard;
5334 ScDocShell* pDocSh = GetDocShell();
5335 if ( pDocSh )
5337 ScCellMergeOption aMergeOption(
5338 aRange.aStart.Col(), aRange.aStart.Row(),
5339 aRange.aEnd.Col(), aRange.aEnd.Row(), false);
5340 aMergeOption.maTabs.insert(aRange.aStart.Tab());
5341 if ( bMerge )
5342 pDocSh->GetDocFunc().MergeCells( aMergeOption, false, true, true );
5343 else
5344 pDocSh->GetDocFunc().UnmergeCells( aMergeOption, true );
5346 //! Fehler abfangen?
5350 sal_Bool SAL_CALL ScCellRangeObj::getIsMerged() throw(uno::RuntimeException, std::exception)
5352 SolarMutexGuard aGuard;
5353 ScDocShell* pDocSh = GetDocShell();
5354 return pDocSh && pDocSh->GetDocument()->HasAttrib( aRange, HASATTR_MERGED );
5357 // XCellSeries
5359 void SAL_CALL ScCellRangeObj::fillSeries( sheet::FillDirection nFillDirection,
5360 sheet::FillMode nFillMode, sheet::FillDateMode nFillDateMode,
5361 double fStep, double fEndValue ) throw(uno::RuntimeException, std::exception)
5363 SolarMutexGuard aGuard;
5364 ScDocShell* pDocSh = GetDocShell();
5365 if ( pDocSh )
5367 bool bError = false;
5369 FillDir eDir = FILL_TO_BOTTOM;
5370 switch (nFillDirection)
5372 case sheet::FillDirection_TO_BOTTOM:
5373 eDir = FILL_TO_BOTTOM;
5374 break;
5375 case sheet::FillDirection_TO_RIGHT:
5376 eDir = FILL_TO_RIGHT;
5377 break;
5378 case sheet::FillDirection_TO_TOP:
5379 eDir = FILL_TO_TOP;
5380 break;
5381 case sheet::FillDirection_TO_LEFT:
5382 eDir = FILL_TO_LEFT;
5383 break;
5384 default:
5385 bError = true;
5388 FillCmd eCmd = FILL_SIMPLE;
5389 switch ( nFillMode )
5391 case sheet::FillMode_SIMPLE:
5392 eCmd = FILL_SIMPLE;
5393 break;
5394 case sheet::FillMode_LINEAR:
5395 eCmd = FILL_LINEAR;
5396 break;
5397 case sheet::FillMode_GROWTH:
5398 eCmd = FILL_GROWTH;
5399 break;
5400 case sheet::FillMode_DATE:
5401 eCmd = FILL_DATE;
5402 break;
5403 case sheet::FillMode_AUTO:
5404 eCmd = FILL_AUTO;
5405 break;
5406 default:
5407 bError = true;
5410 FillDateCmd eDateCmd = FILL_DAY;
5411 switch ( nFillDateMode )
5413 case sheet::FillDateMode_FILL_DATE_DAY:
5414 eDateCmd = FILL_DAY;
5415 break;
5416 case sheet::FillDateMode_FILL_DATE_WEEKDAY:
5417 eDateCmd = FILL_WEEKDAY;
5418 break;
5419 case sheet::FillDateMode_FILL_DATE_MONTH:
5420 eDateCmd = FILL_MONTH;
5421 break;
5422 case sheet::FillDateMode_FILL_DATE_YEAR:
5423 eDateCmd = FILL_YEAR;
5424 break;
5425 default:
5426 bError = true;
5429 if (!bError)
5430 pDocSh->GetDocFunc().FillSeries( aRange, NULL, eDir, eCmd, eDateCmd,
5431 MAXDOUBLE, fStep, fEndValue, true, true );
5435 void SAL_CALL ScCellRangeObj::fillAuto( sheet::FillDirection nFillDirection,
5436 sal_Int32 nSourceCount ) throw(uno::RuntimeException, std::exception)
5438 SolarMutexGuard aGuard;
5439 ScDocShell* pDocSh = GetDocShell();
5440 if ( pDocSh && nSourceCount )
5442 ScRange aSourceRange(aRange);
5443 SCsCOLROW nCount = 0; // "Dest-Count"
5444 FillDir eDir = FILL_TO_BOTTOM;
5445 bool bError = false;
5446 switch (nFillDirection)
5448 case sheet::FillDirection_TO_BOTTOM:
5449 aSourceRange.aEnd.SetRow( static_cast<SCROW>( aSourceRange.aStart.Row() + nSourceCount - 1 ) );
5450 nCount = aRange.aEnd.Row() - aSourceRange.aEnd.Row();
5451 eDir = FILL_TO_BOTTOM;
5452 break;
5453 case sheet::FillDirection_TO_RIGHT:
5454 aSourceRange.aEnd.SetCol( static_cast<SCCOL>( aSourceRange.aStart.Col() + nSourceCount - 1 ) );
5455 nCount = aRange.aEnd.Col() - aSourceRange.aEnd.Col();
5456 eDir = FILL_TO_RIGHT;
5457 break;
5458 case sheet::FillDirection_TO_TOP:
5459 aSourceRange.aStart.SetRow( static_cast<SCROW>( aSourceRange.aEnd.Row() - nSourceCount + 1 ) );
5460 nCount = aSourceRange.aStart.Row() - aRange.aStart.Row();
5461 eDir = FILL_TO_TOP;
5462 break;
5463 case sheet::FillDirection_TO_LEFT:
5464 aSourceRange.aStart.SetCol( static_cast<SCCOL>( aSourceRange.aEnd.Col() - nSourceCount + 1 ) );
5465 nCount = aSourceRange.aStart.Col() - aRange.aStart.Col();
5466 eDir = FILL_TO_LEFT;
5467 break;
5468 default:
5469 bError = true;
5471 if (nCount < 0 || nCount > MAXROW) // overflow
5472 bError = true;
5474 if (!bError)
5475 pDocSh->GetDocFunc().FillAuto( aSourceRange, NULL, eDir, nCount, true, true );
5479 // XAutoFormattable
5481 void SAL_CALL ScCellRangeObj::autoFormat( const OUString& aName )
5482 throw(lang::IllegalArgumentException, uno::RuntimeException, std::exception)
5484 SolarMutexGuard aGuard;
5485 ScDocShell* pDocSh = GetDocShell();
5486 if ( pDocSh )
5488 ScAutoFormat* pAutoFormat = ScGlobal::GetOrCreateAutoFormat();
5489 ScAutoFormat::const_iterator it = pAutoFormat->find(aName);
5490 if (it != pAutoFormat->end())
5492 ScAutoFormat::const_iterator itBeg = pAutoFormat->begin();
5493 size_t nIndex = std::distance(itBeg, it);
5494 pDocSh->GetDocFunc().AutoFormat(aRange, NULL, nIndex, true, true);
5496 else
5497 throw lang::IllegalArgumentException();
5501 // XSortable
5503 uno::Sequence<beans::PropertyValue> SAL_CALL ScCellRangeObj::createSortDescriptor()
5504 throw(uno::RuntimeException, std::exception)
5506 SolarMutexGuard aGuard;
5507 ScSortParam aParam;
5508 ScDocShell* pDocSh = GetDocShell();
5509 if ( pDocSh )
5511 // DB-Bereich anlegen erst beim Ausfuehren, per API immer genau den Bereich
5512 ScDBData* pData = pDocSh->GetDBData( aRange, SC_DB_OLD, SC_DBSEL_FORCE_MARK );
5513 if (pData)
5515 pData->GetSortParam(aParam);
5517 // im SortDescriptor sind die Fields innerhalb des Bereichs gezaehlt
5518 ScRange aDBRange;
5519 pData->GetArea(aDBRange);
5520 SCCOLROW nFieldStart = aParam.bByRow ?
5521 static_cast<SCCOLROW>(aDBRange.aStart.Col()) :
5522 static_cast<SCCOLROW>(aDBRange.aStart.Row());
5523 for (sal_uInt16 i=0; i<aParam.GetSortKeyCount(); i++)
5524 if ( aParam.maKeyState[i].bDoSort && aParam.maKeyState[i].nField >= nFieldStart )
5525 aParam.maKeyState[i].nField -= nFieldStart;
5529 uno::Sequence<beans::PropertyValue> aSeq( ScSortDescriptor::GetPropertyCount() );
5530 ScSortDescriptor::FillProperties( aSeq, aParam );
5531 return aSeq;
5534 void SAL_CALL ScCellRangeObj::sort( const uno::Sequence<beans::PropertyValue>& aDescriptor )
5535 throw(uno::RuntimeException, std::exception)
5537 SolarMutexGuard aGuard;
5538 ScDocShell* pDocSh = GetDocShell();
5539 if (pDocSh)
5541 sal_uInt16 i;
5542 ScSortParam aParam;
5543 ScDBData* pData = pDocSh->GetDBData( aRange, SC_DB_MAKE, SC_DBSEL_FORCE_MARK ); // ggf. Bereich anlegen
5544 if (pData)
5546 // alten Einstellungen holen, falls nicht alles neu gesetzt wird
5547 pData->GetSortParam(aParam);
5548 SCCOLROW nOldStart = aParam.bByRow ?
5549 static_cast<SCCOLROW>(aRange.aStart.Col()) :
5550 static_cast<SCCOLROW>(aRange.aStart.Row());
5551 for (i=0; i<aParam.GetSortKeyCount(); i++)
5552 if ( aParam.maKeyState[i].bDoSort && aParam.maKeyState[i].nField >= nOldStart )
5553 aParam.maKeyState[i].nField -= nOldStart;
5556 ScSortDescriptor::FillSortParam( aParam, aDescriptor );
5558 // im SortDescriptor sind die Fields innerhalb des Bereichs gezaehlt
5559 // ByRow kann bei FillSortParam umgesetzt worden sein
5560 SCCOLROW nFieldStart = aParam.bByRow ?
5561 static_cast<SCCOLROW>(aRange.aStart.Col()) :
5562 static_cast<SCCOLROW>(aRange.aStart.Row());
5563 for (i=0; i<aParam.GetSortKeyCount(); i++)
5564 aParam.maKeyState[i].nField += nFieldStart;
5566 SCTAB nTab = aRange.aStart.Tab();
5567 aParam.nCol1 = aRange.aStart.Col();
5568 aParam.nRow1 = aRange.aStart.Row();
5569 aParam.nCol2 = aRange.aEnd.Col();
5570 aParam.nRow2 = aRange.aEnd.Row();
5572 pDocSh->GetDBData( aRange, SC_DB_MAKE, SC_DBSEL_FORCE_MARK ); // ggf. Bereich anlegen
5574 ScDBDocFunc aFunc(*pDocSh); // Bereich muss angelegt sein
5575 aFunc.Sort( nTab, aParam, true, true, true );
5579 // XFilterable
5581 uno::Reference<sheet::XSheetFilterDescriptor> SAL_CALL ScCellRangeObj::createFilterDescriptor(
5582 sal_Bool bEmpty ) throw(uno::RuntimeException, std::exception)
5584 SolarMutexGuard aGuard;
5585 ScDocShell* pDocSh = GetDocShell();
5586 ScFilterDescriptor* pNew = new ScFilterDescriptor(pDocSh);
5587 if ( !bEmpty && pDocSh )
5589 // DB-Bereich anlegen erst beim Ausfuehren, per API immer genau den Bereich
5590 ScDBData* pData = pDocSh->GetDBData( aRange, SC_DB_OLD, SC_DBSEL_FORCE_MARK );
5591 if (pData)
5593 ScQueryParam aParam;
5594 pData->GetQueryParam(aParam);
5595 // im FilterDescriptor sind die Fields innerhalb des Bereichs gezaehlt
5596 ScRange aDBRange;
5597 pData->GetArea(aDBRange);
5598 SCCOLROW nFieldStart = aParam.bByRow ?
5599 static_cast<SCCOLROW>(aDBRange.aStart.Col()) :
5600 static_cast<SCCOLROW>(aDBRange.aStart.Row());
5601 SCSIZE nCount = aParam.GetEntryCount();
5602 for (SCSIZE i=0; i<nCount; i++)
5604 ScQueryEntry& rEntry = aParam.GetEntry(i);
5605 if (rEntry.bDoQuery && rEntry.nField >= nFieldStart)
5606 rEntry.nField -= nFieldStart;
5608 pNew->SetParam(aParam);
5611 return pNew;
5614 void SAL_CALL ScCellRangeObj::filter( const uno::Reference<sheet::XSheetFilterDescriptor>& xDescriptor )
5615 throw(uno::RuntimeException, std::exception)
5617 SolarMutexGuard aGuard;
5619 // das koennte theoretisch ein fremdes Objekt sein, also nur das
5620 // oeffentliche XSheetFilterDescriptor Interface benutzen, um
5621 // die Daten in ein ScFilterDescriptor Objekt zu kopieren:
5622 //! wenn es schon ein ScFilterDescriptor ist, direkt per getImplementation?
5624 ScDocShell* pDocSh = GetDocShell();
5625 ScFilterDescriptor aImpl(pDocSh);
5626 uno::Reference< sheet::XSheetFilterDescriptor2 > xDescriptor2( xDescriptor, uno::UNO_QUERY );
5627 if ( xDescriptor2.is() )
5629 aImpl.setFilterFields2( xDescriptor2->getFilterFields2() );
5631 else
5633 aImpl.setFilterFields( xDescriptor->getFilterFields() );
5635 // Rest sind jetzt Properties...
5637 uno::Reference<beans::XPropertySet> xPropSet( xDescriptor, uno::UNO_QUERY );
5638 if (xPropSet.is())
5639 lcl_CopyProperties( aImpl, *(beans::XPropertySet*)xPropSet.get() );
5642 // ausfuehren...
5645 if (pDocSh)
5647 ScQueryParam aParam = aImpl.GetParam();
5648 // im FilterDescriptor sind die Fields innerhalb des Bereichs gezaehlt
5649 SCCOLROW nFieldStart = aParam.bByRow ?
5650 static_cast<SCCOLROW>(aRange.aStart.Col()) :
5651 static_cast<SCCOLROW>(aRange.aStart.Row());
5652 SCSIZE nCount = aParam.GetEntryCount();
5653 svl::SharedStringPool& rPool = pDocSh->GetDocument()->GetSharedStringPool();
5654 for (SCSIZE i=0; i<nCount; i++)
5656 ScQueryEntry& rEntry = aParam.GetEntry(i);
5657 if (rEntry.bDoQuery)
5659 rEntry.nField += nFieldStart;
5660 // Im Dialog wird immer der String angezeigt -> muss zum Wert passen
5661 ScQueryEntry::QueryItemsType& rItems = rEntry.GetQueryItems();
5662 rItems.resize(1);
5663 ScQueryEntry::Item& rItem = rItems.front();
5664 if (rItem.meType != ScQueryEntry::ByString)
5666 OUString aStr;
5667 pDocSh->GetDocument()->GetFormatTable()->GetInputLineString(rItem.mfVal, 0, aStr);
5668 rItem.maString = rPool.intern(aStr);
5673 SCTAB nTab = aRange.aStart.Tab();
5674 aParam.nCol1 = aRange.aStart.Col();
5675 aParam.nRow1 = aRange.aStart.Row();
5676 aParam.nCol2 = aRange.aEnd.Col();
5677 aParam.nRow2 = aRange.aEnd.Row();
5679 pDocSh->GetDBData( aRange, SC_DB_MAKE, SC_DBSEL_FORCE_MARK ); // ggf. Bereich anlegen
5681 //! keep source range in filter descriptor
5682 //! if created by createFilterDescriptorByObject ???
5684 ScDBDocFunc aFunc(*pDocSh);
5685 aFunc.Query( nTab, aParam, NULL, true, true ); // Bereich muss angelegt sein
5689 //! get/setAutoFilter als Properties!!!
5691 // XAdvancedFilterSource
5693 uno::Reference<sheet::XSheetFilterDescriptor> SAL_CALL ScCellRangeObj::createFilterDescriptorByObject(
5694 const uno::Reference<sheet::XSheetFilterable>& xObject )
5695 throw(uno::RuntimeException, std::exception)
5697 SolarMutexGuard aGuard;
5699 // this ist hier nicht der Bereich, der gefiltert wird, sondern der
5700 // Bereich mit der Abfrage...
5702 uno::Reference<sheet::XCellRangeAddressable> xAddr( xObject, uno::UNO_QUERY );
5704 ScDocShell* pDocSh = GetDocShell();
5705 if ( pDocSh && xAddr.is() )
5707 //! Test, ob xObject im selben Dokument ist
5709 ScFilterDescriptor* pNew = new ScFilterDescriptor(pDocSh); //! stattdessen vom Objekt?
5711 ScQueryParam aParam = pNew->GetParam();
5712 aParam.bHasHeader = true;
5714 table::CellRangeAddress aDataAddress(xAddr->getRangeAddress());
5715 aParam.nCol1 = (SCCOL)aDataAddress.StartColumn;
5716 aParam.nRow1 = (SCROW)aDataAddress.StartRow;
5717 aParam.nCol2 = (SCCOL)aDataAddress.EndColumn;
5718 aParam.nRow2 = (SCROW)aDataAddress.EndRow;
5719 aParam.nTab = aDataAddress.Sheet;
5721 ScDocument* pDoc = pDocSh->GetDocument();
5722 bool bOk = pDoc->CreateQueryParam(
5723 aRange.aStart.Col(), aRange.aStart.Row(),
5724 aRange.aEnd.Col(), aRange.aEnd.Row(),
5725 aRange.aStart.Tab(), aParam );
5726 if ( bOk )
5728 // im FilterDescriptor sind die Fields innerhalb des Bereichs gezaehlt
5729 SCCOLROW nFieldStart = aParam.bByRow ?
5730 static_cast<SCCOLROW>(aDataAddress.StartColumn) :
5731 static_cast<SCCOLROW>(aDataAddress.StartRow);
5732 SCSIZE nCount = aParam.GetEntryCount();
5733 for (SCSIZE i=0; i<nCount; i++)
5735 ScQueryEntry& rEntry = aParam.GetEntry(i);
5736 if (rEntry.bDoQuery && rEntry.nField >= nFieldStart)
5737 rEntry.nField -= nFieldStart;
5740 pNew->SetParam( aParam );
5741 return pNew;
5743 else
5745 delete pNew;
5746 return NULL; // ungueltig -> null
5750 OSL_FAIL("kein Dokument oder kein Bereich");
5751 return NULL;
5754 // XSubTotalSource
5756 uno::Reference<sheet::XSubTotalDescriptor> SAL_CALL ScCellRangeObj::createSubTotalDescriptor(
5757 sal_Bool bEmpty ) throw(uno::RuntimeException, std::exception)
5759 SolarMutexGuard aGuard;
5760 ScSubTotalDescriptor* pNew = new ScSubTotalDescriptor;
5761 ScDocShell* pDocSh = GetDocShell();
5762 if ( !bEmpty && pDocSh )
5764 // DB-Bereich anlegen erst beim Ausfuehren, per API immer genau den Bereich
5765 ScDBData* pData = pDocSh->GetDBData( aRange, SC_DB_OLD, SC_DBSEL_FORCE_MARK );
5766 if (pData)
5768 ScSubTotalParam aParam;
5769 pData->GetSubTotalParam(aParam);
5770 // im SubTotalDescriptor sind die Fields innerhalb des Bereichs gezaehlt
5771 ScRange aDBRange;
5772 pData->GetArea(aDBRange);
5773 SCCOL nFieldStart = aDBRange.aStart.Col();
5774 for (sal_uInt16 i=0; i<MAXSUBTOTAL; i++)
5776 if ( aParam.bGroupActive[i] )
5778 if ( aParam.nField[i] >= nFieldStart )
5779 aParam.nField[i] = sal::static_int_cast<SCCOL>( aParam.nField[i] - nFieldStart );
5780 for (SCCOL j=0; j<aParam.nSubTotals[i]; j++)
5781 if ( aParam.pSubTotals[i][j] >= nFieldStart )
5782 aParam.pSubTotals[i][j] = sal::static_int_cast<SCCOL>( aParam.pSubTotals[i][j] - nFieldStart );
5785 pNew->SetParam(aParam);
5788 return pNew;
5791 void SAL_CALL ScCellRangeObj::applySubTotals(
5792 const uno::Reference<sheet::XSubTotalDescriptor>& xDescriptor,
5793 sal_Bool bReplace)
5794 throw (uno::RuntimeException, std::exception)
5796 SolarMutexGuard aGuard;
5798 if (!xDescriptor.is()) return;
5800 ScDocShell* pDocSh = GetDocShell();
5801 ScSubTotalDescriptorBase* pImp =
5802 ScSubTotalDescriptorBase::getImplementation( xDescriptor );
5804 if (pDocSh && pImp)
5806 ScSubTotalParam aParam;
5807 pImp->GetData(aParam); // virtuelle Methode der Basisklasse
5809 // im SubTotalDescriptor sind die Fields innerhalb des Bereichs gezaehlt
5810 SCCOL nFieldStart = aRange.aStart.Col();
5811 for (sal_uInt16 i=0; i<MAXSUBTOTAL; i++)
5813 if ( aParam.bGroupActive[i] )
5815 aParam.nField[i] = sal::static_int_cast<SCCOL>( aParam.nField[i] + nFieldStart );
5816 for (SCCOL j=0; j<aParam.nSubTotals[i]; j++)
5817 aParam.pSubTotals[i][j] = sal::static_int_cast<SCCOL>( aParam.pSubTotals[i][j] + nFieldStart );
5821 aParam.bReplace = bReplace;
5823 SCTAB nTab = aRange.aStart.Tab();
5824 aParam.nCol1 = aRange.aStart.Col();
5825 aParam.nRow1 = aRange.aStart.Row();
5826 aParam.nCol2 = aRange.aEnd.Col();
5827 aParam.nRow2 = aRange.aEnd.Row();
5829 pDocSh->GetDBData( aRange, SC_DB_MAKE, SC_DBSEL_FORCE_MARK ); // ggf. Bereich anlegen
5831 ScDBDocFunc aFunc(*pDocSh);
5832 aFunc.DoSubTotals( nTab, aParam, NULL, true, true ); // Bereich muss angelegt sein
5836 void SAL_CALL ScCellRangeObj::removeSubTotals() throw(uno::RuntimeException, std::exception)
5838 SolarMutexGuard aGuard;
5840 ScDocShell* pDocSh = GetDocShell();
5841 if (pDocSh)
5843 ScSubTotalParam aParam;
5844 ScDBData* pData = pDocSh->GetDBData( aRange, SC_DB_OLD, SC_DBSEL_FORCE_MARK );
5845 if (pData)
5846 pData->GetSubTotalParam(aParam); // auch bei Remove die Feld-Eintraege behalten
5848 aParam.bRemoveOnly = true;
5850 SCTAB nTab = aRange.aStart.Tab();
5851 aParam.nCol1 = aRange.aStart.Col();
5852 aParam.nRow1 = aRange.aStart.Row();
5853 aParam.nCol2 = aRange.aEnd.Col();
5854 aParam.nRow2 = aRange.aEnd.Row();
5856 pDocSh->GetDBData( aRange, SC_DB_MAKE, SC_DBSEL_FORCE_MARK ); // ggf. Bereich anlegen
5858 ScDBDocFunc aFunc(*pDocSh);
5859 aFunc.DoSubTotals( nTab, aParam, NULL, true, true ); // Bereich muss angelegt sein
5863 uno::Sequence<beans::PropertyValue> SAL_CALL ScCellRangeObj::createImportDescriptor( sal_Bool bEmpty )
5864 throw(uno::RuntimeException, std::exception)
5866 SolarMutexGuard aGuard;
5867 ScImportParam aParam;
5868 ScDocShell* pDocSh = GetDocShell();
5869 if ( !bEmpty && pDocSh )
5871 // DB-Bereich anlegen erst beim Ausfuehren, per API immer genau den Bereich
5872 ScDBData* pData = pDocSh->GetDBData( aRange, SC_DB_OLD, SC_DBSEL_FORCE_MARK );
5873 if (pData)
5874 pData->GetImportParam(aParam);
5877 uno::Sequence<beans::PropertyValue> aSeq( ScImportDescriptor::GetPropertyCount() );
5878 ScImportDescriptor::FillProperties( aSeq, aParam );
5879 return aSeq;
5882 void SAL_CALL ScCellRangeObj::doImport( const uno::Sequence<beans::PropertyValue>& aDescriptor )
5883 throw(uno::RuntimeException, std::exception)
5885 SolarMutexGuard aGuard;
5886 ScDocShell* pDocSh = GetDocShell();
5887 if (pDocSh)
5889 ScImportParam aParam;
5890 ScImportDescriptor::FillImportParam( aParam, aDescriptor );
5892 SCTAB nTab = aRange.aStart.Tab();
5893 aParam.nCol1 = aRange.aStart.Col();
5894 aParam.nRow1 = aRange.aStart.Row();
5895 aParam.nCol2 = aRange.aEnd.Col();
5896 aParam.nRow2 = aRange.aEnd.Row();
5898 //! TODO: could we get passed a valid result set by any means?
5900 pDocSh->GetDBData( aRange, SC_DB_MAKE, SC_DBSEL_FORCE_MARK ); // ggf. Bereich anlegen
5902 ScDBDocFunc aFunc(*pDocSh); // Bereich muss angelegt sein
5903 aFunc.DoImport( nTab, aParam, NULL, true ); //! Api-Flag as parameter
5907 // XCellFormatRangesSupplier
5909 uno::Reference<container::XIndexAccess> SAL_CALL ScCellRangeObj::getCellFormatRanges()
5910 throw(uno::RuntimeException, std::exception)
5912 SolarMutexGuard aGuard;
5913 ScDocShell* pDocSh = GetDocShell();
5914 if ( pDocSh )
5915 return new ScCellFormatsObj( pDocSh, aRange );
5916 return NULL;
5919 // XUniqueCellFormatRangesSupplier
5921 uno::Reference<container::XIndexAccess> SAL_CALL ScCellRangeObj::getUniqueCellFormatRanges()
5922 throw(uno::RuntimeException, std::exception)
5924 SolarMutexGuard aGuard;
5925 ScDocShell* pDocSh = GetDocShell();
5926 if ( pDocSh )
5927 return new ScUniqueCellFormatsObj( pDocSh, aRange );
5928 return NULL;
5931 // XPropertySet erweitert fuer Range-Properties
5933 uno::Reference<beans::XPropertySetInfo> SAL_CALL ScCellRangeObj::getPropertySetInfo()
5934 throw(uno::RuntimeException, std::exception)
5936 SolarMutexGuard aGuard;
5937 static uno::Reference<beans::XPropertySetInfo> aRef(
5938 new SfxItemPropertySetInfo( pRangePropSet->getPropertyMap() ));
5939 return aRef;
5942 void ScCellRangeObj::SetOnePropertyValue( const SfxItemPropertySimpleEntry* pEntry, const uno::Any& aValue )
5943 throw(lang::IllegalArgumentException, uno::RuntimeException, std::exception)
5945 // Range has only Position and Size in addition to ScCellRangesBase, both are ReadOnly
5946 // -> nothing to do here
5948 ScCellRangesBase::SetOnePropertyValue( pEntry, aValue );
5951 void ScCellRangeObj::GetOnePropertyValue( const SfxItemPropertySimpleEntry* pEntry, uno::Any& rAny )
5952 throw(uno::RuntimeException, std::exception)
5954 if ( pEntry )
5956 if ( pEntry->nWID == SC_WID_UNO_POS )
5958 ScDocShell* pDocSh = GetDocShell();
5959 if (pDocSh)
5961 // GetMMRect converts using HMM_PER_TWIPS, like the DrawingLayer
5962 Rectangle aMMRect(pDocSh->GetDocument()->GetMMRect(
5963 aRange.aStart.Col(), aRange.aStart.Row(),
5964 aRange.aEnd.Col(), aRange.aEnd.Row(), aRange.aStart.Tab() ));
5965 awt::Point aPos( aMMRect.Left(), aMMRect.Top() );
5966 rAny <<= aPos;
5969 else if ( pEntry->nWID == SC_WID_UNO_SIZE )
5971 ScDocShell* pDocSh = GetDocShell();
5972 if (pDocSh)
5974 // GetMMRect converts using HMM_PER_TWIPS, like the DrawingLayer
5975 Rectangle aMMRect = pDocSh->GetDocument()->GetMMRect(
5976 aRange.aStart.Col(), aRange.aStart.Row(),
5977 aRange.aEnd.Col(), aRange.aEnd.Row(), aRange.aStart.Tab() );
5978 Size aSize(aMMRect.GetSize());
5979 awt::Size aAwtSize( aSize.Width(), aSize.Height() );
5980 rAny <<= aAwtSize;
5983 else
5984 ScCellRangesBase::GetOnePropertyValue( pEntry, rAny );
5988 const SfxItemPropertyMap& ScCellRangeObj::GetItemPropertyMap()
5990 return pRangePropSet->getPropertyMap();
5993 // XServiceInfo
5995 OUString SAL_CALL ScCellRangeObj::getImplementationName() throw(uno::RuntimeException, std::exception)
5997 return OUString( "ScCellRangeObj" );
6000 sal_Bool SAL_CALL ScCellRangeObj::supportsService( const OUString& rServiceName )
6001 throw(uno::RuntimeException, std::exception)
6003 return cppu::supportsService(this, rServiceName);
6006 uno::Sequence<OUString> SAL_CALL ScCellRangeObj::getSupportedServiceNames()
6007 throw(uno::RuntimeException, std::exception)
6009 uno::Sequence<OUString> aRet(5);
6010 OUString* pArray = aRet.getArray();
6011 pArray[0] = OUString( SCSHEETCELLRANGE_SERVICE );
6012 pArray[1] = OUString( SCCELLRANGE_SERVICE );
6013 pArray[2] = OUString( SCCELLPROPERTIES_SERVICE );
6014 pArray[3] = OUString( SCCHARPROPERTIES_SERVICE );
6015 pArray[4] = OUString( SCPARAPROPERTIES_SERVICE );
6016 return aRet;
6019 const SvxItemPropertySet* ScCellObj::GetEditPropertySet()
6021 return lcl_GetEditPropertySet();
6024 const SfxItemPropertyMap& ScCellObj::GetCellPropertyMap()
6026 return lcl_GetCellPropertySet()->getPropertyMap();
6029 ScCellObj::ScCellObj(ScDocShell* pDocSh, const ScAddress& rP) :
6030 ScCellRangeObj( pDocSh, ScRange(rP,rP) ),
6031 pCellPropSet( lcl_GetCellPropertySet() ),
6032 aCellPos( rP ),
6033 nActionLockCount( 0 )
6035 // pUnoText is allocated on demand (GetUnoText)
6036 // can't be aggregated because getString/setString is handled here
6039 SvxUnoText& ScCellObj::GetUnoText()
6041 if (!mxUnoText.is())
6043 mxUnoText.set(new ScCellTextObj(GetDocShell(), aCellPos));
6044 if (nActionLockCount)
6046 ScCellEditSource* pEditSource =
6047 static_cast<ScCellEditSource*> (mxUnoText->GetEditSource());
6048 if (pEditSource)
6049 pEditSource->SetDoUpdateData(false);
6052 return *mxUnoText;
6055 ScCellObj::~ScCellObj()
6059 void ScCellObj::RefChanged()
6061 ScCellRangeObj::RefChanged();
6063 const ScRangeList& rRanges = GetRangeList();
6064 OSL_ENSURE(rRanges.size() == 1, "was fuer Ranges ?!?!");
6065 if ( !rRanges.empty() )
6067 const ScRange* pFirst = rRanges[ 0 ];
6068 aCellPos = pFirst->aStart;
6072 uno::Any SAL_CALL ScCellObj::queryInterface( const uno::Type& rType ) throw(uno::RuntimeException, std::exception)
6074 SC_QUERYINTERFACE( table::XCell )
6075 SC_QUERYINTERFACE( table::XCell2 )
6076 SC_QUERYINTERFACE( sheet::XFormulaTokens )
6077 SC_QUERYINTERFACE( sheet::XCellAddressable )
6078 SC_QUERYINTERFACE( text::XText )
6079 SC_QUERYINTERFACE( text::XSimpleText )
6080 SC_QUERYINTERFACE( text::XTextRange )
6081 SC_QUERYINTERFACE( container::XEnumerationAccess )
6082 SC_QUERYINTERFACE( container::XElementAccess )
6083 SC_QUERYINTERFACE( sheet::XSheetAnnotationAnchor )
6084 SC_QUERYINTERFACE( text::XTextFieldsSupplier )
6085 SC_QUERYINTERFACE( document::XActionLockable )
6087 return ScCellRangeObj::queryInterface( rType );
6090 void SAL_CALL ScCellObj::acquire() throw()
6092 ScCellRangeObj::acquire();
6095 void SAL_CALL ScCellObj::release() throw()
6097 ScCellRangeObj::release();
6100 uno::Sequence<uno::Type> SAL_CALL ScCellObj::getTypes() throw(uno::RuntimeException, std::exception)
6102 static uno::Sequence<uno::Type> aTypes;
6103 if ( aTypes.getLength() == 0 )
6105 uno::Sequence<uno::Type> aParentTypes(ScCellRangeObj::getTypes());
6106 long nParentLen = aParentTypes.getLength();
6107 const uno::Type* pParentPtr = aParentTypes.getConstArray();
6109 aTypes.realloc( nParentLen + 9 );
6110 uno::Type* pPtr = aTypes.getArray();
6111 pPtr[nParentLen + 0] = cppu::UnoType<table::XCell>::get();
6112 pPtr[nParentLen + 1] = cppu::UnoType<sheet::XCellAddressable>::get();
6113 pPtr[nParentLen + 2] = cppu::UnoType<text::XText>::get();
6114 pPtr[nParentLen + 3] = cppu::UnoType<container::XEnumerationAccess>::get();
6115 pPtr[nParentLen + 4] = cppu::UnoType<sheet::XSheetAnnotationAnchor>::get();
6116 pPtr[nParentLen + 5] = cppu::UnoType<text::XTextFieldsSupplier>::get();
6117 pPtr[nParentLen + 6] = cppu::UnoType<document::XActionLockable>::get();
6118 pPtr[nParentLen + 7] = cppu::UnoType<sheet::XFormulaTokens>::get();
6119 pPtr[nParentLen + 8] = cppu::UnoType<table::XCell2>::get();
6121 for (long i=0; i<nParentLen; i++)
6122 pPtr[i] = pParentPtr[i]; // parent types first
6124 return aTypes;
6127 uno::Sequence<sal_Int8> SAL_CALL ScCellObj::getImplementationId() throw(uno::RuntimeException, std::exception)
6129 return css::uno::Sequence<sal_Int8>();
6132 // Hilfsfunktionen
6134 OUString ScCellObj::GetInputString_Impl(bool bEnglish) const // fuer getFormula / FormulaLocal
6136 if (GetDocShell())
6137 return lcl_GetInputString( GetDocShell()->GetDocument(), aCellPos, bEnglish );
6138 return OUString();
6141 OUString ScCellObj::GetOutputString_Impl() const
6143 ScDocShell* pDocSh = GetDocShell();
6144 OUString aVal;
6145 if ( pDocSh )
6147 ScDocument* pDoc = pDocSh->GetDocument();
6148 ScRefCellValue aCell;
6149 aCell.assign(*pDoc, aCellPos);
6151 aVal = ScCellFormat::GetOutputString(*pDoc, aCellPos, aCell);
6153 return aVal;
6156 void ScCellObj::SetString_Impl(const OUString& rString, bool bInterpret, bool bEnglish)
6158 ScDocShell* pDocSh = GetDocShell();
6159 if ( pDocSh )
6161 // GRAM_PODF_A1 for API compatibility.
6162 (void)pDocSh->GetDocFunc().SetCellText(
6163 aCellPos, rString, bInterpret, bEnglish, true, formula::FormulaGrammar::GRAM_PODF_A1 );
6167 double ScCellObj::GetValue_Impl() const
6169 ScDocShell* pDocSh = GetDocShell();
6170 if ( pDocSh )
6171 return pDocSh->GetDocument()->GetValue( aCellPos );
6173 return 0.0;
6176 void ScCellObj::SetValue_Impl(double fValue)
6178 ScDocShell* pDocSh = GetDocShell();
6179 if ( pDocSh )
6180 pDocSh->GetDocFunc().SetValueCell(aCellPos, fValue, false);
6183 // only for XML import
6185 void ScCellObj::InputEnglishString( const OUString& rText )
6187 // This is like a mixture of setFormula and property FormulaLocal:
6188 // The cell's number format is checked for "text", a new cell format may be set,
6189 // but all parsing is in English.
6191 ScDocShell* pDocSh = GetDocShell();
6192 if (!pDocSh)
6193 return;
6195 OUString aString(rText);
6196 ScDocument* pDoc = pDocSh->GetDocument();
6197 SvNumberFormatter* pFormatter = pDoc->GetFormatTable();
6198 sal_uInt32 nOldFormat = pDoc->GetNumberFormat( aCellPos );
6199 if (pFormatter->GetType(nOldFormat) == NUMBERFORMAT_TEXT)
6201 SetString_Impl(aString, false, false); // text cell
6202 return;
6205 ScDocFunc &rFunc = pDocSh->GetDocFunc();
6207 ScInputStringType aRes =
6208 ScStringUtil::parseInputString(*pFormatter, aString, LANGUAGE_ENGLISH_US);
6210 if (aRes.meType != ScInputStringType::Unknown)
6212 if ((nOldFormat % SV_COUNTRY_LANGUAGE_OFFSET) == 0 && aRes.mnFormatType)
6214 // apply a format for the recognized type and the old format's language
6215 sal_uInt32 nNewFormat = ScGlobal::GetStandardFormat(*pFormatter, nOldFormat, aRes.mnFormatType);
6216 if (nNewFormat != nOldFormat)
6218 ScPatternAttr aPattern( pDoc->GetPool() );
6219 aPattern.GetItemSet().Put( SfxUInt32Item( ATTR_VALUE_FORMAT, nNewFormat ) );
6220 // ATTR_LANGUAGE_FORMAT remains unchanged
6221 rFunc.ApplyAttributes( *GetMarkData(), aPattern, true, true );
6225 switch (aRes.meType)
6227 case ScInputStringType::Formula:
6228 rFunc.SetFormulaCell(
6229 aCellPos,
6230 new ScFormulaCell(pDoc, aCellPos, aRes.maText, formula::FormulaGrammar::GRAM_PODF_A1),
6231 false);
6232 break;
6233 case ScInputStringType::Number:
6234 rFunc.SetValueCell(aCellPos, aRes.mfValue, false);
6235 break;
6236 case ScInputStringType::Text:
6237 rFunc.SetStringOrEditCell(aCellPos, aRes.maText, false);
6238 break;
6239 default:
6240 SetString_Impl(aString, false, false); // probably empty string
6244 // XText
6246 uno::Reference<text::XTextCursor> SAL_CALL ScCellObj::createTextCursor()
6247 throw(uno::RuntimeException, std::exception)
6249 SolarMutexGuard aGuard;
6250 return new ScCellTextCursor( *this );
6253 uno::Reference<text::XTextCursor> SAL_CALL ScCellObj::createTextCursorByRange(
6254 const uno::Reference<text::XTextRange>& aTextPosition )
6255 throw(uno::RuntimeException, std::exception)
6257 SolarMutexGuard aGuard;
6258 SvxUnoTextCursor* pCursor = new ScCellTextCursor( *this );
6259 uno::Reference<text::XTextCursor> xCursor(pCursor);
6261 SvxUnoTextRangeBase* pRange = SvxUnoTextRangeBase::getImplementation( aTextPosition );
6262 if(pRange)
6263 pCursor->SetSelection( pRange->GetSelection() );
6264 else
6266 ScCellTextCursor* pOther = ScCellTextCursor::getImplementation( aTextPosition );
6267 if(pOther)
6268 pCursor->SetSelection( pOther->GetSelection() );
6269 else
6270 throw uno::RuntimeException();
6273 return xCursor;
6276 OUString SAL_CALL ScCellObj::getString() throw(uno::RuntimeException, std::exception)
6278 SolarMutexGuard aGuard;
6279 return GetOutputString_Impl();
6282 void SAL_CALL ScCellObj::setString( const OUString& aText ) throw(uno::RuntimeException, std::exception)
6284 SolarMutexGuard aGuard;
6285 OUString aString(aText);
6286 SetString_Impl(aString, false, false); // immer Text
6288 // don't create pUnoText here if not there
6289 if (mxUnoText.is())
6290 mxUnoText->SetSelection(ESelection( 0,0, 0,aString.getLength() ));
6293 void SAL_CALL ScCellObj::insertString( const uno::Reference<text::XTextRange>& xRange,
6294 const OUString& aString, sal_Bool bAbsorb )
6295 throw(uno::RuntimeException, std::exception)
6297 // special handling for ScCellTextCursor is no longer needed,
6298 // SvxUnoText::insertString checks for SvxUnoTextRangeBase instead of SvxUnoTextRange
6300 SolarMutexGuard aGuard;
6301 GetUnoText().insertString(xRange, aString, bAbsorb);
6304 void SAL_CALL ScCellObj::insertControlCharacter( const uno::Reference<text::XTextRange>& xRange,
6305 sal_Int16 nControlCharacter, sal_Bool bAbsorb )
6306 throw(lang::IllegalArgumentException, uno::RuntimeException, std::exception)
6308 SolarMutexGuard aGuard;
6309 GetUnoText().insertControlCharacter(xRange, nControlCharacter, bAbsorb);
6312 void SAL_CALL ScCellObj::insertTextContent( const uno::Reference<text::XTextRange >& xRange,
6313 const uno::Reference<text::XTextContent >& xContent,
6314 sal_Bool bAbsorb )
6315 throw(lang::IllegalArgumentException, uno::RuntimeException, std::exception)
6317 SolarMutexGuard aGuard;
6318 ScDocShell* pDocSh = GetDocShell();
6319 if ( pDocSh && xContent.is() )
6321 ScEditFieldObj* pCellField = ScEditFieldObj::getImplementation(xContent);
6322 SvxUnoTextRangeBase* pTextRange = ScCellTextCursor::getImplementation( xRange );
6324 if ( pCellField && !pCellField->IsInserted() && pTextRange )
6326 SvxEditSource* pEditSource = pTextRange->GetEditSource();
6327 ESelection aSelection(pTextRange->GetSelection());
6329 if (!bAbsorb)
6331 // nicht ersetzen -> hinten anhaengen
6332 aSelection.Adjust();
6333 aSelection.nStartPara = aSelection.nEndPara;
6334 aSelection.nStartPos = aSelection.nEndPos;
6337 if (pCellField->GetFieldType() == text::textfield::Type::TABLE)
6338 pCellField->setPropertyValue(SC_UNONAME_TABLEPOS, uno::makeAny<sal_Int32>(aCellPos.Tab()));
6340 SvxFieldItem aItem = pCellField->CreateFieldItem();
6341 SvxTextForwarder* pForwarder = pEditSource->GetTextForwarder();
6342 pForwarder->QuickInsertField( aItem, aSelection );
6343 pEditSource->UpdateData();
6345 // neue Selektion: ein Zeichen
6346 aSelection.Adjust();
6347 aSelection.nEndPara = aSelection.nStartPara;
6348 aSelection.nEndPos = aSelection.nStartPos + 1;
6349 uno::Reference<text::XTextRange> xParent(this);
6350 pCellField->InitDoc(
6351 xParent, new ScCellEditSource(pDocSh, aCellPos), aSelection);
6353 // for bAbsorb=FALSE, the new selection must be behind the inserted content
6354 // (the xml filter relies on this)
6355 if (!bAbsorb)
6356 aSelection.nStartPos = aSelection.nEndPos;
6358 pTextRange->SetSelection( aSelection );
6360 return;
6363 GetUnoText().insertTextContent(xRange, xContent, bAbsorb);
6366 void SAL_CALL ScCellObj::removeTextContent( const uno::Reference<text::XTextContent>& xContent )
6367 throw(container::NoSuchElementException, uno::RuntimeException, std::exception)
6369 SolarMutexGuard aGuard;
6370 if ( xContent.is() )
6372 ScEditFieldObj* pCellField = ScEditFieldObj::getImplementation(xContent);
6373 if ( pCellField && pCellField->IsInserted() )
6375 //! Testen, ob das Feld in dieser Zelle ist
6376 pCellField->DeleteField();
6377 return;
6380 GetUnoText().removeTextContent(xContent);
6383 uno::Reference<text::XText> SAL_CALL ScCellObj::getText() throw(uno::RuntimeException, std::exception)
6385 SolarMutexGuard aGuard;
6386 return this;
6389 uno::Reference<text::XTextRange> SAL_CALL ScCellObj::getStart() throw(uno::RuntimeException, std::exception)
6391 SolarMutexGuard aGuard;
6392 return GetUnoText().getStart();
6395 uno::Reference<text::XTextRange> SAL_CALL ScCellObj::getEnd() throw(uno::RuntimeException, std::exception)
6397 SolarMutexGuard aGuard;
6398 return GetUnoText().getEnd();
6401 uno::Reference<container::XEnumeration> SAL_CALL ScCellObj::createEnumeration()
6402 throw(uno::RuntimeException, std::exception)
6404 SolarMutexGuard aGuard;
6405 return GetUnoText().createEnumeration();
6408 uno::Type SAL_CALL ScCellObj::getElementType() throw(uno::RuntimeException, std::exception)
6410 SolarMutexGuard aGuard;
6411 return GetUnoText().getElementType();
6414 sal_Bool SAL_CALL ScCellObj::hasElements() throw(uno::RuntimeException, std::exception)
6416 SolarMutexGuard aGuard;
6417 return GetUnoText().hasElements();
6420 // XCell
6422 OUString SAL_CALL ScCellObj::getFormula() throw(uno::RuntimeException, std::exception)
6424 SolarMutexGuard aGuard;
6425 return GetInputString_Impl( true /* English */ );
6428 void SAL_CALL ScCellObj::setFormula( const OUString& aFormula ) throw(uno::RuntimeException, std::exception)
6430 SolarMutexGuard aGuard;
6431 OUString aString(aFormula);
6432 SetString_Impl(aString, true, true); // Interpret as English
6435 double SAL_CALL ScCellObj::getValue() throw(uno::RuntimeException, std::exception)
6437 SolarMutexGuard aGuard;
6438 return GetValue_Impl();
6441 void SAL_CALL ScCellObj::setValue( double nValue ) throw(uno::RuntimeException, std::exception)
6443 SolarMutexGuard aGuard;
6444 SetValue_Impl(nValue);
6447 void SAL_CALL ScCellObj::setFormulaString( const OUString& aFormula) throw(uno::RuntimeException, std::exception)
6449 SolarMutexGuard aGuard;
6450 ScDocShell *pDocSh = GetDocShell();
6451 if( pDocSh )
6453 ScFormulaCell* pCell = new ScFormulaCell( pDocSh->GetDocument(), aCellPos );
6454 pCell->SetHybridFormula( aFormula, formula::FormulaGrammar::GRAM_NATIVE );
6455 pDocSh->GetDocFunc().SetFormulaCell(aCellPos, pCell, false);
6458 void SAL_CALL ScCellObj::setFormulaResult( double nValue ) throw(uno::RuntimeException, std::exception)
6460 SolarMutexGuard aGuard;
6461 ScDocShell* pDocSh = GetDocShell();
6462 if ( pDocSh && pDocSh->GetDocument()->GetCellType( aCellPos ) == CELLTYPE_FORMULA )
6464 ScFormulaCell* pCell = pDocSh->GetDocument()->GetFormulaCell(aCellPos);
6465 if (!pCell)
6466 return;
6467 pCell->SetHybridDouble( nValue );
6468 pCell->ResetDirty();
6469 pCell->SetChanged(false);
6473 table::CellContentType SAL_CALL ScCellObj::getType() throw(uno::RuntimeException, std::exception)
6475 SolarMutexGuard aGuard;
6476 table::CellContentType eRet = table::CellContentType_EMPTY;
6477 ScDocShell* pDocSh = GetDocShell();
6478 if (pDocSh)
6480 CellType eCalcType = pDocSh->GetDocument()->GetCellType( aCellPos );
6481 switch (eCalcType)
6483 case CELLTYPE_VALUE:
6484 eRet = table::CellContentType_VALUE;
6485 break;
6486 case CELLTYPE_STRING:
6487 case CELLTYPE_EDIT:
6488 eRet = table::CellContentType_TEXT;
6489 break;
6490 case CELLTYPE_FORMULA:
6491 eRet = table::CellContentType_FORMULA;
6492 break;
6493 default:
6494 eRet = table::CellContentType_EMPTY;
6497 else
6499 OSL_FAIL("keine DocShell"); //! Exception oder so?
6502 return eRet;
6505 table::CellContentType ScCellObj::GetResultType_Impl()
6507 ScDocShell* pDocSh = GetDocShell();
6508 if ( pDocSh )
6510 ScRefCellValue aCell;
6511 aCell.assign(*pDocSh->GetDocument(), aCellPos);
6512 if (aCell.meType == CELLTYPE_FORMULA)
6514 bool bValue = aCell.mpFormula->IsValue();
6515 return bValue ? table::CellContentType_VALUE : table::CellContentType_TEXT;
6518 return getType(); // wenn keine Formel
6521 sal_Int32 SAL_CALL ScCellObj::getError() throw(uno::RuntimeException, std::exception)
6523 SolarMutexGuard aGuard;
6524 ScDocShell* pDocSh = GetDocShell();
6525 if (!pDocSh)
6527 OSL_FAIL("keine DocShell"); //! Exception oder so?
6528 return 0;
6531 sal_uInt16 nError = 0;
6532 ScRefCellValue aCell;
6533 aCell.assign(*pDocSh->GetDocument(), aCellPos);
6534 if (aCell.meType == CELLTYPE_FORMULA)
6535 nError = aCell.mpFormula->GetErrCode();
6537 return nError;
6540 // XFormulaTokens
6542 uno::Sequence<sheet::FormulaToken> SAL_CALL ScCellObj::getTokens()
6543 throw (uno::RuntimeException, std::exception)
6545 SolarMutexGuard aGuard;
6546 uno::Sequence<sheet::FormulaToken> aSequence;
6547 ScDocShell* pDocSh = GetDocShell();
6548 if (!pDocSh)
6549 return aSequence;
6551 ScDocument* pDoc = pDocSh->GetDocument();
6552 ScRefCellValue aCell;
6553 aCell.assign(*pDoc, aCellPos);
6554 if (aCell.meType == CELLTYPE_FORMULA)
6556 ScTokenArray* pTokenArray = aCell.mpFormula->GetCode();
6557 if (pTokenArray)
6558 ScTokenConversion::ConvertToTokenSequence(*pDoc, aSequence, *pTokenArray);
6560 return aSequence;
6563 void SAL_CALL ScCellObj::setTokens( const uno::Sequence<sheet::FormulaToken>& rTokens ) throw(uno::RuntimeException, std::exception)
6565 SolarMutexGuard aGuard;
6566 ScDocShell* pDocSh = GetDocShell();
6567 if ( pDocSh )
6569 ScDocument* pDoc = pDocSh->GetDocument();
6570 ScTokenArray aTokenArray;
6571 (void)ScTokenConversion::ConvertToTokenArray( *pDoc, aTokenArray, rTokens );
6573 ScFormulaCell* pNewCell = new ScFormulaCell(pDoc, aCellPos, aTokenArray);
6574 (void)pDocSh->GetDocFunc().SetFormulaCell(aCellPos, pNewCell, false);
6578 // XCellAddressable
6580 table::CellAddress SAL_CALL ScCellObj::getCellAddress() throw(uno::RuntimeException, std::exception)
6582 SolarMutexGuard aGuard;
6583 table::CellAddress aAdr;
6584 aAdr.Sheet = aCellPos.Tab();
6585 aAdr.Column = aCellPos.Col();
6586 aAdr.Row = aCellPos.Row();
6587 return aAdr;
6590 // XSheetAnnotationAnchor
6592 uno::Reference<sheet::XSheetAnnotation> SAL_CALL ScCellObj::getAnnotation()
6593 throw(uno::RuntimeException, std::exception)
6595 SolarMutexGuard aGuard;
6596 ScDocShell* pDocSh = GetDocShell();
6597 if ( pDocSh )
6598 return new ScAnnotationObj( pDocSh, aCellPos );
6600 OSL_FAIL("getAnnotation ohne DocShell");
6601 return NULL;
6604 // XFieldTypesSupplier
6606 uno::Reference<container::XEnumerationAccess> SAL_CALL ScCellObj::getTextFields()
6607 throw(uno::RuntimeException, std::exception)
6609 SolarMutexGuard aGuard;
6610 ScDocShell* pDocSh = GetDocShell();
6611 if ( pDocSh )
6613 uno::Reference<text::XTextRange> xContent(this);
6614 return new ScCellFieldsObj(xContent, pDocSh, aCellPos);
6617 return NULL;
6620 uno::Reference<container::XNameAccess> SAL_CALL ScCellObj::getTextFieldMasters()
6621 throw(uno::RuntimeException, std::exception)
6623 // sowas gibts nicht im Calc (?)
6624 return NULL;
6627 // XPropertySet erweitert fuer Zell-Properties
6629 uno::Reference<beans::XPropertySetInfo> SAL_CALL ScCellObj::getPropertySetInfo()
6630 throw(uno::RuntimeException, std::exception)
6632 SolarMutexGuard aGuard;
6633 static uno::Reference<beans::XPropertySetInfo> aRef(
6634 new SfxItemPropertySetInfo( pCellPropSet->getPropertyMap() ));
6635 return aRef;
6638 void ScCellObj::SetOnePropertyValue( const SfxItemPropertySimpleEntry* pEntry, const uno::Any& aValue )
6639 throw(lang::IllegalArgumentException, uno::RuntimeException, std::exception)
6641 if ( pEntry )
6643 if ( pEntry->nWID == SC_WID_UNO_FORMLOC )
6645 OUString aStrVal;
6646 aValue >>= aStrVal;
6647 OUString aString(aStrVal);
6648 SetString_Impl(aString, true, false); // lokal interpretieren
6650 else if ( pEntry->nWID == SC_WID_UNO_FORMRT )
6652 // Read-Only
6653 //! Exception oder so...
6655 else
6656 ScCellRangeObj::SetOnePropertyValue( pEntry, aValue );
6660 void ScCellObj::GetOnePropertyValue( const SfxItemPropertySimpleEntry* pEntry, uno::Any& rAny )
6661 throw(uno::RuntimeException, std::exception)
6663 if ( pEntry )
6665 if ( pEntry->nWID == SC_WID_UNO_FORMLOC )
6667 // sal_False = lokal
6668 rAny <<= OUString( GetInputString_Impl(false) );
6670 else if ( pEntry->nWID == SC_WID_UNO_FORMRT )
6672 table::CellContentType eType = GetResultType_Impl();
6673 rAny <<= eType;
6675 else
6676 ScCellRangeObj::GetOnePropertyValue(pEntry, rAny);
6680 const SfxItemPropertyMap& ScCellObj::GetItemPropertyMap()
6682 return pCellPropSet->getPropertyMap();
6685 // XServiceInfo
6687 OUString SAL_CALL ScCellObj::getImplementationName() throw(uno::RuntimeException, std::exception)
6689 return OUString( "ScCellObj" );
6692 sal_Bool SAL_CALL ScCellObj::supportsService( const OUString& rServiceName )
6693 throw(uno::RuntimeException, std::exception)
6695 return cppu::supportsService(this, rServiceName);
6698 uno::Sequence<OUString> SAL_CALL ScCellObj::getSupportedServiceNames()
6699 throw(uno::RuntimeException, std::exception)
6701 uno::Sequence<OUString> aRet(7);
6702 OUString* pArray = aRet.getArray();
6703 pArray[0] = OUString( SCSHEETCELL_SERVICE );
6704 pArray[1] = OUString( SCCELL_SERVICE );
6705 pArray[2] = OUString( SCCELLPROPERTIES_SERVICE );
6706 pArray[3] = OUString( SCCHARPROPERTIES_SERVICE );
6707 pArray[4] = OUString( SCPARAPROPERTIES_SERVICE );
6708 pArray[5] = OUString( SCSHEETCELLRANGE_SERVICE );
6709 pArray[6] = OUString( SCCELLRANGE_SERVICE );
6710 return aRet;
6713 // XActionLockable
6715 sal_Bool SAL_CALL ScCellObj::isActionLocked() throw(uno::RuntimeException, std::exception)
6717 SolarMutexGuard aGuard;
6718 return nActionLockCount != 0;
6721 void SAL_CALL ScCellObj::addActionLock() throw(uno::RuntimeException, std::exception)
6723 SolarMutexGuard aGuard;
6724 if (!nActionLockCount)
6726 if (mxUnoText.is())
6728 ScCellEditSource* pEditSource =
6729 static_cast<ScCellEditSource*> (mxUnoText->GetEditSource());
6730 if (pEditSource)
6731 pEditSource->SetDoUpdateData(false);
6734 nActionLockCount++;
6737 void SAL_CALL ScCellObj::removeActionLock() throw(uno::RuntimeException, std::exception)
6739 SolarMutexGuard aGuard;
6740 if (nActionLockCount > 0)
6742 nActionLockCount--;
6743 if (!nActionLockCount)
6745 if (mxUnoText.is())
6747 ScCellEditSource* pEditSource =
6748 static_cast<ScCellEditSource*> (mxUnoText->GetEditSource());
6749 if (pEditSource)
6751 pEditSource->SetDoUpdateData(true);
6752 if (pEditSource->IsDirty())
6753 pEditSource->UpdateData();
6760 void SAL_CALL ScCellObj::setActionLocks( sal_Int16 nLock ) throw(uno::RuntimeException, std::exception)
6762 SolarMutexGuard aGuard;
6763 if (mxUnoText.is())
6765 ScCellEditSource* pEditSource =
6766 static_cast<ScCellEditSource*> (mxUnoText->GetEditSource());
6767 if (pEditSource)
6769 pEditSource->SetDoUpdateData(nLock == 0);
6770 if ((nActionLockCount > 0) && (nLock == 0) && pEditSource->IsDirty())
6771 pEditSource->UpdateData();
6774 nActionLockCount = nLock;
6777 sal_Int16 SAL_CALL ScCellObj::resetActionLocks() throw(uno::RuntimeException, std::exception)
6779 SolarMutexGuard aGuard;
6780 sal_uInt16 nRet(nActionLockCount);
6781 if (mxUnoText.is())
6783 ScCellEditSource* pEditSource =
6784 static_cast<ScCellEditSource*> (mxUnoText->GetEditSource());
6785 if (pEditSource)
6787 pEditSource->SetDoUpdateData(true);
6788 if (pEditSource->IsDirty())
6789 pEditSource->UpdateData();
6792 nActionLockCount = 0;
6793 return nRet;
6796 ScTableSheetObj::ScTableSheetObj( ScDocShell* pDocSh, SCTAB nTab ) :
6797 ScCellRangeObj( pDocSh, ScRange(0,0,nTab, MAXCOL,MAXROW,nTab) ),
6798 pSheetPropSet(lcl_GetSheetPropertySet())
6802 ScTableSheetObj::~ScTableSheetObj()
6806 void ScTableSheetObj::InitInsertSheet(ScDocShell* pDocSh, SCTAB nTab)
6808 InitInsertRange( pDocSh, ScRange(0,0,nTab, MAXCOL,MAXROW,nTab) );
6811 uno::Any SAL_CALL ScTableSheetObj::queryInterface( const uno::Type& rType ) throw(uno::RuntimeException, std::exception)
6813 SC_QUERYINTERFACE( sheet::XSpreadsheet )
6814 SC_QUERYINTERFACE( container::XNamed )
6815 SC_QUERYINTERFACE( sheet::XSheetPageBreak )
6816 SC_QUERYINTERFACE( sheet::XCellRangeMovement )
6817 SC_QUERYINTERFACE( table::XTableChartsSupplier )
6818 SC_QUERYINTERFACE( sheet::XDataPilotTablesSupplier )
6819 SC_QUERYINTERFACE( sheet::XScenariosSupplier )
6820 SC_QUERYINTERFACE( sheet::XSheetAnnotationsSupplier )
6821 SC_QUERYINTERFACE( drawing::XDrawPageSupplier )
6822 SC_QUERYINTERFACE( sheet::XPrintAreas )
6823 SC_QUERYINTERFACE( sheet::XSheetAuditing )
6824 SC_QUERYINTERFACE( sheet::XSheetOutline )
6825 SC_QUERYINTERFACE( util::XProtectable )
6826 SC_QUERYINTERFACE( sheet::XScenario )
6827 SC_QUERYINTERFACE( sheet::XScenarioEnhanced )
6828 SC_QUERYINTERFACE( sheet::XSheetLinkable )
6829 SC_QUERYINTERFACE( sheet::XExternalSheetName )
6830 SC_QUERYINTERFACE( document::XEventsSupplier )
6832 return ScCellRangeObj::queryInterface( rType );
6835 void SAL_CALL ScTableSheetObj::acquire() throw()
6837 ScCellRangeObj::acquire();
6840 void SAL_CALL ScTableSheetObj::release() throw()
6842 ScCellRangeObj::release();
6845 uno::Sequence<uno::Type> SAL_CALL ScTableSheetObj::getTypes() throw(uno::RuntimeException, std::exception)
6847 static uno::Sequence<uno::Type> aTypes;
6848 if ( aTypes.getLength() == 0 )
6850 uno::Sequence<uno::Type> aParentTypes = ScCellRangeObj::getTypes();
6851 long nParentLen = aParentTypes.getLength();
6852 const uno::Type* pParentPtr = aParentTypes.getConstArray();
6854 aTypes.realloc( nParentLen + 18 );
6855 uno::Type* pPtr = aTypes.getArray();
6856 pPtr[nParentLen + 0] = cppu::UnoType<sheet::XSpreadsheet>::get();
6857 pPtr[nParentLen + 1] = cppu::UnoType<container::XNamed>::get();
6858 pPtr[nParentLen + 2] = cppu::UnoType<sheet::XSheetPageBreak>::get();
6859 pPtr[nParentLen + 3] = cppu::UnoType<sheet::XCellRangeMovement>::get();
6860 pPtr[nParentLen + 4] = cppu::UnoType<table::XTableChartsSupplier>::get();
6861 pPtr[nParentLen + 5] = cppu::UnoType<sheet::XDataPilotTablesSupplier>::get();
6862 pPtr[nParentLen + 6] = cppu::UnoType<sheet::XScenariosSupplier>::get();
6863 pPtr[nParentLen + 7] = cppu::UnoType<sheet::XSheetAnnotationsSupplier>::get();
6864 pPtr[nParentLen + 8] = cppu::UnoType<drawing::XDrawPageSupplier>::get();
6865 pPtr[nParentLen + 9] = cppu::UnoType<sheet::XPrintAreas>::get();
6866 pPtr[nParentLen +10] = cppu::UnoType<sheet::XSheetAuditing>::get();
6867 pPtr[nParentLen +11] = cppu::UnoType<sheet::XSheetOutline>::get();
6868 pPtr[nParentLen +12] = cppu::UnoType<util::XProtectable>::get();
6869 pPtr[nParentLen +13] = cppu::UnoType<sheet::XScenario>::get();
6870 pPtr[nParentLen +14] = cppu::UnoType<sheet::XScenarioEnhanced>::get();
6871 pPtr[nParentLen +15] = cppu::UnoType<sheet::XSheetLinkable>::get();
6872 pPtr[nParentLen +16] = cppu::UnoType<sheet::XExternalSheetName>::get();
6873 pPtr[nParentLen +17] = cppu::UnoType<document::XEventsSupplier>::get();
6875 for (long i=0; i<nParentLen; i++)
6876 pPtr[i] = pParentPtr[i]; // parent types first
6878 return aTypes;
6881 uno::Sequence<sal_Int8> SAL_CALL ScTableSheetObj::getImplementationId() throw(uno::RuntimeException, std::exception)
6883 return css::uno::Sequence<sal_Int8>();
6886 // Hilfsfunktionen
6888 SCTAB ScTableSheetObj::GetTab_Impl() const
6890 const ScRangeList& rRanges = GetRangeList();
6891 OSL_ENSURE(rRanges.size() == 1, "was fuer Ranges ?!?!");
6892 if ( !rRanges.empty() )
6894 const ScRange* pFirst = rRanges[ 0 ];
6895 return pFirst->aStart.Tab();
6897 return 0; // soll nicht sein
6900 // former XSheet
6902 uno::Reference<table::XTableCharts> SAL_CALL ScTableSheetObj::getCharts() throw(uno::RuntimeException, std::exception)
6904 SolarMutexGuard aGuard;
6905 ScDocShell* pDocSh = GetDocShell();
6906 if ( pDocSh )
6907 return new ScChartsObj( pDocSh, GetTab_Impl() );
6909 OSL_FAIL("kein Dokument");
6910 return NULL;
6913 uno::Reference<sheet::XDataPilotTables> SAL_CALL ScTableSheetObj::getDataPilotTables()
6914 throw(uno::RuntimeException, std::exception)
6916 SolarMutexGuard aGuard;
6917 ScDocShell* pDocSh = GetDocShell();
6918 if ( pDocSh )
6919 return new ScDataPilotTablesObj( pDocSh, GetTab_Impl() );
6921 OSL_FAIL("kein Dokument");
6922 return NULL;
6925 uno::Reference<sheet::XScenarios> SAL_CALL ScTableSheetObj::getScenarios() throw(uno::RuntimeException, std::exception)
6927 SolarMutexGuard aGuard;
6928 ScDocShell* pDocSh = GetDocShell();
6930 if ( pDocSh )
6931 return new ScScenariosObj( pDocSh, GetTab_Impl() );
6933 OSL_FAIL("kein Dokument");
6934 return NULL;
6937 uno::Reference<sheet::XSheetAnnotations> SAL_CALL ScTableSheetObj::getAnnotations()
6938 throw(uno::RuntimeException, std::exception)
6940 SolarMutexGuard aGuard;
6941 ScDocShell* pDocSh = GetDocShell();
6943 if ( pDocSh )
6944 return new ScAnnotationsObj( pDocSh, GetTab_Impl() );
6946 OSL_FAIL("kein Dokument");
6947 return NULL;
6950 uno::Reference<table::XCellRange> SAL_CALL ScTableSheetObj::getCellRangeByName(
6951 const OUString& rRange ) throw(uno::RuntimeException, std::exception)
6953 SolarMutexGuard aGuard;
6954 return ScCellRangeObj::getCellRangeByName( rRange );
6957 uno::Reference<sheet::XSheetCellCursor> SAL_CALL ScTableSheetObj::createCursor()
6958 throw(uno::RuntimeException, std::exception)
6960 SolarMutexGuard aGuard;
6961 ScDocShell* pDocSh = GetDocShell();
6962 if ( pDocSh )
6964 //! einzelne Zelle oder ganze Tabelle???????
6965 SCTAB nTab = GetTab_Impl();
6966 return new ScCellCursorObj( pDocSh, ScRange( 0,0,nTab, MAXCOL,MAXROW,nTab ) );
6968 return NULL;
6971 uno::Reference<sheet::XSheetCellCursor> SAL_CALL ScTableSheetObj::createCursorByRange(
6972 const uno::Reference<sheet::XSheetCellRange>& xCellRange )
6973 throw(uno::RuntimeException, std::exception)
6975 SolarMutexGuard aGuard;
6976 ScDocShell* pDocSh = GetDocShell();
6977 if ( pDocSh && xCellRange.is() )
6979 ScCellRangesBase* pRangesImp = ScCellRangesBase::getImplementation( xCellRange );
6980 if (pRangesImp)
6982 const ScRangeList& rRanges = pRangesImp->GetRangeList();
6983 OSL_ENSURE( rRanges.size() == 1, "Range? Ranges?" );
6984 return new ScCellCursorObj( pDocSh, *rRanges[ 0 ] );
6987 return NULL;
6990 // XSheetCellRange
6992 uno::Reference<sheet::XSpreadsheet> SAL_CALL ScTableSheetObj::getSpreadsheet()
6993 throw(uno::RuntimeException, std::exception)
6995 SolarMutexGuard aGuard;
6996 return this; //!???
6999 // XCellRange
7001 uno::Reference<table::XCell> SAL_CALL ScTableSheetObj::getCellByPosition(
7002 sal_Int32 nColumn, sal_Int32 nRow )
7003 throw(lang::IndexOutOfBoundsException, uno::RuntimeException, std::exception)
7005 SolarMutexGuard aGuard;
7006 return ScCellRangeObj::GetCellByPosition_Impl(nColumn, nRow);
7009 uno::Reference<table::XCellRange> SAL_CALL ScTableSheetObj::getCellRangeByPosition(
7010 sal_Int32 nLeft, sal_Int32 nTop, sal_Int32 nRight, sal_Int32 nBottom )
7011 throw(lang::IndexOutOfBoundsException, uno::RuntimeException, std::exception)
7013 SolarMutexGuard aGuard;
7014 return ScCellRangeObj::getCellRangeByPosition(nLeft,nTop,nRight,nBottom);
7017 uno::Sequence<sheet::TablePageBreakData> SAL_CALL ScTableSheetObj::getColumnPageBreaks()
7018 throw(uno::RuntimeException, std::exception)
7020 SolarMutexGuard aGuard;
7021 ScDocShell* pDocSh = GetDocShell();
7022 if ( pDocSh )
7024 ScDocument* pDoc = pDocSh->GetDocument();
7025 SCTAB nTab = GetTab_Impl();
7027 Size aSize(pDoc->GetPageSize( nTab ));
7028 if (aSize.Width() && aSize.Height()) // effektive Groesse schon gesetzt?
7029 pDoc->UpdatePageBreaks( nTab );
7030 else
7032 // Umbrueche updaten wie in ScDocShell::PageStyleModified:
7033 ScPrintFunc aPrintFunc( pDocSh, pDocSh->GetPrinter(), nTab );
7034 aPrintFunc.UpdatePages();
7037 SCCOL nCount = 0;
7038 SCCOL nCol;
7039 for (nCol=0; nCol<=MAXCOL; nCol++)
7040 if (pDoc->HasColBreak(nCol, nTab))
7041 ++nCount;
7043 sheet::TablePageBreakData aData;
7044 uno::Sequence<sheet::TablePageBreakData> aSeq(nCount);
7045 sheet::TablePageBreakData* pAry = aSeq.getArray();
7046 sal_uInt16 nPos = 0;
7047 for (nCol=0; nCol<=MAXCOL; nCol++)
7049 ScBreakType nBreak = pDoc->HasColBreak(nCol, nTab);
7050 if (nBreak)
7052 aData.Position = nCol;
7053 aData.ManualBreak = (nBreak & BREAK_MANUAL);
7054 pAry[nPos] = aData;
7055 ++nPos;
7058 return aSeq;
7060 return uno::Sequence<sheet::TablePageBreakData>(0);
7063 uno::Sequence<sheet::TablePageBreakData> SAL_CALL ScTableSheetObj::getRowPageBreaks()
7064 throw(uno::RuntimeException, std::exception)
7066 SolarMutexGuard aGuard;
7067 ScDocShell* pDocSh = GetDocShell();
7068 if ( pDocSh )
7070 ScDocument* pDoc = pDocSh->GetDocument();
7071 SCTAB nTab = GetTab_Impl();
7073 Size aSize(pDoc->GetPageSize( nTab ));
7074 if (aSize.Width() && aSize.Height()) // effektive Groesse schon gesetzt?
7075 pDoc->UpdatePageBreaks( nTab );
7076 else
7078 // Umbrueche updaten wie in ScDocShell::PageStyleModified:
7079 ScPrintFunc aPrintFunc( pDocSh, pDocSh->GetPrinter(), nTab );
7080 aPrintFunc.UpdatePages();
7082 return pDoc->GetRowBreakData(nTab);
7084 return uno::Sequence<sheet::TablePageBreakData>(0);
7087 void SAL_CALL ScTableSheetObj::removeAllManualPageBreaks() throw(uno::RuntimeException, std::exception)
7089 SolarMutexGuard aGuard;
7090 ScDocShell* pDocSh = GetDocShell();
7091 if ( pDocSh )
7093 //! docfunc Funktion, auch fuer ScViewFunc::RemoveManualBreaks
7095 ScDocument* pDoc = pDocSh->GetDocument();
7096 bool bUndo (pDoc->IsUndoEnabled());
7097 SCTAB nTab = GetTab_Impl();
7099 if (bUndo)
7101 ScDocument* pUndoDoc = new ScDocument( SCDOCMODE_UNDO );
7102 pUndoDoc->InitUndo( pDoc, nTab, nTab, true, true );
7103 pDoc->CopyToDocument( 0,0,nTab, MAXCOL,MAXROW,nTab, IDF_NONE, false, pUndoDoc );
7104 pDocSh->GetUndoManager()->AddUndoAction(
7105 new ScUndoRemoveBreaks( pDocSh, nTab, pUndoDoc ) );
7108 pDoc->RemoveManualBreaks(nTab);
7109 pDoc->UpdatePageBreaks(nTab);
7111 //? UpdatePageBreakData( sal_True );
7112 pDocSh->SetDocumentModified();
7113 pDocSh->PostPaint(ScRange(0, 0, nTab, MAXCOL, MAXROW, nTab), PAINT_GRID);
7117 // XNamed
7119 OUString SAL_CALL ScTableSheetObj::getName() throw(uno::RuntimeException, std::exception)
7121 SolarMutexGuard aGuard;
7122 OUString aName;
7123 ScDocShell* pDocSh = GetDocShell();
7124 if ( pDocSh )
7125 pDocSh->GetDocument()->GetName( GetTab_Impl(), aName );
7126 return aName;
7129 void SAL_CALL ScTableSheetObj::setName( const OUString& aNewName )
7130 throw(uno::RuntimeException, std::exception)
7132 SolarMutexGuard aGuard;
7133 ScDocShell* pDocSh = GetDocShell();
7134 if ( pDocSh )
7136 OUString aString(aNewName);
7137 pDocSh->GetDocFunc().RenameTable( GetTab_Impl(), aString, true, true );
7141 // XDrawPageSupplier
7143 uno::Reference<drawing::XDrawPage> SAL_CALL ScTableSheetObj::getDrawPage()
7144 throw(uno::RuntimeException, std::exception)
7146 SolarMutexGuard aGuard;
7147 ScDocShell* pDocSh = GetDocShell();
7148 if ( pDocSh )
7150 ScDrawLayer* pDrawLayer = pDocSh->MakeDrawLayer();
7151 OSL_ENSURE(pDrawLayer,"kann Draw-Layer nicht anlegen");
7153 SCTAB nTab = GetTab_Impl();
7154 SdrPage* pPage = pDrawLayer->GetPage(static_cast<sal_uInt16>(nTab));
7155 OSL_ENSURE(pPage,"Draw-Page nicht gefunden");
7156 if (pPage)
7157 return uno::Reference<drawing::XDrawPage> (pPage->getUnoPage(), uno::UNO_QUERY);
7159 // Das DrawPage-Objekt meldet sich als Listener am SdrModel an
7160 // und sollte von dort alle Aktionen mitbekommen
7162 return NULL;
7165 // XCellMovement
7167 void SAL_CALL ScTableSheetObj::insertCells( const table::CellRangeAddress& rRangeAddress,
7168 sheet::CellInsertMode nMode ) throw(uno::RuntimeException, std::exception)
7170 SolarMutexGuard aGuard;
7171 ScDocShell* pDocSh = GetDocShell();
7172 if ( pDocSh )
7174 bool bDo = true;
7175 InsCellCmd eCmd = INS_NONE;
7176 switch (nMode)
7178 case sheet::CellInsertMode_NONE: bDo = false; break;
7179 case sheet::CellInsertMode_DOWN: eCmd = INS_CELLSDOWN; break;
7180 case sheet::CellInsertMode_RIGHT: eCmd = INS_CELLSRIGHT; break;
7181 case sheet::CellInsertMode_ROWS: eCmd = INS_INSROWS; break;
7182 case sheet::CellInsertMode_COLUMNS: eCmd = INS_INSCOLS; break;
7183 default:
7184 OSL_FAIL("insertCells: falscher Mode");
7185 bDo = false;
7188 if (bDo)
7190 OSL_ENSURE( rRangeAddress.Sheet == GetTab_Impl(), "falsche Tabelle in CellRangeAddress" );
7191 ScRange aScRange;
7192 ScUnoConversion::FillScRange( aScRange, rRangeAddress );
7193 pDocSh->GetDocFunc().InsertCells( aScRange, NULL, eCmd, true, true );
7198 void SAL_CALL ScTableSheetObj::removeRange( const table::CellRangeAddress& rRangeAddress,
7199 sheet::CellDeleteMode nMode ) throw(uno::RuntimeException, std::exception)
7201 SolarMutexGuard aGuard;
7202 ScDocShell* pDocSh = GetDocShell();
7203 if ( pDocSh )
7205 bool bDo = true;
7206 DelCellCmd eCmd = DEL_NONE;
7207 switch (nMode)
7209 case sheet::CellDeleteMode_NONE: bDo = false; break;
7210 case sheet::CellDeleteMode_UP: eCmd = DEL_CELLSUP; break;
7211 case sheet::CellDeleteMode_LEFT: eCmd = DEL_CELLSLEFT; break;
7212 case sheet::CellDeleteMode_ROWS: eCmd = DEL_DELROWS; break;
7213 case sheet::CellDeleteMode_COLUMNS: eCmd = DEL_DELCOLS; break;
7214 default:
7215 OSL_FAIL("deleteCells: falscher Mode");
7216 bDo = false;
7219 if (bDo)
7221 OSL_ENSURE( rRangeAddress.Sheet == GetTab_Impl(), "falsche Tabelle in CellRangeAddress" );
7222 ScRange aScRange;
7223 ScUnoConversion::FillScRange( aScRange, rRangeAddress );
7224 pDocSh->GetDocFunc().DeleteCells( aScRange, NULL, eCmd, true, true );
7229 void SAL_CALL ScTableSheetObj::moveRange( const table::CellAddress& aDestination,
7230 const table::CellRangeAddress& aSource )
7231 throw(uno::RuntimeException, std::exception)
7233 SolarMutexGuard aGuard;
7234 ScDocShell* pDocSh = GetDocShell();
7235 if ( pDocSh )
7237 OSL_ENSURE( aSource.Sheet == GetTab_Impl(), "falsche Tabelle in CellRangeAddress" );
7238 ScRange aSourceRange;
7239 ScUnoConversion::FillScRange( aSourceRange, aSource );
7240 ScAddress aDestPos( (SCCOL)aDestination.Column, (SCROW)aDestination.Row, aDestination.Sheet );
7241 pDocSh->GetDocFunc().MoveBlock( aSourceRange, aDestPos, true, true, true, true );
7245 void SAL_CALL ScTableSheetObj::copyRange( const table::CellAddress& aDestination,
7246 const table::CellRangeAddress& aSource )
7247 throw(uno::RuntimeException, std::exception)
7249 SolarMutexGuard aGuard;
7250 ScDocShell* pDocSh = GetDocShell();
7251 if ( pDocSh )
7253 OSL_ENSURE( aSource.Sheet == GetTab_Impl(), "falsche Tabelle in CellRangeAddress" );
7254 ScRange aSourceRange;
7255 ScUnoConversion::FillScRange( aSourceRange, aSource );
7256 ScAddress aDestPos( (SCCOL)aDestination.Column, (SCROW)aDestination.Row, aDestination.Sheet );
7257 pDocSh->GetDocFunc().MoveBlock( aSourceRange, aDestPos, false, true, true, true );
7261 // XPrintAreas
7263 void ScTableSheetObj::PrintAreaUndo_Impl( ScPrintRangeSaver* pOldRanges )
7265 // Umbrueche und Undo
7266 ScDocShell* pDocSh = GetDocShell();
7267 ScDocument* pDoc = pDocSh ? pDocSh->GetDocument() : 0;
7269 if(pDocSh && pDoc)
7271 const bool bUndo(pDoc->IsUndoEnabled());
7272 const SCTAB nTab(GetTab_Impl());
7274 if(bUndo)
7276 pDocSh->GetUndoManager()->AddUndoAction(
7277 new ScUndoPrintRange(
7278 pDocSh,
7279 nTab,
7280 pOldRanges,
7281 pDoc->CreatePrintRangeSaver())); // create new ranges
7283 // #i120105# ownership of old ranges has changed, mark as consumed
7284 pOldRanges = 0;
7287 ScPrintFunc(pDocSh, pDocSh->GetPrinter(), nTab).UpdatePages();
7288 SfxBindings* pBindings = pDocSh->GetViewBindings();
7290 if(pBindings)
7292 pBindings->Invalidate(SID_DELETE_PRINTAREA);
7295 pDocSh->SetDocumentModified();
7298 // #i120105# pOldRanges not used, need to cleanup
7299 delete pOldRanges;
7302 uno::Sequence<table::CellRangeAddress> SAL_CALL ScTableSheetObj::getPrintAreas()
7303 throw(uno::RuntimeException, std::exception)
7305 SolarMutexGuard aGuard;
7306 ScDocShell* pDocSh = GetDocShell();
7307 if ( pDocSh )
7309 ScDocument* pDoc = pDocSh->GetDocument();
7310 SCTAB nTab = GetTab_Impl();
7311 sal_uInt16 nCount = pDoc->GetPrintRangeCount( nTab );
7313 table::CellRangeAddress aRangeAddress;
7314 uno::Sequence<table::CellRangeAddress> aSeq(nCount);
7315 table::CellRangeAddress* pAry = aSeq.getArray();
7316 for (sal_uInt16 i=0; i<nCount; i++)
7318 const ScRange* pRange = pDoc->GetPrintRange( nTab, i );
7319 OSL_ENSURE(pRange,"wo ist der Druckbereich");
7320 if (pRange)
7322 ScUnoConversion::FillApiRange( aRangeAddress, *pRange );
7323 aRangeAddress.Sheet = nTab; // core does not care about sheet index
7324 pAry[i] = aRangeAddress;
7327 return aSeq;
7329 return uno::Sequence<table::CellRangeAddress>();
7332 void SAL_CALL ScTableSheetObj::setPrintAreas(
7333 const uno::Sequence<table::CellRangeAddress>& aPrintAreas )
7334 throw(uno::RuntimeException, std::exception)
7336 SolarMutexGuard aGuard;
7337 ScPrintRangeSaver* pOldRanges = NULL;
7338 ScDocShell* pDocSh = GetDocShell();
7339 if ( pDocSh )
7341 ScDocument* pDoc = pDocSh->GetDocument();
7342 SCTAB nTab = GetTab_Impl();
7344 if ( pDoc->IsUndoEnabled() )
7345 pOldRanges = pDoc->CreatePrintRangeSaver();
7347 sal_uInt16 nCount = (sal_uInt16) aPrintAreas.getLength();
7348 pDoc->ClearPrintRanges( nTab );
7349 if (nCount)
7351 ScRange aPrintRange;
7352 const table::CellRangeAddress* pAry = aPrintAreas.getConstArray();
7353 for (sal_uInt16 i=0; i<nCount; i++)
7355 ScUnoConversion::FillScRange( aPrintRange, pAry[i] );
7356 pDoc->AddPrintRange( nTab, aPrintRange );
7360 if ( pDoc->IsUndoEnabled() )
7361 PrintAreaUndo_Impl( pOldRanges ); // Undo, Umbrueche, Modified etc.
7365 sal_Bool SAL_CALL ScTableSheetObj::getPrintTitleColumns() throw(uno::RuntimeException, std::exception)
7367 SolarMutexGuard aGuard;
7368 ScDocShell* pDocSh = GetDocShell();
7369 if ( pDocSh )
7371 ScDocument* pDoc = pDocSh->GetDocument();
7372 SCTAB nTab = GetTab_Impl();
7373 return ( pDoc->GetRepeatColRange(nTab) != NULL );
7375 return false;
7378 void SAL_CALL ScTableSheetObj::setPrintTitleColumns( sal_Bool bPrintTitleColumns )
7379 throw(uno::RuntimeException, std::exception)
7381 SolarMutexGuard aGuard;
7382 ScDocShell* pDocSh = GetDocShell();
7383 if ( pDocSh )
7385 ScDocument* pDoc = pDocSh->GetDocument();
7386 SCTAB nTab = GetTab_Impl();
7388 ScPrintRangeSaver* pOldRanges = pDoc->CreatePrintRangeSaver();
7390 if ( bPrintTitleColumns )
7392 if ( !pDoc->GetRepeatColRange( nTab ) ) // keinen bestehenden Bereich veraendern
7394 ScRange aNew( 0, 0, nTab, 0, 0, nTab ); // Default
7395 pDoc->SetRepeatColRange( nTab, &aNew ); // einschalten
7398 else
7399 pDoc->SetRepeatColRange( nTab, NULL ); // abschalten
7401 PrintAreaUndo_Impl( pOldRanges ); // Undo, Umbrueche, Modified etc.
7403 //! zuletzt gesetzten Bereich beim Abschalten merken und beim Einschalten wiederherstellen ???
7407 table::CellRangeAddress SAL_CALL ScTableSheetObj::getTitleColumns() throw(uno::RuntimeException, std::exception)
7409 SolarMutexGuard aGuard;
7410 table::CellRangeAddress aRet;
7411 ScDocShell* pDocSh = GetDocShell();
7412 if ( pDocSh )
7414 ScDocument* pDoc = pDocSh->GetDocument();
7415 SCTAB nTab = GetTab_Impl();
7416 const ScRange* pRange = pDoc->GetRepeatColRange(nTab);
7417 if (pRange)
7419 ScUnoConversion::FillApiRange( aRet, *pRange );
7420 aRet.Sheet = nTab; // core does not care about sheet index
7423 return aRet;
7426 void SAL_CALL ScTableSheetObj::setTitleColumns( const table::CellRangeAddress& aTitleColumns )
7427 throw(uno::RuntimeException, std::exception)
7429 SolarMutexGuard aGuard;
7430 ScDocShell* pDocSh = GetDocShell();
7431 if ( pDocSh )
7433 ScDocument* pDoc = pDocSh->GetDocument();
7434 SCTAB nTab = GetTab_Impl();
7436 ScPrintRangeSaver* pOldRanges = pDoc->CreatePrintRangeSaver();
7438 ScRange aNew;
7439 ScUnoConversion::FillScRange( aNew, aTitleColumns );
7440 pDoc->SetRepeatColRange( nTab, &aNew ); // immer auch einschalten
7442 PrintAreaUndo_Impl( pOldRanges ); // Undo, Umbrueche, Modified etc.
7446 sal_Bool SAL_CALL ScTableSheetObj::getPrintTitleRows() throw(uno::RuntimeException, std::exception)
7448 SolarMutexGuard aGuard;
7449 ScDocShell* pDocSh = GetDocShell();
7450 if ( pDocSh )
7452 ScDocument* pDoc = pDocSh->GetDocument();
7453 SCTAB nTab = GetTab_Impl();
7454 return ( pDoc->GetRepeatRowRange(nTab) != NULL );
7456 return false;
7459 void SAL_CALL ScTableSheetObj::setPrintTitleRows( sal_Bool bPrintTitleRows )
7460 throw(uno::RuntimeException, std::exception)
7462 SolarMutexGuard aGuard;
7463 ScDocShell* pDocSh = GetDocShell();
7464 if ( pDocSh )
7466 ScDocument* pDoc = pDocSh->GetDocument();
7467 SCTAB nTab = GetTab_Impl();
7469 ScPrintRangeSaver* pOldRanges = pDoc->CreatePrintRangeSaver();
7471 if ( bPrintTitleRows )
7473 if ( !pDoc->GetRepeatRowRange( nTab ) ) // keinen bestehenden Bereich veraendern
7475 ScRange aNew( 0, 0, nTab, 0, 0, nTab ); // Default
7476 pDoc->SetRepeatRowRange( nTab, &aNew ); // einschalten
7479 else
7480 pDoc->SetRepeatRowRange( nTab, NULL ); // abschalten
7482 PrintAreaUndo_Impl( pOldRanges ); // Undo, Umbrueche, Modified etc.
7484 //! zuletzt gesetzten Bereich beim Abschalten merken und beim Einschalten wiederherstellen ???
7488 table::CellRangeAddress SAL_CALL ScTableSheetObj::getTitleRows() throw(uno::RuntimeException, std::exception)
7490 SolarMutexGuard aGuard;
7491 table::CellRangeAddress aRet;
7492 ScDocShell* pDocSh = GetDocShell();
7493 if ( pDocSh )
7495 ScDocument* pDoc = pDocSh->GetDocument();
7496 SCTAB nTab = GetTab_Impl();
7497 const ScRange* pRange = pDoc->GetRepeatRowRange(nTab);
7498 if (pRange)
7500 ScUnoConversion::FillApiRange( aRet, *pRange );
7501 aRet.Sheet = nTab; // core does not care about sheet index
7504 return aRet;
7507 void SAL_CALL ScTableSheetObj::setTitleRows( const table::CellRangeAddress& aTitleRows )
7508 throw(uno::RuntimeException, std::exception)
7510 SolarMutexGuard aGuard;
7511 ScDocShell* pDocSh = GetDocShell();
7512 if ( pDocSh )
7514 ScDocument* pDoc = pDocSh->GetDocument();
7515 SCTAB nTab = GetTab_Impl();
7517 ScPrintRangeSaver* pOldRanges = pDoc->CreatePrintRangeSaver();
7519 ScRange aNew;
7520 ScUnoConversion::FillScRange( aNew, aTitleRows );
7521 pDoc->SetRepeatRowRange( nTab, &aNew ); // immer auch einschalten
7523 PrintAreaUndo_Impl( pOldRanges ); // Undo, Umbrueche, Modified etc.
7527 // XSheetLinkable
7529 sheet::SheetLinkMode SAL_CALL ScTableSheetObj::getLinkMode() throw(uno::RuntimeException, std::exception)
7531 SolarMutexGuard aGuard;
7532 sheet::SheetLinkMode eRet = sheet::SheetLinkMode_NONE;
7533 ScDocShell* pDocSh = GetDocShell();
7534 if ( pDocSh )
7536 sal_uInt8 nMode = pDocSh->GetDocument()->GetLinkMode( GetTab_Impl() );
7537 if ( nMode == SC_LINK_NORMAL )
7538 eRet = sheet::SheetLinkMode_NORMAL;
7539 else if ( nMode == SC_LINK_VALUE )
7540 eRet = sheet::SheetLinkMode_VALUE;
7542 return eRet;
7545 void SAL_CALL ScTableSheetObj::setLinkMode( sheet::SheetLinkMode nLinkMode )
7546 throw(uno::RuntimeException, std::exception)
7548 SolarMutexGuard aGuard;
7550 //! Filter und Options aus altem Link suchen
7552 OUString aUrl(getLinkUrl());
7553 OUString aSheet(getLinkSheetName());
7555 OUString aEmpty;
7556 link( aUrl, aSheet, aEmpty, aEmpty, nLinkMode );
7559 OUString SAL_CALL ScTableSheetObj::getLinkUrl() throw(uno::RuntimeException, std::exception)
7561 SolarMutexGuard aGuard;
7562 OUString aFile;
7563 ScDocShell* pDocSh = GetDocShell();
7564 if ( pDocSh )
7565 aFile = pDocSh->GetDocument()->GetLinkDoc( GetTab_Impl() );
7566 return aFile;
7569 void SAL_CALL ScTableSheetObj::setLinkUrl( const OUString& aLinkUrl )
7570 throw(uno::RuntimeException, std::exception)
7572 SolarMutexGuard aGuard;
7574 //! Filter und Options aus altem Link suchen
7576 sheet::SheetLinkMode eMode = getLinkMode();
7577 OUString aSheet(getLinkSheetName());
7579 OUString aEmpty;
7580 link( aLinkUrl, aSheet, aEmpty, aEmpty, eMode );
7583 OUString SAL_CALL ScTableSheetObj::getLinkSheetName() throw(uno::RuntimeException, std::exception)
7585 SolarMutexGuard aGuard;
7586 OUString aSheet;
7587 ScDocShell* pDocSh = GetDocShell();
7588 if ( pDocSh )
7589 aSheet = pDocSh->GetDocument()->GetLinkTab( GetTab_Impl() );
7590 return aSheet;
7593 void SAL_CALL ScTableSheetObj::setLinkSheetName( const OUString& aLinkSheetName )
7594 throw(uno::RuntimeException, std::exception)
7596 SolarMutexGuard aGuard;
7598 //! Filter und Options aus altem Link suchen
7600 sheet::SheetLinkMode eMode = getLinkMode();
7601 OUString aUrl(getLinkUrl());
7603 OUString aEmpty;
7604 link( aUrl, aLinkSheetName, aEmpty, aEmpty, eMode );
7607 void SAL_CALL ScTableSheetObj::link( const OUString& aUrl, const OUString& aSheetName,
7608 const OUString& aFilterName, const OUString& aFilterOptions,
7609 sheet::SheetLinkMode nMode ) throw(uno::RuntimeException, std::exception)
7611 SolarMutexGuard aGuard;
7612 ScDocShell* pDocSh = GetDocShell();
7613 if ( pDocSh )
7615 ScDocument* pDoc = pDocSh->GetDocument();
7616 SCTAB nTab = GetTab_Impl();
7618 OUString aFileString = aUrl;
7619 OUString aFilterString = aFilterName;
7620 OUString aOptString = aFilterOptions;
7621 OUString aSheetString = aSheetName;
7623 aFileString = ScGlobal::GetAbsDocName( aFileString, pDocSh );
7624 if (aFilterString.isEmpty())
7625 ScDocumentLoader::GetFilterName( aFileString, aFilterString, aOptString, true, false );
7627 // remove application prefix from filter name here, so the filter options
7628 // aren't reset when the filter name is changed in ScTableLink::DataChanged
7629 ScDocumentLoader::RemoveAppPrefix( aFilterString );
7631 sal_uInt8 nLinkMode = SC_LINK_NONE;
7632 if ( nMode == sheet::SheetLinkMode_NORMAL )
7633 nLinkMode = SC_LINK_NORMAL;
7634 else if ( nMode == sheet::SheetLinkMode_VALUE )
7635 nLinkMode = SC_LINK_VALUE;
7637 sal_uLong nRefresh = 0;
7638 pDoc->SetLink( nTab, nLinkMode, aFileString, aFilterString, aOptString, aSheetString, nRefresh );
7640 pDocSh->UpdateLinks(); // ggf. Link eintragen oder loeschen
7641 SfxBindings* pBindings = pDocSh->GetViewBindings();
7642 if (pBindings)
7643 pBindings->Invalidate(SID_LINKS);
7645 //! Undo fuer Link-Daten an der Table
7647 if ( nLinkMode != SC_LINK_NONE && pDoc->IsExecuteLinkEnabled() ) // Link updaten
7649 // Update immer, auch wenn der Link schon da war
7650 //! Update nur fuer die betroffene Tabelle???
7652 sfx2::LinkManager* pLinkManager = pDoc->GetLinkManager();
7653 sal_uInt16 nCount = pLinkManager->GetLinks().size();
7654 for ( sal_uInt16 i=0; i<nCount; i++ )
7656 ::sfx2::SvBaseLink* pBase = *pLinkManager->GetLinks()[i];
7657 if (pBase->ISA(ScTableLink))
7659 ScTableLink* pTabLink = (ScTableLink*)pBase;
7660 if ( aFileString.equals(pTabLink->GetFileName()) )
7661 pTabLink->Update(); // inkl. Paint&Undo
7663 //! Der Dateiname sollte nur einmal vorkommen (?)
7668 //! Notify fuer ScSheetLinkObj Objekte!!!
7672 // XSheetAuditing
7674 sal_Bool SAL_CALL ScTableSheetObj::hideDependents( const table::CellAddress& aPosition )
7675 throw(uno::RuntimeException, std::exception)
7677 SolarMutexGuard aGuard;
7678 ScDocShell* pDocSh = GetDocShell();
7679 if ( pDocSh )
7681 SCTAB nTab = GetTab_Impl();
7682 OSL_ENSURE( aPosition.Sheet == nTab, "falsche Tabelle in CellAddress" );
7683 ScAddress aPos( (SCCOL)aPosition.Column, (SCROW)aPosition.Row, nTab );
7684 return pDocSh->GetDocFunc().DetectiveDelSucc( aPos );
7686 return false;
7689 sal_Bool SAL_CALL ScTableSheetObj::hidePrecedents( const table::CellAddress& aPosition )
7690 throw(uno::RuntimeException, std::exception)
7692 SolarMutexGuard aGuard;
7693 ScDocShell* pDocSh = GetDocShell();
7694 if ( pDocSh )
7696 SCTAB nTab = GetTab_Impl();
7697 OSL_ENSURE( aPosition.Sheet == nTab, "falsche Tabelle in CellAddress" );
7698 ScAddress aPos( (SCCOL)aPosition.Column, (SCROW)aPosition.Row, nTab );
7699 return pDocSh->GetDocFunc().DetectiveDelPred( aPos );
7701 return false;
7704 sal_Bool SAL_CALL ScTableSheetObj::showDependents( const table::CellAddress& aPosition )
7705 throw(uno::RuntimeException, std::exception)
7707 SolarMutexGuard aGuard;
7708 ScDocShell* pDocSh = GetDocShell();
7709 if ( pDocSh )
7711 SCTAB nTab = GetTab_Impl();
7712 OSL_ENSURE( aPosition.Sheet == nTab, "falsche Tabelle in CellAddress" );
7713 ScAddress aPos( (SCCOL)aPosition.Column, (SCROW)aPosition.Row, nTab );
7714 return pDocSh->GetDocFunc().DetectiveAddSucc( aPos );
7716 return false;
7719 sal_Bool SAL_CALL ScTableSheetObj::showPrecedents( const table::CellAddress& aPosition )
7720 throw(uno::RuntimeException, std::exception)
7722 SolarMutexGuard aGuard;
7723 ScDocShell* pDocSh = GetDocShell();
7724 if ( pDocSh )
7726 SCTAB nTab = GetTab_Impl();
7727 OSL_ENSURE( aPosition.Sheet == nTab, "falsche Tabelle in CellAddress" );
7728 ScAddress aPos( (SCCOL)aPosition.Column, (SCROW)aPosition.Row, nTab );
7729 return pDocSh->GetDocFunc().DetectiveAddPred( aPos );
7731 return false;
7734 sal_Bool SAL_CALL ScTableSheetObj::showErrors( const table::CellAddress& aPosition )
7735 throw(uno::RuntimeException, std::exception)
7737 SolarMutexGuard aGuard;
7738 ScDocShell* pDocSh = GetDocShell();
7739 if ( pDocSh )
7741 SCTAB nTab = GetTab_Impl();
7742 OSL_ENSURE( aPosition.Sheet == nTab, "falsche Tabelle in CellAddress" );
7743 ScAddress aPos( (SCCOL)aPosition.Column, (SCROW)aPosition.Row, nTab );
7744 return pDocSh->GetDocFunc().DetectiveAddError( aPos );
7746 return false;
7749 sal_Bool SAL_CALL ScTableSheetObj::showInvalid() throw(uno::RuntimeException, std::exception)
7751 SolarMutexGuard aGuard;
7752 ScDocShell* pDocSh = GetDocShell();
7753 if ( pDocSh )
7754 return pDocSh->GetDocFunc().DetectiveMarkInvalid( GetTab_Impl() );
7755 return false;
7758 void SAL_CALL ScTableSheetObj::clearArrows() throw(uno::RuntimeException, std::exception)
7760 SolarMutexGuard aGuard;
7761 ScDocShell* pDocSh = GetDocShell();
7762 if ( pDocSh )
7763 pDocSh->GetDocFunc().DetectiveDelAll( GetTab_Impl() );
7766 // XSheetOutline
7768 void SAL_CALL ScTableSheetObj::group( const table::CellRangeAddress& rGroupRange,
7769 table::TableOrientation nOrientation )
7770 throw (uno::RuntimeException,
7771 std::exception)
7773 SolarMutexGuard aGuard;
7774 ScDocShell* pDocSh = GetDocShell();
7775 if ( pDocSh )
7777 bool bColumns = ( nOrientation == table::TableOrientation_COLUMNS );
7778 ScRange aGroupRange;
7779 ScUnoConversion::FillScRange( aGroupRange, rGroupRange );
7780 ScOutlineDocFunc aFunc(*pDocSh);
7781 aFunc.MakeOutline( aGroupRange, bColumns, true, true );
7785 void SAL_CALL ScTableSheetObj::ungroup( const table::CellRangeAddress& rGroupRange,
7786 table::TableOrientation nOrientation )
7787 throw (uno::RuntimeException,
7788 std::exception)
7790 SolarMutexGuard aGuard;
7791 ScDocShell* pDocSh = GetDocShell();
7792 if ( pDocSh )
7794 bool bColumns = ( nOrientation == table::TableOrientation_COLUMNS );
7795 ScRange aGroupRange;
7796 ScUnoConversion::FillScRange( aGroupRange, rGroupRange );
7797 ScOutlineDocFunc aFunc(*pDocSh);
7798 aFunc.RemoveOutline( aGroupRange, bColumns, true, true );
7802 void SAL_CALL ScTableSheetObj::autoOutline( const table::CellRangeAddress& rCellRange )
7803 throw(uno::RuntimeException, std::exception)
7805 SolarMutexGuard aGuard;
7806 ScDocShell* pDocSh = GetDocShell();
7807 if ( pDocSh )
7809 ScRange aFormulaRange;
7810 ScUnoConversion::FillScRange( aFormulaRange, rCellRange );
7811 ScOutlineDocFunc aFunc(*pDocSh);
7812 aFunc.AutoOutline( aFormulaRange, true );
7816 void SAL_CALL ScTableSheetObj::clearOutline()
7817 throw(uno::RuntimeException, std::exception)
7819 SolarMutexGuard aGuard;
7820 ScDocShell* pDocSh = GetDocShell();
7821 if ( pDocSh )
7823 SCTAB nTab = GetTab_Impl();
7824 ScOutlineDocFunc aFunc(*pDocSh);
7825 aFunc.RemoveAllOutlines( nTab, true );
7829 void SAL_CALL ScTableSheetObj::hideDetail( const table::CellRangeAddress& rCellRange )
7830 throw(uno::RuntimeException, std::exception)
7832 SolarMutexGuard aGuard;
7833 ScDocShell* pDocSh = GetDocShell();
7834 if ( pDocSh )
7836 ScRange aMarkRange;
7837 ScUnoConversion::FillScRange( aMarkRange, rCellRange );
7838 ScOutlineDocFunc aFunc(*pDocSh);
7839 aFunc.HideMarkedOutlines( aMarkRange, true );
7843 void SAL_CALL ScTableSheetObj::showDetail( const table::CellRangeAddress& rCellRange )
7844 throw(uno::RuntimeException, std::exception)
7846 SolarMutexGuard aGuard;
7847 ScDocShell* pDocSh = GetDocShell();
7848 if ( pDocSh )
7850 ScRange aMarkRange;
7851 ScUnoConversion::FillScRange( aMarkRange, rCellRange );
7852 ScOutlineDocFunc aFunc(*pDocSh);
7853 aFunc.ShowMarkedOutlines( aMarkRange, true );
7857 void SAL_CALL ScTableSheetObj::showLevel( sal_Int16 nLevel, table::TableOrientation nOrientation )
7858 throw(uno::RuntimeException, std::exception)
7860 SolarMutexGuard aGuard;
7861 ScDocShell* pDocSh = GetDocShell();
7862 if ( pDocSh )
7864 bool bColumns = ( nOrientation == table::TableOrientation_COLUMNS );
7865 SCTAB nTab = GetTab_Impl();
7866 ScOutlineDocFunc aFunc(*pDocSh);
7867 aFunc.SelectLevel( nTab, bColumns, nLevel, true, true );
7871 // XProtectable
7873 void SAL_CALL ScTableSheetObj::protect( const OUString& aPassword )
7874 throw(uno::RuntimeException, std::exception)
7876 SolarMutexGuard aGuard;
7877 ScDocShell* pDocSh = GetDocShell();
7878 // #i108245# if already protected, don't change anything
7879 if ( pDocSh && !pDocSh->GetDocument()->IsTabProtected( GetTab_Impl() ) )
7881 OUString aString(aPassword);
7882 pDocSh->GetDocFunc().Protect( GetTab_Impl(), aString, true );
7886 void SAL_CALL ScTableSheetObj::unprotect( const OUString& aPassword )
7887 throw(lang::IllegalArgumentException, uno::RuntimeException, std::exception)
7889 SolarMutexGuard aGuard;
7890 ScDocShell* pDocSh = GetDocShell();
7891 if ( pDocSh )
7893 OUString aString(aPassword);
7894 bool bDone = pDocSh->GetDocFunc().Unprotect( GetTab_Impl(), aString, true );
7895 if (!bDone)
7896 throw lang::IllegalArgumentException();
7900 sal_Bool SAL_CALL ScTableSheetObj::isProtected() throw(uno::RuntimeException, std::exception)
7902 SolarMutexGuard aGuard;
7903 ScDocShell* pDocSh = GetDocShell();
7904 if ( pDocSh )
7905 return pDocSh->GetDocument()->IsTabProtected( GetTab_Impl() );
7907 OSL_FAIL("keine DocShell"); //! Exception oder so?
7908 return false;
7911 // XScenario
7913 sal_Bool SAL_CALL ScTableSheetObj::getIsScenario() throw(uno::RuntimeException, std::exception)
7915 SolarMutexGuard aGuard;
7916 ScDocShell* pDocSh = GetDocShell();
7917 if ( pDocSh )
7918 return pDocSh->GetDocument()->IsScenario( GetTab_Impl() );
7920 return false;
7923 OUString SAL_CALL ScTableSheetObj::getScenarioComment() throw(uno::RuntimeException, std::exception)
7925 SolarMutexGuard aGuard;
7926 ScDocShell* pDocSh = GetDocShell();
7927 if ( pDocSh )
7929 OUString aComment;
7930 Color aColor;
7931 sal_uInt16 nFlags;
7932 pDocSh->GetDocument()->GetScenarioData( GetTab_Impl(), aComment, aColor, nFlags );
7933 return aComment;
7935 return OUString();
7938 void SAL_CALL ScTableSheetObj::setScenarioComment( const OUString& aScenarioComment )
7939 throw(uno::RuntimeException, std::exception)
7941 SolarMutexGuard aGuard;
7942 ScDocShell* pDocSh = GetDocShell();
7943 if ( pDocSh )
7945 ScDocument* pDoc = pDocSh->GetDocument();
7946 SCTAB nTab = GetTab_Impl();
7948 OUString aName;
7949 OUString aComment;
7950 Color aColor;
7951 sal_uInt16 nFlags;
7952 pDoc->GetName( nTab, aName );
7953 pDoc->GetScenarioData( nTab, aComment, aColor, nFlags );
7955 aComment = aScenarioComment;
7957 pDocSh->ModifyScenario( nTab, aName, aComment, aColor, nFlags );
7961 void SAL_CALL ScTableSheetObj::addRanges( const uno::Sequence<table::CellRangeAddress>& rScenRanges )
7962 throw(uno::RuntimeException, std::exception)
7964 SolarMutexGuard aGuard;
7965 ScDocShell* pDocSh = GetDocShell();
7966 if ( pDocSh )
7968 ScDocument* pDoc = pDocSh->GetDocument();
7969 SCTAB nTab = GetTab_Impl();
7971 if (pDoc->IsScenario(nTab))
7973 ScMarkData aMarkData;
7974 aMarkData.SelectTable( nTab, true );
7976 sal_uInt16 nRangeCount = (sal_uInt16)rScenRanges.getLength();
7977 if (nRangeCount)
7979 const table::CellRangeAddress* pAry = rScenRanges.getConstArray();
7980 for (sal_uInt16 i=0; i<nRangeCount; i++)
7982 OSL_ENSURE( pAry[i].Sheet == nTab, "addRanges mit falscher Tab" );
7983 ScRange aOneRange( (SCCOL)pAry[i].StartColumn, (SCROW)pAry[i].StartRow, nTab,
7984 (SCCOL)pAry[i].EndColumn, (SCROW)pAry[i].EndRow, nTab );
7986 aMarkData.SetMultiMarkArea( aOneRange );
7990 // Szenario-Ranges sind durch Attribut gekennzeichnet
7991 ScPatternAttr aPattern( pDoc->GetPool() );
7992 aPattern.GetItemSet().Put( ScMergeFlagAttr( SC_MF_SCENARIO ) );
7993 aPattern.GetItemSet().Put( ScProtectionAttr( true ) );
7994 pDocSh->GetDocFunc().ApplyAttributes( aMarkData, aPattern, true, true );
7999 void SAL_CALL ScTableSheetObj::apply() throw(uno::RuntimeException, std::exception)
8001 SolarMutexGuard aGuard;
8002 ScDocShell* pDocSh = GetDocShell();
8003 if ( pDocSh )
8005 ScDocument* pDoc = pDocSh->GetDocument();
8006 SCTAB nTab = GetTab_Impl();
8007 OUString aName;
8008 pDoc->GetName( nTab, aName ); // Name dieses Szenarios
8010 SCTAB nDestTab = nTab;
8011 while ( nDestTab > 0 && pDoc->IsScenario(nDestTab) )
8012 --nDestTab;
8014 if ( !pDoc->IsScenario(nDestTab) )
8015 pDocSh->UseScenario( nDestTab, aName );
8017 //! sonst Fehler oder so
8021 // XScenarioEnhanced
8023 uno::Sequence< table::CellRangeAddress > SAL_CALL ScTableSheetObj::getRanges( )
8024 throw(uno::RuntimeException, std::exception)
8026 SolarMutexGuard aGuard;
8027 ScDocShell* pDocSh = GetDocShell();
8028 if ( pDocSh )
8030 ScDocument* pDoc = pDocSh->GetDocument();
8031 SCTAB nTab = GetTab_Impl();
8032 const ScRangeList* pRangeList = pDoc->GetScenarioRanges(nTab);
8033 if (pRangeList)
8035 size_t nCount = pRangeList->size();
8036 uno::Sequence< table::CellRangeAddress > aRetRanges( nCount );
8037 table::CellRangeAddress* pAry = aRetRanges.getArray();
8038 for( size_t nIndex = 0; nIndex < nCount; nIndex++ )
8040 const ScRange* pRange = (*pRangeList)[nIndex];
8041 pAry->StartColumn = pRange->aStart.Col();
8042 pAry->StartRow = pRange->aStart.Row();
8043 pAry->EndColumn = pRange->aEnd.Col();
8044 pAry->EndRow = pRange->aEnd.Row();
8045 pAry->Sheet = pRange->aStart.Tab();
8046 ++pAry;
8048 return aRetRanges;
8051 return uno::Sequence< table::CellRangeAddress > ();
8054 // XExternalSheetName
8056 void ScTableSheetObj::setExternalName( const OUString& aUrl, const OUString& aSheetName )
8057 throw (container::ElementExistException, uno::RuntimeException, std::exception)
8059 SolarMutexGuard aGuard;
8060 ScDocShell* pDocSh = GetDocShell();
8061 if ( pDocSh )
8063 ScDocument* pDoc = pDocSh->GetDocument();
8064 if ( pDoc )
8066 const SCTAB nTab = GetTab_Impl();
8067 const OUString aAbsDocName( ScGlobal::GetAbsDocName( aUrl, pDocSh ) );
8068 const OUString aDocTabName( ScGlobal::GetDocTabName( aAbsDocName, aSheetName ) );
8069 if ( !pDoc->RenameTab( nTab, aDocTabName, false /*bUpdateRef*/, true /*bExternalDocument*/ ) )
8071 throw container::ElementExistException( OUString(), *this );
8077 // XEventsSupplier
8079 uno::Reference<container::XNameReplace> SAL_CALL ScTableSheetObj::getEvents() throw (uno::RuntimeException, std::exception)
8081 SolarMutexGuard aGuard;
8082 ScDocShell* pDocSh = GetDocShell();
8083 if ( pDocSh )
8084 return new ScSheetEventsObj( pDocSh, GetTab_Impl() );
8086 return NULL;
8089 // XPropertySet erweitert fuer Sheet-Properties
8091 uno::Reference<beans::XPropertySetInfo> SAL_CALL ScTableSheetObj::getPropertySetInfo()
8092 throw(uno::RuntimeException, std::exception)
8094 SolarMutexGuard aGuard;
8095 static uno::Reference<beans::XPropertySetInfo> aRef(
8096 new SfxItemPropertySetInfo( pSheetPropSet->getPropertyMap() ));
8097 return aRef;
8100 void ScTableSheetObj::SetOnePropertyValue( const SfxItemPropertySimpleEntry* pEntry, const uno::Any& aValue )
8101 throw(lang::IllegalArgumentException, uno::RuntimeException,
8102 std::exception)
8104 if ( pEntry )
8106 if ( IsScItemWid( pEntry->nWID ) )
8108 // for Item WIDs, call ScCellRangesBase directly
8109 ScCellRangesBase::SetOnePropertyValue(pEntry, aValue);
8110 return;
8113 // own properties
8115 ScDocShell* pDocSh = GetDocShell();
8116 if (!pDocSh)
8117 return; //! Exception oder so?
8118 ScDocument* pDoc = pDocSh->GetDocument();
8119 SCTAB nTab = GetTab_Impl();
8120 ScDocFunc &rFunc = pDocSh->GetDocFunc();
8122 if ( pEntry->nWID == SC_WID_UNO_PAGESTL )
8124 OUString aStrVal;
8125 aValue >>= aStrVal;
8126 OUString aNewStr(ScStyleNameConversion::ProgrammaticToDisplayName(
8127 aStrVal, SFX_STYLE_FAMILY_PAGE ));
8129 //! Undo? (auch bei SID_STYLE_APPLY an der View)
8131 if ( pDoc->GetPageStyle( nTab ) != aNewStr )
8133 pDoc->SetPageStyle( nTab, aNewStr );
8134 if (!pDoc->IsImportingXML())
8136 ScPrintFunc( pDocSh, pDocSh->GetPrinter(), nTab ).UpdatePages();
8138 SfxBindings* pBindings = pDocSh->GetViewBindings();
8139 if (pBindings)
8141 pBindings->Invalidate( SID_STYLE_FAMILY4 );
8142 pBindings->Invalidate( SID_STATUS_PAGESTYLE );
8143 pBindings->Invalidate( FID_RESET_PRINTZOOM );
8144 pBindings->Invalidate( SID_ATTR_PARA_LEFT_TO_RIGHT );
8145 pBindings->Invalidate( SID_ATTR_PARA_RIGHT_TO_LEFT );
8148 pDocSh->SetDocumentModified();
8151 else if ( pEntry->nWID == SC_WID_UNO_CELLVIS )
8153 bool bVis = ScUnoHelpFunctions::GetBoolFromAny( aValue );
8154 rFunc.SetTableVisible( nTab, bVis, true );
8156 else if ( pEntry->nWID == SC_WID_UNO_ISACTIVE )
8158 if (pDoc->IsScenario(nTab))
8159 pDoc->SetActiveScenario( nTab, ScUnoHelpFunctions::GetBoolFromAny( aValue ) );
8161 else if ( pEntry->nWID == SC_WID_UNO_BORDCOL )
8163 if (pDoc->IsScenario(nTab))
8165 sal_Int32 nNewColor = 0;
8166 if (aValue >>= nNewColor)
8168 OUString aName;
8169 OUString aComment;
8170 Color aColor;
8171 sal_uInt16 nFlags;
8172 pDoc->GetName( nTab, aName );
8173 pDoc->GetScenarioData( nTab, aComment, aColor, nFlags );
8175 aColor = Color(static_cast<sal_uInt32>(nNewColor));
8177 pDocSh->ModifyScenario( nTab, aName, aComment, aColor, nFlags );
8181 else if ( pEntry->nWID == SC_WID_UNO_PROTECT )
8183 if (pDoc->IsScenario(nTab))
8185 OUString aName;
8186 OUString aComment;
8187 Color aColor;
8188 sal_uInt16 nFlags;
8189 pDoc->GetName( nTab, aName );
8190 pDoc->GetScenarioData( nTab, aComment, aColor, nFlags );
8191 bool bModify(false);
8193 if (ScUnoHelpFunctions::GetBoolFromAny( aValue ))
8195 if (!(nFlags & SC_SCENARIO_PROTECT))
8197 nFlags |= SC_SCENARIO_PROTECT;
8198 bModify = true;
8201 else
8203 if (nFlags & SC_SCENARIO_PROTECT)
8205 nFlags -= SC_SCENARIO_PROTECT;
8206 bModify = true;
8210 if (bModify)
8211 pDocSh->ModifyScenario( nTab, aName, aComment, aColor, nFlags );
8214 else if ( pEntry->nWID == SC_WID_UNO_SHOWBORD )
8216 if (pDoc->IsScenario(nTab))
8218 OUString aName;
8219 OUString aComment;
8220 Color aColor;
8221 sal_uInt16 nFlags;
8222 pDoc->GetName( nTab, aName );
8223 pDoc->GetScenarioData( nTab, aComment, aColor, nFlags );
8224 bool bModify(false);
8226 if (ScUnoHelpFunctions::GetBoolFromAny( aValue ))
8228 if (!(nFlags & SC_SCENARIO_SHOWFRAME))
8230 nFlags |= SC_SCENARIO_SHOWFRAME;
8231 bModify = true;
8234 else
8236 if (nFlags & SC_SCENARIO_SHOWFRAME)
8238 nFlags -= SC_SCENARIO_SHOWFRAME;
8239 bModify = true;
8243 if (bModify)
8244 pDocSh->ModifyScenario( nTab, aName, aComment, aColor, nFlags );
8247 else if ( pEntry->nWID == SC_WID_UNO_PRINTBORD )
8249 if (pDoc->IsScenario(nTab))
8251 OUString aName;
8252 OUString aComment;
8253 Color aColor;
8254 sal_uInt16 nFlags;
8255 pDoc->GetName( nTab, aName );
8256 pDoc->GetScenarioData( nTab, aComment, aColor, nFlags );
8257 bool bModify(false);
8259 if (ScUnoHelpFunctions::GetBoolFromAny( aValue ))
8261 if (!(nFlags & SC_SCENARIO_PRINTFRAME))
8263 nFlags |= SC_SCENARIO_PRINTFRAME;
8264 bModify = true;
8267 else
8269 if (nFlags & SC_SCENARIO_PRINTFRAME)
8271 nFlags -= SC_SCENARIO_PRINTFRAME;
8272 bModify = true;
8276 if (bModify)
8277 pDocSh->ModifyScenario( nTab, aName, aComment, aColor, nFlags );
8280 else if ( pEntry->nWID == SC_WID_UNO_COPYBACK )
8282 if (pDoc->IsScenario(nTab))
8284 OUString aName;
8285 OUString aComment;
8286 Color aColor;
8287 sal_uInt16 nFlags;
8288 pDoc->GetName( nTab, aName );
8289 pDoc->GetScenarioData( nTab, aComment, aColor, nFlags );
8290 bool bModify(false);
8292 if (ScUnoHelpFunctions::GetBoolFromAny( aValue ))
8294 if (!(nFlags & SC_SCENARIO_TWOWAY))
8296 nFlags |= SC_SCENARIO_TWOWAY;
8297 bModify = true;
8300 else
8302 if (nFlags & SC_SCENARIO_TWOWAY)
8304 nFlags -= SC_SCENARIO_TWOWAY;
8305 bModify = true;
8309 if (bModify)
8310 pDocSh->ModifyScenario( nTab, aName, aComment, aColor, nFlags );
8313 else if ( pEntry->nWID == SC_WID_UNO_COPYSTYL )
8315 if (pDoc->IsScenario(nTab))
8317 OUString aName;
8318 OUString aComment;
8319 Color aColor;
8320 sal_uInt16 nFlags;
8321 pDoc->GetName( nTab, aName );
8322 pDoc->GetScenarioData( nTab, aComment, aColor, nFlags );
8323 bool bModify(false);
8325 if (ScUnoHelpFunctions::GetBoolFromAny( aValue ))
8327 if (!(nFlags & SC_SCENARIO_ATTRIB))
8329 nFlags |= SC_SCENARIO_ATTRIB;
8330 bModify = true;
8333 else
8335 if (nFlags & SC_SCENARIO_ATTRIB)
8337 nFlags -= SC_SCENARIO_ATTRIB;
8338 bModify = true;
8342 if (bModify)
8343 pDocSh->ModifyScenario( nTab, aName, aComment, aColor, nFlags );
8346 else if ( pEntry->nWID == SC_WID_UNO_COPYFORM )
8348 if (pDoc->IsScenario(nTab))
8350 OUString aName;
8351 OUString aComment;
8352 Color aColor;
8353 sal_uInt16 nFlags;
8354 pDoc->GetName( nTab, aName );
8355 pDoc->GetScenarioData( nTab, aComment, aColor, nFlags );
8356 bool bModify(false);
8358 if (ScUnoHelpFunctions::GetBoolFromAny( aValue ))
8360 if (nFlags & SC_SCENARIO_VALUE)
8362 nFlags -= SC_SCENARIO_VALUE;
8363 bModify = true;
8366 else
8368 if (!(nFlags & SC_SCENARIO_VALUE))
8370 nFlags |= SC_SCENARIO_VALUE;
8371 bModify = true;
8375 if (bModify)
8376 pDocSh->ModifyScenario( nTab, aName, aComment, aColor, nFlags );
8379 else if ( pEntry->nWID == SC_WID_UNO_TABLAYOUT )
8381 sal_Int16 nValue = 0;
8382 if (aValue >>= nValue)
8384 if (nValue == com::sun::star::text::WritingMode2::RL_TB)
8385 rFunc.SetLayoutRTL(nTab, true, true);
8386 else
8387 rFunc.SetLayoutRTL(nTab, false, true);
8390 else if ( pEntry->nWID == SC_WID_UNO_AUTOPRINT )
8392 bool bAutoPrint = ScUnoHelpFunctions::GetBoolFromAny( aValue );
8393 if (bAutoPrint)
8394 pDoc->SetPrintEntireSheet( nTab ); // clears all print ranges
8395 else
8397 if (pDoc->IsPrintEntireSheet( nTab ))
8398 pDoc->ClearPrintRanges( nTab ); // if this flag is true, there are no PrintRanges, so Clear clears only the flag.
8401 else if ( pEntry->nWID == SC_WID_UNO_TABCOLOR )
8403 sal_Int32 nColor = COL_AUTO;
8404 if ( aValue >>= nColor )
8406 const Color aColor( static_cast< ColorData >( nColor ) );
8407 if ( pDoc->GetTabBgColor( nTab ) != aColor )
8408 rFunc.SetTabBgColor( nTab, aColor, true, true );
8411 else if ( pEntry->nWID == SC_WID_UNO_CODENAME )
8413 OUString aCodeName;
8414 if ( pDocSh && ( aValue >>= aCodeName ) )
8416 pDocSh->GetDocument()->SetCodeName( GetTab_Impl(), aCodeName );
8419 else
8420 ScCellRangeObj::SetOnePropertyValue(pEntry, aValue); // base class, no Item WID
8424 void ScTableSheetObj::GetOnePropertyValue( const SfxItemPropertySimpleEntry* pEntry,
8425 uno::Any& rAny )
8426 throw(uno::RuntimeException,
8427 std::exception)
8429 if ( pEntry )
8431 ScDocShell* pDocSh = GetDocShell();
8432 if (!pDocSh)
8433 throw uno::RuntimeException();
8434 ScDocument* pDoc = pDocSh->GetDocument();
8435 SCTAB nTab = GetTab_Impl();
8437 if ( pEntry->nWID == SC_WID_UNO_NAMES )
8439 rAny <<= uno::Reference<sheet::XNamedRanges>(new ScLocalNamedRangesObj(pDocSh, this));
8441 else if ( pEntry->nWID == SC_WID_UNO_PAGESTL )
8443 rAny <<= OUString( ScStyleNameConversion::DisplayToProgrammaticName(
8444 pDoc->GetPageStyle( nTab ), SFX_STYLE_FAMILY_PAGE ) );
8446 else if ( pEntry->nWID == SC_WID_UNO_CELLVIS )
8448 bool bVis = pDoc->IsVisible( nTab );
8449 ScUnoHelpFunctions::SetBoolInAny( rAny, bVis );
8451 else if ( pEntry->nWID == SC_WID_UNO_LINKDISPBIT )
8453 // no target bitmaps for individual entries (would be all equal)
8454 // ScLinkTargetTypeObj::SetLinkTargetBitmap( aAny, SC_LINKTARGETTYPE_SHEET );
8456 else if ( pEntry->nWID == SC_WID_UNO_LINKDISPNAME )
8458 // LinkDisplayName for hyperlink dialog
8459 rAny <<= getName(); // sheet name
8461 else if ( pEntry->nWID == SC_WID_UNO_ISACTIVE )
8463 if (pDoc->IsScenario(nTab))
8464 ScUnoHelpFunctions::SetBoolInAny( rAny, pDoc->IsActiveScenario( nTab ));
8466 else if ( pEntry->nWID == SC_WID_UNO_BORDCOL )
8468 if (pDoc->IsScenario(nTab))
8470 OUString aComment;
8471 Color aColor;
8472 sal_uInt16 nFlags;
8473 pDoc->GetScenarioData( nTab, aComment, aColor, nFlags );
8475 rAny <<= static_cast<sal_Int32>(aColor.GetColor());
8478 else if ( pEntry->nWID == SC_WID_UNO_PROTECT )
8480 if (pDoc->IsScenario(nTab))
8482 OUString aComment;
8483 Color aColor;
8484 sal_uInt16 nFlags;
8485 pDoc->GetScenarioData( nTab, aComment, aColor, nFlags );
8487 ScUnoHelpFunctions::SetBoolInAny( rAny, (nFlags & SC_SCENARIO_PROTECT) != 0 );
8490 else if ( pEntry->nWID == SC_WID_UNO_SHOWBORD )
8492 if (pDoc->IsScenario(nTab))
8494 OUString aComment;
8495 Color aColor;
8496 sal_uInt16 nFlags;
8497 pDoc->GetScenarioData( nTab, aComment, aColor, nFlags );
8499 ScUnoHelpFunctions::SetBoolInAny( rAny, (nFlags & SC_SCENARIO_SHOWFRAME) != 0 );
8502 else if ( pEntry->nWID == SC_WID_UNO_PRINTBORD )
8504 if (pDoc->IsScenario(nTab))
8506 OUString aComment;
8507 Color aColor;
8508 sal_uInt16 nFlags;
8509 pDoc->GetScenarioData( nTab, aComment, aColor, nFlags );
8511 ScUnoHelpFunctions::SetBoolInAny( rAny, (nFlags & SC_SCENARIO_PRINTFRAME) != 0 );
8514 else if ( pEntry->nWID == SC_WID_UNO_COPYBACK )
8516 if (pDoc->IsScenario(nTab))
8518 OUString aComment;
8519 Color aColor;
8520 sal_uInt16 nFlags;
8521 pDoc->GetScenarioData( nTab, aComment, aColor, nFlags );
8523 ScUnoHelpFunctions::SetBoolInAny( rAny, (nFlags & SC_SCENARIO_TWOWAY) != 0 );
8526 else if ( pEntry->nWID == SC_WID_UNO_COPYSTYL )
8528 if (pDoc->IsScenario(nTab))
8530 OUString aComment;
8531 Color aColor;
8532 sal_uInt16 nFlags;
8533 pDoc->GetScenarioData( nTab, aComment, aColor, nFlags );
8535 ScUnoHelpFunctions::SetBoolInAny( rAny, (nFlags & SC_SCENARIO_ATTRIB) != 0 );
8538 else if ( pEntry->nWID == SC_WID_UNO_COPYFORM )
8540 if (pDoc->IsScenario(nTab))
8542 OUString aComment;
8543 Color aColor;
8544 sal_uInt16 nFlags;
8545 pDoc->GetScenarioData( nTab, aComment, aColor, nFlags );
8547 ScUnoHelpFunctions::SetBoolInAny( rAny, !(nFlags & SC_SCENARIO_VALUE));
8550 else if ( pEntry->nWID == SC_WID_UNO_TABLAYOUT )
8552 if (pDoc->IsLayoutRTL(nTab))
8553 rAny <<= sal_Int16(com::sun::star::text::WritingMode2::RL_TB);
8554 else
8555 rAny <<= sal_Int16(com::sun::star::text::WritingMode2::LR_TB);
8557 else if ( pEntry->nWID == SC_WID_UNO_AUTOPRINT )
8559 bool bAutoPrint = pDoc->IsPrintEntireSheet( nTab );
8560 ScUnoHelpFunctions::SetBoolInAny( rAny, bAutoPrint );
8562 else if ( pEntry->nWID == SC_WID_UNO_TABCOLOR )
8564 rAny <<= sal_Int32(pDoc->GetTabBgColor(nTab).GetColor());
8566 else if ( pEntry->nWID == SC_WID_UNO_CODENAME )
8568 OUString aCodeName;
8569 if ( pDocSh )
8570 pDocSh->GetDocument()->GetCodeName( GetTab_Impl(), aCodeName );
8571 rAny <<= OUString( aCodeName );
8573 else
8574 ScCellRangeObj::GetOnePropertyValue(pEntry, rAny);
8578 const SfxItemPropertyMap& ScTableSheetObj::GetItemPropertyMap()
8580 return pSheetPropSet->getPropertyMap();
8583 // XServiceInfo
8585 OUString SAL_CALL ScTableSheetObj::getImplementationName() throw(uno::RuntimeException, std::exception)
8587 return OUString( "ScTableSheetObj" );
8590 sal_Bool SAL_CALL ScTableSheetObj::supportsService( const OUString& rServiceName )
8591 throw(uno::RuntimeException, std::exception)
8593 return cppu::supportsService(this, rServiceName);
8596 uno::Sequence<OUString> SAL_CALL ScTableSheetObj::getSupportedServiceNames()
8597 throw(uno::RuntimeException, std::exception)
8599 uno::Sequence<OUString> aRet(7);
8600 OUString* pArray = aRet.getArray();
8601 pArray[0] = OUString( SCSPREADSHEET_SERVICE );
8602 pArray[1] = OUString( SCSHEETCELLRANGE_SERVICE );
8603 pArray[2] = OUString( SCCELLRANGE_SERVICE );
8604 pArray[3] = OUString( SCCELLPROPERTIES_SERVICE );
8605 pArray[4] = OUString( SCCHARPROPERTIES_SERVICE );
8606 pArray[5] = OUString( SCPARAPROPERTIES_SERVICE );
8607 pArray[6] = OUString( SCLINKTARGET_SERVICE );
8608 return aRet;
8611 // XUnoTunnel
8613 sal_Int64 SAL_CALL ScTableSheetObj::getSomething(
8614 const uno::Sequence<sal_Int8 >& rId ) throw(uno::RuntimeException, std::exception)
8616 if ( rId.getLength() == 16 &&
8617 0 == memcmp( getUnoTunnelId().getConstArray(),
8618 rId.getConstArray(), 16 ) )
8620 return sal::static_int_cast<sal_Int64>(reinterpret_cast<sal_IntPtr>(this));
8623 return ScCellRangeObj::getSomething( rId );
8626 namespace
8628 class theScTableSheetObjUnoTunnelId : public rtl::Static< UnoTunnelIdInit, theScTableSheetObjUnoTunnelId> {};
8631 const uno::Sequence<sal_Int8>& ScTableSheetObj::getUnoTunnelId()
8633 return theScTableSheetObjUnoTunnelId::get().getSeq();
8636 ScTableSheetObj* ScTableSheetObj::getImplementation( const uno::Reference<uno::XInterface> xObj )
8638 ScTableSheetObj* pRet = NULL;
8639 uno::Reference<lang::XUnoTunnel> xUT( xObj, uno::UNO_QUERY );
8640 if (xUT.is())
8641 pRet = reinterpret_cast<ScTableSheetObj*>(sal::static_int_cast<sal_IntPtr>(xUT->getSomething(getUnoTunnelId())));
8642 return pRet;
8645 ScTableColumnObj::ScTableColumnObj( ScDocShell* pDocSh, SCCOL nCol, SCTAB nTab ) :
8646 ScCellRangeObj( pDocSh, ScRange(nCol,0,nTab, nCol,MAXROW,nTab) ),
8647 pColPropSet(lcl_GetColumnPropertySet())
8651 ScTableColumnObj::~ScTableColumnObj()
8655 uno::Any SAL_CALL ScTableColumnObj::queryInterface( const uno::Type& rType ) throw(uno::RuntimeException, std::exception)
8657 SC_QUERYINTERFACE( container::XNamed )
8659 return ScCellRangeObj::queryInterface( rType );
8662 void SAL_CALL ScTableColumnObj::acquire() throw()
8664 ScCellRangeObj::acquire();
8667 void SAL_CALL ScTableColumnObj::release() throw()
8669 ScCellRangeObj::release();
8672 uno::Sequence<uno::Type> SAL_CALL ScTableColumnObj::getTypes() throw(uno::RuntimeException, std::exception)
8674 static uno::Sequence<uno::Type> aTypes;
8675 if ( aTypes.getLength() == 0 )
8677 uno::Sequence<uno::Type> aParentTypes(ScCellRangeObj::getTypes());
8678 long nParentLen = aParentTypes.getLength();
8679 const uno::Type* pParentPtr = aParentTypes.getConstArray();
8681 aTypes.realloc( nParentLen + 1 );
8682 uno::Type* pPtr = aTypes.getArray();
8683 pPtr[nParentLen + 0] = cppu::UnoType<container::XNamed>::get();
8685 for (long i=0; i<nParentLen; i++)
8686 pPtr[i] = pParentPtr[i]; // parent types first
8688 return aTypes;
8691 uno::Sequence<sal_Int8> SAL_CALL ScTableColumnObj::getImplementationId() throw(uno::RuntimeException, std::exception)
8693 return css::uno::Sequence<sal_Int8>();
8696 // XNamed
8698 OUString SAL_CALL ScTableColumnObj::getName() throw(uno::RuntimeException, std::exception)
8700 SolarMutexGuard aGuard;
8702 const ScRange& rRange = GetRange();
8703 OSL_ENSURE(rRange.aStart.Col() == rRange.aEnd.Col(), "too many columns");
8704 SCCOL nCol = rRange.aStart.Col();
8706 return ScColToAlpha( nCol ); // from global.hxx
8709 void SAL_CALL ScTableColumnObj::setName( const OUString& /* aNewName */ )
8710 throw(uno::RuntimeException, std::exception)
8712 SolarMutexGuard aGuard;
8713 throw uno::RuntimeException(); // read-only
8716 // XPropertySet erweitert fuer Spalten-Properties
8718 uno::Reference<beans::XPropertySetInfo> SAL_CALL ScTableColumnObj::getPropertySetInfo()
8719 throw(uno::RuntimeException, std::exception)
8721 SolarMutexGuard aGuard;
8722 static uno::Reference<beans::XPropertySetInfo> aRef(
8723 new SfxItemPropertySetInfo( pColPropSet->getPropertyMap() ));
8724 return aRef;
8727 void ScTableColumnObj::SetOnePropertyValue(const SfxItemPropertySimpleEntry* pEntry, const uno::Any& aValue)
8728 throw(lang::IllegalArgumentException, uno::RuntimeException,
8729 std::exception)
8731 if ( pEntry )
8733 if ( IsScItemWid( pEntry->nWID ) )
8735 // for Item WIDs, call ScCellRangesBase directly
8736 ScCellRangesBase::SetOnePropertyValue(pEntry, aValue);
8737 return;
8740 // own properties
8742 ScDocShell* pDocSh = GetDocShell();
8743 if (!pDocSh)
8744 return; //! Exception oder so?
8745 const ScRange& rRange = GetRange();
8746 OSL_ENSURE(rRange.aStart.Col() == rRange.aEnd.Col(), "zuviele Spalten");
8747 SCCOL nCol = rRange.aStart.Col();
8748 SCTAB nTab = rRange.aStart.Tab();
8749 ScDocFunc &rFunc = pDocSh->GetDocFunc();
8751 std::vector<sc::ColRowSpan> aColArr(1, sc::ColRowSpan(nCol,nCol));
8753 if ( pEntry->nWID == SC_WID_UNO_CELLWID )
8755 sal_Int32 nNewWidth = 0;
8756 if ( aValue >>= nNewWidth )
8758 // property is 1/100mm, column width is twips
8759 nNewWidth = HMMToTwips(nNewWidth);
8760 rFunc.SetWidthOrHeight(
8761 true, aColArr, nTab, SC_SIZE_ORIGINAL, (sal_uInt16)nNewWidth, true, true);
8764 else if ( pEntry->nWID == SC_WID_UNO_CELLVIS )
8766 bool bVis = ScUnoHelpFunctions::GetBoolFromAny( aValue );
8767 ScSizeMode eMode = bVis ? SC_SIZE_SHOW : SC_SIZE_DIRECT;
8768 rFunc.SetWidthOrHeight(true, aColArr, nTab, eMode, 0, true, true);
8769 // SC_SIZE_DIRECT mit Groesse 0 blendet aus
8771 else if ( pEntry->nWID == SC_WID_UNO_OWIDTH )
8773 bool bOpt = ScUnoHelpFunctions::GetBoolFromAny( aValue );
8774 if (bOpt)
8775 rFunc.SetWidthOrHeight(
8776 true, aColArr, nTab, SC_SIZE_OPTIMAL, STD_EXTRA_WIDTH, true, true);
8777 // sal_False bei Spalten momentan ohne Auswirkung
8779 else if ( pEntry->nWID == SC_WID_UNO_NEWPAGE || pEntry->nWID == SC_WID_UNO_MANPAGE )
8781 bool bSet = ScUnoHelpFunctions::GetBoolFromAny( aValue );
8782 if (bSet)
8783 rFunc.InsertPageBreak( true, rRange.aStart, true, true, true );
8784 else
8785 rFunc.RemovePageBreak( true, rRange.aStart, true, true, true );
8787 else
8788 ScCellRangeObj::SetOnePropertyValue(pEntry, aValue); // base class, no Item WID
8792 void ScTableColumnObj::GetOnePropertyValue( const SfxItemPropertySimpleEntry* pEntry, uno::Any& rAny )
8793 throw(uno::RuntimeException, std::exception)
8795 if ( pEntry )
8797 ScDocShell* pDocSh = GetDocShell();
8798 if (!pDocSh)
8799 throw uno::RuntimeException();
8801 ScDocument* pDoc = pDocSh->GetDocument();
8802 const ScRange& rRange = GetRange();
8803 OSL_ENSURE(rRange.aStart.Col() == rRange.aEnd.Col(), "zuviele Spalten");
8804 SCCOL nCol = rRange.aStart.Col();
8805 SCTAB nTab = rRange.aStart.Tab();
8807 if ( pEntry->nWID == SC_WID_UNO_CELLWID )
8809 // for hidden column, return original height
8810 sal_uInt16 nWidth = pDoc->GetOriginalWidth( nCol, nTab );
8811 // property is 1/100mm, column width is twips
8812 nWidth = (sal_uInt16) TwipsToHMM(nWidth);
8813 rAny <<= (sal_Int32)( nWidth );
8815 else if ( pEntry->nWID == SC_WID_UNO_CELLVIS )
8817 bool bHidden = pDoc->ColHidden(nCol, nTab);
8818 ScUnoHelpFunctions::SetBoolInAny( rAny, !bHidden );
8820 else if ( pEntry->nWID == SC_WID_UNO_OWIDTH )
8822 //! momentan immer gesetzt ??!?!
8823 bool bOpt = !(pDoc->GetColFlags( nCol, nTab ) & CR_MANUALSIZE);
8824 ScUnoHelpFunctions::SetBoolInAny( rAny, bOpt );
8826 else if ( pEntry->nWID == SC_WID_UNO_NEWPAGE )
8828 ScBreakType nBreak = pDoc->HasColBreak(nCol, nTab);
8829 ScUnoHelpFunctions::SetBoolInAny( rAny, nBreak );
8831 else if ( pEntry->nWID == SC_WID_UNO_MANPAGE )
8833 ScBreakType nBreak = pDoc->HasColBreak(nCol, nTab);
8834 ScUnoHelpFunctions::SetBoolInAny(rAny, (nBreak & BREAK_MANUAL) != 0);
8836 else
8837 ScCellRangeObj::GetOnePropertyValue(pEntry, rAny);
8841 const SfxItemPropertyMap& ScTableColumnObj::GetItemPropertyMap()
8843 return pColPropSet->getPropertyMap();
8846 ScTableRowObj::ScTableRowObj(ScDocShell* pDocSh, SCROW nRow, SCTAB nTab) :
8847 ScCellRangeObj( pDocSh, ScRange(0,nRow,nTab, MAXCOL,nRow,nTab) ),
8848 pRowPropSet(lcl_GetRowPropertySet())
8852 ScTableRowObj::~ScTableRowObj()
8856 // XPropertySet erweitert fuer Zeilen-Properties
8858 uno::Reference<beans::XPropertySetInfo> SAL_CALL ScTableRowObj::getPropertySetInfo()
8859 throw(uno::RuntimeException, std::exception)
8861 SolarMutexGuard aGuard;
8862 static uno::Reference<beans::XPropertySetInfo> aRef(
8863 new SfxItemPropertySetInfo( pRowPropSet->getPropertyMap() ));
8864 return aRef;
8867 void ScTableRowObj::SetOnePropertyValue( const SfxItemPropertySimpleEntry* pEntry, const uno::Any& aValue )
8868 throw(lang::IllegalArgumentException, uno::RuntimeException, std::exception)
8870 if ( pEntry )
8872 if ( IsScItemWid( pEntry->nWID ) )
8874 // for Item WIDs, call ScCellRangesBase directly
8875 ScCellRangesBase::SetOnePropertyValue(pEntry, aValue);
8876 return;
8879 // own properties
8881 ScDocShell* pDocSh = GetDocShell();
8882 if (!pDocSh)
8883 return; //! Exception oder so?
8884 ScDocument* pDoc = pDocSh->GetDocument();
8885 const ScRange& rRange = GetRange();
8886 OSL_ENSURE(rRange.aStart.Row() == rRange.aEnd.Row(), "zuviele Zeilen");
8887 SCROW nRow = rRange.aStart.Row();
8888 SCTAB nTab = rRange.aStart.Tab();
8889 ScDocFunc &rFunc = pDocSh->GetDocFunc();
8891 std::vector<sc::ColRowSpan> aRowArr(1, sc::ColRowSpan(nRow,nRow));
8893 if ( pEntry->nWID == SC_WID_UNO_CELLHGT )
8895 sal_Int32 nNewHeight = 0;
8896 if ( aValue >>= nNewHeight )
8898 // property is 1/100mm, row height is twips
8899 nNewHeight = HMMToTwips(nNewHeight);
8900 rFunc.SetWidthOrHeight(
8901 false, aRowArr, nTab, SC_SIZE_ORIGINAL, (sal_uInt16)nNewHeight, true, true);
8904 else if ( pEntry->nWID == SC_WID_UNO_CELLVIS )
8906 bool bVis = ScUnoHelpFunctions::GetBoolFromAny( aValue );
8907 ScSizeMode eMode = bVis ? SC_SIZE_SHOW : SC_SIZE_DIRECT;
8908 rFunc.SetWidthOrHeight(false, aRowArr, nTab, eMode, 0, true, true);
8909 // SC_SIZE_DIRECT mit Groesse 0 blendet aus
8911 else if ( pEntry->nWID == SC_WID_UNO_CELLFILT )
8913 bool bFil = ScUnoHelpFunctions::GetBoolFromAny( aValue );
8914 // SC_SIZE_DIRECT mit Groesse 0 blendet aus
8915 pDoc->SetRowFiltered(nRow, nRow, nTab, bFil);
8917 else if ( pEntry->nWID == SC_WID_UNO_OHEIGHT )
8919 bool bOpt = ScUnoHelpFunctions::GetBoolFromAny( aValue );
8920 if (bOpt)
8921 rFunc.SetWidthOrHeight(false, aRowArr, nTab, SC_SIZE_OPTIMAL, 0, true, true);
8922 else
8924 // set current height again manually
8925 sal_uInt16 nHeight = pDoc->GetOriginalHeight( nRow, nTab );
8926 rFunc.SetWidthOrHeight(false, aRowArr, nTab, SC_SIZE_ORIGINAL, nHeight, true, true);
8929 else if ( pEntry->nWID == SC_WID_UNO_NEWPAGE || pEntry->nWID == SC_WID_UNO_MANPAGE )
8931 bool bSet = ScUnoHelpFunctions::GetBoolFromAny( aValue );
8932 if (bSet)
8933 rFunc.InsertPageBreak( false, rRange.aStart, true, true, true );
8934 else
8935 rFunc.RemovePageBreak( false, rRange.aStart, true, true, true );
8937 else
8938 ScCellRangeObj::SetOnePropertyValue(pEntry, aValue); // base class, no Item WID
8942 void ScTableRowObj::GetOnePropertyValue( const SfxItemPropertySimpleEntry* pEntry, uno::Any& rAny )
8943 throw(uno::RuntimeException, std::exception)
8945 if ( pEntry )
8947 ScDocShell* pDocSh = GetDocShell();
8948 if (!pDocSh)
8949 throw uno::RuntimeException();
8950 ScDocument* pDoc = pDocSh->GetDocument();
8951 const ScRange& rRange = GetRange();
8952 OSL_ENSURE(rRange.aStart.Row() == rRange.aEnd.Row(), "zuviele Zeilen");
8953 SCROW nRow = rRange.aStart.Row();
8954 SCTAB nTab = rRange.aStart.Tab();
8956 if ( pEntry->nWID == SC_WID_UNO_CELLHGT )
8958 // for hidden row, return original height
8959 sal_uInt16 nHeight = pDoc->GetOriginalHeight( nRow, nTab );
8960 // property is 1/100mm, row height is twips
8961 nHeight = (sal_uInt16) TwipsToHMM(nHeight);
8962 rAny <<= (sal_Int32)( nHeight );
8964 else if ( pEntry->nWID == SC_WID_UNO_CELLVIS )
8966 bool bHidden = pDoc->RowHidden(nRow, nTab);
8967 ScUnoHelpFunctions::SetBoolInAny( rAny, !bHidden );
8969 else if ( pEntry->nWID == SC_WID_UNO_CELLFILT )
8971 bool bVis = pDoc->RowFiltered(nRow, nTab);
8972 ScUnoHelpFunctions::SetBoolInAny( rAny, bVis );
8974 else if ( pEntry->nWID == SC_WID_UNO_OHEIGHT )
8976 bool bOpt = !(pDoc->GetRowFlags( nRow, nTab ) & CR_MANUALSIZE);
8977 ScUnoHelpFunctions::SetBoolInAny( rAny, bOpt );
8979 else if ( pEntry->nWID == SC_WID_UNO_NEWPAGE )
8981 ScBreakType nBreak = pDoc->HasRowBreak(nRow, nTab);
8982 ScUnoHelpFunctions::SetBoolInAny( rAny, nBreak );
8984 else if ( pEntry->nWID == SC_WID_UNO_MANPAGE )
8986 ScBreakType nBreak = (pDoc->HasRowBreak(nRow, nTab) & BREAK_MANUAL);
8987 ScUnoHelpFunctions::SetBoolInAny( rAny, nBreak );
8989 else
8990 ScCellRangeObj::GetOnePropertyValue(pEntry, rAny);
8994 const SfxItemPropertyMap& ScTableRowObj::GetItemPropertyMap()
8996 return pRowPropSet->getPropertyMap();
8999 ScCellsObj::ScCellsObj(ScDocShell* pDocSh, const ScRangeList& rR) :
9000 pDocShell( pDocSh ),
9001 aRanges( rR )
9003 pDocShell->GetDocument()->AddUnoObject(*this);
9006 ScCellsObj::~ScCellsObj()
9008 if (pDocShell)
9009 pDocShell->GetDocument()->RemoveUnoObject(*this);
9012 void ScCellsObj::Notify( SfxBroadcaster&, const SfxHint& rHint )
9014 if ( rHint.ISA( ScUpdateRefHint ) )
9016 const ScUpdateRefHint& rRef = (const ScUpdateRefHint&)rHint;
9017 aRanges.UpdateReference( rRef.GetMode(), pDocShell->GetDocument(), rRef.GetRange(),
9018 rRef.GetDx(), rRef.GetDy(), rRef.GetDz() );
9020 else if ( rHint.ISA( SfxSimpleHint ) &&
9021 ((const SfxSimpleHint&)rHint).GetId() == SFX_HINT_DYING )
9023 pDocShell = NULL; // ungueltig geworden
9027 // XEnumerationAccess
9029 uno::Reference<container::XEnumeration> SAL_CALL ScCellsObj::createEnumeration()
9030 throw(uno::RuntimeException, std::exception)
9032 SolarMutexGuard aGuard;
9033 if (pDocShell)
9034 return new ScCellsEnumeration( pDocShell, aRanges );
9035 return NULL;
9038 uno::Type SAL_CALL ScCellsObj::getElementType() throw(uno::RuntimeException, std::exception)
9040 SolarMutexGuard aGuard;
9041 return cppu::UnoType<table::XCell>::get();
9044 sal_Bool SAL_CALL ScCellsObj::hasElements() throw(uno::RuntimeException, std::exception)
9046 SolarMutexGuard aGuard;
9047 bool bHas = false;
9048 if ( pDocShell )
9050 //! schneller selber testen?
9052 uno::Reference<container::XEnumeration> xEnum(new ScCellsEnumeration( pDocShell, aRanges ));
9053 bHas = xEnum->hasMoreElements();
9055 return bHas;
9058 ScCellsEnumeration::ScCellsEnumeration(ScDocShell* pDocSh, const ScRangeList& rR) :
9059 pDocShell( pDocSh ),
9060 aRanges( rR ),
9061 pMark( NULL ),
9062 bAtEnd( false )
9064 ScDocument* pDoc = pDocShell->GetDocument();
9065 pDoc->AddUnoObject(*this);
9067 if ( aRanges.empty() )
9068 bAtEnd = true;
9069 else
9071 SCTAB nTab = 0;
9072 const ScRange* pFirst = aRanges[ 0 ];
9073 if (pFirst)
9074 nTab = pFirst->aStart.Tab();
9075 aPos = ScAddress(0,0,nTab);
9076 CheckPos_Impl(); // aPos auf erste passende Zelle setzen
9080 void ScCellsEnumeration::CheckPos_Impl()
9082 if (!pDocShell)
9083 return;
9085 bool bFound = false;
9086 ScDocument* pDoc = pDocShell->GetDocument();
9087 ScRefCellValue aCell;
9088 aCell.assign(*pDoc, aPos);
9089 if (!aCell.isEmpty())
9091 if (!pMark)
9093 pMark = new ScMarkData;
9094 pMark->MarkFromRangeList(aRanges, false);
9095 pMark->MarkToMulti(); // needed for GetNextMarkedCell
9097 bFound = pMark->IsCellMarked(aPos.Col(), aPos.Row());
9099 if (!bFound)
9100 Advance_Impl();
9103 ScCellsEnumeration::~ScCellsEnumeration()
9105 if (pDocShell)
9106 pDocShell->GetDocument()->RemoveUnoObject(*this);
9107 delete pMark;
9110 void ScCellsEnumeration::Advance_Impl()
9112 OSL_ENSURE(!bAtEnd,"zuviel Advance_Impl");
9113 if (!pMark)
9115 pMark = new ScMarkData;
9116 pMark->MarkFromRangeList( aRanges, false );
9117 pMark->MarkToMulti(); // needed for GetNextMarkedCell
9120 SCCOL nCol = aPos.Col();
9121 SCROW nRow = aPos.Row();
9122 SCTAB nTab = aPos.Tab();
9123 bool bFound = pDocShell->GetDocument()->GetNextMarkedCell( nCol, nRow, nTab, *pMark );
9124 if (bFound)
9125 aPos.Set( nCol, nRow, nTab );
9126 else
9127 bAtEnd = true; // kommt nix mehr
9130 void ScCellsEnumeration::Notify( SfxBroadcaster&, const SfxHint& rHint )
9132 if ( rHint.ISA( ScUpdateRefHint ) )
9134 if (pDocShell)
9136 const ScUpdateRefHint& rRef = (const ScUpdateRefHint&)rHint;
9137 aRanges.UpdateReference( rRef.GetMode(), pDocShell->GetDocument(), rRef.GetRange(),
9138 rRef.GetDx(), rRef.GetDy(), rRef.GetDz() );
9140 delete pMark; // aus verschobenen Bereichen neu erzeugen
9141 pMark = NULL;
9143 if (!bAtEnd) // aPos anpassen
9145 ScRangeList aNew;
9146 aNew.Append(ScRange(aPos));
9147 aNew.UpdateReference( rRef.GetMode(), pDocShell->GetDocument(), rRef.GetRange(),
9148 rRef.GetDx(), rRef.GetDy(), rRef.GetDz() );
9149 if (aNew.size()==1)
9151 aPos = aNew[ 0 ]->aStart;
9152 CheckPos_Impl();
9157 else if ( rHint.ISA( SfxSimpleHint ) &&
9158 ((const SfxSimpleHint&)rHint).GetId() == SFX_HINT_DYING )
9160 pDocShell = NULL; // ungueltig geworden
9164 // XEnumeration
9166 sal_Bool SAL_CALL ScCellsEnumeration::hasMoreElements() throw(uno::RuntimeException, std::exception)
9168 SolarMutexGuard aGuard;
9169 return !bAtEnd;
9172 uno::Any SAL_CALL ScCellsEnumeration::nextElement() throw(container::NoSuchElementException,
9173 lang::WrappedTargetException, uno::RuntimeException, std::exception)
9175 SolarMutexGuard aGuard;
9176 if (pDocShell && !bAtEnd)
9178 // Interface-Typ muss zu ScCellsObj::getElementType passen
9180 ScAddress aTempPos(aPos);
9181 Advance_Impl();
9182 return uno::makeAny(uno::Reference<table::XCell>(new ScCellObj( pDocShell, aTempPos )));
9185 throw container::NoSuchElementException(); // no more elements
9188 ScCellFormatsObj::ScCellFormatsObj(ScDocShell* pDocSh, const ScRange& rRange) :
9189 pDocShell( pDocSh ),
9190 aTotalRange( rRange )
9192 ScDocument* pDoc = pDocShell->GetDocument();
9193 pDoc->AddUnoObject(*this);
9195 OSL_ENSURE( aTotalRange.aStart.Tab() == aTotalRange.aEnd.Tab(), "unterschiedliche Tabellen" );
9198 ScCellFormatsObj::~ScCellFormatsObj()
9200 if (pDocShell)
9201 pDocShell->GetDocument()->RemoveUnoObject(*this);
9204 void ScCellFormatsObj::Notify( SfxBroadcaster&, const SfxHint& rHint )
9206 if ( rHint.ISA( ScUpdateRefHint ) )
9208 //! aTotalRange...
9210 else if ( rHint.ISA( SfxSimpleHint ) &&
9211 ((const SfxSimpleHint&)rHint).GetId() == SFX_HINT_DYING )
9213 pDocShell = NULL; // ungueltig geworden
9217 ScCellRangeObj* ScCellFormatsObj::GetObjectByIndex_Impl(long nIndex) const
9219 //! direkt auf die AttrArrays zugreifen !!!!
9221 ScCellRangeObj* pRet = NULL;
9222 if (pDocShell)
9224 ScDocument* pDoc = pDocShell->GetDocument();
9225 long nPos = 0;
9226 ScAttrRectIterator aIter( pDoc, aTotalRange.aStart.Tab(),
9227 aTotalRange.aStart.Col(), aTotalRange.aStart.Row(),
9228 aTotalRange.aEnd.Col(), aTotalRange.aEnd.Row() );
9229 SCCOL nCol1, nCol2;
9230 SCROW nRow1, nRow2;
9231 while ( aIter.GetNext( nCol1, nCol2, nRow1, nRow2 ) )
9233 if ( nPos == nIndex )
9235 SCTAB nTab = aTotalRange.aStart.Tab();
9236 ScRange aNext( nCol1, nRow1, nTab, nCol2, nRow2, nTab );
9238 if ( aNext.aStart == aNext.aEnd )
9239 pRet = new ScCellObj( pDocShell, aNext.aStart );
9240 else
9241 pRet = new ScCellRangeObj( pDocShell, aNext );
9243 ++nPos;
9246 return pRet;
9249 // XIndexAccess
9251 sal_Int32 SAL_CALL ScCellFormatsObj::getCount() throw(uno::RuntimeException, std::exception)
9253 SolarMutexGuard aGuard;
9255 //! direkt auf die AttrArrays zugreifen !!!!
9257 long nCount = 0;
9258 if (pDocShell)
9260 ScDocument* pDoc = pDocShell->GetDocument();
9261 ScAttrRectIterator aIter( pDoc, aTotalRange.aStart.Tab(),
9262 aTotalRange.aStart.Col(), aTotalRange.aStart.Row(),
9263 aTotalRange.aEnd.Col(), aTotalRange.aEnd.Row() );
9264 SCCOL nCol1, nCol2;
9265 SCROW nRow1, nRow2;
9266 while ( aIter.GetNext( nCol1, nCol2, nRow1, nRow2 ) )
9267 ++nCount;
9269 return nCount;
9272 uno::Any SAL_CALL ScCellFormatsObj::getByIndex( sal_Int32 nIndex )
9273 throw(lang::IndexOutOfBoundsException,
9274 lang::WrappedTargetException, uno::RuntimeException, std::exception)
9276 SolarMutexGuard aGuard;
9278 uno::Reference<table::XCellRange> xRange(GetObjectByIndex_Impl(nIndex));
9279 if (xRange.is())
9280 return uno::makeAny(xRange);
9281 else
9282 throw lang::IndexOutOfBoundsException();
9285 uno::Type SAL_CALL ScCellFormatsObj::getElementType() throw(uno::RuntimeException, std::exception)
9287 SolarMutexGuard aGuard;
9288 return cppu::UnoType<table::XCellRange>::get();
9291 sal_Bool SAL_CALL ScCellFormatsObj::hasElements() throw(uno::RuntimeException, std::exception)
9293 SolarMutexGuard aGuard;
9294 return ( getCount() != 0 ); //! immer groesser 0 ??
9297 // XEnumerationAccess
9299 uno::Reference<container::XEnumeration> SAL_CALL ScCellFormatsObj::createEnumeration()
9300 throw(uno::RuntimeException, std::exception)
9302 SolarMutexGuard aGuard;
9303 if (pDocShell)
9304 return new ScCellFormatsEnumeration( pDocShell, aTotalRange );
9305 return NULL;
9308 ScCellFormatsEnumeration::ScCellFormatsEnumeration(ScDocShell* pDocSh, const ScRange& rRange) :
9309 pDocShell( pDocSh ),
9310 nTab( rRange.aStart.Tab() ),
9311 pIter( NULL ),
9312 bAtEnd( false ),
9313 bDirty( false )
9315 ScDocument* pDoc = pDocShell->GetDocument();
9316 pDoc->AddUnoObject(*this);
9318 OSL_ENSURE( rRange.aStart.Tab() == rRange.aEnd.Tab(),
9319 "CellFormatsEnumeration: unterschiedliche Tabellen" );
9321 pIter = new ScAttrRectIterator( pDoc, nTab,
9322 rRange.aStart.Col(), rRange.aStart.Row(),
9323 rRange.aEnd.Col(), rRange.aEnd.Row() );
9324 Advance_Impl();
9327 ScCellFormatsEnumeration::~ScCellFormatsEnumeration()
9329 if (pDocShell)
9330 pDocShell->GetDocument()->RemoveUnoObject(*this);
9331 delete pIter;
9334 void ScCellFormatsEnumeration::Advance_Impl()
9336 OSL_ENSURE(!bAtEnd,"zuviel Advance_Impl");
9338 if ( pIter )
9340 if ( bDirty )
9342 pIter->DataChanged(); // AttrArray-Index neu suchen
9343 bDirty = false;
9346 SCCOL nCol1, nCol2;
9347 SCROW nRow1, nRow2;
9348 if ( pIter->GetNext( nCol1, nCol2, nRow1, nRow2 ) )
9349 aNext = ScRange( nCol1, nRow1, nTab, nCol2, nRow2, nTab );
9350 else
9351 bAtEnd = true; // kommt nix mehr
9353 else
9354 bAtEnd = true; // Dok weggekommen oder so
9357 ScCellRangeObj* ScCellFormatsEnumeration::NextObject_Impl()
9359 ScCellRangeObj* pRet = NULL;
9360 if (pDocShell && !bAtEnd)
9362 if ( aNext.aStart == aNext.aEnd )
9363 pRet = new ScCellObj( pDocShell, aNext.aStart );
9364 else
9365 pRet = new ScCellRangeObj( pDocShell, aNext );
9366 Advance_Impl();
9368 return pRet;
9371 void ScCellFormatsEnumeration::Notify( SfxBroadcaster&, const SfxHint& rHint )
9373 if ( rHint.ISA( ScUpdateRefHint ) )
9375 //! und nun ???
9377 else if ( rHint.ISA( SfxSimpleHint ) )
9379 sal_uLong nId = ((const SfxSimpleHint&)rHint).GetId();
9380 if ( nId == SFX_HINT_DYING )
9382 pDocShell = NULL; // ungueltig geworden
9383 delete pIter;
9384 pIter = NULL;
9386 else if ( nId == SFX_HINT_DATACHANGED )
9388 bDirty = true; // AttrArray-Index evtl. ungueltig geworden
9393 // XEnumeration
9395 sal_Bool SAL_CALL ScCellFormatsEnumeration::hasMoreElements() throw(uno::RuntimeException, std::exception)
9397 SolarMutexGuard aGuard;
9398 return !bAtEnd;
9401 uno::Any SAL_CALL ScCellFormatsEnumeration::nextElement() throw(container::NoSuchElementException,
9402 lang::WrappedTargetException, uno::RuntimeException, std::exception)
9404 SolarMutexGuard aGuard;
9406 if ( bAtEnd || !pDocShell )
9407 throw container::NoSuchElementException(); // no more elements
9409 // Interface-Typ muss zu ScCellFormatsObj::getElementType passen
9411 return uno::makeAny(uno::Reference<table::XCellRange> (NextObject_Impl()));
9414 ScUniqueCellFormatsObj::ScUniqueCellFormatsObj(ScDocShell* pDocSh, const ScRange& rRange) :
9415 pDocShell( pDocSh ),
9416 aTotalRange( rRange ),
9417 aRangeLists()
9419 pDocShell->GetDocument()->AddUnoObject(*this);
9421 OSL_ENSURE( aTotalRange.aStart.Tab() == aTotalRange.aEnd.Tab(), "unterschiedliche Tabellen" );
9423 GetObjects_Impl();
9426 ScUniqueCellFormatsObj::~ScUniqueCellFormatsObj()
9428 if (pDocShell)
9429 pDocShell->GetDocument()->RemoveUnoObject(*this);
9432 void ScUniqueCellFormatsObj::Notify( SfxBroadcaster&, const SfxHint& rHint )
9434 if ( rHint.ISA( ScUpdateRefHint ) )
9436 //! aTotalRange...
9438 else if ( rHint.ISA( SfxSimpleHint ) )
9440 sal_uLong nId = ((const SfxSimpleHint&)rHint).GetId();
9441 if ( nId == SFX_HINT_DYING )
9442 pDocShell = NULL; // ungueltig geworden
9447 // Fill the list of formats from the document
9450 // hash code to access the range lists by ScPatternAttr pointer
9451 struct ScPatternHashCode
9453 size_t operator()( const ScPatternAttr* pPattern ) const
9455 return reinterpret_cast<size_t>(pPattern);
9459 // Hash map to find a range by its start row
9460 typedef ::boost::unordered_map< SCROW, ScRange > ScRowRangeHashMap;
9462 typedef ::std::vector<ScRange> ScRangeVector;
9464 // Hash map entry.
9465 // The Join method depends on the column-wise order of ScAttrRectIterator
9466 class ScUniqueFormatsEntry
9468 enum EntryState { STATE_EMPTY, STATE_SINGLE, STATE_COMPLEX };
9470 EntryState eState;
9471 ScRange aSingleRange;
9472 ScRowRangeHashMap aJoinedRanges; // "active" ranges to be merged
9473 ScRangeVector aCompletedRanges; // ranges that will no longer be touched
9474 ScRangeListRef aReturnRanges; // result as ScRangeList for further use
9476 public:
9477 ScUniqueFormatsEntry() : eState( STATE_EMPTY ) {}
9478 ~ScUniqueFormatsEntry() {}
9480 void Join( const ScRange& rNewRange );
9481 const ScRangeList& GetRanges();
9482 void Clear() { aReturnRanges.Clear(); } // aJoinedRanges and aCompletedRanges are cleared in GetRanges
9485 void ScUniqueFormatsEntry::Join( const ScRange& rNewRange )
9487 // Special-case handling for single range
9489 if ( eState == STATE_EMPTY )
9491 aSingleRange = rNewRange;
9492 eState = STATE_SINGLE;
9493 return;
9495 if ( eState == STATE_SINGLE )
9497 if ( aSingleRange.aStart.Row() == rNewRange.aStart.Row() &&
9498 aSingleRange.aEnd.Row() == rNewRange.aEnd.Row() &&
9499 aSingleRange.aEnd.Col() + 1 == rNewRange.aStart.Col() )
9501 aSingleRange.aEnd.SetCol( rNewRange.aEnd.Col() );
9502 return; // still a single range
9505 SCROW nSingleRow = aSingleRange.aStart.Row();
9506 aJoinedRanges.insert( ScRowRangeHashMap::value_type( nSingleRow, aSingleRange ) );
9507 eState = STATE_COMPLEX;
9508 // continue normally
9511 // This is called in the order of ScAttrRectIterator results.
9512 // rNewRange can only be joined with an existing entry if it's the same rows, starting in the next column.
9513 // If the old entry for the start row extends to a different end row, or ends in a different column, it
9514 // can be moved to aCompletedRanges because it can't be joined with following iterator results.
9515 // Everything happens within one sheet, so Tab can be ignored.
9517 SCROW nStartRow = rNewRange.aStart.Row();
9518 ScRowRangeHashMap::iterator aIter( aJoinedRanges.find( nStartRow ) ); // find the active entry for the start row
9519 if ( aIter != aJoinedRanges.end() )
9521 ScRange& rOldRange = aIter->second;
9522 if ( rOldRange.aEnd.Row() == rNewRange.aEnd.Row() &&
9523 rOldRange.aEnd.Col() + 1 == rNewRange.aStart.Col() )
9525 // extend existing range
9526 rOldRange.aEnd.SetCol( rNewRange.aEnd.Col() );
9528 else
9530 // move old range to aCompletedRanges, keep rNewRange for joining
9531 aCompletedRanges.push_back( rOldRange );
9532 rOldRange = rNewRange; // replace in hash map
9535 else
9537 // keep rNewRange for joining
9538 aJoinedRanges.insert( ScRowRangeHashMap::value_type( nStartRow, rNewRange ) );
9542 const ScRangeList& ScUniqueFormatsEntry::GetRanges()
9544 if ( eState == STATE_SINGLE )
9546 aReturnRanges = new ScRangeList;
9547 aReturnRanges->Append( aSingleRange );
9548 return *aReturnRanges;
9551 // move remaining entries from aJoinedRanges to aCompletedRanges
9553 ScRowRangeHashMap::const_iterator aJoinedEnd = aJoinedRanges.end();
9554 for ( ScRowRangeHashMap::const_iterator aJoinedIter = aJoinedRanges.begin(); aJoinedIter != aJoinedEnd; ++aJoinedIter )
9555 aCompletedRanges.push_back( aJoinedIter->second );
9556 aJoinedRanges.clear();
9558 // sort all ranges for a predictable API result
9560 std::sort( aCompletedRanges.begin(), aCompletedRanges.end() );
9562 // fill and return ScRangeList
9564 aReturnRanges = new ScRangeList;
9565 ScRangeVector::const_iterator aCompEnd( aCompletedRanges.end() );
9566 for ( ScRangeVector::const_iterator aCompIter( aCompletedRanges.begin() ); aCompIter != aCompEnd; ++aCompIter )
9567 aReturnRanges->Append( *aCompIter );
9568 aCompletedRanges.clear();
9570 return *aReturnRanges;
9573 typedef ::boost::unordered_map< const ScPatternAttr*, ScUniqueFormatsEntry, ScPatternHashCode > ScUniqueFormatsHashMap;
9575 // function object to sort the range lists by start of first range
9576 struct ScUniqueFormatsOrder
9578 bool operator()( const ScRangeList& rList1, const ScRangeList& rList2 ) const
9580 // all range lists have at least one entry
9581 OSL_ENSURE( rList1.size() > 0 && rList2.size() > 0, "ScUniqueFormatsOrder: empty list" );
9583 // compare start positions using ScAddress comparison operator
9584 return ( rList1[ 0 ]->aStart < rList2[ 0 ]->aStart );
9588 void ScUniqueCellFormatsObj::GetObjects_Impl()
9590 if (pDocShell)
9592 ScDocument* pDoc = pDocShell->GetDocument();
9593 SCTAB nTab = aTotalRange.aStart.Tab();
9594 ScAttrRectIterator aIter( pDoc, nTab,
9595 aTotalRange.aStart.Col(), aTotalRange.aStart.Row(),
9596 aTotalRange.aEnd.Col(), aTotalRange.aEnd.Row() );
9597 SCCOL nCol1, nCol2;
9598 SCROW nRow1, nRow2;
9600 // Collect the ranges for each format in a hash map, to avoid nested loops
9602 ScUniqueFormatsHashMap aHashMap;
9603 while (aIter.GetNext( nCol1, nCol2, nRow1, nRow2 ) )
9605 ScRange aRange( nCol1, nRow1, nTab, nCol2, nRow2, nTab );
9606 const ScPatternAttr* pPattern = pDoc->GetPattern(nCol1, nRow1, nTab);
9607 aHashMap[pPattern].Join( aRange );
9610 // Fill the vector aRangeLists with the range lists from the hash map
9612 aRangeLists.reserve( aHashMap.size() );
9613 ScUniqueFormatsHashMap::iterator aMapIter( aHashMap.begin() );
9614 ScUniqueFormatsHashMap::iterator aMapEnd( aHashMap.end() );
9615 while ( aMapIter != aMapEnd )
9617 ScUniqueFormatsEntry& rEntry = aMapIter->second;
9618 const ScRangeList& rRanges = rEntry.GetRanges();
9619 aRangeLists.push_back( rRanges ); // copy ScRangeList
9620 rEntry.Clear(); // free memory, don't hold both copies of all ranges
9621 ++aMapIter;
9624 // Sort the vector by first range's start position, to avoid random shuffling
9625 // due to using the ScPatterAttr pointers
9627 ScUniqueFormatsOrder aComp;
9628 ::std::sort( aRangeLists.begin(), aRangeLists.end(), aComp );
9632 // XIndexAccess
9634 sal_Int32 SAL_CALL ScUniqueCellFormatsObj::getCount() throw(uno::RuntimeException, std::exception)
9636 SolarMutexGuard aGuard;
9638 return aRangeLists.size();
9641 uno::Any SAL_CALL ScUniqueCellFormatsObj::getByIndex( sal_Int32 nIndex )
9642 throw(lang::IndexOutOfBoundsException,
9643 lang::WrappedTargetException, uno::RuntimeException, std::exception)
9645 SolarMutexGuard aGuard;
9647 if(static_cast<sal_uInt32>(nIndex) < aRangeLists.size())
9648 return uno::makeAny(uno::Reference<sheet::XSheetCellRangeContainer>(new ScCellRangesObj(pDocShell, aRangeLists[nIndex])));
9649 else
9650 throw lang::IndexOutOfBoundsException();
9653 uno::Type SAL_CALL ScUniqueCellFormatsObj::getElementType() throw(uno::RuntimeException, std::exception)
9655 SolarMutexGuard aGuard;
9656 return cppu::UnoType<sheet::XSheetCellRangeContainer>::get();
9659 sal_Bool SAL_CALL ScUniqueCellFormatsObj::hasElements() throw(uno::RuntimeException, std::exception)
9661 SolarMutexGuard aGuard;
9662 return ( aRangeLists.size() != 0 );
9665 // XEnumerationAccess
9667 uno::Reference<container::XEnumeration> SAL_CALL ScUniqueCellFormatsObj::createEnumeration()
9668 throw(uno::RuntimeException, std::exception)
9670 SolarMutexGuard aGuard;
9671 if (pDocShell)
9672 return new ScUniqueCellFormatsEnumeration( pDocShell, aRangeLists );
9673 return NULL;
9676 ScUniqueCellFormatsEnumeration::ScUniqueCellFormatsEnumeration(ScDocShell* pDocSh, const ScMyRangeLists& rRangeLists) :
9677 aRangeLists(rRangeLists),
9678 pDocShell( pDocSh ),
9679 nCurrentPosition(0)
9681 pDocShell->GetDocument()->AddUnoObject(*this);
9684 ScUniqueCellFormatsEnumeration::~ScUniqueCellFormatsEnumeration()
9686 if (pDocShell)
9687 pDocShell->GetDocument()->RemoveUnoObject(*this);
9690 void ScUniqueCellFormatsEnumeration::Notify( SfxBroadcaster&, const SfxHint& rHint )
9692 if ( rHint.ISA( ScUpdateRefHint ) )
9694 //! und nun ???
9696 else if ( rHint.ISA( SfxSimpleHint ) )
9698 sal_uLong nId = ((const SfxSimpleHint&)rHint).GetId();
9699 if ( nId == SFX_HINT_DYING )
9700 pDocShell = NULL; // ungueltig geworden
9704 // XEnumeration
9706 sal_Bool SAL_CALL ScUniqueCellFormatsEnumeration::hasMoreElements() throw(uno::RuntimeException, std::exception)
9708 SolarMutexGuard aGuard;
9709 return static_cast<sal_uInt32>(nCurrentPosition) < aRangeLists.size();
9712 uno::Any SAL_CALL ScUniqueCellFormatsEnumeration::nextElement() throw(container::NoSuchElementException,
9713 lang::WrappedTargetException, uno::RuntimeException, std::exception)
9715 SolarMutexGuard aGuard;
9717 if ( !hasMoreElements() || !pDocShell )
9718 throw container::NoSuchElementException(); // no more elements
9720 // Interface-Typ muss zu ScCellFormatsObj::getElementType passen
9722 return uno::makeAny(uno::Reference<sheet::XSheetCellRangeContainer>(new ScCellRangesObj(pDocShell, aRangeLists[nCurrentPosition++])));
9725 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */