Version 4.3.0.0.beta1, tag libreoffice-4.3.0.0.beta1
[LibreOffice.git] / sc / source / ui / unoobj / cellsuno.cxx
blobdd3a0e25e0e3914985efe3877714f0e664f041ed
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"
129 #include <list>
130 #include <boost/scoped_array.hpp>
131 #include <boost/scoped_ptr.hpp>
133 using namespace com::sun::star;
135 class ScNamedEntry
137 OUString aName;
138 ScRange aRange;
140 public:
141 ScNamedEntry(const OUString& rN, const ScRange& rR) :
142 aName(rN), aRange(rR) {}
144 const OUString& GetName() const { return aName; }
145 const ScRange& GetRange() const { return aRange; }
148 // The names in the maps must be sorted according to strcmp!
149 //! Instead of Which-ID 0 use special IDs and do not compare via names!
151 // Left/Right/Top/BottomBorder are mapped directly to the core items,
152 // not collected/applied to the borders of a range -> ATTR_BORDER can be used directly
154 static const SfxItemPropertySet* lcl_GetCellsPropertySet()
156 static const SfxItemPropertyMapEntry aCellsPropertyMap_Impl[] =
158 {OUString(SC_UNONAME_ABSNAME), SC_WID_UNO_ABSNAME, cppu::UnoType<OUString>::get(), 0 | beans::PropertyAttribute::READONLY, 0 },
159 {OUString(SC_UNONAME_ASIANVERT),ATTR_VERTICAL_ASIAN,getBooleanCppuType(), 0, 0 },
160 {OUString(SC_UNONAME_BOTTBORDER),ATTR_BORDER, ::cppu::UnoType<table::BorderLine>::get(), 0, BOTTOM_BORDER | CONVERT_TWIPS },
161 {OUString(SC_UNONAME_BOTTBORDER2),ATTR_BORDER, ::cppu::UnoType<table::BorderLine2>::get(), 0, BOTTOM_BORDER | CONVERT_TWIPS },
162 {OUString(SC_UNONAME_CELLBACK), ATTR_BACKGROUND, cppu::UnoType<sal_Int32>::get(), 0, MID_BACK_COLOR },
163 {OUString(SC_UNONAME_CELLPRO), ATTR_PROTECTION, cppu::UnoType<util::CellProtection>::get(), 0, 0 },
164 {OUString(SC_UNONAME_CELLSTYL), SC_WID_UNO_CELLSTYL,cppu::UnoType<OUString>::get(), 0, 0 },
165 {OUString(SC_UNONAME_CCOLOR), ATTR_FONT_COLOR, cppu::UnoType<sal_Int32>::get(), 0, 0 },
166 {OUString(SC_UNONAME_COUTL), ATTR_FONT_CONTOUR, getBooleanCppuType(), 0, 0 },
167 {OUString(SC_UNONAME_CCROSS), ATTR_FONT_CROSSEDOUT,getBooleanCppuType(), 0, MID_CROSSED_OUT },
168 {OUString(SC_UNONAME_CEMPHAS), ATTR_FONT_EMPHASISMARK,cppu::UnoType<sal_Int16>::get(), 0, MID_EMPHASIS },
169 {OUString(SC_UNONAME_CFONT), ATTR_FONT, cppu::UnoType<sal_Int16>::get(), 0, MID_FONT_FAMILY },
170 {OUString(SC_UNONAME_CFCHARS), ATTR_FONT, cppu::UnoType<sal_Int16>::get(), 0, MID_FONT_CHAR_SET },
171 {OUString(SC_UNO_CJK_CFCHARS), ATTR_CJK_FONT, cppu::UnoType<sal_Int16>::get(), 0, MID_FONT_CHAR_SET },
172 {OUString(SC_UNO_CTL_CFCHARS), ATTR_CTL_FONT, cppu::UnoType<sal_Int16>::get(), 0, MID_FONT_CHAR_SET },
173 {OUString(SC_UNONAME_CFFAMIL), ATTR_FONT, cppu::UnoType<sal_Int16>::get(), 0, MID_FONT_FAMILY },
174 {OUString(SC_UNO_CJK_CFFAMIL), ATTR_CJK_FONT, cppu::UnoType<sal_Int16>::get(), 0, MID_FONT_FAMILY },
175 {OUString(SC_UNO_CTL_CFFAMIL), ATTR_CTL_FONT, cppu::UnoType<sal_Int16>::get(), 0, MID_FONT_FAMILY },
176 {OUString(SC_UNONAME_CFNAME), ATTR_FONT, cppu::UnoType<OUString>::get(), 0, MID_FONT_FAMILY_NAME },
177 {OUString(SC_UNO_CJK_CFNAME), ATTR_CJK_FONT, cppu::UnoType<OUString>::get(), 0, MID_FONT_FAMILY_NAME },
178 {OUString(SC_UNO_CTL_CFNAME), ATTR_CTL_FONT, cppu::UnoType<OUString>::get(), 0, MID_FONT_FAMILY_NAME },
179 {OUString(SC_UNONAME_CFPITCH), ATTR_FONT, cppu::UnoType<sal_Int16>::get(), 0, MID_FONT_PITCH },
180 {OUString(SC_UNO_CJK_CFPITCH), ATTR_CJK_FONT, cppu::UnoType<sal_Int16>::get(), 0, MID_FONT_PITCH },
181 {OUString(SC_UNO_CTL_CFPITCH), ATTR_CTL_FONT, cppu::UnoType<sal_Int16>::get(), 0, MID_FONT_PITCH },
182 {OUString(SC_UNONAME_CFSTYLE), ATTR_FONT, cppu::UnoType<OUString>::get(), 0, MID_FONT_STYLE_NAME },
183 {OUString(SC_UNO_CJK_CFSTYLE), ATTR_CJK_FONT, cppu::UnoType<OUString>::get(), 0, MID_FONT_STYLE_NAME },
184 {OUString(SC_UNO_CTL_CFSTYLE), ATTR_CTL_FONT, cppu::UnoType<OUString>::get(), 0, MID_FONT_STYLE_NAME },
185 {OUString(SC_UNONAME_CHEIGHT), ATTR_FONT_HEIGHT, cppu::UnoType<float>::get(), 0, MID_FONTHEIGHT | CONVERT_TWIPS },
186 {OUString(SC_UNO_CJK_CHEIGHT), ATTR_CJK_FONT_HEIGHT,cppu::UnoType<float>::get(), 0, MID_FONTHEIGHT | CONVERT_TWIPS },
187 {OUString(SC_UNO_CTL_CHEIGHT), ATTR_CTL_FONT_HEIGHT,cppu::UnoType<float>::get(), 0, MID_FONTHEIGHT | CONVERT_TWIPS },
188 {OUString(SC_UNONAME_CLOCAL), ATTR_FONT_LANGUAGE, cppu::UnoType<lang::Locale>::get(), 0, MID_LANG_LOCALE },
189 {OUString(SC_UNO_CJK_CLOCAL), ATTR_CJK_FONT_LANGUAGE,cppu::UnoType<lang::Locale>::get(), 0, MID_LANG_LOCALE },
190 {OUString(SC_UNO_CTL_CLOCAL), ATTR_CTL_FONT_LANGUAGE,cppu::UnoType<lang::Locale>::get(), 0, MID_LANG_LOCALE },
191 {OUString(SC_UNONAME_COVER), ATTR_FONT_OVERLINE, cppu::UnoType<sal_Int16>::get(), 0, MID_TL_STYLE },
192 {OUString(SC_UNONAME_COVRLCOL), ATTR_FONT_OVERLINE, cppu::UnoType<sal_Int32>::get(), 0, MID_TL_COLOR },
193 {OUString(SC_UNONAME_COVRLHAS), ATTR_FONT_OVERLINE, getBooleanCppuType(), 0, MID_TL_HASCOLOR },
194 {OUString(SC_UNONAME_CPOST), ATTR_FONT_POSTURE, cppu::UnoType<awt::FontSlant>::get(), 0, MID_POSTURE },
195 {OUString(SC_UNO_CJK_CPOST), ATTR_CJK_FONT_POSTURE,cppu::UnoType<awt::FontSlant>::get(), 0, MID_POSTURE },
196 {OUString(SC_UNO_CTL_CPOST), ATTR_CTL_FONT_POSTURE,cppu::UnoType<awt::FontSlant>::get(), 0, MID_POSTURE },
197 {OUString(SC_UNONAME_CRELIEF), ATTR_FONT_RELIEF, cppu::UnoType<sal_Int16>::get(), 0, MID_RELIEF },
198 {OUString(SC_UNONAME_CSHADD), ATTR_FONT_SHADOWED, getBooleanCppuType(), 0, 0 },
199 {OUString(SC_UNONAME_CSTRIKE), ATTR_FONT_CROSSEDOUT,cppu::UnoType<sal_Int16>::get(), 0, MID_CROSS_OUT },
200 {OUString(SC_UNONAME_CUNDER), ATTR_FONT_UNDERLINE,cppu::UnoType<sal_Int16>::get(), 0, MID_TL_STYLE },
201 {OUString(SC_UNONAME_CUNDLCOL), ATTR_FONT_UNDERLINE,cppu::UnoType<sal_Int32>::get(), 0, MID_TL_COLOR },
202 {OUString(SC_UNONAME_CUNDLHAS), ATTR_FONT_UNDERLINE,getBooleanCppuType(), 0, MID_TL_HASCOLOR },
203 {OUString(SC_UNONAME_CWEIGHT), ATTR_FONT_WEIGHT, cppu::UnoType<float>::get(), 0, MID_WEIGHT },
204 {OUString(SC_UNO_CJK_CWEIGHT), ATTR_CJK_FONT_WEIGHT,cppu::UnoType<float>::get(), 0, MID_WEIGHT },
205 {OUString(SC_UNO_CTL_CWEIGHT), ATTR_CTL_FONT_WEIGHT,cppu::UnoType<float>::get(), 0, MID_WEIGHT },
206 {OUString(SC_UNONAME_CWORDMOD), ATTR_FONT_WORDLINE, getBooleanCppuType(), 0, 0 },
207 {OUString(SC_UNONAME_CHCOLHDR), SC_WID_UNO_CHCOLHDR,getBooleanCppuType(), 0, 0 },
208 {OUString(SC_UNONAME_CHROWHDR), SC_WID_UNO_CHROWHDR,getBooleanCppuType(), 0, 0 },
209 {OUString(SC_UNONAME_CONDFMT), SC_WID_UNO_CONDFMT, cppu::UnoType<sheet::XSheetConditionalEntries>::get(), 0, 0 },
210 {OUString(SC_UNONAME_CONDLOC), SC_WID_UNO_CONDLOC, cppu::UnoType<sheet::XSheetConditionalEntries>::get(), 0, 0 },
211 {OUString(SC_UNONAME_CONDXML), SC_WID_UNO_CONDXML, cppu::UnoType<sheet::XSheetConditionalEntries>::get(), 0, 0 },
212 {OUString(SC_UNONAME_DIAGONAL_BLTR), ATTR_BORDER_BLTR, ::cppu::UnoType<table::BorderLine>::get(), 0, 0 | CONVERT_TWIPS },
213 {OUString(SC_UNONAME_DIAGONAL_BLTR2), ATTR_BORDER_BLTR, ::cppu::UnoType<table::BorderLine2>::get(), 0, 0 | CONVERT_TWIPS },
214 {OUString(SC_UNONAME_DIAGONAL_TLBR), ATTR_BORDER_TLBR, ::cppu::UnoType<table::BorderLine>::get(), 0, 0 | CONVERT_TWIPS },
215 {OUString(SC_UNONAME_DIAGONAL_TLBR2), ATTR_BORDER_TLBR, ::cppu::UnoType<table::BorderLine2>::get(), 0, 0 | CONVERT_TWIPS },
216 {OUString(SC_UNONAME_CELLHJUS), ATTR_HOR_JUSTIFY, cppu::UnoType<table::CellHoriJustify>::get(), 0, MID_HORJUST_HORJUST },
217 {OUString(SC_UNONAME_CELLHJUS_METHOD), ATTR_HOR_JUSTIFY_METHOD, ::cppu::UnoType<sal_Int32>::get(), 0, 0 },
218 {OUString(SC_UNONAME_CELLTRAN), ATTR_BACKGROUND, getBooleanCppuType(), 0, MID_GRAPHIC_TRANSPARENT },
219 {OUString(SC_UNONAME_WRAP), ATTR_LINEBREAK, getBooleanCppuType(), 0, 0 },
220 {OUString(SC_UNONAME_LEFTBORDER),ATTR_BORDER, ::cppu::UnoType<table::BorderLine>::get(), 0, LEFT_BORDER | CONVERT_TWIPS },
221 {OUString(SC_UNONAME_LEFTBORDER2),ATTR_BORDER, ::cppu::UnoType<table::BorderLine2>::get(), 0, LEFT_BORDER | CONVERT_TWIPS },
222 {OUString(SC_UNONAME_NUMFMT), ATTR_VALUE_FORMAT, cppu::UnoType<sal_Int32>::get(), 0, 0 },
223 {OUString(SC_UNONAME_NUMRULES), SC_WID_UNO_NUMRULES,cppu::UnoType<container::XIndexReplace>::get(), 0, 0 },
224 {OUString(SC_UNONAME_CELLORI), ATTR_STACKED, cppu::UnoType<table::CellOrientation>::get(), 0, 0 },
225 {OUString(SC_UNONAME_PADJUST), ATTR_HOR_JUSTIFY, ::cppu::UnoType<sal_Int16>::get(), 0, MID_HORJUST_ADJUST },
226 {OUString(SC_UNONAME_PBMARGIN), ATTR_MARGIN, cppu::UnoType<sal_Int32>::get(), 0, MID_MARGIN_LO_MARGIN | CONVERT_TWIPS },
227 {OUString(SC_UNONAME_PINDENT), ATTR_INDENT, cppu::UnoType<sal_Int16>::get(), 0, 0 }, //! CONVERT_TWIPS
228 {OUString(SC_UNONAME_PISCHDIST),ATTR_SCRIPTSPACE, getBooleanCppuType(), 0, 0 },
229 {OUString(SC_UNONAME_PISFORBID),ATTR_FORBIDDEN_RULES,getBooleanCppuType(), 0, 0 },
230 {OUString(SC_UNONAME_PISHANG), ATTR_HANGPUNCTUATION,getBooleanCppuType(), 0, 0 },
231 {OUString(SC_UNONAME_PISHYPHEN),ATTR_HYPHENATE, getBooleanCppuType(), 0, 0 },
232 {OUString(SC_UNONAME_PLASTADJ), ATTR_HOR_JUSTIFY, ::cppu::UnoType<sal_Int16>::get(), 0, MID_HORJUST_ADJUST },
233 {OUString(SC_UNONAME_PLMARGIN), ATTR_MARGIN, cppu::UnoType<sal_Int32>::get(), 0, MID_MARGIN_L_MARGIN | CONVERT_TWIPS },
234 {OUString(SC_UNONAME_PRMARGIN), ATTR_MARGIN, cppu::UnoType<sal_Int32>::get(), 0, MID_MARGIN_R_MARGIN | CONVERT_TWIPS },
235 {OUString(SC_UNONAME_PTMARGIN), ATTR_MARGIN, cppu::UnoType<sal_Int32>::get(), 0, MID_MARGIN_UP_MARGIN | CONVERT_TWIPS },
236 {OUString(SC_UNONAME_RIGHTBORDER),ATTR_BORDER, ::cppu::UnoType<table::BorderLine>::get(), 0, RIGHT_BORDER | CONVERT_TWIPS },
237 {OUString(SC_UNONAME_RIGHTBORDER2),ATTR_BORDER, ::cppu::UnoType<table::BorderLine2>::get(), 0, RIGHT_BORDER | CONVERT_TWIPS },
238 {OUString(SC_UNONAME_ROTANG), ATTR_ROTATE_VALUE, cppu::UnoType<sal_Int32>::get(), 0, 0 },
239 {OUString(SC_UNONAME_ROTREF), ATTR_ROTATE_MODE, cppu::UnoType<sal_Int32>::get(), 0, 0 },
240 {OUString(SC_UNONAME_SHADOW), ATTR_SHADOW, cppu::UnoType<table::ShadowFormat>::get(), 0, 0 | CONVERT_TWIPS },
241 {OUString(SC_UNONAME_SHRINK_TO_FIT), ATTR_SHRINKTOFIT, getBooleanCppuType(), 0, 0 },
242 {OUString(SC_UNONAME_TBLBORD), SC_WID_UNO_TBLBORD, cppu::UnoType<table::TableBorder>::get(), 0, 0 | CONVERT_TWIPS },
243 {OUString(SC_UNONAME_TBLBORD2), SC_WID_UNO_TBLBORD2, cppu::UnoType<table::TableBorder2>::get(), 0, 0 | CONVERT_TWIPS },
244 {OUString(SC_UNONAME_TOPBORDER),ATTR_BORDER, ::cppu::UnoType<table::BorderLine>::get(), 0, TOP_BORDER | CONVERT_TWIPS },
245 {OUString(SC_UNONAME_TOPBORDER2),ATTR_BORDER, ::cppu::UnoType<table::BorderLine2>::get(), 0, TOP_BORDER | CONVERT_TWIPS },
246 {OUString(SC_UNONAME_USERDEF), ATTR_USERDEF, cppu::UnoType<container::XNameContainer>::get(), 0, 0 },
247 {OUString(SC_UNONAME_VALIDAT), SC_WID_UNO_VALIDAT, cppu::UnoType<beans::XPropertySet>::get(), 0, 0 },
248 {OUString(SC_UNONAME_VALILOC), SC_WID_UNO_VALILOC, cppu::UnoType<beans::XPropertySet>::get(), 0, 0 },
249 {OUString(SC_UNONAME_VALIXML), SC_WID_UNO_VALIXML, cppu::UnoType<beans::XPropertySet>::get(), 0, 0 },
250 {OUString(SC_UNONAME_CELLVJUS), ATTR_VER_JUSTIFY, cppu::UnoType<sal_Int32>::get(), 0, 0 },
251 {OUString(SC_UNONAME_CELLVJUS_METHOD), ATTR_VER_JUSTIFY_METHOD, ::cppu::UnoType<sal_Int32>::get(), 0, 0 },
252 {OUString(SC_UNONAME_WRITING), ATTR_WRITINGDIR, cppu::UnoType<sal_Int16>::get(), 0, 0 },
253 {OUString(SC_UNONAME_HYPERLINK), ATTR_HYPERLINK, cppu::UnoType<OUString>::get(), 0, 0 },
254 { OUString(), 0, css::uno::Type(), 0, 0 }
256 static SfxItemPropertySet aCellsPropertySet( aCellsPropertyMap_Impl );
257 return &aCellsPropertySet;
260 // CellRange enthaelt alle Eintraege von Cells, zusaetzlich eigene Eintraege
261 // mit Which-ID 0 (werden nur fuer getPropertySetInfo benoetigt).
263 static const SfxItemPropertySet* lcl_GetRangePropertySet()
265 static const SfxItemPropertyMapEntry aRangePropertyMap_Impl[] =
267 {OUString(SC_UNONAME_ABSNAME), SC_WID_UNO_ABSNAME, cppu::UnoType<OUString>::get(), 0 | beans::PropertyAttribute::READONLY, 0 },
268 {OUString(SC_UNONAME_ASIANVERT),ATTR_VERTICAL_ASIAN,getBooleanCppuType(), 0, 0 },
269 {OUString(SC_UNONAME_BOTTBORDER),ATTR_BORDER, ::cppu::UnoType<table::BorderLine>::get(), 0, BOTTOM_BORDER | CONVERT_TWIPS },
270 {OUString(SC_UNONAME_BOTTBORDER2),ATTR_BORDER, ::cppu::UnoType<table::BorderLine2>::get(), 0, BOTTOM_BORDER | CONVERT_TWIPS },
271 {OUString(SC_UNONAME_CELLBACK), ATTR_BACKGROUND, cppu::UnoType<sal_Int32>::get(), 0, MID_BACK_COLOR },
272 {OUString(SC_UNONAME_CELLPRO), ATTR_PROTECTION, cppu::UnoType<util::CellProtection>::get(), 0, 0 },
273 {OUString(SC_UNONAME_CELLSTYL), SC_WID_UNO_CELLSTYL,cppu::UnoType<OUString>::get(), 0, 0 },
274 {OUString(SC_UNONAME_CCOLOR), ATTR_FONT_COLOR, cppu::UnoType<sal_Int32>::get(), 0, 0 },
275 {OUString(SC_UNONAME_COUTL), ATTR_FONT_CONTOUR, getBooleanCppuType(), 0, 0 },
276 {OUString(SC_UNONAME_CCROSS), ATTR_FONT_CROSSEDOUT,getBooleanCppuType(), 0, MID_CROSSED_OUT },
277 {OUString(SC_UNONAME_CEMPHAS), ATTR_FONT_EMPHASISMARK,cppu::UnoType<sal_Int16>::get(), 0, MID_EMPHASIS },
278 {OUString(SC_UNONAME_CFONT), ATTR_FONT, cppu::UnoType<sal_Int16>::get(), 0, MID_FONT_FAMILY },
279 {OUString(SC_UNONAME_CFCHARS), ATTR_FONT, cppu::UnoType<sal_Int16>::get(), 0, MID_FONT_CHAR_SET },
280 {OUString(SC_UNO_CJK_CFCHARS), ATTR_CJK_FONT, cppu::UnoType<sal_Int16>::get(), 0, MID_FONT_CHAR_SET },
281 {OUString(SC_UNO_CTL_CFCHARS), ATTR_CTL_FONT, cppu::UnoType<sal_Int16>::get(), 0, MID_FONT_CHAR_SET },
282 {OUString(SC_UNONAME_CFFAMIL), ATTR_FONT, cppu::UnoType<sal_Int16>::get(), 0, MID_FONT_FAMILY },
283 {OUString(SC_UNO_CJK_CFFAMIL), ATTR_CJK_FONT, cppu::UnoType<sal_Int16>::get(), 0, MID_FONT_FAMILY },
284 {OUString(SC_UNO_CTL_CFFAMIL), ATTR_CTL_FONT, cppu::UnoType<sal_Int16>::get(), 0, MID_FONT_FAMILY },
285 {OUString(SC_UNONAME_CFNAME), ATTR_FONT, cppu::UnoType<OUString>::get(), 0, MID_FONT_FAMILY_NAME },
286 {OUString(SC_UNO_CJK_CFNAME), ATTR_CJK_FONT, cppu::UnoType<OUString>::get(), 0, MID_FONT_FAMILY_NAME },
287 {OUString(SC_UNO_CTL_CFNAME), ATTR_CTL_FONT, cppu::UnoType<OUString>::get(), 0, MID_FONT_FAMILY_NAME },
288 {OUString(SC_UNONAME_CFPITCH), ATTR_FONT, cppu::UnoType<sal_Int16>::get(), 0, MID_FONT_PITCH },
289 {OUString(SC_UNO_CJK_CFPITCH), ATTR_CJK_FONT, cppu::UnoType<sal_Int16>::get(), 0, MID_FONT_PITCH },
290 {OUString(SC_UNO_CTL_CFPITCH), ATTR_CTL_FONT, cppu::UnoType<sal_Int16>::get(), 0, MID_FONT_PITCH },
291 {OUString(SC_UNONAME_CFSTYLE), ATTR_FONT, cppu::UnoType<OUString>::get(), 0, MID_FONT_STYLE_NAME },
292 {OUString(SC_UNO_CJK_CFSTYLE), ATTR_CJK_FONT, cppu::UnoType<OUString>::get(), 0, MID_FONT_STYLE_NAME },
293 {OUString(SC_UNO_CTL_CFSTYLE), ATTR_CTL_FONT, cppu::UnoType<OUString>::get(), 0, MID_FONT_STYLE_NAME },
294 {OUString(SC_UNONAME_CHEIGHT), ATTR_FONT_HEIGHT, cppu::UnoType<float>::get(), 0, MID_FONTHEIGHT | CONVERT_TWIPS },
295 {OUString(SC_UNO_CJK_CHEIGHT), ATTR_CJK_FONT_HEIGHT,cppu::UnoType<float>::get(), 0, MID_FONTHEIGHT | CONVERT_TWIPS },
296 {OUString(SC_UNO_CTL_CHEIGHT), ATTR_CTL_FONT_HEIGHT,cppu::UnoType<float>::get(), 0, MID_FONTHEIGHT | CONVERT_TWIPS },
297 {OUString(SC_UNONAME_CLOCAL), ATTR_FONT_LANGUAGE, cppu::UnoType<lang::Locale>::get(), 0, MID_LANG_LOCALE },
298 {OUString(SC_UNO_CJK_CLOCAL), ATTR_CJK_FONT_LANGUAGE,cppu::UnoType<lang::Locale>::get(), 0, MID_LANG_LOCALE },
299 {OUString(SC_UNO_CTL_CLOCAL), ATTR_CTL_FONT_LANGUAGE,cppu::UnoType<lang::Locale>::get(), 0, MID_LANG_LOCALE },
300 {OUString(SC_UNONAME_COVER), ATTR_FONT_OVERLINE, cppu::UnoType<sal_Int16>::get(), 0, MID_TL_STYLE },
301 {OUString(SC_UNONAME_COVRLCOL), ATTR_FONT_OVERLINE, cppu::UnoType<sal_Int32>::get(), 0, MID_TL_COLOR },
302 {OUString(SC_UNONAME_COVRLHAS), ATTR_FONT_OVERLINE, getBooleanCppuType(), 0, MID_TL_HASCOLOR },
303 {OUString(SC_UNONAME_CPOST), ATTR_FONT_POSTURE, cppu::UnoType<awt::FontSlant>::get(), 0, MID_POSTURE },
304 {OUString(SC_UNO_CJK_CPOST), ATTR_CJK_FONT_POSTURE,cppu::UnoType<awt::FontSlant>::get(), 0, MID_POSTURE },
305 {OUString(SC_UNO_CTL_CPOST), ATTR_CTL_FONT_POSTURE,cppu::UnoType<awt::FontSlant>::get(), 0, MID_POSTURE },
306 {OUString(SC_UNONAME_CRELIEF), ATTR_FONT_RELIEF, cppu::UnoType<sal_Int16>::get(), 0, MID_RELIEF },
307 {OUString(SC_UNONAME_CSHADD), ATTR_FONT_SHADOWED, getBooleanCppuType(), 0, 0 },
308 {OUString(SC_UNONAME_CSTRIKE), ATTR_FONT_CROSSEDOUT,cppu::UnoType<sal_Int16>::get(), 0, MID_CROSS_OUT },
309 {OUString(SC_UNONAME_CUNDER), ATTR_FONT_UNDERLINE,cppu::UnoType<sal_Int16>::get(), 0, MID_TL_STYLE },
310 {OUString(SC_UNONAME_CUNDLCOL), ATTR_FONT_UNDERLINE,cppu::UnoType<sal_Int32>::get(), 0, MID_TL_COLOR },
311 {OUString(SC_UNONAME_CUNDLHAS), ATTR_FONT_UNDERLINE,getBooleanCppuType(), 0, MID_TL_HASCOLOR },
312 {OUString(SC_UNONAME_CWEIGHT), ATTR_FONT_WEIGHT, cppu::UnoType<float>::get(), 0, MID_WEIGHT },
313 {OUString(SC_UNO_CJK_CWEIGHT), ATTR_CJK_FONT_WEIGHT,cppu::UnoType<float>::get(), 0, MID_WEIGHT },
314 {OUString(SC_UNO_CTL_CWEIGHT), ATTR_CTL_FONT_WEIGHT,cppu::UnoType<float>::get(), 0, MID_WEIGHT },
315 {OUString(SC_UNONAME_CWORDMOD), ATTR_FONT_WORDLINE, getBooleanCppuType(), 0, 0 },
316 {OUString(SC_UNONAME_CHCOLHDR), SC_WID_UNO_CHCOLHDR,getBooleanCppuType(), 0, 0 },
317 {OUString(SC_UNONAME_CHROWHDR), SC_WID_UNO_CHROWHDR,getBooleanCppuType(), 0, 0 },
318 {OUString(SC_UNONAME_CONDFMT), SC_WID_UNO_CONDFMT, cppu::UnoType<sheet::XSheetConditionalEntries>::get(), 0, 0 },
319 {OUString(SC_UNONAME_CONDLOC), SC_WID_UNO_CONDLOC, cppu::UnoType<sheet::XSheetConditionalEntries>::get(), 0, 0 },
320 {OUString(SC_UNONAME_CONDXML), SC_WID_UNO_CONDXML, cppu::UnoType<sheet::XSheetConditionalEntries>::get(), 0, 0 },
321 {OUString(SC_UNONAME_DIAGONAL_BLTR), ATTR_BORDER_BLTR, ::cppu::UnoType<table::BorderLine>::get(), 0, 0 | CONVERT_TWIPS },
322 {OUString(SC_UNONAME_DIAGONAL_BLTR2), ATTR_BORDER_BLTR, ::cppu::UnoType<table::BorderLine2>::get(), 0, 0 | CONVERT_TWIPS },
323 {OUString(SC_UNONAME_DIAGONAL_TLBR), ATTR_BORDER_TLBR, ::cppu::UnoType<table::BorderLine>::get(), 0, 0 | CONVERT_TWIPS },
324 {OUString(SC_UNONAME_DIAGONAL_TLBR2), ATTR_BORDER_TLBR, ::cppu::UnoType<table::BorderLine2>::get(), 0, 0 | CONVERT_TWIPS },
325 {OUString(SC_UNONAME_CELLHJUS), ATTR_HOR_JUSTIFY, cppu::UnoType<table::CellHoriJustify>::get(), 0, MID_HORJUST_HORJUST },
326 {OUString(SC_UNONAME_CELLHJUS_METHOD), ATTR_HOR_JUSTIFY_METHOD, ::cppu::UnoType<sal_Int32>::get(), 0, 0 },
327 {OUString(SC_UNONAME_CELLTRAN), ATTR_BACKGROUND, getBooleanCppuType(), 0, MID_GRAPHIC_TRANSPARENT },
328 {OUString(SC_UNONAME_WRAP), ATTR_LINEBREAK, getBooleanCppuType(), 0, 0 },
329 {OUString(SC_UNONAME_LEFTBORDER),ATTR_BORDER, ::cppu::UnoType<table::BorderLine>::get(), 0, LEFT_BORDER | CONVERT_TWIPS },
330 {OUString(SC_UNONAME_LEFTBORDER2),ATTR_BORDER, ::cppu::UnoType<table::BorderLine2>::get(), 0, LEFT_BORDER | CONVERT_TWIPS },
331 {OUString(SC_UNONAME_NUMFMT), ATTR_VALUE_FORMAT, cppu::UnoType<sal_Int32>::get(), 0, 0 },
332 {OUString(SC_UNONAME_NUMRULES), SC_WID_UNO_NUMRULES,cppu::UnoType<container::XIndexReplace>::get(), 0, 0 },
333 {OUString(SC_UNONAME_CELLORI), ATTR_STACKED, cppu::UnoType<table::CellOrientation>::get(), 0, 0 },
334 {OUString(SC_UNONAME_PADJUST), ATTR_HOR_JUSTIFY, ::cppu::UnoType<sal_Int16>::get(), 0, MID_HORJUST_ADJUST },
335 {OUString(SC_UNONAME_PBMARGIN), ATTR_MARGIN, cppu::UnoType<sal_Int32>::get(), 0, MID_MARGIN_LO_MARGIN | CONVERT_TWIPS },
336 {OUString(SC_UNONAME_PINDENT), ATTR_INDENT, cppu::UnoType<sal_Int16>::get(), 0, 0 }, //! CONVERT_TWIPS
337 {OUString(SC_UNONAME_PISCHDIST),ATTR_SCRIPTSPACE, getBooleanCppuType(), 0, 0 },
338 {OUString(SC_UNONAME_PISFORBID),ATTR_FORBIDDEN_RULES,getBooleanCppuType(), 0, 0 },
339 {OUString(SC_UNONAME_PISHANG), ATTR_HANGPUNCTUATION,getBooleanCppuType(), 0, 0 },
340 {OUString(SC_UNONAME_PISHYPHEN),ATTR_HYPHENATE, getBooleanCppuType(), 0, 0 },
341 {OUString(SC_UNONAME_PLASTADJ), ATTR_HOR_JUSTIFY, ::cppu::UnoType<sal_Int16>::get(), 0, MID_HORJUST_ADJUST },
342 {OUString(SC_UNONAME_PLMARGIN), ATTR_MARGIN, cppu::UnoType<sal_Int32>::get(), 0, MID_MARGIN_L_MARGIN | CONVERT_TWIPS },
343 {OUString(SC_UNONAME_PRMARGIN), ATTR_MARGIN, cppu::UnoType<sal_Int32>::get(), 0, MID_MARGIN_R_MARGIN | CONVERT_TWIPS },
344 {OUString(SC_UNONAME_PTMARGIN), ATTR_MARGIN, cppu::UnoType<sal_Int32>::get(), 0, MID_MARGIN_UP_MARGIN | CONVERT_TWIPS },
345 {OUString(SC_UNONAME_POS), SC_WID_UNO_POS, cppu::UnoType<awt::Point>::get(), 0 | beans::PropertyAttribute::READONLY, 0 },
346 {OUString(SC_UNONAME_RIGHTBORDER),ATTR_BORDER, ::cppu::UnoType<table::BorderLine>::get(), 0, RIGHT_BORDER | CONVERT_TWIPS },
347 {OUString(SC_UNONAME_RIGHTBORDER2),ATTR_BORDER, ::cppu::UnoType<table::BorderLine2>::get(), 0, RIGHT_BORDER | CONVERT_TWIPS },
348 {OUString(SC_UNONAME_ROTANG), ATTR_ROTATE_VALUE, cppu::UnoType<sal_Int32>::get(), 0, 0 },
349 {OUString(SC_UNONAME_ROTREF), ATTR_ROTATE_MODE, cppu::UnoType<sal_Int32>::get(), 0, 0 },
350 {OUString(SC_UNONAME_SHADOW), ATTR_SHADOW, cppu::UnoType<table::ShadowFormat>::get(), 0, 0 | CONVERT_TWIPS },
351 {OUString(SC_UNONAME_SHRINK_TO_FIT), ATTR_SHRINKTOFIT, getBooleanCppuType(), 0, 0 },
352 {OUString(SC_UNONAME_SIZE), SC_WID_UNO_SIZE, cppu::UnoType<awt::Size>::get(), 0 | beans::PropertyAttribute::READONLY, 0 },
353 {OUString(SC_UNONAME_TBLBORD), SC_WID_UNO_TBLBORD, cppu::UnoType<table::TableBorder>::get(), 0, 0 | CONVERT_TWIPS },
354 {OUString(SC_UNONAME_TBLBORD2), SC_WID_UNO_TBLBORD2, cppu::UnoType<table::TableBorder2>::get(), 0, 0 | CONVERT_TWIPS },
355 {OUString(SC_UNONAME_TOPBORDER),ATTR_BORDER, ::cppu::UnoType<table::BorderLine>::get(), 0, TOP_BORDER | CONVERT_TWIPS },
356 {OUString(SC_UNONAME_TOPBORDER2),ATTR_BORDER, ::cppu::UnoType<table::BorderLine2>::get(), 0, TOP_BORDER | CONVERT_TWIPS },
357 {OUString(SC_UNONAME_USERDEF), ATTR_USERDEF, cppu::UnoType<container::XNameContainer>::get(), 0, 0 },
358 {OUString(SC_UNONAME_VALIDAT), SC_WID_UNO_VALIDAT, cppu::UnoType<beans::XPropertySet>::get(), 0, 0 },
359 {OUString(SC_UNONAME_VALILOC), SC_WID_UNO_VALILOC, cppu::UnoType<beans::XPropertySet>::get(), 0, 0 },
360 {OUString(SC_UNONAME_VALIXML), SC_WID_UNO_VALIXML, cppu::UnoType<beans::XPropertySet>::get(), 0, 0 },
361 {OUString(SC_UNONAME_CELLVJUS), ATTR_VER_JUSTIFY, cppu::UnoType<sal_Int32>::get(), 0, 0 },
362 {OUString(SC_UNONAME_CELLVJUS_METHOD), ATTR_VER_JUSTIFY_METHOD, ::cppu::UnoType<sal_Int32>::get(), 0, 0 },
363 {OUString(SC_UNONAME_WRITING), ATTR_WRITINGDIR, cppu::UnoType<sal_Int16>::get(), 0, 0 },
364 { OUString(), 0, css::uno::Type(), 0, 0 }
366 static SfxItemPropertySet aRangePropertySet( aRangePropertyMap_Impl );
367 return &aRangePropertySet;
370 // Cell enthaelt alle Eintraege von CellRange, zusaetzlich eigene Eintraege
371 // mit Which-ID 0 (werden nur fuer getPropertySetInfo benoetigt).
373 static const SfxItemPropertySet* lcl_GetCellPropertySet()
375 static const SfxItemPropertyMapEntry aCellPropertyMap_Impl[] =
377 {OUString(SC_UNONAME_ABSNAME), SC_WID_UNO_ABSNAME, cppu::UnoType<OUString>::get(), 0 | beans::PropertyAttribute::READONLY, 0 },
378 {OUString(SC_UNONAME_ASIANVERT),ATTR_VERTICAL_ASIAN,getBooleanCppuType(), 0, 0 },
379 {OUString(SC_UNONAME_BOTTBORDER),ATTR_BORDER, ::cppu::UnoType<table::BorderLine>::get(), 0, BOTTOM_BORDER | CONVERT_TWIPS },
380 {OUString(SC_UNONAME_BOTTBORDER2),ATTR_BORDER, ::cppu::UnoType<table::BorderLine2>::get(), 0, BOTTOM_BORDER | CONVERT_TWIPS },
381 {OUString(SC_UNONAME_CELLBACK), ATTR_BACKGROUND, cppu::UnoType<sal_Int32>::get(), 0, MID_BACK_COLOR },
382 {OUString(SC_UNONAME_CELLPRO), ATTR_PROTECTION, cppu::UnoType<util::CellProtection>::get(), 0, 0 },
383 {OUString(SC_UNONAME_CELLSTYL), SC_WID_UNO_CELLSTYL,cppu::UnoType<OUString>::get(), 0, 0 },
384 {OUString(SC_UNONAME_CCOLOR), ATTR_FONT_COLOR, cppu::UnoType<sal_Int32>::get(), 0, 0 },
385 {OUString(SC_UNONAME_COUTL), ATTR_FONT_CONTOUR, getBooleanCppuType(), 0, 0 },
386 {OUString(SC_UNONAME_CCROSS), ATTR_FONT_CROSSEDOUT,getBooleanCppuType(), 0, MID_CROSSED_OUT },
387 {OUString(SC_UNONAME_CEMPHAS), ATTR_FONT_EMPHASISMARK,cppu::UnoType<sal_Int16>::get(), 0, MID_EMPHASIS },
388 {OUString(SC_UNONAME_CFONT), ATTR_FONT, cppu::UnoType<sal_Int16>::get(), 0, MID_FONT_FAMILY },
389 {OUString(SC_UNONAME_CFCHARS), ATTR_FONT, cppu::UnoType<sal_Int16>::get(), 0, MID_FONT_CHAR_SET },
390 {OUString(SC_UNO_CJK_CFCHARS), ATTR_CJK_FONT, cppu::UnoType<sal_Int16>::get(), 0, MID_FONT_CHAR_SET },
391 {OUString(SC_UNO_CTL_CFCHARS), ATTR_CTL_FONT, cppu::UnoType<sal_Int16>::get(), 0, MID_FONT_CHAR_SET },
392 {OUString(SC_UNONAME_CFFAMIL), ATTR_FONT, cppu::UnoType<sal_Int16>::get(), 0, MID_FONT_FAMILY },
393 {OUString(SC_UNO_CJK_CFFAMIL), ATTR_CJK_FONT, cppu::UnoType<sal_Int16>::get(), 0, MID_FONT_FAMILY },
394 {OUString(SC_UNO_CTL_CFFAMIL), ATTR_CTL_FONT, cppu::UnoType<sal_Int16>::get(), 0, MID_FONT_FAMILY },
395 {OUString(SC_UNONAME_CFNAME), ATTR_FONT, cppu::UnoType<OUString>::get(), 0, MID_FONT_FAMILY_NAME },
396 {OUString(SC_UNO_CJK_CFNAME), ATTR_CJK_FONT, cppu::UnoType<OUString>::get(), 0, MID_FONT_FAMILY_NAME },
397 {OUString(SC_UNO_CTL_CFNAME), ATTR_CTL_FONT, cppu::UnoType<OUString>::get(), 0, MID_FONT_FAMILY_NAME },
398 {OUString(SC_UNONAME_CFPITCH), ATTR_FONT, cppu::UnoType<sal_Int16>::get(), 0, MID_FONT_PITCH },
399 {OUString(SC_UNO_CJK_CFPITCH), ATTR_CJK_FONT, cppu::UnoType<sal_Int16>::get(), 0, MID_FONT_PITCH },
400 {OUString(SC_UNO_CTL_CFPITCH), ATTR_CTL_FONT, cppu::UnoType<sal_Int16>::get(), 0, MID_FONT_PITCH },
401 {OUString(SC_UNONAME_CFSTYLE), ATTR_FONT, cppu::UnoType<OUString>::get(), 0, MID_FONT_STYLE_NAME },
402 {OUString(SC_UNO_CJK_CFSTYLE), ATTR_CJK_FONT, cppu::UnoType<OUString>::get(), 0, MID_FONT_STYLE_NAME },
403 {OUString(SC_UNO_CTL_CFSTYLE), ATTR_CTL_FONT, cppu::UnoType<OUString>::get(), 0, MID_FONT_STYLE_NAME },
404 {OUString(SC_UNONAME_CHEIGHT), ATTR_FONT_HEIGHT, cppu::UnoType<float>::get(), 0, MID_FONTHEIGHT | CONVERT_TWIPS },
405 {OUString(SC_UNO_CJK_CHEIGHT), ATTR_CJK_FONT_HEIGHT,cppu::UnoType<float>::get(), 0, MID_FONTHEIGHT | CONVERT_TWIPS },
406 {OUString(SC_UNO_CTL_CHEIGHT), ATTR_CTL_FONT_HEIGHT,cppu::UnoType<float>::get(), 0, MID_FONTHEIGHT | CONVERT_TWIPS },
407 {OUString(SC_UNONAME_CLOCAL), ATTR_FONT_LANGUAGE, cppu::UnoType<lang::Locale>::get(), 0, MID_LANG_LOCALE },
408 {OUString(SC_UNO_CJK_CLOCAL), ATTR_CJK_FONT_LANGUAGE,cppu::UnoType<lang::Locale>::get(), 0, MID_LANG_LOCALE },
409 {OUString(SC_UNO_CTL_CLOCAL), ATTR_CTL_FONT_LANGUAGE,cppu::UnoType<lang::Locale>::get(), 0, MID_LANG_LOCALE },
410 {OUString(SC_UNONAME_COVER), ATTR_FONT_OVERLINE, cppu::UnoType<sal_Int16>::get(), 0, MID_TL_STYLE },
411 {OUString(SC_UNONAME_COVRLCOL), ATTR_FONT_OVERLINE, cppu::UnoType<sal_Int32>::get(), 0, MID_TL_COLOR },
412 {OUString(SC_UNONAME_COVRLHAS), ATTR_FONT_OVERLINE, getBooleanCppuType(), 0, MID_TL_HASCOLOR },
413 {OUString(SC_UNONAME_CPOST), ATTR_FONT_POSTURE, cppu::UnoType<awt::FontSlant>::get(), 0, MID_POSTURE },
414 {OUString(SC_UNO_CJK_CPOST), ATTR_CJK_FONT_POSTURE,cppu::UnoType<awt::FontSlant>::get(), 0, MID_POSTURE },
415 {OUString(SC_UNO_CTL_CPOST), ATTR_CTL_FONT_POSTURE,cppu::UnoType<awt::FontSlant>::get(), 0, MID_POSTURE },
416 {OUString(SC_UNONAME_CRELIEF), ATTR_FONT_RELIEF, cppu::UnoType<sal_Int16>::get(), 0, MID_RELIEF },
417 {OUString(SC_UNONAME_CSHADD), ATTR_FONT_SHADOWED, getBooleanCppuType(), 0, 0 },
418 {OUString(SC_UNONAME_CSTRIKE), ATTR_FONT_CROSSEDOUT,cppu::UnoType<sal_Int16>::get(), 0, MID_CROSS_OUT },
419 {OUString(SC_UNONAME_CUNDER), ATTR_FONT_UNDERLINE,cppu::UnoType<sal_Int16>::get(), 0, MID_TL_STYLE },
420 {OUString(SC_UNONAME_CUNDLCOL), ATTR_FONT_UNDERLINE,cppu::UnoType<sal_Int32>::get(), 0, MID_TL_COLOR },
421 {OUString(SC_UNONAME_CUNDLHAS), ATTR_FONT_UNDERLINE,getBooleanCppuType(), 0, MID_TL_HASCOLOR },
422 {OUString(SC_UNONAME_CWEIGHT), ATTR_FONT_WEIGHT, cppu::UnoType<float>::get(), 0, MID_WEIGHT },
423 {OUString(SC_UNO_CJK_CWEIGHT), ATTR_CJK_FONT_WEIGHT,cppu::UnoType<float>::get(), 0, MID_WEIGHT },
424 {OUString(SC_UNO_CTL_CWEIGHT), ATTR_CTL_FONT_WEIGHT,cppu::UnoType<float>::get(), 0, MID_WEIGHT },
425 {OUString(SC_UNONAME_CWORDMOD), ATTR_FONT_WORDLINE, getBooleanCppuType(), 0, 0 },
426 {OUString(SC_UNONAME_CHCOLHDR), SC_WID_UNO_CHCOLHDR,getBooleanCppuType(), 0, 0 },
427 {OUString(SC_UNONAME_CHROWHDR), SC_WID_UNO_CHROWHDR,getBooleanCppuType(), 0, 0 },
428 {OUString(SC_UNONAME_CONDFMT), SC_WID_UNO_CONDFMT, cppu::UnoType<sheet::XSheetConditionalEntries>::get(), 0, 0 },
429 {OUString(SC_UNONAME_CONDLOC), SC_WID_UNO_CONDLOC, cppu::UnoType<sheet::XSheetConditionalEntries>::get(), 0, 0 },
430 {OUString(SC_UNONAME_CONDXML), SC_WID_UNO_CONDXML, cppu::UnoType<sheet::XSheetConditionalEntries>::get(), 0, 0 },
431 {OUString(SC_UNONAME_DIAGONAL_BLTR), ATTR_BORDER_BLTR, ::cppu::UnoType<table::BorderLine>::get(), 0, 0 | CONVERT_TWIPS },
432 {OUString(SC_UNONAME_DIAGONAL_BLTR2), ATTR_BORDER_BLTR, ::cppu::UnoType<table::BorderLine2>::get(), 0, 0 | CONVERT_TWIPS },
433 {OUString(SC_UNONAME_DIAGONAL_TLBR), ATTR_BORDER_TLBR, ::cppu::UnoType<table::BorderLine>::get(), 0, 0 | CONVERT_TWIPS },
434 {OUString(SC_UNONAME_DIAGONAL_TLBR2), ATTR_BORDER_TLBR, ::cppu::UnoType<table::BorderLine2>::get(), 0, 0 | CONVERT_TWIPS },
435 {OUString(SC_UNONAME_FORMLOC), SC_WID_UNO_FORMLOC, cppu::UnoType<OUString>::get(), 0, 0 },
436 {OUString(SC_UNONAME_FORMRT), SC_WID_UNO_FORMRT, cppu::UnoType<table::CellContentType>::get(), 0 | beans::PropertyAttribute::READONLY, 0 },
437 {OUString(SC_UNONAME_CELLHJUS), ATTR_HOR_JUSTIFY, cppu::UnoType<table::CellHoriJustify>::get(), 0, MID_HORJUST_HORJUST },
438 {OUString(SC_UNONAME_CELLHJUS_METHOD), ATTR_HOR_JUSTIFY_METHOD, ::cppu::UnoType<sal_Int32>::get(), 0, 0 },
439 {OUString(SC_UNONAME_CELLTRAN), ATTR_BACKGROUND, getBooleanCppuType(), 0, MID_GRAPHIC_TRANSPARENT },
440 {OUString(SC_UNONAME_WRAP), ATTR_LINEBREAK, getBooleanCppuType(), 0, 0 },
441 {OUString(SC_UNONAME_LEFTBORDER),ATTR_BORDER, ::cppu::UnoType<table::BorderLine>::get(), 0, LEFT_BORDER | CONVERT_TWIPS },
442 {OUString(SC_UNONAME_LEFTBORDER2),ATTR_BORDER, ::cppu::UnoType<table::BorderLine2>::get(), 0, LEFT_BORDER | CONVERT_TWIPS },
443 {OUString(SC_UNONAME_NUMFMT), ATTR_VALUE_FORMAT, cppu::UnoType<sal_Int32>::get(), 0, 0 },
444 {OUString(SC_UNONAME_NUMRULES), SC_WID_UNO_NUMRULES,cppu::UnoType<container::XIndexReplace>::get(), 0, 0 },
445 {OUString(SC_UNONAME_CELLORI), ATTR_STACKED, cppu::UnoType<table::CellOrientation>::get(), 0, 0 },
446 {OUString(SC_UNONAME_PADJUST), ATTR_HOR_JUSTIFY, ::cppu::UnoType<sal_Int16>::get(), 0, MID_HORJUST_ADJUST },
447 {OUString(SC_UNONAME_PBMARGIN), ATTR_MARGIN, cppu::UnoType<sal_Int32>::get(), 0, MID_MARGIN_LO_MARGIN | CONVERT_TWIPS },
448 {OUString(SC_UNONAME_PINDENT), ATTR_INDENT, cppu::UnoType<sal_Int16>::get(), 0, 0 }, //! CONVERT_TWIPS
449 {OUString(SC_UNONAME_PISCHDIST),ATTR_SCRIPTSPACE, getBooleanCppuType(), 0, 0 },
450 {OUString(SC_UNONAME_PISFORBID),ATTR_FORBIDDEN_RULES,getBooleanCppuType(), 0, 0 },
451 {OUString(SC_UNONAME_PISHANG), ATTR_HANGPUNCTUATION,getBooleanCppuType(), 0, 0 },
452 {OUString(SC_UNONAME_PISHYPHEN),ATTR_HYPHENATE, getBooleanCppuType(), 0, 0 },
453 {OUString(SC_UNONAME_PLASTADJ), ATTR_HOR_JUSTIFY, ::cppu::UnoType<sal_Int16>::get(), 0, MID_HORJUST_ADJUST },
454 {OUString(SC_UNONAME_PLMARGIN), ATTR_MARGIN, cppu::UnoType<sal_Int32>::get(), 0, MID_MARGIN_L_MARGIN | CONVERT_TWIPS },
455 {OUString(SC_UNONAME_PRMARGIN), ATTR_MARGIN, cppu::UnoType<sal_Int32>::get(), 0, MID_MARGIN_R_MARGIN | CONVERT_TWIPS },
456 {OUString(SC_UNONAME_PTMARGIN), ATTR_MARGIN, cppu::UnoType<sal_Int32>::get(), 0, MID_MARGIN_UP_MARGIN | CONVERT_TWIPS },
457 {OUString(SC_UNONAME_POS), SC_WID_UNO_POS, cppu::UnoType<awt::Point>::get(), 0 | beans::PropertyAttribute::READONLY, 0 },
458 {OUString(SC_UNONAME_RIGHTBORDER),ATTR_BORDER, ::cppu::UnoType<table::BorderLine>::get(), 0, RIGHT_BORDER | CONVERT_TWIPS },
459 {OUString(SC_UNONAME_RIGHTBORDER2),ATTR_BORDER, ::cppu::UnoType<table::BorderLine2>::get(), 0, RIGHT_BORDER | CONVERT_TWIPS },
460 {OUString(SC_UNONAME_ROTANG), ATTR_ROTATE_VALUE, cppu::UnoType<sal_Int32>::get(), 0, 0 },
461 {OUString(SC_UNONAME_ROTREF), ATTR_ROTATE_MODE, cppu::UnoType<sal_Int32>::get(), 0, 0 },
462 {OUString(SC_UNONAME_SHADOW), ATTR_SHADOW, cppu::UnoType<table::ShadowFormat>::get(), 0, 0 | CONVERT_TWIPS },
463 {OUString(SC_UNONAME_SHRINK_TO_FIT), ATTR_SHRINKTOFIT, getBooleanCppuType(), 0, 0 },
464 {OUString(SC_UNONAME_SIZE), SC_WID_UNO_SIZE, cppu::UnoType<awt::Size>::get(), 0 | beans::PropertyAttribute::READONLY, 0 },
465 {OUString(SC_UNONAME_TBLBORD), SC_WID_UNO_TBLBORD, cppu::UnoType<table::TableBorder>::get(), 0, 0 | CONVERT_TWIPS },
466 {OUString(SC_UNONAME_TBLBORD2), SC_WID_UNO_TBLBORD2, cppu::UnoType<table::TableBorder2>::get(), 0, 0 | CONVERT_TWIPS },
467 {OUString(SC_UNONAME_TOPBORDER),ATTR_BORDER, ::cppu::UnoType<table::BorderLine>::get(), 0, TOP_BORDER | CONVERT_TWIPS },
468 {OUString(SC_UNONAME_TOPBORDER2),ATTR_BORDER, ::cppu::UnoType<table::BorderLine2>::get(), 0, TOP_BORDER | CONVERT_TWIPS },
469 {OUString(SC_UNONAME_USERDEF), ATTR_USERDEF, cppu::UnoType<container::XNameContainer>::get(), 0, 0 },
470 {OUString(SC_UNONAME_VALIDAT), SC_WID_UNO_VALIDAT, cppu::UnoType<beans::XPropertySet>::get(), 0, 0 },
471 {OUString(SC_UNONAME_VALILOC), SC_WID_UNO_VALILOC, cppu::UnoType<beans::XPropertySet>::get(), 0, 0 },
472 {OUString(SC_UNONAME_VALIXML), SC_WID_UNO_VALIXML, cppu::UnoType<beans::XPropertySet>::get(), 0, 0 },
473 {OUString(SC_UNONAME_CELLVJUS), ATTR_VER_JUSTIFY, cppu::UnoType<sal_Int32>::get(), 0, 0 },
474 {OUString(SC_UNONAME_CELLVJUS_METHOD), ATTR_VER_JUSTIFY_METHOD, ::cppu::UnoType<sal_Int32>::get(), 0, 0 },
475 {OUString(SC_UNONAME_WRITING), ATTR_WRITINGDIR, cppu::UnoType<sal_Int16>::get(), 0, 0 },
476 {OUString(UNO_NAME_EDIT_CHAR_ESCAPEMENT), EE_CHAR_ESCAPEMENT, cppu::UnoType<sal_Int32>::get(), 0, 0 },
477 {OUString(SC_UNONAME_HYPERLINK), ATTR_HYPERLINK, cppu::UnoType<OUString>::get(), 0, 0 },
478 { OUString(), 0, css::uno::Type(), 0, 0 }
480 static SfxItemPropertySet aCellPropertySet( aCellPropertyMap_Impl );
481 return &aCellPropertySet;
484 // Column und Row enthalten alle Eintraege von CellRange, zusaetzlich eigene Eintraege
485 // mit Which-ID 0 (werden nur fuer getPropertySetInfo benoetigt).
487 static const SfxItemPropertySet* lcl_GetColumnPropertySet()
489 static const SfxItemPropertyMapEntry aColumnPropertyMap_Impl[] =
491 {OUString(SC_UNONAME_ABSNAME), SC_WID_UNO_ABSNAME, cppu::UnoType<OUString>::get(), 0 | beans::PropertyAttribute::READONLY, 0 },
492 {OUString(SC_UNONAME_ASIANVERT),ATTR_VERTICAL_ASIAN,getBooleanCppuType(), 0, 0 },
493 {OUString(SC_UNONAME_BOTTBORDER),ATTR_BORDER, ::cppu::UnoType<table::BorderLine>::get(), 0, BOTTOM_BORDER | CONVERT_TWIPS },
494 {OUString(SC_UNONAME_BOTTBORDER2),ATTR_BORDER, ::cppu::UnoType<table::BorderLine2>::get(), 0, BOTTOM_BORDER | CONVERT_TWIPS },
495 {OUString(SC_UNONAME_CELLBACK), ATTR_BACKGROUND, cppu::UnoType<sal_Int32>::get(), 0, MID_BACK_COLOR },
496 {OUString(SC_UNONAME_CELLPRO), ATTR_PROTECTION, cppu::UnoType<util::CellProtection>::get(), 0, 0 },
497 {OUString(SC_UNONAME_CELLSTYL), SC_WID_UNO_CELLSTYL,cppu::UnoType<OUString>::get(), 0, 0 },
498 {OUString(SC_UNONAME_CCOLOR), ATTR_FONT_COLOR, cppu::UnoType<sal_Int32>::get(), 0, 0 },
499 {OUString(SC_UNONAME_COUTL), ATTR_FONT_CONTOUR, getBooleanCppuType(), 0, 0 },
500 {OUString(SC_UNONAME_CCROSS), ATTR_FONT_CROSSEDOUT,getBooleanCppuType(), 0, MID_CROSSED_OUT },
501 {OUString(SC_UNONAME_CEMPHAS), ATTR_FONT_EMPHASISMARK,cppu::UnoType<sal_Int16>::get(), 0, MID_EMPHASIS },
502 {OUString(SC_UNONAME_CFONT), ATTR_FONT, cppu::UnoType<sal_Int16>::get(), 0, MID_FONT_FAMILY },
503 {OUString(SC_UNONAME_CFCHARS), ATTR_FONT, cppu::UnoType<sal_Int16>::get(), 0, MID_FONT_CHAR_SET },
504 {OUString(SC_UNO_CJK_CFCHARS), ATTR_CJK_FONT, cppu::UnoType<sal_Int16>::get(), 0, MID_FONT_CHAR_SET },
505 {OUString(SC_UNO_CTL_CFCHARS), ATTR_CTL_FONT, cppu::UnoType<sal_Int16>::get(), 0, MID_FONT_CHAR_SET },
506 {OUString(SC_UNONAME_CFFAMIL), ATTR_FONT, cppu::UnoType<sal_Int16>::get(), 0, MID_FONT_FAMILY },
507 {OUString(SC_UNO_CJK_CFFAMIL), ATTR_CJK_FONT, cppu::UnoType<sal_Int16>::get(), 0, MID_FONT_FAMILY },
508 {OUString(SC_UNO_CTL_CFFAMIL), ATTR_CTL_FONT, cppu::UnoType<sal_Int16>::get(), 0, MID_FONT_FAMILY },
509 {OUString(SC_UNONAME_CFNAME), ATTR_FONT, cppu::UnoType<OUString>::get(), 0, MID_FONT_FAMILY_NAME },
510 {OUString(SC_UNO_CJK_CFNAME), ATTR_CJK_FONT, cppu::UnoType<OUString>::get(), 0, MID_FONT_FAMILY_NAME },
511 {OUString(SC_UNO_CTL_CFNAME), ATTR_CTL_FONT, cppu::UnoType<OUString>::get(), 0, MID_FONT_FAMILY_NAME },
512 {OUString(SC_UNONAME_CFPITCH), ATTR_FONT, cppu::UnoType<sal_Int16>::get(), 0, MID_FONT_PITCH },
513 {OUString(SC_UNO_CJK_CFPITCH), ATTR_CJK_FONT, cppu::UnoType<sal_Int16>::get(), 0, MID_FONT_PITCH },
514 {OUString(SC_UNO_CTL_CFPITCH), ATTR_CTL_FONT, cppu::UnoType<sal_Int16>::get(), 0, MID_FONT_PITCH },
515 {OUString(SC_UNONAME_CFSTYLE), ATTR_FONT, cppu::UnoType<OUString>::get(), 0, MID_FONT_STYLE_NAME },
516 {OUString(SC_UNO_CJK_CFSTYLE), ATTR_CJK_FONT, cppu::UnoType<OUString>::get(), 0, MID_FONT_STYLE_NAME },
517 {OUString(SC_UNO_CTL_CFSTYLE), ATTR_CTL_FONT, cppu::UnoType<OUString>::get(), 0, MID_FONT_STYLE_NAME },
518 {OUString(SC_UNONAME_CHEIGHT), ATTR_FONT_HEIGHT, cppu::UnoType<float>::get(), 0, MID_FONTHEIGHT | CONVERT_TWIPS },
519 {OUString(SC_UNO_CJK_CHEIGHT), ATTR_CJK_FONT_HEIGHT,cppu::UnoType<float>::get(), 0, MID_FONTHEIGHT | CONVERT_TWIPS },
520 {OUString(SC_UNO_CTL_CHEIGHT), ATTR_CTL_FONT_HEIGHT,cppu::UnoType<float>::get(), 0, MID_FONTHEIGHT | CONVERT_TWIPS },
521 {OUString(SC_UNONAME_CLOCAL), ATTR_FONT_LANGUAGE, cppu::UnoType<lang::Locale>::get(), 0, MID_LANG_LOCALE },
522 {OUString(SC_UNO_CJK_CLOCAL), ATTR_CJK_FONT_LANGUAGE,cppu::UnoType<lang::Locale>::get(), 0, MID_LANG_LOCALE },
523 {OUString(SC_UNO_CTL_CLOCAL), ATTR_CTL_FONT_LANGUAGE,cppu::UnoType<lang::Locale>::get(), 0, MID_LANG_LOCALE },
524 {OUString(SC_UNONAME_COVER), ATTR_FONT_OVERLINE, cppu::UnoType<sal_Int16>::get(), 0, MID_TL_STYLE },
525 {OUString(SC_UNONAME_COVRLCOL), ATTR_FONT_OVERLINE, cppu::UnoType<sal_Int32>::get(), 0, MID_TL_COLOR },
526 {OUString(SC_UNONAME_COVRLHAS), ATTR_FONT_OVERLINE, getBooleanCppuType(), 0, MID_TL_HASCOLOR },
527 {OUString(SC_UNONAME_CPOST), ATTR_FONT_POSTURE, cppu::UnoType<awt::FontSlant>::get(), 0, MID_POSTURE },
528 {OUString(SC_UNO_CJK_CPOST), ATTR_CJK_FONT_POSTURE,cppu::UnoType<awt::FontSlant>::get(), 0, MID_POSTURE },
529 {OUString(SC_UNO_CTL_CPOST), ATTR_CTL_FONT_POSTURE,cppu::UnoType<awt::FontSlant>::get(), 0, MID_POSTURE },
530 {OUString(SC_UNONAME_CRELIEF), ATTR_FONT_RELIEF, cppu::UnoType<sal_Int16>::get(), 0, MID_RELIEF },
531 {OUString(SC_UNONAME_CSHADD), ATTR_FONT_SHADOWED, getBooleanCppuType(), 0, 0 },
532 {OUString(SC_UNONAME_CSTRIKE), ATTR_FONT_CROSSEDOUT,cppu::UnoType<sal_Int16>::get(), 0, MID_CROSS_OUT },
533 {OUString(SC_UNONAME_CUNDER), ATTR_FONT_UNDERLINE,cppu::UnoType<sal_Int16>::get(), 0, MID_TL_STYLE },
534 {OUString(SC_UNONAME_CUNDLCOL), ATTR_FONT_UNDERLINE,cppu::UnoType<sal_Int32>::get(), 0, MID_TL_COLOR },
535 {OUString(SC_UNONAME_CUNDLHAS), ATTR_FONT_UNDERLINE,getBooleanCppuType(), 0, MID_TL_HASCOLOR },
536 {OUString(SC_UNONAME_CWEIGHT), ATTR_FONT_WEIGHT, cppu::UnoType<float>::get(), 0, MID_WEIGHT },
537 {OUString(SC_UNO_CJK_CWEIGHT), ATTR_CJK_FONT_WEIGHT,cppu::UnoType<float>::get(), 0, MID_WEIGHT },
538 {OUString(SC_UNO_CTL_CWEIGHT), ATTR_CTL_FONT_WEIGHT,cppu::UnoType<float>::get(), 0, MID_WEIGHT },
539 {OUString(SC_UNONAME_CWORDMOD), ATTR_FONT_WORDLINE, getBooleanCppuType(), 0, 0 },
540 {OUString(SC_UNONAME_CHCOLHDR), SC_WID_UNO_CHCOLHDR,getBooleanCppuType(), 0, 0 },
541 {OUString(SC_UNONAME_CHROWHDR), SC_WID_UNO_CHROWHDR,getBooleanCppuType(), 0, 0 },
542 {OUString(SC_UNONAME_CONDFMT), SC_WID_UNO_CONDFMT, cppu::UnoType<sheet::XSheetConditionalEntries>::get(), 0, 0 },
543 {OUString(SC_UNONAME_CONDLOC), SC_WID_UNO_CONDLOC, cppu::UnoType<sheet::XSheetConditionalEntries>::get(), 0, 0 },
544 {OUString(SC_UNONAME_CONDXML), SC_WID_UNO_CONDXML, cppu::UnoType<sheet::XSheetConditionalEntries>::get(), 0, 0 },
545 {OUString(SC_UNONAME_DIAGONAL_BLTR), ATTR_BORDER_BLTR, ::cppu::UnoType<table::BorderLine>::get(), 0, 0 | CONVERT_TWIPS },
546 {OUString(SC_UNONAME_DIAGONAL_BLTR2), ATTR_BORDER_BLTR, ::cppu::UnoType<table::BorderLine2>::get(), 0, 0 | CONVERT_TWIPS },
547 {OUString(SC_UNONAME_DIAGONAL_TLBR), ATTR_BORDER_TLBR, ::cppu::UnoType<table::BorderLine>::get(), 0, 0 | CONVERT_TWIPS },
548 {OUString(SC_UNONAME_DIAGONAL_TLBR2), ATTR_BORDER_TLBR, ::cppu::UnoType<table::BorderLine2>::get(), 0, 0 | CONVERT_TWIPS },
549 {OUString(SC_UNONAME_CELLHJUS), ATTR_HOR_JUSTIFY, cppu::UnoType<table::CellHoriJustify>::get(), 0, MID_HORJUST_HORJUST },
550 {OUString(SC_UNONAME_CELLHJUS_METHOD), ATTR_HOR_JUSTIFY_METHOD, ::cppu::UnoType<sal_Int32>::get(), 0, 0 },
551 {OUString(SC_UNONAME_CELLTRAN), ATTR_BACKGROUND, getBooleanCppuType(), 0, MID_GRAPHIC_TRANSPARENT },
552 {OUString(SC_UNONAME_MANPAGE), SC_WID_UNO_MANPAGE, getBooleanCppuType(), 0, 0 },
553 {OUString(SC_UNONAME_NEWPAGE), SC_WID_UNO_NEWPAGE, getBooleanCppuType(), 0, 0 },
554 {OUString(SC_UNONAME_WRAP), ATTR_LINEBREAK, getBooleanCppuType(), 0, 0 },
555 {OUString(SC_UNONAME_CELLVIS), SC_WID_UNO_CELLVIS, getBooleanCppuType(), 0, 0 },
556 {OUString(SC_UNONAME_LEFTBORDER),ATTR_BORDER, ::cppu::UnoType<table::BorderLine>::get(), 0, LEFT_BORDER | CONVERT_TWIPS },
557 {OUString(SC_UNONAME_LEFTBORDER2),ATTR_BORDER, ::cppu::UnoType<table::BorderLine2>::get(), 0, LEFT_BORDER | CONVERT_TWIPS },
558 {OUString(SC_UNONAME_NUMFMT), ATTR_VALUE_FORMAT, cppu::UnoType<sal_Int32>::get(), 0, 0 },
559 {OUString(SC_UNONAME_NUMRULES), SC_WID_UNO_NUMRULES,cppu::UnoType<container::XIndexReplace>::get(), 0, 0 },
560 {OUString(SC_UNONAME_OWIDTH), SC_WID_UNO_OWIDTH, getBooleanCppuType(), 0, 0 },
561 {OUString(SC_UNONAME_CELLORI), ATTR_STACKED, cppu::UnoType<table::CellOrientation>::get(), 0, 0 },
562 {OUString(SC_UNONAME_PADJUST), ATTR_HOR_JUSTIFY, ::cppu::UnoType<sal_Int16>::get(), 0, MID_HORJUST_ADJUST },
563 {OUString(SC_UNONAME_PBMARGIN), ATTR_MARGIN, cppu::UnoType<sal_Int32>::get(), 0, MID_MARGIN_LO_MARGIN | CONVERT_TWIPS },
564 {OUString(SC_UNONAME_PINDENT), ATTR_INDENT, cppu::UnoType<sal_Int16>::get(), 0, 0 }, //! CONVERT_TWIPS
565 {OUString(SC_UNONAME_PISCHDIST),ATTR_SCRIPTSPACE, getBooleanCppuType(), 0, 0 },
566 {OUString(SC_UNONAME_PISFORBID),ATTR_FORBIDDEN_RULES,getBooleanCppuType(), 0, 0 },
567 {OUString(SC_UNONAME_PISHANG), ATTR_HANGPUNCTUATION,getBooleanCppuType(), 0, 0 },
568 {OUString(SC_UNONAME_PISHYPHEN),ATTR_HYPHENATE, getBooleanCppuType(), 0, 0 },
569 {OUString(SC_UNONAME_PLASTADJ), ATTR_HOR_JUSTIFY, ::cppu::UnoType<sal_Int16>::get(), 0, MID_HORJUST_ADJUST },
570 {OUString(SC_UNONAME_PLMARGIN), ATTR_MARGIN, cppu::UnoType<sal_Int32>::get(), 0, MID_MARGIN_L_MARGIN | CONVERT_TWIPS },
571 {OUString(SC_UNONAME_PRMARGIN), ATTR_MARGIN, cppu::UnoType<sal_Int32>::get(), 0, MID_MARGIN_R_MARGIN | CONVERT_TWIPS },
572 {OUString(SC_UNONAME_PTMARGIN), ATTR_MARGIN, cppu::UnoType<sal_Int32>::get(), 0, MID_MARGIN_UP_MARGIN | CONVERT_TWIPS },
573 {OUString(SC_UNONAME_POS), SC_WID_UNO_POS, cppu::UnoType<awt::Point>::get(), 0 | beans::PropertyAttribute::READONLY, 0 },
574 {OUString(SC_UNONAME_RIGHTBORDER),ATTR_BORDER, ::cppu::UnoType<table::BorderLine>::get(), 0, RIGHT_BORDER | CONVERT_TWIPS },
575 {OUString(SC_UNONAME_RIGHTBORDER2),ATTR_BORDER, ::cppu::UnoType<table::BorderLine2>::get(), 0, RIGHT_BORDER | CONVERT_TWIPS },
576 {OUString(SC_UNONAME_ROTANG), ATTR_ROTATE_VALUE, cppu::UnoType<sal_Int32>::get(), 0, 0 },
577 {OUString(SC_UNONAME_ROTREF), ATTR_ROTATE_MODE, cppu::UnoType<sal_Int32>::get(), 0, 0 },
578 {OUString(SC_UNONAME_SHADOW), ATTR_SHADOW, cppu::UnoType<table::ShadowFormat>::get(), 0, 0 | CONVERT_TWIPS },
579 {OUString(SC_UNONAME_SHRINK_TO_FIT), ATTR_SHRINKTOFIT, getBooleanCppuType(), 0, 0 },
580 {OUString(SC_UNONAME_SIZE), SC_WID_UNO_SIZE, cppu::UnoType<awt::Size>::get(), 0 | beans::PropertyAttribute::READONLY, 0 },
581 {OUString(SC_UNONAME_TBLBORD), SC_WID_UNO_TBLBORD, cppu::UnoType<table::TableBorder>::get(), 0, 0 | CONVERT_TWIPS },
582 {OUString(SC_UNONAME_TBLBORD2), SC_WID_UNO_TBLBORD2, cppu::UnoType<table::TableBorder2>::get(), 0, 0 | CONVERT_TWIPS },
583 {OUString(SC_UNONAME_TOPBORDER),ATTR_BORDER, ::cppu::UnoType<table::BorderLine>::get(), 0, TOP_BORDER | CONVERT_TWIPS },
584 {OUString(SC_UNONAME_TOPBORDER2),ATTR_BORDER, ::cppu::UnoType<table::BorderLine2>::get(), 0, TOP_BORDER | CONVERT_TWIPS },
585 {OUString(SC_UNONAME_USERDEF), ATTR_USERDEF, cppu::UnoType<container::XNameContainer>::get(), 0, 0 },
586 {OUString(SC_UNONAME_VALIDAT), SC_WID_UNO_VALIDAT, cppu::UnoType<beans::XPropertySet>::get(), 0, 0 },
587 {OUString(SC_UNONAME_VALILOC), SC_WID_UNO_VALILOC, cppu::UnoType<beans::XPropertySet>::get(), 0, 0 },
588 {OUString(SC_UNONAME_VALIXML), SC_WID_UNO_VALIXML, cppu::UnoType<beans::XPropertySet>::get(), 0, 0 },
589 {OUString(SC_UNONAME_CELLVJUS), ATTR_VER_JUSTIFY, cppu::UnoType<sal_Int32>::get(), 0, 0 },
590 {OUString(SC_UNONAME_CELLVJUS_METHOD), ATTR_VER_JUSTIFY_METHOD, ::cppu::UnoType<sal_Int32>::get(), 0, 0 },
591 {OUString(SC_UNONAME_CELLWID), SC_WID_UNO_CELLWID, cppu::UnoType<sal_Int32>::get(), 0, 0 },
592 {OUString(SC_UNONAME_WRITING), ATTR_WRITINGDIR, cppu::UnoType<sal_Int16>::get(), 0, 0 },
593 { OUString(), 0, css::uno::Type(), 0, 0 }
595 static SfxItemPropertySet aColumnPropertySet( aColumnPropertyMap_Impl );
596 return &aColumnPropertySet;
599 static const SfxItemPropertySet* lcl_GetRowPropertySet()
601 static const SfxItemPropertyMapEntry aRowPropertyMap_Impl[] =
603 {OUString(SC_UNONAME_ABSNAME), SC_WID_UNO_ABSNAME, cppu::UnoType<OUString>::get(), 0 | beans::PropertyAttribute::READONLY, 0 },
604 {OUString(SC_UNONAME_ASIANVERT),ATTR_VERTICAL_ASIAN,getBooleanCppuType(), 0, 0 },
605 {OUString(SC_UNONAME_BOTTBORDER),ATTR_BORDER, ::cppu::UnoType<table::BorderLine>::get(), 0, BOTTOM_BORDER | CONVERT_TWIPS },
606 {OUString(SC_UNONAME_BOTTBORDER2),ATTR_BORDER, ::cppu::UnoType<table::BorderLine2>::get(), 0, BOTTOM_BORDER | CONVERT_TWIPS },
607 {OUString(SC_UNONAME_CELLBACK), ATTR_BACKGROUND, cppu::UnoType<sal_Int32>::get(), 0, MID_BACK_COLOR },
608 {OUString(SC_UNONAME_CELLPRO), ATTR_PROTECTION, cppu::UnoType<util::CellProtection>::get(), 0, 0 },
609 {OUString(SC_UNONAME_CELLSTYL), SC_WID_UNO_CELLSTYL,cppu::UnoType<OUString>::get(), 0, 0 },
610 {OUString(SC_UNONAME_CCOLOR), ATTR_FONT_COLOR, cppu::UnoType<sal_Int32>::get(), 0, 0 },
611 {OUString(SC_UNONAME_COUTL), ATTR_FONT_CONTOUR, getBooleanCppuType(), 0, 0 },
612 {OUString(SC_UNONAME_CCROSS), ATTR_FONT_CROSSEDOUT,getBooleanCppuType(), 0, MID_CROSSED_OUT },
613 {OUString(SC_UNONAME_CEMPHAS), ATTR_FONT_EMPHASISMARK,cppu::UnoType<sal_Int16>::get(), 0, MID_EMPHASIS },
614 {OUString(SC_UNONAME_CFONT), ATTR_FONT, cppu::UnoType<sal_Int16>::get(), 0, MID_FONT_FAMILY },
615 {OUString(SC_UNONAME_CFCHARS), ATTR_FONT, cppu::UnoType<sal_Int16>::get(), 0, MID_FONT_CHAR_SET },
616 {OUString(SC_UNO_CJK_CFCHARS), ATTR_CJK_FONT, cppu::UnoType<sal_Int16>::get(), 0, MID_FONT_CHAR_SET },
617 {OUString(SC_UNO_CTL_CFCHARS), ATTR_CTL_FONT, cppu::UnoType<sal_Int16>::get(), 0, MID_FONT_CHAR_SET },
618 {OUString(SC_UNONAME_CFFAMIL), ATTR_FONT, cppu::UnoType<sal_Int16>::get(), 0, MID_FONT_FAMILY },
619 {OUString(SC_UNO_CJK_CFFAMIL), ATTR_CJK_FONT, cppu::UnoType<sal_Int16>::get(), 0, MID_FONT_FAMILY },
620 {OUString(SC_UNO_CTL_CFFAMIL), ATTR_CTL_FONT, cppu::UnoType<sal_Int16>::get(), 0, MID_FONT_FAMILY },
621 {OUString(SC_UNONAME_CFNAME), ATTR_FONT, cppu::UnoType<OUString>::get(), 0, MID_FONT_FAMILY_NAME },
622 {OUString(SC_UNO_CJK_CFNAME), ATTR_CJK_FONT, cppu::UnoType<OUString>::get(), 0, MID_FONT_FAMILY_NAME },
623 {OUString(SC_UNO_CTL_CFNAME), ATTR_CTL_FONT, cppu::UnoType<OUString>::get(), 0, MID_FONT_FAMILY_NAME },
624 {OUString(SC_UNONAME_CFPITCH), ATTR_FONT, cppu::UnoType<sal_Int16>::get(), 0, MID_FONT_PITCH },
625 {OUString(SC_UNO_CJK_CFPITCH), ATTR_CJK_FONT, cppu::UnoType<sal_Int16>::get(), 0, MID_FONT_PITCH },
626 {OUString(SC_UNO_CTL_CFPITCH), ATTR_CTL_FONT, cppu::UnoType<sal_Int16>::get(), 0, MID_FONT_PITCH },
627 {OUString(SC_UNONAME_CFSTYLE), ATTR_FONT, cppu::UnoType<OUString>::get(), 0, MID_FONT_STYLE_NAME },
628 {OUString(SC_UNO_CJK_CFSTYLE), ATTR_CJK_FONT, cppu::UnoType<OUString>::get(), 0, MID_FONT_STYLE_NAME },
629 {OUString(SC_UNO_CTL_CFSTYLE), ATTR_CTL_FONT, cppu::UnoType<OUString>::get(), 0, MID_FONT_STYLE_NAME },
630 {OUString(SC_UNONAME_CHEIGHT), ATTR_FONT_HEIGHT, cppu::UnoType<float>::get(), 0, MID_FONTHEIGHT | CONVERT_TWIPS },
631 {OUString(SC_UNO_CJK_CHEIGHT), ATTR_CJK_FONT_HEIGHT,cppu::UnoType<float>::get(), 0, MID_FONTHEIGHT | CONVERT_TWIPS },
632 {OUString(SC_UNO_CTL_CHEIGHT), ATTR_CTL_FONT_HEIGHT,cppu::UnoType<float>::get(), 0, MID_FONTHEIGHT | CONVERT_TWIPS },
633 {OUString(SC_UNONAME_CLOCAL), ATTR_FONT_LANGUAGE, cppu::UnoType<lang::Locale>::get(), 0, MID_LANG_LOCALE },
634 {OUString(SC_UNO_CJK_CLOCAL), ATTR_CJK_FONT_LANGUAGE,cppu::UnoType<lang::Locale>::get(), 0, MID_LANG_LOCALE },
635 {OUString(SC_UNO_CTL_CLOCAL), ATTR_CTL_FONT_LANGUAGE,cppu::UnoType<lang::Locale>::get(), 0, MID_LANG_LOCALE },
636 {OUString(SC_UNONAME_COVER), ATTR_FONT_OVERLINE, cppu::UnoType<sal_Int16>::get(), 0, MID_TL_STYLE },
637 {OUString(SC_UNONAME_COVRLCOL), ATTR_FONT_OVERLINE, cppu::UnoType<sal_Int32>::get(), 0, MID_TL_COLOR },
638 {OUString(SC_UNONAME_COVRLHAS), ATTR_FONT_OVERLINE, getBooleanCppuType(), 0, MID_TL_HASCOLOR },
639 {OUString(SC_UNONAME_CPOST), ATTR_FONT_POSTURE, cppu::UnoType<awt::FontSlant>::get(), 0, MID_POSTURE },
640 {OUString(SC_UNO_CJK_CPOST), ATTR_CJK_FONT_POSTURE,cppu::UnoType<awt::FontSlant>::get(), 0, MID_POSTURE },
641 {OUString(SC_UNO_CTL_CPOST), ATTR_CTL_FONT_POSTURE,cppu::UnoType<awt::FontSlant>::get(), 0, MID_POSTURE },
642 {OUString(SC_UNONAME_CRELIEF), ATTR_FONT_RELIEF, cppu::UnoType<sal_Int16>::get(), 0, MID_RELIEF },
643 {OUString(SC_UNONAME_CSHADD), ATTR_FONT_SHADOWED, getBooleanCppuType(), 0, 0 },
644 {OUString(SC_UNONAME_CSTRIKE), ATTR_FONT_CROSSEDOUT,cppu::UnoType<sal_Int16>::get(), 0, MID_CROSS_OUT },
645 {OUString(SC_UNONAME_CUNDER), ATTR_FONT_UNDERLINE,cppu::UnoType<sal_Int16>::get(), 0, MID_TL_STYLE },
646 {OUString(SC_UNONAME_CUNDLCOL), ATTR_FONT_UNDERLINE,cppu::UnoType<sal_Int32>::get(), 0, MID_TL_COLOR },
647 {OUString(SC_UNONAME_CUNDLHAS), ATTR_FONT_UNDERLINE,getBooleanCppuType(), 0, MID_TL_HASCOLOR },
648 {OUString(SC_UNONAME_CWEIGHT), ATTR_FONT_WEIGHT, cppu::UnoType<float>::get(), 0, MID_WEIGHT },
649 {OUString(SC_UNO_CJK_CWEIGHT), ATTR_CJK_FONT_WEIGHT,cppu::UnoType<float>::get(), 0, MID_WEIGHT },
650 {OUString(SC_UNO_CTL_CWEIGHT), ATTR_CTL_FONT_WEIGHT,cppu::UnoType<float>::get(), 0, MID_WEIGHT },
651 {OUString(SC_UNONAME_CWORDMOD), ATTR_FONT_WORDLINE, getBooleanCppuType(), 0, 0 },
652 {OUString(SC_UNONAME_CHCOLHDR), SC_WID_UNO_CHCOLHDR,getBooleanCppuType(), 0, 0 },
653 {OUString(SC_UNONAME_CHROWHDR), SC_WID_UNO_CHROWHDR,getBooleanCppuType(), 0, 0 },
654 {OUString(SC_UNONAME_CONDFMT), SC_WID_UNO_CONDFMT, cppu::UnoType<sheet::XSheetConditionalEntries>::get(), 0, 0 },
655 {OUString(SC_UNONAME_CONDLOC), SC_WID_UNO_CONDLOC, cppu::UnoType<sheet::XSheetConditionalEntries>::get(), 0, 0 },
656 {OUString(SC_UNONAME_CONDXML), SC_WID_UNO_CONDXML, cppu::UnoType<sheet::XSheetConditionalEntries>::get(), 0, 0 },
657 {OUString(SC_UNONAME_DIAGONAL_BLTR), ATTR_BORDER_BLTR, ::cppu::UnoType<table::BorderLine>::get(), 0, 0 | CONVERT_TWIPS },
658 {OUString(SC_UNONAME_DIAGONAL_BLTR2), ATTR_BORDER_BLTR, ::cppu::UnoType<table::BorderLine2>::get(), 0, 0 | CONVERT_TWIPS },
659 {OUString(SC_UNONAME_DIAGONAL_TLBR), ATTR_BORDER_TLBR, ::cppu::UnoType<table::BorderLine>::get(), 0, 0 | CONVERT_TWIPS },
660 {OUString(SC_UNONAME_DIAGONAL_TLBR2), ATTR_BORDER_TLBR, ::cppu::UnoType<table::BorderLine2>::get(), 0, 0 | CONVERT_TWIPS },
661 {OUString(SC_UNONAME_CELLHGT), SC_WID_UNO_CELLHGT, cppu::UnoType<sal_Int32>::get(), 0, 0 },
662 {OUString(SC_UNONAME_CELLHJUS), ATTR_HOR_JUSTIFY, cppu::UnoType<table::CellHoriJustify>::get(), 0, MID_HORJUST_HORJUST },
663 {OUString(SC_UNONAME_CELLHJUS_METHOD), ATTR_HOR_JUSTIFY_METHOD, ::cppu::UnoType<sal_Int32>::get(), 0, 0 },
664 {OUString(SC_UNONAME_CELLTRAN), ATTR_BACKGROUND, getBooleanCppuType(), 0, MID_GRAPHIC_TRANSPARENT },
665 {OUString(SC_UNONAME_CELLFILT), SC_WID_UNO_CELLFILT,getBooleanCppuType(), 0, 0 },
666 {OUString(SC_UNONAME_MANPAGE), SC_WID_UNO_MANPAGE, getBooleanCppuType(), 0, 0 },
667 {OUString(SC_UNONAME_NEWPAGE), SC_WID_UNO_NEWPAGE, getBooleanCppuType(), 0, 0 },
668 {OUString(SC_UNONAME_WRAP), ATTR_LINEBREAK, getBooleanCppuType(), 0, 0 },
669 {OUString(SC_UNONAME_CELLVIS), SC_WID_UNO_CELLVIS, getBooleanCppuType(), 0, 0 },
670 {OUString(SC_UNONAME_LEFTBORDER),ATTR_BORDER, ::cppu::UnoType<table::BorderLine>::get(), 0, LEFT_BORDER | CONVERT_TWIPS },
671 {OUString(SC_UNONAME_LEFTBORDER2),ATTR_BORDER, ::cppu::UnoType<table::BorderLine2>::get(), 0, LEFT_BORDER | CONVERT_TWIPS },
672 {OUString(SC_UNONAME_NUMFMT), ATTR_VALUE_FORMAT, cppu::UnoType<sal_Int32>::get(), 0, 0 },
673 {OUString(SC_UNONAME_NUMRULES), SC_WID_UNO_NUMRULES,cppu::UnoType<container::XIndexReplace>::get(), 0, 0 },
674 {OUString(SC_UNONAME_OHEIGHT), SC_WID_UNO_OHEIGHT, getBooleanCppuType(), 0, 0 },
675 {OUString(SC_UNONAME_CELLORI), ATTR_STACKED, cppu::UnoType<table::CellOrientation>::get(), 0, 0 },
676 {OUString(SC_UNONAME_PADJUST), ATTR_HOR_JUSTIFY, ::cppu::UnoType<sal_Int16>::get(), 0, MID_HORJUST_ADJUST },
677 {OUString(SC_UNONAME_PBMARGIN), ATTR_MARGIN, cppu::UnoType<sal_Int32>::get(), 0, MID_MARGIN_LO_MARGIN | CONVERT_TWIPS },
678 {OUString(SC_UNONAME_PINDENT), ATTR_INDENT, cppu::UnoType<sal_Int16>::get(), 0, 0 }, //! CONVERT_TWIPS
679 {OUString(SC_UNONAME_PISCHDIST),ATTR_SCRIPTSPACE, getBooleanCppuType(), 0, 0 },
680 {OUString(SC_UNONAME_PISFORBID),ATTR_FORBIDDEN_RULES,getBooleanCppuType(), 0, 0 },
681 {OUString(SC_UNONAME_PISHANG), ATTR_HANGPUNCTUATION,getBooleanCppuType(), 0, 0 },
682 {OUString(SC_UNONAME_PISHYPHEN),ATTR_HYPHENATE, getBooleanCppuType(), 0, 0 },
683 {OUString(SC_UNONAME_PLASTADJ), ATTR_HOR_JUSTIFY, ::cppu::UnoType<sal_Int16>::get(), 0, MID_HORJUST_ADJUST },
684 {OUString(SC_UNONAME_PLMARGIN), ATTR_MARGIN, cppu::UnoType<sal_Int32>::get(), 0, MID_MARGIN_L_MARGIN | CONVERT_TWIPS },
685 {OUString(SC_UNONAME_PRMARGIN), ATTR_MARGIN, cppu::UnoType<sal_Int32>::get(), 0, MID_MARGIN_R_MARGIN | CONVERT_TWIPS },
686 {OUString(SC_UNONAME_PTMARGIN), ATTR_MARGIN, cppu::UnoType<sal_Int32>::get(), 0, MID_MARGIN_UP_MARGIN | CONVERT_TWIPS },
687 {OUString(SC_UNONAME_POS), SC_WID_UNO_POS, cppu::UnoType<awt::Point>::get(), 0 | beans::PropertyAttribute::READONLY, 0 },
688 {OUString(SC_UNONAME_RIGHTBORDER),ATTR_BORDER, ::cppu::UnoType<table::BorderLine>::get(), 0, RIGHT_BORDER | CONVERT_TWIPS },
689 {OUString(SC_UNONAME_RIGHTBORDER2),ATTR_BORDER, ::cppu::UnoType<table::BorderLine2>::get(), 0, RIGHT_BORDER | CONVERT_TWIPS },
690 {OUString(SC_UNONAME_ROTANG), ATTR_ROTATE_VALUE, cppu::UnoType<sal_Int32>::get(), 0, 0 },
691 {OUString(SC_UNONAME_ROTREF), ATTR_ROTATE_MODE, cppu::UnoType<sal_Int32>::get(), 0, 0 },
692 {OUString(SC_UNONAME_SHADOW), ATTR_SHADOW, cppu::UnoType<table::ShadowFormat>::get(), 0, 0 | CONVERT_TWIPS },
693 {OUString(SC_UNONAME_SHRINK_TO_FIT), ATTR_SHRINKTOFIT, getBooleanCppuType(), 0, 0 },
694 {OUString(SC_UNONAME_SIZE), SC_WID_UNO_SIZE, cppu::UnoType<awt::Size>::get(), 0 | beans::PropertyAttribute::READONLY, 0 },
695 {OUString(SC_UNONAME_TBLBORD), SC_WID_UNO_TBLBORD, cppu::UnoType<table::TableBorder>::get(), 0, 0 | CONVERT_TWIPS },
696 {OUString(SC_UNONAME_TBLBORD2), SC_WID_UNO_TBLBORD2, cppu::UnoType<table::TableBorder2>::get(), 0, 0 | CONVERT_TWIPS },
697 {OUString(SC_UNONAME_TOPBORDER),ATTR_BORDER, ::cppu::UnoType<table::BorderLine>::get(), 0, TOP_BORDER | CONVERT_TWIPS },
698 {OUString(SC_UNONAME_TOPBORDER2),ATTR_BORDER, ::cppu::UnoType<table::BorderLine2>::get(), 0, TOP_BORDER | CONVERT_TWIPS },
699 {OUString(SC_UNONAME_USERDEF), ATTR_USERDEF, cppu::UnoType<container::XNameContainer>::get(), 0, 0 },
700 {OUString(SC_UNONAME_VALIDAT), SC_WID_UNO_VALIDAT, cppu::UnoType<beans::XPropertySet>::get(), 0, 0 },
701 {OUString(SC_UNONAME_VALILOC), SC_WID_UNO_VALILOC, cppu::UnoType<beans::XPropertySet>::get(), 0, 0 },
702 {OUString(SC_UNONAME_VALIXML), SC_WID_UNO_VALIXML, cppu::UnoType<beans::XPropertySet>::get(), 0, 0 },
703 {OUString(SC_UNONAME_CELLVJUS), ATTR_VER_JUSTIFY, cppu::UnoType<sal_Int32>::get(), 0, 0 },
704 {OUString(SC_UNONAME_CELLVJUS_METHOD), ATTR_VER_JUSTIFY_METHOD, ::cppu::UnoType<sal_Int32>::get(), 0, 0 },
705 {OUString(SC_UNONAME_WRITING), ATTR_WRITINGDIR, cppu::UnoType<sal_Int16>::get(), 0, 0 },
706 { OUString(), 0, css::uno::Type(), 0, 0 }
708 static SfxItemPropertySet aRowPropertySet( aRowPropertyMap_Impl );
709 return &aRowPropertySet;
712 static const SfxItemPropertySet* lcl_GetSheetPropertySet()
714 static const SfxItemPropertyMapEntry aSheetPropertyMap_Impl[] =
716 {OUString(SC_UNONAME_ABSNAME), SC_WID_UNO_ABSNAME, cppu::UnoType<OUString>::get(), 0 | beans::PropertyAttribute::READONLY, 0 },
717 {OUString(SC_UNONAME_ASIANVERT),ATTR_VERTICAL_ASIAN,getBooleanCppuType(), 0, 0 },
718 {OUString(SC_UNONAME_AUTOPRINT),SC_WID_UNO_AUTOPRINT,getBooleanCppuType(), 0, 0 },
719 {OUString(SC_UNONAME_BORDCOL), SC_WID_UNO_BORDCOL, cppu::UnoType<sal_Int32>::get(), 0, 0 },
720 {OUString(SC_UNONAME_BOTTBORDER),ATTR_BORDER, ::cppu::UnoType<table::BorderLine>::get(), 0, BOTTOM_BORDER | CONVERT_TWIPS },
721 {OUString(SC_UNONAME_BOTTBORDER2),ATTR_BORDER, ::cppu::UnoType<table::BorderLine2>::get(), 0, BOTTOM_BORDER | CONVERT_TWIPS },
722 {OUString(SC_UNONAME_CELLBACK), ATTR_BACKGROUND, cppu::UnoType<sal_Int32>::get(), 0, MID_BACK_COLOR },
723 {OUString(SC_UNONAME_CELLPRO), ATTR_PROTECTION, cppu::UnoType<util::CellProtection>::get(), 0, 0 },
724 {OUString(SC_UNONAME_CELLSTYL), SC_WID_UNO_CELLSTYL,cppu::UnoType<OUString>::get(), 0, 0 },
725 {OUString(SC_UNONAME_CCOLOR), ATTR_FONT_COLOR, cppu::UnoType<sal_Int32>::get(), 0, 0 },
726 {OUString(SC_UNONAME_COUTL), ATTR_FONT_CONTOUR, getBooleanCppuType(), 0, 0 },
727 {OUString(SC_UNONAME_CCROSS), ATTR_FONT_CROSSEDOUT,getBooleanCppuType(), 0, MID_CROSSED_OUT },
728 {OUString(SC_UNONAME_CEMPHAS), ATTR_FONT_EMPHASISMARK,cppu::UnoType<sal_Int16>::get(), 0, MID_EMPHASIS },
729 {OUString(SC_UNONAME_CFONT), ATTR_FONT, cppu::UnoType<sal_Int16>::get(), 0, MID_FONT_FAMILY },
730 {OUString(SC_UNONAME_CFCHARS), ATTR_FONT, cppu::UnoType<sal_Int16>::get(), 0, MID_FONT_CHAR_SET },
731 {OUString(SC_UNO_CJK_CFCHARS), ATTR_CJK_FONT, cppu::UnoType<sal_Int16>::get(), 0, MID_FONT_CHAR_SET },
732 {OUString(SC_UNO_CTL_CFCHARS), ATTR_CTL_FONT, cppu::UnoType<sal_Int16>::get(), 0, MID_FONT_CHAR_SET },
733 {OUString(SC_UNONAME_CFFAMIL), ATTR_FONT, cppu::UnoType<sal_Int16>::get(), 0, MID_FONT_FAMILY },
734 {OUString(SC_UNO_CJK_CFFAMIL), ATTR_CJK_FONT, cppu::UnoType<sal_Int16>::get(), 0, MID_FONT_FAMILY },
735 {OUString(SC_UNO_CTL_CFFAMIL), ATTR_CTL_FONT, cppu::UnoType<sal_Int16>::get(), 0, MID_FONT_FAMILY },
736 {OUString(SC_UNONAME_CFNAME), ATTR_FONT, cppu::UnoType<OUString>::get(), 0, MID_FONT_FAMILY_NAME },
737 {OUString(SC_UNO_CJK_CFNAME), ATTR_CJK_FONT, cppu::UnoType<OUString>::get(), 0, MID_FONT_FAMILY_NAME },
738 {OUString(SC_UNO_CTL_CFNAME), ATTR_CTL_FONT, cppu::UnoType<OUString>::get(), 0, MID_FONT_FAMILY_NAME },
739 {OUString(SC_UNONAME_CFPITCH), ATTR_FONT, cppu::UnoType<sal_Int16>::get(), 0, MID_FONT_PITCH },
740 {OUString(SC_UNO_CJK_CFPITCH), ATTR_CJK_FONT, cppu::UnoType<sal_Int16>::get(), 0, MID_FONT_PITCH },
741 {OUString(SC_UNO_CTL_CFPITCH), ATTR_CTL_FONT, cppu::UnoType<sal_Int16>::get(), 0, MID_FONT_PITCH },
742 {OUString(SC_UNONAME_CFSTYLE), ATTR_FONT, cppu::UnoType<OUString>::get(), 0, MID_FONT_STYLE_NAME },
743 {OUString(SC_UNO_CJK_CFSTYLE), ATTR_CJK_FONT, cppu::UnoType<OUString>::get(), 0, MID_FONT_STYLE_NAME },
744 {OUString(SC_UNO_CTL_CFSTYLE), ATTR_CTL_FONT, cppu::UnoType<OUString>::get(), 0, MID_FONT_STYLE_NAME },
745 {OUString(SC_UNONAME_CHEIGHT), ATTR_FONT_HEIGHT, cppu::UnoType<float>::get(), 0, MID_FONTHEIGHT | CONVERT_TWIPS },
746 {OUString(SC_UNO_CJK_CHEIGHT), ATTR_CJK_FONT_HEIGHT,cppu::UnoType<float>::get(), 0, MID_FONTHEIGHT | CONVERT_TWIPS },
747 {OUString(SC_UNO_CTL_CHEIGHT), ATTR_CTL_FONT_HEIGHT,cppu::UnoType<float>::get(), 0, MID_FONTHEIGHT | CONVERT_TWIPS },
748 {OUString(SC_UNONAME_CLOCAL), ATTR_FONT_LANGUAGE, cppu::UnoType<lang::Locale>::get(), 0, MID_LANG_LOCALE },
749 {OUString(SC_UNO_CJK_CLOCAL), ATTR_CJK_FONT_LANGUAGE,cppu::UnoType<lang::Locale>::get(), 0, MID_LANG_LOCALE },
750 {OUString(SC_UNO_CTL_CLOCAL), ATTR_CTL_FONT_LANGUAGE,cppu::UnoType<lang::Locale>::get(), 0, MID_LANG_LOCALE },
751 {OUString(SC_UNONAME_COVER), ATTR_FONT_OVERLINE, cppu::UnoType<sal_Int16>::get(), 0, MID_TL_STYLE },
752 {OUString(SC_UNONAME_COVRLCOL), ATTR_FONT_OVERLINE, cppu::UnoType<sal_Int32>::get(), 0, MID_TL_COLOR },
753 {OUString(SC_UNONAME_COVRLHAS), ATTR_FONT_OVERLINE, getBooleanCppuType(), 0, MID_TL_HASCOLOR },
754 {OUString(SC_UNONAME_CPOST), ATTR_FONT_POSTURE, cppu::UnoType<awt::FontSlant>::get(), 0, MID_POSTURE },
755 {OUString(SC_UNO_CJK_CPOST), ATTR_CJK_FONT_POSTURE,cppu::UnoType<awt::FontSlant>::get(), 0, MID_POSTURE },
756 {OUString(SC_UNO_CTL_CPOST), ATTR_CTL_FONT_POSTURE,cppu::UnoType<awt::FontSlant>::get(), 0, MID_POSTURE },
757 {OUString(SC_UNONAME_CRELIEF), ATTR_FONT_RELIEF, cppu::UnoType<sal_Int16>::get(), 0, MID_RELIEF },
758 {OUString(SC_UNONAME_CSHADD), ATTR_FONT_SHADOWED, getBooleanCppuType(), 0, 0 },
759 {OUString(SC_UNONAME_CSTRIKE), ATTR_FONT_CROSSEDOUT,cppu::UnoType<sal_Int16>::get(), 0, MID_CROSS_OUT },
760 {OUString(SC_UNONAME_CUNDER), ATTR_FONT_UNDERLINE,cppu::UnoType<sal_Int16>::get(), 0, MID_TL_STYLE },
761 {OUString(SC_UNONAME_CUNDLCOL), ATTR_FONT_UNDERLINE,cppu::UnoType<sal_Int32>::get(), 0, MID_TL_COLOR },
762 {OUString(SC_UNONAME_CUNDLHAS), ATTR_FONT_UNDERLINE,getBooleanCppuType(), 0, MID_TL_HASCOLOR },
763 {OUString(SC_UNONAME_CWEIGHT), ATTR_FONT_WEIGHT, cppu::UnoType<float>::get(), 0, MID_WEIGHT },
764 {OUString(SC_UNO_CJK_CWEIGHT), ATTR_CJK_FONT_WEIGHT,cppu::UnoType<float>::get(), 0, MID_WEIGHT },
765 {OUString(SC_UNO_CTL_CWEIGHT), ATTR_CTL_FONT_WEIGHT,cppu::UnoType<float>::get(), 0, MID_WEIGHT },
766 {OUString(SC_UNONAME_CWORDMOD), ATTR_FONT_WORDLINE, getBooleanCppuType(), 0, 0 },
767 {OUString(SC_UNONAME_CHCOLHDR), SC_WID_UNO_CHCOLHDR,getBooleanCppuType(), 0, 0 },
768 {OUString(SC_UNONAME_CHROWHDR), SC_WID_UNO_CHROWHDR,getBooleanCppuType(), 0, 0 },
769 {OUString(SC_UNONAME_CONDFMT), SC_WID_UNO_CONDFMT, cppu::UnoType<sheet::XSheetConditionalEntries>::get(), 0, 0 },
770 {OUString(SC_UNONAME_CONDLOC), SC_WID_UNO_CONDLOC, cppu::UnoType<sheet::XSheetConditionalEntries>::get(), 0, 0 },
771 {OUString(SC_UNONAME_CONDXML), SC_WID_UNO_CONDXML, cppu::UnoType<sheet::XSheetConditionalEntries>::get(), 0, 0 },
772 {OUString(SC_UNONAME_COPYBACK), SC_WID_UNO_COPYBACK,getBooleanCppuType(), 0, 0 },
773 {OUString(SC_UNONAME_COPYFORM), SC_WID_UNO_COPYFORM,getBooleanCppuType(), 0, 0 },
774 {OUString(SC_UNONAME_COPYSTYL), SC_WID_UNO_COPYSTYL,getBooleanCppuType(), 0, 0 },
775 {OUString(SC_UNONAME_DIAGONAL_BLTR), ATTR_BORDER_BLTR, ::cppu::UnoType<table::BorderLine>::get(), 0, 0 | CONVERT_TWIPS },
776 {OUString(SC_UNONAME_DIAGONAL_BLTR2), ATTR_BORDER_BLTR, ::cppu::UnoType<table::BorderLine2>::get(), 0, 0 | CONVERT_TWIPS },
777 {OUString(SC_UNONAME_DIAGONAL_TLBR), ATTR_BORDER_TLBR, ::cppu::UnoType<table::BorderLine>::get(), 0, 0 | CONVERT_TWIPS },
778 {OUString(SC_UNONAME_DIAGONAL_TLBR2), ATTR_BORDER_TLBR, ::cppu::UnoType<table::BorderLine2>::get(), 0, 0 | CONVERT_TWIPS },
779 {OUString(SC_UNONAME_CELLHJUS), ATTR_HOR_JUSTIFY, cppu::UnoType<table::CellHoriJustify>::get(), 0, MID_HORJUST_HORJUST },
780 {OUString(SC_UNONAME_CELLHJUS_METHOD), ATTR_HOR_JUSTIFY_METHOD, ::cppu::UnoType<sal_Int32>::get(), 0, 0 },
781 {OUString(SC_UNONAME_ISACTIVE), SC_WID_UNO_ISACTIVE,getBooleanCppuType(), 0, 0 },
782 {OUString(SC_UNONAME_CELLTRAN), ATTR_BACKGROUND, getBooleanCppuType(), 0, MID_GRAPHIC_TRANSPARENT },
783 {OUString(SC_UNONAME_WRAP), ATTR_LINEBREAK, getBooleanCppuType(), 0, 0 },
784 {OUString(SC_UNONAME_CELLVIS), SC_WID_UNO_CELLVIS, getBooleanCppuType(), 0, 0 },
785 {OUString(SC_UNONAME_LEFTBORDER),ATTR_BORDER, ::cppu::UnoType<table::BorderLine>::get(), 0, LEFT_BORDER | CONVERT_TWIPS },
786 {OUString(SC_UNONAME_LEFTBORDER2),ATTR_BORDER, ::cppu::UnoType<table::BorderLine2>::get(), 0, LEFT_BORDER | CONVERT_TWIPS },
787 {OUString(SC_UNO_LINKDISPBIT), SC_WID_UNO_LINKDISPBIT,cppu::UnoType<awt::XBitmap>::get(), 0 | beans::PropertyAttribute::READONLY, 0 },
788 {OUString(SC_UNO_LINKDISPNAME), SC_WID_UNO_LINKDISPNAME,cppu::UnoType<OUString>::get(), 0 | beans::PropertyAttribute::READONLY, 0 },
789 {OUString(SC_UNONAME_NUMFMT), ATTR_VALUE_FORMAT, cppu::UnoType<sal_Int32>::get(), 0, 0 },
790 {OUString(SC_UNONAME_NUMRULES), SC_WID_UNO_NUMRULES,cppu::UnoType<container::XIndexReplace>::get(), 0, 0 },
791 {OUString(SC_UNONAME_CELLORI), ATTR_STACKED, cppu::UnoType<table::CellOrientation>::get(), 0, 0 },
792 {OUString(SC_UNONAME_PAGESTL), SC_WID_UNO_PAGESTL, cppu::UnoType<OUString>::get(), 0, 0 },
793 {OUString(SC_UNONAME_PADJUST), ATTR_HOR_JUSTIFY, ::cppu::UnoType<sal_Int16>::get(), 0, MID_HORJUST_ADJUST },
794 {OUString(SC_UNONAME_PBMARGIN), ATTR_MARGIN, cppu::UnoType<sal_Int32>::get(), 0, MID_MARGIN_LO_MARGIN | CONVERT_TWIPS },
795 {OUString(SC_UNONAME_PINDENT), ATTR_INDENT, cppu::UnoType<sal_Int16>::get(), 0, 0 }, //! CONVERT_TWIPS
796 {OUString(SC_UNONAME_PISCHDIST),ATTR_SCRIPTSPACE, getBooleanCppuType(), 0, 0 },
797 {OUString(SC_UNONAME_PISFORBID),ATTR_FORBIDDEN_RULES,getBooleanCppuType(), 0, 0 },
798 {OUString(SC_UNONAME_PISHANG), ATTR_HANGPUNCTUATION,getBooleanCppuType(), 0, 0 },
799 {OUString(SC_UNONAME_PISHYPHEN),ATTR_HYPHENATE, getBooleanCppuType(), 0, 0 },
800 {OUString(SC_UNONAME_PLASTADJ), ATTR_HOR_JUSTIFY, ::cppu::UnoType<sal_Int16>::get(), 0, MID_HORJUST_ADJUST },
801 {OUString(SC_UNONAME_PLMARGIN), ATTR_MARGIN, cppu::UnoType<sal_Int32>::get(), 0, MID_MARGIN_L_MARGIN | CONVERT_TWIPS },
802 {OUString(SC_UNONAME_PRMARGIN), ATTR_MARGIN, cppu::UnoType<sal_Int32>::get(), 0, MID_MARGIN_R_MARGIN | CONVERT_TWIPS },
803 {OUString(SC_UNONAME_PTMARGIN), ATTR_MARGIN, cppu::UnoType<sal_Int32>::get(), 0, MID_MARGIN_UP_MARGIN | CONVERT_TWIPS },
804 {OUString(SC_UNONAME_POS), SC_WID_UNO_POS, cppu::UnoType<awt::Point>::get(), 0 | beans::PropertyAttribute::READONLY, 0 },
805 {OUString(SC_UNONAME_PRINTBORD),SC_WID_UNO_PRINTBORD,getBooleanCppuType(), 0, 0 },
806 {OUString(SC_UNONAME_PROTECT), SC_WID_UNO_PROTECT, getBooleanCppuType(), 0, 0 },
807 {OUString(SC_UNONAME_RIGHTBORDER),ATTR_BORDER, ::cppu::UnoType<table::BorderLine>::get(), 0, RIGHT_BORDER | CONVERT_TWIPS },
808 {OUString(SC_UNONAME_RIGHTBORDER2),ATTR_BORDER, ::cppu::UnoType<table::BorderLine2>::get(), 0, RIGHT_BORDER | CONVERT_TWIPS },
809 {OUString(SC_UNONAME_ROTANG), ATTR_ROTATE_VALUE, cppu::UnoType<sal_Int32>::get(), 0, 0 },
810 {OUString(SC_UNONAME_ROTREF), ATTR_ROTATE_MODE, cppu::UnoType<sal_Int32>::get(), 0, 0 },
811 {OUString(SC_UNONAME_SHADOW), ATTR_SHADOW, cppu::UnoType<table::ShadowFormat>::get(), 0, 0 | CONVERT_TWIPS },
812 {OUString(SC_UNONAME_SHOWBORD), SC_WID_UNO_SHOWBORD,getBooleanCppuType(), 0, 0 },
813 {OUString(SC_UNONAME_SHRINK_TO_FIT), ATTR_SHRINKTOFIT, getBooleanCppuType(), 0, 0 },
814 {OUString(SC_UNONAME_SIZE), SC_WID_UNO_SIZE, cppu::UnoType<awt::Size>::get(), 0 | beans::PropertyAttribute::READONLY, 0 },
815 {OUString(SC_UNONAME_TBLBORD), SC_WID_UNO_TBLBORD, cppu::UnoType<table::TableBorder>::get(), 0, 0 | CONVERT_TWIPS },
816 {OUString(SC_UNONAME_TBLBORD2), SC_WID_UNO_TBLBORD2, cppu::UnoType<table::TableBorder2>::get(), 0, 0 | CONVERT_TWIPS },
817 {OUString(SC_UNONAME_TABLAYOUT),SC_WID_UNO_TABLAYOUT,cppu::UnoType<sal_Int16>::get(), 0, 0 },
818 {OUString(SC_UNONAME_TOPBORDER),ATTR_BORDER, ::cppu::UnoType<table::BorderLine>::get(), 0, TOP_BORDER | CONVERT_TWIPS },
819 {OUString(SC_UNONAME_TOPBORDER2),ATTR_BORDER, ::cppu::UnoType<table::BorderLine2>::get(), 0, TOP_BORDER | CONVERT_TWIPS },
820 {OUString(SC_UNONAME_USERDEF), ATTR_USERDEF, cppu::UnoType<container::XNameContainer>::get(), 0, 0 },
821 {OUString(SC_UNONAME_VALIDAT), SC_WID_UNO_VALIDAT, cppu::UnoType<beans::XPropertySet>::get(), 0, 0 },
822 {OUString(SC_UNONAME_VALILOC), SC_WID_UNO_VALILOC, cppu::UnoType<beans::XPropertySet>::get(), 0, 0 },
823 {OUString(SC_UNONAME_VALIXML), SC_WID_UNO_VALIXML, cppu::UnoType<beans::XPropertySet>::get(), 0, 0 },
824 {OUString(SC_UNONAME_CELLVJUS), ATTR_VER_JUSTIFY, cppu::UnoType<sal_Int32>::get(), 0, 0 },
825 {OUString(SC_UNONAME_CELLVJUS_METHOD), ATTR_VER_JUSTIFY_METHOD, ::cppu::UnoType<sal_Int32>::get(), 0, 0 },
826 {OUString(SC_UNONAME_WRITING), ATTR_WRITINGDIR, cppu::UnoType<sal_Int16>::get(), 0, 0 },
827 {OUString(SC_UNONAME_TABCOLOR), SC_WID_UNO_TABCOLOR, cppu::UnoType<sal_Int32>::get(), 0, 0 },
828 {OUString(SC_UNO_CODENAME), SC_WID_UNO_CODENAME, cppu::UnoType<OUString>::get(), 0, 0},
829 {OUString(SC_UNO_NAMEDRANGES), SC_WID_UNO_NAMES, cppu::UnoType<sheet::XNamedRanges>::get(), 0, 0 },
830 { OUString(), 0, css::uno::Type(), 0, 0 }
832 static SfxItemPropertySet aSheetPropertySet( aSheetPropertyMap_Impl );
833 return &aSheetPropertySet;
836 static const SfxItemPropertyMapEntry* lcl_GetEditPropertyMap()
838 static const SfxItemPropertyMapEntry aEditPropertyMap_Impl[] =
840 SVX_UNOEDIT_CHAR_PROPERTIES,
841 SVX_UNOEDIT_FONT_PROPERTIES,
842 SVX_UNOEDIT_PARA_PROPERTIES,
843 SVX_UNOEDIT_NUMBERING_PROPERTIE, // for completeness of service ParagraphProperties
844 {OUString(SC_UNONAME_TEXTUSER), EE_CHAR_XMLATTRIBS, cppu::UnoType<container::XNameContainer>::get(), 0, 0},
845 {OUString(SC_UNONAME_USERDEF), EE_PARA_XMLATTRIBS, cppu::UnoType<container::XNameContainer>::get(), 0, 0},
846 { OUString(), 0, css::uno::Type(), 0, 0 }
848 return aEditPropertyMap_Impl;
850 static const SvxItemPropertySet* lcl_GetEditPropertySet()
852 static SvxItemPropertySet aEditPropertySet( lcl_GetEditPropertyMap(), SdrObject::GetGlobalDrawObjectItemPool() );
853 return &aEditPropertySet;
856 using sc::HMMToTwips;
857 using sc::TwipsToHMM;
859 #define SCCHARPROPERTIES_SERVICE "com.sun.star.style.CharacterProperties"
860 #define SCPARAPROPERTIES_SERVICE "com.sun.star.style.ParagraphProperties"
861 #define SCCELLPROPERTIES_SERVICE "com.sun.star.table.CellProperties"
862 #define SCCELLRANGE_SERVICE "com.sun.star.table.CellRange"
863 #define SCCELL_SERVICE "com.sun.star.table.Cell"
864 #define SCSHEETCELLRANGES_SERVICE "com.sun.star.sheet.SheetCellRanges"
865 #define SCSHEETCELLRANGE_SERVICE "com.sun.star.sheet.SheetCellRange"
866 #define SCSPREADSHEET_SERVICE "com.sun.star.sheet.Spreadsheet"
867 #define SCSHEETCELL_SERVICE "com.sun.star.sheet.SheetCell"
869 SC_SIMPLE_SERVICE_INFO( ScCellFormatsEnumeration, "ScCellFormatsEnumeration", "com.sun.star.sheet.CellFormatRangesEnumeration" )
870 SC_SIMPLE_SERVICE_INFO( ScCellFormatsObj, "ScCellFormatsObj", "com.sun.star.sheet.CellFormatRanges" )
871 SC_SIMPLE_SERVICE_INFO( ScUniqueCellFormatsEnumeration, "ScUniqueCellFormatsEnumeration", "com.sun.star.sheet.UniqueCellFormatRangesEnumeration" )
872 SC_SIMPLE_SERVICE_INFO( ScUniqueCellFormatsObj, "ScUniqueCellFormatsObj", "com.sun.star.sheet.UniqueCellFormatRanges" )
873 SC_SIMPLE_SERVICE_INFO( ScCellRangesBase, "ScCellRangesBase", "stardiv.unknown" )
874 SC_SIMPLE_SERVICE_INFO( ScCellsEnumeration, "ScCellsEnumeration", "com.sun.star.sheet.CellsEnumeration" )
875 SC_SIMPLE_SERVICE_INFO( ScCellsObj, "ScCellsObj", "com.sun.star.sheet.Cells" )
876 SC_SIMPLE_SERVICE_INFO( ScTableColumnObj, "ScTableColumnObj", "com.sun.star.table.TableColumn" )
877 SC_SIMPLE_SERVICE_INFO( ScTableRowObj, "ScTableRowObj", "com.sun.star.table.TableRow" )
879 //! ScLinkListener in anderes File verschieben !!!
881 ScLinkListener::~ScLinkListener()
885 void ScLinkListener::Notify( const SfxHint& rHint )
887 aLink.Call( (SfxHint*)&rHint );
890 static void lcl_CopyProperties( beans::XPropertySet& rDest, beans::XPropertySet& rSource )
892 uno::Reference<beans::XPropertySetInfo> xInfo(rSource.getPropertySetInfo());
893 if (xInfo.is())
895 uno::Sequence<beans::Property> aSeq(xInfo->getProperties());
896 const beans::Property* pAry = aSeq.getConstArray();
897 sal_uLong nCount = aSeq.getLength();
898 for (sal_uLong i=0; i<nCount; i++)
900 OUString aName(pAry[i].Name);
901 rDest.setPropertyValue( aName, rSource.getPropertyValue( aName ) );
906 static SCTAB lcl_FirstTab( const ScRangeList& rRanges )
908 OSL_ENSURE(rRanges.size() >= 1, "was fuer Ranges ?!?!");
909 const ScRange* pFirst = rRanges[ 0 ];
910 if (pFirst)
911 return pFirst->aStart.Tab();
913 return 0; // soll nicht sein
916 static bool lcl_WholeSheet( const ScRangeList& rRanges )
918 if ( rRanges.size() == 1 )
920 const ScRange* pRange = rRanges[0];
921 if ( pRange && pRange->aStart.Col() == 0 && pRange->aEnd.Col() == MAXCOL &&
922 pRange->aStart.Row() == 0 && pRange->aEnd.Row() == MAXROW )
923 return true;
925 return false;
928 namespace {
929 template<typename BorderLineType>
930 const ::editeng::SvxBorderLine* lcl_getBorderLine(
931 ::editeng::SvxBorderLine& rLine, const BorderLineType& rStruct )
933 // Convert from 1/100mm to Twips.
934 if (!SvxBoxItem::LineToSvxLine( rStruct, rLine, true))
935 return NULL;
937 if ( rLine.GetOutWidth() || rLine.GetInWidth() || rLine.GetDistance() )
938 return &rLine;
939 else
940 return NULL;
944 const ::editeng::SvxBorderLine* ScHelperFunctions::GetBorderLine(
945 ::editeng::SvxBorderLine& rLine, const table::BorderLine& rStruct )
947 return lcl_getBorderLine( rLine, rStruct);
950 const ::editeng::SvxBorderLine* ScHelperFunctions::GetBorderLine(
951 ::editeng::SvxBorderLine& rLine, const table::BorderLine2& rStruct )
953 return lcl_getBorderLine( rLine, rStruct);
957 namespace {
958 template<typename TableBorderType>
959 void lcl_fillBoxItems( SvxBoxItem& rOuter, SvxBoxInfoItem& rInner, const TableBorderType& rBorder )
961 ::editeng::SvxBorderLine aLine;
962 rOuter.SetDistance( (sal_uInt16)HMMToTwips( rBorder.Distance ) );
963 rOuter.SetLine( ScHelperFunctions::GetBorderLine( aLine, rBorder.TopLine ), BOX_LINE_TOP );
964 rOuter.SetLine( ScHelperFunctions::GetBorderLine( aLine, rBorder.BottomLine ), BOX_LINE_BOTTOM );
965 rOuter.SetLine( ScHelperFunctions::GetBorderLine( aLine, rBorder.LeftLine ), BOX_LINE_LEFT );
966 rOuter.SetLine( ScHelperFunctions::GetBorderLine( aLine, rBorder.RightLine ), BOX_LINE_RIGHT );
967 rInner.SetLine( ScHelperFunctions::GetBorderLine( aLine, rBorder.HorizontalLine ), BOXINFO_LINE_HORI );
968 rInner.SetLine( ScHelperFunctions::GetBorderLine( aLine, rBorder.VerticalLine ), BOXINFO_LINE_VERT );
969 rInner.SetValid( VALID_TOP, rBorder.IsTopLineValid );
970 rInner.SetValid( VALID_BOTTOM, rBorder.IsBottomLineValid );
971 rInner.SetValid( VALID_LEFT, rBorder.IsLeftLineValid );
972 rInner.SetValid( VALID_RIGHT, rBorder.IsRightLineValid );
973 rInner.SetValid( VALID_HORI, rBorder.IsHorizontalLineValid );
974 rInner.SetValid( VALID_VERT, rBorder.IsVerticalLineValid );
975 rInner.SetValid( VALID_DISTANCE, rBorder.IsDistanceValid );
976 rInner.SetTable( true );
980 void ScHelperFunctions::FillBoxItems( SvxBoxItem& rOuter, SvxBoxInfoItem& rInner, const table::TableBorder& rBorder )
982 lcl_fillBoxItems( rOuter, rInner, rBorder);
985 void ScHelperFunctions::FillBoxItems( SvxBoxItem& rOuter, SvxBoxInfoItem& rInner, const table::TableBorder2& rBorder )
987 lcl_fillBoxItems( rOuter, rInner, rBorder);
991 void ScHelperFunctions::FillBorderLine( table::BorderLine& rStruct, const ::editeng::SvxBorderLine* pLine )
993 // Convert from Twips to 1/100mm.
994 table::BorderLine2 aStruct( SvxBoxItem::SvxLineToLine( pLine, true));
995 rStruct = aStruct;
998 void ScHelperFunctions::FillBorderLine( table::BorderLine2& rStruct, const ::editeng::SvxBorderLine* pLine )
1000 rStruct = SvxBoxItem::SvxLineToLine( pLine, true);
1004 namespace {
1005 template<typename TableBorderItem>
1006 void lcl_fillTableBorder( TableBorderItem& rBorder, const SvxBoxItem& rOuter, const SvxBoxInfoItem& rInner,
1007 bool bInvalidateHorVerDist )
1009 ScHelperFunctions::FillBorderLine( rBorder.TopLine, rOuter.GetTop() );
1010 ScHelperFunctions::FillBorderLine( rBorder.BottomLine, rOuter.GetBottom() );
1011 ScHelperFunctions::FillBorderLine( rBorder.LeftLine, rOuter.GetLeft() );
1012 ScHelperFunctions::FillBorderLine( rBorder.RightLine, rOuter.GetRight() );
1013 ScHelperFunctions::FillBorderLine( rBorder.HorizontalLine, rInner.GetHori() );
1014 ScHelperFunctions::FillBorderLine( rBorder.VerticalLine, rInner.GetVert() );
1016 rBorder.Distance = rOuter.GetDistance();
1017 rBorder.IsTopLineValid = rInner.IsValid(VALID_TOP);
1018 rBorder.IsBottomLineValid = rInner.IsValid(VALID_BOTTOM);
1019 rBorder.IsLeftLineValid = rInner.IsValid(VALID_LEFT);
1020 rBorder.IsRightLineValid = rInner.IsValid(VALID_RIGHT);
1021 rBorder.IsHorizontalLineValid = !bInvalidateHorVerDist && rInner.IsValid(VALID_HORI);
1022 rBorder.IsVerticalLineValid = !bInvalidateHorVerDist && rInner.IsValid(VALID_VERT);
1023 rBorder.IsDistanceValid = !bInvalidateHorVerDist && rInner.IsValid(VALID_DISTANCE);
1027 void ScHelperFunctions::AssignTableBorderToAny( uno::Any& rAny,
1028 const SvxBoxItem& rOuter, const SvxBoxInfoItem& rInner, bool bInvalidateHorVerDist )
1030 table::TableBorder aBorder;
1031 lcl_fillTableBorder( aBorder, rOuter, rInner, bInvalidateHorVerDist);
1032 rAny <<= aBorder;
1035 void ScHelperFunctions::AssignTableBorder2ToAny( uno::Any& rAny,
1036 const SvxBoxItem& rOuter, const SvxBoxInfoItem& rInner, bool bInvalidateHorVerDist )
1038 table::TableBorder2 aBorder;
1039 lcl_fillTableBorder( aBorder, rOuter, rInner, bInvalidateHorVerDist);
1040 rAny <<= aBorder;
1043 //! lcl_ApplyBorder nach docfunc verschieben!
1045 void ScHelperFunctions::ApplyBorder( ScDocShell* pDocShell, const ScRangeList& rRanges,
1046 const SvxBoxItem& rOuter, const SvxBoxInfoItem& rInner )
1048 ScDocument* pDoc = pDocShell->GetDocument();
1049 bool bUndo(pDoc->IsUndoEnabled());
1050 ScDocument* pUndoDoc = NULL;
1051 if (bUndo)
1052 pUndoDoc = new ScDocument( SCDOCMODE_UNDO );
1053 size_t nCount = rRanges.size();
1054 for (size_t i = 0; i < nCount; ++i)
1056 ScRange aRange( *rRanges[ i ] );
1057 SCTAB nTab = aRange.aStart.Tab();
1059 if (bUndo)
1061 if ( i==0 )
1062 pUndoDoc->InitUndo( pDoc, nTab, nTab );
1063 else
1064 pUndoDoc->AddUndoTab( nTab, nTab );
1065 pDoc->CopyToDocument( aRange, IDF_ATTRIB, false, pUndoDoc );
1068 ScMarkData aMark;
1069 aMark.SetMarkArea( aRange );
1070 aMark.SelectTable( nTab, true );
1072 pDoc->ApplySelectionFrame( aMark, &rOuter, &rInner );
1073 // RowHeight bei Umrandung alleine nicht noetig
1076 if (bUndo)
1078 pDocShell->GetUndoManager()->AddUndoAction(
1079 new ScUndoBorder( pDocShell, rRanges, pUndoDoc, rOuter, rInner ) );
1082 for (size_t i = 0; i < nCount; ++i )
1083 pDocShell->PostPaint( *rRanges[ i ], PAINT_GRID, SC_PF_LINES | SC_PF_TESTMERGE );
1085 pDocShell->SetDocumentModified();
1088 //! move lcl_PutDataArray to docfunc?
1089 //! merge loop with ScFunctionAccess::callFunction
1091 static bool lcl_PutDataArray( ScDocShell& rDocShell, const ScRange& rRange,
1092 const uno::Sequence< uno::Sequence<uno::Any> >& aData )
1094 ScDocument* pDoc = rDocShell.GetDocument();
1095 SCTAB nTab = rRange.aStart.Tab();
1096 SCCOL nStartCol = rRange.aStart.Col();
1097 SCROW nStartRow = rRange.aStart.Row();
1098 SCCOL nEndCol = rRange.aEnd.Col();
1099 SCROW nEndRow = rRange.aEnd.Row();
1100 bool bUndo(pDoc->IsUndoEnabled());
1102 if ( !pDoc->IsBlockEditable( nTab, nStartCol,nStartRow, nEndCol,nEndRow ) )
1104 //! error message
1105 return false;
1108 long nCols = 0;
1109 long nRows = aData.getLength();
1110 const uno::Sequence<uno::Any>* pArray = aData.getConstArray();
1111 if ( nRows )
1112 nCols = pArray[0].getLength();
1114 if ( nCols != nEndCol-nStartCol+1 || nRows != nEndRow-nStartRow+1 )
1116 //! error message?
1117 return false;
1120 ScDocument* pUndoDoc = NULL;
1121 if ( bUndo )
1123 pUndoDoc = new ScDocument( SCDOCMODE_UNDO );
1124 pUndoDoc->InitUndo( pDoc, nTab, nTab );
1125 pDoc->CopyToDocument( rRange, IDF_CONTENTS|IDF_NOCAPTIONS, false, pUndoDoc );
1128 pDoc->DeleteAreaTab( nStartCol, nStartRow, nEndCol, nEndRow, nTab, IDF_CONTENTS );
1130 bool bError = false;
1131 SCROW nDocRow = nStartRow;
1132 for (long nRow=0; nRow<nRows; nRow++)
1134 const uno::Sequence<uno::Any>& rColSeq = pArray[nRow];
1135 if ( rColSeq.getLength() == nCols )
1137 SCCOL nDocCol = nStartCol;
1138 const uno::Any* pColArr = rColSeq.getConstArray();
1139 for (long nCol=0; nCol<nCols; nCol++)
1141 ScAddress aPos(nDocCol, nDocRow, nTab);
1143 const uno::Any& rElement = pColArr[nCol];
1144 switch( rElement.getValueTypeClass() )
1146 case uno::TypeClass_VOID:
1148 // void = "no value"
1149 pDoc->SetError( nDocCol, nDocRow, nTab, NOTAVAILABLE );
1151 break;
1153 // #87871# accept integer types because Basic passes a floating point
1154 // variable as byte, short or long if it's an integer number.
1155 case uno::TypeClass_BYTE:
1156 case uno::TypeClass_SHORT:
1157 case uno::TypeClass_UNSIGNED_SHORT:
1158 case uno::TypeClass_LONG:
1159 case uno::TypeClass_UNSIGNED_LONG:
1160 case uno::TypeClass_FLOAT:
1161 case uno::TypeClass_DOUBLE:
1163 double fVal(0.0);
1164 rElement >>= fVal;
1165 pDoc->SetValue(aPos, fVal);
1167 break;
1169 case uno::TypeClass_STRING:
1171 OUString aUStr;
1172 rElement >>= aUStr;
1173 if ( !aUStr.isEmpty() )
1175 ScSetStringParam aParam;
1176 aParam.setTextInput();
1177 pDoc->SetString(aPos, aUStr, &aParam);
1180 break;
1182 // accept Sequence<FormulaToken> for formula cells
1183 case uno::TypeClass_SEQUENCE:
1185 uno::Sequence< sheet::FormulaToken > aTokens;
1186 if ( rElement >>= aTokens )
1188 ScTokenArray aTokenArray;
1189 ScTokenConversion::ConvertToTokenArray( *pDoc, aTokenArray, aTokens );
1190 pDoc->SetFormula(aPos, aTokenArray);
1192 else
1193 bError = true;
1195 break;
1197 default:
1198 bError = true; // invalid type
1200 ++nDocCol;
1203 else
1204 bError = true; // wrong size
1206 ++nDocRow;
1209 bool bHeight = rDocShell.AdjustRowHeight( nStartRow, nEndRow, nTab );
1211 if ( pUndoDoc )
1213 ScMarkData aDestMark;
1214 aDestMark.SelectOneTable( nTab );
1215 rDocShell.GetUndoManager()->AddUndoAction(
1216 new ScUndoPaste(
1217 &rDocShell, ScRange(nStartCol, nStartRow, nTab, nEndCol, nEndRow, nTab),
1218 aDestMark, pUndoDoc, NULL, IDF_CONTENTS, NULL, false));
1221 if (!bHeight)
1222 rDocShell.PostPaint( rRange, PAINT_GRID ); // AdjustRowHeight may have painted already
1224 rDocShell.SetDocumentModified();
1226 return !bError;
1229 static bool lcl_PutFormulaArray( ScDocShell& rDocShell, const ScRange& rRange,
1230 const uno::Sequence< uno::Sequence<OUString> >& aData,
1231 const formula::FormulaGrammar::Grammar eGrammar )
1233 ScDocument* pDoc = rDocShell.GetDocument();
1234 SCTAB nTab = rRange.aStart.Tab();
1235 SCCOL nStartCol = rRange.aStart.Col();
1236 SCROW nStartRow = rRange.aStart.Row();
1237 SCCOL nEndCol = rRange.aEnd.Col();
1238 SCROW nEndRow = rRange.aEnd.Row();
1239 bool bUndo(pDoc->IsUndoEnabled());
1241 if ( !pDoc->IsBlockEditable( nTab, nStartCol,nStartRow, nEndCol,nEndRow ) )
1243 //! error message
1244 return false;
1247 long nCols = 0;
1248 long nRows = aData.getLength();
1249 const uno::Sequence<OUString>* pArray = aData.getConstArray();
1250 if ( nRows )
1251 nCols = pArray[0].getLength();
1253 if ( nCols != nEndCol-nStartCol+1 || nRows != nEndRow-nStartRow+1 )
1255 //! error message?
1256 return false;
1259 ScDocument* pUndoDoc = NULL;
1260 if ( bUndo )
1262 pUndoDoc = new ScDocument( SCDOCMODE_UNDO );
1263 pUndoDoc->InitUndo( pDoc, nTab, nTab );
1264 pDoc->CopyToDocument( rRange, IDF_CONTENTS, false, pUndoDoc );
1267 pDoc->DeleteAreaTab( nStartCol, nStartRow, nEndCol, nEndRow, nTab, IDF_CONTENTS );
1269 bool bError = false;
1270 SCROW nDocRow = nStartRow;
1271 for (long nRow=0; nRow<nRows; nRow++)
1273 const uno::Sequence<OUString>& rColSeq = pArray[nRow];
1274 if ( rColSeq.getLength() == nCols )
1276 SCCOL nDocCol = nStartCol;
1277 const OUString* pColArr = rColSeq.getConstArray();
1278 for (long nCol=0; nCol<nCols; nCol++)
1280 OUString aText(pColArr[nCol]);
1281 ScAddress aPos( nDocCol, nDocRow, nTab );
1283 ScInputStringType aRes =
1284 ScStringUtil::parseInputString(
1285 *pDoc->GetFormatTable(), aText, LANGUAGE_ENGLISH_US);
1286 switch (aRes.meType)
1288 case ScInputStringType::Formula:
1289 pDoc->SetFormula(aPos, aRes.maText, eGrammar);
1290 break;
1291 case ScInputStringType::Number:
1292 pDoc->SetValue(aPos, aRes.mfValue);
1293 break;
1294 case ScInputStringType::Text:
1295 pDoc->SetTextCell(aPos, aRes.maText);
1296 break;
1297 default:
1301 ++nDocCol;
1304 else
1305 bError = true; // wrong size
1307 ++nDocRow;
1310 bool bHeight = rDocShell.AdjustRowHeight( nStartRow, nEndRow, nTab );
1312 if ( pUndoDoc )
1314 ScMarkData aDestMark;
1315 aDestMark.SelectOneTable( nTab );
1316 rDocShell.GetUndoManager()->AddUndoAction(
1317 new ScUndoPaste( &rDocShell,
1318 ScRange(nStartCol, nStartRow, nTab, nEndCol, nEndRow, nTab), aDestMark,
1319 pUndoDoc, NULL, IDF_CONTENTS, NULL, false));
1322 if (!bHeight)
1323 rDocShell.PostPaint( rRange, PAINT_GRID ); // AdjustRowHeight may have painted already
1325 rDocShell.SetDocumentModified();
1327 return !bError;
1330 // used in ScCellRangeObj::getFormulaArray and ScCellObj::GetInputString_Impl
1331 static OUString lcl_GetInputString( ScDocument* pDoc, const ScAddress& rPos, bool bEnglish )
1333 if (!pDoc)
1334 return EMPTY_OUSTRING;
1336 ScRefCellValue aCell;
1337 aCell.assign(*pDoc, rPos);
1338 if (aCell.isEmpty())
1339 return EMPTY_OUSTRING;
1341 OUString aVal;
1343 CellType eType = aCell.meType;
1344 if (eType == CELLTYPE_FORMULA)
1346 ScFormulaCell* pForm = aCell.mpFormula;
1347 pForm->GetFormula( aVal, formula::FormulaGrammar::mapAPItoGrammar( bEnglish, false));
1348 return aVal;
1351 SvNumberFormatter* pFormatter = bEnglish ? ScGlobal::GetEnglishFormatter() :
1352 pDoc->GetFormatTable();
1353 // Since the English formatter was constructed with
1354 // LANGUAGE_ENGLISH_US the "General" format has index key 0,
1355 // we don't have to query.
1356 sal_uInt32 nNumFmt = bEnglish ? 0 : pDoc->GetNumberFormat(rPos);
1358 if (eType == CELLTYPE_EDIT)
1360 // GetString an der EditCell macht Leerzeichen aus Umbruechen,
1361 // hier werden die Umbrueche aber gebraucht
1362 const EditTextObject* pData = aCell.mpEditText;
1363 if (pData)
1365 EditEngine& rEngine = pDoc->GetEditEngine();
1366 rEngine.SetText(*pData);
1367 aVal = rEngine.GetText(LINEEND_LF);
1370 else
1371 ScCellFormat::GetInputString(aCell, nNumFmt, aVal, *pFormatter, pDoc);
1373 // ggf. ein ' davorhaengen wie in ScTabViewShell::UpdateInputHandler
1374 if ( eType == CELLTYPE_STRING || eType == CELLTYPE_EDIT )
1376 double fDummy;
1377 OUString aTempString = aVal;
1378 bool bIsNumberFormat(pFormatter->IsNumberFormat(aTempString, nNumFmt, fDummy));
1379 if ( bIsNumberFormat )
1380 aTempString = "'" + aTempString;
1381 else if ( aTempString.startsWith("'") )
1383 // if the string starts with a "'", add another one because setFormula
1384 // strips one (like text input, except for "text" number formats)
1385 if ( bEnglish || ( pFormatter->GetType(nNumFmt) != NUMBERFORMAT_TEXT ) )
1386 aTempString = "'" + aTempString;
1388 aVal = aTempString;
1390 return aVal;
1393 ScCellRangesBase::ScCellRangesBase(ScDocShell* pDocSh, const ScRange& rR) :
1394 pPropSet(lcl_GetCellsPropertySet()),
1395 pDocShell( pDocSh ),
1396 pValueListener( NULL ),
1397 pCurrentFlat( NULL ),
1398 pCurrentDeep( NULL ),
1399 pCurrentDataSet( NULL ),
1400 pNoDfltCurrentDataSet( NULL ),
1401 pMarkData( NULL ),
1402 nObjectId( 0 ),
1403 bChartColAsHdr( false ),
1404 bChartRowAsHdr( false ),
1405 bCursorOnly( false ),
1406 bGotDataChangedHint( false ),
1407 aValueListeners( 0 )
1409 ScRange aCellRange(rR);
1410 aCellRange.Justify();
1411 aRanges.Append( aCellRange );
1413 if (pDocShell) // Null if created with createInstance
1415 ScDocument* pDoc = pDocShell->GetDocument();
1416 pDoc->AddUnoObject(*this);
1417 nObjectId = pDoc->GetNewUnoId();
1421 ScCellRangesBase::ScCellRangesBase(ScDocShell* pDocSh, const ScRangeList& rR) :
1422 pPropSet(lcl_GetCellsPropertySet()),
1423 pDocShell( pDocSh ),
1424 pValueListener( NULL ),
1425 pCurrentFlat( NULL ),
1426 pCurrentDeep( NULL ),
1427 pCurrentDataSet( NULL ),
1428 pNoDfltCurrentDataSet( NULL ),
1429 pMarkData( NULL ),
1430 aRanges( rR ),
1431 nObjectId( 0 ),
1432 bChartColAsHdr( false ),
1433 bChartRowAsHdr( false ),
1434 bCursorOnly( false ),
1435 bGotDataChangedHint( false ),
1436 aValueListeners( 0 )
1438 if (pDocShell) // Null if created with createInstance
1440 ScDocument* pDoc = pDocShell->GetDocument();
1441 pDoc->AddUnoObject(*this);
1442 nObjectId = pDoc->GetNewUnoId();
1446 ScCellRangesBase::~ScCellRangesBase()
1448 // call RemoveUnoObject first, so no notification can happen
1449 // during ForgetCurrentAttrs
1451 if (pDocShell)
1452 pDocShell->GetDocument()->RemoveUnoObject(*this);
1454 ForgetCurrentAttrs();
1455 ForgetMarkData();
1457 delete pValueListener;
1459 //! XChartDataChangeEventListener abmelden ??
1460 //! (ChartCollection haelt dann auch dieses Objekt fest!)
1463 void ScCellRangesBase::ForgetCurrentAttrs()
1465 delete pCurrentFlat;
1466 delete pCurrentDeep;
1467 delete pCurrentDataSet;
1468 delete pNoDfltCurrentDataSet;
1469 pCurrentFlat = NULL;
1470 pCurrentDeep = NULL;
1471 pCurrentDataSet = NULL;
1472 pNoDfltCurrentDataSet = NULL;
1474 // #i62483# pMarkData can remain unchanged, is deleted only if the range changes (RefChanged)
1477 void ScCellRangesBase::ForgetMarkData()
1479 delete pMarkData;
1480 pMarkData = NULL;
1483 const ScPatternAttr* ScCellRangesBase::GetCurrentAttrsFlat()
1485 // get and cache direct cell attributes for this object's range
1487 if ( !pCurrentFlat && pDocShell )
1489 ScDocument* pDoc = pDocShell->GetDocument();
1490 pCurrentFlat = pDoc->CreateSelectionPattern( *GetMarkData(), false );
1492 return pCurrentFlat;
1495 const ScPatternAttr* ScCellRangesBase::GetCurrentAttrsDeep()
1497 // get and cache cell attributes (incl. styles) for this object's range
1499 if ( !pCurrentDeep && pDocShell )
1501 ScDocument* pDoc = pDocShell->GetDocument();
1502 pCurrentDeep = pDoc->CreateSelectionPattern( *GetMarkData(), true );
1504 return pCurrentDeep;
1507 SfxItemSet* ScCellRangesBase::GetCurrentDataSet(bool bNoDflt)
1509 if(!pCurrentDataSet)
1511 const ScPatternAttr* pPattern = GetCurrentAttrsDeep();
1512 if ( pPattern )
1514 // Dontcare durch Default ersetzen, damit man immer eine Reflection hat
1515 pCurrentDataSet = new SfxItemSet( pPattern->GetItemSet() );
1516 pNoDfltCurrentDataSet = new SfxItemSet( pPattern->GetItemSet() );
1517 pCurrentDataSet->ClearInvalidItems();
1520 return bNoDflt ? pNoDfltCurrentDataSet : pCurrentDataSet;
1523 const ScMarkData* ScCellRangesBase::GetMarkData()
1525 if (!pMarkData)
1527 pMarkData = new ScMarkData();
1528 pMarkData->MarkFromRangeList( aRanges, false );
1530 return pMarkData;
1533 void ScCellRangesBase::Notify( SfxBroadcaster&, const SfxHint& rHint )
1535 if ( rHint.ISA( ScUpdateRefHint ) )
1537 const ScUpdateRefHint& rRef = (const ScUpdateRefHint&)rHint;
1539 ScDocument* pDoc = pDocShell->GetDocument();
1540 boost::scoped_ptr<ScRangeList> pUndoRanges;
1541 if ( pDoc->HasUnoRefUndo() )
1542 pUndoRanges.reset(new ScRangeList( aRanges ));
1544 if ( aRanges.UpdateReference( rRef.GetMode(), pDoc, rRef.GetRange(),
1545 rRef.GetDx(), rRef.GetDy(), rRef.GetDz() ) )
1547 // i#90076; the object "this" was destroyed after calling ScTableSheetObj::getImplementation
1548 // this hack make sure that the object lives a bit longer
1549 uno::Reference<uno::XInterface> xInterface((cppu::OWeakObject*)this, uno::UNO_QUERY);
1550 if ( rRef.GetMode() == URM_INSDEL
1551 && aRanges.size() == 1
1552 && ScTableSheetObj::getImplementation( xInterface )
1555 // #101755#; the range size of a sheet does not change
1556 ScRange* pR = aRanges.front();
1557 if (pR)
1559 pR->aStart.SetCol(0);
1560 pR->aStart.SetRow(0);
1561 pR->aEnd.SetCol(MAXCOL);
1562 pR->aEnd.SetRow(MAXROW);
1565 RefChanged();
1567 // any change of the range address is broadcast to value (modify) listeners
1568 if ( !aValueListeners.empty() )
1569 bGotDataChangedHint = true;
1571 if ( pUndoRanges )
1572 pDoc->AddUnoRefChange( nObjectId, *pUndoRanges );
1575 else if ( rHint.ISA( SfxSimpleHint ) )
1577 sal_uLong nId = ((const SfxSimpleHint&)rHint).GetId();
1578 if ( nId == SFX_HINT_DYING )
1580 ForgetCurrentAttrs();
1581 pDocShell = NULL; // invalid
1583 if ( !aValueListeners.empty() )
1585 // dispose listeners
1587 lang::EventObject aEvent;
1588 aEvent.Source.set(static_cast<cppu::OWeakObject*>(this));
1589 for ( sal_uInt16 n=0; n<aValueListeners.size(); n++ )
1590 aValueListeners[n]->disposing( aEvent );
1592 aValueListeners.clear();
1594 // The listeners can't have the last ref to this, as it's still held
1595 // by the DocShell.
1598 else if ( nId == SFX_HINT_DATACHANGED )
1600 // document content changed -> forget cached attributes
1601 ForgetCurrentAttrs();
1603 if ( bGotDataChangedHint && pDocShell )
1605 // This object was notified of content changes, so one call
1606 // for each listener is generated now.
1607 // The calls can't be executed directly because the document's
1608 // UNO broadcaster list must not be modified.
1609 // Instead, add to the document's list of listener calls,
1610 // which will be executed directly after the broadcast of
1611 // SFX_HINT_DATACHANGED.
1613 lang::EventObject aEvent;
1614 aEvent.Source.set((cppu::OWeakObject*)this);
1616 // the EventObject holds a Ref to this object until after the listener calls
1618 ScDocument* pDoc = pDocShell->GetDocument();
1619 for ( sal_uInt16 n=0; n<aValueListeners.size(); n++ )
1620 pDoc->AddUnoListenerCall( aValueListeners[n], aEvent );
1622 bGotDataChangedHint = false;
1625 else if ( nId == SC_HINT_CALCALL )
1627 // broadcast from DoHardRecalc - set bGotDataChangedHint
1628 // (SFX_HINT_DATACHANGED follows separately)
1630 if ( !aValueListeners.empty() )
1631 bGotDataChangedHint = true;
1634 else if ( rHint.ISA( ScUnoRefUndoHint ) )
1636 const ScUnoRefUndoHint& rUndoHint = static_cast<const ScUnoRefUndoHint&>(rHint);
1637 if ( rUndoHint.GetObjectId() == nObjectId )
1639 // restore ranges from hint
1641 aRanges = rUndoHint.GetRanges();
1643 RefChanged();
1644 if ( !aValueListeners.empty() )
1645 bGotDataChangedHint = true; // need to broadcast the undo, too
1650 void ScCellRangesBase::RefChanged()
1652 //! adjust XChartDataChangeEventListener
1654 if ( pValueListener && !aValueListeners.empty() )
1656 pValueListener->EndListeningAll();
1658 ScDocument* pDoc = pDocShell->GetDocument();
1659 for ( size_t i = 0, nCount = aRanges.size(); i < nCount; ++i )
1660 pDoc->StartListeningArea( *aRanges[ i ], pValueListener );
1663 ForgetCurrentAttrs();
1664 ForgetMarkData();
1667 ScDocument* ScCellRangesBase::GetDocument() const
1669 if (pDocShell)
1670 return pDocShell->GetDocument();
1671 else
1672 return NULL;
1675 void ScCellRangesBase::InitInsertRange(ScDocShell* pDocSh, const ScRange& rR)
1677 if ( !pDocShell && pDocSh )
1679 pDocShell = pDocSh;
1681 ScRange aCellRange(rR);
1682 aCellRange.Justify();
1683 aRanges.RemoveAll();
1684 aRanges.Append( aCellRange );
1686 pDocShell->GetDocument()->AddUnoObject(*this);
1688 RefChanged(); // Range im Range-Objekt anpassen
1692 void ScCellRangesBase::AddRange(const ScRange& rRange, const bool bMergeRanges)
1694 if (bMergeRanges)
1695 aRanges.Join(rRange);
1696 else
1697 aRanges.Append(rRange);
1698 RefChanged();
1701 void ScCellRangesBase::SetNewRange(const ScRange& rNew)
1703 ScRange aCellRange(rNew);
1704 aCellRange.Justify();
1706 aRanges.RemoveAll();
1707 aRanges.Append( aCellRange );
1708 RefChanged();
1711 void ScCellRangesBase::SetNewRanges(const ScRangeList& rNew)
1713 aRanges = rNew;
1714 RefChanged();
1717 void ScCellRangesBase::SetCursorOnly( bool bSet )
1719 // set for a selection object that is created from the cursor position
1720 // without anything selected (may contain several sheets)
1722 bCursorOnly = bSet;
1725 uno::Any SAL_CALL ScCellRangesBase::queryInterface( const uno::Type& rType )
1726 throw(uno::RuntimeException, std::exception)
1728 SC_QUERYINTERFACE( beans::XPropertySet )
1729 SC_QUERYINTERFACE( beans::XMultiPropertySet )
1730 SC_QUERYINTERFACE( beans::XTolerantMultiPropertySet )
1731 SC_QUERYINTERFACE( beans::XPropertyState )
1732 SC_QUERYINTERFACE( sheet::XSheetOperation )
1733 SC_QUERYINTERFACE( chart::XChartDataArray )
1734 SC_QUERYINTERFACE( chart::XChartData )
1735 SC_QUERYINTERFACE( util::XIndent )
1736 SC_QUERYINTERFACE( sheet::XCellRangesQuery )
1737 SC_QUERYINTERFACE( sheet::XFormulaQuery )
1738 SC_QUERYINTERFACE( util::XReplaceable )
1739 SC_QUERYINTERFACE( util::XSearchable )
1740 SC_QUERYINTERFACE( util::XModifyBroadcaster )
1741 SC_QUERYINTERFACE( lang::XServiceInfo )
1742 SC_QUERYINTERFACE( lang::XUnoTunnel )
1743 SC_QUERYINTERFACE( lang::XTypeProvider )
1745 return OWeakObject::queryInterface( rType );
1748 void SAL_CALL ScCellRangesBase::acquire() throw()
1750 OWeakObject::acquire();
1753 void SAL_CALL ScCellRangesBase::release() throw()
1755 OWeakObject::release();
1758 uno::Sequence<uno::Type> SAL_CALL ScCellRangesBase::getTypes() throw(uno::RuntimeException, std::exception)
1760 static uno::Sequence<uno::Type> aTypes;
1761 if ( aTypes.getLength() == 0 )
1763 aTypes.realloc(13);
1764 uno::Type* pPtr = aTypes.getArray();
1765 pPtr[0] = cppu::UnoType<beans::XPropertySet>::get();
1766 pPtr[1] = cppu::UnoType<beans::XMultiPropertySet>::get();
1767 pPtr[2] = cppu::UnoType<beans::XPropertyState>::get();
1768 pPtr[3] = cppu::UnoType<sheet::XSheetOperation>::get();
1769 pPtr[4] = cppu::UnoType<chart::XChartDataArray>::get();
1770 pPtr[5] = cppu::UnoType<util::XIndent>::get();
1771 pPtr[6] = cppu::UnoType<sheet::XCellRangesQuery>::get();
1772 pPtr[7] = cppu::UnoType<sheet::XFormulaQuery>::get();
1773 pPtr[8] = cppu::UnoType<util::XReplaceable>::get();
1774 pPtr[9] = cppu::UnoType<util::XModifyBroadcaster>::get();
1775 pPtr[10]= cppu::UnoType<lang::XServiceInfo>::get();
1776 pPtr[11]= cppu::UnoType<lang::XUnoTunnel>::get();
1777 pPtr[12]= cppu::UnoType<lang::XTypeProvider>::get();
1779 return aTypes;
1782 uno::Sequence<sal_Int8> SAL_CALL ScCellRangesBase::getImplementationId()
1783 throw(uno::RuntimeException, std::exception)
1785 return css::uno::Sequence<sal_Int8>();
1788 void ScCellRangesBase::PaintRanges_Impl( sal_uInt16 nPart )
1790 for (size_t i = 0, nCount = aRanges.size(); i < nCount; ++i)
1791 pDocShell->PostPaint( *aRanges[ i ], nPart );
1794 // XSheetOperation
1796 double SAL_CALL ScCellRangesBase::computeFunction( sheet::GeneralFunction nFunction )
1797 throw(uno::Exception, uno::RuntimeException, std::exception)
1799 SolarMutexGuard aGuard;
1800 ScMarkData aMark(*GetMarkData());
1801 aMark.MarkToSimple();
1802 if (!aMark.IsMarked())
1803 aMark.SetMarkNegative(true); // um Dummy Position angeben zu koennen
1805 ScAddress aDummy; // wenn nicht Marked, ignoriert wegen Negative
1806 double fVal;
1807 ScSubTotalFunc eFunc = ScDPUtil::toSubTotalFunc(nFunction);
1808 ScDocument* pDoc = pDocShell->GetDocument();
1809 if ( !pDoc->GetSelectionFunction( eFunc, aDummy, aMark, fVal ) )
1811 throw uno::RuntimeException(); //! own exception?
1814 return fVal;
1817 void SAL_CALL ScCellRangesBase::clearContents( sal_Int32 nContentFlags ) throw(uno::RuntimeException, std::exception)
1819 SolarMutexGuard aGuard;
1820 if ( !aRanges.empty() )
1822 // only for clearContents: EDITATTR is only used if no contents are deleted
1823 sal_uInt16 nDelFlags = static_cast< sal_uInt16 >( nContentFlags & IDF_ALL );
1824 if ( ( nContentFlags & IDF_EDITATTR ) && ( nContentFlags & IDF_CONTENTS ) == 0 )
1825 nDelFlags |= IDF_EDITATTR;
1827 pDocShell->GetDocFunc().DeleteContents( *GetMarkData(), nDelFlags, true, true );
1829 // sonst ist nichts zu tun
1832 // XPropertyState
1834 const SfxItemPropertyMap& ScCellRangesBase::GetItemPropertyMap()
1836 return pPropSet->getPropertyMap();
1839 static void lcl_GetPropertyWhich( const SfxItemPropertySimpleEntry* pEntry,
1840 sal_uInt16& rItemWhich )
1842 // Which-ID des betroffenen Items, auch wenn das Item die Property
1843 // nicht alleine behandeln kann
1844 if ( pEntry )
1846 if ( IsScItemWid( pEntry->nWID ) )
1847 rItemWhich = pEntry->nWID;
1848 else
1849 switch ( pEntry->nWID )
1851 case SC_WID_UNO_TBLBORD:
1852 case SC_WID_UNO_TBLBORD2:
1853 rItemWhich = ATTR_BORDER;
1854 break;
1855 case SC_WID_UNO_CONDFMT:
1856 case SC_WID_UNO_CONDLOC:
1857 case SC_WID_UNO_CONDXML:
1858 rItemWhich = ATTR_CONDITIONAL;
1859 break;
1860 case SC_WID_UNO_VALIDAT:
1861 case SC_WID_UNO_VALILOC:
1862 case SC_WID_UNO_VALIXML:
1863 rItemWhich = ATTR_VALIDDATA;
1864 break;
1870 beans::PropertyState ScCellRangesBase::GetOnePropertyState( sal_uInt16 nItemWhich, const SfxItemPropertySimpleEntry* pEntry )
1872 beans::PropertyState eRet = beans::PropertyState_DIRECT_VALUE;
1873 if ( nItemWhich ) // item wid (from map or special case)
1875 // For items that contain several properties (like background),
1876 // "ambiguous" is returned too often here
1878 // for PropertyState, don't look at styles
1879 const ScPatternAttr* pPattern = GetCurrentAttrsFlat();
1880 if ( pPattern )
1882 SfxItemState eState = pPattern->GetItemSet().GetItemState( nItemWhich, false );
1884 if ( nItemWhich == ATTR_VALUE_FORMAT && eState == SFX_ITEM_DEFAULT )
1885 eState = pPattern->GetItemSet().GetItemState( ATTR_LANGUAGE_FORMAT, false );
1887 if ( eState == SFX_ITEM_SET )
1888 eRet = beans::PropertyState_DIRECT_VALUE;
1889 else if ( eState == SFX_ITEM_DEFAULT )
1890 eRet = beans::PropertyState_DEFAULT_VALUE;
1891 else if ( eState == SFX_ITEM_DONTCARE )
1892 eRet = beans::PropertyState_AMBIGUOUS_VALUE;
1893 else
1895 OSL_FAIL("unbekannter ItemState");
1899 else if ( pEntry )
1901 if ( pEntry->nWID == SC_WID_UNO_CHCOLHDR || pEntry->nWID == SC_WID_UNO_CHROWHDR || pEntry->nWID == SC_WID_UNO_ABSNAME )
1902 eRet = beans::PropertyState_DIRECT_VALUE;
1903 else if ( pEntry->nWID == SC_WID_UNO_CELLSTYL )
1905 // a style is always set, there's no default state
1906 const ScStyleSheet* pStyle = pDocShell->GetDocument()->GetSelectionStyle(*GetMarkData());
1907 if (pStyle)
1908 eRet = beans::PropertyState_DIRECT_VALUE;
1909 else
1910 eRet = beans::PropertyState_AMBIGUOUS_VALUE;
1912 else if ( pEntry->nWID == SC_WID_UNO_NUMRULES )
1913 eRet = beans::PropertyState_DEFAULT_VALUE; // numbering rules are always default
1915 return eRet;
1918 beans::PropertyState SAL_CALL ScCellRangesBase::getPropertyState( const OUString& aPropertyName )
1919 throw(beans::UnknownPropertyException, uno::RuntimeException, std::exception)
1921 SolarMutexGuard aGuard;
1922 if ( aRanges.empty() )
1923 throw uno::RuntimeException();
1925 const SfxItemPropertyMap& rMap = GetItemPropertyMap(); // from derived class
1926 sal_uInt16 nItemWhich = 0;
1927 const SfxItemPropertySimpleEntry* pEntry = rMap.getByName( aPropertyName );
1928 lcl_GetPropertyWhich( pEntry, nItemWhich );
1929 return GetOnePropertyState( nItemWhich, pEntry );
1932 uno::Sequence<beans::PropertyState> SAL_CALL ScCellRangesBase::getPropertyStates(
1933 const uno::Sequence<OUString>& aPropertyNames )
1934 throw(beans::UnknownPropertyException, uno::RuntimeException, std::exception)
1936 SolarMutexGuard aGuard;
1938 const SfxItemPropertyMap& rPropertyMap = GetItemPropertyMap(); // from derived class
1940 uno::Sequence<beans::PropertyState> aRet(aPropertyNames.getLength());
1941 beans::PropertyState* pStates = aRet.getArray();
1942 for(sal_Int32 i = 0; i < aPropertyNames.getLength(); i++)
1944 sal_uInt16 nItemWhich = 0;
1945 const SfxItemPropertySimpleEntry* pEntry = rPropertyMap.getByName( aPropertyNames[i] );
1946 lcl_GetPropertyWhich( pEntry, nItemWhich );
1947 pStates[i] = GetOnePropertyState(nItemWhich, pEntry);
1949 return aRet;
1952 void SAL_CALL ScCellRangesBase::setPropertyToDefault( const OUString& aPropertyName )
1953 throw(beans::UnknownPropertyException, uno::RuntimeException, std::exception)
1955 SolarMutexGuard aGuard;
1956 if ( pDocShell )
1958 const SfxItemPropertyMap& rPropertyMap = GetItemPropertyMap(); // from derived class
1959 sal_uInt16 nItemWhich = 0;
1960 const SfxItemPropertySimpleEntry* pEntry = rPropertyMap.getByName( aPropertyName );
1961 lcl_GetPropertyWhich( pEntry, nItemWhich );
1962 if ( nItemWhich ) // item wid (from map or special case)
1964 if ( !aRanges.empty() ) // leer = nichts zu tun
1966 //! Bei Items, die mehrere Properties enthalten (z.B. Hintergrund)
1967 //! wird hier zuviel zurueckgesetzt
1968 //! for ATTR_ROTATE_VALUE, also reset ATTR_ORIENTATION?
1970 sal_uInt16 aWIDs[3];
1971 aWIDs[0] = nItemWhich;
1972 if ( nItemWhich == ATTR_VALUE_FORMAT )
1974 aWIDs[1] = ATTR_LANGUAGE_FORMAT; // language for number formats
1975 aWIDs[2] = 0;
1977 else
1978 aWIDs[1] = 0;
1979 pDocShell->GetDocFunc().ClearItems( *GetMarkData(), aWIDs, true );
1982 else if ( pEntry )
1984 if ( pEntry->nWID == SC_WID_UNO_CHCOLHDR )
1985 bChartColAsHdr = false;
1986 else if ( pEntry->nWID == SC_WID_UNO_CHROWHDR )
1987 bChartRowAsHdr = false;
1988 else if ( pEntry->nWID == SC_WID_UNO_CELLSTYL )
1990 OUString aStyleName( ScGlobal::GetRscString( STR_STYLENAME_STANDARD ) );
1991 pDocShell->GetDocFunc().ApplyStyle( *GetMarkData(), aStyleName, true, true );
1997 uno::Any SAL_CALL ScCellRangesBase::getPropertyDefault( const OUString& aPropertyName )
1998 throw(beans::UnknownPropertyException, lang::WrappedTargetException,
1999 uno::RuntimeException, std::exception)
2001 //! mit getPropertyValue zusammenfassen
2003 SolarMutexGuard aGuard;
2004 uno::Any aAny;
2006 if ( pDocShell )
2008 ScDocument* pDoc = pDocShell->GetDocument();
2009 const SfxItemPropertyMap& rPropertyMap = GetItemPropertyMap(); // from derived class
2010 const SfxItemPropertySimpleEntry* pEntry = rPropertyMap.getByName( aPropertyName );
2011 if ( pEntry )
2013 if ( IsScItemWid( pEntry->nWID ) )
2015 const ScPatternAttr* pPattern = pDoc->GetDefPattern();
2016 if ( pPattern )
2018 const SfxItemSet& rSet = pPattern->GetItemSet();
2020 switch ( pEntry->nWID ) // fuer Item-Spezial-Behandlungen
2022 case ATTR_VALUE_FORMAT:
2023 // default has no language set
2024 aAny <<= (sal_Int32)( ((const SfxUInt32Item&)rSet.Get(pEntry->nWID)).GetValue() );
2025 break;
2026 case ATTR_INDENT:
2027 aAny <<= (sal_Int16)( TwipsToHMM(((const SfxUInt16Item&)
2028 rSet.Get(pEntry->nWID)).GetValue()) );
2029 break;
2030 default:
2031 pPropSet->getPropertyValue(aPropertyName, rSet, aAny);
2035 else
2036 switch ( pEntry->nWID )
2038 case SC_WID_UNO_CHCOLHDR:
2039 case SC_WID_UNO_CHROWHDR:
2040 ScUnoHelpFunctions::SetBoolInAny( aAny, false );
2041 break;
2042 case SC_WID_UNO_CELLSTYL:
2043 aAny <<= OUString( ScStyleNameConversion::DisplayToProgrammaticName(
2044 ScGlobal::GetRscString(STR_STYLENAME_STANDARD), SFX_STYLE_FAMILY_PARA ) );
2045 break;
2046 case SC_WID_UNO_TBLBORD:
2047 case SC_WID_UNO_TBLBORD2:
2049 const ScPatternAttr* pPattern = pDoc->GetDefPattern();
2050 if ( pPattern )
2052 if (pEntry->nWID == SC_WID_UNO_TBLBORD2)
2053 ScHelperFunctions::AssignTableBorder2ToAny( aAny,
2054 (const SvxBoxItem&)pPattern->GetItem(ATTR_BORDER),
2055 (const SvxBoxInfoItem&)pPattern->GetItem(ATTR_BORDER_INNER) );
2056 else
2057 ScHelperFunctions::AssignTableBorderToAny( aAny,
2058 (const SvxBoxItem&)pPattern->GetItem(ATTR_BORDER),
2059 (const SvxBoxInfoItem&)pPattern->GetItem(ATTR_BORDER_INNER) );
2062 break;
2063 case SC_WID_UNO_CONDFMT:
2064 case SC_WID_UNO_CONDLOC:
2065 case SC_WID_UNO_CONDXML:
2067 bool bEnglish = ( pEntry->nWID != SC_WID_UNO_CONDLOC );
2068 bool bXML = ( pEntry->nWID == SC_WID_UNO_CONDXML );
2069 formula::FormulaGrammar::Grammar eGrammar = (bXML ?
2070 pDoc->GetStorageGrammar() :
2071 formula::FormulaGrammar::mapAPItoGrammar( bEnglish, bXML));
2073 aAny <<= uno::Reference<sheet::XSheetConditionalEntries>(
2074 new ScTableConditionalFormat( pDoc, 0, aRanges[0]->aStart.Tab(), eGrammar ));
2076 break;
2077 case SC_WID_UNO_VALIDAT:
2078 case SC_WID_UNO_VALILOC:
2079 case SC_WID_UNO_VALIXML:
2081 bool bEnglish = ( pEntry->nWID != SC_WID_UNO_VALILOC );
2082 bool bXML = ( pEntry->nWID == SC_WID_UNO_VALIXML );
2083 formula::FormulaGrammar::Grammar eGrammar = (bXML ?
2084 pDoc->GetStorageGrammar() :
2085 formula::FormulaGrammar::mapAPItoGrammar( bEnglish, bXML));
2087 aAny <<= uno::Reference<beans::XPropertySet>(
2088 new ScTableValidationObj( pDoc, 0, eGrammar ));
2090 break;
2091 case SC_WID_UNO_NUMRULES:
2093 aAny <<= uno::Reference<container::XIndexReplace>(ScStyleObj::CreateEmptyNumberingRules());
2095 break;
2100 return aAny;
2103 // XPropertySet
2105 uno::Reference<beans::XPropertySetInfo> SAL_CALL ScCellRangesBase::getPropertySetInfo()
2106 throw(uno::RuntimeException, std::exception)
2108 SolarMutexGuard aGuard;
2109 static uno::Reference<beans::XPropertySetInfo> aRef(
2110 new SfxItemPropertySetInfo( pPropSet->getPropertyMap() ));
2111 return aRef;
2114 static void lcl_SetCellProperty( const SfxItemPropertySimpleEntry& rEntry, const uno::Any& rValue,
2115 ScPatternAttr& rPattern, ScDocument* pDoc,
2116 sal_uInt16& rFirstItemId, sal_uInt16& rSecondItemId )
2118 rFirstItemId = rEntry.nWID;
2119 rSecondItemId = 0;
2121 SfxItemSet& rSet = rPattern.GetItemSet();
2122 switch ( rEntry.nWID )
2124 case ATTR_VALUE_FORMAT:
2126 // language for number formats
2127 SvNumberFormatter* pFormatter = pDoc->GetFormatTable();
2128 sal_uLong nOldFormat = ((const SfxUInt32Item&)rSet.Get( ATTR_VALUE_FORMAT )).GetValue();
2129 LanguageType eOldLang = ((const SvxLanguageItem&)rSet.Get( ATTR_LANGUAGE_FORMAT )).GetLanguage();
2130 nOldFormat = pFormatter->GetFormatForLanguageIfBuiltIn( nOldFormat, eOldLang );
2132 sal_Int32 nIntVal = 0;
2133 if ( rValue >>= nIntVal )
2135 sal_uLong nNewFormat = (sal_uLong)nIntVal;
2136 rSet.Put( SfxUInt32Item( ATTR_VALUE_FORMAT, nNewFormat ) );
2138 const SvNumberformat* pNewEntry = pFormatter->GetEntry( nNewFormat );
2139 LanguageType eNewLang =
2140 pNewEntry ? pNewEntry->GetLanguage() : LANGUAGE_DONTKNOW;
2141 if ( eNewLang != eOldLang && eNewLang != LANGUAGE_DONTKNOW )
2143 rSet.Put( SvxLanguageItem( eNewLang, ATTR_LANGUAGE_FORMAT ) );
2145 // if only language is changed,
2146 // don't touch number format attribute
2147 sal_uLong nNewMod = nNewFormat % SV_COUNTRY_LANGUAGE_OFFSET;
2148 if ( nNewMod == ( nOldFormat % SV_COUNTRY_LANGUAGE_OFFSET ) &&
2149 nNewMod <= SV_MAX_ANZ_STANDARD_FORMATE )
2151 rFirstItemId = 0; // don't use ATTR_VALUE_FORMAT value
2154 rSecondItemId = ATTR_LANGUAGE_FORMAT;
2157 else
2158 throw lang::IllegalArgumentException();
2160 break;
2161 case ATTR_INDENT:
2163 sal_Int16 nIntVal = 0;
2164 if ( rValue >>= nIntVal )
2165 rSet.Put( SfxUInt16Item( rEntry.nWID, (sal_uInt16)HMMToTwips(nIntVal) ) );
2166 else
2167 throw lang::IllegalArgumentException();
2169 break;
2170 case ATTR_ROTATE_VALUE:
2172 sal_Int32 nRotVal = 0;
2173 if ( rValue >>= nRotVal )
2175 // stored value is always between 0 and 360 deg.
2176 nRotVal %= 36000;
2177 if ( nRotVal < 0 )
2178 nRotVal += 36000;
2180 rSet.Put( SfxInt32Item( ATTR_ROTATE_VALUE, nRotVal ) );
2182 else
2183 throw lang::IllegalArgumentException();
2185 break;
2186 case ATTR_STACKED:
2188 table::CellOrientation eOrient;
2189 if( rValue >>= eOrient )
2191 switch( eOrient )
2193 case table::CellOrientation_STANDARD:
2194 rSet.Put( SfxBoolItem( ATTR_STACKED, false ) );
2195 break;
2196 case table::CellOrientation_TOPBOTTOM:
2197 rSet.Put( SfxBoolItem( ATTR_STACKED, false ) );
2198 rSet.Put( SfxInt32Item( ATTR_ROTATE_VALUE, 27000 ) );
2199 rSecondItemId = ATTR_ROTATE_VALUE;
2200 break;
2201 case table::CellOrientation_BOTTOMTOP:
2202 rSet.Put( SfxBoolItem( ATTR_STACKED, false ) );
2203 rSet.Put( SfxInt32Item( ATTR_ROTATE_VALUE, 9000 ) );
2204 rSecondItemId = ATTR_ROTATE_VALUE;
2205 break;
2206 case table::CellOrientation_STACKED:
2207 rSet.Put( SfxBoolItem( ATTR_STACKED, true ) );
2208 break;
2209 default:
2211 // added to avoid warnings
2216 break;
2217 default:
2219 lcl_GetCellsPropertySet()->setPropertyValue(rEntry, rValue, rSet);
2224 void SAL_CALL ScCellRangesBase::setPropertyValue(
2225 const OUString& aPropertyName, const uno::Any& aValue )
2226 throw(beans::UnknownPropertyException, beans::PropertyVetoException,
2227 lang::IllegalArgumentException, lang::WrappedTargetException,
2228 uno::RuntimeException, std::exception)
2230 SolarMutexGuard aGuard;
2232 if ( !pDocShell || aRanges.empty() )
2233 throw uno::RuntimeException();
2235 const SfxItemPropertyMap& rPropertyMap = GetItemPropertyMap(); // from derived class
2236 const SfxItemPropertySimpleEntry* pEntry = rPropertyMap.getByName( aPropertyName );
2237 if ( !pEntry )
2238 throw beans::UnknownPropertyException();
2240 SetOnePropertyValue( pEntry, aValue );
2243 void ScCellRangesBase::SetOnePropertyValue( const SfxItemPropertySimpleEntry* pEntry, const uno::Any& aValue )
2244 throw(lang::IllegalArgumentException, uno::RuntimeException, std::exception)
2246 if ( pEntry )
2248 if ( IsScItemWid( pEntry->nWID ) )
2250 if ( !aRanges.empty() ) // leer = nichts zu tun
2252 ScDocument* pDoc = pDocShell->GetDocument();
2254 // Fuer Teile von zusammengesetzten Items mit mehreren Properties (z.B. Hintergrund)
2255 // muss vorher das alte Item aus dem Dokument geholt werden
2256 //! Das kann hier aber nicht erkannt werden
2257 //! -> eigenes Flag im PropertyMap-Eintrag, oder was ???
2258 //! Item direkt von einzelner Position im Bereich holen?
2259 // ClearInvalidItems, damit auf jeden Fall ein Item vom richtigen Typ da ist
2261 ScPatternAttr aPattern( *GetCurrentAttrsDeep() );
2262 SfxItemSet& rSet = aPattern.GetItemSet();
2263 rSet.ClearInvalidItems();
2265 sal_uInt16 nFirstItem, nSecondItem;
2266 lcl_SetCellProperty( *pEntry, aValue, aPattern, pDoc, nFirstItem, nSecondItem );
2268 for (sal_uInt16 nWhich = ATTR_PATTERN_START; nWhich <= ATTR_PATTERN_END; nWhich++)
2269 if ( nWhich != nFirstItem && nWhich != nSecondItem )
2270 rSet.ClearItem(nWhich);
2272 pDocShell->GetDocFunc().ApplyAttributes( *GetMarkData(), aPattern, true, true );
2275 else // implemented here
2276 switch ( pEntry->nWID )
2278 case EE_CHAR_ESCAPEMENT: // Specifically for xlsx import
2280 sal_Int32 nValue = 0;
2281 aValue >>= nValue;
2282 if (nValue)
2284 for (size_t i = 0, n = aRanges.size(); i < n; ++i)
2286 ScRange aRange = *aRanges[i];
2288 /* TODO: Iterate through the range */
2289 ScAddress aAddr = aRange.aStart;
2290 ScDocument *pDoc = pDocShell->GetDocument();
2291 ScRefCellValue aCell;
2292 aCell.assign(*pDoc, aAddr);
2294 OUString aStr = aCell.getString(pDoc);
2295 EditEngine aEngine( pDoc->GetEnginePool() );
2296 aEngine.SetEditTextObjectPool(pDoc->GetEditPool());
2298 /* EE_CHAR_ESCAPEMENT seems to be set on the cell _only_ when
2299 * there are no other attribs for the cell.
2300 * So, it is safe to overwrite the complete attribute set.
2301 * If there is a need - getting CellType and processing
2302 * the attributes could be considered.
2304 SfxItemSet aAttr = aEngine.GetEmptyItemSet();
2305 aEngine.SetText(aStr);
2306 if( nValue < 0 ) // Subscript
2307 aAttr.Put( SvxEscapementItem( SVX_ESCAPEMENT_SUBSCRIPT, EE_CHAR_ESCAPEMENT ) );
2308 else // Superscript
2309 aAttr.Put( SvxEscapementItem( SVX_ESCAPEMENT_SUPERSCRIPT, EE_CHAR_ESCAPEMENT ) );
2310 aEngine.QuickSetAttribs(aAttr, ESelection(0, 0, 0, aStr.getLength()));
2312 // The cell will own the text object instance.
2313 pDoc->SetEditText(aRanges[0]->aStart, aEngine.CreateTextObject());
2317 break;
2318 case SC_WID_UNO_CHCOLHDR:
2319 // chart header flags are set for this object, not stored with document
2320 bChartColAsHdr = ScUnoHelpFunctions::GetBoolFromAny( aValue );
2321 break;
2322 case SC_WID_UNO_CHROWHDR:
2323 bChartRowAsHdr = ScUnoHelpFunctions::GetBoolFromAny( aValue );
2324 break;
2325 case SC_WID_UNO_CELLSTYL:
2327 OUString aStrVal;
2328 aValue >>= aStrVal;
2329 OUString aString(ScStyleNameConversion::ProgrammaticToDisplayName(
2330 aStrVal, SFX_STYLE_FAMILY_PARA ));
2331 pDocShell->GetDocFunc().ApplyStyle( *GetMarkData(), aString, true, true );
2333 break;
2334 case SC_WID_UNO_TBLBORD:
2336 table::TableBorder aBorder;
2337 if ( !aRanges.empty() && ( aValue >>= aBorder ) ) // empty = nothing to do
2339 SvxBoxItem aOuter(ATTR_BORDER);
2340 SvxBoxInfoItem aInner(ATTR_BORDER_INNER);
2341 ScHelperFunctions::FillBoxItems( aOuter, aInner, aBorder );
2343 ScHelperFunctions::ApplyBorder( pDocShell, aRanges, aOuter, aInner ); //! docfunc
2346 break;
2347 case SC_WID_UNO_TBLBORD2:
2349 table::TableBorder2 aBorder2;
2350 if ( !aRanges.empty() && ( aValue >>= aBorder2 ) ) // empty = nothing to do
2352 SvxBoxItem aOuter(ATTR_BORDER);
2353 SvxBoxInfoItem aInner(ATTR_BORDER_INNER);
2354 ScHelperFunctions::FillBoxItems( aOuter, aInner, aBorder2 );
2356 ScHelperFunctions::ApplyBorder( pDocShell, aRanges, aOuter, aInner ); //! docfunc
2359 break;
2360 case SC_WID_UNO_CONDFMT:
2361 case SC_WID_UNO_CONDLOC:
2362 case SC_WID_UNO_CONDXML:
2364 uno::Reference<sheet::XSheetConditionalEntries> xInterface(aValue, uno::UNO_QUERY);
2365 if ( !aRanges.empty() && xInterface.is() ) // leer = nichts zu tun
2367 ScTableConditionalFormat* pFormat =
2368 ScTableConditionalFormat::getImplementation( xInterface );
2369 if (pFormat)
2371 ScDocument* pDoc = pDocShell->GetDocument();
2372 bool bEnglish = ( pEntry->nWID != SC_WID_UNO_CONDLOC );
2373 bool bXML = ( pEntry->nWID == SC_WID_UNO_CONDXML );
2374 formula::FormulaGrammar::Grammar eGrammar = (bXML ?
2375 formula::FormulaGrammar::GRAM_UNSPECIFIED :
2376 formula::FormulaGrammar::mapAPItoGrammar( bEnglish, bXML));
2378 ScConditionalFormat* pNew = new ScConditionalFormat( 0, pDoc ); // Index wird beim Einfuegen gesetzt
2379 pFormat->FillFormat( *pNew, pDoc, eGrammar );
2380 pNew->AddRange( aRanges );
2381 SCTAB nTab = aRanges.front()->aStart.Tab();
2382 pDocShell->GetDocFunc().ReplaceConditionalFormat( 0, pNew, nTab, aRanges );
2386 break;
2387 case SC_WID_UNO_VALIDAT:
2388 case SC_WID_UNO_VALILOC:
2389 case SC_WID_UNO_VALIXML:
2391 uno::Reference<beans::XPropertySet> xInterface(aValue, uno::UNO_QUERY);
2392 if ( !aRanges.empty() && xInterface.is() ) // leer = nichts zu tun
2394 ScTableValidationObj* pValidObj =
2395 ScTableValidationObj::getImplementation( xInterface );
2396 if (pValidObj)
2398 ScDocument* pDoc = pDocShell->GetDocument();
2399 bool bEnglish = ( pEntry->nWID != SC_WID_UNO_VALILOC );
2400 bool bXML = ( pEntry->nWID == SC_WID_UNO_VALIXML );
2401 formula::FormulaGrammar::Grammar eGrammar = (bXML ?
2402 formula::FormulaGrammar::GRAM_UNSPECIFIED :
2403 formula::FormulaGrammar::mapAPItoGrammar( bEnglish, bXML));
2405 boost::scoped_ptr<ScValidationData> pNewData(
2406 pValidObj->CreateValidationData( pDoc, eGrammar ));
2407 sal_uLong nIndex = pDoc->AddValidationEntry( *pNewData );
2408 pNewData.reset();
2410 ScPatternAttr aPattern( pDoc->GetPool() );
2411 aPattern.GetItemSet().Put( SfxUInt32Item( ATTR_VALIDDATA, nIndex ) );
2412 pDocShell->GetDocFunc().ApplyAttributes( *GetMarkData(), aPattern, true, true );
2416 break;
2417 // SC_WID_UNO_NUMRULES is ignored...
2422 uno::Any SAL_CALL ScCellRangesBase::getPropertyValue( const OUString& aPropertyName )
2423 throw(beans::UnknownPropertyException, lang::WrappedTargetException,
2424 uno::RuntimeException, std::exception)
2426 SolarMutexGuard aGuard;
2428 if ( !pDocShell || aRanges.empty() )
2429 throw uno::RuntimeException();
2431 const SfxItemPropertyMap& rPropertyMap = GetItemPropertyMap(); // from derived class
2432 const SfxItemPropertySimpleEntry* pEntry = rPropertyMap.getByName( aPropertyName );
2433 if ( !pEntry )
2434 throw beans::UnknownPropertyException();
2436 uno::Any aAny;
2437 GetOnePropertyValue( pEntry, aAny );
2438 return aAny;
2441 void ScCellRangesBase::GetOnePropertyValue( const SfxItemPropertySimpleEntry* pEntry, uno::Any& rAny )
2442 throw(uno::RuntimeException, std::exception)
2444 if ( pEntry )
2446 if ( IsScItemWid( pEntry->nWID ) )
2448 SfxItemSet* pDataSet = GetCurrentDataSet();
2449 if ( pDataSet )
2451 switch ( pEntry->nWID ) // fuer Item-Spezial-Behandlungen
2453 case ATTR_VALUE_FORMAT:
2455 ScDocument* pDoc = pDocShell->GetDocument();
2457 sal_uLong nOldFormat = ((const SfxUInt32Item&)
2458 pDataSet->Get( ATTR_VALUE_FORMAT )).GetValue();
2459 LanguageType eOldLang = ((const SvxLanguageItem&)
2460 pDataSet->Get( ATTR_LANGUAGE_FORMAT )).GetLanguage();
2461 nOldFormat = pDoc->GetFormatTable()->
2462 GetFormatForLanguageIfBuiltIn( nOldFormat, eOldLang );
2463 rAny <<= (sal_Int32)( nOldFormat );
2465 break;
2466 case ATTR_INDENT:
2467 rAny <<= (sal_Int16)( TwipsToHMM(((const SfxUInt16Item&)
2468 pDataSet->Get(pEntry->nWID)).GetValue()) );
2469 break;
2470 case ATTR_STACKED:
2472 sal_Int32 nRot = ((const SfxInt32Item&)pDataSet->Get(ATTR_ROTATE_VALUE)).GetValue();
2473 bool bStacked = ((const SfxBoolItem&)pDataSet->Get(pEntry->nWID)).GetValue();
2474 SvxOrientationItem( nRot, bStacked, 0 ).QueryValue( rAny );
2476 break;
2477 default:
2478 pPropSet->getPropertyValue(*pEntry, *pDataSet, rAny);
2482 else // implemented here
2483 switch ( pEntry->nWID )
2485 case SC_WID_UNO_CHCOLHDR:
2486 ScUnoHelpFunctions::SetBoolInAny( rAny, bChartColAsHdr );
2487 break;
2488 case SC_WID_UNO_CHROWHDR:
2489 ScUnoHelpFunctions::SetBoolInAny( rAny, bChartRowAsHdr );
2490 break;
2491 case SC_WID_UNO_CELLSTYL:
2493 OUString aStyleName;
2494 const ScStyleSheet* pStyle = pDocShell->GetDocument()->GetSelectionStyle(*GetMarkData());
2495 if (pStyle)
2496 aStyleName = pStyle->GetName();
2497 rAny <<= OUString( ScStyleNameConversion::DisplayToProgrammaticName(
2498 aStyleName, SFX_STYLE_FAMILY_PARA ) );
2500 break;
2501 case SC_WID_UNO_TBLBORD:
2502 case SC_WID_UNO_TBLBORD2:
2504 //! loop throgh all ranges
2505 if ( !aRanges.empty() )
2507 const ScRange* pFirst = aRanges[ 0 ];
2508 SvxBoxItem aOuter(ATTR_BORDER);
2509 SvxBoxInfoItem aInner(ATTR_BORDER_INNER);
2511 ScDocument* pDoc = pDocShell->GetDocument();
2512 ScMarkData aMark;
2513 aMark.SetMarkArea( *pFirst );
2514 aMark.SelectTable( pFirst->aStart.Tab(), true );
2515 pDoc->GetSelectionFrame( aMark, aOuter, aInner );
2517 if (pEntry->nWID == SC_WID_UNO_TBLBORD2)
2518 ScHelperFunctions::AssignTableBorder2ToAny( rAny, aOuter, aInner);
2519 else
2520 ScHelperFunctions::AssignTableBorderToAny( rAny, aOuter, aInner);
2523 break;
2524 case SC_WID_UNO_CONDFMT:
2525 case SC_WID_UNO_CONDLOC:
2526 case SC_WID_UNO_CONDXML:
2528 const ScPatternAttr* pPattern = GetCurrentAttrsDeep();
2529 if ( pPattern )
2531 ScDocument* pDoc = pDocShell->GetDocument();
2532 bool bEnglish = ( pEntry->nWID != SC_WID_UNO_CONDLOC );
2533 bool bXML = ( pEntry->nWID == SC_WID_UNO_CONDXML );
2534 formula::FormulaGrammar::Grammar eGrammar = (bXML ?
2535 pDoc->GetStorageGrammar() :
2536 formula::FormulaGrammar::mapAPItoGrammar( bEnglish, bXML));
2537 const std::vector<sal_uInt32>& rIndex = ((const ScCondFormatItem&)
2538 pPattern->GetItem(ATTR_CONDITIONAL)).GetCondFormatData();
2539 sal_uLong nIndex = 0;
2540 if(!rIndex.empty())
2541 nIndex = rIndex[0];
2542 rAny <<= uno::Reference<sheet::XSheetConditionalEntries>(
2543 new ScTableConditionalFormat( pDoc, nIndex, aRanges.front()->aStart.Tab(), eGrammar ));
2546 break;
2547 case SC_WID_UNO_VALIDAT:
2548 case SC_WID_UNO_VALILOC:
2549 case SC_WID_UNO_VALIXML:
2551 const ScPatternAttr* pPattern = GetCurrentAttrsDeep();
2552 if ( pPattern )
2554 ScDocument* pDoc = pDocShell->GetDocument();
2555 bool bEnglish = ( pEntry->nWID != SC_WID_UNO_VALILOC );
2556 bool bXML = ( pEntry->nWID == SC_WID_UNO_VALIXML );
2557 formula::FormulaGrammar::Grammar eGrammar = (bXML ?
2558 pDoc->GetStorageGrammar() :
2559 formula::FormulaGrammar::mapAPItoGrammar( bEnglish, bXML));
2560 sal_uLong nIndex = ((const SfxUInt32Item&)
2561 pPattern->GetItem(ATTR_VALIDDATA)).GetValue();
2562 rAny <<= uno::Reference<beans::XPropertySet>(
2563 new ScTableValidationObj( pDoc, nIndex, eGrammar ));
2566 break;
2567 case SC_WID_UNO_NUMRULES:
2569 // always return empty numbering rules object
2570 rAny <<= uno::Reference<container::XIndexReplace>(ScStyleObj::CreateEmptyNumberingRules());
2572 break;
2573 case SC_WID_UNO_ABSNAME:
2575 OUString sRet;
2576 aRanges.Format(sRet, SCR_ABS_3D, pDocShell->GetDocument());
2577 rAny <<= sRet;
2583 void SAL_CALL ScCellRangesBase::addPropertyChangeListener( const OUString& /* aPropertyName */,
2584 const uno::Reference<beans::XPropertyChangeListener>& /* aListener */)
2585 throw(beans::UnknownPropertyException,
2586 lang::WrappedTargetException, uno::RuntimeException, std::exception)
2588 SolarMutexGuard aGuard;
2589 if ( aRanges.empty() )
2590 throw uno::RuntimeException();
2592 OSL_FAIL("not implemented");
2595 void SAL_CALL ScCellRangesBase::removePropertyChangeListener( const OUString& /* aPropertyName */,
2596 const uno::Reference<beans::XPropertyChangeListener>& /* aListener */)
2597 throw(beans::UnknownPropertyException,
2598 lang::WrappedTargetException, uno::RuntimeException, std::exception)
2600 SolarMutexGuard aGuard;
2601 if ( aRanges.empty() )
2602 throw uno::RuntimeException();
2604 OSL_FAIL("not implemented");
2607 void SAL_CALL ScCellRangesBase::addVetoableChangeListener( const OUString&,
2608 const uno::Reference<beans::XVetoableChangeListener>&)
2609 throw(beans::UnknownPropertyException,
2610 lang::WrappedTargetException, uno::RuntimeException, std::exception)
2612 OSL_FAIL("not implemented");
2615 void SAL_CALL ScCellRangesBase::removeVetoableChangeListener( const OUString&,
2616 const uno::Reference<beans::XVetoableChangeListener>&)
2617 throw(beans::UnknownPropertyException,
2618 lang::WrappedTargetException, uno::RuntimeException, std::exception)
2620 OSL_FAIL("not implemented");
2623 // XMultiPropertySet
2625 void SAL_CALL ScCellRangesBase::setPropertyValues( const uno::Sequence< OUString >& aPropertyNames,
2626 const uno::Sequence< uno::Any >& aValues )
2627 throw (beans::PropertyVetoException,
2628 lang::IllegalArgumentException,
2629 lang::WrappedTargetException,
2630 uno::RuntimeException, std::exception)
2632 SolarMutexGuard aGuard;
2634 sal_Int32 nCount(aPropertyNames.getLength());
2635 sal_Int32 nValues(aValues.getLength());
2636 if (nCount != nValues)
2637 throw lang::IllegalArgumentException();
2639 if ( pDocShell && nCount )
2641 const SfxItemPropertyMap& rPropertyMap = GetItemPropertyMap(); // from derived class
2642 const OUString* pNames = aPropertyNames.getConstArray();
2643 const uno::Any* pValues = aValues.getConstArray();
2645 boost::scoped_array<const SfxItemPropertySimpleEntry*> pEntryArray(new const SfxItemPropertySimpleEntry*[nCount]);
2647 sal_Int32 i;
2648 for(i = 0; i < nCount; i++)
2650 // first loop: find all properties in map, but handle only CellStyle
2651 // (CellStyle must be set before any other cell properties)
2653 const SfxItemPropertySimpleEntry* pEntry = rPropertyMap.getByName( pNames[i] );
2654 pEntryArray[i] = pEntry;
2655 if (pEntry)
2657 if ( pEntry->nWID == SC_WID_UNO_CELLSTYL )
2661 SetOnePropertyValue( pEntry, pValues[i] );
2663 catch ( lang::IllegalArgumentException& )
2665 OSL_FAIL("exception when setting cell style"); // not supposed to happen
2671 ScDocument* pDoc = pDocShell->GetDocument();
2672 boost::scoped_ptr<ScPatternAttr> pOldPattern;
2673 boost::scoped_ptr<ScPatternAttr> pNewPattern;
2675 for(i = 0; i < nCount; i++)
2677 // second loop: handle other properties
2679 const SfxItemPropertySimpleEntry* pEntry = pEntryArray[i];
2680 if ( pEntry )
2682 if ( IsScItemWid( pEntry->nWID ) ) // can be handled by SfxItemPropertySet
2684 if ( !pOldPattern )
2686 pOldPattern.reset(new ScPatternAttr( *GetCurrentAttrsDeep() ));
2687 pOldPattern->GetItemSet().ClearInvalidItems();
2688 pNewPattern.reset(new ScPatternAttr( pDoc->GetPool() ));
2691 // collect items in pNewPattern, apply with one call after the loop
2693 sal_uInt16 nFirstItem, nSecondItem;
2694 lcl_SetCellProperty( *pEntry, pValues[i], *pOldPattern, pDoc, nFirstItem, nSecondItem );
2696 // put only affected items into new set
2697 if ( nFirstItem )
2698 pNewPattern->GetItemSet().Put( pOldPattern->GetItemSet().Get( nFirstItem ) );
2699 if ( nSecondItem )
2700 pNewPattern->GetItemSet().Put( pOldPattern->GetItemSet().Get( nSecondItem ) );
2702 else if ( pEntry->nWID != SC_WID_UNO_CELLSTYL ) // CellStyle is handled above
2704 // call virtual method to set a single property
2705 SetOnePropertyValue( pEntry, pValues[i] );
2710 if ( pNewPattern && !aRanges.empty() )
2711 pDocShell->GetDocFunc().ApplyAttributes( *GetMarkData(), *pNewPattern, true, true );
2715 uno::Sequence<uno::Any> SAL_CALL ScCellRangesBase::getPropertyValues(
2716 const uno::Sequence< OUString >& aPropertyNames )
2717 throw (uno::RuntimeException, std::exception)
2719 SolarMutexGuard aGuard;
2721 const SfxItemPropertyMap& rPropertyMap = GetItemPropertyMap(); // from derived class
2723 uno::Sequence<uno::Any> aRet(aPropertyNames.getLength());
2724 uno::Any* pProperties = aRet.getArray();
2725 for(sal_Int32 i = 0; i < aPropertyNames.getLength(); i++)
2727 const SfxItemPropertySimpleEntry* pEntry = rPropertyMap.getByName( aPropertyNames[i] );
2728 GetOnePropertyValue( pEntry, pProperties[i] );
2730 return aRet;
2733 void SAL_CALL ScCellRangesBase::addPropertiesChangeListener( const uno::Sequence< OUString >& /* aPropertyNames */,
2734 const uno::Reference< beans::XPropertiesChangeListener >& /* xListener */ )
2735 throw (uno::RuntimeException, std::exception)
2737 OSL_FAIL("not implemented");
2740 void SAL_CALL ScCellRangesBase::removePropertiesChangeListener( const uno::Reference< beans::XPropertiesChangeListener >& /* xListener */ )
2741 throw (uno::RuntimeException, std::exception)
2743 OSL_FAIL("not implemented");
2746 void SAL_CALL ScCellRangesBase::firePropertiesChangeEvent( const uno::Sequence< OUString >& /* aPropertyNames */,
2747 const uno::Reference< beans::XPropertiesChangeListener >& /* xListener */ )
2748 throw (uno::RuntimeException, std::exception)
2750 OSL_FAIL("not implemented");
2753 IMPL_LINK( ScCellRangesBase, ValueListenerHdl, SfxHint*, pHint )
2755 if ( pDocShell && pHint && pHint->ISA( SfxSimpleHint ) &&
2756 (((const SfxSimpleHint*)pHint)->GetId() & SC_HINT_DATACHANGED))
2758 // This may be called several times for a single change, if several formulas
2759 // in the range are notified. So only a flag is set that is checked when
2760 // SFX_HINT_DATACHANGED is received.
2762 bGotDataChangedHint = true;
2764 return 0;
2767 // XTolerantMultiPropertySet
2768 uno::Sequence< beans::SetPropertyTolerantFailed > SAL_CALL ScCellRangesBase::setPropertyValuesTolerant( const uno::Sequence< OUString >& aPropertyNames,
2769 const uno::Sequence< uno::Any >& aValues )
2770 throw (lang::IllegalArgumentException, uno::RuntimeException, std::exception)
2772 SolarMutexGuard aGuard;
2774 sal_Int32 nCount(aPropertyNames.getLength());
2775 sal_Int32 nValues(aValues.getLength());
2776 if (nCount != nValues)
2777 throw lang::IllegalArgumentException();
2779 if ( pDocShell && nCount )
2781 uno::Sequence < beans::SetPropertyTolerantFailed > aReturns(nCount);
2782 beans::SetPropertyTolerantFailed* pReturns = aReturns.getArray();
2784 const SfxItemPropertyMap& rPropertyMap = GetItemPropertyMap(); // from derived class
2785 const OUString* pNames = aPropertyNames.getConstArray();
2786 const uno::Any* pValues = aValues.getConstArray();
2788 boost::scoped_array<const SfxItemPropertySimpleEntry*> pMapArray(new const SfxItemPropertySimpleEntry*[nCount]);
2790 sal_Int32 i;
2791 for(i = 0; i < nCount; i++)
2793 // first loop: find all properties in map, but handle only CellStyle
2794 // (CellStyle must be set before any other cell properties)
2796 const SfxItemPropertySimpleEntry* pEntry = rPropertyMap.getByName( pNames[i] );
2797 pMapArray[i] = pEntry;
2798 if (pEntry)
2800 if ( pEntry->nWID == SC_WID_UNO_CELLSTYL )
2804 SetOnePropertyValue( pEntry, pValues[i] );
2806 catch ( lang::IllegalArgumentException& )
2808 OSL_FAIL("exception when setting cell style"); // not supposed to happen
2814 ScDocument* pDoc = pDocShell->GetDocument();
2815 boost::scoped_ptr<ScPatternAttr> pOldPattern;
2816 boost::scoped_ptr<ScPatternAttr> pNewPattern;
2818 sal_Int32 nFailed(0);
2819 for(i = 0; i < nCount; i++)
2821 // second loop: handle other properties
2823 const SfxItemPropertySimpleEntry* pEntry = pMapArray[i];
2824 if ( pEntry && ((pEntry->nFlags & beans::PropertyAttribute::READONLY) == 0))
2826 if ( IsScItemWid( pEntry->nWID ) ) // can be handled by SfxItemPropertySet
2828 if ( !pOldPattern )
2830 pOldPattern.reset(new ScPatternAttr( *GetCurrentAttrsDeep() ));
2831 pOldPattern->GetItemSet().ClearInvalidItems();
2832 pNewPattern.reset(new ScPatternAttr( pDoc->GetPool() ));
2835 // collect items in pNewPattern, apply with one call after the loop
2837 sal_uInt16 nFirstItem, nSecondItem;
2840 lcl_SetCellProperty( *pEntry, pValues[i], *pOldPattern, pDoc, nFirstItem, nSecondItem );
2842 // put only affected items into new set
2843 if ( nFirstItem )
2844 pNewPattern->GetItemSet().Put( pOldPattern->GetItemSet().Get( nFirstItem ) );
2845 if ( nSecondItem )
2846 pNewPattern->GetItemSet().Put( pOldPattern->GetItemSet().Get( nSecondItem ) );
2848 catch ( lang::IllegalArgumentException& )
2850 pReturns[nFailed].Name = pNames[i];
2851 pReturns[nFailed++].Result = beans::TolerantPropertySetResultType::ILLEGAL_ARGUMENT;
2854 else if ( pEntry->nWID != SC_WID_UNO_CELLSTYL ) // CellStyle is handled above
2856 // call virtual method to set a single property
2859 SetOnePropertyValue( pEntry, pValues[i] );
2861 catch ( lang::IllegalArgumentException& )
2863 pReturns[nFailed].Name = pNames[i];
2864 pReturns[nFailed++].Result = beans::TolerantPropertySetResultType::ILLEGAL_ARGUMENT;
2868 else
2870 pReturns[nFailed].Name = pNames[i];
2871 if (pEntry)
2872 pReturns[nFailed++].Result = beans::TolerantPropertySetResultType::PROPERTY_VETO;
2873 else
2874 pReturns[nFailed++].Result = beans::TolerantPropertySetResultType::UNKNOWN_PROPERTY;
2878 if ( pNewPattern && !aRanges.empty() )
2879 pDocShell->GetDocFunc().ApplyAttributes( *GetMarkData(), *pNewPattern, true, true );
2881 aReturns.realloc(nFailed);
2883 return aReturns;
2885 return uno::Sequence < beans::SetPropertyTolerantFailed >();
2888 uno::Sequence< beans::GetPropertyTolerantResult > SAL_CALL ScCellRangesBase::getPropertyValuesTolerant( const uno::Sequence< OUString >& aPropertyNames )
2889 throw (uno::RuntimeException, std::exception)
2891 SolarMutexGuard aGuard;
2893 sal_Int32 nCount(aPropertyNames.getLength());
2894 uno::Sequence < beans::GetPropertyTolerantResult > aReturns(nCount);
2895 beans::GetPropertyTolerantResult* pReturns = aReturns.getArray();
2897 const SfxItemPropertyMap& rPropertyMap = GetItemPropertyMap(); // from derived class
2899 for(sal_Int32 i = 0; i < nCount; i++)
2901 const SfxItemPropertySimpleEntry* pEntry = rPropertyMap.getByName( aPropertyNames[i] );
2902 if (!pEntry)
2904 pReturns[i].Result = beans::TolerantPropertySetResultType::UNKNOWN_PROPERTY;
2906 else
2908 sal_uInt16 nItemWhich = 0;
2909 lcl_GetPropertyWhich( pEntry, nItemWhich );
2910 pReturns[i].State = GetOnePropertyState( nItemWhich, pEntry );
2911 GetOnePropertyValue( pEntry, pReturns[i].Value );
2912 pReturns[i].Result = beans::TolerantPropertySetResultType::SUCCESS;
2915 return aReturns;
2918 uno::Sequence< beans::GetDirectPropertyTolerantResult > SAL_CALL ScCellRangesBase::getDirectPropertyValuesTolerant( const uno::Sequence< OUString >& aPropertyNames )
2919 throw (uno::RuntimeException, std::exception)
2921 SolarMutexGuard aGuard;
2923 sal_Int32 nCount(aPropertyNames.getLength());
2924 uno::Sequence < beans::GetDirectPropertyTolerantResult > aReturns(nCount);
2925 beans::GetDirectPropertyTolerantResult* pReturns = aReturns.getArray();
2927 const SfxItemPropertyMap& rPropertyMap = GetItemPropertyMap(); // from derived class
2929 sal_Int32 j = 0;
2930 for(sal_Int32 i = 0; i < nCount; i++)
2932 const SfxItemPropertySimpleEntry* pEntry = rPropertyMap.getByName( aPropertyNames[i] );
2933 if (!pEntry)
2935 pReturns[i].Result = beans::TolerantPropertySetResultType::UNKNOWN_PROPERTY;
2937 else
2939 sal_uInt16 nItemWhich = 0;
2940 lcl_GetPropertyWhich( pEntry, nItemWhich );
2941 pReturns[j].State = GetOnePropertyState( nItemWhich, pEntry );
2942 if (pReturns[j].State == beans::PropertyState_DIRECT_VALUE)
2944 GetOnePropertyValue( pEntry, pReturns[j].Value );
2945 pReturns[j].Result = beans::TolerantPropertySetResultType::SUCCESS;
2946 pReturns[j].Name = aPropertyNames[i];
2947 ++j;
2951 if (j < nCount)
2952 aReturns.realloc(j);
2953 return aReturns;
2956 // XIndent
2958 void SAL_CALL ScCellRangesBase::decrementIndent() throw(::com::sun::star::uno::RuntimeException, std::exception)
2960 SolarMutexGuard aGuard;
2961 if ( pDocShell && !aRanges.empty() ) // leer = nichts zu tun
2963 //#97041#; put only MultiMarked ScMarkData in ChangeIndent
2964 ScMarkData aMarkData(*GetMarkData());
2965 aMarkData.MarkToMulti();
2966 pDocShell->GetDocFunc().ChangeIndent( aMarkData, false, true );
2970 void SAL_CALL ScCellRangesBase::incrementIndent() throw(::com::sun::star::uno::RuntimeException, std::exception)
2972 SolarMutexGuard aGuard;
2973 if ( pDocShell && !aRanges.empty() ) // leer = nichts zu tun
2975 //#97041#; put only MultiMarked ScMarkData in ChangeIndent
2976 ScMarkData aMarkData(*GetMarkData());
2977 aMarkData.MarkToMulti();
2978 pDocShell->GetDocFunc().ChangeIndent( aMarkData, true, true );
2982 // XChartData
2984 ScMemChart* ScCellRangesBase::CreateMemChart_Impl() const
2986 if ( pDocShell && !aRanges.empty() )
2988 ScRangeListRef xChartRanges;
2989 if ( aRanges.size() == 1 )
2991 // ganze Tabelle sinnvoll begrenzen (auf belegten Datenbereich)
2992 // (nur hier, Listener werden auf den ganzen Bereich angemeldet)
2993 //! direkt testen, ob es ein ScTableSheetObj ist?
2995 const ScRange* pRange = aRanges[0];
2996 if ( pRange->aStart.Col() == 0 && pRange->aEnd.Col() == MAXCOL &&
2997 pRange->aStart.Row() == 0 && pRange->aEnd.Row() == MAXROW )
2999 SCTAB nTab = pRange->aStart.Tab();
3001 SCCOL nStartX;
3002 SCROW nStartY; // Anfang holen
3003 if (!pDocShell->GetDocument()->GetDataStart( nTab, nStartX, nStartY ))
3005 nStartX = 0;
3006 nStartY = 0;
3009 SCCOL nEndX;
3010 SCROW nEndY; // Ende holen
3011 if (!pDocShell->GetDocument()->GetTableArea( nTab, nEndX, nEndY ))
3013 nEndX = 0;
3014 nEndY = 0;
3017 xChartRanges = new ScRangeList;
3018 xChartRanges->Append( ScRange( nStartX, nStartY, nTab, nEndX, nEndY, nTab ) );
3021 if (!xChartRanges.Is()) // sonst Ranges direkt uebernehmen
3022 xChartRanges = new ScRangeList(aRanges);
3023 ScChartArray aArr( pDocShell->GetDocument(), xChartRanges, OUString() );
3025 // RowAsHdr = ColHeaders und umgekehrt
3026 aArr.SetHeaders( bChartRowAsHdr, bChartColAsHdr );
3028 return aArr.CreateMemChart();
3030 return NULL;
3033 uno::Sequence< uno::Sequence<double> > SAL_CALL ScCellRangesBase::getData()
3034 throw(uno::RuntimeException, std::exception)
3036 SolarMutexGuard aGuard;
3037 boost::scoped_ptr<ScMemChart> pMemChart(CreateMemChart_Impl());
3038 if ( pMemChart )
3040 sal_Int32 nColCount = pMemChart->GetColCount();
3041 sal_Int32 nRowCount = static_cast<sal_Int32>(pMemChart->GetRowCount());
3043 uno::Sequence< uno::Sequence<double> > aRowSeq( nRowCount );
3044 uno::Sequence<double>* pRowAry = aRowSeq.getArray();
3045 for (sal_Int32 nRow = 0; nRow < nRowCount; nRow++)
3047 uno::Sequence<double> aColSeq( nColCount );
3048 double* pColAry = aColSeq.getArray();
3049 for (sal_Int32 nCol = 0; nCol < nColCount; nCol++)
3050 pColAry[nCol] = pMemChart->GetData( nCol, nRow );
3052 pRowAry[nRow] = aColSeq;
3055 return aRowSeq;
3058 return uno::Sequence< uno::Sequence<double> >(0);
3061 ScRangeListRef ScCellRangesBase::GetLimitedChartRanges_Impl( long nDataColumns, long nDataRows ) const
3063 if ( aRanges.size() == 1 )
3065 const ScRange* pRange = aRanges[0];
3066 if ( pRange->aStart.Col() == 0 && pRange->aEnd.Col() == MAXCOL &&
3067 pRange->aStart.Row() == 0 && pRange->aEnd.Row() == MAXROW )
3069 // if aRanges is a complete sheet, limit to given size
3071 SCTAB nTab = pRange->aStart.Tab();
3073 long nEndColumn = nDataColumns - 1 + ( bChartColAsHdr ? 1 : 0 );
3074 if ( nEndColumn < 0 )
3075 nEndColumn = 0;
3076 if ( nEndColumn > MAXCOL )
3077 nEndColumn = MAXCOL;
3079 long nEndRow = nDataRows - 1 + ( bChartRowAsHdr ? 1 : 0 );
3080 if ( nEndRow < 0 )
3081 nEndRow = 0;
3082 if ( nEndRow > MAXROW )
3083 nEndRow = MAXROW;
3085 ScRangeListRef xChartRanges = new ScRangeList;
3086 xChartRanges->Append( ScRange( 0, 0, nTab, (SCCOL)nEndColumn, (SCROW)nEndRow, nTab ) );
3087 return xChartRanges;
3091 return new ScRangeList(aRanges); // as-is
3094 void SAL_CALL ScCellRangesBase::setData( const uno::Sequence< uno::Sequence<double> >& aData )
3095 throw(uno::RuntimeException, std::exception)
3097 SolarMutexGuard aGuard;
3098 bool bDone = false;
3099 long nRowCount = aData.getLength();
3100 long nColCount = nRowCount ? aData[0].getLength() : 0;
3101 ScRangeListRef xChartRanges = GetLimitedChartRanges_Impl( nColCount, nRowCount );
3102 if ( pDocShell && xChartRanges.Is() )
3104 ScDocument* pDoc = pDocShell->GetDocument();
3105 ScChartArray aArr( pDoc, xChartRanges, OUString() );
3106 aArr.SetHeaders( bChartRowAsHdr, bChartColAsHdr ); // RowAsHdr = ColHeaders
3107 const ScChartPositionMap* pPosMap = aArr.GetPositionMap();
3108 if (pPosMap)
3110 if ( pPosMap->GetColCount() == static_cast<SCCOL>(nColCount) &&
3111 pPosMap->GetRowCount() == static_cast<SCROW>(nRowCount) )
3113 for (long nRow=0; nRow<nRowCount; nRow++)
3115 const uno::Sequence<double>& rRowSeq = aData[nRow];
3116 const double* pArray = rRowSeq.getConstArray();
3117 nColCount = rRowSeq.getLength();
3118 for (long nCol=0; nCol<nColCount; nCol++)
3120 const ScAddress* pPos = pPosMap->GetPosition(
3121 sal::static_int_cast<SCCOL>(nCol),
3122 sal::static_int_cast<SCROW>(nRow) );
3123 if (pPos)
3125 double fVal = pArray[nCol];
3126 if ( fVal == DBL_MIN )
3127 pDoc->SetEmptyCell(*pPos);
3128 else
3129 pDoc->SetValue(*pPos, pArray[nCol]);
3134 //! undo
3135 PaintRanges_Impl( PAINT_GRID );
3136 pDocShell->SetDocumentModified();
3137 ForceChartListener_Impl(); // call listeners for this object synchronously
3138 bDone = true;
3143 if (!bDone)
3144 throw uno::RuntimeException();
3147 uno::Sequence<OUString> SAL_CALL ScCellRangesBase::getRowDescriptions()
3148 throw(uno::RuntimeException, std::exception)
3150 SolarMutexGuard aGuard;
3151 boost::scoped_ptr<ScMemChart> pMemChart(CreateMemChart_Impl());
3152 if ( pMemChart )
3154 sal_Int32 nRowCount = static_cast<sal_Int32>(pMemChart->GetRowCount());
3155 uno::Sequence<OUString> aSeq( nRowCount );
3156 OUString* pAry = aSeq.getArray();
3157 for (sal_Int32 nRow = 0; nRow < nRowCount; nRow++)
3158 pAry[nRow] = pMemChart->GetRowText(nRow);
3160 return aSeq;
3162 return uno::Sequence<OUString>(0);
3165 void SAL_CALL ScCellRangesBase::setRowDescriptions(
3166 const uno::Sequence<OUString>& aRowDescriptions )
3167 throw(uno::RuntimeException, std::exception)
3169 SolarMutexGuard aGuard;
3170 bool bDone = false;
3171 if ( bChartColAsHdr )
3173 long nRowCount = aRowDescriptions.getLength();
3174 ScRangeListRef xChartRanges = GetLimitedChartRanges_Impl( 1, nRowCount );
3175 if ( pDocShell && xChartRanges.Is() )
3177 ScDocument* pDoc = pDocShell->GetDocument();
3178 ScChartArray aArr( pDoc, xChartRanges, OUString() );
3179 aArr.SetHeaders( bChartRowAsHdr, bChartColAsHdr ); // RowAsHdr = ColHeaders
3180 const ScChartPositionMap* pPosMap = aArr.GetPositionMap();
3181 if (pPosMap)
3183 if ( pPosMap->GetRowCount() == static_cast<SCROW>(nRowCount) )
3185 const OUString* pArray = aRowDescriptions.getConstArray();
3186 for (long nRow=0; nRow<nRowCount; nRow++)
3188 const ScAddress* pPos = pPosMap->GetRowHeaderPosition(
3189 static_cast<SCSIZE>(nRow) );
3190 if (pPos)
3192 const OUString& aStr = pArray[nRow];
3193 if (aStr.isEmpty())
3194 pDoc->SetEmptyCell(*pPos);
3195 else
3197 ScSetStringParam aParam;
3198 aParam.setTextInput();
3199 pDoc->SetString(*pPos, aStr, &aParam);
3204 //! undo
3205 PaintRanges_Impl( PAINT_GRID );
3206 pDocShell->SetDocumentModified();
3207 ForceChartListener_Impl(); // call listeners for this object synchronously
3208 bDone = true;
3214 if (!bDone)
3215 throw uno::RuntimeException();
3218 uno::Sequence<OUString> SAL_CALL ScCellRangesBase::getColumnDescriptions()
3219 throw(uno::RuntimeException, std::exception)
3221 SolarMutexGuard aGuard;
3222 boost::scoped_ptr<ScMemChart> pMemChart(CreateMemChart_Impl());
3223 if ( pMemChart )
3225 sal_Int32 nColCount = pMemChart->GetColCount();
3226 uno::Sequence<OUString> aSeq( nColCount );
3227 OUString* pAry = aSeq.getArray();
3228 for (sal_Int32 nCol = 0; nCol < nColCount; nCol++)
3229 pAry[nCol] = pMemChart->GetColText(nCol);
3231 return aSeq;
3233 return uno::Sequence<OUString>(0);
3236 void SAL_CALL ScCellRangesBase::setColumnDescriptions(
3237 const uno::Sequence<OUString>& aColumnDescriptions )
3238 throw(uno::RuntimeException, std::exception)
3240 SolarMutexGuard aGuard;
3241 bool bDone = false;
3242 if ( bChartRowAsHdr )
3244 long nColCount = aColumnDescriptions.getLength();
3245 ScRangeListRef xChartRanges = GetLimitedChartRanges_Impl( nColCount, 1 );
3246 if ( pDocShell && xChartRanges.Is() )
3248 ScDocument* pDoc = pDocShell->GetDocument();
3249 ScChartArray aArr( pDoc, xChartRanges, OUString() );
3250 aArr.SetHeaders( bChartRowAsHdr, bChartColAsHdr ); // RowAsHdr = ColHeaders
3251 const ScChartPositionMap* pPosMap = aArr.GetPositionMap();
3252 if (pPosMap)
3254 if ( pPosMap->GetColCount() == static_cast<SCCOL>(nColCount) )
3256 const OUString* pArray = aColumnDescriptions.getConstArray();
3257 for (long nCol=0; nCol<nColCount; nCol++)
3259 const ScAddress* pPos = pPosMap->GetColHeaderPosition(
3260 sal::static_int_cast<SCCOL>(nCol) );
3261 if (pPos)
3263 const OUString& aStr = pArray[nCol];
3264 if (aStr.isEmpty())
3265 pDoc->SetEmptyCell(*pPos);
3266 else
3268 ScSetStringParam aParam;
3269 aParam.setTextInput();
3270 pDoc->SetString(*pPos, aStr, &aParam);
3275 //! undo
3276 PaintRanges_Impl( PAINT_GRID );
3277 pDocShell->SetDocumentModified();
3278 ForceChartListener_Impl(); // call listeners for this object synchronously
3279 bDone = true;
3285 if (!bDone)
3286 throw uno::RuntimeException();
3289 void ScCellRangesBase::ForceChartListener_Impl()
3291 // call Update immediately so the caller to setData etc. can
3292 // regognize the listener call
3294 if (!pDocShell)
3295 return;
3297 ScChartListenerCollection* pColl = pDocShell->GetDocument()->GetChartListenerCollection();
3298 if (!pColl)
3299 return;
3301 ScChartListenerCollection::ListenersType& rListeners = pColl->getListeners();
3302 ScChartListenerCollection::ListenersType::iterator it = rListeners.begin(), itEnd = rListeners.end();
3303 for (; it != itEnd; ++it)
3305 ScChartListener* p = it->second;
3306 OSL_ASSERT(p);
3307 if (p->GetUnoSource() == static_cast<chart::XChartData*>(this) && p->IsDirty())
3308 p->Update();
3312 void SAL_CALL ScCellRangesBase::addChartDataChangeEventListener( const uno::Reference<
3313 chart::XChartDataChangeEventListener >& aListener )
3314 throw(uno::RuntimeException, std::exception)
3316 SolarMutexGuard aGuard;
3317 if ( pDocShell && !aRanges.empty() )
3319 //! auf doppelte testen?
3321 ScDocument* pDoc = pDocShell->GetDocument();
3322 ScRangeListRef aRangesRef( new ScRangeList(aRanges) );
3323 ScChartListenerCollection* pColl = pDoc->GetChartListenerCollection();
3324 OUString aName = pColl->getUniqueName(OUString("__Uno"));
3325 if (aName.isEmpty())
3326 // failed to create unique name.
3327 return;
3329 ScChartListener* pListener = new ScChartListener( aName, pDoc, aRangesRef );
3330 pListener->SetUno( aListener, this );
3331 pColl->insert( pListener );
3332 pListener->StartListeningTo();
3336 void SAL_CALL ScCellRangesBase::removeChartDataChangeEventListener( const uno::Reference<
3337 chart::XChartDataChangeEventListener >& aListener )
3338 throw (uno::RuntimeException, std::exception)
3340 SolarMutexGuard aGuard;
3341 if ( pDocShell && !aRanges.empty() )
3343 ScDocument* pDoc = pDocShell->GetDocument();
3344 ScChartListenerCollection* pColl = pDoc->GetChartListenerCollection();
3345 pColl->FreeUno( aListener, this );
3349 double SAL_CALL ScCellRangesBase::getNotANumber() throw(::com::sun::star::uno::RuntimeException, std::exception)
3351 // im ScChartArray wird DBL_MIN verwendet, weil das Chart es so will
3352 return DBL_MIN;
3355 sal_Bool SAL_CALL ScCellRangesBase::isNotANumber( double nNumber ) throw(uno::RuntimeException, std::exception)
3357 // im ScChartArray wird DBL_MIN verwendet, weil das Chart es so will
3358 return (nNumber == DBL_MIN);
3361 // XModifyBroadcaster
3363 void SAL_CALL ScCellRangesBase::addModifyListener(const uno::Reference<util::XModifyListener>& aListener)
3364 throw (uno::RuntimeException, std::exception)
3366 SolarMutexGuard aGuard;
3367 if ( aRanges.empty() )
3368 throw uno::RuntimeException();
3370 uno::Reference<util::XModifyListener> *pObj =
3371 new uno::Reference<util::XModifyListener>( aListener );
3372 aValueListeners.push_back( pObj );
3374 if ( aValueListeners.size() == 1 )
3376 if (!pValueListener)
3377 pValueListener = new ScLinkListener( LINK( this, ScCellRangesBase, ValueListenerHdl ) );
3379 ScDocument* pDoc = pDocShell->GetDocument();
3380 for ( size_t i = 0, nCount = aRanges.size(); i < nCount; i++)
3381 pDoc->StartListeningArea( *aRanges[ i ], pValueListener );
3383 acquire(); // don't lose this object (one ref for all listeners)
3387 void SAL_CALL ScCellRangesBase::removeModifyListener( const uno::Reference<util::XModifyListener>& aListener )
3388 throw(uno::RuntimeException, std::exception)
3391 SolarMutexGuard aGuard;
3392 if ( aRanges.empty() )
3393 throw uno::RuntimeException();
3395 acquire(); // in case the listeners have the last ref - released below
3397 sal_uInt16 nCount = aValueListeners.size();
3398 for ( sal_uInt16 n=nCount; n--; )
3400 uno::Reference<util::XModifyListener>& rObj = aValueListeners[n];
3401 if ( rObj == aListener )
3403 aValueListeners.erase( aValueListeners.begin() + n );
3405 if ( aValueListeners.empty() )
3407 if (pValueListener)
3408 pValueListener->EndListeningAll();
3410 release(); // release the ref for the listeners
3413 break;
3417 release(); // might delete this object
3420 // XCellRangesQuery
3422 uno::Reference<sheet::XSheetCellRanges> SAL_CALL ScCellRangesBase::queryVisibleCells()
3423 throw(uno::RuntimeException, std::exception)
3425 SolarMutexGuard aGuard;
3426 if (pDocShell)
3428 //! fuer alle Tabellen getrennt, wenn Markierungen pro Tabelle getrennt sind!
3429 SCTAB nTab = lcl_FirstTab(aRanges);
3431 ScMarkData aMarkData(*GetMarkData());
3433 ScDocument* pDoc = pDocShell->GetDocument();
3434 SCCOL nCol = 0, nLastCol;
3435 while (nCol <= MAXCOL)
3437 if (pDoc->ColHidden(nCol, nTab, NULL, &nLastCol))
3438 // hidden columns. Unselect them.
3439 aMarkData.SetMultiMarkArea(ScRange(nCol, 0, nTab, nLastCol, MAXROW, nTab), false);
3441 nCol = nLastCol + 1;
3444 SCROW nRow = 0, nLastRow;
3445 while (nRow <= MAXROW)
3447 if (pDoc->RowHidden(nRow, nTab, NULL, &nLastRow))
3448 // These rows are hidden. Unselect them.
3449 aMarkData.SetMultiMarkArea(ScRange(0, nRow, nTab, MAXCOL, nLastRow, nTab), false);
3451 nRow = nLastRow + 1;
3454 ScRangeList aNewRanges;
3455 aMarkData.FillRangeListWithMarks( &aNewRanges, false );
3456 return new ScCellRangesObj( pDocShell, aNewRanges );
3459 return NULL;
3462 uno::Reference<sheet::XSheetCellRanges> SAL_CALL ScCellRangesBase::queryEmptyCells()
3463 throw(uno::RuntimeException, std::exception)
3465 SolarMutexGuard aGuard;
3466 if (pDocShell)
3468 ScDocument* pDoc = pDocShell->GetDocument();
3470 ScMarkData aMarkData(*GetMarkData());
3472 // belegte Zellen wegmarkieren
3473 for (size_t i = 0, nCount = aRanges.size(); i < nCount; ++i)
3475 ScRange aRange = *aRanges[ i ];
3477 ScCellIterator aIter( pDoc, aRange );
3478 for (bool bHasCell = aIter.first(); bHasCell; bHasCell = aIter.next())
3480 // Notizen zaehlen als nicht-leer
3481 if (!aIter.isEmpty())
3482 aMarkData.SetMultiMarkArea(aIter.GetPos(), false);
3486 ScRangeList aNewRanges;
3487 // IsMultiMarked reicht hier nicht (wird beim deselektieren nicht zurueckgesetzt)
3488 //if (aMarkData.HasAnyMultiMarks()) // #i20044# should be set for all empty range
3489 aMarkData.FillRangeListWithMarks( &aNewRanges, false );
3491 return new ScCellRangesObj( pDocShell, aNewRanges ); // aNewRanges kann leer sein
3494 return NULL;
3497 uno::Reference<sheet::XSheetCellRanges> SAL_CALL ScCellRangesBase::queryContentCells(
3498 sal_Int16 nContentFlags )
3499 throw(uno::RuntimeException, std::exception)
3501 SolarMutexGuard aGuard;
3502 if (pDocShell)
3504 ScDocument* pDoc = pDocShell->GetDocument();
3506 ScMarkData aMarkData;
3508 // passende Zellen selektieren
3509 for ( size_t i = 0, nCount = aRanges.size(); i < nCount; ++i )
3511 ScRange aRange = *aRanges[ i ];
3513 ScCellIterator aIter( pDoc, aRange );
3514 for (bool bHasCell = aIter.first(); bHasCell; bHasCell = aIter.next())
3516 bool bAdd = false;
3517 switch (aIter.getType())
3519 case CELLTYPE_STRING:
3520 if ( nContentFlags & sheet::CellFlags::STRING )
3521 bAdd = true;
3522 break;
3523 case CELLTYPE_EDIT:
3524 if ( (nContentFlags & sheet::CellFlags::STRING) || (nContentFlags & sheet::CellFlags::FORMATTED) )
3525 bAdd = true;
3526 break;
3527 case CELLTYPE_FORMULA:
3528 if ( nContentFlags & sheet::CellFlags::FORMULA )
3529 bAdd = true;
3530 break;
3531 case CELLTYPE_VALUE:
3532 if ( (nContentFlags & (sheet::CellFlags::VALUE|sheet::CellFlags::DATETIME))
3533 == (sheet::CellFlags::VALUE|sheet::CellFlags::DATETIME) )
3534 bAdd = true;
3535 else
3537 // Date/Time Erkennung
3539 sal_uLong nIndex = (sal_uLong)((SfxUInt32Item*)pDoc->GetAttr(
3540 aIter.GetPos(), ATTR_VALUE_FORMAT))->GetValue();
3541 short nTyp = pDoc->GetFormatTable()->GetType(nIndex);
3542 if ((nTyp == NUMBERFORMAT_DATE) || (nTyp == NUMBERFORMAT_TIME) ||
3543 (nTyp == NUMBERFORMAT_DATETIME))
3545 if ( nContentFlags & sheet::CellFlags::DATETIME )
3546 bAdd = true;
3548 else
3550 if ( nContentFlags & sheet::CellFlags::VALUE )
3551 bAdd = true;
3554 break;
3555 default:
3557 // added to avoid warnings
3561 if (bAdd)
3562 aMarkData.SetMultiMarkArea(aIter.GetPos(), true);
3567 ScRangeList aNewRanges;
3568 if (aMarkData.IsMultiMarked())
3569 aMarkData.FillRangeListWithMarks( &aNewRanges, false );
3571 return new ScCellRangesObj( pDocShell, aNewRanges ); // aNewRanges kann leer sein
3574 return NULL;
3577 uno::Reference<sheet::XSheetCellRanges> SAL_CALL ScCellRangesBase::queryFormulaCells(
3578 sal_Int32 nResultFlags )
3579 throw(uno::RuntimeException, std::exception)
3581 SolarMutexGuard aGuard;
3582 if (pDocShell)
3584 ScDocument* pDoc = pDocShell->GetDocument();
3586 ScMarkData aMarkData;
3588 // passende Zellen selektieren
3589 for ( size_t i = 0, nCount = aRanges.size(); i < nCount; ++i )
3591 ScRange aRange = *aRanges[ i ];
3593 ScCellIterator aIter( pDoc, aRange );
3594 for (bool bHasCell = aIter.first(); bHasCell; bHasCell = aIter.next())
3596 if (aIter.getType() == CELLTYPE_FORMULA)
3598 ScFormulaCell* pFCell = aIter.getFormulaCell();
3599 bool bAdd = false;
3600 if (pFCell->GetErrCode())
3602 if ( nResultFlags & sheet::FormulaResult::ERROR )
3603 bAdd = true;
3605 else if (pFCell->IsValue())
3607 if ( nResultFlags & sheet::FormulaResult::VALUE )
3608 bAdd = true;
3610 else // String
3612 if ( nResultFlags & sheet::FormulaResult::STRING )
3613 bAdd = true;
3616 if (bAdd)
3617 aMarkData.SetMultiMarkArea(aIter.GetPos(), true);
3622 ScRangeList aNewRanges;
3623 if (aMarkData.IsMultiMarked())
3624 aMarkData.FillRangeListWithMarks( &aNewRanges, false );
3626 return new ScCellRangesObj( pDocShell, aNewRanges ); // aNewRanges kann leer sein
3629 return NULL;
3632 uno::Reference<sheet::XSheetCellRanges> ScCellRangesBase::QueryDifferences_Impl(
3633 const table::CellAddress& aCompare, bool bColumnDiff)
3635 if (pDocShell)
3637 size_t nRangeCount = aRanges.size();
3638 size_t i;
3639 ScDocument* pDoc = pDocShell->GetDocument();
3640 ScMarkData aMarkData;
3642 SCCOLROW nCmpPos = bColumnDiff ? (SCCOLROW)aCompare.Row : (SCCOLROW)aCompare.Column;
3644 // zuerst alles selektieren, wo ueberhaupt etwas in der Vergleichsspalte steht
3645 // (fuer gleiche Zellen wird die Selektion im zweiten Schritt aufgehoben)
3647 SCTAB nTab = lcl_FirstTab(aRanges); //! fuer alle Tabellen, wenn Markierungen pro Tabelle!
3648 ScRange aCmpRange, aCellRange;
3649 if (bColumnDiff)
3650 aCmpRange = ScRange( 0,nCmpPos,nTab, MAXCOL,nCmpPos,nTab );
3651 else
3652 aCmpRange = ScRange( static_cast<SCCOL>(nCmpPos),0,nTab, static_cast<SCCOL>(nCmpPos),MAXROW,nTab );
3653 ScCellIterator aCmpIter( pDoc, aCmpRange );
3654 for (bool bHasCell = aCmpIter.first(); bHasCell; bHasCell = aCmpIter.next())
3656 SCCOLROW nCellPos = bColumnDiff ? static_cast<SCCOLROW>(aCmpIter.GetPos().Col()) : static_cast<SCCOLROW>(aCmpIter.GetPos().Row());
3657 if (bColumnDiff)
3658 aCellRange = ScRange( static_cast<SCCOL>(nCellPos),0,nTab,
3659 static_cast<SCCOL>(nCellPos),MAXROW,nTab );
3660 else
3661 aCellRange = ScRange( 0,nCellPos,nTab, MAXCOL,nCellPos,nTab );
3663 for (i=0; i<nRangeCount; i++)
3665 ScRange aRange( *aRanges[ i ] );
3666 if ( aRange.Intersects( aCellRange ) )
3668 if (bColumnDiff)
3670 aRange.aStart.SetCol(static_cast<SCCOL>(nCellPos));
3671 aRange.aEnd.SetCol(static_cast<SCCOL>(nCellPos));
3673 else
3675 aRange.aStart.SetRow(nCellPos);
3676 aRange.aEnd.SetRow(nCellPos);
3678 aMarkData.SetMultiMarkArea( aRange );
3683 // alle nichtleeren Zellen mit der Vergleichsspalte vergleichen und entsprechend
3684 // selektieren oder aufheben
3686 ScAddress aCmpAddr;
3687 for (i=0; i<nRangeCount; i++)
3689 ScRange aRange( *aRanges[ i ] );
3691 ScCellIterator aIter( pDoc, aRange );
3692 for (bool bHasCell = aIter.first(); bHasCell; bHasCell = aIter.next())
3694 if (bColumnDiff)
3695 aCmpAddr = ScAddress( aIter.GetPos().Col(), nCmpPos, aIter.GetPos().Tab() );
3696 else
3697 aCmpAddr = ScAddress( static_cast<SCCOL>(nCmpPos), aIter.GetPos().Row(), aIter.GetPos().Tab() );
3699 ScRange aOneRange(aIter.GetPos());
3700 if (!aIter.equalsWithoutFormat(aCmpAddr))
3701 aMarkData.SetMultiMarkArea( aOneRange );
3702 else
3703 aMarkData.SetMultiMarkArea( aOneRange, false ); // deselect
3707 ScRangeList aNewRanges;
3708 if (aMarkData.IsMultiMarked())
3709 aMarkData.FillRangeListWithMarks( &aNewRanges, false );
3711 return new ScCellRangesObj( pDocShell, aNewRanges ); // aNewRanges kann leer sein
3713 return NULL;
3716 uno::Reference<sheet::XSheetCellRanges > SAL_CALL ScCellRangesBase::queryColumnDifferences(
3717 const table::CellAddress& aCompare ) throw(uno::RuntimeException, std::exception)
3719 SolarMutexGuard aGuard;
3720 return QueryDifferences_Impl( aCompare, true );
3723 uno::Reference<sheet::XSheetCellRanges> SAL_CALL ScCellRangesBase::queryRowDifferences(
3724 const table::CellAddress& aCompare ) throw(uno::RuntimeException, std::exception)
3726 SolarMutexGuard aGuard;
3727 return QueryDifferences_Impl( aCompare, false );
3730 uno::Reference<sheet::XSheetCellRanges> SAL_CALL ScCellRangesBase::queryIntersection(
3731 const table::CellRangeAddress& aRange ) throw(uno::RuntimeException, std::exception)
3733 SolarMutexGuard aGuard;
3734 ScRange aMask( (SCCOL)aRange.StartColumn, (SCROW)aRange.StartRow, aRange.Sheet,
3735 (SCCOL)aRange.EndColumn, (SCROW)aRange.EndRow, aRange.Sheet );
3737 ScRangeList aNew;
3738 for ( size_t i = 0, nCount = aRanges.size(); i < nCount; ++i )
3740 ScRange aTemp( *aRanges[ i ] );
3741 if ( aTemp.Intersects( aMask ) )
3742 aNew.Join( ScRange( std::max( aTemp.aStart.Col(), aMask.aStart.Col() ),
3743 std::max( aTemp.aStart.Row(), aMask.aStart.Row() ),
3744 std::max( aTemp.aStart.Tab(), aMask.aStart.Tab() ),
3745 std::min( aTemp.aEnd.Col(), aMask.aEnd.Col() ),
3746 std::min( aTemp.aEnd.Row(), aMask.aEnd.Row() ),
3747 std::min( aTemp.aEnd.Tab(), aMask.aEnd.Tab() ) ) );
3750 return new ScCellRangesObj( pDocShell, aNew ); // kann leer sein
3753 // XFormulaQuery
3755 uno::Reference<sheet::XSheetCellRanges> SAL_CALL ScCellRangesBase::queryPrecedents(
3756 sal_Bool bRecursive ) throw(uno::RuntimeException, std::exception)
3758 SolarMutexGuard aGuard;
3759 if ( pDocShell )
3761 ScDocument* pDoc = pDocShell->GetDocument();
3763 ScRangeList aNewRanges(aRanges);
3764 bool bFound;
3767 bFound = false;
3769 // aMarkData uses aNewRanges, not aRanges, so GetMarkData can't be used
3770 ScMarkData aMarkData;
3771 aMarkData.MarkFromRangeList( aNewRanges, false );
3772 aMarkData.MarkToMulti(); // needed for IsAllMarked
3774 for (size_t nR = 0, nCount = aNewRanges.size(); nR<nCount; ++nR)
3776 ScRange aRange( *aNewRanges[ nR] );
3777 ScCellIterator aIter( pDoc, aRange );
3778 for (bool bHasCell = aIter.first(); bHasCell; bHasCell = aIter.next())
3780 if (aIter.getType() != CELLTYPE_FORMULA)
3781 continue;
3783 ScDetectiveRefIter aRefIter(aIter.getFormulaCell());
3784 ScRange aRefRange;
3785 while ( aRefIter.GetNextRef( aRefRange) )
3787 if ( bRecursive && !bFound && !aMarkData.IsAllMarked( aRefRange ) )
3788 bFound = true;
3789 aMarkData.SetMultiMarkArea(aRefRange, true);
3794 aMarkData.FillRangeListWithMarks( &aNewRanges, true );
3796 while ( bRecursive && bFound );
3798 return new ScCellRangesObj( pDocShell, aNewRanges );
3801 return NULL;
3804 uno::Reference<sheet::XSheetCellRanges> SAL_CALL ScCellRangesBase::queryDependents(
3805 sal_Bool bRecursive ) throw(uno::RuntimeException, std::exception)
3807 SolarMutexGuard aGuard;
3808 if ( pDocShell )
3810 ScDocument* pDoc = pDocShell->GetDocument();
3812 ScRangeList aNewRanges(aRanges);
3813 bool bFound;
3816 bFound = false;
3818 // aMarkData uses aNewRanges, not aRanges, so GetMarkData can't be used
3819 ScMarkData aMarkData;
3820 aMarkData.MarkFromRangeList( aNewRanges, false );
3821 aMarkData.MarkToMulti(); // needed for IsAllMarked
3823 SCTAB nTab = lcl_FirstTab(aNewRanges); //! alle Tabellen
3825 ScCellIterator aCellIter( pDoc, ScRange(0, 0, nTab, MAXCOL, MAXROW, nTab) );
3826 for (bool bHasCell = aCellIter.first(); bHasCell; bHasCell = aCellIter.next())
3828 if (aCellIter.getType() != CELLTYPE_FORMULA)
3829 continue;
3831 bool bMark = false;
3832 ScDetectiveRefIter aIter(aCellIter.getFormulaCell());
3833 ScRange aRefRange;
3834 while ( aIter.GetNextRef( aRefRange) )
3836 size_t nRangesCount = aNewRanges.size();
3837 for (size_t nR = 0; nR < nRangesCount; ++nR)
3839 ScRange aRange( *aNewRanges[ nR ] );
3840 if (aRange.Intersects(aRefRange))
3841 bMark = true; // von Teil des Ranges abhaengig
3844 if (bMark)
3846 ScRange aCellRange(aCellIter.GetPos());
3847 if ( bRecursive && !bFound && !aMarkData.IsAllMarked( aCellRange ) )
3848 bFound = true;
3849 aMarkData.SetMultiMarkArea(aCellRange, true);
3853 aMarkData.FillRangeListWithMarks( &aNewRanges, true );
3855 while ( bRecursive && bFound );
3857 return new ScCellRangesObj( pDocShell, aNewRanges );
3860 return NULL;
3863 // XSearchable
3865 uno::Reference<util::XSearchDescriptor> SAL_CALL ScCellRangesBase::createSearchDescriptor()
3866 throw(uno::RuntimeException, std::exception)
3868 SolarMutexGuard aGuard;
3869 return new ScCellSearchObj;
3872 uno::Reference<container::XIndexAccess> SAL_CALL ScCellRangesBase::findAll(
3873 const uno::Reference<util::XSearchDescriptor>& xDesc )
3874 throw(uno::RuntimeException,
3875 std::exception)
3877 SolarMutexGuard aGuard;
3878 // Wenn nichts gefunden wird, soll Null zurueckgegeben werden (?)
3879 uno::Reference<container::XIndexAccess> xRet;
3880 if ( pDocShell && xDesc.is() )
3882 ScCellSearchObj* pSearch = ScCellSearchObj::getImplementation( xDesc );
3883 if (pSearch)
3885 SvxSearchItem* pSearchItem = pSearch->GetSearchItem();
3886 if (pSearchItem)
3888 ScDocument* pDoc = pDocShell->GetDocument();
3889 pSearchItem->SetCommand( SVX_SEARCHCMD_FIND_ALL );
3890 // immer nur innerhalb dieses Objekts
3891 pSearchItem->SetSelection( !lcl_WholeSheet(aRanges) );
3893 ScMarkData aMark(*GetMarkData());
3895 OUString aDummyUndo;
3896 ScRangeList aMatchedRanges;
3897 SCCOL nCol = 0;
3898 SCROW nRow = 0;
3899 SCTAB nTab = 0;
3900 bool bFound = pDoc->SearchAndReplace(
3901 *pSearchItem, nCol, nRow, nTab, aMark, aMatchedRanges, aDummyUndo, NULL);
3902 if (bFound)
3904 // bei findAll immer CellRanges, egal wieviel gefunden wurde
3905 xRet.set(new ScCellRangesObj( pDocShell, aMatchedRanges ));
3910 return xRet;
3913 uno::Reference<uno::XInterface> ScCellRangesBase::Find_Impl(
3914 const uno::Reference<util::XSearchDescriptor>& xDesc,
3915 const ScAddress* pLastPos )
3917 uno::Reference<uno::XInterface> xRet;
3918 if ( pDocShell && xDesc.is() )
3920 ScCellSearchObj* pSearch = ScCellSearchObj::getImplementation( xDesc );
3921 if (pSearch)
3923 SvxSearchItem* pSearchItem = pSearch->GetSearchItem();
3924 if (pSearchItem)
3926 ScDocument* pDoc = pDocShell->GetDocument();
3927 pSearchItem->SetCommand( SVX_SEARCHCMD_FIND );
3928 // immer nur innerhalb dieses Objekts
3929 pSearchItem->SetSelection( !lcl_WholeSheet(aRanges) );
3931 ScMarkData aMark(*GetMarkData());
3933 SCCOL nCol;
3934 SCROW nRow;
3935 SCTAB nTab;
3936 if (pLastPos)
3937 pLastPos->GetVars( nCol, nRow, nTab );
3938 else
3940 nTab = lcl_FirstTab(aRanges); //! mehrere Tabellen?
3941 ScDocument::GetSearchAndReplaceStart( *pSearchItem, nCol, nRow );
3944 OUString aDummyUndo;
3945 ScRangeList aMatchedRanges;
3946 bool bFound = pDoc->SearchAndReplace(
3947 *pSearchItem, nCol, nRow, nTab, aMark, aMatchedRanges, aDummyUndo, NULL);
3948 if (bFound)
3950 ScAddress aFoundPos( nCol, nRow, nTab );
3951 xRet.set((cppu::OWeakObject*) new ScCellObj( pDocShell, aFoundPos ));
3956 return xRet;
3959 uno::Reference<uno::XInterface> SAL_CALL ScCellRangesBase::findFirst(
3960 const uno::Reference<util::XSearchDescriptor>& xDesc )
3961 throw(uno::RuntimeException, std::exception)
3963 SolarMutexGuard aGuard;
3964 return Find_Impl( xDesc, NULL );
3967 uno::Reference<uno::XInterface> SAL_CALL ScCellRangesBase::findNext(
3968 const uno::Reference<uno::XInterface>& xStartAt,
3969 const uno::Reference<util::XSearchDescriptor >& xDesc )
3970 throw(uno::RuntimeException, std::exception)
3972 SolarMutexGuard aGuard;
3973 if ( xStartAt.is() )
3975 ScCellRangesBase* pRangesImp = ScCellRangesBase::getImplementation( xStartAt );
3976 if ( pRangesImp && pRangesImp->GetDocShell() == pDocShell )
3978 const ScRangeList& rStartRanges = pRangesImp->GetRangeList();
3979 if ( rStartRanges.size() == 1 )
3981 ScAddress aStartPos = rStartRanges[ 0 ]->aStart;
3982 return Find_Impl( xDesc, &aStartPos );
3986 return NULL;
3989 // XReplaceable
3991 uno::Reference<util::XReplaceDescriptor> SAL_CALL ScCellRangesBase::createReplaceDescriptor()
3992 throw(uno::RuntimeException, std::exception)
3994 SolarMutexGuard aGuard;
3995 return new ScCellSearchObj;
3998 sal_Int32 SAL_CALL ScCellRangesBase::replaceAll( const uno::Reference<util::XSearchDescriptor>& xDesc )
3999 throw(uno::RuntimeException,
4000 std::exception)
4002 SolarMutexGuard aGuard;
4003 sal_Int32 nReplaced = 0;
4004 if ( pDocShell && xDesc.is() )
4006 ScCellSearchObj* pSearch = ScCellSearchObj::getImplementation( xDesc );
4007 if (pSearch)
4009 SvxSearchItem* pSearchItem = pSearch->GetSearchItem();
4010 if (pSearchItem)
4012 ScDocument* pDoc = pDocShell->GetDocument();
4013 bool bUndo(pDoc->IsUndoEnabled());
4014 pSearchItem->SetCommand( SVX_SEARCHCMD_REPLACE_ALL );
4015 // immer nur innerhalb dieses Objekts
4016 pSearchItem->SetSelection( !lcl_WholeSheet(aRanges) );
4018 ScMarkData aMark(*GetMarkData());
4020 SCTAB nTabCount = pDoc->GetTableCount();
4021 bool bProtected = !pDocShell->IsEditable();
4022 ScMarkData::iterator itr = aMark.begin(), itrEnd = aMark.end();
4023 for (; itr != itrEnd && *itr < nTabCount; ++itr)
4024 if ( pDoc->IsTabProtected(*itr) )
4025 bProtected = true;
4026 if (bProtected)
4028 //! Exception, oder was?
4030 else
4032 SCTAB nTab = aMark.GetFirstSelected(); // bei SearchAndReplace nicht benutzt
4033 SCCOL nCol = 0;
4034 SCROW nRow = 0;
4036 OUString aUndoStr;
4037 ScDocument* pUndoDoc = NULL;
4038 if (bUndo)
4040 pUndoDoc = new ScDocument( SCDOCMODE_UNDO );
4041 pUndoDoc->InitUndo( pDoc, nTab, nTab );
4043 itr = aMark.begin();
4044 for (; itr != itrEnd && *itr < nTabCount; ++itr)
4045 if ( *itr != nTab && bUndo)
4046 pUndoDoc->AddUndoTab( *itr, *itr );
4047 boost::scoped_ptr<ScMarkData> pUndoMark;
4048 if (bUndo)
4049 pUndoMark.reset(new ScMarkData(aMark));
4051 bool bFound = false;
4052 if (bUndo)
4054 ScRangeList aMatchedRanges;
4055 bFound = pDoc->SearchAndReplace(
4056 *pSearchItem, nCol, nRow, nTab, aMark, aMatchedRanges, aUndoStr, pUndoDoc );
4058 if (bFound)
4060 nReplaced = pUndoDoc->GetCellCount();
4062 pDocShell->GetUndoManager()->AddUndoAction(
4063 new ScUndoReplace( pDocShell, *pUndoMark, nCol, nRow, nTab,
4064 aUndoStr, pUndoDoc, pSearchItem ) );
4066 pDocShell->PostPaintGridAll();
4067 pDocShell->SetDocumentModified();
4069 else
4071 delete pUndoDoc;
4072 // nReplaced bleibt 0
4078 return nReplaced;
4081 // XUnoTunnel
4083 sal_Int64 SAL_CALL ScCellRangesBase::getSomething(
4084 const uno::Sequence<sal_Int8 >& rId ) throw(uno::RuntimeException, std::exception)
4086 if ( rId.getLength() == 16 &&
4087 0 == memcmp( getUnoTunnelId().getConstArray(),
4088 rId.getConstArray(), 16 ) )
4090 return sal::static_int_cast<sal_Int64>(reinterpret_cast<sal_IntPtr>(this));
4092 return 0;
4095 namespace
4097 class theScCellRangesBaseUnoTunnelId : public rtl::Static< UnoTunnelIdInit, theScCellRangesBaseUnoTunnelId> {};
4100 const uno::Sequence<sal_Int8>& ScCellRangesBase::getUnoTunnelId()
4102 return theScCellRangesBaseUnoTunnelId::get().getSeq();
4105 ScCellRangesBase* ScCellRangesBase::getImplementation( const uno::Reference<uno::XInterface> xObj )
4107 ScCellRangesBase* pRet = NULL;
4108 uno::Reference<lang::XUnoTunnel> xUT( xObj, uno::UNO_QUERY );
4109 if (xUT.is())
4110 pRet = reinterpret_cast<ScCellRangesBase*>(sal::static_int_cast<sal_IntPtr>(xUT->getSomething(getUnoTunnelId())));
4111 return pRet;
4114 typedef boost::ptr_vector<ScNamedEntry> ScNamedEntryArr_Impl;
4116 struct ScCellRangesObj::Impl
4118 ScNamedEntryArr_Impl m_aNamedEntries;
4121 ScCellRangesObj::ScCellRangesObj(ScDocShell* pDocSh, const ScRangeList& rR)
4122 : ScCellRangesBase(pDocSh, rR)
4123 , m_pImpl(new Impl)
4127 ScCellRangesObj::~ScCellRangesObj()
4131 void ScCellRangesObj::RefChanged()
4133 ScCellRangesBase::RefChanged();
4135 // nix weiter...
4138 uno::Any SAL_CALL ScCellRangesObj::queryInterface( const uno::Type& rType )
4139 throw(uno::RuntimeException, std::exception)
4141 SC_QUERYINTERFACE( sheet::XSheetCellRangeContainer )
4142 SC_QUERYINTERFACE( sheet::XSheetCellRanges )
4143 SC_QUERYINTERFACE( container::XIndexAccess )
4144 SC_QUERY_MULTIPLE( container::XElementAccess, container::XIndexAccess )
4145 SC_QUERYINTERFACE( container::XEnumerationAccess )
4146 SC_QUERYINTERFACE( container::XNameContainer )
4147 SC_QUERYINTERFACE( container::XNameReplace )
4148 SC_QUERYINTERFACE( container::XNameAccess )
4150 return ScCellRangesBase::queryInterface( rType );
4153 void SAL_CALL ScCellRangesObj::acquire() throw()
4155 ScCellRangesBase::acquire();
4158 void SAL_CALL ScCellRangesObj::release() throw()
4160 ScCellRangesBase::release();
4163 uno::Sequence<uno::Type> SAL_CALL ScCellRangesObj::getTypes() throw(uno::RuntimeException, std::exception)
4165 static uno::Sequence<uno::Type> aTypes;
4166 if ( aTypes.getLength() == 0 )
4168 uno::Sequence<uno::Type> aParentTypes(ScCellRangesBase::getTypes());
4169 long nParentLen = aParentTypes.getLength();
4170 const uno::Type* pParentPtr = aParentTypes.getConstArray();
4172 aTypes.realloc( nParentLen + 3 );
4173 uno::Type* pPtr = aTypes.getArray();
4174 pPtr[nParentLen + 0] = cppu::UnoType<sheet::XSheetCellRangeContainer>::get();
4175 pPtr[nParentLen + 1] = cppu::UnoType<container::XNameContainer>::get();
4176 pPtr[nParentLen + 2] = cppu::UnoType<container::XEnumerationAccess>::get();
4178 for (long i=0; i<nParentLen; i++)
4179 pPtr[i] = pParentPtr[i]; // parent types first
4181 return aTypes;
4184 uno::Sequence<sal_Int8> SAL_CALL ScCellRangesObj::getImplementationId()
4185 throw(uno::RuntimeException, std::exception)
4187 return css::uno::Sequence<sal_Int8>();
4190 // XCellRanges
4192 ScCellRangeObj* ScCellRangesObj::GetObjectByIndex_Impl(sal_Int32 nIndex) const
4194 ScDocShell* pDocSh = GetDocShell();
4195 const ScRangeList& rRanges = GetRangeList();
4196 if ( pDocSh && nIndex >= 0 && nIndex < sal::static_int_cast<sal_Int32>(rRanges.size()) )
4198 ScRange aRange( *rRanges[ nIndex ] );
4199 if ( aRange.aStart == aRange.aEnd )
4200 return new ScCellObj( pDocSh, aRange.aStart );
4201 else
4202 return new ScCellRangeObj( pDocSh, aRange );
4205 return NULL; // keine DocShell oder falscher Index
4208 uno::Sequence<table::CellRangeAddress> SAL_CALL ScCellRangesObj::getRangeAddresses()
4209 throw(uno::RuntimeException, std::exception)
4211 SolarMutexGuard aGuard;
4212 ScDocShell* pDocSh = GetDocShell();
4213 const ScRangeList& rRanges = GetRangeList();
4214 size_t nCount = rRanges.size();
4215 if ( pDocSh && nCount )
4217 table::CellRangeAddress aRangeAddress;
4218 uno::Sequence<table::CellRangeAddress> aSeq(nCount);
4219 table::CellRangeAddress* pAry = aSeq.getArray();
4220 for ( size_t i=0; i < nCount; i++)
4222 ScUnoConversion::FillApiRange( aRangeAddress, *rRanges[ i ] );
4223 pAry[i] = aRangeAddress;
4225 return aSeq;
4228 return uno::Sequence<table::CellRangeAddress>(0); // leer ist moeglich
4231 uno::Reference<container::XEnumerationAccess> SAL_CALL ScCellRangesObj::getCells()
4232 throw(uno::RuntimeException, std::exception)
4234 SolarMutexGuard aGuard;
4236 // getCells with empty range list is possible (no exception),
4237 // the resulting enumeration just has no elements
4238 // (same behaviour as a valid range with no cells)
4239 // This is handled in ScCellsEnumeration ctor.
4241 const ScRangeList& rRanges = GetRangeList();
4242 ScDocShell* pDocSh = GetDocShell();
4243 if (pDocSh)
4244 return new ScCellsObj( pDocSh, rRanges );
4245 return NULL;
4248 OUString SAL_CALL ScCellRangesObj::getRangeAddressesAsString()
4249 throw(uno::RuntimeException, std::exception)
4251 SolarMutexGuard aGuard;
4252 OUString aString;
4253 ScDocShell* pDocSh = GetDocShell();
4254 const ScRangeList& rRanges = GetRangeList();
4255 if (pDocSh)
4256 rRanges.Format( aString, SCA_VALID | SCA_TAB_3D, pDocSh->GetDocument() );
4257 return aString;
4260 // XSheetCellRangeContainer
4262 void SAL_CALL ScCellRangesObj::addRangeAddress( const table::CellRangeAddress& rRange,
4263 sal_Bool bMergeRanges )
4264 throw(::com::sun::star::uno::RuntimeException, std::exception)
4266 SolarMutexGuard aGuard;
4267 ScRange aRange(static_cast<SCCOL>(rRange.StartColumn),
4268 static_cast<SCROW>(rRange.StartRow),
4269 static_cast<SCTAB>(rRange.Sheet),
4270 static_cast<SCCOL>(rRange.EndColumn),
4271 static_cast<SCROW>(rRange.EndRow),
4272 static_cast<SCTAB>(rRange.Sheet));
4273 AddRange(aRange, bMergeRanges);
4276 static void lcl_RemoveNamedEntry( ScNamedEntryArr_Impl& rNamedEntries, const ScRange& rRange )
4278 sal_uInt16 nCount = rNamedEntries.size();
4279 for ( sal_uInt16 n=nCount; n--; )
4280 if ( rNamedEntries[n].GetRange() == rRange )
4281 rNamedEntries.erase( rNamedEntries.begin() + n );
4284 void SAL_CALL ScCellRangesObj::removeRangeAddress( const table::CellRangeAddress& rRange )
4285 throw(::com::sun::star::container::NoSuchElementException,
4286 ::com::sun::star::uno::RuntimeException, std::exception)
4288 SolarMutexGuard aGuard;
4289 const ScRangeList& rRanges = GetRangeList();
4291 ScRangeList aSheetRanges;
4292 ScRangeList aNotSheetRanges;
4293 for (size_t i = 0; i < rRanges.size(); ++i)
4295 if (rRanges[ i]->aStart.Tab() == rRange.Sheet)
4297 aSheetRanges.Append( *rRanges[ i ] );
4299 else
4301 aNotSheetRanges.Append( *rRanges[ i ] );
4304 ScMarkData aMarkData;
4305 aMarkData.MarkFromRangeList( aSheetRanges, false );
4306 ScRange aRange(static_cast<SCCOL>(rRange.StartColumn),
4307 static_cast<SCROW>(rRange.StartRow),
4308 static_cast<SCTAB>(rRange.Sheet),
4309 static_cast<SCCOL>(rRange.EndColumn),
4310 static_cast<SCROW>(rRange.EndRow),
4311 static_cast<SCTAB>(rRange.Sheet));
4312 if (aMarkData.GetTableSelect( aRange.aStart.Tab() ))
4314 aMarkData.MarkToMulti();
4315 if (aMarkData.IsAllMarked( aRange ) )
4317 aMarkData.SetMultiMarkArea( aRange, false );
4318 lcl_RemoveNamedEntry(m_pImpl->m_aNamedEntries, aRange);
4320 else
4321 throw container::NoSuchElementException();
4323 SetNewRanges(aNotSheetRanges);
4324 ScRangeList aNew;
4325 aMarkData.FillRangeListWithMarks( &aNew, false );
4326 for ( size_t j = 0; j < aNew.size(); ++j)
4328 AddRange(*aNew[ j ], false);
4332 void SAL_CALL ScCellRangesObj::addRangeAddresses( const uno::Sequence<table::CellRangeAddress >& rRanges,
4333 sal_Bool bMergeRanges )
4334 throw(::com::sun::star::uno::RuntimeException, std::exception)
4336 SolarMutexGuard aGuard;
4337 sal_Int32 nCount(rRanges.getLength());
4338 if (nCount)
4340 const table::CellRangeAddress* pRanges = rRanges.getConstArray();
4341 for (sal_Int32 i = 0; i < rRanges.getLength(); i++, pRanges++)
4343 ScRange aRange(static_cast<SCCOL>(pRanges->StartColumn),
4344 static_cast<SCROW>(pRanges->StartRow),
4345 static_cast<SCTAB>(pRanges->Sheet),
4346 static_cast<SCCOL>(pRanges->EndColumn),
4347 static_cast<SCROW>(pRanges->EndRow),
4348 static_cast<SCTAB>(pRanges->Sheet));
4349 AddRange(aRange, bMergeRanges);
4354 void SAL_CALL ScCellRangesObj::removeRangeAddresses( const uno::Sequence<table::CellRangeAddress >& rRangeSeq )
4355 throw(::com::sun::star::container::NoSuchElementException,
4356 ::com::sun::star::uno::RuntimeException, std::exception)
4358 // use sometimes a better/faster implementation
4359 sal_uInt32 nCount(rRangeSeq.getLength());
4360 if (nCount)
4362 const table::CellRangeAddress* pRanges = rRangeSeq.getConstArray();
4363 for (sal_uInt32 i=0; i < nCount; ++i, ++pRanges)
4365 removeRangeAddress(*pRanges);
4370 // XNameContainer
4372 static void lcl_RemoveNamedEntry( ScNamedEntryArr_Impl& rNamedEntries, const OUString& rName )
4374 sal_uInt16 nCount = rNamedEntries.size();
4375 for ( sal_uInt16 n=nCount; n--; )
4376 if ( rNamedEntries[n].GetName() == rName )
4377 rNamedEntries.erase( rNamedEntries.begin() + n );
4380 void SAL_CALL ScCellRangesObj::insertByName( const OUString& aName, const uno::Any& aElement )
4381 throw (lang::IllegalArgumentException, container::ElementExistException,
4382 lang::WrappedTargetException, uno::RuntimeException,
4383 std::exception)
4385 SolarMutexGuard aGuard;
4386 ScDocShell* pDocSh = GetDocShell();
4387 bool bDone = false;
4389 //! Type of aElement can be some specific interface instead of XInterface
4391 uno::Reference<uno::XInterface> xInterface(aElement, uno::UNO_QUERY);
4392 if ( pDocSh && xInterface.is() )
4394 ScCellRangesBase* pRangesImp = ScCellRangesBase::getImplementation( xInterface );
4395 if ( pRangesImp && pRangesImp->GetDocShell() == pDocSh )
4397 // if explicit name is given and already existing, throw exception
4399 OUString aNamStr(aName);
4400 if ( !aNamStr.isEmpty() )
4402 size_t nNamedCount = m_pImpl->m_aNamedEntries.size();
4403 for (size_t n = 0; n < nNamedCount; n++)
4405 if (m_pImpl->m_aNamedEntries[n].GetName() == aNamStr)
4406 throw container::ElementExistException();
4410 ScRangeList aNew(GetRangeList());
4411 const ScRangeList& rAddRanges = pRangesImp->GetRangeList();
4412 size_t nAddCount = rAddRanges.size();
4413 for ( size_t i = 0; i < nAddCount; i++ )
4414 aNew.Join( *rAddRanges[ i ] );
4415 SetNewRanges(aNew);
4416 bDone = true;
4418 if ( !aName.isEmpty() && nAddCount == 1 )
4420 // if a name is given, also insert into list of named entries
4421 // (only possible for a single range)
4422 // name is not in m_pImpl->m_aNamedEntries (tested above)
4424 ScNamedEntry* pEntry = new ScNamedEntry( aNamStr, *rAddRanges[ 0 ] );
4425 m_pImpl->m_aNamedEntries.push_back(pEntry);
4430 if (!bDone)
4432 // invalid element - double names are handled above
4433 throw lang::IllegalArgumentException();
4437 static bool lcl_FindRangeByName( const ScRangeList& rRanges, ScDocShell* pDocSh,
4438 const OUString& rName, size_t& rIndex )
4440 if (pDocSh)
4442 OUString aRangeStr;
4443 ScDocument* pDoc = pDocSh->GetDocument();
4444 for ( size_t i = 0, nCount = rRanges.size(); i < nCount; i++ )
4446 aRangeStr = rRanges[ i ]->Format(SCA_VALID | SCA_TAB_3D, pDoc);
4447 if ( aRangeStr == rName )
4449 rIndex = i;
4450 return true;
4454 return false; // nicht gefunden
4457 static bool lcl_FindRangeOrEntry( const ScNamedEntryArr_Impl& rNamedEntries,
4458 const ScRangeList& rRanges, ScDocShell* pDocSh,
4459 const OUString& rName, ScRange& rFound )
4461 // exact range in list?
4463 size_t nIndex = 0;
4464 if ( lcl_FindRangeByName( rRanges, pDocSh, rName, nIndex ) )
4466 rFound = *rRanges[ nIndex ];
4467 return true;
4470 // range contained in selection? (sheet must be specified)
4472 ScRange aCellRange;
4473 sal_uInt16 nParse = aCellRange.ParseAny( rName, pDocSh->GetDocument() );
4474 if ( ( nParse & ( SCA_VALID | SCA_TAB_3D ) ) == ( SCA_VALID | SCA_TAB_3D ) )
4476 ScMarkData aMarkData;
4477 aMarkData.MarkFromRangeList( rRanges, false );
4478 aMarkData.MarkToMulti(); // needed for IsAllMarked
4479 if ( aMarkData.IsAllMarked( aCellRange ) )
4481 rFound = aCellRange;
4482 return true;
4486 // named entry in this object?
4488 if ( !rNamedEntries.empty() )
4490 for ( sal_uInt16 n=0; n<rNamedEntries.size(); n++ )
4491 if ( rNamedEntries[n].GetName() == rName )
4493 // test if named entry is contained in rRanges
4495 const ScRange& rComp = rNamedEntries[n].GetRange();
4496 ScMarkData aMarkData;
4497 aMarkData.MarkFromRangeList( rRanges, false );
4498 aMarkData.MarkToMulti(); // needed for IsAllMarked
4499 if ( aMarkData.IsAllMarked( rComp ) )
4501 rFound = rComp;
4502 return true;
4507 return false; // not found
4510 void SAL_CALL ScCellRangesObj::removeByName( const OUString& aName )
4511 throw(container::NoSuchElementException,
4512 lang::WrappedTargetException, uno::RuntimeException, std::exception)
4514 SolarMutexGuard aGuard;
4515 bool bDone = false;
4516 OUString aNameStr(aName);
4517 ScDocShell* pDocSh = GetDocShell();
4518 const ScRangeList& rRanges = GetRangeList();
4519 size_t nIndex = 0;
4520 if ( lcl_FindRangeByName( rRanges, pDocSh, aNameStr, nIndex ) )
4522 // einzelnen Range weglassen
4523 ScRangeList aNew;
4524 for ( size_t i = 0, nCount = rRanges.size(); i < nCount; i++ )
4525 if (i != nIndex)
4526 aNew.Append( *rRanges[ i ] );
4527 SetNewRanges(aNew);
4528 bDone = true;
4530 else if (pDocSh)
4532 // deselect any ranges (parsed or named entry)
4533 ScRangeList aDiff;
4534 bool bValid = ( aDiff.Parse( aNameStr, pDocSh->GetDocument() ) & SCA_VALID ) != 0;
4535 if (!bValid && !m_pImpl->m_aNamedEntries.empty())
4537 sal_uInt16 nCount = m_pImpl->m_aNamedEntries.size();
4538 for (sal_uInt16 n=0; n<nCount && !bValid; n++)
4539 if (m_pImpl->m_aNamedEntries[n].GetName() == aNameStr)
4541 aDiff.RemoveAll();
4542 aDiff.Append(m_pImpl->m_aNamedEntries[n].GetRange());
4543 bValid = true;
4546 if ( bValid )
4548 ScMarkData aMarkData;
4549 aMarkData.MarkFromRangeList( rRanges, false );
4551 for ( size_t i = 0, nDiffCount = aDiff.size(); i < nDiffCount; i++ )
4553 ScRange* pDiffRange = aDiff[ i ];
4554 if (aMarkData.GetTableSelect( pDiffRange->aStart.Tab() ))
4555 aMarkData.SetMultiMarkArea( *pDiffRange, false );
4558 ScRangeList aNew;
4559 aMarkData.FillRangeListWithMarks( &aNew, false );
4560 SetNewRanges(aNew);
4562 bDone = true; //! error if range was not selected before?
4566 if (!m_pImpl->m_aNamedEntries.empty())
4567 lcl_RemoveNamedEntry(m_pImpl->m_aNamedEntries, aNameStr);
4569 if (!bDone)
4570 throw container::NoSuchElementException(); // not found
4573 // XNameReplace
4575 void SAL_CALL ScCellRangesObj::replaceByName( const OUString& aName, const uno::Any& aElement )
4576 throw(lang::IllegalArgumentException, container::NoSuchElementException,
4577 lang::WrappedTargetException, uno::RuntimeException, std::exception)
4579 SolarMutexGuard aGuard;
4580 //! zusammenfassen?
4581 removeByName( aName );
4582 insertByName( aName, aElement );
4585 // XNameAccess
4587 uno::Any SAL_CALL ScCellRangesObj::getByName( const OUString& aName )
4588 throw(container::NoSuchElementException,
4589 lang::WrappedTargetException, uno::RuntimeException, std::exception)
4591 SolarMutexGuard aGuard;
4592 uno::Any aRet;
4594 OUString aNameStr(aName);
4595 ScDocShell* pDocSh = GetDocShell();
4596 const ScRangeList& rRanges = GetRangeList();
4597 ScRange aRange;
4598 if (lcl_FindRangeOrEntry(m_pImpl->m_aNamedEntries, rRanges,
4599 pDocSh, aNameStr, aRange))
4601 uno::Reference<table::XCellRange> xRange;
4602 if ( aRange.aStart == aRange.aEnd )
4603 xRange.set(new ScCellObj( pDocSh, aRange.aStart ));
4604 else
4605 xRange.set(new ScCellRangeObj( pDocSh, aRange ));
4606 aRet <<= xRange;
4608 else
4609 throw container::NoSuchElementException();
4610 return aRet;
4613 static bool lcl_FindEntryName( const ScNamedEntryArr_Impl& rNamedEntries,
4614 const ScRange& rRange, OUString& rName )
4616 sal_uInt16 nCount = rNamedEntries.size();
4617 for (sal_uInt16 i=0; i<nCount; i++)
4618 if (rNamedEntries[i].GetRange() == rRange)
4620 rName = rNamedEntries[i].GetName();
4621 return true;
4623 return false;
4626 uno::Sequence<OUString> SAL_CALL ScCellRangesObj::getElementNames()
4627 throw(uno::RuntimeException, std::exception)
4629 SolarMutexGuard aGuard;
4631 ScDocShell* pDocSh = GetDocShell();
4632 const ScRangeList& rRanges = GetRangeList();
4633 if (pDocSh)
4635 OUString aRangeStr;
4636 ScDocument* pDoc = pDocSh->GetDocument();
4637 size_t nCount = rRanges.size();
4639 uno::Sequence<OUString> aSeq(nCount);
4640 OUString* pAry = aSeq.getArray();
4641 for (size_t i=0; i < nCount; i++)
4643 // use given name if for exactly this range, otherwise just format
4644 ScRange aRange = *rRanges[ i ];
4645 if (m_pImpl->m_aNamedEntries.empty() ||
4646 !lcl_FindEntryName(m_pImpl->m_aNamedEntries, aRange, aRangeStr))
4648 aRangeStr = aRange.Format(SCA_VALID | SCA_TAB_3D, pDoc);
4650 pAry[i] = aRangeStr;
4652 return aSeq;
4654 return uno::Sequence<OUString>(0);
4657 sal_Bool SAL_CALL ScCellRangesObj::hasByName( const OUString& aName )
4658 throw(uno::RuntimeException, std::exception)
4660 SolarMutexGuard aGuard;
4661 OUString aNameStr(aName);
4662 ScDocShell* pDocSh = GetDocShell();
4663 const ScRangeList& rRanges = GetRangeList();
4664 ScRange aRange;
4665 return lcl_FindRangeOrEntry(m_pImpl->m_aNamedEntries, rRanges, pDocSh,
4666 aNameStr, aRange);
4669 // XEnumerationAccess
4671 uno::Reference<container::XEnumeration> SAL_CALL ScCellRangesObj::createEnumeration()
4672 throw(uno::RuntimeException, std::exception)
4674 SolarMutexGuard aGuard;
4675 return new ScIndexEnumeration(this, OUString("com.sun.star.sheet.SheetCellRangesEnumeration"));
4678 // XIndexAccess
4680 sal_Int32 SAL_CALL ScCellRangesObj::getCount() throw(uno::RuntimeException, std::exception)
4682 SolarMutexGuard aGuard;
4683 const ScRangeList& rRanges = GetRangeList();
4684 return rRanges.size();
4687 uno::Any SAL_CALL ScCellRangesObj::getByIndex( sal_Int32 nIndex )
4688 throw(lang::IndexOutOfBoundsException,
4689 lang::WrappedTargetException, uno::RuntimeException, std::exception)
4691 SolarMutexGuard aGuard;
4692 uno::Reference<table::XCellRange> xRange(GetObjectByIndex_Impl(nIndex));
4693 if (xRange.is())
4694 return uno::makeAny(xRange);
4695 else
4696 throw lang::IndexOutOfBoundsException();
4699 uno::Type SAL_CALL ScCellRangesObj::getElementType() throw(uno::RuntimeException, std::exception)
4701 SolarMutexGuard aGuard;
4702 return cppu::UnoType<table::XCellRange>::get();
4705 sal_Bool SAL_CALL ScCellRangesObj::hasElements() throw(uno::RuntimeException, std::exception)
4707 SolarMutexGuard aGuard;
4708 const ScRangeList& rRanges = GetRangeList();
4709 return !rRanges.empty();
4712 // XServiceInfo
4713 OUString SAL_CALL ScCellRangesObj::getImplementationName() throw(uno::RuntimeException, std::exception)
4715 return OUString( "ScCellRangesObj" );
4718 sal_Bool SAL_CALL ScCellRangesObj::supportsService( const OUString& rServiceName )
4719 throw(uno::RuntimeException, std::exception)
4721 return cppu::supportsService(this, rServiceName);
4724 uno::Sequence<OUString> SAL_CALL ScCellRangesObj::getSupportedServiceNames()
4725 throw(uno::RuntimeException, std::exception)
4727 uno::Sequence<OUString> aRet(4);
4728 OUString* pArray = aRet.getArray();
4729 pArray[0] = OUString( SCSHEETCELLRANGES_SERVICE );
4730 pArray[1] = OUString( SCCELLPROPERTIES_SERVICE );
4731 pArray[2] = OUString( SCCHARPROPERTIES_SERVICE );
4732 pArray[3] = OUString( SCPARAPROPERTIES_SERVICE );
4733 return aRet;
4736 uno::Reference<table::XCellRange> ScCellRangeObj::CreateRangeFromDoc( ScDocument* pDoc, const ScRange& rR )
4738 SfxObjectShell* pObjSh = pDoc->GetDocumentShell();
4739 if ( pObjSh && pObjSh->ISA(ScDocShell) )
4740 return new ScCellRangeObj( (ScDocShell*) pObjSh, rR );
4741 return NULL;
4744 ScCellRangeObj::ScCellRangeObj(ScDocShell* pDocSh, const ScRange& rR) :
4745 ScCellRangesBase( pDocSh, rR ),
4746 pRangePropSet( lcl_GetRangePropertySet() ),
4747 aRange( rR )
4749 aRange.Justify(); // Anfang / Ende richtig
4752 ScCellRangeObj::~ScCellRangeObj()
4756 void ScCellRangeObj::RefChanged()
4758 ScCellRangesBase::RefChanged();
4760 const ScRangeList& rRanges = GetRangeList();
4761 OSL_ENSURE(rRanges.size() == 1, "was fuer Ranges ?!?!");
4762 if ( !rRanges.empty() )
4764 const ScRange* pFirst = rRanges[0];
4765 aRange = ScRange(*pFirst);
4766 aRange.Justify();
4770 uno::Any SAL_CALL ScCellRangeObj::queryInterface( const uno::Type& rType )
4771 throw(uno::RuntimeException, std::exception)
4773 SC_QUERYINTERFACE( sheet::XCellRangeAddressable )
4774 SC_QUERYINTERFACE( table::XCellRange )
4775 SC_QUERYINTERFACE( sheet::XSheetCellRange )
4776 SC_QUERYINTERFACE( sheet::XArrayFormulaRange )
4777 SC_QUERYINTERFACE( sheet::XArrayFormulaTokens )
4778 SC_QUERYINTERFACE( sheet::XCellRangeData )
4779 SC_QUERYINTERFACE( sheet::XCellRangeFormula )
4780 SC_QUERYINTERFACE( sheet::XMultipleOperation )
4781 SC_QUERYINTERFACE( util::XMergeable )
4782 SC_QUERYINTERFACE( sheet::XCellSeries )
4783 SC_QUERYINTERFACE( table::XAutoFormattable )
4784 SC_QUERYINTERFACE( util::XSortable )
4785 SC_QUERYINTERFACE( sheet::XSheetFilterableEx )
4786 SC_QUERYINTERFACE( sheet::XSheetFilterable )
4787 SC_QUERYINTERFACE( sheet::XSubTotalCalculatable )
4788 SC_QUERYINTERFACE( table::XColumnRowRange )
4789 SC_QUERYINTERFACE( util::XImportable )
4790 SC_QUERYINTERFACE( sheet::XCellFormatRangesSupplier )
4791 SC_QUERYINTERFACE( sheet::XUniqueCellFormatRangesSupplier )
4793 return ScCellRangesBase::queryInterface( rType );
4796 void SAL_CALL ScCellRangeObj::acquire() throw()
4798 ScCellRangesBase::acquire();
4801 void SAL_CALL ScCellRangeObj::release() throw()
4803 ScCellRangesBase::release();
4806 uno::Sequence<uno::Type> SAL_CALL ScCellRangeObj::getTypes() throw(uno::RuntimeException, std::exception)
4808 static uno::Sequence<uno::Type> aTypes;
4809 if ( aTypes.getLength() == 0 )
4811 uno::Sequence<uno::Type> aParentTypes(ScCellRangesBase::getTypes());
4812 long nParentLen = aParentTypes.getLength();
4813 const uno::Type* pParentPtr = aParentTypes.getConstArray();
4815 aTypes.realloc( nParentLen + 17 );
4816 uno::Type* pPtr = aTypes.getArray();
4817 pPtr[nParentLen + 0] = cppu::UnoType<sheet::XCellRangeAddressable>::get();
4818 pPtr[nParentLen + 1] = cppu::UnoType<sheet::XSheetCellRange>::get();
4819 pPtr[nParentLen + 2] = cppu::UnoType<sheet::XArrayFormulaRange>::get();
4820 pPtr[nParentLen + 3] = cppu::UnoType<sheet::XArrayFormulaTokens>::get();
4821 pPtr[nParentLen + 4] = cppu::UnoType<sheet::XCellRangeData>::get();
4822 pPtr[nParentLen + 5] = cppu::UnoType<sheet::XCellRangeFormula>::get();
4823 pPtr[nParentLen + 6] = cppu::UnoType<sheet::XMultipleOperation>::get();
4824 pPtr[nParentLen + 7] = cppu::UnoType<util::XMergeable>::get();
4825 pPtr[nParentLen + 8] = cppu::UnoType<sheet::XCellSeries>::get();
4826 pPtr[nParentLen + 9] = cppu::UnoType<table::XAutoFormattable>::get();
4827 pPtr[nParentLen +10] = cppu::UnoType<util::XSortable>::get();
4828 pPtr[nParentLen +11] = cppu::UnoType<sheet::XSheetFilterableEx>::get();
4829 pPtr[nParentLen +12] = cppu::UnoType<sheet::XSubTotalCalculatable>::get();
4830 pPtr[nParentLen +13] = cppu::UnoType<table::XColumnRowRange>::get();
4831 pPtr[nParentLen +14] = cppu::UnoType<util::XImportable>::get();
4832 pPtr[nParentLen +15] = cppu::UnoType<sheet::XCellFormatRangesSupplier>::get();
4833 pPtr[nParentLen +16] = cppu::UnoType<sheet::XUniqueCellFormatRangesSupplier>::get();
4835 for (long i=0; i<nParentLen; i++)
4836 pPtr[i] = pParentPtr[i]; // parent types first
4838 return aTypes;
4841 uno::Sequence<sal_Int8> SAL_CALL ScCellRangeObj::getImplementationId()
4842 throw(uno::RuntimeException, std::exception)
4844 return css::uno::Sequence<sal_Int8>();
4847 // XCellRange
4849 // ColumnCount / RowCount sind weggefallen
4850 //! werden im Writer fuer Tabellen noch gebraucht ???
4852 uno::Reference<table::XCell> ScCellRangeObj::GetCellByPosition_Impl(
4853 sal_Int32 nColumn, sal_Int32 nRow )
4854 throw(lang::IndexOutOfBoundsException, uno::RuntimeException)
4856 ScDocShell* pDocSh = GetDocShell();
4857 if (!pDocSh)
4858 throw uno::RuntimeException();
4860 if ( nColumn >= 0 && nRow >= 0 )
4862 sal_Int32 nPosX = aRange.aStart.Col() + nColumn;
4863 sal_Int32 nPosY = aRange.aStart.Row() + nRow;
4865 if ( nPosX <= aRange.aEnd.Col() && nPosY <= aRange.aEnd.Row() )
4867 ScAddress aNew( (SCCOL)nPosX, (SCROW)nPosY, aRange.aStart.Tab() );
4868 return new ScCellObj( pDocSh, aNew );
4872 throw lang::IndexOutOfBoundsException();
4875 uno::Reference<table::XCell> SAL_CALL ScCellRangeObj::getCellByPosition(
4876 sal_Int32 nColumn, sal_Int32 nRow )
4877 throw(lang::IndexOutOfBoundsException, uno::RuntimeException, std::exception)
4879 SolarMutexGuard aGuard;
4881 return GetCellByPosition_Impl(nColumn, nRow);
4884 uno::Reference<table::XCellRange> SAL_CALL ScCellRangeObj::getCellRangeByPosition(
4885 sal_Int32 nLeft, sal_Int32 nTop, sal_Int32 nRight, sal_Int32 nBottom )
4886 throw(lang::IndexOutOfBoundsException, uno::RuntimeException, std::exception)
4888 SolarMutexGuard aGuard;
4890 ScDocShell* pDocSh = GetDocShell();
4891 if (!pDocSh)
4892 throw uno::RuntimeException();
4894 if ( nLeft >= 0 && nTop >= 0 && nRight >= 0 && nBottom >= 0 )
4896 sal_Int32 nStartX = aRange.aStart.Col() + nLeft;
4897 sal_Int32 nStartY = aRange.aStart.Row() + nTop;
4898 sal_Int32 nEndX = aRange.aStart.Col() + nRight;
4899 sal_Int32 nEndY = aRange.aStart.Row() + nBottom;
4901 if ( nStartX <= nEndX && nEndX <= aRange.aEnd.Col() &&
4902 nStartY <= nEndY && nEndY <= aRange.aEnd.Row() )
4904 ScRange aNew( (SCCOL)nStartX, (SCROW)nStartY, aRange.aStart.Tab(),
4905 (SCCOL)nEndX, (SCROW)nEndY, aRange.aEnd.Tab() );
4906 return new ScCellRangeObj( pDocSh, aNew );
4910 throw lang::IndexOutOfBoundsException();
4913 uno::Reference<table::XCellRange> SAL_CALL ScCellRangeObj::getCellRangeByName(
4914 const OUString& aName ) throw(uno::RuntimeException, std::exception)
4916 return getCellRangeByName( aName, ScAddress::detailsOOOa1 );
4919 uno::Reference<table::XCellRange> ScCellRangeObj::getCellRangeByName(
4920 const OUString& aName, const ScAddress::Details& rDetails ) throw(uno::RuntimeException)
4922 // name refers to the whole document (with the range's table as default),
4923 // valid only if the range is within this range
4925 SolarMutexGuard aGuard;
4926 ScDocShell* pDocSh = GetDocShell();
4927 if ( pDocSh )
4929 ScDocument* pDoc = pDocSh->GetDocument();
4930 SCTAB nTab = aRange.aStart.Tab();
4932 ScRange aCellRange;
4933 bool bFound = false;
4934 OUString aString(aName);
4935 sal_uInt16 nParse = aCellRange.ParseAny( aString, pDoc, rDetails );
4936 if ( nParse & SCA_VALID )
4938 if ( !(nParse & SCA_TAB_3D) ) // keine Tabelle angegeben -> auf dieser Tabelle
4940 aCellRange.aStart.SetTab(nTab);
4941 aCellRange.aEnd.SetTab(nTab);
4943 bFound = true;
4945 else
4947 ScRangeUtil aRangeUtil;
4948 if ( aRangeUtil.MakeRangeFromName( aString, pDoc, nTab, aCellRange, RUTL_NAMES ) ||
4949 aRangeUtil.MakeRangeFromName( aString, pDoc, nTab, aCellRange, RUTL_DBASE ) )
4950 bFound = true;
4953 if (bFound) // valid only if within this object's range
4955 if (!aRange.In(aCellRange))
4956 bFound = false;
4959 if (bFound)
4961 if ( aCellRange.aStart == aCellRange.aEnd )
4962 return new ScCellObj( pDocSh, aCellRange.aStart );
4963 else
4964 return new ScCellRangeObj( pDocSh, aCellRange );
4968 throw uno::RuntimeException();
4971 // XColumnRowRange
4973 uno::Reference<table::XTableColumns> SAL_CALL ScCellRangeObj::getColumns() throw(uno::RuntimeException, std::exception)
4975 SolarMutexGuard aGuard;
4976 ScDocShell* pDocSh = GetDocShell();
4977 if (pDocSh)
4978 return new ScTableColumnsObj( pDocSh, aRange.aStart.Tab(),
4979 aRange.aStart.Col(), aRange.aEnd.Col() );
4981 OSL_FAIL("Dokument ungueltig");
4982 return NULL;
4985 uno::Reference<table::XTableRows> SAL_CALL ScCellRangeObj::getRows() throw(uno::RuntimeException, std::exception)
4987 SolarMutexGuard aGuard;
4988 ScDocShell* pDocSh = GetDocShell();
4989 if (pDocSh)
4990 return new ScTableRowsObj( pDocSh, aRange.aStart.Tab(),
4991 aRange.aStart.Row(), aRange.aEnd.Row() );
4993 OSL_FAIL("Dokument ungueltig");
4994 return NULL;
4997 // XAddressableCellRange
4999 table::CellRangeAddress SAL_CALL ScCellRangeObj::getRangeAddress() throw(uno::RuntimeException, std::exception)
5001 SolarMutexGuard aGuard;
5002 table::CellRangeAddress aRet;
5003 ScUnoConversion::FillApiRange( aRet, aRange );
5004 return aRet;
5007 // XSheetCellRange
5009 uno::Reference<sheet::XSpreadsheet> SAL_CALL ScCellRangeObj::getSpreadsheet()
5010 throw(uno::RuntimeException, std::exception)
5012 SolarMutexGuard aGuard;
5013 ScDocShell* pDocSh = GetDocShell();
5014 if (pDocSh)
5015 return new ScTableSheetObj( pDocSh, aRange.aStart.Tab() );
5017 OSL_FAIL("Dokument ungueltig");
5018 return NULL;
5021 // XArrayFormulaRange
5023 OUString SAL_CALL ScCellRangeObj::getArrayFormula() throw(uno::RuntimeException, std::exception)
5025 SolarMutexGuard aGuard;
5027 // Matrix-Formel, wenn eindeutig Teil einer Matrix,
5028 // also wenn Anfang und Ende des Blocks zur selben Matrix gehoeren.
5029 // Sonst Leerstring.
5031 ScDocShell* pDocSh = GetDocShell();
5032 if (!pDocSh)
5033 return EMPTY_OUSTRING;
5035 OUString aFormula;
5037 ScDocument* pDoc = pDocSh->GetDocument();
5038 ScRefCellValue aCell1;
5039 ScRefCellValue aCell2;
5040 aCell1.assign(*pDoc, aRange.aStart);
5041 aCell2.assign(*pDoc, aRange.aEnd);
5042 if (aCell1.meType == CELLTYPE_FORMULA && aCell2.meType == CELLTYPE_FORMULA)
5044 const ScFormulaCell* pFCell1 = aCell1.mpFormula;
5045 const ScFormulaCell* pFCell2 = aCell2.mpFormula;
5046 ScAddress aStart1;
5047 ScAddress aStart2;
5048 if (pFCell1->GetMatrixOrigin(aStart1) && pFCell2->GetMatrixOrigin(aStart2))
5050 if (aStart1 == aStart2) // beides dieselbe Matrix
5051 pFCell1->GetFormula(aFormula); // egal, von welcher Zelle
5054 return aFormula;
5057 void ScCellRangeObj::SetArrayFormula_Impl( const OUString& rFormula,
5058 const OUString& rFormulaNmsp, const formula::FormulaGrammar::Grammar eGrammar ) throw(uno::RuntimeException)
5060 ScDocShell* pDocSh = GetDocShell();
5061 if (pDocSh)
5063 if ( !rFormula.isEmpty() )
5065 if ( ScTableSheetObj::getImplementation( (cppu::OWeakObject*)this ) )
5067 // don't set array formula for sheet object
5068 throw uno::RuntimeException();
5071 pDocSh->GetDocFunc().EnterMatrix( aRange, NULL, NULL, rFormula, true, true, rFormulaNmsp, eGrammar );
5073 else
5075 // empty string -> erase array formula
5076 ScMarkData aMark;
5077 aMark.SetMarkArea( aRange );
5078 aMark.SelectTable( aRange.aStart.Tab(), true );
5079 pDocSh->GetDocFunc().DeleteContents( aMark, IDF_CONTENTS, true, true );
5084 void SAL_CALL ScCellRangeObj::setArrayFormula( const OUString& aFormula )
5085 throw(uno::RuntimeException, std::exception)
5087 SolarMutexGuard aGuard;
5088 // GRAM_PODF_A1 for API compatibility.
5089 SetArrayFormula_Impl( aFormula, OUString(), formula::FormulaGrammar::GRAM_PODF_A1);
5092 void ScCellRangeObj::SetArrayFormulaWithGrammar( const OUString& rFormula,
5093 const OUString& rFormulaNmsp, const formula::FormulaGrammar::Grammar eGrammar ) throw(uno::RuntimeException)
5095 SolarMutexGuard aGuard;
5096 SetArrayFormula_Impl( rFormula, rFormulaNmsp, eGrammar);
5099 // XArrayFormulaTokens
5101 uno::Sequence<sheet::FormulaToken> SAL_CALL ScCellRangeObj::getArrayTokens()
5102 throw (uno::RuntimeException, std::exception)
5104 SolarMutexGuard aGuard;
5106 // same cell logic as in getArrayFormula
5108 uno::Sequence<sheet::FormulaToken> aSequence;
5109 ScDocShell* pDocSh = GetDocShell();
5110 if (!pDocSh)
5111 return aSequence;
5113 ScDocument* pDoc = pDocSh->GetDocument();
5114 ScRefCellValue aCell1;
5115 ScRefCellValue aCell2;
5116 aCell1.assign(*pDoc, aRange.aStart);
5117 aCell2.assign(*pDoc, aRange.aEnd);
5118 if (aCell1.meType == CELLTYPE_FORMULA && aCell2.meType == CELLTYPE_FORMULA)
5120 const ScFormulaCell* pFCell1 = aCell1.mpFormula;
5121 const ScFormulaCell* pFCell2 = aCell2.mpFormula;
5122 ScAddress aStart1;
5123 ScAddress aStart2;
5124 if (pFCell1->GetMatrixOrigin(aStart1) && pFCell2->GetMatrixOrigin(aStart2))
5126 if (aStart1 == aStart2)
5128 const ScTokenArray* pTokenArray = pFCell1->GetCode();
5129 if (pTokenArray)
5130 (void)ScTokenConversion::ConvertToTokenSequence(*pDoc, aSequence, *pTokenArray);
5135 return aSequence;
5138 void SAL_CALL ScCellRangeObj::setArrayTokens( const uno::Sequence<sheet::FormulaToken>& rTokens ) throw(uno::RuntimeException, std::exception)
5140 SolarMutexGuard aGuard;
5141 ScDocShell* pDocSh = GetDocShell();
5142 if ( pDocSh )
5144 if ( rTokens.getLength() )
5146 if ( ScTableSheetObj::getImplementation( (cppu::OWeakObject*)this ) )
5148 throw uno::RuntimeException();
5151 ScDocument* pDoc = pDocSh->GetDocument();
5152 ScTokenArray aTokenArray;
5153 (void)ScTokenConversion::ConvertToTokenArray( *pDoc, aTokenArray, rTokens );
5155 // Actually GRAM_PODF_A1 is a don't-care here because of the token
5156 // array being set, it fits with other API compatibility grammars
5157 // though.
5158 pDocSh->GetDocFunc().EnterMatrix( aRange, NULL, &aTokenArray, EMPTY_OUSTRING, true, true, EMPTY_OUSTRING, formula::FormulaGrammar::GRAM_PODF_A1 );
5160 else
5162 // empty sequence -> erase array formula
5163 ScMarkData aMark;
5164 aMark.SetMarkArea( aRange );
5165 aMark.SelectTable( aRange.aStart.Tab(), true );
5166 pDocSh->GetDocFunc().DeleteContents( aMark, IDF_CONTENTS, true, true );
5171 // XCellRangeData
5173 uno::Sequence< uno::Sequence<uno::Any> > SAL_CALL ScCellRangeObj::getDataArray()
5174 throw(uno::RuntimeException, std::exception)
5176 SolarMutexGuard aGuard;
5178 if ( ScTableSheetObj::getImplementation( (cppu::OWeakObject*)this ) )
5180 // don't create a data array for the sheet
5181 throw uno::RuntimeException();
5184 ScDocShell* pDocSh = GetDocShell();
5185 if (pDocSh)
5187 uno::Any aAny;
5188 // bAllowNV = TRUE: errors as void
5189 if ( ScRangeToSequence::FillMixedArray( aAny, pDocSh->GetDocument(), aRange, true ) )
5191 uno::Sequence< uno::Sequence<uno::Any> > aSeq;
5192 if ( aAny >>= aSeq )
5193 return aSeq; // success
5197 throw uno::RuntimeException(); // no other exceptions specified
5200 void SAL_CALL ScCellRangeObj::setDataArray(
5201 const uno::Sequence< uno::Sequence<uno::Any> >& aArray )
5202 throw(uno::RuntimeException, std::exception)
5204 SolarMutexGuard aGuard;
5206 bool bDone = false;
5207 ScDocShell* pDocSh = GetDocShell();
5208 if (pDocSh)
5210 //! move lcl_PutDataArray to docfunc?
5211 bDone = lcl_PutDataArray( *pDocSh, aRange, aArray );
5214 if (!bDone)
5215 throw uno::RuntimeException(); // no other exceptions specified
5218 // XCellRangeFormula
5220 uno::Sequence< uno::Sequence<OUString> > SAL_CALL ScCellRangeObj::getFormulaArray()
5221 throw(uno::RuntimeException, std::exception)
5223 SolarMutexGuard aGuard;
5225 if ( ScTableSheetObj::getImplementation( (cppu::OWeakObject*)this ) )
5227 // don't create a data array for the sheet
5228 throw uno::RuntimeException();
5231 ScDocShell* pDocSh = GetDocShell();
5232 if (pDocSh)
5234 SCCOL nStartCol = aRange.aStart.Col();
5235 SCROW nStartRow = aRange.aStart.Row();
5236 SCCOL nEndCol = aRange.aEnd.Col();
5237 SCROW nEndRow = aRange.aEnd.Row();
5238 SCCOL nColCount = nEndCol + 1 - nStartCol;
5239 SCROW nRowCount = nEndRow + 1 - nStartRow;
5240 SCTAB nTab = aRange.aStart.Tab();
5242 uno::Sequence< uno::Sequence<OUString> > aRowSeq( nRowCount );
5243 uno::Sequence<OUString>* pRowAry = aRowSeq.getArray();
5244 for (SCROW nRowIndex = 0; nRowIndex < nRowCount; nRowIndex++)
5246 uno::Sequence<OUString> aColSeq( nColCount );
5247 OUString* pColAry = aColSeq.getArray();
5248 for (SCCOL nColIndex = 0; nColIndex < nColCount; nColIndex++)
5249 pColAry[nColIndex] = lcl_GetInputString( pDocSh->GetDocument(),
5250 ScAddress( nStartCol+nColIndex, nStartRow+nRowIndex, nTab ), true );
5252 pRowAry[nRowIndex] = aColSeq;
5255 return aRowSeq;
5258 throw uno::RuntimeException(); // no other exceptions specified
5261 void SAL_CALL ScCellRangeObj::setFormulaArray(
5262 const uno::Sequence< uno::Sequence<OUString> >& aArray )
5263 throw(uno::RuntimeException, std::exception)
5265 SolarMutexGuard aGuard;
5267 bool bDone = false;
5268 ScDocShell* pDocSh = GetDocShell();
5269 if (pDocSh)
5271 ScExternalRefManager::ApiGuard aExtRefGuard(pDocSh->GetDocument());
5273 // GRAM_PODF_A1 for API compatibility.
5274 bDone = lcl_PutFormulaArray( *pDocSh, aRange, aArray, formula::FormulaGrammar::GRAM_PODF_A1 );
5277 if (!bDone)
5278 throw uno::RuntimeException(); // no other exceptions specified
5281 // XMultipleOperation
5283 void SAL_CALL ScCellRangeObj::setTableOperation( const table::CellRangeAddress& aFormulaRange,
5284 sheet::TableOperationMode nMode,
5285 const table::CellAddress& aColumnCell,
5286 const table::CellAddress& aRowCell )
5287 throw(uno::RuntimeException, std::exception)
5289 SolarMutexGuard aGuard;
5290 ScDocShell* pDocSh = GetDocShell();
5291 if (pDocSh)
5293 bool bError = false;
5294 ScTabOpParam aParam;
5295 aParam.aRefFormulaCell = ScRefAddress( (SCCOL)aFormulaRange.StartColumn,
5296 (SCROW)aFormulaRange.StartRow, aFormulaRange.Sheet,
5297 false, false, false );
5298 aParam.aRefFormulaEnd = ScRefAddress( (SCCOL)aFormulaRange.EndColumn,
5299 (SCROW)aFormulaRange.EndRow, aFormulaRange.Sheet,
5300 false, false, false );
5301 aParam.aRefRowCell = ScRefAddress( (SCCOL)aRowCell.Column,
5302 (SCROW)aRowCell.Row, aRowCell.Sheet,
5303 false, false, false );
5304 aParam.aRefColCell = ScRefAddress( (SCCOL)aColumnCell.Column,
5305 (SCROW)aColumnCell.Row, aColumnCell.Sheet,
5306 false, false, false );
5308 switch (nMode)
5310 case sheet::TableOperationMode_COLUMN:
5311 aParam.meMode = ScTabOpParam::Column;
5312 break;
5313 case sheet::TableOperationMode_ROW:
5314 aParam.meMode = ScTabOpParam::Row;
5315 break;
5316 case sheet::TableOperationMode_BOTH:
5317 aParam.meMode = ScTabOpParam::Both;
5318 break;
5319 default:
5320 bError = true;
5323 if (!bError)
5324 pDocSh->GetDocFunc().TabOp( aRange, NULL, aParam, true, true );
5328 // XMergeable
5330 void SAL_CALL ScCellRangeObj::merge( sal_Bool bMerge ) throw(uno::RuntimeException, std::exception)
5332 SolarMutexGuard aGuard;
5333 ScDocShell* pDocSh = GetDocShell();
5334 if ( pDocSh )
5336 ScCellMergeOption aMergeOption(
5337 aRange.aStart.Col(), aRange.aStart.Row(),
5338 aRange.aEnd.Col(), aRange.aEnd.Row(), false);
5339 aMergeOption.maTabs.insert(aRange.aStart.Tab());
5340 if ( bMerge )
5341 pDocSh->GetDocFunc().MergeCells( aMergeOption, false, true, true );
5342 else
5343 pDocSh->GetDocFunc().UnmergeCells( aMergeOption, true );
5345 //! Fehler abfangen?
5349 sal_Bool SAL_CALL ScCellRangeObj::getIsMerged() throw(uno::RuntimeException, std::exception)
5351 SolarMutexGuard aGuard;
5352 ScDocShell* pDocSh = GetDocShell();
5353 return pDocSh && pDocSh->GetDocument()->HasAttrib( aRange, HASATTR_MERGED );
5356 // XCellSeries
5358 void SAL_CALL ScCellRangeObj::fillSeries( sheet::FillDirection nFillDirection,
5359 sheet::FillMode nFillMode, sheet::FillDateMode nFillDateMode,
5360 double fStep, double fEndValue ) throw(uno::RuntimeException, std::exception)
5362 SolarMutexGuard aGuard;
5363 ScDocShell* pDocSh = GetDocShell();
5364 if ( pDocSh )
5366 bool bError = false;
5368 FillDir eDir = FILL_TO_BOTTOM;
5369 switch (nFillDirection)
5371 case sheet::FillDirection_TO_BOTTOM:
5372 eDir = FILL_TO_BOTTOM;
5373 break;
5374 case sheet::FillDirection_TO_RIGHT:
5375 eDir = FILL_TO_RIGHT;
5376 break;
5377 case sheet::FillDirection_TO_TOP:
5378 eDir = FILL_TO_TOP;
5379 break;
5380 case sheet::FillDirection_TO_LEFT:
5381 eDir = FILL_TO_LEFT;
5382 break;
5383 default:
5384 bError = true;
5387 FillCmd eCmd = FILL_SIMPLE;
5388 switch ( nFillMode )
5390 case sheet::FillMode_SIMPLE:
5391 eCmd = FILL_SIMPLE;
5392 break;
5393 case sheet::FillMode_LINEAR:
5394 eCmd = FILL_LINEAR;
5395 break;
5396 case sheet::FillMode_GROWTH:
5397 eCmd = FILL_GROWTH;
5398 break;
5399 case sheet::FillMode_DATE:
5400 eCmd = FILL_DATE;
5401 break;
5402 case sheet::FillMode_AUTO:
5403 eCmd = FILL_AUTO;
5404 break;
5405 default:
5406 bError = true;
5409 FillDateCmd eDateCmd = FILL_DAY;
5410 switch ( nFillDateMode )
5412 case sheet::FillDateMode_FILL_DATE_DAY:
5413 eDateCmd = FILL_DAY;
5414 break;
5415 case sheet::FillDateMode_FILL_DATE_WEEKDAY:
5416 eDateCmd = FILL_WEEKDAY;
5417 break;
5418 case sheet::FillDateMode_FILL_DATE_MONTH:
5419 eDateCmd = FILL_MONTH;
5420 break;
5421 case sheet::FillDateMode_FILL_DATE_YEAR:
5422 eDateCmd = FILL_YEAR;
5423 break;
5424 default:
5425 bError = true;
5428 if (!bError)
5429 pDocSh->GetDocFunc().FillSeries( aRange, NULL, eDir, eCmd, eDateCmd,
5430 MAXDOUBLE, fStep, fEndValue, true, true );
5434 void SAL_CALL ScCellRangeObj::fillAuto( sheet::FillDirection nFillDirection,
5435 sal_Int32 nSourceCount ) throw(uno::RuntimeException, std::exception)
5437 SolarMutexGuard aGuard;
5438 ScDocShell* pDocSh = GetDocShell();
5439 if ( pDocSh && nSourceCount )
5441 ScRange aSourceRange(aRange);
5442 SCsCOLROW nCount = 0; // "Dest-Count"
5443 FillDir eDir = FILL_TO_BOTTOM;
5444 bool bError = false;
5445 switch (nFillDirection)
5447 case sheet::FillDirection_TO_BOTTOM:
5448 aSourceRange.aEnd.SetRow( static_cast<SCROW>( aSourceRange.aStart.Row() + nSourceCount - 1 ) );
5449 nCount = aRange.aEnd.Row() - aSourceRange.aEnd.Row();
5450 eDir = FILL_TO_BOTTOM;
5451 break;
5452 case sheet::FillDirection_TO_RIGHT:
5453 aSourceRange.aEnd.SetCol( static_cast<SCCOL>( aSourceRange.aStart.Col() + nSourceCount - 1 ) );
5454 nCount = aRange.aEnd.Col() - aSourceRange.aEnd.Col();
5455 eDir = FILL_TO_RIGHT;
5456 break;
5457 case sheet::FillDirection_TO_TOP:
5458 aSourceRange.aStart.SetRow( static_cast<SCROW>( aSourceRange.aEnd.Row() - nSourceCount + 1 ) );
5459 nCount = aSourceRange.aStart.Row() - aRange.aStart.Row();
5460 eDir = FILL_TO_TOP;
5461 break;
5462 case sheet::FillDirection_TO_LEFT:
5463 aSourceRange.aStart.SetCol( static_cast<SCCOL>( aSourceRange.aEnd.Col() - nSourceCount + 1 ) );
5464 nCount = aSourceRange.aStart.Col() - aRange.aStart.Col();
5465 eDir = FILL_TO_LEFT;
5466 break;
5467 default:
5468 bError = true;
5470 if (nCount < 0 || nCount > MAXROW) // overflow
5471 bError = true;
5473 if (!bError)
5474 pDocSh->GetDocFunc().FillAuto( aSourceRange, NULL, eDir, nCount, true, true );
5478 // XAutoFormattable
5480 void SAL_CALL ScCellRangeObj::autoFormat( const OUString& aName )
5481 throw(lang::IllegalArgumentException, uno::RuntimeException, std::exception)
5483 SolarMutexGuard aGuard;
5484 ScDocShell* pDocSh = GetDocShell();
5485 if ( pDocSh )
5487 ScAutoFormat* pAutoFormat = ScGlobal::GetOrCreateAutoFormat();
5488 ScAutoFormat::const_iterator it = pAutoFormat->find(aName);
5489 if (it != pAutoFormat->end())
5491 ScAutoFormat::const_iterator itBeg = pAutoFormat->begin();
5492 size_t nIndex = std::distance(itBeg, it);
5493 pDocSh->GetDocFunc().AutoFormat(aRange, NULL, nIndex, true, true);
5495 else
5496 throw lang::IllegalArgumentException();
5500 // XSortable
5502 uno::Sequence<beans::PropertyValue> SAL_CALL ScCellRangeObj::createSortDescriptor()
5503 throw(uno::RuntimeException, std::exception)
5505 SolarMutexGuard aGuard;
5506 ScSortParam aParam;
5507 ScDocShell* pDocSh = GetDocShell();
5508 if ( pDocSh )
5510 // DB-Bereich anlegen erst beim Ausfuehren, per API immer genau den Bereich
5511 ScDBData* pData = pDocSh->GetDBData( aRange, SC_DB_OLD, SC_DBSEL_FORCE_MARK );
5512 if (pData)
5514 pData->GetSortParam(aParam);
5516 // im SortDescriptor sind die Fields innerhalb des Bereichs gezaehlt
5517 ScRange aDBRange;
5518 pData->GetArea(aDBRange);
5519 SCCOLROW nFieldStart = aParam.bByRow ?
5520 static_cast<SCCOLROW>(aDBRange.aStart.Col()) :
5521 static_cast<SCCOLROW>(aDBRange.aStart.Row());
5522 for (sal_uInt16 i=0; i<aParam.GetSortKeyCount(); i++)
5523 if ( aParam.maKeyState[i].bDoSort && aParam.maKeyState[i].nField >= nFieldStart )
5524 aParam.maKeyState[i].nField -= nFieldStart;
5528 uno::Sequence<beans::PropertyValue> aSeq( ScSortDescriptor::GetPropertyCount() );
5529 ScSortDescriptor::FillProperties( aSeq, aParam );
5530 return aSeq;
5533 void SAL_CALL ScCellRangeObj::sort( const uno::Sequence<beans::PropertyValue>& aDescriptor )
5534 throw(uno::RuntimeException, std::exception)
5536 SolarMutexGuard aGuard;
5537 ScDocShell* pDocSh = GetDocShell();
5538 if (pDocSh)
5540 sal_uInt16 i;
5541 ScSortParam aParam;
5542 ScDBData* pData = pDocSh->GetDBData( aRange, SC_DB_MAKE, SC_DBSEL_FORCE_MARK ); // ggf. Bereich anlegen
5543 if (pData)
5545 // alten Einstellungen holen, falls nicht alles neu gesetzt wird
5546 pData->GetSortParam(aParam);
5547 SCCOLROW nOldStart = aParam.bByRow ?
5548 static_cast<SCCOLROW>(aRange.aStart.Col()) :
5549 static_cast<SCCOLROW>(aRange.aStart.Row());
5550 for (i=0; i<aParam.GetSortKeyCount(); i++)
5551 if ( aParam.maKeyState[i].bDoSort && aParam.maKeyState[i].nField >= nOldStart )
5552 aParam.maKeyState[i].nField -= nOldStart;
5555 ScSortDescriptor::FillSortParam( aParam, aDescriptor );
5557 // im SortDescriptor sind die Fields innerhalb des Bereichs gezaehlt
5558 // ByRow kann bei FillSortParam umgesetzt worden sein
5559 SCCOLROW nFieldStart = aParam.bByRow ?
5560 static_cast<SCCOLROW>(aRange.aStart.Col()) :
5561 static_cast<SCCOLROW>(aRange.aStart.Row());
5562 for (i=0; i<aParam.GetSortKeyCount(); i++)
5563 aParam.maKeyState[i].nField += nFieldStart;
5565 SCTAB nTab = aRange.aStart.Tab();
5566 aParam.nCol1 = aRange.aStart.Col();
5567 aParam.nRow1 = aRange.aStart.Row();
5568 aParam.nCol2 = aRange.aEnd.Col();
5569 aParam.nRow2 = aRange.aEnd.Row();
5571 pDocSh->GetDBData( aRange, SC_DB_MAKE, SC_DBSEL_FORCE_MARK ); // ggf. Bereich anlegen
5573 ScDBDocFunc aFunc(*pDocSh); // Bereich muss angelegt sein
5574 aFunc.Sort( nTab, aParam, true, true, true );
5578 // XFilterable
5580 uno::Reference<sheet::XSheetFilterDescriptor> SAL_CALL ScCellRangeObj::createFilterDescriptor(
5581 sal_Bool bEmpty ) throw(uno::RuntimeException, std::exception)
5583 SolarMutexGuard aGuard;
5584 ScDocShell* pDocSh = GetDocShell();
5585 ScFilterDescriptor* pNew = new ScFilterDescriptor(pDocSh);
5586 if ( !bEmpty && pDocSh )
5588 // DB-Bereich anlegen erst beim Ausfuehren, per API immer genau den Bereich
5589 ScDBData* pData = pDocSh->GetDBData( aRange, SC_DB_OLD, SC_DBSEL_FORCE_MARK );
5590 if (pData)
5592 ScQueryParam aParam;
5593 pData->GetQueryParam(aParam);
5594 // im FilterDescriptor sind die Fields innerhalb des Bereichs gezaehlt
5595 ScRange aDBRange;
5596 pData->GetArea(aDBRange);
5597 SCCOLROW nFieldStart = aParam.bByRow ?
5598 static_cast<SCCOLROW>(aDBRange.aStart.Col()) :
5599 static_cast<SCCOLROW>(aDBRange.aStart.Row());
5600 SCSIZE nCount = aParam.GetEntryCount();
5601 for (SCSIZE i=0; i<nCount; i++)
5603 ScQueryEntry& rEntry = aParam.GetEntry(i);
5604 if (rEntry.bDoQuery && rEntry.nField >= nFieldStart)
5605 rEntry.nField -= nFieldStart;
5607 pNew->SetParam(aParam);
5610 return pNew;
5613 void SAL_CALL ScCellRangeObj::filter( const uno::Reference<sheet::XSheetFilterDescriptor>& xDescriptor )
5614 throw(uno::RuntimeException, std::exception)
5616 SolarMutexGuard aGuard;
5618 // das koennte theoretisch ein fremdes Objekt sein, also nur das
5619 // oeffentliche XSheetFilterDescriptor Interface benutzen, um
5620 // die Daten in ein ScFilterDescriptor Objekt zu kopieren:
5621 //! wenn es schon ein ScFilterDescriptor ist, direkt per getImplementation?
5623 ScDocShell* pDocSh = GetDocShell();
5624 ScFilterDescriptor aImpl(pDocSh);
5625 uno::Reference< sheet::XSheetFilterDescriptor2 > xDescriptor2( xDescriptor, uno::UNO_QUERY );
5626 if ( xDescriptor2.is() )
5628 aImpl.setFilterFields2( xDescriptor2->getFilterFields2() );
5630 else
5632 aImpl.setFilterFields( xDescriptor->getFilterFields() );
5634 // Rest sind jetzt Properties...
5636 uno::Reference<beans::XPropertySet> xPropSet( xDescriptor, uno::UNO_QUERY );
5637 if (xPropSet.is())
5638 lcl_CopyProperties( aImpl, *(beans::XPropertySet*)xPropSet.get() );
5641 // ausfuehren...
5644 if (pDocSh)
5646 ScQueryParam aParam = aImpl.GetParam();
5647 // im FilterDescriptor sind die Fields innerhalb des Bereichs gezaehlt
5648 SCCOLROW nFieldStart = aParam.bByRow ?
5649 static_cast<SCCOLROW>(aRange.aStart.Col()) :
5650 static_cast<SCCOLROW>(aRange.aStart.Row());
5651 SCSIZE nCount = aParam.GetEntryCount();
5652 svl::SharedStringPool& rPool = pDocSh->GetDocument()->GetSharedStringPool();
5653 for (SCSIZE i=0; i<nCount; i++)
5655 ScQueryEntry& rEntry = aParam.GetEntry(i);
5656 if (rEntry.bDoQuery)
5658 rEntry.nField += nFieldStart;
5659 // Im Dialog wird immer der String angezeigt -> muss zum Wert passen
5660 ScQueryEntry::QueryItemsType& rItems = rEntry.GetQueryItems();
5661 rItems.resize(1);
5662 ScQueryEntry::Item& rItem = rItems.front();
5663 if (rItem.meType != ScQueryEntry::ByString)
5665 OUString aStr;
5666 pDocSh->GetDocument()->GetFormatTable()->GetInputLineString(rItem.mfVal, 0, aStr);
5667 rItem.maString = rPool.intern(aStr);
5672 SCTAB nTab = aRange.aStart.Tab();
5673 aParam.nCol1 = aRange.aStart.Col();
5674 aParam.nRow1 = aRange.aStart.Row();
5675 aParam.nCol2 = aRange.aEnd.Col();
5676 aParam.nRow2 = aRange.aEnd.Row();
5678 pDocSh->GetDBData( aRange, SC_DB_MAKE, SC_DBSEL_FORCE_MARK ); // ggf. Bereich anlegen
5680 //! keep source range in filter descriptor
5681 //! if created by createFilterDescriptorByObject ???
5683 ScDBDocFunc aFunc(*pDocSh);
5684 aFunc.Query( nTab, aParam, NULL, true, true ); // Bereich muss angelegt sein
5688 //! get/setAutoFilter als Properties!!!
5690 // XAdvancedFilterSource
5692 uno::Reference<sheet::XSheetFilterDescriptor> SAL_CALL ScCellRangeObj::createFilterDescriptorByObject(
5693 const uno::Reference<sheet::XSheetFilterable>& xObject )
5694 throw(uno::RuntimeException, std::exception)
5696 SolarMutexGuard aGuard;
5698 // this ist hier nicht der Bereich, der gefiltert wird, sondern der
5699 // Bereich mit der Abfrage...
5701 uno::Reference<sheet::XCellRangeAddressable> xAddr( xObject, uno::UNO_QUERY );
5703 ScDocShell* pDocSh = GetDocShell();
5704 if ( pDocSh && xAddr.is() )
5706 //! Test, ob xObject im selben Dokument ist
5708 ScFilterDescriptor* pNew = new ScFilterDescriptor(pDocSh); //! stattdessen vom Objekt?
5710 ScQueryParam aParam = pNew->GetParam();
5711 aParam.bHasHeader = true;
5713 table::CellRangeAddress aDataAddress(xAddr->getRangeAddress());
5714 aParam.nCol1 = (SCCOL)aDataAddress.StartColumn;
5715 aParam.nRow1 = (SCROW)aDataAddress.StartRow;
5716 aParam.nCol2 = (SCCOL)aDataAddress.EndColumn;
5717 aParam.nRow2 = (SCROW)aDataAddress.EndRow;
5718 aParam.nTab = aDataAddress.Sheet;
5720 ScDocument* pDoc = pDocSh->GetDocument();
5721 bool bOk = pDoc->CreateQueryParam(
5722 aRange.aStart.Col(), aRange.aStart.Row(),
5723 aRange.aEnd.Col(), aRange.aEnd.Row(),
5724 aRange.aStart.Tab(), aParam );
5725 if ( bOk )
5727 // im FilterDescriptor sind die Fields innerhalb des Bereichs gezaehlt
5728 SCCOLROW nFieldStart = aParam.bByRow ?
5729 static_cast<SCCOLROW>(aDataAddress.StartColumn) :
5730 static_cast<SCCOLROW>(aDataAddress.StartRow);
5731 SCSIZE nCount = aParam.GetEntryCount();
5732 for (SCSIZE i=0; i<nCount; i++)
5734 ScQueryEntry& rEntry = aParam.GetEntry(i);
5735 if (rEntry.bDoQuery && rEntry.nField >= nFieldStart)
5736 rEntry.nField -= nFieldStart;
5739 pNew->SetParam( aParam );
5740 return pNew;
5742 else
5744 delete pNew;
5745 return NULL; // ungueltig -> null
5749 OSL_FAIL("kein Dokument oder kein Bereich");
5750 return NULL;
5753 // XSubTotalSource
5755 uno::Reference<sheet::XSubTotalDescriptor> SAL_CALL ScCellRangeObj::createSubTotalDescriptor(
5756 sal_Bool bEmpty ) throw(uno::RuntimeException, std::exception)
5758 SolarMutexGuard aGuard;
5759 ScSubTotalDescriptor* pNew = new ScSubTotalDescriptor;
5760 ScDocShell* pDocSh = GetDocShell();
5761 if ( !bEmpty && pDocSh )
5763 // DB-Bereich anlegen erst beim Ausfuehren, per API immer genau den Bereich
5764 ScDBData* pData = pDocSh->GetDBData( aRange, SC_DB_OLD, SC_DBSEL_FORCE_MARK );
5765 if (pData)
5767 ScSubTotalParam aParam;
5768 pData->GetSubTotalParam(aParam);
5769 // im SubTotalDescriptor sind die Fields innerhalb des Bereichs gezaehlt
5770 ScRange aDBRange;
5771 pData->GetArea(aDBRange);
5772 SCCOL nFieldStart = aDBRange.aStart.Col();
5773 for (sal_uInt16 i=0; i<MAXSUBTOTAL; i++)
5775 if ( aParam.bGroupActive[i] )
5777 if ( aParam.nField[i] >= nFieldStart )
5778 aParam.nField[i] = sal::static_int_cast<SCCOL>( aParam.nField[i] - nFieldStart );
5779 for (SCCOL j=0; j<aParam.nSubTotals[i]; j++)
5780 if ( aParam.pSubTotals[i][j] >= nFieldStart )
5781 aParam.pSubTotals[i][j] = sal::static_int_cast<SCCOL>( aParam.pSubTotals[i][j] - nFieldStart );
5784 pNew->SetParam(aParam);
5787 return pNew;
5790 void SAL_CALL ScCellRangeObj::applySubTotals(
5791 const uno::Reference<sheet::XSubTotalDescriptor>& xDescriptor,
5792 sal_Bool bReplace)
5793 throw (uno::RuntimeException, std::exception)
5795 SolarMutexGuard aGuard;
5797 if (!xDescriptor.is()) return;
5799 ScDocShell* pDocSh = GetDocShell();
5800 ScSubTotalDescriptorBase* pImp =
5801 ScSubTotalDescriptorBase::getImplementation( xDescriptor );
5803 if (pDocSh && pImp)
5805 ScSubTotalParam aParam;
5806 pImp->GetData(aParam); // virtuelle Methode der Basisklasse
5808 // im SubTotalDescriptor sind die Fields innerhalb des Bereichs gezaehlt
5809 SCCOL nFieldStart = aRange.aStart.Col();
5810 for (sal_uInt16 i=0; i<MAXSUBTOTAL; i++)
5812 if ( aParam.bGroupActive[i] )
5814 aParam.nField[i] = sal::static_int_cast<SCCOL>( aParam.nField[i] + nFieldStart );
5815 for (SCCOL j=0; j<aParam.nSubTotals[i]; j++)
5816 aParam.pSubTotals[i][j] = sal::static_int_cast<SCCOL>( aParam.pSubTotals[i][j] + nFieldStart );
5820 aParam.bReplace = bReplace;
5822 SCTAB nTab = aRange.aStart.Tab();
5823 aParam.nCol1 = aRange.aStart.Col();
5824 aParam.nRow1 = aRange.aStart.Row();
5825 aParam.nCol2 = aRange.aEnd.Col();
5826 aParam.nRow2 = aRange.aEnd.Row();
5828 pDocSh->GetDBData( aRange, SC_DB_MAKE, SC_DBSEL_FORCE_MARK ); // ggf. Bereich anlegen
5830 ScDBDocFunc aFunc(*pDocSh);
5831 aFunc.DoSubTotals( nTab, aParam, NULL, true, true ); // Bereich muss angelegt sein
5835 void SAL_CALL ScCellRangeObj::removeSubTotals() throw(uno::RuntimeException, std::exception)
5837 SolarMutexGuard aGuard;
5839 ScDocShell* pDocSh = GetDocShell();
5840 if (pDocSh)
5842 ScSubTotalParam aParam;
5843 ScDBData* pData = pDocSh->GetDBData( aRange, SC_DB_OLD, SC_DBSEL_FORCE_MARK );
5844 if (pData)
5845 pData->GetSubTotalParam(aParam); // auch bei Remove die Feld-Eintraege behalten
5847 aParam.bRemoveOnly = true;
5849 SCTAB nTab = aRange.aStart.Tab();
5850 aParam.nCol1 = aRange.aStart.Col();
5851 aParam.nRow1 = aRange.aStart.Row();
5852 aParam.nCol2 = aRange.aEnd.Col();
5853 aParam.nRow2 = aRange.aEnd.Row();
5855 pDocSh->GetDBData( aRange, SC_DB_MAKE, SC_DBSEL_FORCE_MARK ); // ggf. Bereich anlegen
5857 ScDBDocFunc aFunc(*pDocSh);
5858 aFunc.DoSubTotals( nTab, aParam, NULL, true, true ); // Bereich muss angelegt sein
5862 uno::Sequence<beans::PropertyValue> SAL_CALL ScCellRangeObj::createImportDescriptor( sal_Bool bEmpty )
5863 throw(uno::RuntimeException, std::exception)
5865 SolarMutexGuard aGuard;
5866 ScImportParam aParam;
5867 ScDocShell* pDocSh = GetDocShell();
5868 if ( !bEmpty && pDocSh )
5870 // DB-Bereich anlegen erst beim Ausfuehren, per API immer genau den Bereich
5871 ScDBData* pData = pDocSh->GetDBData( aRange, SC_DB_OLD, SC_DBSEL_FORCE_MARK );
5872 if (pData)
5873 pData->GetImportParam(aParam);
5876 uno::Sequence<beans::PropertyValue> aSeq( ScImportDescriptor::GetPropertyCount() );
5877 ScImportDescriptor::FillProperties( aSeq, aParam );
5878 return aSeq;
5881 void SAL_CALL ScCellRangeObj::doImport( const uno::Sequence<beans::PropertyValue>& aDescriptor )
5882 throw(uno::RuntimeException, std::exception)
5884 SolarMutexGuard aGuard;
5885 ScDocShell* pDocSh = GetDocShell();
5886 if (pDocSh)
5888 ScImportParam aParam;
5889 ScImportDescriptor::FillImportParam( aParam, aDescriptor );
5891 SCTAB nTab = aRange.aStart.Tab();
5892 aParam.nCol1 = aRange.aStart.Col();
5893 aParam.nRow1 = aRange.aStart.Row();
5894 aParam.nCol2 = aRange.aEnd.Col();
5895 aParam.nRow2 = aRange.aEnd.Row();
5897 //! TODO: could we get passed a valid result set by any means?
5899 pDocSh->GetDBData( aRange, SC_DB_MAKE, SC_DBSEL_FORCE_MARK ); // ggf. Bereich anlegen
5901 ScDBDocFunc aFunc(*pDocSh); // Bereich muss angelegt sein
5902 aFunc.DoImport( nTab, aParam, NULL, true ); //! Api-Flag as parameter
5906 // XCellFormatRangesSupplier
5908 uno::Reference<container::XIndexAccess> SAL_CALL ScCellRangeObj::getCellFormatRanges()
5909 throw(uno::RuntimeException, std::exception)
5911 SolarMutexGuard aGuard;
5912 ScDocShell* pDocSh = GetDocShell();
5913 if ( pDocSh )
5914 return new ScCellFormatsObj( pDocSh, aRange );
5915 return NULL;
5918 // XUniqueCellFormatRangesSupplier
5920 uno::Reference<container::XIndexAccess> SAL_CALL ScCellRangeObj::getUniqueCellFormatRanges()
5921 throw(uno::RuntimeException, std::exception)
5923 SolarMutexGuard aGuard;
5924 ScDocShell* pDocSh = GetDocShell();
5925 if ( pDocSh )
5926 return new ScUniqueCellFormatsObj( pDocSh, aRange );
5927 return NULL;
5930 // XPropertySet erweitert fuer Range-Properties
5932 uno::Reference<beans::XPropertySetInfo> SAL_CALL ScCellRangeObj::getPropertySetInfo()
5933 throw(uno::RuntimeException, std::exception)
5935 SolarMutexGuard aGuard;
5936 static uno::Reference<beans::XPropertySetInfo> aRef(
5937 new SfxItemPropertySetInfo( pRangePropSet->getPropertyMap() ));
5938 return aRef;
5941 void ScCellRangeObj::SetOnePropertyValue( const SfxItemPropertySimpleEntry* pEntry, const uno::Any& aValue )
5942 throw(lang::IllegalArgumentException, uno::RuntimeException, std::exception)
5944 // Range has only Position and Size in addition to ScCellRangesBase, both are ReadOnly
5945 // -> nothing to do here
5947 ScCellRangesBase::SetOnePropertyValue( pEntry, aValue );
5950 void ScCellRangeObj::GetOnePropertyValue( const SfxItemPropertySimpleEntry* pEntry, uno::Any& rAny )
5951 throw(uno::RuntimeException, std::exception)
5953 if ( pEntry )
5955 if ( pEntry->nWID == SC_WID_UNO_POS )
5957 ScDocShell* pDocSh = GetDocShell();
5958 if (pDocSh)
5960 // GetMMRect converts using HMM_PER_TWIPS, like the DrawingLayer
5961 Rectangle aMMRect(pDocSh->GetDocument()->GetMMRect(
5962 aRange.aStart.Col(), aRange.aStart.Row(),
5963 aRange.aEnd.Col(), aRange.aEnd.Row(), aRange.aStart.Tab() ));
5964 awt::Point aPos( aMMRect.Left(), aMMRect.Top() );
5965 rAny <<= aPos;
5968 else if ( pEntry->nWID == SC_WID_UNO_SIZE )
5970 ScDocShell* pDocSh = GetDocShell();
5971 if (pDocSh)
5973 // GetMMRect converts using HMM_PER_TWIPS, like the DrawingLayer
5974 Rectangle aMMRect = pDocSh->GetDocument()->GetMMRect(
5975 aRange.aStart.Col(), aRange.aStart.Row(),
5976 aRange.aEnd.Col(), aRange.aEnd.Row(), aRange.aStart.Tab() );
5977 Size aSize(aMMRect.GetSize());
5978 awt::Size aAwtSize( aSize.Width(), aSize.Height() );
5979 rAny <<= aAwtSize;
5982 else
5983 ScCellRangesBase::GetOnePropertyValue( pEntry, rAny );
5987 const SfxItemPropertyMap& ScCellRangeObj::GetItemPropertyMap()
5989 return pRangePropSet->getPropertyMap();
5992 // XServiceInfo
5994 OUString SAL_CALL ScCellRangeObj::getImplementationName() throw(uno::RuntimeException, std::exception)
5996 return OUString( "ScCellRangeObj" );
5999 sal_Bool SAL_CALL ScCellRangeObj::supportsService( const OUString& rServiceName )
6000 throw(uno::RuntimeException, std::exception)
6002 return cppu::supportsService(this, rServiceName);
6005 uno::Sequence<OUString> SAL_CALL ScCellRangeObj::getSupportedServiceNames()
6006 throw(uno::RuntimeException, std::exception)
6008 uno::Sequence<OUString> aRet(5);
6009 OUString* pArray = aRet.getArray();
6010 pArray[0] = OUString( SCSHEETCELLRANGE_SERVICE );
6011 pArray[1] = OUString( SCCELLRANGE_SERVICE );
6012 pArray[2] = OUString( SCCELLPROPERTIES_SERVICE );
6013 pArray[3] = OUString( SCCHARPROPERTIES_SERVICE );
6014 pArray[4] = OUString( SCPARAPROPERTIES_SERVICE );
6015 return aRet;
6018 const SvxItemPropertySet* ScCellObj::GetEditPropertySet()
6020 return lcl_GetEditPropertySet();
6023 const SfxItemPropertyMap& ScCellObj::GetCellPropertyMap()
6025 return lcl_GetCellPropertySet()->getPropertyMap();
6028 ScCellObj::ScCellObj(ScDocShell* pDocSh, const ScAddress& rP) :
6029 ScCellRangeObj( pDocSh, ScRange(rP,rP) ),
6030 pCellPropSet( lcl_GetCellPropertySet() ),
6031 aCellPos( rP ),
6032 nActionLockCount( 0 )
6034 // pUnoText is allocated on demand (GetUnoText)
6035 // can't be aggregated because getString/setString is handled here
6038 SvxUnoText& ScCellObj::GetUnoText()
6040 if (!mxUnoText.is())
6042 mxUnoText.set(new ScCellTextObj(GetDocShell(), aCellPos));
6043 if (nActionLockCount)
6045 ScCellEditSource* pEditSource =
6046 static_cast<ScCellEditSource*> (mxUnoText->GetEditSource());
6047 if (pEditSource)
6048 pEditSource->SetDoUpdateData(false);
6051 return *mxUnoText;
6054 ScCellObj::~ScCellObj()
6058 void ScCellObj::RefChanged()
6060 ScCellRangeObj::RefChanged();
6062 const ScRangeList& rRanges = GetRangeList();
6063 OSL_ENSURE(rRanges.size() == 1, "was fuer Ranges ?!?!");
6064 if ( !rRanges.empty() )
6066 const ScRange* pFirst = rRanges[ 0 ];
6067 aCellPos = pFirst->aStart;
6071 uno::Any SAL_CALL ScCellObj::queryInterface( const uno::Type& rType ) throw(uno::RuntimeException, std::exception)
6073 SC_QUERYINTERFACE( table::XCell )
6074 SC_QUERYINTERFACE( table::XCell2 )
6075 SC_QUERYINTERFACE( sheet::XFormulaTokens )
6076 SC_QUERYINTERFACE( sheet::XCellAddressable )
6077 SC_QUERYINTERFACE( text::XText )
6078 SC_QUERYINTERFACE( text::XSimpleText )
6079 SC_QUERYINTERFACE( text::XTextRange )
6080 SC_QUERYINTERFACE( container::XEnumerationAccess )
6081 SC_QUERYINTERFACE( container::XElementAccess )
6082 SC_QUERYINTERFACE( sheet::XSheetAnnotationAnchor )
6083 SC_QUERYINTERFACE( text::XTextFieldsSupplier )
6084 SC_QUERYINTERFACE( document::XActionLockable )
6086 return ScCellRangeObj::queryInterface( rType );
6089 void SAL_CALL ScCellObj::acquire() throw()
6091 ScCellRangeObj::acquire();
6094 void SAL_CALL ScCellObj::release() throw()
6096 ScCellRangeObj::release();
6099 uno::Sequence<uno::Type> SAL_CALL ScCellObj::getTypes() throw(uno::RuntimeException, std::exception)
6101 static uno::Sequence<uno::Type> aTypes;
6102 if ( aTypes.getLength() == 0 )
6104 uno::Sequence<uno::Type> aParentTypes(ScCellRangeObj::getTypes());
6105 long nParentLen = aParentTypes.getLength();
6106 const uno::Type* pParentPtr = aParentTypes.getConstArray();
6108 aTypes.realloc( nParentLen + 9 );
6109 uno::Type* pPtr = aTypes.getArray();
6110 pPtr[nParentLen + 0] = cppu::UnoType<table::XCell>::get();
6111 pPtr[nParentLen + 1] = cppu::UnoType<sheet::XCellAddressable>::get();
6112 pPtr[nParentLen + 2] = cppu::UnoType<text::XText>::get();
6113 pPtr[nParentLen + 3] = cppu::UnoType<container::XEnumerationAccess>::get();
6114 pPtr[nParentLen + 4] = cppu::UnoType<sheet::XSheetAnnotationAnchor>::get();
6115 pPtr[nParentLen + 5] = cppu::UnoType<text::XTextFieldsSupplier>::get();
6116 pPtr[nParentLen + 6] = cppu::UnoType<document::XActionLockable>::get();
6117 pPtr[nParentLen + 7] = cppu::UnoType<sheet::XFormulaTokens>::get();
6118 pPtr[nParentLen + 8] = cppu::UnoType<table::XCell2>::get();
6120 for (long i=0; i<nParentLen; i++)
6121 pPtr[i] = pParentPtr[i]; // parent types first
6123 return aTypes;
6126 uno::Sequence<sal_Int8> SAL_CALL ScCellObj::getImplementationId() throw(uno::RuntimeException, std::exception)
6128 return css::uno::Sequence<sal_Int8>();
6131 // Hilfsfunktionen
6133 OUString ScCellObj::GetInputString_Impl(bool bEnglish) const // fuer getFormula / FormulaLocal
6135 if (GetDocShell())
6136 return lcl_GetInputString( GetDocShell()->GetDocument(), aCellPos, bEnglish );
6137 return OUString();
6140 OUString ScCellObj::GetOutputString_Impl() const
6142 ScDocShell* pDocSh = GetDocShell();
6143 OUString aVal;
6144 if ( pDocSh )
6146 ScDocument* pDoc = pDocSh->GetDocument();
6147 ScRefCellValue aCell;
6148 aCell.assign(*pDoc, aCellPos);
6150 aVal = ScCellFormat::GetOutputString(*pDoc, aCellPos, aCell);
6152 return aVal;
6155 void ScCellObj::SetString_Impl(const OUString& rString, bool bInterpret, bool bEnglish)
6157 ScDocShell* pDocSh = GetDocShell();
6158 if ( pDocSh )
6160 // GRAM_PODF_A1 for API compatibility.
6161 (void)pDocSh->GetDocFunc().SetCellText(
6162 aCellPos, rString, bInterpret, bEnglish, true, formula::FormulaGrammar::GRAM_PODF_A1 );
6166 double ScCellObj::GetValue_Impl() const
6168 ScDocShell* pDocSh = GetDocShell();
6169 if ( pDocSh )
6170 return pDocSh->GetDocument()->GetValue( aCellPos );
6172 return 0.0;
6175 void ScCellObj::SetValue_Impl(double fValue)
6177 ScDocShell* pDocSh = GetDocShell();
6178 if ( pDocSh )
6179 pDocSh->GetDocFunc().SetValueCell(aCellPos, fValue, false);
6182 // only for XML import
6184 void ScCellObj::InputEnglishString( const OUString& rText )
6186 // This is like a mixture of setFormula and property FormulaLocal:
6187 // The cell's number format is checked for "text", a new cell format may be set,
6188 // but all parsing is in English.
6190 ScDocShell* pDocSh = GetDocShell();
6191 if (!pDocSh)
6192 return;
6194 OUString aString(rText);
6195 ScDocument* pDoc = pDocSh->GetDocument();
6196 SvNumberFormatter* pFormatter = pDoc->GetFormatTable();
6197 sal_uInt32 nOldFormat = pDoc->GetNumberFormat( aCellPos );
6198 if (pFormatter->GetType(nOldFormat) == NUMBERFORMAT_TEXT)
6200 SetString_Impl(aString, false, false); // text cell
6201 return;
6204 ScDocFunc &rFunc = pDocSh->GetDocFunc();
6206 ScInputStringType aRes =
6207 ScStringUtil::parseInputString(*pFormatter, aString, LANGUAGE_ENGLISH_US);
6209 if (aRes.meType != ScInputStringType::Unknown)
6211 if ((nOldFormat % SV_COUNTRY_LANGUAGE_OFFSET) == 0 && aRes.mnFormatType)
6213 // apply a format for the recognized type and the old format's language
6214 sal_uInt32 nNewFormat = ScGlobal::GetStandardFormat(*pFormatter, nOldFormat, aRes.mnFormatType);
6215 if (nNewFormat != nOldFormat)
6217 ScPatternAttr aPattern( pDoc->GetPool() );
6218 aPattern.GetItemSet().Put( SfxUInt32Item( ATTR_VALUE_FORMAT, nNewFormat ) );
6219 // ATTR_LANGUAGE_FORMAT remains unchanged
6220 rFunc.ApplyAttributes( *GetMarkData(), aPattern, true, true );
6224 switch (aRes.meType)
6226 case ScInputStringType::Formula:
6227 rFunc.SetFormulaCell(
6228 aCellPos,
6229 new ScFormulaCell(pDoc, aCellPos, aRes.maText, formula::FormulaGrammar::GRAM_PODF_A1),
6230 false);
6231 break;
6232 case ScInputStringType::Number:
6233 rFunc.SetValueCell(aCellPos, aRes.mfValue, false);
6234 break;
6235 case ScInputStringType::Text:
6236 rFunc.SetStringOrEditCell(aCellPos, aRes.maText, false);
6237 break;
6238 default:
6239 SetString_Impl(aString, false, false); // probably empty string
6243 // XText
6245 uno::Reference<text::XTextCursor> SAL_CALL ScCellObj::createTextCursor()
6246 throw(uno::RuntimeException, std::exception)
6248 SolarMutexGuard aGuard;
6249 return new ScCellTextCursor( *this );
6252 uno::Reference<text::XTextCursor> SAL_CALL ScCellObj::createTextCursorByRange(
6253 const uno::Reference<text::XTextRange>& aTextPosition )
6254 throw(uno::RuntimeException, std::exception)
6256 SolarMutexGuard aGuard;
6257 SvxUnoTextCursor* pCursor = new ScCellTextCursor( *this );
6258 uno::Reference<text::XTextCursor> xCursor(pCursor);
6260 SvxUnoTextRangeBase* pRange = SvxUnoTextRangeBase::getImplementation( aTextPosition );
6261 if(pRange)
6262 pCursor->SetSelection( pRange->GetSelection() );
6263 else
6265 ScCellTextCursor* pOther = ScCellTextCursor::getImplementation( aTextPosition );
6266 if(pOther)
6267 pCursor->SetSelection( pOther->GetSelection() );
6268 else
6269 throw uno::RuntimeException();
6272 return xCursor;
6275 OUString SAL_CALL ScCellObj::getString() throw(uno::RuntimeException, std::exception)
6277 SolarMutexGuard aGuard;
6278 return GetOutputString_Impl();
6281 void SAL_CALL ScCellObj::setString( const OUString& aText ) throw(uno::RuntimeException, std::exception)
6283 SolarMutexGuard aGuard;
6284 OUString aString(aText);
6285 SetString_Impl(aString, false, false); // immer Text
6287 // don't create pUnoText here if not there
6288 if (mxUnoText.is())
6289 mxUnoText->SetSelection(ESelection( 0,0, 0,aString.getLength() ));
6292 void SAL_CALL ScCellObj::insertString( const uno::Reference<text::XTextRange>& xRange,
6293 const OUString& aString, sal_Bool bAbsorb )
6294 throw(uno::RuntimeException, std::exception)
6296 // special handling for ScCellTextCursor is no longer needed,
6297 // SvxUnoText::insertString checks for SvxUnoTextRangeBase instead of SvxUnoTextRange
6299 SolarMutexGuard aGuard;
6300 GetUnoText().insertString(xRange, aString, bAbsorb);
6303 void SAL_CALL ScCellObj::insertControlCharacter( const uno::Reference<text::XTextRange>& xRange,
6304 sal_Int16 nControlCharacter, sal_Bool bAbsorb )
6305 throw(lang::IllegalArgumentException, uno::RuntimeException, std::exception)
6307 SolarMutexGuard aGuard;
6308 GetUnoText().insertControlCharacter(xRange, nControlCharacter, bAbsorb);
6311 void SAL_CALL ScCellObj::insertTextContent( const uno::Reference<text::XTextRange >& xRange,
6312 const uno::Reference<text::XTextContent >& xContent,
6313 sal_Bool bAbsorb )
6314 throw(lang::IllegalArgumentException, uno::RuntimeException, std::exception)
6316 SolarMutexGuard aGuard;
6317 ScDocShell* pDocSh = GetDocShell();
6318 if ( pDocSh && xContent.is() )
6320 ScEditFieldObj* pCellField = ScEditFieldObj::getImplementation(xContent);
6321 SvxUnoTextRangeBase* pTextRange = ScCellTextCursor::getImplementation( xRange );
6323 if ( pCellField && !pCellField->IsInserted() && pTextRange )
6325 SvxEditSource* pEditSource = pTextRange->GetEditSource();
6326 ESelection aSelection(pTextRange->GetSelection());
6328 if (!bAbsorb)
6330 // nicht ersetzen -> hinten anhaengen
6331 aSelection.Adjust();
6332 aSelection.nStartPara = aSelection.nEndPara;
6333 aSelection.nStartPos = aSelection.nEndPos;
6336 if (pCellField->GetFieldType() == text::textfield::Type::TABLE)
6337 pCellField->setPropertyValue(SC_UNONAME_TABLEPOS, uno::makeAny<sal_Int32>(aCellPos.Tab()));
6339 SvxFieldItem aItem = pCellField->CreateFieldItem();
6340 SvxTextForwarder* pForwarder = pEditSource->GetTextForwarder();
6341 pForwarder->QuickInsertField( aItem, aSelection );
6342 pEditSource->UpdateData();
6344 // neue Selektion: ein Zeichen
6345 aSelection.Adjust();
6346 aSelection.nEndPara = aSelection.nStartPara;
6347 aSelection.nEndPos = aSelection.nStartPos + 1;
6348 uno::Reference<text::XTextRange> xParent(this);
6349 pCellField->InitDoc(
6350 xParent, new ScCellEditSource(pDocSh, aCellPos), aSelection);
6352 // for bAbsorb=FALSE, the new selection must be behind the inserted content
6353 // (the xml filter relies on this)
6354 if (!bAbsorb)
6355 aSelection.nStartPos = aSelection.nEndPos;
6357 pTextRange->SetSelection( aSelection );
6359 return;
6362 GetUnoText().insertTextContent(xRange, xContent, bAbsorb);
6365 void SAL_CALL ScCellObj::removeTextContent( const uno::Reference<text::XTextContent>& xContent )
6366 throw(container::NoSuchElementException, uno::RuntimeException, std::exception)
6368 SolarMutexGuard aGuard;
6369 if ( xContent.is() )
6371 ScEditFieldObj* pCellField = ScEditFieldObj::getImplementation(xContent);
6372 if ( pCellField && pCellField->IsInserted() )
6374 //! Testen, ob das Feld in dieser Zelle ist
6375 pCellField->DeleteField();
6376 return;
6379 GetUnoText().removeTextContent(xContent);
6382 uno::Reference<text::XText> SAL_CALL ScCellObj::getText() throw(uno::RuntimeException, std::exception)
6384 SolarMutexGuard aGuard;
6385 return this;
6388 uno::Reference<text::XTextRange> SAL_CALL ScCellObj::getStart() throw(uno::RuntimeException, std::exception)
6390 SolarMutexGuard aGuard;
6391 return GetUnoText().getStart();
6394 uno::Reference<text::XTextRange> SAL_CALL ScCellObj::getEnd() throw(uno::RuntimeException, std::exception)
6396 SolarMutexGuard aGuard;
6397 return GetUnoText().getEnd();
6400 uno::Reference<container::XEnumeration> SAL_CALL ScCellObj::createEnumeration()
6401 throw(uno::RuntimeException, std::exception)
6403 SolarMutexGuard aGuard;
6404 return GetUnoText().createEnumeration();
6407 uno::Type SAL_CALL ScCellObj::getElementType() throw(uno::RuntimeException, std::exception)
6409 SolarMutexGuard aGuard;
6410 return GetUnoText().getElementType();
6413 sal_Bool SAL_CALL ScCellObj::hasElements() throw(uno::RuntimeException, std::exception)
6415 SolarMutexGuard aGuard;
6416 return GetUnoText().hasElements();
6419 // XCell
6421 OUString SAL_CALL ScCellObj::getFormula() throw(uno::RuntimeException, std::exception)
6423 SolarMutexGuard aGuard;
6424 return GetInputString_Impl( true /* English */ );
6427 void SAL_CALL ScCellObj::setFormula( const OUString& aFormula ) throw(uno::RuntimeException, std::exception)
6429 SolarMutexGuard aGuard;
6430 OUString aString(aFormula);
6431 SetString_Impl(aString, true, true); // Interpret as English
6434 double SAL_CALL ScCellObj::getValue() throw(uno::RuntimeException, std::exception)
6436 SolarMutexGuard aGuard;
6437 return GetValue_Impl();
6440 void SAL_CALL ScCellObj::setValue( double nValue ) throw(uno::RuntimeException, std::exception)
6442 SolarMutexGuard aGuard;
6443 SetValue_Impl(nValue);
6446 void SAL_CALL ScCellObj::setFormulaString( const OUString& aFormula) throw(uno::RuntimeException, std::exception)
6448 SolarMutexGuard aGuard;
6449 ScDocShell *pDocSh = GetDocShell();
6450 if( pDocSh )
6452 ScFormulaCell* pCell = new ScFormulaCell( pDocSh->GetDocument(), aCellPos );
6453 pCell->SetHybridFormula( aFormula, formula::FormulaGrammar::GRAM_NATIVE );
6454 pDocSh->GetDocFunc().SetFormulaCell(aCellPos, pCell, false);
6457 void SAL_CALL ScCellObj::setFormulaResult( double nValue ) throw(uno::RuntimeException, std::exception)
6459 SolarMutexGuard aGuard;
6460 ScDocShell* pDocSh = GetDocShell();
6461 if ( pDocSh && pDocSh->GetDocument()->GetCellType( aCellPos ) == CELLTYPE_FORMULA )
6463 ScFormulaCell* pCell = pDocSh->GetDocument()->GetFormulaCell(aCellPos);
6464 if (!pCell)
6465 return;
6466 pCell->SetHybridDouble( nValue );
6467 pCell->ResetDirty();
6468 pCell->SetChanged(false);
6472 table::CellContentType SAL_CALL ScCellObj::getType() throw(uno::RuntimeException, std::exception)
6474 SolarMutexGuard aGuard;
6475 table::CellContentType eRet = table::CellContentType_EMPTY;
6476 ScDocShell* pDocSh = GetDocShell();
6477 if (pDocSh)
6479 CellType eCalcType = pDocSh->GetDocument()->GetCellType( aCellPos );
6480 switch (eCalcType)
6482 case CELLTYPE_VALUE:
6483 eRet = table::CellContentType_VALUE;
6484 break;
6485 case CELLTYPE_STRING:
6486 case CELLTYPE_EDIT:
6487 eRet = table::CellContentType_TEXT;
6488 break;
6489 case CELLTYPE_FORMULA:
6490 eRet = table::CellContentType_FORMULA;
6491 break;
6492 default:
6493 eRet = table::CellContentType_EMPTY;
6496 else
6498 OSL_FAIL("keine DocShell"); //! Exception oder so?
6501 return eRet;
6504 table::CellContentType ScCellObj::GetResultType_Impl()
6506 ScDocShell* pDocSh = GetDocShell();
6507 if ( pDocSh )
6509 ScRefCellValue aCell;
6510 aCell.assign(*pDocSh->GetDocument(), aCellPos);
6511 if (aCell.meType == CELLTYPE_FORMULA)
6513 bool bValue = aCell.mpFormula->IsValue();
6514 return bValue ? table::CellContentType_VALUE : table::CellContentType_TEXT;
6517 return getType(); // wenn keine Formel
6520 sal_Int32 SAL_CALL ScCellObj::getError() throw(uno::RuntimeException, std::exception)
6522 SolarMutexGuard aGuard;
6523 ScDocShell* pDocSh = GetDocShell();
6524 if (!pDocSh)
6526 OSL_FAIL("keine DocShell"); //! Exception oder so?
6527 return 0;
6530 sal_uInt16 nError = 0;
6531 ScRefCellValue aCell;
6532 aCell.assign(*pDocSh->GetDocument(), aCellPos);
6533 if (aCell.meType == CELLTYPE_FORMULA)
6534 nError = aCell.mpFormula->GetErrCode();
6536 return nError;
6539 // XFormulaTokens
6541 uno::Sequence<sheet::FormulaToken> SAL_CALL ScCellObj::getTokens()
6542 throw (uno::RuntimeException, std::exception)
6544 SolarMutexGuard aGuard;
6545 uno::Sequence<sheet::FormulaToken> aSequence;
6546 ScDocShell* pDocSh = GetDocShell();
6547 if (!pDocSh)
6548 return aSequence;
6550 ScDocument* pDoc = pDocSh->GetDocument();
6551 ScRefCellValue aCell;
6552 aCell.assign(*pDoc, aCellPos);
6553 if (aCell.meType == CELLTYPE_FORMULA)
6555 ScTokenArray* pTokenArray = aCell.mpFormula->GetCode();
6556 if (pTokenArray)
6557 ScTokenConversion::ConvertToTokenSequence(*pDoc, aSequence, *pTokenArray);
6559 return aSequence;
6562 void SAL_CALL ScCellObj::setTokens( const uno::Sequence<sheet::FormulaToken>& rTokens ) throw(uno::RuntimeException, std::exception)
6564 SolarMutexGuard aGuard;
6565 ScDocShell* pDocSh = GetDocShell();
6566 if ( pDocSh )
6568 ScDocument* pDoc = pDocSh->GetDocument();
6569 ScTokenArray aTokenArray;
6570 (void)ScTokenConversion::ConvertToTokenArray( *pDoc, aTokenArray, rTokens );
6572 ScFormulaCell* pNewCell = new ScFormulaCell(pDoc, aCellPos, aTokenArray);
6573 (void)pDocSh->GetDocFunc().SetFormulaCell(aCellPos, pNewCell, false);
6577 // XCellAddressable
6579 table::CellAddress SAL_CALL ScCellObj::getCellAddress() throw(uno::RuntimeException, std::exception)
6581 SolarMutexGuard aGuard;
6582 table::CellAddress aAdr;
6583 aAdr.Sheet = aCellPos.Tab();
6584 aAdr.Column = aCellPos.Col();
6585 aAdr.Row = aCellPos.Row();
6586 return aAdr;
6589 // XSheetAnnotationAnchor
6591 uno::Reference<sheet::XSheetAnnotation> SAL_CALL ScCellObj::getAnnotation()
6592 throw(uno::RuntimeException, std::exception)
6594 SolarMutexGuard aGuard;
6595 ScDocShell* pDocSh = GetDocShell();
6596 if ( pDocSh )
6597 return new ScAnnotationObj( pDocSh, aCellPos );
6599 OSL_FAIL("getAnnotation ohne DocShell");
6600 return NULL;
6603 // XFieldTypesSupplier
6605 uno::Reference<container::XEnumerationAccess> SAL_CALL ScCellObj::getTextFields()
6606 throw(uno::RuntimeException, std::exception)
6608 SolarMutexGuard aGuard;
6609 ScDocShell* pDocSh = GetDocShell();
6610 if ( pDocSh )
6612 uno::Reference<text::XTextRange> xContent(this);
6613 return new ScCellFieldsObj(xContent, pDocSh, aCellPos);
6616 return NULL;
6619 uno::Reference<container::XNameAccess> SAL_CALL ScCellObj::getTextFieldMasters()
6620 throw(uno::RuntimeException, std::exception)
6622 // sowas gibts nicht im Calc (?)
6623 return NULL;
6626 // XPropertySet erweitert fuer Zell-Properties
6628 uno::Reference<beans::XPropertySetInfo> SAL_CALL ScCellObj::getPropertySetInfo()
6629 throw(uno::RuntimeException, std::exception)
6631 SolarMutexGuard aGuard;
6632 static uno::Reference<beans::XPropertySetInfo> aRef(
6633 new SfxItemPropertySetInfo( pCellPropSet->getPropertyMap() ));
6634 return aRef;
6637 void ScCellObj::SetOnePropertyValue( const SfxItemPropertySimpleEntry* pEntry, const uno::Any& aValue )
6638 throw(lang::IllegalArgumentException, uno::RuntimeException, std::exception)
6640 if ( pEntry )
6642 if ( pEntry->nWID == SC_WID_UNO_FORMLOC )
6644 OUString aStrVal;
6645 aValue >>= aStrVal;
6646 OUString aString(aStrVal);
6647 SetString_Impl(aString, true, false); // lokal interpretieren
6649 else if ( pEntry->nWID == SC_WID_UNO_FORMRT )
6651 // Read-Only
6652 //! Exception oder so...
6654 else
6655 ScCellRangeObj::SetOnePropertyValue( pEntry, aValue );
6659 void ScCellObj::GetOnePropertyValue( const SfxItemPropertySimpleEntry* pEntry, uno::Any& rAny )
6660 throw(uno::RuntimeException, std::exception)
6662 if ( pEntry )
6664 if ( pEntry->nWID == SC_WID_UNO_FORMLOC )
6666 // sal_False = lokal
6667 rAny <<= OUString( GetInputString_Impl(false) );
6669 else if ( pEntry->nWID == SC_WID_UNO_FORMRT )
6671 table::CellContentType eType = GetResultType_Impl();
6672 rAny <<= eType;
6674 else
6675 ScCellRangeObj::GetOnePropertyValue(pEntry, rAny);
6679 const SfxItemPropertyMap& ScCellObj::GetItemPropertyMap()
6681 return pCellPropSet->getPropertyMap();
6684 // XServiceInfo
6686 OUString SAL_CALL ScCellObj::getImplementationName() throw(uno::RuntimeException, std::exception)
6688 return OUString( "ScCellObj" );
6691 sal_Bool SAL_CALL ScCellObj::supportsService( const OUString& rServiceName )
6692 throw(uno::RuntimeException, std::exception)
6694 return cppu::supportsService(this, rServiceName);
6697 uno::Sequence<OUString> SAL_CALL ScCellObj::getSupportedServiceNames()
6698 throw(uno::RuntimeException, std::exception)
6700 uno::Sequence<OUString> aRet(7);
6701 OUString* pArray = aRet.getArray();
6702 pArray[0] = OUString( SCSHEETCELL_SERVICE );
6703 pArray[1] = OUString( SCCELL_SERVICE );
6704 pArray[2] = OUString( SCCELLPROPERTIES_SERVICE );
6705 pArray[3] = OUString( SCCHARPROPERTIES_SERVICE );
6706 pArray[4] = OUString( SCPARAPROPERTIES_SERVICE );
6707 pArray[5] = OUString( SCSHEETCELLRANGE_SERVICE );
6708 pArray[6] = OUString( SCCELLRANGE_SERVICE );
6709 return aRet;
6712 // XActionLockable
6714 sal_Bool SAL_CALL ScCellObj::isActionLocked() throw(uno::RuntimeException, std::exception)
6716 SolarMutexGuard aGuard;
6717 return nActionLockCount != 0;
6720 void SAL_CALL ScCellObj::addActionLock() throw(uno::RuntimeException, std::exception)
6722 SolarMutexGuard aGuard;
6723 if (!nActionLockCount)
6725 if (mxUnoText.is())
6727 ScCellEditSource* pEditSource =
6728 static_cast<ScCellEditSource*> (mxUnoText->GetEditSource());
6729 if (pEditSource)
6730 pEditSource->SetDoUpdateData(false);
6733 nActionLockCount++;
6736 void SAL_CALL ScCellObj::removeActionLock() throw(uno::RuntimeException, std::exception)
6738 SolarMutexGuard aGuard;
6739 if (nActionLockCount > 0)
6741 nActionLockCount--;
6742 if (!nActionLockCount)
6744 if (mxUnoText.is())
6746 ScCellEditSource* pEditSource =
6747 static_cast<ScCellEditSource*> (mxUnoText->GetEditSource());
6748 if (pEditSource)
6750 pEditSource->SetDoUpdateData(true);
6751 if (pEditSource->IsDirty())
6752 pEditSource->UpdateData();
6759 void SAL_CALL ScCellObj::setActionLocks( sal_Int16 nLock ) throw(uno::RuntimeException, std::exception)
6761 SolarMutexGuard aGuard;
6762 if (mxUnoText.is())
6764 ScCellEditSource* pEditSource =
6765 static_cast<ScCellEditSource*> (mxUnoText->GetEditSource());
6766 if (pEditSource)
6768 pEditSource->SetDoUpdateData(nLock == 0);
6769 if ((nActionLockCount > 0) && (nLock == 0) && pEditSource->IsDirty())
6770 pEditSource->UpdateData();
6773 nActionLockCount = nLock;
6776 sal_Int16 SAL_CALL ScCellObj::resetActionLocks() throw(uno::RuntimeException, std::exception)
6778 SolarMutexGuard aGuard;
6779 sal_uInt16 nRet(nActionLockCount);
6780 if (mxUnoText.is())
6782 ScCellEditSource* pEditSource =
6783 static_cast<ScCellEditSource*> (mxUnoText->GetEditSource());
6784 if (pEditSource)
6786 pEditSource->SetDoUpdateData(true);
6787 if (pEditSource->IsDirty())
6788 pEditSource->UpdateData();
6791 nActionLockCount = 0;
6792 return nRet;
6795 ScTableSheetObj::ScTableSheetObj( ScDocShell* pDocSh, SCTAB nTab ) :
6796 ScCellRangeObj( pDocSh, ScRange(0,0,nTab, MAXCOL,MAXROW,nTab) ),
6797 pSheetPropSet(lcl_GetSheetPropertySet())
6801 ScTableSheetObj::~ScTableSheetObj()
6805 void ScTableSheetObj::InitInsertSheet(ScDocShell* pDocSh, SCTAB nTab)
6807 InitInsertRange( pDocSh, ScRange(0,0,nTab, MAXCOL,MAXROW,nTab) );
6810 uno::Any SAL_CALL ScTableSheetObj::queryInterface( const uno::Type& rType ) throw(uno::RuntimeException, std::exception)
6812 SC_QUERYINTERFACE( sheet::XSpreadsheet )
6813 SC_QUERYINTERFACE( container::XNamed )
6814 SC_QUERYINTERFACE( sheet::XSheetPageBreak )
6815 SC_QUERYINTERFACE( sheet::XCellRangeMovement )
6816 SC_QUERYINTERFACE( table::XTableChartsSupplier )
6817 SC_QUERYINTERFACE( sheet::XDataPilotTablesSupplier )
6818 SC_QUERYINTERFACE( sheet::XScenariosSupplier )
6819 SC_QUERYINTERFACE( sheet::XSheetAnnotationsSupplier )
6820 SC_QUERYINTERFACE( drawing::XDrawPageSupplier )
6821 SC_QUERYINTERFACE( sheet::XPrintAreas )
6822 SC_QUERYINTERFACE( sheet::XSheetAuditing )
6823 SC_QUERYINTERFACE( sheet::XSheetOutline )
6824 SC_QUERYINTERFACE( util::XProtectable )
6825 SC_QUERYINTERFACE( sheet::XScenario )
6826 SC_QUERYINTERFACE( sheet::XScenarioEnhanced )
6827 SC_QUERYINTERFACE( sheet::XSheetLinkable )
6828 SC_QUERYINTERFACE( sheet::XExternalSheetName )
6829 SC_QUERYINTERFACE( document::XEventsSupplier )
6831 return ScCellRangeObj::queryInterface( rType );
6834 void SAL_CALL ScTableSheetObj::acquire() throw()
6836 ScCellRangeObj::acquire();
6839 void SAL_CALL ScTableSheetObj::release() throw()
6841 ScCellRangeObj::release();
6844 uno::Sequence<uno::Type> SAL_CALL ScTableSheetObj::getTypes() throw(uno::RuntimeException, std::exception)
6846 static uno::Sequence<uno::Type> aTypes;
6847 if ( aTypes.getLength() == 0 )
6849 uno::Sequence<uno::Type> aParentTypes = ScCellRangeObj::getTypes();
6850 long nParentLen = aParentTypes.getLength();
6851 const uno::Type* pParentPtr = aParentTypes.getConstArray();
6853 aTypes.realloc( nParentLen + 18 );
6854 uno::Type* pPtr = aTypes.getArray();
6855 pPtr[nParentLen + 0] = cppu::UnoType<sheet::XSpreadsheet>::get();
6856 pPtr[nParentLen + 1] = cppu::UnoType<container::XNamed>::get();
6857 pPtr[nParentLen + 2] = cppu::UnoType<sheet::XSheetPageBreak>::get();
6858 pPtr[nParentLen + 3] = cppu::UnoType<sheet::XCellRangeMovement>::get();
6859 pPtr[nParentLen + 4] = cppu::UnoType<table::XTableChartsSupplier>::get();
6860 pPtr[nParentLen + 5] = cppu::UnoType<sheet::XDataPilotTablesSupplier>::get();
6861 pPtr[nParentLen + 6] = cppu::UnoType<sheet::XScenariosSupplier>::get();
6862 pPtr[nParentLen + 7] = cppu::UnoType<sheet::XSheetAnnotationsSupplier>::get();
6863 pPtr[nParentLen + 8] = cppu::UnoType<drawing::XDrawPageSupplier>::get();
6864 pPtr[nParentLen + 9] = cppu::UnoType<sheet::XPrintAreas>::get();
6865 pPtr[nParentLen +10] = cppu::UnoType<sheet::XSheetAuditing>::get();
6866 pPtr[nParentLen +11] = cppu::UnoType<sheet::XSheetOutline>::get();
6867 pPtr[nParentLen +12] = cppu::UnoType<util::XProtectable>::get();
6868 pPtr[nParentLen +13] = cppu::UnoType<sheet::XScenario>::get();
6869 pPtr[nParentLen +14] = cppu::UnoType<sheet::XScenarioEnhanced>::get();
6870 pPtr[nParentLen +15] = cppu::UnoType<sheet::XSheetLinkable>::get();
6871 pPtr[nParentLen +16] = cppu::UnoType<sheet::XExternalSheetName>::get();
6872 pPtr[nParentLen +17] = cppu::UnoType<document::XEventsSupplier>::get();
6874 for (long i=0; i<nParentLen; i++)
6875 pPtr[i] = pParentPtr[i]; // parent types first
6877 return aTypes;
6880 uno::Sequence<sal_Int8> SAL_CALL ScTableSheetObj::getImplementationId() throw(uno::RuntimeException, std::exception)
6882 return css::uno::Sequence<sal_Int8>();
6885 // Hilfsfunktionen
6887 SCTAB ScTableSheetObj::GetTab_Impl() const
6889 const ScRangeList& rRanges = GetRangeList();
6890 OSL_ENSURE(rRanges.size() == 1, "was fuer Ranges ?!?!");
6891 if ( !rRanges.empty() )
6893 const ScRange* pFirst = rRanges[ 0 ];
6894 return pFirst->aStart.Tab();
6896 return 0; // soll nicht sein
6899 // former XSheet
6901 uno::Reference<table::XTableCharts> SAL_CALL ScTableSheetObj::getCharts() throw(uno::RuntimeException, std::exception)
6903 SolarMutexGuard aGuard;
6904 ScDocShell* pDocSh = GetDocShell();
6905 if ( pDocSh )
6906 return new ScChartsObj( pDocSh, GetTab_Impl() );
6908 OSL_FAIL("kein Dokument");
6909 return NULL;
6912 uno::Reference<sheet::XDataPilotTables> SAL_CALL ScTableSheetObj::getDataPilotTables()
6913 throw(uno::RuntimeException, std::exception)
6915 SolarMutexGuard aGuard;
6916 ScDocShell* pDocSh = GetDocShell();
6917 if ( pDocSh )
6918 return new ScDataPilotTablesObj( pDocSh, GetTab_Impl() );
6920 OSL_FAIL("kein Dokument");
6921 return NULL;
6924 uno::Reference<sheet::XScenarios> SAL_CALL ScTableSheetObj::getScenarios() throw(uno::RuntimeException, std::exception)
6926 SolarMutexGuard aGuard;
6927 ScDocShell* pDocSh = GetDocShell();
6929 if ( pDocSh )
6930 return new ScScenariosObj( pDocSh, GetTab_Impl() );
6932 OSL_FAIL("kein Dokument");
6933 return NULL;
6936 uno::Reference<sheet::XSheetAnnotations> SAL_CALL ScTableSheetObj::getAnnotations()
6937 throw(uno::RuntimeException, std::exception)
6939 SolarMutexGuard aGuard;
6940 ScDocShell* pDocSh = GetDocShell();
6942 if ( pDocSh )
6943 return new ScAnnotationsObj( pDocSh, GetTab_Impl() );
6945 OSL_FAIL("kein Dokument");
6946 return NULL;
6949 uno::Reference<table::XCellRange> SAL_CALL ScTableSheetObj::getCellRangeByName(
6950 const OUString& rRange ) throw(uno::RuntimeException, std::exception)
6952 SolarMutexGuard aGuard;
6953 return ScCellRangeObj::getCellRangeByName( rRange );
6956 uno::Reference<sheet::XSheetCellCursor> SAL_CALL ScTableSheetObj::createCursor()
6957 throw(uno::RuntimeException, std::exception)
6959 SolarMutexGuard aGuard;
6960 ScDocShell* pDocSh = GetDocShell();
6961 if ( pDocSh )
6963 //! einzelne Zelle oder ganze Tabelle???????
6964 SCTAB nTab = GetTab_Impl();
6965 return new ScCellCursorObj( pDocSh, ScRange( 0,0,nTab, MAXCOL,MAXROW,nTab ) );
6967 return NULL;
6970 uno::Reference<sheet::XSheetCellCursor> SAL_CALL ScTableSheetObj::createCursorByRange(
6971 const uno::Reference<sheet::XSheetCellRange>& xCellRange )
6972 throw(uno::RuntimeException, std::exception)
6974 SolarMutexGuard aGuard;
6975 ScDocShell* pDocSh = GetDocShell();
6976 if ( pDocSh && xCellRange.is() )
6978 ScCellRangesBase* pRangesImp = ScCellRangesBase::getImplementation( xCellRange );
6979 if (pRangesImp)
6981 const ScRangeList& rRanges = pRangesImp->GetRangeList();
6982 OSL_ENSURE( rRanges.size() == 1, "Range? Ranges?" );
6983 return new ScCellCursorObj( pDocSh, *rRanges[ 0 ] );
6986 return NULL;
6989 // XSheetCellRange
6991 uno::Reference<sheet::XSpreadsheet> SAL_CALL ScTableSheetObj::getSpreadsheet()
6992 throw(uno::RuntimeException, std::exception)
6994 SolarMutexGuard aGuard;
6995 return this; //!???
6998 // XCellRange
7000 uno::Reference<table::XCell> SAL_CALL ScTableSheetObj::getCellByPosition(
7001 sal_Int32 nColumn, sal_Int32 nRow )
7002 throw(lang::IndexOutOfBoundsException, uno::RuntimeException, std::exception)
7004 SolarMutexGuard aGuard;
7005 return ScCellRangeObj::GetCellByPosition_Impl(nColumn, nRow);
7008 uno::Reference<table::XCellRange> SAL_CALL ScTableSheetObj::getCellRangeByPosition(
7009 sal_Int32 nLeft, sal_Int32 nTop, sal_Int32 nRight, sal_Int32 nBottom )
7010 throw(lang::IndexOutOfBoundsException, uno::RuntimeException, std::exception)
7012 SolarMutexGuard aGuard;
7013 return ScCellRangeObj::getCellRangeByPosition(nLeft,nTop,nRight,nBottom);
7016 uno::Sequence<sheet::TablePageBreakData> SAL_CALL ScTableSheetObj::getColumnPageBreaks()
7017 throw(uno::RuntimeException, std::exception)
7019 SolarMutexGuard aGuard;
7020 ScDocShell* pDocSh = GetDocShell();
7021 if ( pDocSh )
7023 ScDocument* pDoc = pDocSh->GetDocument();
7024 SCTAB nTab = GetTab_Impl();
7026 Size aSize(pDoc->GetPageSize( nTab ));
7027 if (aSize.Width() && aSize.Height()) // effektive Groesse schon gesetzt?
7028 pDoc->UpdatePageBreaks( nTab );
7029 else
7031 // Umbrueche updaten wie in ScDocShell::PageStyleModified:
7032 ScPrintFunc aPrintFunc( pDocSh, pDocSh->GetPrinter(), nTab );
7033 aPrintFunc.UpdatePages();
7036 SCCOL nCount = 0;
7037 SCCOL nCol;
7038 for (nCol=0; nCol<=MAXCOL; nCol++)
7039 if (pDoc->HasColBreak(nCol, nTab))
7040 ++nCount;
7042 sheet::TablePageBreakData aData;
7043 uno::Sequence<sheet::TablePageBreakData> aSeq(nCount);
7044 sheet::TablePageBreakData* pAry = aSeq.getArray();
7045 sal_uInt16 nPos = 0;
7046 for (nCol=0; nCol<=MAXCOL; nCol++)
7048 ScBreakType nBreak = pDoc->HasColBreak(nCol, nTab);
7049 if (nBreak)
7051 aData.Position = nCol;
7052 aData.ManualBreak = (nBreak & BREAK_MANUAL);
7053 pAry[nPos] = aData;
7054 ++nPos;
7057 return aSeq;
7059 return uno::Sequence<sheet::TablePageBreakData>(0);
7062 uno::Sequence<sheet::TablePageBreakData> SAL_CALL ScTableSheetObj::getRowPageBreaks()
7063 throw(uno::RuntimeException, std::exception)
7065 SolarMutexGuard aGuard;
7066 ScDocShell* pDocSh = GetDocShell();
7067 if ( pDocSh )
7069 ScDocument* pDoc = pDocSh->GetDocument();
7070 SCTAB nTab = GetTab_Impl();
7072 Size aSize(pDoc->GetPageSize( nTab ));
7073 if (aSize.Width() && aSize.Height()) // effektive Groesse schon gesetzt?
7074 pDoc->UpdatePageBreaks( nTab );
7075 else
7077 // Umbrueche updaten wie in ScDocShell::PageStyleModified:
7078 ScPrintFunc aPrintFunc( pDocSh, pDocSh->GetPrinter(), nTab );
7079 aPrintFunc.UpdatePages();
7081 return pDoc->GetRowBreakData(nTab);
7083 return uno::Sequence<sheet::TablePageBreakData>(0);
7086 void SAL_CALL ScTableSheetObj::removeAllManualPageBreaks() throw(uno::RuntimeException, std::exception)
7088 SolarMutexGuard aGuard;
7089 ScDocShell* pDocSh = GetDocShell();
7090 if ( pDocSh )
7092 //! docfunc Funktion, auch fuer ScViewFunc::RemoveManualBreaks
7094 ScDocument* pDoc = pDocSh->GetDocument();
7095 bool bUndo (pDoc->IsUndoEnabled());
7096 SCTAB nTab = GetTab_Impl();
7098 if (bUndo)
7100 ScDocument* pUndoDoc = new ScDocument( SCDOCMODE_UNDO );
7101 pUndoDoc->InitUndo( pDoc, nTab, nTab, true, true );
7102 pDoc->CopyToDocument( 0,0,nTab, MAXCOL,MAXROW,nTab, IDF_NONE, false, pUndoDoc );
7103 pDocSh->GetUndoManager()->AddUndoAction(
7104 new ScUndoRemoveBreaks( pDocSh, nTab, pUndoDoc ) );
7107 pDoc->RemoveManualBreaks(nTab);
7108 pDoc->UpdatePageBreaks(nTab);
7110 //? UpdatePageBreakData( sal_True );
7111 pDocSh->SetDocumentModified();
7112 pDocSh->PostPaint(ScRange(0, 0, nTab, MAXCOL, MAXROW, nTab), PAINT_GRID);
7116 // XNamed
7118 OUString SAL_CALL ScTableSheetObj::getName() throw(uno::RuntimeException, std::exception)
7120 SolarMutexGuard aGuard;
7121 OUString aName;
7122 ScDocShell* pDocSh = GetDocShell();
7123 if ( pDocSh )
7124 pDocSh->GetDocument()->GetName( GetTab_Impl(), aName );
7125 return aName;
7128 void SAL_CALL ScTableSheetObj::setName( const OUString& aNewName )
7129 throw(uno::RuntimeException, std::exception)
7131 SolarMutexGuard aGuard;
7132 ScDocShell* pDocSh = GetDocShell();
7133 if ( pDocSh )
7135 OUString aString(aNewName);
7136 pDocSh->GetDocFunc().RenameTable( GetTab_Impl(), aString, true, true );
7140 // XDrawPageSupplier
7142 uno::Reference<drawing::XDrawPage> SAL_CALL ScTableSheetObj::getDrawPage()
7143 throw(uno::RuntimeException, std::exception)
7145 SolarMutexGuard aGuard;
7146 ScDocShell* pDocSh = GetDocShell();
7147 if ( pDocSh )
7149 ScDrawLayer* pDrawLayer = pDocSh->MakeDrawLayer();
7150 OSL_ENSURE(pDrawLayer,"kann Draw-Layer nicht anlegen");
7152 SCTAB nTab = GetTab_Impl();
7153 SdrPage* pPage = pDrawLayer->GetPage(static_cast<sal_uInt16>(nTab));
7154 OSL_ENSURE(pPage,"Draw-Page nicht gefunden");
7155 if (pPage)
7156 return uno::Reference<drawing::XDrawPage> (pPage->getUnoPage(), uno::UNO_QUERY);
7158 // Das DrawPage-Objekt meldet sich als Listener am SdrModel an
7159 // und sollte von dort alle Aktionen mitbekommen
7161 return NULL;
7164 // XCellMovement
7166 void SAL_CALL ScTableSheetObj::insertCells( const table::CellRangeAddress& rRangeAddress,
7167 sheet::CellInsertMode nMode ) throw(uno::RuntimeException, std::exception)
7169 SolarMutexGuard aGuard;
7170 ScDocShell* pDocSh = GetDocShell();
7171 if ( pDocSh )
7173 bool bDo = true;
7174 InsCellCmd eCmd = INS_NONE;
7175 switch (nMode)
7177 case sheet::CellInsertMode_NONE: bDo = false; break;
7178 case sheet::CellInsertMode_DOWN: eCmd = INS_CELLSDOWN; break;
7179 case sheet::CellInsertMode_RIGHT: eCmd = INS_CELLSRIGHT; break;
7180 case sheet::CellInsertMode_ROWS: eCmd = INS_INSROWS; break;
7181 case sheet::CellInsertMode_COLUMNS: eCmd = INS_INSCOLS; break;
7182 default:
7183 OSL_FAIL("insertCells: falscher Mode");
7184 bDo = false;
7187 if (bDo)
7189 OSL_ENSURE( rRangeAddress.Sheet == GetTab_Impl(), "falsche Tabelle in CellRangeAddress" );
7190 ScRange aScRange;
7191 ScUnoConversion::FillScRange( aScRange, rRangeAddress );
7192 pDocSh->GetDocFunc().InsertCells( aScRange, NULL, eCmd, true, true );
7197 void SAL_CALL ScTableSheetObj::removeRange( const table::CellRangeAddress& rRangeAddress,
7198 sheet::CellDeleteMode nMode ) throw(uno::RuntimeException, std::exception)
7200 SolarMutexGuard aGuard;
7201 ScDocShell* pDocSh = GetDocShell();
7202 if ( pDocSh )
7204 bool bDo = true;
7205 DelCellCmd eCmd = DEL_NONE;
7206 switch (nMode)
7208 case sheet::CellDeleteMode_NONE: bDo = false; break;
7209 case sheet::CellDeleteMode_UP: eCmd = DEL_CELLSUP; break;
7210 case sheet::CellDeleteMode_LEFT: eCmd = DEL_CELLSLEFT; break;
7211 case sheet::CellDeleteMode_ROWS: eCmd = DEL_DELROWS; break;
7212 case sheet::CellDeleteMode_COLUMNS: eCmd = DEL_DELCOLS; break;
7213 default:
7214 OSL_FAIL("deleteCells: falscher Mode");
7215 bDo = false;
7218 if (bDo)
7220 OSL_ENSURE( rRangeAddress.Sheet == GetTab_Impl(), "falsche Tabelle in CellRangeAddress" );
7221 ScRange aScRange;
7222 ScUnoConversion::FillScRange( aScRange, rRangeAddress );
7223 pDocSh->GetDocFunc().DeleteCells( aScRange, NULL, eCmd, true, true );
7228 void SAL_CALL ScTableSheetObj::moveRange( const table::CellAddress& aDestination,
7229 const table::CellRangeAddress& aSource )
7230 throw(uno::RuntimeException, std::exception)
7232 SolarMutexGuard aGuard;
7233 ScDocShell* pDocSh = GetDocShell();
7234 if ( pDocSh )
7236 OSL_ENSURE( aSource.Sheet == GetTab_Impl(), "falsche Tabelle in CellRangeAddress" );
7237 ScRange aSourceRange;
7238 ScUnoConversion::FillScRange( aSourceRange, aSource );
7239 ScAddress aDestPos( (SCCOL)aDestination.Column, (SCROW)aDestination.Row, aDestination.Sheet );
7240 pDocSh->GetDocFunc().MoveBlock( aSourceRange, aDestPos, true, true, true, true );
7244 void SAL_CALL ScTableSheetObj::copyRange( const table::CellAddress& aDestination,
7245 const table::CellRangeAddress& aSource )
7246 throw(uno::RuntimeException, std::exception)
7248 SolarMutexGuard aGuard;
7249 ScDocShell* pDocSh = GetDocShell();
7250 if ( pDocSh )
7252 OSL_ENSURE( aSource.Sheet == GetTab_Impl(), "falsche Tabelle in CellRangeAddress" );
7253 ScRange aSourceRange;
7254 ScUnoConversion::FillScRange( aSourceRange, aSource );
7255 ScAddress aDestPos( (SCCOL)aDestination.Column, (SCROW)aDestination.Row, aDestination.Sheet );
7256 pDocSh->GetDocFunc().MoveBlock( aSourceRange, aDestPos, false, true, true, true );
7260 // XPrintAreas
7262 void ScTableSheetObj::PrintAreaUndo_Impl( ScPrintRangeSaver* pOldRanges )
7264 // Umbrueche und Undo
7265 ScDocShell* pDocSh = GetDocShell();
7266 ScDocument* pDoc = pDocSh ? pDocSh->GetDocument() : 0;
7268 if(pDocSh && pDoc)
7270 const bool bUndo(pDoc->IsUndoEnabled());
7271 const SCTAB nTab(GetTab_Impl());
7273 if(bUndo)
7275 pDocSh->GetUndoManager()->AddUndoAction(
7276 new ScUndoPrintRange(
7277 pDocSh,
7278 nTab,
7279 pOldRanges,
7280 pDoc->CreatePrintRangeSaver())); // create new ranges
7282 // #i120105# ownership of old ranges has changed, mark as consumed
7283 pOldRanges = 0;
7286 ScPrintFunc(pDocSh, pDocSh->GetPrinter(), nTab).UpdatePages();
7287 SfxBindings* pBindings = pDocSh->GetViewBindings();
7289 if(pBindings)
7291 pBindings->Invalidate(SID_DELETE_PRINTAREA);
7294 pDocSh->SetDocumentModified();
7297 // #i120105# pOldRanges not used, need to cleanup
7298 delete pOldRanges;
7301 uno::Sequence<table::CellRangeAddress> SAL_CALL ScTableSheetObj::getPrintAreas()
7302 throw(uno::RuntimeException, std::exception)
7304 SolarMutexGuard aGuard;
7305 ScDocShell* pDocSh = GetDocShell();
7306 if ( pDocSh )
7308 ScDocument* pDoc = pDocSh->GetDocument();
7309 SCTAB nTab = GetTab_Impl();
7310 sal_uInt16 nCount = pDoc->GetPrintRangeCount( nTab );
7312 table::CellRangeAddress aRangeAddress;
7313 uno::Sequence<table::CellRangeAddress> aSeq(nCount);
7314 table::CellRangeAddress* pAry = aSeq.getArray();
7315 for (sal_uInt16 i=0; i<nCount; i++)
7317 const ScRange* pRange = pDoc->GetPrintRange( nTab, i );
7318 OSL_ENSURE(pRange,"wo ist der Druckbereich");
7319 if (pRange)
7321 ScUnoConversion::FillApiRange( aRangeAddress, *pRange );
7322 aRangeAddress.Sheet = nTab; // core does not care about sheet index
7323 pAry[i] = aRangeAddress;
7326 return aSeq;
7328 return uno::Sequence<table::CellRangeAddress>();
7331 void SAL_CALL ScTableSheetObj::setPrintAreas(
7332 const uno::Sequence<table::CellRangeAddress>& aPrintAreas )
7333 throw(uno::RuntimeException, std::exception)
7335 SolarMutexGuard aGuard;
7336 ScPrintRangeSaver* pOldRanges = NULL;
7337 ScDocShell* pDocSh = GetDocShell();
7338 if ( pDocSh )
7340 ScDocument* pDoc = pDocSh->GetDocument();
7341 SCTAB nTab = GetTab_Impl();
7343 if ( pDoc->IsUndoEnabled() )
7344 pOldRanges = pDoc->CreatePrintRangeSaver();
7346 sal_uInt16 nCount = (sal_uInt16) aPrintAreas.getLength();
7347 pDoc->ClearPrintRanges( nTab );
7348 if (nCount)
7350 ScRange aPrintRange;
7351 const table::CellRangeAddress* pAry = aPrintAreas.getConstArray();
7352 for (sal_uInt16 i=0; i<nCount; i++)
7354 ScUnoConversion::FillScRange( aPrintRange, pAry[i] );
7355 pDoc->AddPrintRange( nTab, aPrintRange );
7359 if ( pDoc->IsUndoEnabled() )
7360 PrintAreaUndo_Impl( pOldRanges ); // Undo, Umbrueche, Modified etc.
7364 sal_Bool SAL_CALL ScTableSheetObj::getPrintTitleColumns() throw(uno::RuntimeException, std::exception)
7366 SolarMutexGuard aGuard;
7367 ScDocShell* pDocSh = GetDocShell();
7368 if ( pDocSh )
7370 ScDocument* pDoc = pDocSh->GetDocument();
7371 SCTAB nTab = GetTab_Impl();
7372 return ( pDoc->GetRepeatColRange(nTab) != NULL );
7374 return false;
7377 void SAL_CALL ScTableSheetObj::setPrintTitleColumns( sal_Bool bPrintTitleColumns )
7378 throw(uno::RuntimeException, std::exception)
7380 SolarMutexGuard aGuard;
7381 ScDocShell* pDocSh = GetDocShell();
7382 if ( pDocSh )
7384 ScDocument* pDoc = pDocSh->GetDocument();
7385 SCTAB nTab = GetTab_Impl();
7387 ScPrintRangeSaver* pOldRanges = pDoc->CreatePrintRangeSaver();
7389 if ( bPrintTitleColumns )
7391 if ( !pDoc->GetRepeatColRange( nTab ) ) // keinen bestehenden Bereich veraendern
7393 ScRange aNew( 0, 0, nTab, 0, 0, nTab ); // Default
7394 pDoc->SetRepeatColRange( nTab, &aNew ); // einschalten
7397 else
7398 pDoc->SetRepeatColRange( nTab, NULL ); // abschalten
7400 PrintAreaUndo_Impl( pOldRanges ); // Undo, Umbrueche, Modified etc.
7402 //! zuletzt gesetzten Bereich beim Abschalten merken und beim Einschalten wiederherstellen ???
7406 table::CellRangeAddress SAL_CALL ScTableSheetObj::getTitleColumns() throw(uno::RuntimeException, std::exception)
7408 SolarMutexGuard aGuard;
7409 table::CellRangeAddress aRet;
7410 ScDocShell* pDocSh = GetDocShell();
7411 if ( pDocSh )
7413 ScDocument* pDoc = pDocSh->GetDocument();
7414 SCTAB nTab = GetTab_Impl();
7415 const ScRange* pRange = pDoc->GetRepeatColRange(nTab);
7416 if (pRange)
7418 ScUnoConversion::FillApiRange( aRet, *pRange );
7419 aRet.Sheet = nTab; // core does not care about sheet index
7422 return aRet;
7425 void SAL_CALL ScTableSheetObj::setTitleColumns( const table::CellRangeAddress& aTitleColumns )
7426 throw(uno::RuntimeException, std::exception)
7428 SolarMutexGuard aGuard;
7429 ScDocShell* pDocSh = GetDocShell();
7430 if ( pDocSh )
7432 ScDocument* pDoc = pDocSh->GetDocument();
7433 SCTAB nTab = GetTab_Impl();
7435 ScPrintRangeSaver* pOldRanges = pDoc->CreatePrintRangeSaver();
7437 ScRange aNew;
7438 ScUnoConversion::FillScRange( aNew, aTitleColumns );
7439 pDoc->SetRepeatColRange( nTab, &aNew ); // immer auch einschalten
7441 PrintAreaUndo_Impl( pOldRanges ); // Undo, Umbrueche, Modified etc.
7445 sal_Bool SAL_CALL ScTableSheetObj::getPrintTitleRows() throw(uno::RuntimeException, std::exception)
7447 SolarMutexGuard aGuard;
7448 ScDocShell* pDocSh = GetDocShell();
7449 if ( pDocSh )
7451 ScDocument* pDoc = pDocSh->GetDocument();
7452 SCTAB nTab = GetTab_Impl();
7453 return ( pDoc->GetRepeatRowRange(nTab) != NULL );
7455 return false;
7458 void SAL_CALL ScTableSheetObj::setPrintTitleRows( sal_Bool bPrintTitleRows )
7459 throw(uno::RuntimeException, std::exception)
7461 SolarMutexGuard aGuard;
7462 ScDocShell* pDocSh = GetDocShell();
7463 if ( pDocSh )
7465 ScDocument* pDoc = pDocSh->GetDocument();
7466 SCTAB nTab = GetTab_Impl();
7468 ScPrintRangeSaver* pOldRanges = pDoc->CreatePrintRangeSaver();
7470 if ( bPrintTitleRows )
7472 if ( !pDoc->GetRepeatRowRange( nTab ) ) // keinen bestehenden Bereich veraendern
7474 ScRange aNew( 0, 0, nTab, 0, 0, nTab ); // Default
7475 pDoc->SetRepeatRowRange( nTab, &aNew ); // einschalten
7478 else
7479 pDoc->SetRepeatRowRange( nTab, NULL ); // abschalten
7481 PrintAreaUndo_Impl( pOldRanges ); // Undo, Umbrueche, Modified etc.
7483 //! zuletzt gesetzten Bereich beim Abschalten merken und beim Einschalten wiederherstellen ???
7487 table::CellRangeAddress SAL_CALL ScTableSheetObj::getTitleRows() throw(uno::RuntimeException, std::exception)
7489 SolarMutexGuard aGuard;
7490 table::CellRangeAddress aRet;
7491 ScDocShell* pDocSh = GetDocShell();
7492 if ( pDocSh )
7494 ScDocument* pDoc = pDocSh->GetDocument();
7495 SCTAB nTab = GetTab_Impl();
7496 const ScRange* pRange = pDoc->GetRepeatRowRange(nTab);
7497 if (pRange)
7499 ScUnoConversion::FillApiRange( aRet, *pRange );
7500 aRet.Sheet = nTab; // core does not care about sheet index
7503 return aRet;
7506 void SAL_CALL ScTableSheetObj::setTitleRows( const table::CellRangeAddress& aTitleRows )
7507 throw(uno::RuntimeException, std::exception)
7509 SolarMutexGuard aGuard;
7510 ScDocShell* pDocSh = GetDocShell();
7511 if ( pDocSh )
7513 ScDocument* pDoc = pDocSh->GetDocument();
7514 SCTAB nTab = GetTab_Impl();
7516 ScPrintRangeSaver* pOldRanges = pDoc->CreatePrintRangeSaver();
7518 ScRange aNew;
7519 ScUnoConversion::FillScRange( aNew, aTitleRows );
7520 pDoc->SetRepeatRowRange( nTab, &aNew ); // immer auch einschalten
7522 PrintAreaUndo_Impl( pOldRanges ); // Undo, Umbrueche, Modified etc.
7526 // XSheetLinkable
7528 sheet::SheetLinkMode SAL_CALL ScTableSheetObj::getLinkMode() throw(uno::RuntimeException, std::exception)
7530 SolarMutexGuard aGuard;
7531 sheet::SheetLinkMode eRet = sheet::SheetLinkMode_NONE;
7532 ScDocShell* pDocSh = GetDocShell();
7533 if ( pDocSh )
7535 sal_uInt8 nMode = pDocSh->GetDocument()->GetLinkMode( GetTab_Impl() );
7536 if ( nMode == SC_LINK_NORMAL )
7537 eRet = sheet::SheetLinkMode_NORMAL;
7538 else if ( nMode == SC_LINK_VALUE )
7539 eRet = sheet::SheetLinkMode_VALUE;
7541 return eRet;
7544 void SAL_CALL ScTableSheetObj::setLinkMode( sheet::SheetLinkMode nLinkMode )
7545 throw(uno::RuntimeException, std::exception)
7547 SolarMutexGuard aGuard;
7549 //! Filter und Options aus altem Link suchen
7551 OUString aUrl(getLinkUrl());
7552 OUString aSheet(getLinkSheetName());
7554 OUString aEmpty;
7555 link( aUrl, aSheet, aEmpty, aEmpty, nLinkMode );
7558 OUString SAL_CALL ScTableSheetObj::getLinkUrl() throw(uno::RuntimeException, std::exception)
7560 SolarMutexGuard aGuard;
7561 OUString aFile;
7562 ScDocShell* pDocSh = GetDocShell();
7563 if ( pDocSh )
7564 aFile = pDocSh->GetDocument()->GetLinkDoc( GetTab_Impl() );
7565 return aFile;
7568 void SAL_CALL ScTableSheetObj::setLinkUrl( const OUString& aLinkUrl )
7569 throw(uno::RuntimeException, std::exception)
7571 SolarMutexGuard aGuard;
7573 //! Filter und Options aus altem Link suchen
7575 sheet::SheetLinkMode eMode = getLinkMode();
7576 OUString aSheet(getLinkSheetName());
7578 OUString aEmpty;
7579 link( aLinkUrl, aSheet, aEmpty, aEmpty, eMode );
7582 OUString SAL_CALL ScTableSheetObj::getLinkSheetName() throw(uno::RuntimeException, std::exception)
7584 SolarMutexGuard aGuard;
7585 OUString aSheet;
7586 ScDocShell* pDocSh = GetDocShell();
7587 if ( pDocSh )
7588 aSheet = pDocSh->GetDocument()->GetLinkTab( GetTab_Impl() );
7589 return aSheet;
7592 void SAL_CALL ScTableSheetObj::setLinkSheetName( const OUString& aLinkSheetName )
7593 throw(uno::RuntimeException, std::exception)
7595 SolarMutexGuard aGuard;
7597 //! Filter und Options aus altem Link suchen
7599 sheet::SheetLinkMode eMode = getLinkMode();
7600 OUString aUrl(getLinkUrl());
7602 OUString aEmpty;
7603 link( aUrl, aLinkSheetName, aEmpty, aEmpty, eMode );
7606 void SAL_CALL ScTableSheetObj::link( const OUString& aUrl, const OUString& aSheetName,
7607 const OUString& aFilterName, const OUString& aFilterOptions,
7608 sheet::SheetLinkMode nMode ) throw(uno::RuntimeException, std::exception)
7610 SolarMutexGuard aGuard;
7611 ScDocShell* pDocSh = GetDocShell();
7612 if ( pDocSh )
7614 ScDocument* pDoc = pDocSh->GetDocument();
7615 SCTAB nTab = GetTab_Impl();
7617 OUString aFileString = aUrl;
7618 OUString aFilterString = aFilterName;
7619 OUString aOptString = aFilterOptions;
7620 OUString aSheetString = aSheetName;
7622 aFileString = ScGlobal::GetAbsDocName( aFileString, pDocSh );
7623 if (aFilterString.isEmpty())
7624 ScDocumentLoader::GetFilterName( aFileString, aFilterString, aOptString, true, false );
7626 // remove application prefix from filter name here, so the filter options
7627 // aren't reset when the filter name is changed in ScTableLink::DataChanged
7628 ScDocumentLoader::RemoveAppPrefix( aFilterString );
7630 sal_uInt8 nLinkMode = SC_LINK_NONE;
7631 if ( nMode == sheet::SheetLinkMode_NORMAL )
7632 nLinkMode = SC_LINK_NORMAL;
7633 else if ( nMode == sheet::SheetLinkMode_VALUE )
7634 nLinkMode = SC_LINK_VALUE;
7636 sal_uLong nRefresh = 0;
7637 pDoc->SetLink( nTab, nLinkMode, aFileString, aFilterString, aOptString, aSheetString, nRefresh );
7639 pDocSh->UpdateLinks(); // ggf. Link eintragen oder loeschen
7640 SfxBindings* pBindings = pDocSh->GetViewBindings();
7641 if (pBindings)
7642 pBindings->Invalidate(SID_LINKS);
7644 //! Undo fuer Link-Daten an der Table
7646 if ( nLinkMode != SC_LINK_NONE && pDoc->IsExecuteLinkEnabled() ) // Link updaten
7648 // Update immer, auch wenn der Link schon da war
7649 //! Update nur fuer die betroffene Tabelle???
7651 sfx2::LinkManager* pLinkManager = pDoc->GetLinkManager();
7652 sal_uInt16 nCount = pLinkManager->GetLinks().size();
7653 for ( sal_uInt16 i=0; i<nCount; i++ )
7655 ::sfx2::SvBaseLink* pBase = *pLinkManager->GetLinks()[i];
7656 if (pBase->ISA(ScTableLink))
7658 ScTableLink* pTabLink = (ScTableLink*)pBase;
7659 if ( aFileString.equals(pTabLink->GetFileName()) )
7660 pTabLink->Update(); // inkl. Paint&Undo
7662 //! Der Dateiname sollte nur einmal vorkommen (?)
7667 //! Notify fuer ScSheetLinkObj Objekte!!!
7671 // XSheetAuditing
7673 sal_Bool SAL_CALL ScTableSheetObj::hideDependents( const table::CellAddress& aPosition )
7674 throw(uno::RuntimeException, std::exception)
7676 SolarMutexGuard aGuard;
7677 ScDocShell* pDocSh = GetDocShell();
7678 if ( pDocSh )
7680 SCTAB nTab = GetTab_Impl();
7681 OSL_ENSURE( aPosition.Sheet == nTab, "falsche Tabelle in CellAddress" );
7682 ScAddress aPos( (SCCOL)aPosition.Column, (SCROW)aPosition.Row, nTab );
7683 return pDocSh->GetDocFunc().DetectiveDelSucc( aPos );
7685 return false;
7688 sal_Bool SAL_CALL ScTableSheetObj::hidePrecedents( const table::CellAddress& aPosition )
7689 throw(uno::RuntimeException, std::exception)
7691 SolarMutexGuard aGuard;
7692 ScDocShell* pDocSh = GetDocShell();
7693 if ( pDocSh )
7695 SCTAB nTab = GetTab_Impl();
7696 OSL_ENSURE( aPosition.Sheet == nTab, "falsche Tabelle in CellAddress" );
7697 ScAddress aPos( (SCCOL)aPosition.Column, (SCROW)aPosition.Row, nTab );
7698 return pDocSh->GetDocFunc().DetectiveDelPred( aPos );
7700 return false;
7703 sal_Bool SAL_CALL ScTableSheetObj::showDependents( const table::CellAddress& aPosition )
7704 throw(uno::RuntimeException, std::exception)
7706 SolarMutexGuard aGuard;
7707 ScDocShell* pDocSh = GetDocShell();
7708 if ( pDocSh )
7710 SCTAB nTab = GetTab_Impl();
7711 OSL_ENSURE( aPosition.Sheet == nTab, "falsche Tabelle in CellAddress" );
7712 ScAddress aPos( (SCCOL)aPosition.Column, (SCROW)aPosition.Row, nTab );
7713 return pDocSh->GetDocFunc().DetectiveAddSucc( aPos );
7715 return false;
7718 sal_Bool SAL_CALL ScTableSheetObj::showPrecedents( const table::CellAddress& aPosition )
7719 throw(uno::RuntimeException, std::exception)
7721 SolarMutexGuard aGuard;
7722 ScDocShell* pDocSh = GetDocShell();
7723 if ( pDocSh )
7725 SCTAB nTab = GetTab_Impl();
7726 OSL_ENSURE( aPosition.Sheet == nTab, "falsche Tabelle in CellAddress" );
7727 ScAddress aPos( (SCCOL)aPosition.Column, (SCROW)aPosition.Row, nTab );
7728 return pDocSh->GetDocFunc().DetectiveAddPred( aPos );
7730 return false;
7733 sal_Bool SAL_CALL ScTableSheetObj::showErrors( const table::CellAddress& aPosition )
7734 throw(uno::RuntimeException, std::exception)
7736 SolarMutexGuard aGuard;
7737 ScDocShell* pDocSh = GetDocShell();
7738 if ( pDocSh )
7740 SCTAB nTab = GetTab_Impl();
7741 OSL_ENSURE( aPosition.Sheet == nTab, "falsche Tabelle in CellAddress" );
7742 ScAddress aPos( (SCCOL)aPosition.Column, (SCROW)aPosition.Row, nTab );
7743 return pDocSh->GetDocFunc().DetectiveAddError( aPos );
7745 return false;
7748 sal_Bool SAL_CALL ScTableSheetObj::showInvalid() throw(uno::RuntimeException, std::exception)
7750 SolarMutexGuard aGuard;
7751 ScDocShell* pDocSh = GetDocShell();
7752 if ( pDocSh )
7753 return pDocSh->GetDocFunc().DetectiveMarkInvalid( GetTab_Impl() );
7754 return false;
7757 void SAL_CALL ScTableSheetObj::clearArrows() throw(uno::RuntimeException, std::exception)
7759 SolarMutexGuard aGuard;
7760 ScDocShell* pDocSh = GetDocShell();
7761 if ( pDocSh )
7762 pDocSh->GetDocFunc().DetectiveDelAll( GetTab_Impl() );
7765 // XSheetOutline
7767 void SAL_CALL ScTableSheetObj::group( const table::CellRangeAddress& rGroupRange,
7768 table::TableOrientation nOrientation )
7769 throw (uno::RuntimeException,
7770 std::exception)
7772 SolarMutexGuard aGuard;
7773 ScDocShell* pDocSh = GetDocShell();
7774 if ( pDocSh )
7776 bool bColumns = ( nOrientation == table::TableOrientation_COLUMNS );
7777 ScRange aGroupRange;
7778 ScUnoConversion::FillScRange( aGroupRange, rGroupRange );
7779 ScOutlineDocFunc aFunc(*pDocSh);
7780 aFunc.MakeOutline( aGroupRange, bColumns, true, true );
7784 void SAL_CALL ScTableSheetObj::ungroup( const table::CellRangeAddress& rGroupRange,
7785 table::TableOrientation nOrientation )
7786 throw (uno::RuntimeException,
7787 std::exception)
7789 SolarMutexGuard aGuard;
7790 ScDocShell* pDocSh = GetDocShell();
7791 if ( pDocSh )
7793 bool bColumns = ( nOrientation == table::TableOrientation_COLUMNS );
7794 ScRange aGroupRange;
7795 ScUnoConversion::FillScRange( aGroupRange, rGroupRange );
7796 ScOutlineDocFunc aFunc(*pDocSh);
7797 aFunc.RemoveOutline( aGroupRange, bColumns, true, true );
7801 void SAL_CALL ScTableSheetObj::autoOutline( const table::CellRangeAddress& rCellRange )
7802 throw(uno::RuntimeException, std::exception)
7804 SolarMutexGuard aGuard;
7805 ScDocShell* pDocSh = GetDocShell();
7806 if ( pDocSh )
7808 ScRange aFormulaRange;
7809 ScUnoConversion::FillScRange( aFormulaRange, rCellRange );
7810 ScOutlineDocFunc aFunc(*pDocSh);
7811 aFunc.AutoOutline( aFormulaRange, true );
7815 void SAL_CALL ScTableSheetObj::clearOutline()
7816 throw(uno::RuntimeException, std::exception)
7818 SolarMutexGuard aGuard;
7819 ScDocShell* pDocSh = GetDocShell();
7820 if ( pDocSh )
7822 SCTAB nTab = GetTab_Impl();
7823 ScOutlineDocFunc aFunc(*pDocSh);
7824 aFunc.RemoveAllOutlines( nTab, true );
7828 void SAL_CALL ScTableSheetObj::hideDetail( const table::CellRangeAddress& rCellRange )
7829 throw(uno::RuntimeException, std::exception)
7831 SolarMutexGuard aGuard;
7832 ScDocShell* pDocSh = GetDocShell();
7833 if ( pDocSh )
7835 ScRange aMarkRange;
7836 ScUnoConversion::FillScRange( aMarkRange, rCellRange );
7837 ScOutlineDocFunc aFunc(*pDocSh);
7838 aFunc.HideMarkedOutlines( aMarkRange, true );
7842 void SAL_CALL ScTableSheetObj::showDetail( const table::CellRangeAddress& rCellRange )
7843 throw(uno::RuntimeException, std::exception)
7845 SolarMutexGuard aGuard;
7846 ScDocShell* pDocSh = GetDocShell();
7847 if ( pDocSh )
7849 ScRange aMarkRange;
7850 ScUnoConversion::FillScRange( aMarkRange, rCellRange );
7851 ScOutlineDocFunc aFunc(*pDocSh);
7852 aFunc.ShowMarkedOutlines( aMarkRange, true );
7856 void SAL_CALL ScTableSheetObj::showLevel( sal_Int16 nLevel, table::TableOrientation nOrientation )
7857 throw(uno::RuntimeException, std::exception)
7859 SolarMutexGuard aGuard;
7860 ScDocShell* pDocSh = GetDocShell();
7861 if ( pDocSh )
7863 bool bColumns = ( nOrientation == table::TableOrientation_COLUMNS );
7864 SCTAB nTab = GetTab_Impl();
7865 ScOutlineDocFunc aFunc(*pDocSh);
7866 aFunc.SelectLevel( nTab, bColumns, nLevel, true, true );
7870 // XProtectable
7872 void SAL_CALL ScTableSheetObj::protect( const OUString& aPassword )
7873 throw(uno::RuntimeException, std::exception)
7875 SolarMutexGuard aGuard;
7876 ScDocShell* pDocSh = GetDocShell();
7877 // #i108245# if already protected, don't change anything
7878 if ( pDocSh && !pDocSh->GetDocument()->IsTabProtected( GetTab_Impl() ) )
7880 OUString aString(aPassword);
7881 pDocSh->GetDocFunc().Protect( GetTab_Impl(), aString, true );
7885 void SAL_CALL ScTableSheetObj::unprotect( const OUString& aPassword )
7886 throw(lang::IllegalArgumentException, uno::RuntimeException, std::exception)
7888 SolarMutexGuard aGuard;
7889 ScDocShell* pDocSh = GetDocShell();
7890 if ( pDocSh )
7892 OUString aString(aPassword);
7893 bool bDone = pDocSh->GetDocFunc().Unprotect( GetTab_Impl(), aString, true );
7894 if (!bDone)
7895 throw lang::IllegalArgumentException();
7899 sal_Bool SAL_CALL ScTableSheetObj::isProtected() throw(uno::RuntimeException, std::exception)
7901 SolarMutexGuard aGuard;
7902 ScDocShell* pDocSh = GetDocShell();
7903 if ( pDocSh )
7904 return pDocSh->GetDocument()->IsTabProtected( GetTab_Impl() );
7906 OSL_FAIL("keine DocShell"); //! Exception oder so?
7907 return false;
7910 // XScenario
7912 sal_Bool SAL_CALL ScTableSheetObj::getIsScenario() throw(uno::RuntimeException, std::exception)
7914 SolarMutexGuard aGuard;
7915 ScDocShell* pDocSh = GetDocShell();
7916 if ( pDocSh )
7917 return pDocSh->GetDocument()->IsScenario( GetTab_Impl() );
7919 return false;
7922 OUString SAL_CALL ScTableSheetObj::getScenarioComment() throw(uno::RuntimeException, std::exception)
7924 SolarMutexGuard aGuard;
7925 ScDocShell* pDocSh = GetDocShell();
7926 if ( pDocSh )
7928 OUString aComment;
7929 Color aColor;
7930 sal_uInt16 nFlags;
7931 pDocSh->GetDocument()->GetScenarioData( GetTab_Impl(), aComment, aColor, nFlags );
7932 return aComment;
7934 return OUString();
7937 void SAL_CALL ScTableSheetObj::setScenarioComment( const OUString& aScenarioComment )
7938 throw(uno::RuntimeException, std::exception)
7940 SolarMutexGuard aGuard;
7941 ScDocShell* pDocSh = GetDocShell();
7942 if ( pDocSh )
7944 ScDocument* pDoc = pDocSh->GetDocument();
7945 SCTAB nTab = GetTab_Impl();
7947 OUString aName;
7948 OUString aComment;
7949 Color aColor;
7950 sal_uInt16 nFlags;
7951 pDoc->GetName( nTab, aName );
7952 pDoc->GetScenarioData( nTab, aComment, aColor, nFlags );
7954 aComment = aScenarioComment;
7956 pDocSh->ModifyScenario( nTab, aName, aComment, aColor, nFlags );
7960 void SAL_CALL ScTableSheetObj::addRanges( const uno::Sequence<table::CellRangeAddress>& rScenRanges )
7961 throw(uno::RuntimeException, std::exception)
7963 SolarMutexGuard aGuard;
7964 ScDocShell* pDocSh = GetDocShell();
7965 if ( pDocSh )
7967 ScDocument* pDoc = pDocSh->GetDocument();
7968 SCTAB nTab = GetTab_Impl();
7970 if (pDoc->IsScenario(nTab))
7972 ScMarkData aMarkData;
7973 aMarkData.SelectTable( nTab, true );
7975 sal_uInt16 nRangeCount = (sal_uInt16)rScenRanges.getLength();
7976 if (nRangeCount)
7978 const table::CellRangeAddress* pAry = rScenRanges.getConstArray();
7979 for (sal_uInt16 i=0; i<nRangeCount; i++)
7981 OSL_ENSURE( pAry[i].Sheet == nTab, "addRanges mit falscher Tab" );
7982 ScRange aOneRange( (SCCOL)pAry[i].StartColumn, (SCROW)pAry[i].StartRow, nTab,
7983 (SCCOL)pAry[i].EndColumn, (SCROW)pAry[i].EndRow, nTab );
7985 aMarkData.SetMultiMarkArea( aOneRange );
7989 // Szenario-Ranges sind durch Attribut gekennzeichnet
7990 ScPatternAttr aPattern( pDoc->GetPool() );
7991 aPattern.GetItemSet().Put( ScMergeFlagAttr( SC_MF_SCENARIO ) );
7992 aPattern.GetItemSet().Put( ScProtectionAttr( true ) );
7993 pDocSh->GetDocFunc().ApplyAttributes( aMarkData, aPattern, true, true );
7998 void SAL_CALL ScTableSheetObj::apply() throw(uno::RuntimeException, std::exception)
8000 SolarMutexGuard aGuard;
8001 ScDocShell* pDocSh = GetDocShell();
8002 if ( pDocSh )
8004 ScDocument* pDoc = pDocSh->GetDocument();
8005 SCTAB nTab = GetTab_Impl();
8006 OUString aName;
8007 pDoc->GetName( nTab, aName ); // Name dieses Szenarios
8009 SCTAB nDestTab = nTab;
8010 while ( nDestTab > 0 && pDoc->IsScenario(nDestTab) )
8011 --nDestTab;
8013 if ( !pDoc->IsScenario(nDestTab) )
8014 pDocSh->UseScenario( nDestTab, aName );
8016 //! sonst Fehler oder so
8020 // XScenarioEnhanced
8022 uno::Sequence< table::CellRangeAddress > SAL_CALL ScTableSheetObj::getRanges( )
8023 throw(uno::RuntimeException, std::exception)
8025 SolarMutexGuard aGuard;
8026 ScDocShell* pDocSh = GetDocShell();
8027 if ( pDocSh )
8029 ScDocument* pDoc = pDocSh->GetDocument();
8030 SCTAB nTab = GetTab_Impl();
8031 const ScRangeList* pRangeList = pDoc->GetScenarioRanges(nTab);
8032 if (pRangeList)
8034 size_t nCount = pRangeList->size();
8035 uno::Sequence< table::CellRangeAddress > aRetRanges( nCount );
8036 table::CellRangeAddress* pAry = aRetRanges.getArray();
8037 for( size_t nIndex = 0; nIndex < nCount; nIndex++ )
8039 const ScRange* pRange = (*pRangeList)[nIndex];
8040 pAry->StartColumn = pRange->aStart.Col();
8041 pAry->StartRow = pRange->aStart.Row();
8042 pAry->EndColumn = pRange->aEnd.Col();
8043 pAry->EndRow = pRange->aEnd.Row();
8044 pAry->Sheet = pRange->aStart.Tab();
8045 ++pAry;
8047 return aRetRanges;
8050 return uno::Sequence< table::CellRangeAddress > ();
8053 // XExternalSheetName
8055 void ScTableSheetObj::setExternalName( const OUString& aUrl, const OUString& aSheetName )
8056 throw (container::ElementExistException, uno::RuntimeException, std::exception)
8058 SolarMutexGuard aGuard;
8059 ScDocShell* pDocSh = GetDocShell();
8060 if ( pDocSh )
8062 ScDocument* pDoc = pDocSh->GetDocument();
8063 if ( pDoc )
8065 const SCTAB nTab = GetTab_Impl();
8066 const OUString aAbsDocName( ScGlobal::GetAbsDocName( aUrl, pDocSh ) );
8067 const OUString aDocTabName( ScGlobal::GetDocTabName( aAbsDocName, aSheetName ) );
8068 if ( !pDoc->RenameTab( nTab, aDocTabName, false /*bUpdateRef*/, true /*bExternalDocument*/ ) )
8070 throw container::ElementExistException( OUString(), *this );
8076 // XEventsSupplier
8078 uno::Reference<container::XNameReplace> SAL_CALL ScTableSheetObj::getEvents() throw (uno::RuntimeException, std::exception)
8080 SolarMutexGuard aGuard;
8081 ScDocShell* pDocSh = GetDocShell();
8082 if ( pDocSh )
8083 return new ScSheetEventsObj( pDocSh, GetTab_Impl() );
8085 return NULL;
8088 // XPropertySet erweitert fuer Sheet-Properties
8090 uno::Reference<beans::XPropertySetInfo> SAL_CALL ScTableSheetObj::getPropertySetInfo()
8091 throw(uno::RuntimeException, std::exception)
8093 SolarMutexGuard aGuard;
8094 static uno::Reference<beans::XPropertySetInfo> aRef(
8095 new SfxItemPropertySetInfo( pSheetPropSet->getPropertyMap() ));
8096 return aRef;
8099 void ScTableSheetObj::SetOnePropertyValue( const SfxItemPropertySimpleEntry* pEntry, const uno::Any& aValue )
8100 throw(lang::IllegalArgumentException, uno::RuntimeException,
8101 std::exception)
8103 if ( pEntry )
8105 if ( IsScItemWid( pEntry->nWID ) )
8107 // for Item WIDs, call ScCellRangesBase directly
8108 ScCellRangesBase::SetOnePropertyValue(pEntry, aValue);
8109 return;
8112 // own properties
8114 ScDocShell* pDocSh = GetDocShell();
8115 if (!pDocSh)
8116 return; //! Exception oder so?
8117 ScDocument* pDoc = pDocSh->GetDocument();
8118 SCTAB nTab = GetTab_Impl();
8119 ScDocFunc &rFunc = pDocSh->GetDocFunc();
8121 if ( pEntry->nWID == SC_WID_UNO_PAGESTL )
8123 OUString aStrVal;
8124 aValue >>= aStrVal;
8125 OUString aNewStr(ScStyleNameConversion::ProgrammaticToDisplayName(
8126 aStrVal, SFX_STYLE_FAMILY_PAGE ));
8128 //! Undo? (auch bei SID_STYLE_APPLY an der View)
8130 if ( pDoc->GetPageStyle( nTab ) != aNewStr )
8132 pDoc->SetPageStyle( nTab, aNewStr );
8133 if (!pDoc->IsImportingXML())
8135 ScPrintFunc( pDocSh, pDocSh->GetPrinter(), nTab ).UpdatePages();
8137 SfxBindings* pBindings = pDocSh->GetViewBindings();
8138 if (pBindings)
8140 pBindings->Invalidate( SID_STYLE_FAMILY4 );
8141 pBindings->Invalidate( SID_STATUS_PAGESTYLE );
8142 pBindings->Invalidate( FID_RESET_PRINTZOOM );
8143 pBindings->Invalidate( SID_ATTR_PARA_LEFT_TO_RIGHT );
8144 pBindings->Invalidate( SID_ATTR_PARA_RIGHT_TO_LEFT );
8147 pDocSh->SetDocumentModified();
8150 else if ( pEntry->nWID == SC_WID_UNO_CELLVIS )
8152 bool bVis = ScUnoHelpFunctions::GetBoolFromAny( aValue );
8153 rFunc.SetTableVisible( nTab, bVis, true );
8155 else if ( pEntry->nWID == SC_WID_UNO_ISACTIVE )
8157 if (pDoc->IsScenario(nTab))
8158 pDoc->SetActiveScenario( nTab, ScUnoHelpFunctions::GetBoolFromAny( aValue ) );
8160 else if ( pEntry->nWID == SC_WID_UNO_BORDCOL )
8162 if (pDoc->IsScenario(nTab))
8164 sal_Int32 nNewColor = 0;
8165 if (aValue >>= nNewColor)
8167 OUString aName;
8168 OUString aComment;
8169 Color aColor;
8170 sal_uInt16 nFlags;
8171 pDoc->GetName( nTab, aName );
8172 pDoc->GetScenarioData( nTab, aComment, aColor, nFlags );
8174 aColor = Color(static_cast<sal_uInt32>(nNewColor));
8176 pDocSh->ModifyScenario( nTab, aName, aComment, aColor, nFlags );
8180 else if ( pEntry->nWID == SC_WID_UNO_PROTECT )
8182 if (pDoc->IsScenario(nTab))
8184 OUString aName;
8185 OUString aComment;
8186 Color aColor;
8187 sal_uInt16 nFlags;
8188 pDoc->GetName( nTab, aName );
8189 pDoc->GetScenarioData( nTab, aComment, aColor, nFlags );
8190 bool bModify(false);
8192 if (ScUnoHelpFunctions::GetBoolFromAny( aValue ))
8194 if (!(nFlags & SC_SCENARIO_PROTECT))
8196 nFlags |= SC_SCENARIO_PROTECT;
8197 bModify = true;
8200 else
8202 if (nFlags & SC_SCENARIO_PROTECT)
8204 nFlags -= SC_SCENARIO_PROTECT;
8205 bModify = true;
8209 if (bModify)
8210 pDocSh->ModifyScenario( nTab, aName, aComment, aColor, nFlags );
8213 else if ( pEntry->nWID == SC_WID_UNO_SHOWBORD )
8215 if (pDoc->IsScenario(nTab))
8217 OUString aName;
8218 OUString aComment;
8219 Color aColor;
8220 sal_uInt16 nFlags;
8221 pDoc->GetName( nTab, aName );
8222 pDoc->GetScenarioData( nTab, aComment, aColor, nFlags );
8223 bool bModify(false);
8225 if (ScUnoHelpFunctions::GetBoolFromAny( aValue ))
8227 if (!(nFlags & SC_SCENARIO_SHOWFRAME))
8229 nFlags |= SC_SCENARIO_SHOWFRAME;
8230 bModify = true;
8233 else
8235 if (nFlags & SC_SCENARIO_SHOWFRAME)
8237 nFlags -= SC_SCENARIO_SHOWFRAME;
8238 bModify = true;
8242 if (bModify)
8243 pDocSh->ModifyScenario( nTab, aName, aComment, aColor, nFlags );
8246 else if ( pEntry->nWID == SC_WID_UNO_PRINTBORD )
8248 if (pDoc->IsScenario(nTab))
8250 OUString aName;
8251 OUString aComment;
8252 Color aColor;
8253 sal_uInt16 nFlags;
8254 pDoc->GetName( nTab, aName );
8255 pDoc->GetScenarioData( nTab, aComment, aColor, nFlags );
8256 bool bModify(false);
8258 if (ScUnoHelpFunctions::GetBoolFromAny( aValue ))
8260 if (!(nFlags & SC_SCENARIO_PRINTFRAME))
8262 nFlags |= SC_SCENARIO_PRINTFRAME;
8263 bModify = true;
8266 else
8268 if (nFlags & SC_SCENARIO_PRINTFRAME)
8270 nFlags -= SC_SCENARIO_PRINTFRAME;
8271 bModify = true;
8275 if (bModify)
8276 pDocSh->ModifyScenario( nTab, aName, aComment, aColor, nFlags );
8279 else if ( pEntry->nWID == SC_WID_UNO_COPYBACK )
8281 if (pDoc->IsScenario(nTab))
8283 OUString aName;
8284 OUString aComment;
8285 Color aColor;
8286 sal_uInt16 nFlags;
8287 pDoc->GetName( nTab, aName );
8288 pDoc->GetScenarioData( nTab, aComment, aColor, nFlags );
8289 bool bModify(false);
8291 if (ScUnoHelpFunctions::GetBoolFromAny( aValue ))
8293 if (!(nFlags & SC_SCENARIO_TWOWAY))
8295 nFlags |= SC_SCENARIO_TWOWAY;
8296 bModify = true;
8299 else
8301 if (nFlags & SC_SCENARIO_TWOWAY)
8303 nFlags -= SC_SCENARIO_TWOWAY;
8304 bModify = true;
8308 if (bModify)
8309 pDocSh->ModifyScenario( nTab, aName, aComment, aColor, nFlags );
8312 else if ( pEntry->nWID == SC_WID_UNO_COPYSTYL )
8314 if (pDoc->IsScenario(nTab))
8316 OUString aName;
8317 OUString aComment;
8318 Color aColor;
8319 sal_uInt16 nFlags;
8320 pDoc->GetName( nTab, aName );
8321 pDoc->GetScenarioData( nTab, aComment, aColor, nFlags );
8322 bool bModify(false);
8324 if (ScUnoHelpFunctions::GetBoolFromAny( aValue ))
8326 if (!(nFlags & SC_SCENARIO_ATTRIB))
8328 nFlags |= SC_SCENARIO_ATTRIB;
8329 bModify = true;
8332 else
8334 if (nFlags & SC_SCENARIO_ATTRIB)
8336 nFlags -= SC_SCENARIO_ATTRIB;
8337 bModify = true;
8341 if (bModify)
8342 pDocSh->ModifyScenario( nTab, aName, aComment, aColor, nFlags );
8345 else if ( pEntry->nWID == SC_WID_UNO_COPYFORM )
8347 if (pDoc->IsScenario(nTab))
8349 OUString aName;
8350 OUString aComment;
8351 Color aColor;
8352 sal_uInt16 nFlags;
8353 pDoc->GetName( nTab, aName );
8354 pDoc->GetScenarioData( nTab, aComment, aColor, nFlags );
8355 bool bModify(false);
8357 if (ScUnoHelpFunctions::GetBoolFromAny( aValue ))
8359 if (nFlags & SC_SCENARIO_VALUE)
8361 nFlags -= SC_SCENARIO_VALUE;
8362 bModify = true;
8365 else
8367 if (!(nFlags & SC_SCENARIO_VALUE))
8369 nFlags |= SC_SCENARIO_VALUE;
8370 bModify = true;
8374 if (bModify)
8375 pDocSh->ModifyScenario( nTab, aName, aComment, aColor, nFlags );
8378 else if ( pEntry->nWID == SC_WID_UNO_TABLAYOUT )
8380 sal_Int16 nValue = 0;
8381 if (aValue >>= nValue)
8383 if (nValue == com::sun::star::text::WritingMode2::RL_TB)
8384 rFunc.SetLayoutRTL(nTab, true, true);
8385 else
8386 rFunc.SetLayoutRTL(nTab, false, true);
8389 else if ( pEntry->nWID == SC_WID_UNO_AUTOPRINT )
8391 bool bAutoPrint = ScUnoHelpFunctions::GetBoolFromAny( aValue );
8392 if (bAutoPrint)
8393 pDoc->SetPrintEntireSheet( nTab ); // clears all print ranges
8394 else
8396 if (pDoc->IsPrintEntireSheet( nTab ))
8397 pDoc->ClearPrintRanges( nTab ); // if this flag is true, there are no PrintRanges, so Clear clears only the flag.
8400 else if ( pEntry->nWID == SC_WID_UNO_TABCOLOR )
8402 sal_Int32 nColor = COL_AUTO;
8403 if ( aValue >>= nColor )
8405 const Color aColor( static_cast< ColorData >( nColor ) );
8406 if ( pDoc->GetTabBgColor( nTab ) != aColor )
8407 rFunc.SetTabBgColor( nTab, aColor, true, true );
8410 else if ( pEntry->nWID == SC_WID_UNO_CODENAME )
8412 OUString aCodeName;
8413 if ( pDocSh && ( aValue >>= aCodeName ) )
8415 pDocSh->GetDocument()->SetCodeName( GetTab_Impl(), aCodeName );
8418 else
8419 ScCellRangeObj::SetOnePropertyValue(pEntry, aValue); // base class, no Item WID
8423 void ScTableSheetObj::GetOnePropertyValue( const SfxItemPropertySimpleEntry* pEntry,
8424 uno::Any& rAny )
8425 throw(uno::RuntimeException,
8426 std::exception)
8428 if ( pEntry )
8430 ScDocShell* pDocSh = GetDocShell();
8431 if (!pDocSh)
8432 throw uno::RuntimeException();
8433 ScDocument* pDoc = pDocSh->GetDocument();
8434 SCTAB nTab = GetTab_Impl();
8436 if ( pEntry->nWID == SC_WID_UNO_NAMES )
8438 rAny <<= uno::Reference<sheet::XNamedRanges>(new ScLocalNamedRangesObj(pDocSh, this));
8440 else if ( pEntry->nWID == SC_WID_UNO_PAGESTL )
8442 rAny <<= OUString( ScStyleNameConversion::DisplayToProgrammaticName(
8443 pDoc->GetPageStyle( nTab ), SFX_STYLE_FAMILY_PAGE ) );
8445 else if ( pEntry->nWID == SC_WID_UNO_CELLVIS )
8447 bool bVis = pDoc->IsVisible( nTab );
8448 ScUnoHelpFunctions::SetBoolInAny( rAny, bVis );
8450 else if ( pEntry->nWID == SC_WID_UNO_LINKDISPBIT )
8452 // no target bitmaps for individual entries (would be all equal)
8453 // ScLinkTargetTypeObj::SetLinkTargetBitmap( aAny, SC_LINKTARGETTYPE_SHEET );
8455 else if ( pEntry->nWID == SC_WID_UNO_LINKDISPNAME )
8457 // LinkDisplayName for hyperlink dialog
8458 rAny <<= getName(); // sheet name
8460 else if ( pEntry->nWID == SC_WID_UNO_ISACTIVE )
8462 if (pDoc->IsScenario(nTab))
8463 ScUnoHelpFunctions::SetBoolInAny( rAny, pDoc->IsActiveScenario( nTab ));
8465 else if ( pEntry->nWID == SC_WID_UNO_BORDCOL )
8467 if (pDoc->IsScenario(nTab))
8469 OUString aComment;
8470 Color aColor;
8471 sal_uInt16 nFlags;
8472 pDoc->GetScenarioData( nTab, aComment, aColor, nFlags );
8474 rAny <<= static_cast<sal_Int32>(aColor.GetColor());
8477 else if ( pEntry->nWID == SC_WID_UNO_PROTECT )
8479 if (pDoc->IsScenario(nTab))
8481 OUString aComment;
8482 Color aColor;
8483 sal_uInt16 nFlags;
8484 pDoc->GetScenarioData( nTab, aComment, aColor, nFlags );
8486 ScUnoHelpFunctions::SetBoolInAny( rAny, (nFlags & SC_SCENARIO_PROTECT) != 0 );
8489 else if ( pEntry->nWID == SC_WID_UNO_SHOWBORD )
8491 if (pDoc->IsScenario(nTab))
8493 OUString aComment;
8494 Color aColor;
8495 sal_uInt16 nFlags;
8496 pDoc->GetScenarioData( nTab, aComment, aColor, nFlags );
8498 ScUnoHelpFunctions::SetBoolInAny( rAny, (nFlags & SC_SCENARIO_SHOWFRAME) != 0 );
8501 else if ( pEntry->nWID == SC_WID_UNO_PRINTBORD )
8503 if (pDoc->IsScenario(nTab))
8505 OUString aComment;
8506 Color aColor;
8507 sal_uInt16 nFlags;
8508 pDoc->GetScenarioData( nTab, aComment, aColor, nFlags );
8510 ScUnoHelpFunctions::SetBoolInAny( rAny, (nFlags & SC_SCENARIO_PRINTFRAME) != 0 );
8513 else if ( pEntry->nWID == SC_WID_UNO_COPYBACK )
8515 if (pDoc->IsScenario(nTab))
8517 OUString aComment;
8518 Color aColor;
8519 sal_uInt16 nFlags;
8520 pDoc->GetScenarioData( nTab, aComment, aColor, nFlags );
8522 ScUnoHelpFunctions::SetBoolInAny( rAny, (nFlags & SC_SCENARIO_TWOWAY) != 0 );
8525 else if ( pEntry->nWID == SC_WID_UNO_COPYSTYL )
8527 if (pDoc->IsScenario(nTab))
8529 OUString aComment;
8530 Color aColor;
8531 sal_uInt16 nFlags;
8532 pDoc->GetScenarioData( nTab, aComment, aColor, nFlags );
8534 ScUnoHelpFunctions::SetBoolInAny( rAny, (nFlags & SC_SCENARIO_ATTRIB) != 0 );
8537 else if ( pEntry->nWID == SC_WID_UNO_COPYFORM )
8539 if (pDoc->IsScenario(nTab))
8541 OUString aComment;
8542 Color aColor;
8543 sal_uInt16 nFlags;
8544 pDoc->GetScenarioData( nTab, aComment, aColor, nFlags );
8546 ScUnoHelpFunctions::SetBoolInAny( rAny, !(nFlags & SC_SCENARIO_VALUE));
8549 else if ( pEntry->nWID == SC_WID_UNO_TABLAYOUT )
8551 if (pDoc->IsLayoutRTL(nTab))
8552 rAny <<= sal_Int16(com::sun::star::text::WritingMode2::RL_TB);
8553 else
8554 rAny <<= sal_Int16(com::sun::star::text::WritingMode2::LR_TB);
8556 else if ( pEntry->nWID == SC_WID_UNO_AUTOPRINT )
8558 bool bAutoPrint = pDoc->IsPrintEntireSheet( nTab );
8559 ScUnoHelpFunctions::SetBoolInAny( rAny, bAutoPrint );
8561 else if ( pEntry->nWID == SC_WID_UNO_TABCOLOR )
8563 rAny <<= sal_Int32(pDoc->GetTabBgColor(nTab).GetColor());
8565 else if ( pEntry->nWID == SC_WID_UNO_CODENAME )
8567 OUString aCodeName;
8568 if ( pDocSh )
8569 pDocSh->GetDocument()->GetCodeName( GetTab_Impl(), aCodeName );
8570 rAny <<= OUString( aCodeName );
8572 else
8573 ScCellRangeObj::GetOnePropertyValue(pEntry, rAny);
8577 const SfxItemPropertyMap& ScTableSheetObj::GetItemPropertyMap()
8579 return pSheetPropSet->getPropertyMap();
8582 // XServiceInfo
8584 OUString SAL_CALL ScTableSheetObj::getImplementationName() throw(uno::RuntimeException, std::exception)
8586 return OUString( "ScTableSheetObj" );
8589 sal_Bool SAL_CALL ScTableSheetObj::supportsService( const OUString& rServiceName )
8590 throw(uno::RuntimeException, std::exception)
8592 return cppu::supportsService(this, rServiceName);
8595 uno::Sequence<OUString> SAL_CALL ScTableSheetObj::getSupportedServiceNames()
8596 throw(uno::RuntimeException, std::exception)
8598 uno::Sequence<OUString> aRet(7);
8599 OUString* pArray = aRet.getArray();
8600 pArray[0] = OUString( SCSPREADSHEET_SERVICE );
8601 pArray[1] = OUString( SCSHEETCELLRANGE_SERVICE );
8602 pArray[2] = OUString( SCCELLRANGE_SERVICE );
8603 pArray[3] = OUString( SCCELLPROPERTIES_SERVICE );
8604 pArray[4] = OUString( SCCHARPROPERTIES_SERVICE );
8605 pArray[5] = OUString( SCPARAPROPERTIES_SERVICE );
8606 pArray[6] = OUString( SCLINKTARGET_SERVICE );
8607 return aRet;
8610 // XUnoTunnel
8612 sal_Int64 SAL_CALL ScTableSheetObj::getSomething(
8613 const uno::Sequence<sal_Int8 >& rId ) throw(uno::RuntimeException, std::exception)
8615 if ( rId.getLength() == 16 &&
8616 0 == memcmp( getUnoTunnelId().getConstArray(),
8617 rId.getConstArray(), 16 ) )
8619 return sal::static_int_cast<sal_Int64>(reinterpret_cast<sal_IntPtr>(this));
8622 return ScCellRangeObj::getSomething( rId );
8625 namespace
8627 class theScTableSheetObjUnoTunnelId : public rtl::Static< UnoTunnelIdInit, theScTableSheetObjUnoTunnelId> {};
8630 const uno::Sequence<sal_Int8>& ScTableSheetObj::getUnoTunnelId()
8632 return theScTableSheetObjUnoTunnelId::get().getSeq();
8635 ScTableSheetObj* ScTableSheetObj::getImplementation( const uno::Reference<uno::XInterface> xObj )
8637 ScTableSheetObj* pRet = NULL;
8638 uno::Reference<lang::XUnoTunnel> xUT( xObj, uno::UNO_QUERY );
8639 if (xUT.is())
8640 pRet = reinterpret_cast<ScTableSheetObj*>(sal::static_int_cast<sal_IntPtr>(xUT->getSomething(getUnoTunnelId())));
8641 return pRet;
8644 ScTableColumnObj::ScTableColumnObj( ScDocShell* pDocSh, SCCOL nCol, SCTAB nTab ) :
8645 ScCellRangeObj( pDocSh, ScRange(nCol,0,nTab, nCol,MAXROW,nTab) ),
8646 pColPropSet(lcl_GetColumnPropertySet())
8650 ScTableColumnObj::~ScTableColumnObj()
8654 uno::Any SAL_CALL ScTableColumnObj::queryInterface( const uno::Type& rType ) throw(uno::RuntimeException, std::exception)
8656 SC_QUERYINTERFACE( container::XNamed )
8658 return ScCellRangeObj::queryInterface( rType );
8661 void SAL_CALL ScTableColumnObj::acquire() throw()
8663 ScCellRangeObj::acquire();
8666 void SAL_CALL ScTableColumnObj::release() throw()
8668 ScCellRangeObj::release();
8671 uno::Sequence<uno::Type> SAL_CALL ScTableColumnObj::getTypes() throw(uno::RuntimeException, std::exception)
8673 static uno::Sequence<uno::Type> aTypes;
8674 if ( aTypes.getLength() == 0 )
8676 uno::Sequence<uno::Type> aParentTypes(ScCellRangeObj::getTypes());
8677 long nParentLen = aParentTypes.getLength();
8678 const uno::Type* pParentPtr = aParentTypes.getConstArray();
8680 aTypes.realloc( nParentLen + 1 );
8681 uno::Type* pPtr = aTypes.getArray();
8682 pPtr[nParentLen + 0] = cppu::UnoType<container::XNamed>::get();
8684 for (long i=0; i<nParentLen; i++)
8685 pPtr[i] = pParentPtr[i]; // parent types first
8687 return aTypes;
8690 uno::Sequence<sal_Int8> SAL_CALL ScTableColumnObj::getImplementationId() throw(uno::RuntimeException, std::exception)
8692 return css::uno::Sequence<sal_Int8>();
8695 // XNamed
8697 OUString SAL_CALL ScTableColumnObj::getName() throw(uno::RuntimeException, std::exception)
8699 SolarMutexGuard aGuard;
8701 const ScRange& rRange = GetRange();
8702 OSL_ENSURE(rRange.aStart.Col() == rRange.aEnd.Col(), "too many columns");
8703 SCCOL nCol = rRange.aStart.Col();
8705 return ScColToAlpha( nCol ); // from global.hxx
8708 void SAL_CALL ScTableColumnObj::setName( const OUString& /* aNewName */ )
8709 throw(uno::RuntimeException, std::exception)
8711 SolarMutexGuard aGuard;
8712 throw uno::RuntimeException(); // read-only
8715 // XPropertySet erweitert fuer Spalten-Properties
8717 uno::Reference<beans::XPropertySetInfo> SAL_CALL ScTableColumnObj::getPropertySetInfo()
8718 throw(uno::RuntimeException, std::exception)
8720 SolarMutexGuard aGuard;
8721 static uno::Reference<beans::XPropertySetInfo> aRef(
8722 new SfxItemPropertySetInfo( pColPropSet->getPropertyMap() ));
8723 return aRef;
8726 void ScTableColumnObj::SetOnePropertyValue(const SfxItemPropertySimpleEntry* pEntry, const uno::Any& aValue)
8727 throw(lang::IllegalArgumentException, uno::RuntimeException,
8728 std::exception)
8730 if ( pEntry )
8732 if ( IsScItemWid( pEntry->nWID ) )
8734 // for Item WIDs, call ScCellRangesBase directly
8735 ScCellRangesBase::SetOnePropertyValue(pEntry, aValue);
8736 return;
8739 // own properties
8741 ScDocShell* pDocSh = GetDocShell();
8742 if (!pDocSh)
8743 return; //! Exception oder so?
8744 const ScRange& rRange = GetRange();
8745 OSL_ENSURE(rRange.aStart.Col() == rRange.aEnd.Col(), "zuviele Spalten");
8746 SCCOL nCol = rRange.aStart.Col();
8747 SCTAB nTab = rRange.aStart.Tab();
8748 ScDocFunc &rFunc = pDocSh->GetDocFunc();
8750 std::vector<sc::ColRowSpan> aColArr(1, sc::ColRowSpan(nCol,nCol));
8752 if ( pEntry->nWID == SC_WID_UNO_CELLWID )
8754 sal_Int32 nNewWidth = 0;
8755 if ( aValue >>= nNewWidth )
8757 // property is 1/100mm, column width is twips
8758 nNewWidth = HMMToTwips(nNewWidth);
8759 rFunc.SetWidthOrHeight(
8760 true, aColArr, nTab, SC_SIZE_ORIGINAL, (sal_uInt16)nNewWidth, true, true);
8763 else if ( pEntry->nWID == SC_WID_UNO_CELLVIS )
8765 bool bVis = ScUnoHelpFunctions::GetBoolFromAny( aValue );
8766 ScSizeMode eMode = bVis ? SC_SIZE_SHOW : SC_SIZE_DIRECT;
8767 rFunc.SetWidthOrHeight(true, aColArr, nTab, eMode, 0, true, true);
8768 // SC_SIZE_DIRECT mit Groesse 0 blendet aus
8770 else if ( pEntry->nWID == SC_WID_UNO_OWIDTH )
8772 bool bOpt = ScUnoHelpFunctions::GetBoolFromAny( aValue );
8773 if (bOpt)
8774 rFunc.SetWidthOrHeight(
8775 true, aColArr, nTab, SC_SIZE_OPTIMAL, STD_EXTRA_WIDTH, true, true);
8776 // sal_False bei Spalten momentan ohne Auswirkung
8778 else if ( pEntry->nWID == SC_WID_UNO_NEWPAGE || pEntry->nWID == SC_WID_UNO_MANPAGE )
8780 bool bSet = ScUnoHelpFunctions::GetBoolFromAny( aValue );
8781 if (bSet)
8782 rFunc.InsertPageBreak( true, rRange.aStart, true, true, true );
8783 else
8784 rFunc.RemovePageBreak( true, rRange.aStart, true, true, true );
8786 else
8787 ScCellRangeObj::SetOnePropertyValue(pEntry, aValue); // base class, no Item WID
8791 void ScTableColumnObj::GetOnePropertyValue( const SfxItemPropertySimpleEntry* pEntry, uno::Any& rAny )
8792 throw(uno::RuntimeException, std::exception)
8794 if ( pEntry )
8796 ScDocShell* pDocSh = GetDocShell();
8797 if (!pDocSh)
8798 throw uno::RuntimeException();
8800 ScDocument* pDoc = pDocSh->GetDocument();
8801 const ScRange& rRange = GetRange();
8802 OSL_ENSURE(rRange.aStart.Col() == rRange.aEnd.Col(), "zuviele Spalten");
8803 SCCOL nCol = rRange.aStart.Col();
8804 SCTAB nTab = rRange.aStart.Tab();
8806 if ( pEntry->nWID == SC_WID_UNO_CELLWID )
8808 // for hidden column, return original height
8809 sal_uInt16 nWidth = pDoc->GetOriginalWidth( nCol, nTab );
8810 // property is 1/100mm, column width is twips
8811 nWidth = (sal_uInt16) TwipsToHMM(nWidth);
8812 rAny <<= (sal_Int32)( nWidth );
8814 else if ( pEntry->nWID == SC_WID_UNO_CELLVIS )
8816 bool bHidden = pDoc->ColHidden(nCol, nTab);
8817 ScUnoHelpFunctions::SetBoolInAny( rAny, !bHidden );
8819 else if ( pEntry->nWID == SC_WID_UNO_OWIDTH )
8821 //! momentan immer gesetzt ??!?!
8822 bool bOpt = !(pDoc->GetColFlags( nCol, nTab ) & CR_MANUALSIZE);
8823 ScUnoHelpFunctions::SetBoolInAny( rAny, bOpt );
8825 else if ( pEntry->nWID == SC_WID_UNO_NEWPAGE )
8827 ScBreakType nBreak = pDoc->HasColBreak(nCol, nTab);
8828 ScUnoHelpFunctions::SetBoolInAny( rAny, nBreak );
8830 else if ( pEntry->nWID == SC_WID_UNO_MANPAGE )
8832 ScBreakType nBreak = pDoc->HasColBreak(nCol, nTab);
8833 ScUnoHelpFunctions::SetBoolInAny(rAny, (nBreak & BREAK_MANUAL) != 0);
8835 else
8836 ScCellRangeObj::GetOnePropertyValue(pEntry, rAny);
8840 const SfxItemPropertyMap& ScTableColumnObj::GetItemPropertyMap()
8842 return pColPropSet->getPropertyMap();
8845 ScTableRowObj::ScTableRowObj(ScDocShell* pDocSh, SCROW nRow, SCTAB nTab) :
8846 ScCellRangeObj( pDocSh, ScRange(0,nRow,nTab, MAXCOL,nRow,nTab) ),
8847 pRowPropSet(lcl_GetRowPropertySet())
8851 ScTableRowObj::~ScTableRowObj()
8855 // XPropertySet erweitert fuer Zeilen-Properties
8857 uno::Reference<beans::XPropertySetInfo> SAL_CALL ScTableRowObj::getPropertySetInfo()
8858 throw(uno::RuntimeException, std::exception)
8860 SolarMutexGuard aGuard;
8861 static uno::Reference<beans::XPropertySetInfo> aRef(
8862 new SfxItemPropertySetInfo( pRowPropSet->getPropertyMap() ));
8863 return aRef;
8866 void ScTableRowObj::SetOnePropertyValue( const SfxItemPropertySimpleEntry* pEntry, const uno::Any& aValue )
8867 throw(lang::IllegalArgumentException, uno::RuntimeException, std::exception)
8869 if ( pEntry )
8871 if ( IsScItemWid( pEntry->nWID ) )
8873 // for Item WIDs, call ScCellRangesBase directly
8874 ScCellRangesBase::SetOnePropertyValue(pEntry, aValue);
8875 return;
8878 // own properties
8880 ScDocShell* pDocSh = GetDocShell();
8881 if (!pDocSh)
8882 return; //! Exception oder so?
8883 ScDocument* pDoc = pDocSh->GetDocument();
8884 const ScRange& rRange = GetRange();
8885 OSL_ENSURE(rRange.aStart.Row() == rRange.aEnd.Row(), "zuviele Zeilen");
8886 SCROW nRow = rRange.aStart.Row();
8887 SCTAB nTab = rRange.aStart.Tab();
8888 ScDocFunc &rFunc = pDocSh->GetDocFunc();
8890 std::vector<sc::ColRowSpan> aRowArr(1, sc::ColRowSpan(nRow,nRow));
8892 if ( pEntry->nWID == SC_WID_UNO_CELLHGT )
8894 sal_Int32 nNewHeight = 0;
8895 if ( aValue >>= nNewHeight )
8897 // property is 1/100mm, row height is twips
8898 nNewHeight = HMMToTwips(nNewHeight);
8899 rFunc.SetWidthOrHeight(
8900 false, aRowArr, nTab, SC_SIZE_ORIGINAL, (sal_uInt16)nNewHeight, true, true);
8903 else if ( pEntry->nWID == SC_WID_UNO_CELLVIS )
8905 bool bVis = ScUnoHelpFunctions::GetBoolFromAny( aValue );
8906 ScSizeMode eMode = bVis ? SC_SIZE_SHOW : SC_SIZE_DIRECT;
8907 rFunc.SetWidthOrHeight(false, aRowArr, nTab, eMode, 0, true, true);
8908 // SC_SIZE_DIRECT mit Groesse 0 blendet aus
8910 else if ( pEntry->nWID == SC_WID_UNO_CELLFILT )
8912 bool bFil = ScUnoHelpFunctions::GetBoolFromAny( aValue );
8913 // SC_SIZE_DIRECT mit Groesse 0 blendet aus
8914 pDoc->SetRowFiltered(nRow, nRow, nTab, bFil);
8916 else if ( pEntry->nWID == SC_WID_UNO_OHEIGHT )
8918 bool bOpt = ScUnoHelpFunctions::GetBoolFromAny( aValue );
8919 if (bOpt)
8920 rFunc.SetWidthOrHeight(false, aRowArr, nTab, SC_SIZE_OPTIMAL, 0, true, true);
8921 else
8923 // set current height again manually
8924 sal_uInt16 nHeight = pDoc->GetOriginalHeight( nRow, nTab );
8925 rFunc.SetWidthOrHeight(false, aRowArr, nTab, SC_SIZE_ORIGINAL, nHeight, true, true);
8928 else if ( pEntry->nWID == SC_WID_UNO_NEWPAGE || pEntry->nWID == SC_WID_UNO_MANPAGE )
8930 bool bSet = ScUnoHelpFunctions::GetBoolFromAny( aValue );
8931 if (bSet)
8932 rFunc.InsertPageBreak( false, rRange.aStart, true, true, true );
8933 else
8934 rFunc.RemovePageBreak( false, rRange.aStart, true, true, true );
8936 else
8937 ScCellRangeObj::SetOnePropertyValue(pEntry, aValue); // base class, no Item WID
8941 void ScTableRowObj::GetOnePropertyValue( const SfxItemPropertySimpleEntry* pEntry, uno::Any& rAny )
8942 throw(uno::RuntimeException, std::exception)
8944 if ( pEntry )
8946 ScDocShell* pDocSh = GetDocShell();
8947 if (!pDocSh)
8948 throw uno::RuntimeException();
8949 ScDocument* pDoc = pDocSh->GetDocument();
8950 const ScRange& rRange = GetRange();
8951 OSL_ENSURE(rRange.aStart.Row() == rRange.aEnd.Row(), "zuviele Zeilen");
8952 SCROW nRow = rRange.aStart.Row();
8953 SCTAB nTab = rRange.aStart.Tab();
8955 if ( pEntry->nWID == SC_WID_UNO_CELLHGT )
8957 // for hidden row, return original height
8958 sal_uInt16 nHeight = pDoc->GetOriginalHeight( nRow, nTab );
8959 // property is 1/100mm, row height is twips
8960 nHeight = (sal_uInt16) TwipsToHMM(nHeight);
8961 rAny <<= (sal_Int32)( nHeight );
8963 else if ( pEntry->nWID == SC_WID_UNO_CELLVIS )
8965 bool bHidden = pDoc->RowHidden(nRow, nTab);
8966 ScUnoHelpFunctions::SetBoolInAny( rAny, !bHidden );
8968 else if ( pEntry->nWID == SC_WID_UNO_CELLFILT )
8970 bool bVis = pDoc->RowFiltered(nRow, nTab);
8971 ScUnoHelpFunctions::SetBoolInAny( rAny, bVis );
8973 else if ( pEntry->nWID == SC_WID_UNO_OHEIGHT )
8975 bool bOpt = !(pDoc->GetRowFlags( nRow, nTab ) & CR_MANUALSIZE);
8976 ScUnoHelpFunctions::SetBoolInAny( rAny, bOpt );
8978 else if ( pEntry->nWID == SC_WID_UNO_NEWPAGE )
8980 ScBreakType nBreak = pDoc->HasRowBreak(nRow, nTab);
8981 ScUnoHelpFunctions::SetBoolInAny( rAny, nBreak );
8983 else if ( pEntry->nWID == SC_WID_UNO_MANPAGE )
8985 ScBreakType nBreak = (pDoc->HasRowBreak(nRow, nTab) & BREAK_MANUAL);
8986 ScUnoHelpFunctions::SetBoolInAny( rAny, nBreak );
8988 else
8989 ScCellRangeObj::GetOnePropertyValue(pEntry, rAny);
8993 const SfxItemPropertyMap& ScTableRowObj::GetItemPropertyMap()
8995 return pRowPropSet->getPropertyMap();
8998 ScCellsObj::ScCellsObj(ScDocShell* pDocSh, const ScRangeList& rR) :
8999 pDocShell( pDocSh ),
9000 aRanges( rR )
9002 pDocShell->GetDocument()->AddUnoObject(*this);
9005 ScCellsObj::~ScCellsObj()
9007 if (pDocShell)
9008 pDocShell->GetDocument()->RemoveUnoObject(*this);
9011 void ScCellsObj::Notify( SfxBroadcaster&, const SfxHint& rHint )
9013 if ( rHint.ISA( ScUpdateRefHint ) )
9015 const ScUpdateRefHint& rRef = (const ScUpdateRefHint&)rHint;
9016 aRanges.UpdateReference( rRef.GetMode(), pDocShell->GetDocument(), rRef.GetRange(),
9017 rRef.GetDx(), rRef.GetDy(), rRef.GetDz() );
9019 else if ( rHint.ISA( SfxSimpleHint ) &&
9020 ((const SfxSimpleHint&)rHint).GetId() == SFX_HINT_DYING )
9022 pDocShell = NULL; // ungueltig geworden
9026 // XEnumerationAccess
9028 uno::Reference<container::XEnumeration> SAL_CALL ScCellsObj::createEnumeration()
9029 throw(uno::RuntimeException, std::exception)
9031 SolarMutexGuard aGuard;
9032 if (pDocShell)
9033 return new ScCellsEnumeration( pDocShell, aRanges );
9034 return NULL;
9037 uno::Type SAL_CALL ScCellsObj::getElementType() throw(uno::RuntimeException, std::exception)
9039 SolarMutexGuard aGuard;
9040 return cppu::UnoType<table::XCell>::get();
9043 sal_Bool SAL_CALL ScCellsObj::hasElements() throw(uno::RuntimeException, std::exception)
9045 SolarMutexGuard aGuard;
9046 bool bHas = false;
9047 if ( pDocShell )
9049 //! schneller selber testen?
9051 uno::Reference<container::XEnumeration> xEnum(new ScCellsEnumeration( pDocShell, aRanges ));
9052 bHas = xEnum->hasMoreElements();
9054 return bHas;
9057 ScCellsEnumeration::ScCellsEnumeration(ScDocShell* pDocSh, const ScRangeList& rR) :
9058 pDocShell( pDocSh ),
9059 aRanges( rR ),
9060 pMark( NULL ),
9061 bAtEnd( false )
9063 ScDocument* pDoc = pDocShell->GetDocument();
9064 pDoc->AddUnoObject(*this);
9066 if ( aRanges.empty() )
9067 bAtEnd = true;
9068 else
9070 SCTAB nTab = 0;
9071 const ScRange* pFirst = aRanges[ 0 ];
9072 if (pFirst)
9073 nTab = pFirst->aStart.Tab();
9074 aPos = ScAddress(0,0,nTab);
9075 CheckPos_Impl(); // aPos auf erste passende Zelle setzen
9079 void ScCellsEnumeration::CheckPos_Impl()
9081 if (!pDocShell)
9082 return;
9084 bool bFound = false;
9085 ScDocument* pDoc = pDocShell->GetDocument();
9086 ScRefCellValue aCell;
9087 aCell.assign(*pDoc, aPos);
9088 if (!aCell.isEmpty())
9090 if (!pMark)
9092 pMark = new ScMarkData;
9093 pMark->MarkFromRangeList(aRanges, false);
9094 pMark->MarkToMulti(); // needed for GetNextMarkedCell
9096 bFound = pMark->IsCellMarked(aPos.Col(), aPos.Row());
9098 if (!bFound)
9099 Advance_Impl();
9102 ScCellsEnumeration::~ScCellsEnumeration()
9104 if (pDocShell)
9105 pDocShell->GetDocument()->RemoveUnoObject(*this);
9106 delete pMark;
9109 void ScCellsEnumeration::Advance_Impl()
9111 OSL_ENSURE(!bAtEnd,"zuviel Advance_Impl");
9112 if (!pMark)
9114 pMark = new ScMarkData;
9115 pMark->MarkFromRangeList( aRanges, false );
9116 pMark->MarkToMulti(); // needed for GetNextMarkedCell
9119 SCCOL nCol = aPos.Col();
9120 SCROW nRow = aPos.Row();
9121 SCTAB nTab = aPos.Tab();
9122 bool bFound = pDocShell->GetDocument()->GetNextMarkedCell( nCol, nRow, nTab, *pMark );
9123 if (bFound)
9124 aPos.Set( nCol, nRow, nTab );
9125 else
9126 bAtEnd = true; // kommt nix mehr
9129 void ScCellsEnumeration::Notify( SfxBroadcaster&, const SfxHint& rHint )
9131 if ( rHint.ISA( ScUpdateRefHint ) )
9133 if (pDocShell)
9135 const ScUpdateRefHint& rRef = (const ScUpdateRefHint&)rHint;
9136 aRanges.UpdateReference( rRef.GetMode(), pDocShell->GetDocument(), rRef.GetRange(),
9137 rRef.GetDx(), rRef.GetDy(), rRef.GetDz() );
9139 delete pMark; // aus verschobenen Bereichen neu erzeugen
9140 pMark = NULL;
9142 if (!bAtEnd) // aPos anpassen
9144 ScRangeList aNew;
9145 aNew.Append(ScRange(aPos));
9146 aNew.UpdateReference( rRef.GetMode(), pDocShell->GetDocument(), rRef.GetRange(),
9147 rRef.GetDx(), rRef.GetDy(), rRef.GetDz() );
9148 if (aNew.size()==1)
9150 aPos = aNew[ 0 ]->aStart;
9151 CheckPos_Impl();
9156 else if ( rHint.ISA( SfxSimpleHint ) &&
9157 ((const SfxSimpleHint&)rHint).GetId() == SFX_HINT_DYING )
9159 pDocShell = NULL; // ungueltig geworden
9163 // XEnumeration
9165 sal_Bool SAL_CALL ScCellsEnumeration::hasMoreElements() throw(uno::RuntimeException, std::exception)
9167 SolarMutexGuard aGuard;
9168 return !bAtEnd;
9171 uno::Any SAL_CALL ScCellsEnumeration::nextElement() throw(container::NoSuchElementException,
9172 lang::WrappedTargetException, uno::RuntimeException, std::exception)
9174 SolarMutexGuard aGuard;
9175 if (pDocShell && !bAtEnd)
9177 // Interface-Typ muss zu ScCellsObj::getElementType passen
9179 ScAddress aTempPos(aPos);
9180 Advance_Impl();
9181 return uno::makeAny(uno::Reference<table::XCell>(new ScCellObj( pDocShell, aTempPos )));
9184 throw container::NoSuchElementException(); // no more elements
9187 ScCellFormatsObj::ScCellFormatsObj(ScDocShell* pDocSh, const ScRange& rRange) :
9188 pDocShell( pDocSh ),
9189 aTotalRange( rRange )
9191 ScDocument* pDoc = pDocShell->GetDocument();
9192 pDoc->AddUnoObject(*this);
9194 OSL_ENSURE( aTotalRange.aStart.Tab() == aTotalRange.aEnd.Tab(), "unterschiedliche Tabellen" );
9197 ScCellFormatsObj::~ScCellFormatsObj()
9199 if (pDocShell)
9200 pDocShell->GetDocument()->RemoveUnoObject(*this);
9203 void ScCellFormatsObj::Notify( SfxBroadcaster&, const SfxHint& rHint )
9205 if ( rHint.ISA( ScUpdateRefHint ) )
9207 //! aTotalRange...
9209 else if ( rHint.ISA( SfxSimpleHint ) &&
9210 ((const SfxSimpleHint&)rHint).GetId() == SFX_HINT_DYING )
9212 pDocShell = NULL; // ungueltig geworden
9216 ScCellRangeObj* ScCellFormatsObj::GetObjectByIndex_Impl(long nIndex) const
9218 //! direkt auf die AttrArrays zugreifen !!!!
9220 ScCellRangeObj* pRet = NULL;
9221 if (pDocShell)
9223 ScDocument* pDoc = pDocShell->GetDocument();
9224 long nPos = 0;
9225 ScAttrRectIterator aIter( pDoc, aTotalRange.aStart.Tab(),
9226 aTotalRange.aStart.Col(), aTotalRange.aStart.Row(),
9227 aTotalRange.aEnd.Col(), aTotalRange.aEnd.Row() );
9228 SCCOL nCol1, nCol2;
9229 SCROW nRow1, nRow2;
9230 while ( aIter.GetNext( nCol1, nCol2, nRow1, nRow2 ) )
9232 if ( nPos == nIndex )
9234 SCTAB nTab = aTotalRange.aStart.Tab();
9235 ScRange aNext( nCol1, nRow1, nTab, nCol2, nRow2, nTab );
9237 if ( aNext.aStart == aNext.aEnd )
9238 pRet = new ScCellObj( pDocShell, aNext.aStart );
9239 else
9240 pRet = new ScCellRangeObj( pDocShell, aNext );
9242 ++nPos;
9245 return pRet;
9248 // XIndexAccess
9250 sal_Int32 SAL_CALL ScCellFormatsObj::getCount() throw(uno::RuntimeException, std::exception)
9252 SolarMutexGuard aGuard;
9254 //! direkt auf die AttrArrays zugreifen !!!!
9256 long nCount = 0;
9257 if (pDocShell)
9259 ScDocument* pDoc = pDocShell->GetDocument();
9260 ScAttrRectIterator aIter( pDoc, aTotalRange.aStart.Tab(),
9261 aTotalRange.aStart.Col(), aTotalRange.aStart.Row(),
9262 aTotalRange.aEnd.Col(), aTotalRange.aEnd.Row() );
9263 SCCOL nCol1, nCol2;
9264 SCROW nRow1, nRow2;
9265 while ( aIter.GetNext( nCol1, nCol2, nRow1, nRow2 ) )
9266 ++nCount;
9268 return nCount;
9271 uno::Any SAL_CALL ScCellFormatsObj::getByIndex( sal_Int32 nIndex )
9272 throw(lang::IndexOutOfBoundsException,
9273 lang::WrappedTargetException, uno::RuntimeException, std::exception)
9275 SolarMutexGuard aGuard;
9277 uno::Reference<table::XCellRange> xRange(GetObjectByIndex_Impl(nIndex));
9278 if (xRange.is())
9279 return uno::makeAny(xRange);
9280 else
9281 throw lang::IndexOutOfBoundsException();
9284 uno::Type SAL_CALL ScCellFormatsObj::getElementType() throw(uno::RuntimeException, std::exception)
9286 SolarMutexGuard aGuard;
9287 return cppu::UnoType<table::XCellRange>::get();
9290 sal_Bool SAL_CALL ScCellFormatsObj::hasElements() throw(uno::RuntimeException, std::exception)
9292 SolarMutexGuard aGuard;
9293 return ( getCount() != 0 ); //! immer groesser 0 ??
9296 // XEnumerationAccess
9298 uno::Reference<container::XEnumeration> SAL_CALL ScCellFormatsObj::createEnumeration()
9299 throw(uno::RuntimeException, std::exception)
9301 SolarMutexGuard aGuard;
9302 if (pDocShell)
9303 return new ScCellFormatsEnumeration( pDocShell, aTotalRange );
9304 return NULL;
9307 ScCellFormatsEnumeration::ScCellFormatsEnumeration(ScDocShell* pDocSh, const ScRange& rRange) :
9308 pDocShell( pDocSh ),
9309 nTab( rRange.aStart.Tab() ),
9310 pIter( NULL ),
9311 bAtEnd( false ),
9312 bDirty( false )
9314 ScDocument* pDoc = pDocShell->GetDocument();
9315 pDoc->AddUnoObject(*this);
9317 OSL_ENSURE( rRange.aStart.Tab() == rRange.aEnd.Tab(),
9318 "CellFormatsEnumeration: unterschiedliche Tabellen" );
9320 pIter = new ScAttrRectIterator( pDoc, nTab,
9321 rRange.aStart.Col(), rRange.aStart.Row(),
9322 rRange.aEnd.Col(), rRange.aEnd.Row() );
9323 Advance_Impl();
9326 ScCellFormatsEnumeration::~ScCellFormatsEnumeration()
9328 if (pDocShell)
9329 pDocShell->GetDocument()->RemoveUnoObject(*this);
9330 delete pIter;
9333 void ScCellFormatsEnumeration::Advance_Impl()
9335 OSL_ENSURE(!bAtEnd,"zuviel Advance_Impl");
9337 if ( pIter )
9339 if ( bDirty )
9341 pIter->DataChanged(); // AttrArray-Index neu suchen
9342 bDirty = false;
9345 SCCOL nCol1, nCol2;
9346 SCROW nRow1, nRow2;
9347 if ( pIter->GetNext( nCol1, nCol2, nRow1, nRow2 ) )
9348 aNext = ScRange( nCol1, nRow1, nTab, nCol2, nRow2, nTab );
9349 else
9350 bAtEnd = true; // kommt nix mehr
9352 else
9353 bAtEnd = true; // Dok weggekommen oder so
9356 ScCellRangeObj* ScCellFormatsEnumeration::NextObject_Impl()
9358 ScCellRangeObj* pRet = NULL;
9359 if (pDocShell && !bAtEnd)
9361 if ( aNext.aStart == aNext.aEnd )
9362 pRet = new ScCellObj( pDocShell, aNext.aStart );
9363 else
9364 pRet = new ScCellRangeObj( pDocShell, aNext );
9365 Advance_Impl();
9367 return pRet;
9370 void ScCellFormatsEnumeration::Notify( SfxBroadcaster&, const SfxHint& rHint )
9372 if ( rHint.ISA( ScUpdateRefHint ) )
9374 //! und nun ???
9376 else if ( rHint.ISA( SfxSimpleHint ) )
9378 sal_uLong nId = ((const SfxSimpleHint&)rHint).GetId();
9379 if ( nId == SFX_HINT_DYING )
9381 pDocShell = NULL; // ungueltig geworden
9382 delete pIter;
9383 pIter = NULL;
9385 else if ( nId == SFX_HINT_DATACHANGED )
9387 bDirty = true; // AttrArray-Index evtl. ungueltig geworden
9392 // XEnumeration
9394 sal_Bool SAL_CALL ScCellFormatsEnumeration::hasMoreElements() throw(uno::RuntimeException, std::exception)
9396 SolarMutexGuard aGuard;
9397 return !bAtEnd;
9400 uno::Any SAL_CALL ScCellFormatsEnumeration::nextElement() throw(container::NoSuchElementException,
9401 lang::WrappedTargetException, uno::RuntimeException, std::exception)
9403 SolarMutexGuard aGuard;
9405 if ( bAtEnd || !pDocShell )
9406 throw container::NoSuchElementException(); // no more elements
9408 // Interface-Typ muss zu ScCellFormatsObj::getElementType passen
9410 return uno::makeAny(uno::Reference<table::XCellRange> (NextObject_Impl()));
9413 ScUniqueCellFormatsObj::ScUniqueCellFormatsObj(ScDocShell* pDocSh, const ScRange& rRange) :
9414 pDocShell( pDocSh ),
9415 aTotalRange( rRange ),
9416 aRangeLists()
9418 pDocShell->GetDocument()->AddUnoObject(*this);
9420 OSL_ENSURE( aTotalRange.aStart.Tab() == aTotalRange.aEnd.Tab(), "unterschiedliche Tabellen" );
9422 GetObjects_Impl();
9425 ScUniqueCellFormatsObj::~ScUniqueCellFormatsObj()
9427 if (pDocShell)
9428 pDocShell->GetDocument()->RemoveUnoObject(*this);
9431 void ScUniqueCellFormatsObj::Notify( SfxBroadcaster&, const SfxHint& rHint )
9433 if ( rHint.ISA( ScUpdateRefHint ) )
9435 //! aTotalRange...
9437 else if ( rHint.ISA( SfxSimpleHint ) )
9439 sal_uLong nId = ((const SfxSimpleHint&)rHint).GetId();
9440 if ( nId == SFX_HINT_DYING )
9441 pDocShell = NULL; // ungueltig geworden
9446 // Fill the list of formats from the document
9449 // hash code to access the range lists by ScPatternAttr pointer
9450 struct ScPatternHashCode
9452 size_t operator()( const ScPatternAttr* pPattern ) const
9454 return reinterpret_cast<size_t>(pPattern);
9458 // Hash map to find a range by its start row
9459 typedef ::boost::unordered_map< SCROW, ScRange > ScRowRangeHashMap;
9461 typedef ::std::vector<ScRange> ScRangeVector;
9463 // Hash map entry.
9464 // The Join method depends on the column-wise order of ScAttrRectIterator
9465 class ScUniqueFormatsEntry
9467 enum EntryState { STATE_EMPTY, STATE_SINGLE, STATE_COMPLEX };
9469 EntryState eState;
9470 ScRange aSingleRange;
9471 ScRowRangeHashMap aJoinedRanges; // "active" ranges to be merged
9472 ScRangeVector aCompletedRanges; // ranges that will no longer be touched
9473 ScRangeListRef aReturnRanges; // result as ScRangeList for further use
9475 public:
9476 ScUniqueFormatsEntry() : eState( STATE_EMPTY ) {}
9477 ~ScUniqueFormatsEntry() {}
9479 void Join( const ScRange& rNewRange );
9480 const ScRangeList& GetRanges();
9481 void Clear() { aReturnRanges.Clear(); } // aJoinedRanges and aCompletedRanges are cleared in GetRanges
9484 void ScUniqueFormatsEntry::Join( const ScRange& rNewRange )
9486 // Special-case handling for single range
9488 if ( eState == STATE_EMPTY )
9490 aSingleRange = rNewRange;
9491 eState = STATE_SINGLE;
9492 return;
9494 if ( eState == STATE_SINGLE )
9496 if ( aSingleRange.aStart.Row() == rNewRange.aStart.Row() &&
9497 aSingleRange.aEnd.Row() == rNewRange.aEnd.Row() &&
9498 aSingleRange.aEnd.Col() + 1 == rNewRange.aStart.Col() )
9500 aSingleRange.aEnd.SetCol( rNewRange.aEnd.Col() );
9501 return; // still a single range
9504 SCROW nSingleRow = aSingleRange.aStart.Row();
9505 aJoinedRanges.insert( ScRowRangeHashMap::value_type( nSingleRow, aSingleRange ) );
9506 eState = STATE_COMPLEX;
9507 // continue normally
9510 // This is called in the order of ScAttrRectIterator results.
9511 // rNewRange can only be joined with an existing entry if it's the same rows, starting in the next column.
9512 // If the old entry for the start row extends to a different end row, or ends in a different column, it
9513 // can be moved to aCompletedRanges because it can't be joined with following iterator results.
9514 // Everything happens within one sheet, so Tab can be ignored.
9516 SCROW nStartRow = rNewRange.aStart.Row();
9517 ScRowRangeHashMap::iterator aIter( aJoinedRanges.find( nStartRow ) ); // find the active entry for the start row
9518 if ( aIter != aJoinedRanges.end() )
9520 ScRange& rOldRange = aIter->second;
9521 if ( rOldRange.aEnd.Row() == rNewRange.aEnd.Row() &&
9522 rOldRange.aEnd.Col() + 1 == rNewRange.aStart.Col() )
9524 // extend existing range
9525 rOldRange.aEnd.SetCol( rNewRange.aEnd.Col() );
9527 else
9529 // move old range to aCompletedRanges, keep rNewRange for joining
9530 aCompletedRanges.push_back( rOldRange );
9531 rOldRange = rNewRange; // replace in hash map
9534 else
9536 // keep rNewRange for joining
9537 aJoinedRanges.insert( ScRowRangeHashMap::value_type( nStartRow, rNewRange ) );
9541 const ScRangeList& ScUniqueFormatsEntry::GetRanges()
9543 if ( eState == STATE_SINGLE )
9545 aReturnRanges = new ScRangeList;
9546 aReturnRanges->Append( aSingleRange );
9547 return *aReturnRanges;
9550 // move remaining entries from aJoinedRanges to aCompletedRanges
9552 ScRowRangeHashMap::const_iterator aJoinedEnd = aJoinedRanges.end();
9553 for ( ScRowRangeHashMap::const_iterator aJoinedIter = aJoinedRanges.begin(); aJoinedIter != aJoinedEnd; ++aJoinedIter )
9554 aCompletedRanges.push_back( aJoinedIter->second );
9555 aJoinedRanges.clear();
9557 // sort all ranges for a predictable API result
9559 std::sort( aCompletedRanges.begin(), aCompletedRanges.end() );
9561 // fill and return ScRangeList
9563 aReturnRanges = new ScRangeList;
9564 ScRangeVector::const_iterator aCompEnd( aCompletedRanges.end() );
9565 for ( ScRangeVector::const_iterator aCompIter( aCompletedRanges.begin() ); aCompIter != aCompEnd; ++aCompIter )
9566 aReturnRanges->Append( *aCompIter );
9567 aCompletedRanges.clear();
9569 return *aReturnRanges;
9572 typedef ::boost::unordered_map< const ScPatternAttr*, ScUniqueFormatsEntry, ScPatternHashCode > ScUniqueFormatsHashMap;
9574 // function object to sort the range lists by start of first range
9575 struct ScUniqueFormatsOrder
9577 bool operator()( const ScRangeList& rList1, const ScRangeList& rList2 ) const
9579 // all range lists have at least one entry
9580 OSL_ENSURE( rList1.size() > 0 && rList2.size() > 0, "ScUniqueFormatsOrder: empty list" );
9582 // compare start positions using ScAddress comparison operator
9583 return ( rList1[ 0 ]->aStart < rList2[ 0 ]->aStart );
9587 void ScUniqueCellFormatsObj::GetObjects_Impl()
9589 if (pDocShell)
9591 ScDocument* pDoc = pDocShell->GetDocument();
9592 SCTAB nTab = aTotalRange.aStart.Tab();
9593 ScAttrRectIterator aIter( pDoc, nTab,
9594 aTotalRange.aStart.Col(), aTotalRange.aStart.Row(),
9595 aTotalRange.aEnd.Col(), aTotalRange.aEnd.Row() );
9596 SCCOL nCol1, nCol2;
9597 SCROW nRow1, nRow2;
9599 // Collect the ranges for each format in a hash map, to avoid nested loops
9601 ScUniqueFormatsHashMap aHashMap;
9602 while (aIter.GetNext( nCol1, nCol2, nRow1, nRow2 ) )
9604 ScRange aRange( nCol1, nRow1, nTab, nCol2, nRow2, nTab );
9605 const ScPatternAttr* pPattern = pDoc->GetPattern(nCol1, nRow1, nTab);
9606 aHashMap[pPattern].Join( aRange );
9609 // Fill the vector aRangeLists with the range lists from the hash map
9611 aRangeLists.reserve( aHashMap.size() );
9612 ScUniqueFormatsHashMap::iterator aMapIter( aHashMap.begin() );
9613 ScUniqueFormatsHashMap::iterator aMapEnd( aHashMap.end() );
9614 while ( aMapIter != aMapEnd )
9616 ScUniqueFormatsEntry& rEntry = aMapIter->second;
9617 const ScRangeList& rRanges = rEntry.GetRanges();
9618 aRangeLists.push_back( rRanges ); // copy ScRangeList
9619 rEntry.Clear(); // free memory, don't hold both copies of all ranges
9620 ++aMapIter;
9623 // Sort the vector by first range's start position, to avoid random shuffling
9624 // due to using the ScPatterAttr pointers
9626 ScUniqueFormatsOrder aComp;
9627 ::std::sort( aRangeLists.begin(), aRangeLists.end(), aComp );
9631 // XIndexAccess
9633 sal_Int32 SAL_CALL ScUniqueCellFormatsObj::getCount() throw(uno::RuntimeException, std::exception)
9635 SolarMutexGuard aGuard;
9637 return aRangeLists.size();
9640 uno::Any SAL_CALL ScUniqueCellFormatsObj::getByIndex( sal_Int32 nIndex )
9641 throw(lang::IndexOutOfBoundsException,
9642 lang::WrappedTargetException, uno::RuntimeException, std::exception)
9644 SolarMutexGuard aGuard;
9646 if(static_cast<sal_uInt32>(nIndex) < aRangeLists.size())
9647 return uno::makeAny(uno::Reference<sheet::XSheetCellRangeContainer>(new ScCellRangesObj(pDocShell, aRangeLists[nIndex])));
9648 else
9649 throw lang::IndexOutOfBoundsException();
9652 uno::Type SAL_CALL ScUniqueCellFormatsObj::getElementType() throw(uno::RuntimeException, std::exception)
9654 SolarMutexGuard aGuard;
9655 return cppu::UnoType<sheet::XSheetCellRangeContainer>::get();
9658 sal_Bool SAL_CALL ScUniqueCellFormatsObj::hasElements() throw(uno::RuntimeException, std::exception)
9660 SolarMutexGuard aGuard;
9661 return ( aRangeLists.size() != 0 );
9664 // XEnumerationAccess
9666 uno::Reference<container::XEnumeration> SAL_CALL ScUniqueCellFormatsObj::createEnumeration()
9667 throw(uno::RuntimeException, std::exception)
9669 SolarMutexGuard aGuard;
9670 if (pDocShell)
9671 return new ScUniqueCellFormatsEnumeration( pDocShell, aRangeLists );
9672 return NULL;
9675 ScUniqueCellFormatsEnumeration::ScUniqueCellFormatsEnumeration(ScDocShell* pDocSh, const ScMyRangeLists& rRangeLists) :
9676 aRangeLists(rRangeLists),
9677 pDocShell( pDocSh ),
9678 nCurrentPosition(0)
9680 pDocShell->GetDocument()->AddUnoObject(*this);
9683 ScUniqueCellFormatsEnumeration::~ScUniqueCellFormatsEnumeration()
9685 if (pDocShell)
9686 pDocShell->GetDocument()->RemoveUnoObject(*this);
9689 void ScUniqueCellFormatsEnumeration::Notify( SfxBroadcaster&, const SfxHint& rHint )
9691 if ( rHint.ISA( ScUpdateRefHint ) )
9693 //! und nun ???
9695 else if ( rHint.ISA( SfxSimpleHint ) )
9697 sal_uLong nId = ((const SfxSimpleHint&)rHint).GetId();
9698 if ( nId == SFX_HINT_DYING )
9699 pDocShell = NULL; // ungueltig geworden
9703 // XEnumeration
9705 sal_Bool SAL_CALL ScUniqueCellFormatsEnumeration::hasMoreElements() throw(uno::RuntimeException, std::exception)
9707 SolarMutexGuard aGuard;
9708 return static_cast<sal_uInt32>(nCurrentPosition) < aRangeLists.size();
9711 uno::Any SAL_CALL ScUniqueCellFormatsEnumeration::nextElement() throw(container::NoSuchElementException,
9712 lang::WrappedTargetException, uno::RuntimeException, std::exception)
9714 SolarMutexGuard aGuard;
9716 if ( !hasMoreElements() || !pDocShell )
9717 throw container::NoSuchElementException(); // no more elements
9719 // Interface-Typ muss zu ScCellFormatsObj::getElementType passen
9721 return uno::makeAny(uno::Reference<sheet::XSheetCellRangeContainer>(new ScCellRangesObj(pDocShell, aRangeLists[nCurrentPosition++])));
9724 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */