fix baseline build (old cairo) - 'cairo_rectangle_int_t' does not name a type
[LibreOffice.git] / sc / source / ui / unoobj / cellsuno.cxx
blob1201939eafbb1b3f863bb2803bb705c0d2a04e75
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>
63 #include <com/sun/star/sheet/XConditionalFormats.hpp>
65 #include "autoform.hxx"
66 #include "cellmergeoption.hxx"
67 #include "cellsuno.hxx"
68 #include "cursuno.hxx"
69 #include "textuno.hxx"
70 #include "editsrc.hxx"
71 #include "notesuno.hxx"
72 #include "fielduno.hxx"
73 #include "docuno.hxx"
74 #include "datauno.hxx"
75 #include "dapiuno.hxx"
76 #include "chartuno.hxx"
77 #include "fmtuno.hxx"
78 #include "miscuno.hxx"
79 #include "convuno.hxx"
80 #include "srchuno.hxx"
81 #include "nameuno.hxx"
82 #include "targuno.hxx"
83 #include "tokenuno.hxx"
84 #include "eventuno.hxx"
85 #include "docsh.hxx"
86 #include "markdata.hxx"
87 #include "patattr.hxx"
88 #include "docpool.hxx"
89 #include "docfunc.hxx"
90 #include "dbdocfun.hxx"
91 #include "olinefun.hxx"
92 #include "hints.hxx"
93 #include "formulacell.hxx"
94 #include "undocell.hxx"
95 #include "undotab.hxx"
96 #include "undoblk.hxx"
97 #include "stlsheet.hxx"
98 #include "dbdata.hxx"
99 #include "attrib.hxx"
100 #include "chartarr.hxx"
101 #include "chartlis.hxx"
102 #include "drwlayer.hxx"
103 #include "printfun.hxx"
104 #include "prnsave.hxx"
105 #include "tablink.hxx"
106 #include "dociter.hxx"
107 #include "rangeutl.hxx"
108 #include "conditio.hxx"
109 #include "validat.hxx"
110 #include "sc.hrc"
111 #include "brdcst.hxx"
112 #include "cellform.hxx"
113 #include "globstr.hrc"
114 #include "unonames.hxx"
115 #include "styleuno.hxx"
116 #include "rangeseq.hxx"
117 #include "unowids.hxx"
118 #include "paramisc.hxx"
119 #include "queryentry.hxx"
120 #include <formula/errorcodes.hxx>
121 #include "unoreflist.hxx"
122 #include <formula/grammar.hxx>
123 #include <editeng/escapementitem.hxx>
124 #include "stringutil.hxx"
125 #include "formulaiter.hxx"
126 #include "tokenarray.hxx"
127 #include "stylehelper.hxx"
128 #include "dputil.hxx"
129 #include <sortparam.hxx>
130 #include "condformatuno.hxx"
132 #include <list>
133 #include <boost/scoped_array.hpp>
134 #include <boost/scoped_ptr.hpp>
136 using namespace com::sun::star;
138 class ScNamedEntry
140 OUString aName;
141 ScRange aRange;
143 public:
144 ScNamedEntry(const OUString& rN, const ScRange& rR) :
145 aName(rN), aRange(rR) {}
147 const OUString& GetName() const { return aName; }
148 const ScRange& GetRange() const { return aRange; }
151 // The names in the maps must be sorted according to strcmp!
152 //! Instead of Which-ID 0 use special IDs and do not compare via names!
154 // Left/Right/Top/BottomBorder are mapped directly to the core items,
155 // not collected/applied to the borders of a range -> ATTR_BORDER can be used directly
157 static const SfxItemPropertySet* lcl_GetCellsPropertySet()
159 static const SfxItemPropertyMapEntry aCellsPropertyMap_Impl[] =
161 {OUString(SC_UNONAME_ABSNAME), SC_WID_UNO_ABSNAME, cppu::UnoType<OUString>::get(), 0 | beans::PropertyAttribute::READONLY, 0 },
162 {OUString(SC_UNONAME_ASIANVERT),ATTR_VERTICAL_ASIAN,cppu::UnoType<bool>::get(), 0, 0 },
163 {OUString(SC_UNONAME_BOTTBORDER),ATTR_BORDER, ::cppu::UnoType<table::BorderLine>::get(), 0, BOTTOM_BORDER | CONVERT_TWIPS },
164 {OUString(SC_UNONAME_BOTTBORDER2),ATTR_BORDER, ::cppu::UnoType<table::BorderLine2>::get(), 0, BOTTOM_BORDER | CONVERT_TWIPS },
165 {OUString(SC_UNONAME_CELLBACK), ATTR_BACKGROUND, cppu::UnoType<sal_Int32>::get(), 0, MID_BACK_COLOR },
166 {OUString(SC_UNONAME_CELLPRO), ATTR_PROTECTION, cppu::UnoType<util::CellProtection>::get(), 0, 0 },
167 {OUString(SC_UNONAME_CELLSTYL), SC_WID_UNO_CELLSTYL,cppu::UnoType<OUString>::get(), 0, 0 },
168 {OUString(SC_UNONAME_CCOLOR), ATTR_FONT_COLOR, cppu::UnoType<sal_Int32>::get(), 0, 0 },
169 {OUString(SC_UNONAME_COUTL), ATTR_FONT_CONTOUR, cppu::UnoType<bool>::get(), 0, 0 },
170 {OUString(SC_UNONAME_CCROSS), ATTR_FONT_CROSSEDOUT,cppu::UnoType<bool>::get(), 0, MID_CROSSED_OUT },
171 {OUString(SC_UNONAME_CEMPHAS), ATTR_FONT_EMPHASISMARK,cppu::UnoType<sal_Int16>::get(), 0, MID_EMPHASIS },
172 {OUString(SC_UNONAME_CFONT), ATTR_FONT, cppu::UnoType<sal_Int16>::get(), 0, MID_FONT_FAMILY },
173 {OUString(SC_UNONAME_CFCHARS), ATTR_FONT, cppu::UnoType<sal_Int16>::get(), 0, MID_FONT_CHAR_SET },
174 {OUString(SC_UNO_CJK_CFCHARS), ATTR_CJK_FONT, cppu::UnoType<sal_Int16>::get(), 0, MID_FONT_CHAR_SET },
175 {OUString(SC_UNO_CTL_CFCHARS), ATTR_CTL_FONT, cppu::UnoType<sal_Int16>::get(), 0, MID_FONT_CHAR_SET },
176 {OUString(SC_UNONAME_CFFAMIL), ATTR_FONT, cppu::UnoType<sal_Int16>::get(), 0, MID_FONT_FAMILY },
177 {OUString(SC_UNO_CJK_CFFAMIL), ATTR_CJK_FONT, cppu::UnoType<sal_Int16>::get(), 0, MID_FONT_FAMILY },
178 {OUString(SC_UNO_CTL_CFFAMIL), ATTR_CTL_FONT, cppu::UnoType<sal_Int16>::get(), 0, MID_FONT_FAMILY },
179 {OUString(SC_UNONAME_CFNAME), ATTR_FONT, cppu::UnoType<OUString>::get(), 0, MID_FONT_FAMILY_NAME },
180 {OUString(SC_UNO_CJK_CFNAME), ATTR_CJK_FONT, cppu::UnoType<OUString>::get(), 0, MID_FONT_FAMILY_NAME },
181 {OUString(SC_UNO_CTL_CFNAME), ATTR_CTL_FONT, cppu::UnoType<OUString>::get(), 0, MID_FONT_FAMILY_NAME },
182 {OUString(SC_UNONAME_CFPITCH), ATTR_FONT, cppu::UnoType<sal_Int16>::get(), 0, MID_FONT_PITCH },
183 {OUString(SC_UNO_CJK_CFPITCH), ATTR_CJK_FONT, cppu::UnoType<sal_Int16>::get(), 0, MID_FONT_PITCH },
184 {OUString(SC_UNO_CTL_CFPITCH), ATTR_CTL_FONT, cppu::UnoType<sal_Int16>::get(), 0, MID_FONT_PITCH },
185 {OUString(SC_UNONAME_CFSTYLE), ATTR_FONT, cppu::UnoType<OUString>::get(), 0, MID_FONT_STYLE_NAME },
186 {OUString(SC_UNO_CJK_CFSTYLE), ATTR_CJK_FONT, cppu::UnoType<OUString>::get(), 0, MID_FONT_STYLE_NAME },
187 {OUString(SC_UNO_CTL_CFSTYLE), ATTR_CTL_FONT, cppu::UnoType<OUString>::get(), 0, MID_FONT_STYLE_NAME },
188 {OUString(SC_UNONAME_CHEIGHT), ATTR_FONT_HEIGHT, cppu::UnoType<float>::get(), 0, MID_FONTHEIGHT | CONVERT_TWIPS },
189 {OUString(SC_UNO_CJK_CHEIGHT), ATTR_CJK_FONT_HEIGHT,cppu::UnoType<float>::get(), 0, MID_FONTHEIGHT | CONVERT_TWIPS },
190 {OUString(SC_UNO_CTL_CHEIGHT), ATTR_CTL_FONT_HEIGHT,cppu::UnoType<float>::get(), 0, MID_FONTHEIGHT | CONVERT_TWIPS },
191 {OUString(SC_UNONAME_CLOCAL), ATTR_FONT_LANGUAGE, cppu::UnoType<lang::Locale>::get(), 0, MID_LANG_LOCALE },
192 {OUString(SC_UNO_CJK_CLOCAL), ATTR_CJK_FONT_LANGUAGE,cppu::UnoType<lang::Locale>::get(), 0, MID_LANG_LOCALE },
193 {OUString(SC_UNO_CTL_CLOCAL), ATTR_CTL_FONT_LANGUAGE,cppu::UnoType<lang::Locale>::get(), 0, MID_LANG_LOCALE },
194 {OUString(SC_UNONAME_COVER), ATTR_FONT_OVERLINE, cppu::UnoType<sal_Int16>::get(), 0, MID_TL_STYLE },
195 {OUString(SC_UNONAME_COVRLCOL), ATTR_FONT_OVERLINE, cppu::UnoType<sal_Int32>::get(), 0, MID_TL_COLOR },
196 {OUString(SC_UNONAME_COVRLHAS), ATTR_FONT_OVERLINE, cppu::UnoType<bool>::get(), 0, MID_TL_HASCOLOR },
197 {OUString(SC_UNONAME_CPOST), ATTR_FONT_POSTURE, cppu::UnoType<awt::FontSlant>::get(), 0, MID_POSTURE },
198 {OUString(SC_UNO_CJK_CPOST), ATTR_CJK_FONT_POSTURE,cppu::UnoType<awt::FontSlant>::get(), 0, MID_POSTURE },
199 {OUString(SC_UNO_CTL_CPOST), ATTR_CTL_FONT_POSTURE,cppu::UnoType<awt::FontSlant>::get(), 0, MID_POSTURE },
200 {OUString(SC_UNONAME_CRELIEF), ATTR_FONT_RELIEF, cppu::UnoType<sal_Int16>::get(), 0, MID_RELIEF },
201 {OUString(SC_UNONAME_CSHADD), ATTR_FONT_SHADOWED, cppu::UnoType<bool>::get(), 0, 0 },
202 {OUString(SC_UNONAME_CSTRIKE), ATTR_FONT_CROSSEDOUT,cppu::UnoType<sal_Int16>::get(), 0, MID_CROSS_OUT },
203 {OUString(SC_UNONAME_CUNDER), ATTR_FONT_UNDERLINE,cppu::UnoType<sal_Int16>::get(), 0, MID_TL_STYLE },
204 {OUString(SC_UNONAME_CUNDLCOL), ATTR_FONT_UNDERLINE,cppu::UnoType<sal_Int32>::get(), 0, MID_TL_COLOR },
205 {OUString(SC_UNONAME_CUNDLHAS), ATTR_FONT_UNDERLINE,cppu::UnoType<bool>::get(), 0, MID_TL_HASCOLOR },
206 {OUString(SC_UNONAME_CWEIGHT), ATTR_FONT_WEIGHT, cppu::UnoType<float>::get(), 0, MID_WEIGHT },
207 {OUString(SC_UNO_CJK_CWEIGHT), ATTR_CJK_FONT_WEIGHT,cppu::UnoType<float>::get(), 0, MID_WEIGHT },
208 {OUString(SC_UNO_CTL_CWEIGHT), ATTR_CTL_FONT_WEIGHT,cppu::UnoType<float>::get(), 0, MID_WEIGHT },
209 {OUString(SC_UNONAME_CWORDMOD), ATTR_FONT_WORDLINE, cppu::UnoType<bool>::get(), 0, 0 },
210 {OUString(SC_UNONAME_CHCOLHDR), SC_WID_UNO_CHCOLHDR,cppu::UnoType<bool>::get(), 0, 0 },
211 {OUString(SC_UNONAME_CHROWHDR), SC_WID_UNO_CHROWHDR,cppu::UnoType<bool>::get(), 0, 0 },
212 {OUString(SC_UNONAME_CONDFMT), SC_WID_UNO_CONDFMT, cppu::UnoType<sheet::XSheetConditionalEntries>::get(), 0, 0 },
213 {OUString(SC_UNONAME_CONDLOC), SC_WID_UNO_CONDLOC, cppu::UnoType<sheet::XSheetConditionalEntries>::get(), 0, 0 },
214 {OUString(SC_UNONAME_CONDXML), SC_WID_UNO_CONDXML, cppu::UnoType<sheet::XSheetConditionalEntries>::get(), 0, 0 },
215 {OUString(SC_UNONAME_DIAGONAL_BLTR), ATTR_BORDER_BLTR, ::cppu::UnoType<table::BorderLine>::get(), 0, 0 | CONVERT_TWIPS },
216 {OUString(SC_UNONAME_DIAGONAL_BLTR2), ATTR_BORDER_BLTR, ::cppu::UnoType<table::BorderLine2>::get(), 0, 0 | CONVERT_TWIPS },
217 {OUString(SC_UNONAME_DIAGONAL_TLBR), ATTR_BORDER_TLBR, ::cppu::UnoType<table::BorderLine>::get(), 0, 0 | CONVERT_TWIPS },
218 {OUString(SC_UNONAME_DIAGONAL_TLBR2), ATTR_BORDER_TLBR, ::cppu::UnoType<table::BorderLine2>::get(), 0, 0 | CONVERT_TWIPS },
219 {OUString(SC_UNONAME_CELLHJUS), ATTR_HOR_JUSTIFY, cppu::UnoType<table::CellHoriJustify>::get(), 0, MID_HORJUST_HORJUST },
220 {OUString(SC_UNONAME_CELLHJUS_METHOD), ATTR_HOR_JUSTIFY_METHOD, ::cppu::UnoType<sal_Int32>::get(), 0, 0 },
221 {OUString(SC_UNONAME_CELLTRAN), ATTR_BACKGROUND, cppu::UnoType<bool>::get(), 0, MID_GRAPHIC_TRANSPARENT },
222 {OUString(SC_UNONAME_WRAP), ATTR_LINEBREAK, cppu::UnoType<bool>::get(), 0, 0 },
223 {OUString(SC_UNONAME_LEFTBORDER),ATTR_BORDER, ::cppu::UnoType<table::BorderLine>::get(), 0, LEFT_BORDER | CONVERT_TWIPS },
224 {OUString(SC_UNONAME_LEFTBORDER2),ATTR_BORDER, ::cppu::UnoType<table::BorderLine2>::get(), 0, LEFT_BORDER | CONVERT_TWIPS },
225 {OUString(SC_UNONAME_NUMFMT), ATTR_VALUE_FORMAT, cppu::UnoType<sal_Int32>::get(), 0, 0 },
226 {OUString(SC_UNONAME_NUMRULES), SC_WID_UNO_NUMRULES,cppu::UnoType<container::XIndexReplace>::get(), 0, 0 },
227 {OUString(SC_UNONAME_CELLORI), ATTR_STACKED, cppu::UnoType<table::CellOrientation>::get(), 0, 0 },
228 {OUString(SC_UNONAME_PADJUST), ATTR_HOR_JUSTIFY, ::cppu::UnoType<sal_Int16>::get(), 0, MID_HORJUST_ADJUST },
229 {OUString(SC_UNONAME_PBMARGIN), ATTR_MARGIN, cppu::UnoType<sal_Int32>::get(), 0, MID_MARGIN_LO_MARGIN | CONVERT_TWIPS },
230 {OUString(SC_UNONAME_PINDENT), ATTR_INDENT, cppu::UnoType<sal_Int16>::get(), 0, 0 }, //! CONVERT_TWIPS
231 {OUString(SC_UNONAME_PISCHDIST),ATTR_SCRIPTSPACE, cppu::UnoType<bool>::get(), 0, 0 },
232 {OUString(SC_UNONAME_PISFORBID),ATTR_FORBIDDEN_RULES,cppu::UnoType<bool>::get(), 0, 0 },
233 {OUString(SC_UNONAME_PISHANG), ATTR_HANGPUNCTUATION,cppu::UnoType<bool>::get(), 0, 0 },
234 {OUString(SC_UNONAME_PISHYPHEN),ATTR_HYPHENATE, cppu::UnoType<bool>::get(), 0, 0 },
235 {OUString(SC_UNONAME_PLASTADJ), ATTR_HOR_JUSTIFY, ::cppu::UnoType<sal_Int16>::get(), 0, MID_HORJUST_ADJUST },
236 {OUString(SC_UNONAME_PLMARGIN), ATTR_MARGIN, cppu::UnoType<sal_Int32>::get(), 0, MID_MARGIN_L_MARGIN | CONVERT_TWIPS },
237 {OUString(SC_UNONAME_PRMARGIN), ATTR_MARGIN, cppu::UnoType<sal_Int32>::get(), 0, MID_MARGIN_R_MARGIN | CONVERT_TWIPS },
238 {OUString(SC_UNONAME_PTMARGIN), ATTR_MARGIN, cppu::UnoType<sal_Int32>::get(), 0, MID_MARGIN_UP_MARGIN | CONVERT_TWIPS },
239 {OUString(SC_UNONAME_RIGHTBORDER),ATTR_BORDER, ::cppu::UnoType<table::BorderLine>::get(), 0, RIGHT_BORDER | CONVERT_TWIPS },
240 {OUString(SC_UNONAME_RIGHTBORDER2),ATTR_BORDER, ::cppu::UnoType<table::BorderLine2>::get(), 0, RIGHT_BORDER | CONVERT_TWIPS },
241 {OUString(SC_UNONAME_ROTANG), ATTR_ROTATE_VALUE, cppu::UnoType<sal_Int32>::get(), 0, 0 },
242 {OUString(SC_UNONAME_ROTREF), ATTR_ROTATE_MODE, cppu::UnoType<sal_Int32>::get(), 0, 0 },
243 {OUString(SC_UNONAME_SHADOW), ATTR_SHADOW, cppu::UnoType<table::ShadowFormat>::get(), 0, 0 | CONVERT_TWIPS },
244 {OUString(SC_UNONAME_SHRINK_TO_FIT), ATTR_SHRINKTOFIT, cppu::UnoType<bool>::get(), 0, 0 },
245 {OUString(SC_UNONAME_TBLBORD), SC_WID_UNO_TBLBORD, cppu::UnoType<table::TableBorder>::get(), 0, 0 | CONVERT_TWIPS },
246 {OUString(SC_UNONAME_TBLBORD2), SC_WID_UNO_TBLBORD2, cppu::UnoType<table::TableBorder2>::get(), 0, 0 | CONVERT_TWIPS },
247 {OUString(SC_UNONAME_TOPBORDER),ATTR_BORDER, ::cppu::UnoType<table::BorderLine>::get(), 0, TOP_BORDER | CONVERT_TWIPS },
248 {OUString(SC_UNONAME_TOPBORDER2),ATTR_BORDER, ::cppu::UnoType<table::BorderLine2>::get(), 0, TOP_BORDER | CONVERT_TWIPS },
249 {OUString(SC_UNONAME_USERDEF), ATTR_USERDEF, cppu::UnoType<container::XNameContainer>::get(), 0, 0 },
250 {OUString(SC_UNONAME_VALIDAT), SC_WID_UNO_VALIDAT, cppu::UnoType<beans::XPropertySet>::get(), 0, 0 },
251 {OUString(SC_UNONAME_VALILOC), SC_WID_UNO_VALILOC, cppu::UnoType<beans::XPropertySet>::get(), 0, 0 },
252 {OUString(SC_UNONAME_VALIXML), SC_WID_UNO_VALIXML, cppu::UnoType<beans::XPropertySet>::get(), 0, 0 },
253 {OUString(SC_UNONAME_CELLVJUS), ATTR_VER_JUSTIFY, cppu::UnoType<sal_Int32>::get(), 0, 0 },
254 {OUString(SC_UNONAME_CELLVJUS_METHOD), ATTR_VER_JUSTIFY_METHOD, ::cppu::UnoType<sal_Int32>::get(), 0, 0 },
255 {OUString(SC_UNONAME_WRITING), ATTR_WRITINGDIR, cppu::UnoType<sal_Int16>::get(), 0, 0 },
256 {OUString(SC_UNONAME_HYPERLINK), ATTR_HYPERLINK, cppu::UnoType<OUString>::get(), 0, 0 },
257 { OUString(), 0, css::uno::Type(), 0, 0 }
259 static SfxItemPropertySet aCellsPropertySet( aCellsPropertyMap_Impl );
260 return &aCellsPropertySet;
263 // CellRange enthaelt alle Eintraege von Cells, zusaetzlich eigene Eintraege
264 // mit Which-ID 0 (werden nur fuer getPropertySetInfo benoetigt).
266 static const SfxItemPropertySet* lcl_GetRangePropertySet()
268 static const SfxItemPropertyMapEntry aRangePropertyMap_Impl[] =
270 {OUString(SC_UNONAME_ABSNAME), SC_WID_UNO_ABSNAME, cppu::UnoType<OUString>::get(), 0 | beans::PropertyAttribute::READONLY, 0 },
271 {OUString(SC_UNONAME_ASIANVERT),ATTR_VERTICAL_ASIAN,cppu::UnoType<bool>::get(), 0, 0 },
272 {OUString(SC_UNONAME_BOTTBORDER),ATTR_BORDER, ::cppu::UnoType<table::BorderLine>::get(), 0, BOTTOM_BORDER | CONVERT_TWIPS },
273 {OUString(SC_UNONAME_BOTTBORDER2),ATTR_BORDER, ::cppu::UnoType<table::BorderLine2>::get(), 0, BOTTOM_BORDER | CONVERT_TWIPS },
274 {OUString(SC_UNONAME_CELLBACK), ATTR_BACKGROUND, cppu::UnoType<sal_Int32>::get(), 0, MID_BACK_COLOR },
275 {OUString(SC_UNONAME_CELLPRO), ATTR_PROTECTION, cppu::UnoType<util::CellProtection>::get(), 0, 0 },
276 {OUString(SC_UNONAME_CELLSTYL), SC_WID_UNO_CELLSTYL,cppu::UnoType<OUString>::get(), 0, 0 },
277 {OUString(SC_UNONAME_CCOLOR), ATTR_FONT_COLOR, cppu::UnoType<sal_Int32>::get(), 0, 0 },
278 {OUString(SC_UNONAME_COUTL), ATTR_FONT_CONTOUR, cppu::UnoType<bool>::get(), 0, 0 },
279 {OUString(SC_UNONAME_CCROSS), ATTR_FONT_CROSSEDOUT,cppu::UnoType<bool>::get(), 0, MID_CROSSED_OUT },
280 {OUString(SC_UNONAME_CEMPHAS), ATTR_FONT_EMPHASISMARK,cppu::UnoType<sal_Int16>::get(), 0, MID_EMPHASIS },
281 {OUString(SC_UNONAME_CFONT), ATTR_FONT, cppu::UnoType<sal_Int16>::get(), 0, MID_FONT_FAMILY },
282 {OUString(SC_UNONAME_CFCHARS), ATTR_FONT, cppu::UnoType<sal_Int16>::get(), 0, MID_FONT_CHAR_SET },
283 {OUString(SC_UNO_CJK_CFCHARS), ATTR_CJK_FONT, cppu::UnoType<sal_Int16>::get(), 0, MID_FONT_CHAR_SET },
284 {OUString(SC_UNO_CTL_CFCHARS), ATTR_CTL_FONT, cppu::UnoType<sal_Int16>::get(), 0, MID_FONT_CHAR_SET },
285 {OUString(SC_UNONAME_CFFAMIL), ATTR_FONT, cppu::UnoType<sal_Int16>::get(), 0, MID_FONT_FAMILY },
286 {OUString(SC_UNO_CJK_CFFAMIL), ATTR_CJK_FONT, cppu::UnoType<sal_Int16>::get(), 0, MID_FONT_FAMILY },
287 {OUString(SC_UNO_CTL_CFFAMIL), ATTR_CTL_FONT, cppu::UnoType<sal_Int16>::get(), 0, MID_FONT_FAMILY },
288 {OUString(SC_UNONAME_CFNAME), ATTR_FONT, cppu::UnoType<OUString>::get(), 0, MID_FONT_FAMILY_NAME },
289 {OUString(SC_UNO_CJK_CFNAME), ATTR_CJK_FONT, cppu::UnoType<OUString>::get(), 0, MID_FONT_FAMILY_NAME },
290 {OUString(SC_UNO_CTL_CFNAME), ATTR_CTL_FONT, cppu::UnoType<OUString>::get(), 0, MID_FONT_FAMILY_NAME },
291 {OUString(SC_UNONAME_CFPITCH), ATTR_FONT, cppu::UnoType<sal_Int16>::get(), 0, MID_FONT_PITCH },
292 {OUString(SC_UNO_CJK_CFPITCH), ATTR_CJK_FONT, cppu::UnoType<sal_Int16>::get(), 0, MID_FONT_PITCH },
293 {OUString(SC_UNO_CTL_CFPITCH), ATTR_CTL_FONT, cppu::UnoType<sal_Int16>::get(), 0, MID_FONT_PITCH },
294 {OUString(SC_UNONAME_CFSTYLE), ATTR_FONT, cppu::UnoType<OUString>::get(), 0, MID_FONT_STYLE_NAME },
295 {OUString(SC_UNO_CJK_CFSTYLE), ATTR_CJK_FONT, cppu::UnoType<OUString>::get(), 0, MID_FONT_STYLE_NAME },
296 {OUString(SC_UNO_CTL_CFSTYLE), ATTR_CTL_FONT, cppu::UnoType<OUString>::get(), 0, MID_FONT_STYLE_NAME },
297 {OUString(SC_UNONAME_CHEIGHT), ATTR_FONT_HEIGHT, cppu::UnoType<float>::get(), 0, MID_FONTHEIGHT | CONVERT_TWIPS },
298 {OUString(SC_UNO_CJK_CHEIGHT), ATTR_CJK_FONT_HEIGHT,cppu::UnoType<float>::get(), 0, MID_FONTHEIGHT | CONVERT_TWIPS },
299 {OUString(SC_UNO_CTL_CHEIGHT), ATTR_CTL_FONT_HEIGHT,cppu::UnoType<float>::get(), 0, MID_FONTHEIGHT | CONVERT_TWIPS },
300 {OUString(SC_UNONAME_CLOCAL), ATTR_FONT_LANGUAGE, cppu::UnoType<lang::Locale>::get(), 0, MID_LANG_LOCALE },
301 {OUString(SC_UNO_CJK_CLOCAL), ATTR_CJK_FONT_LANGUAGE,cppu::UnoType<lang::Locale>::get(), 0, MID_LANG_LOCALE },
302 {OUString(SC_UNO_CTL_CLOCAL), ATTR_CTL_FONT_LANGUAGE,cppu::UnoType<lang::Locale>::get(), 0, MID_LANG_LOCALE },
303 {OUString(SC_UNONAME_COVER), ATTR_FONT_OVERLINE, cppu::UnoType<sal_Int16>::get(), 0, MID_TL_STYLE },
304 {OUString(SC_UNONAME_COVRLCOL), ATTR_FONT_OVERLINE, cppu::UnoType<sal_Int32>::get(), 0, MID_TL_COLOR },
305 {OUString(SC_UNONAME_COVRLHAS), ATTR_FONT_OVERLINE, cppu::UnoType<bool>::get(), 0, MID_TL_HASCOLOR },
306 {OUString(SC_UNONAME_CPOST), ATTR_FONT_POSTURE, cppu::UnoType<awt::FontSlant>::get(), 0, MID_POSTURE },
307 {OUString(SC_UNO_CJK_CPOST), ATTR_CJK_FONT_POSTURE,cppu::UnoType<awt::FontSlant>::get(), 0, MID_POSTURE },
308 {OUString(SC_UNO_CTL_CPOST), ATTR_CTL_FONT_POSTURE,cppu::UnoType<awt::FontSlant>::get(), 0, MID_POSTURE },
309 {OUString(SC_UNONAME_CRELIEF), ATTR_FONT_RELIEF, cppu::UnoType<sal_Int16>::get(), 0, MID_RELIEF },
310 {OUString(SC_UNONAME_CSHADD), ATTR_FONT_SHADOWED, cppu::UnoType<bool>::get(), 0, 0 },
311 {OUString(SC_UNONAME_CSTRIKE), ATTR_FONT_CROSSEDOUT,cppu::UnoType<sal_Int16>::get(), 0, MID_CROSS_OUT },
312 {OUString(SC_UNONAME_CUNDER), ATTR_FONT_UNDERLINE,cppu::UnoType<sal_Int16>::get(), 0, MID_TL_STYLE },
313 {OUString(SC_UNONAME_CUNDLCOL), ATTR_FONT_UNDERLINE,cppu::UnoType<sal_Int32>::get(), 0, MID_TL_COLOR },
314 {OUString(SC_UNONAME_CUNDLHAS), ATTR_FONT_UNDERLINE,cppu::UnoType<bool>::get(), 0, MID_TL_HASCOLOR },
315 {OUString(SC_UNONAME_CWEIGHT), ATTR_FONT_WEIGHT, cppu::UnoType<float>::get(), 0, MID_WEIGHT },
316 {OUString(SC_UNO_CJK_CWEIGHT), ATTR_CJK_FONT_WEIGHT,cppu::UnoType<float>::get(), 0, MID_WEIGHT },
317 {OUString(SC_UNO_CTL_CWEIGHT), ATTR_CTL_FONT_WEIGHT,cppu::UnoType<float>::get(), 0, MID_WEIGHT },
318 {OUString(SC_UNONAME_CWORDMOD), ATTR_FONT_WORDLINE, cppu::UnoType<bool>::get(), 0, 0 },
319 {OUString(SC_UNONAME_CHCOLHDR), SC_WID_UNO_CHCOLHDR,cppu::UnoType<bool>::get(), 0, 0 },
320 {OUString(SC_UNONAME_CHROWHDR), SC_WID_UNO_CHROWHDR,cppu::UnoType<bool>::get(), 0, 0 },
321 {OUString(SC_UNONAME_CONDFMT), SC_WID_UNO_CONDFMT, cppu::UnoType<sheet::XSheetConditionalEntries>::get(), 0, 0 },
322 {OUString(SC_UNONAME_CONDLOC), SC_WID_UNO_CONDLOC, cppu::UnoType<sheet::XSheetConditionalEntries>::get(), 0, 0 },
323 {OUString(SC_UNONAME_CONDXML), SC_WID_UNO_CONDXML, cppu::UnoType<sheet::XSheetConditionalEntries>::get(), 0, 0 },
324 {OUString(SC_UNONAME_DIAGONAL_BLTR), ATTR_BORDER_BLTR, ::cppu::UnoType<table::BorderLine>::get(), 0, 0 | CONVERT_TWIPS },
325 {OUString(SC_UNONAME_DIAGONAL_BLTR2), ATTR_BORDER_BLTR, ::cppu::UnoType<table::BorderLine2>::get(), 0, 0 | CONVERT_TWIPS },
326 {OUString(SC_UNONAME_DIAGONAL_TLBR), ATTR_BORDER_TLBR, ::cppu::UnoType<table::BorderLine>::get(), 0, 0 | CONVERT_TWIPS },
327 {OUString(SC_UNONAME_DIAGONAL_TLBR2), ATTR_BORDER_TLBR, ::cppu::UnoType<table::BorderLine2>::get(), 0, 0 | CONVERT_TWIPS },
328 {OUString(SC_UNONAME_CELLHJUS), ATTR_HOR_JUSTIFY, cppu::UnoType<table::CellHoriJustify>::get(), 0, MID_HORJUST_HORJUST },
329 {OUString(SC_UNONAME_CELLHJUS_METHOD), ATTR_HOR_JUSTIFY_METHOD, ::cppu::UnoType<sal_Int32>::get(), 0, 0 },
330 {OUString(SC_UNONAME_CELLTRAN), ATTR_BACKGROUND, cppu::UnoType<bool>::get(), 0, MID_GRAPHIC_TRANSPARENT },
331 {OUString(SC_UNONAME_WRAP), ATTR_LINEBREAK, cppu::UnoType<bool>::get(), 0, 0 },
332 {OUString(SC_UNONAME_LEFTBORDER),ATTR_BORDER, ::cppu::UnoType<table::BorderLine>::get(), 0, LEFT_BORDER | CONVERT_TWIPS },
333 {OUString(SC_UNONAME_LEFTBORDER2),ATTR_BORDER, ::cppu::UnoType<table::BorderLine2>::get(), 0, LEFT_BORDER | CONVERT_TWIPS },
334 {OUString(SC_UNONAME_NUMFMT), ATTR_VALUE_FORMAT, cppu::UnoType<sal_Int32>::get(), 0, 0 },
335 {OUString(SC_UNONAME_NUMRULES), SC_WID_UNO_NUMRULES,cppu::UnoType<container::XIndexReplace>::get(), 0, 0 },
336 {OUString(SC_UNONAME_CELLORI), ATTR_STACKED, cppu::UnoType<table::CellOrientation>::get(), 0, 0 },
337 {OUString(SC_UNONAME_PADJUST), ATTR_HOR_JUSTIFY, ::cppu::UnoType<sal_Int16>::get(), 0, MID_HORJUST_ADJUST },
338 {OUString(SC_UNONAME_PBMARGIN), ATTR_MARGIN, cppu::UnoType<sal_Int32>::get(), 0, MID_MARGIN_LO_MARGIN | CONVERT_TWIPS },
339 {OUString(SC_UNONAME_PINDENT), ATTR_INDENT, cppu::UnoType<sal_Int16>::get(), 0, 0 }, //! CONVERT_TWIPS
340 {OUString(SC_UNONAME_PISCHDIST),ATTR_SCRIPTSPACE, cppu::UnoType<bool>::get(), 0, 0 },
341 {OUString(SC_UNONAME_PISFORBID),ATTR_FORBIDDEN_RULES,cppu::UnoType<bool>::get(), 0, 0 },
342 {OUString(SC_UNONAME_PISHANG), ATTR_HANGPUNCTUATION,cppu::UnoType<bool>::get(), 0, 0 },
343 {OUString(SC_UNONAME_PISHYPHEN),ATTR_HYPHENATE, cppu::UnoType<bool>::get(), 0, 0 },
344 {OUString(SC_UNONAME_PLASTADJ), ATTR_HOR_JUSTIFY, ::cppu::UnoType<sal_Int16>::get(), 0, MID_HORJUST_ADJUST },
345 {OUString(SC_UNONAME_PLMARGIN), ATTR_MARGIN, cppu::UnoType<sal_Int32>::get(), 0, MID_MARGIN_L_MARGIN | CONVERT_TWIPS },
346 {OUString(SC_UNONAME_PRMARGIN), ATTR_MARGIN, cppu::UnoType<sal_Int32>::get(), 0, MID_MARGIN_R_MARGIN | CONVERT_TWIPS },
347 {OUString(SC_UNONAME_PTMARGIN), ATTR_MARGIN, cppu::UnoType<sal_Int32>::get(), 0, MID_MARGIN_UP_MARGIN | CONVERT_TWIPS },
348 {OUString(SC_UNONAME_POS), SC_WID_UNO_POS, cppu::UnoType<awt::Point>::get(), 0 | beans::PropertyAttribute::READONLY, 0 },
349 {OUString(SC_UNONAME_RIGHTBORDER),ATTR_BORDER, ::cppu::UnoType<table::BorderLine>::get(), 0, RIGHT_BORDER | CONVERT_TWIPS },
350 {OUString(SC_UNONAME_RIGHTBORDER2),ATTR_BORDER, ::cppu::UnoType<table::BorderLine2>::get(), 0, RIGHT_BORDER | CONVERT_TWIPS },
351 {OUString(SC_UNONAME_ROTANG), ATTR_ROTATE_VALUE, cppu::UnoType<sal_Int32>::get(), 0, 0 },
352 {OUString(SC_UNONAME_ROTREF), ATTR_ROTATE_MODE, cppu::UnoType<sal_Int32>::get(), 0, 0 },
353 {OUString(SC_UNONAME_SHADOW), ATTR_SHADOW, cppu::UnoType<table::ShadowFormat>::get(), 0, 0 | CONVERT_TWIPS },
354 {OUString(SC_UNONAME_SHRINK_TO_FIT), ATTR_SHRINKTOFIT, cppu::UnoType<bool>::get(), 0, 0 },
355 {OUString(SC_UNONAME_SIZE), SC_WID_UNO_SIZE, cppu::UnoType<awt::Size>::get(), 0 | beans::PropertyAttribute::READONLY, 0 },
356 {OUString(SC_UNONAME_TBLBORD), SC_WID_UNO_TBLBORD, cppu::UnoType<table::TableBorder>::get(), 0, 0 | CONVERT_TWIPS },
357 {OUString(SC_UNONAME_TBLBORD2), SC_WID_UNO_TBLBORD2, cppu::UnoType<table::TableBorder2>::get(), 0, 0 | CONVERT_TWIPS },
358 {OUString(SC_UNONAME_TOPBORDER),ATTR_BORDER, ::cppu::UnoType<table::BorderLine>::get(), 0, TOP_BORDER | CONVERT_TWIPS },
359 {OUString(SC_UNONAME_TOPBORDER2),ATTR_BORDER, ::cppu::UnoType<table::BorderLine2>::get(), 0, TOP_BORDER | CONVERT_TWIPS },
360 {OUString(SC_UNONAME_USERDEF), ATTR_USERDEF, cppu::UnoType<container::XNameContainer>::get(), 0, 0 },
361 {OUString(SC_UNONAME_VALIDAT), SC_WID_UNO_VALIDAT, cppu::UnoType<beans::XPropertySet>::get(), 0, 0 },
362 {OUString(SC_UNONAME_VALILOC), SC_WID_UNO_VALILOC, cppu::UnoType<beans::XPropertySet>::get(), 0, 0 },
363 {OUString(SC_UNONAME_VALIXML), SC_WID_UNO_VALIXML, cppu::UnoType<beans::XPropertySet>::get(), 0, 0 },
364 {OUString(SC_UNONAME_CELLVJUS), ATTR_VER_JUSTIFY, cppu::UnoType<sal_Int32>::get(), 0, 0 },
365 {OUString(SC_UNONAME_CELLVJUS_METHOD), ATTR_VER_JUSTIFY_METHOD, ::cppu::UnoType<sal_Int32>::get(), 0, 0 },
366 {OUString(SC_UNONAME_WRITING), ATTR_WRITINGDIR, cppu::UnoType<sal_Int16>::get(), 0, 0 },
367 { OUString(), 0, css::uno::Type(), 0, 0 }
369 static SfxItemPropertySet aRangePropertySet( aRangePropertyMap_Impl );
370 return &aRangePropertySet;
373 // Cell enthaelt alle Eintraege von CellRange, zusaetzlich eigene Eintraege
374 // mit Which-ID 0 (werden nur fuer getPropertySetInfo benoetigt).
376 static const SfxItemPropertySet* lcl_GetCellPropertySet()
378 static const SfxItemPropertyMapEntry aCellPropertyMap_Impl[] =
380 {OUString(SC_UNONAME_ABSNAME), SC_WID_UNO_ABSNAME, cppu::UnoType<OUString>::get(), 0 | beans::PropertyAttribute::READONLY, 0 },
381 {OUString(SC_UNONAME_ASIANVERT),ATTR_VERTICAL_ASIAN,cppu::UnoType<bool>::get(), 0, 0 },
382 {OUString(SC_UNONAME_BOTTBORDER),ATTR_BORDER, ::cppu::UnoType<table::BorderLine>::get(), 0, BOTTOM_BORDER | CONVERT_TWIPS },
383 {OUString(SC_UNONAME_BOTTBORDER2),ATTR_BORDER, ::cppu::UnoType<table::BorderLine2>::get(), 0, BOTTOM_BORDER | CONVERT_TWIPS },
384 {OUString(SC_UNONAME_CELLBACK), ATTR_BACKGROUND, cppu::UnoType<sal_Int32>::get(), 0, MID_BACK_COLOR },
385 {OUString(SC_UNONAME_CELLPRO), ATTR_PROTECTION, cppu::UnoType<util::CellProtection>::get(), 0, 0 },
386 {OUString(SC_UNONAME_CELLSTYL), SC_WID_UNO_CELLSTYL,cppu::UnoType<OUString>::get(), 0, 0 },
387 {OUString(SC_UNONAME_CCOLOR), ATTR_FONT_COLOR, cppu::UnoType<sal_Int32>::get(), 0, 0 },
388 {OUString(SC_UNONAME_COUTL), ATTR_FONT_CONTOUR, cppu::UnoType<bool>::get(), 0, 0 },
389 {OUString(SC_UNONAME_CCROSS), ATTR_FONT_CROSSEDOUT,cppu::UnoType<bool>::get(), 0, MID_CROSSED_OUT },
390 {OUString(SC_UNONAME_CEMPHAS), ATTR_FONT_EMPHASISMARK,cppu::UnoType<sal_Int16>::get(), 0, MID_EMPHASIS },
391 {OUString(SC_UNONAME_CFONT), ATTR_FONT, cppu::UnoType<sal_Int16>::get(), 0, MID_FONT_FAMILY },
392 {OUString(SC_UNONAME_CFCHARS), ATTR_FONT, cppu::UnoType<sal_Int16>::get(), 0, MID_FONT_CHAR_SET },
393 {OUString(SC_UNO_CJK_CFCHARS), ATTR_CJK_FONT, cppu::UnoType<sal_Int16>::get(), 0, MID_FONT_CHAR_SET },
394 {OUString(SC_UNO_CTL_CFCHARS), ATTR_CTL_FONT, cppu::UnoType<sal_Int16>::get(), 0, MID_FONT_CHAR_SET },
395 {OUString(SC_UNONAME_CFFAMIL), ATTR_FONT, cppu::UnoType<sal_Int16>::get(), 0, MID_FONT_FAMILY },
396 {OUString(SC_UNO_CJK_CFFAMIL), ATTR_CJK_FONT, cppu::UnoType<sal_Int16>::get(), 0, MID_FONT_FAMILY },
397 {OUString(SC_UNO_CTL_CFFAMIL), ATTR_CTL_FONT, cppu::UnoType<sal_Int16>::get(), 0, MID_FONT_FAMILY },
398 {OUString(SC_UNONAME_CFNAME), ATTR_FONT, cppu::UnoType<OUString>::get(), 0, MID_FONT_FAMILY_NAME },
399 {OUString(SC_UNO_CJK_CFNAME), ATTR_CJK_FONT, cppu::UnoType<OUString>::get(), 0, MID_FONT_FAMILY_NAME },
400 {OUString(SC_UNO_CTL_CFNAME), ATTR_CTL_FONT, cppu::UnoType<OUString>::get(), 0, MID_FONT_FAMILY_NAME },
401 {OUString(SC_UNONAME_CFPITCH), ATTR_FONT, cppu::UnoType<sal_Int16>::get(), 0, MID_FONT_PITCH },
402 {OUString(SC_UNO_CJK_CFPITCH), ATTR_CJK_FONT, cppu::UnoType<sal_Int16>::get(), 0, MID_FONT_PITCH },
403 {OUString(SC_UNO_CTL_CFPITCH), ATTR_CTL_FONT, cppu::UnoType<sal_Int16>::get(), 0, MID_FONT_PITCH },
404 {OUString(SC_UNONAME_CFSTYLE), ATTR_FONT, cppu::UnoType<OUString>::get(), 0, MID_FONT_STYLE_NAME },
405 {OUString(SC_UNO_CJK_CFSTYLE), ATTR_CJK_FONT, cppu::UnoType<OUString>::get(), 0, MID_FONT_STYLE_NAME },
406 {OUString(SC_UNO_CTL_CFSTYLE), ATTR_CTL_FONT, cppu::UnoType<OUString>::get(), 0, MID_FONT_STYLE_NAME },
407 {OUString(SC_UNONAME_CHEIGHT), ATTR_FONT_HEIGHT, cppu::UnoType<float>::get(), 0, MID_FONTHEIGHT | CONVERT_TWIPS },
408 {OUString(SC_UNO_CJK_CHEIGHT), ATTR_CJK_FONT_HEIGHT,cppu::UnoType<float>::get(), 0, MID_FONTHEIGHT | CONVERT_TWIPS },
409 {OUString(SC_UNO_CTL_CHEIGHT), ATTR_CTL_FONT_HEIGHT,cppu::UnoType<float>::get(), 0, MID_FONTHEIGHT | CONVERT_TWIPS },
410 {OUString(SC_UNONAME_CLOCAL), ATTR_FONT_LANGUAGE, cppu::UnoType<lang::Locale>::get(), 0, MID_LANG_LOCALE },
411 {OUString(SC_UNO_CJK_CLOCAL), ATTR_CJK_FONT_LANGUAGE,cppu::UnoType<lang::Locale>::get(), 0, MID_LANG_LOCALE },
412 {OUString(SC_UNO_CTL_CLOCAL), ATTR_CTL_FONT_LANGUAGE,cppu::UnoType<lang::Locale>::get(), 0, MID_LANG_LOCALE },
413 {OUString(SC_UNONAME_COVER), ATTR_FONT_OVERLINE, cppu::UnoType<sal_Int16>::get(), 0, MID_TL_STYLE },
414 {OUString(SC_UNONAME_COVRLCOL), ATTR_FONT_OVERLINE, cppu::UnoType<sal_Int32>::get(), 0, MID_TL_COLOR },
415 {OUString(SC_UNONAME_COVRLHAS), ATTR_FONT_OVERLINE, cppu::UnoType<bool>::get(), 0, MID_TL_HASCOLOR },
416 {OUString(SC_UNONAME_CPOST), ATTR_FONT_POSTURE, cppu::UnoType<awt::FontSlant>::get(), 0, MID_POSTURE },
417 {OUString(SC_UNO_CJK_CPOST), ATTR_CJK_FONT_POSTURE,cppu::UnoType<awt::FontSlant>::get(), 0, MID_POSTURE },
418 {OUString(SC_UNO_CTL_CPOST), ATTR_CTL_FONT_POSTURE,cppu::UnoType<awt::FontSlant>::get(), 0, MID_POSTURE },
419 {OUString(SC_UNONAME_CRELIEF), ATTR_FONT_RELIEF, cppu::UnoType<sal_Int16>::get(), 0, MID_RELIEF },
420 {OUString(SC_UNONAME_CSHADD), ATTR_FONT_SHADOWED, cppu::UnoType<bool>::get(), 0, 0 },
421 {OUString(SC_UNONAME_CSTRIKE), ATTR_FONT_CROSSEDOUT,cppu::UnoType<sal_Int16>::get(), 0, MID_CROSS_OUT },
422 {OUString(SC_UNONAME_CUNDER), ATTR_FONT_UNDERLINE,cppu::UnoType<sal_Int16>::get(), 0, MID_TL_STYLE },
423 {OUString(SC_UNONAME_CUNDLCOL), ATTR_FONT_UNDERLINE,cppu::UnoType<sal_Int32>::get(), 0, MID_TL_COLOR },
424 {OUString(SC_UNONAME_CUNDLHAS), ATTR_FONT_UNDERLINE,cppu::UnoType<bool>::get(), 0, MID_TL_HASCOLOR },
425 {OUString(SC_UNONAME_CWEIGHT), ATTR_FONT_WEIGHT, cppu::UnoType<float>::get(), 0, MID_WEIGHT },
426 {OUString(SC_UNO_CJK_CWEIGHT), ATTR_CJK_FONT_WEIGHT,cppu::UnoType<float>::get(), 0, MID_WEIGHT },
427 {OUString(SC_UNO_CTL_CWEIGHT), ATTR_CTL_FONT_WEIGHT,cppu::UnoType<float>::get(), 0, MID_WEIGHT },
428 {OUString(SC_UNONAME_CWORDMOD), ATTR_FONT_WORDLINE, cppu::UnoType<bool>::get(), 0, 0 },
429 {OUString(SC_UNONAME_CHCOLHDR), SC_WID_UNO_CHCOLHDR,cppu::UnoType<bool>::get(), 0, 0 },
430 {OUString(SC_UNONAME_CHROWHDR), SC_WID_UNO_CHROWHDR,cppu::UnoType<bool>::get(), 0, 0 },
431 {OUString(SC_UNONAME_CONDFMT), SC_WID_UNO_CONDFMT, cppu::UnoType<sheet::XSheetConditionalEntries>::get(), 0, 0 },
432 {OUString(SC_UNONAME_CONDLOC), SC_WID_UNO_CONDLOC, cppu::UnoType<sheet::XSheetConditionalEntries>::get(), 0, 0 },
433 {OUString(SC_UNONAME_CONDXML), SC_WID_UNO_CONDXML, cppu::UnoType<sheet::XSheetConditionalEntries>::get(), 0, 0 },
434 {OUString(SC_UNONAME_DIAGONAL_BLTR), ATTR_BORDER_BLTR, ::cppu::UnoType<table::BorderLine>::get(), 0, 0 | CONVERT_TWIPS },
435 {OUString(SC_UNONAME_DIAGONAL_BLTR2), ATTR_BORDER_BLTR, ::cppu::UnoType<table::BorderLine2>::get(), 0, 0 | CONVERT_TWIPS },
436 {OUString(SC_UNONAME_DIAGONAL_TLBR), ATTR_BORDER_TLBR, ::cppu::UnoType<table::BorderLine>::get(), 0, 0 | CONVERT_TWIPS },
437 {OUString(SC_UNONAME_DIAGONAL_TLBR2), ATTR_BORDER_TLBR, ::cppu::UnoType<table::BorderLine2>::get(), 0, 0 | CONVERT_TWIPS },
438 {OUString(SC_UNONAME_FORMLOC), SC_WID_UNO_FORMLOC, cppu::UnoType<OUString>::get(), 0, 0 },
439 {OUString(SC_UNONAME_FORMRT), SC_WID_UNO_FORMRT, cppu::UnoType<table::CellContentType>::get(), 0 | beans::PropertyAttribute::READONLY, 0 },
440 {OUString(SC_UNONAME_CELLHJUS), ATTR_HOR_JUSTIFY, cppu::UnoType<table::CellHoriJustify>::get(), 0, MID_HORJUST_HORJUST },
441 {OUString(SC_UNONAME_CELLHJUS_METHOD), ATTR_HOR_JUSTIFY_METHOD, ::cppu::UnoType<sal_Int32>::get(), 0, 0 },
442 {OUString(SC_UNONAME_CELLTRAN), ATTR_BACKGROUND, cppu::UnoType<bool>::get(), 0, MID_GRAPHIC_TRANSPARENT },
443 {OUString(SC_UNONAME_WRAP), ATTR_LINEBREAK, cppu::UnoType<bool>::get(), 0, 0 },
444 {OUString(SC_UNONAME_LEFTBORDER),ATTR_BORDER, ::cppu::UnoType<table::BorderLine>::get(), 0, LEFT_BORDER | CONVERT_TWIPS },
445 {OUString(SC_UNONAME_LEFTBORDER2),ATTR_BORDER, ::cppu::UnoType<table::BorderLine2>::get(), 0, LEFT_BORDER | CONVERT_TWIPS },
446 {OUString(SC_UNONAME_NUMFMT), ATTR_VALUE_FORMAT, cppu::UnoType<sal_Int32>::get(), 0, 0 },
447 {OUString(SC_UNONAME_NUMRULES), SC_WID_UNO_NUMRULES,cppu::UnoType<container::XIndexReplace>::get(), 0, 0 },
448 {OUString(SC_UNONAME_CELLORI), ATTR_STACKED, cppu::UnoType<table::CellOrientation>::get(), 0, 0 },
449 {OUString(SC_UNONAME_PADJUST), ATTR_HOR_JUSTIFY, ::cppu::UnoType<sal_Int16>::get(), 0, MID_HORJUST_ADJUST },
450 {OUString(SC_UNONAME_PBMARGIN), ATTR_MARGIN, cppu::UnoType<sal_Int32>::get(), 0, MID_MARGIN_LO_MARGIN | CONVERT_TWIPS },
451 {OUString(SC_UNONAME_PINDENT), ATTR_INDENT, cppu::UnoType<sal_Int16>::get(), 0, 0 }, //! CONVERT_TWIPS
452 {OUString(SC_UNONAME_PISCHDIST),ATTR_SCRIPTSPACE, cppu::UnoType<bool>::get(), 0, 0 },
453 {OUString(SC_UNONAME_PISFORBID),ATTR_FORBIDDEN_RULES,cppu::UnoType<bool>::get(), 0, 0 },
454 {OUString(SC_UNONAME_PISHANG), ATTR_HANGPUNCTUATION,cppu::UnoType<bool>::get(), 0, 0 },
455 {OUString(SC_UNONAME_PISHYPHEN),ATTR_HYPHENATE, cppu::UnoType<bool>::get(), 0, 0 },
456 {OUString(SC_UNONAME_PLASTADJ), ATTR_HOR_JUSTIFY, ::cppu::UnoType<sal_Int16>::get(), 0, MID_HORJUST_ADJUST },
457 {OUString(SC_UNONAME_PLMARGIN), ATTR_MARGIN, cppu::UnoType<sal_Int32>::get(), 0, MID_MARGIN_L_MARGIN | CONVERT_TWIPS },
458 {OUString(SC_UNONAME_PRMARGIN), ATTR_MARGIN, cppu::UnoType<sal_Int32>::get(), 0, MID_MARGIN_R_MARGIN | CONVERT_TWIPS },
459 {OUString(SC_UNONAME_PTMARGIN), ATTR_MARGIN, cppu::UnoType<sal_Int32>::get(), 0, MID_MARGIN_UP_MARGIN | CONVERT_TWIPS },
460 {OUString(SC_UNONAME_POS), SC_WID_UNO_POS, cppu::UnoType<awt::Point>::get(), 0 | beans::PropertyAttribute::READONLY, 0 },
461 {OUString(SC_UNONAME_RIGHTBORDER),ATTR_BORDER, ::cppu::UnoType<table::BorderLine>::get(), 0, RIGHT_BORDER | CONVERT_TWIPS },
462 {OUString(SC_UNONAME_RIGHTBORDER2),ATTR_BORDER, ::cppu::UnoType<table::BorderLine2>::get(), 0, RIGHT_BORDER | CONVERT_TWIPS },
463 {OUString(SC_UNONAME_ROTANG), ATTR_ROTATE_VALUE, cppu::UnoType<sal_Int32>::get(), 0, 0 },
464 {OUString(SC_UNONAME_ROTREF), ATTR_ROTATE_MODE, cppu::UnoType<sal_Int32>::get(), 0, 0 },
465 {OUString(SC_UNONAME_SHADOW), ATTR_SHADOW, cppu::UnoType<table::ShadowFormat>::get(), 0, 0 | CONVERT_TWIPS },
466 {OUString(SC_UNONAME_SHRINK_TO_FIT), ATTR_SHRINKTOFIT, cppu::UnoType<bool>::get(), 0, 0 },
467 {OUString(SC_UNONAME_SIZE), SC_WID_UNO_SIZE, cppu::UnoType<awt::Size>::get(), 0 | beans::PropertyAttribute::READONLY, 0 },
468 {OUString(SC_UNONAME_TBLBORD), SC_WID_UNO_TBLBORD, cppu::UnoType<table::TableBorder>::get(), 0, 0 | CONVERT_TWIPS },
469 {OUString(SC_UNONAME_TBLBORD2), SC_WID_UNO_TBLBORD2, cppu::UnoType<table::TableBorder2>::get(), 0, 0 | CONVERT_TWIPS },
470 {OUString(SC_UNONAME_TOPBORDER),ATTR_BORDER, ::cppu::UnoType<table::BorderLine>::get(), 0, TOP_BORDER | CONVERT_TWIPS },
471 {OUString(SC_UNONAME_TOPBORDER2),ATTR_BORDER, ::cppu::UnoType<table::BorderLine2>::get(), 0, TOP_BORDER | CONVERT_TWIPS },
472 {OUString(SC_UNONAME_USERDEF), ATTR_USERDEF, cppu::UnoType<container::XNameContainer>::get(), 0, 0 },
473 {OUString(SC_UNONAME_VALIDAT), SC_WID_UNO_VALIDAT, cppu::UnoType<beans::XPropertySet>::get(), 0, 0 },
474 {OUString(SC_UNONAME_VALILOC), SC_WID_UNO_VALILOC, cppu::UnoType<beans::XPropertySet>::get(), 0, 0 },
475 {OUString(SC_UNONAME_VALIXML), SC_WID_UNO_VALIXML, cppu::UnoType<beans::XPropertySet>::get(), 0, 0 },
476 {OUString(SC_UNONAME_CELLVJUS), ATTR_VER_JUSTIFY, cppu::UnoType<sal_Int32>::get(), 0, 0 },
477 {OUString(SC_UNONAME_CELLVJUS_METHOD), ATTR_VER_JUSTIFY_METHOD, ::cppu::UnoType<sal_Int32>::get(), 0, 0 },
478 {OUString(SC_UNONAME_WRITING), ATTR_WRITINGDIR, cppu::UnoType<sal_Int16>::get(), 0, 0 },
479 {OUString(UNO_NAME_EDIT_CHAR_ESCAPEMENT), EE_CHAR_ESCAPEMENT, cppu::UnoType<sal_Int32>::get(), 0, 0 },
480 {OUString(SC_UNONAME_HYPERLINK), ATTR_HYPERLINK, cppu::UnoType<OUString>::get(), 0, 0 },
481 { OUString(), 0, css::uno::Type(), 0, 0 }
483 static SfxItemPropertySet aCellPropertySet( aCellPropertyMap_Impl );
484 return &aCellPropertySet;
487 // Column und Row enthalten alle Eintraege von CellRange, zusaetzlich eigene Eintraege
488 // mit Which-ID 0 (werden nur fuer getPropertySetInfo benoetigt).
490 static const SfxItemPropertySet* lcl_GetColumnPropertySet()
492 static const SfxItemPropertyMapEntry aColumnPropertyMap_Impl[] =
494 {OUString(SC_UNONAME_ABSNAME), SC_WID_UNO_ABSNAME, cppu::UnoType<OUString>::get(), 0 | beans::PropertyAttribute::READONLY, 0 },
495 {OUString(SC_UNONAME_ASIANVERT),ATTR_VERTICAL_ASIAN,cppu::UnoType<bool>::get(), 0, 0 },
496 {OUString(SC_UNONAME_BOTTBORDER),ATTR_BORDER, ::cppu::UnoType<table::BorderLine>::get(), 0, BOTTOM_BORDER | CONVERT_TWIPS },
497 {OUString(SC_UNONAME_BOTTBORDER2),ATTR_BORDER, ::cppu::UnoType<table::BorderLine2>::get(), 0, BOTTOM_BORDER | CONVERT_TWIPS },
498 {OUString(SC_UNONAME_CELLBACK), ATTR_BACKGROUND, cppu::UnoType<sal_Int32>::get(), 0, MID_BACK_COLOR },
499 {OUString(SC_UNONAME_CELLPRO), ATTR_PROTECTION, cppu::UnoType<util::CellProtection>::get(), 0, 0 },
500 {OUString(SC_UNONAME_CELLSTYL), SC_WID_UNO_CELLSTYL,cppu::UnoType<OUString>::get(), 0, 0 },
501 {OUString(SC_UNONAME_CCOLOR), ATTR_FONT_COLOR, cppu::UnoType<sal_Int32>::get(), 0, 0 },
502 {OUString(SC_UNONAME_COUTL), ATTR_FONT_CONTOUR, cppu::UnoType<bool>::get(), 0, 0 },
503 {OUString(SC_UNONAME_CCROSS), ATTR_FONT_CROSSEDOUT,cppu::UnoType<bool>::get(), 0, MID_CROSSED_OUT },
504 {OUString(SC_UNONAME_CEMPHAS), ATTR_FONT_EMPHASISMARK,cppu::UnoType<sal_Int16>::get(), 0, MID_EMPHASIS },
505 {OUString(SC_UNONAME_CFONT), ATTR_FONT, cppu::UnoType<sal_Int16>::get(), 0, MID_FONT_FAMILY },
506 {OUString(SC_UNONAME_CFCHARS), ATTR_FONT, cppu::UnoType<sal_Int16>::get(), 0, MID_FONT_CHAR_SET },
507 {OUString(SC_UNO_CJK_CFCHARS), ATTR_CJK_FONT, cppu::UnoType<sal_Int16>::get(), 0, MID_FONT_CHAR_SET },
508 {OUString(SC_UNO_CTL_CFCHARS), ATTR_CTL_FONT, cppu::UnoType<sal_Int16>::get(), 0, MID_FONT_CHAR_SET },
509 {OUString(SC_UNONAME_CFFAMIL), ATTR_FONT, cppu::UnoType<sal_Int16>::get(), 0, MID_FONT_FAMILY },
510 {OUString(SC_UNO_CJK_CFFAMIL), ATTR_CJK_FONT, cppu::UnoType<sal_Int16>::get(), 0, MID_FONT_FAMILY },
511 {OUString(SC_UNO_CTL_CFFAMIL), ATTR_CTL_FONT, cppu::UnoType<sal_Int16>::get(), 0, MID_FONT_FAMILY },
512 {OUString(SC_UNONAME_CFNAME), ATTR_FONT, cppu::UnoType<OUString>::get(), 0, MID_FONT_FAMILY_NAME },
513 {OUString(SC_UNO_CJK_CFNAME), ATTR_CJK_FONT, cppu::UnoType<OUString>::get(), 0, MID_FONT_FAMILY_NAME },
514 {OUString(SC_UNO_CTL_CFNAME), ATTR_CTL_FONT, cppu::UnoType<OUString>::get(), 0, MID_FONT_FAMILY_NAME },
515 {OUString(SC_UNONAME_CFPITCH), ATTR_FONT, cppu::UnoType<sal_Int16>::get(), 0, MID_FONT_PITCH },
516 {OUString(SC_UNO_CJK_CFPITCH), ATTR_CJK_FONT, cppu::UnoType<sal_Int16>::get(), 0, MID_FONT_PITCH },
517 {OUString(SC_UNO_CTL_CFPITCH), ATTR_CTL_FONT, cppu::UnoType<sal_Int16>::get(), 0, MID_FONT_PITCH },
518 {OUString(SC_UNONAME_CFSTYLE), ATTR_FONT, cppu::UnoType<OUString>::get(), 0, MID_FONT_STYLE_NAME },
519 {OUString(SC_UNO_CJK_CFSTYLE), ATTR_CJK_FONT, cppu::UnoType<OUString>::get(), 0, MID_FONT_STYLE_NAME },
520 {OUString(SC_UNO_CTL_CFSTYLE), ATTR_CTL_FONT, cppu::UnoType<OUString>::get(), 0, MID_FONT_STYLE_NAME },
521 {OUString(SC_UNONAME_CHEIGHT), ATTR_FONT_HEIGHT, cppu::UnoType<float>::get(), 0, MID_FONTHEIGHT | CONVERT_TWIPS },
522 {OUString(SC_UNO_CJK_CHEIGHT), ATTR_CJK_FONT_HEIGHT,cppu::UnoType<float>::get(), 0, MID_FONTHEIGHT | CONVERT_TWIPS },
523 {OUString(SC_UNO_CTL_CHEIGHT), ATTR_CTL_FONT_HEIGHT,cppu::UnoType<float>::get(), 0, MID_FONTHEIGHT | CONVERT_TWIPS },
524 {OUString(SC_UNONAME_CLOCAL), ATTR_FONT_LANGUAGE, cppu::UnoType<lang::Locale>::get(), 0, MID_LANG_LOCALE },
525 {OUString(SC_UNO_CJK_CLOCAL), ATTR_CJK_FONT_LANGUAGE,cppu::UnoType<lang::Locale>::get(), 0, MID_LANG_LOCALE },
526 {OUString(SC_UNO_CTL_CLOCAL), ATTR_CTL_FONT_LANGUAGE,cppu::UnoType<lang::Locale>::get(), 0, MID_LANG_LOCALE },
527 {OUString(SC_UNONAME_COVER), ATTR_FONT_OVERLINE, cppu::UnoType<sal_Int16>::get(), 0, MID_TL_STYLE },
528 {OUString(SC_UNONAME_COVRLCOL), ATTR_FONT_OVERLINE, cppu::UnoType<sal_Int32>::get(), 0, MID_TL_COLOR },
529 {OUString(SC_UNONAME_COVRLHAS), ATTR_FONT_OVERLINE, cppu::UnoType<bool>::get(), 0, MID_TL_HASCOLOR },
530 {OUString(SC_UNONAME_CPOST), ATTR_FONT_POSTURE, cppu::UnoType<awt::FontSlant>::get(), 0, MID_POSTURE },
531 {OUString(SC_UNO_CJK_CPOST), ATTR_CJK_FONT_POSTURE,cppu::UnoType<awt::FontSlant>::get(), 0, MID_POSTURE },
532 {OUString(SC_UNO_CTL_CPOST), ATTR_CTL_FONT_POSTURE,cppu::UnoType<awt::FontSlant>::get(), 0, MID_POSTURE },
533 {OUString(SC_UNONAME_CRELIEF), ATTR_FONT_RELIEF, cppu::UnoType<sal_Int16>::get(), 0, MID_RELIEF },
534 {OUString(SC_UNONAME_CSHADD), ATTR_FONT_SHADOWED, cppu::UnoType<bool>::get(), 0, 0 },
535 {OUString(SC_UNONAME_CSTRIKE), ATTR_FONT_CROSSEDOUT,cppu::UnoType<sal_Int16>::get(), 0, MID_CROSS_OUT },
536 {OUString(SC_UNONAME_CUNDER), ATTR_FONT_UNDERLINE,cppu::UnoType<sal_Int16>::get(), 0, MID_TL_STYLE },
537 {OUString(SC_UNONAME_CUNDLCOL), ATTR_FONT_UNDERLINE,cppu::UnoType<sal_Int32>::get(), 0, MID_TL_COLOR },
538 {OUString(SC_UNONAME_CUNDLHAS), ATTR_FONT_UNDERLINE,cppu::UnoType<bool>::get(), 0, MID_TL_HASCOLOR },
539 {OUString(SC_UNONAME_CWEIGHT), ATTR_FONT_WEIGHT, cppu::UnoType<float>::get(), 0, MID_WEIGHT },
540 {OUString(SC_UNO_CJK_CWEIGHT), ATTR_CJK_FONT_WEIGHT,cppu::UnoType<float>::get(), 0, MID_WEIGHT },
541 {OUString(SC_UNO_CTL_CWEIGHT), ATTR_CTL_FONT_WEIGHT,cppu::UnoType<float>::get(), 0, MID_WEIGHT },
542 {OUString(SC_UNONAME_CWORDMOD), ATTR_FONT_WORDLINE, cppu::UnoType<bool>::get(), 0, 0 },
543 {OUString(SC_UNONAME_CHCOLHDR), SC_WID_UNO_CHCOLHDR,cppu::UnoType<bool>::get(), 0, 0 },
544 {OUString(SC_UNONAME_CHROWHDR), SC_WID_UNO_CHROWHDR,cppu::UnoType<bool>::get(), 0, 0 },
545 {OUString(SC_UNONAME_CONDFMT), SC_WID_UNO_CONDFMT, cppu::UnoType<sheet::XSheetConditionalEntries>::get(), 0, 0 },
546 {OUString(SC_UNONAME_CONDLOC), SC_WID_UNO_CONDLOC, cppu::UnoType<sheet::XSheetConditionalEntries>::get(), 0, 0 },
547 {OUString(SC_UNONAME_CONDXML), SC_WID_UNO_CONDXML, cppu::UnoType<sheet::XSheetConditionalEntries>::get(), 0, 0 },
548 {OUString(SC_UNONAME_DIAGONAL_BLTR), ATTR_BORDER_BLTR, ::cppu::UnoType<table::BorderLine>::get(), 0, 0 | CONVERT_TWIPS },
549 {OUString(SC_UNONAME_DIAGONAL_BLTR2), ATTR_BORDER_BLTR, ::cppu::UnoType<table::BorderLine2>::get(), 0, 0 | CONVERT_TWIPS },
550 {OUString(SC_UNONAME_DIAGONAL_TLBR), ATTR_BORDER_TLBR, ::cppu::UnoType<table::BorderLine>::get(), 0, 0 | CONVERT_TWIPS },
551 {OUString(SC_UNONAME_DIAGONAL_TLBR2), ATTR_BORDER_TLBR, ::cppu::UnoType<table::BorderLine2>::get(), 0, 0 | CONVERT_TWIPS },
552 {OUString(SC_UNONAME_CELLHJUS), ATTR_HOR_JUSTIFY, cppu::UnoType<table::CellHoriJustify>::get(), 0, MID_HORJUST_HORJUST },
553 {OUString(SC_UNONAME_CELLHJUS_METHOD), ATTR_HOR_JUSTIFY_METHOD, ::cppu::UnoType<sal_Int32>::get(), 0, 0 },
554 {OUString(SC_UNONAME_CELLTRAN), ATTR_BACKGROUND, cppu::UnoType<bool>::get(), 0, MID_GRAPHIC_TRANSPARENT },
555 {OUString(SC_UNONAME_MANPAGE), SC_WID_UNO_MANPAGE, cppu::UnoType<bool>::get(), 0, 0 },
556 {OUString(SC_UNONAME_NEWPAGE), SC_WID_UNO_NEWPAGE, cppu::UnoType<bool>::get(), 0, 0 },
557 {OUString(SC_UNONAME_WRAP), ATTR_LINEBREAK, cppu::UnoType<bool>::get(), 0, 0 },
558 {OUString(SC_UNONAME_CELLVIS), SC_WID_UNO_CELLVIS, cppu::UnoType<bool>::get(), 0, 0 },
559 {OUString(SC_UNONAME_LEFTBORDER),ATTR_BORDER, ::cppu::UnoType<table::BorderLine>::get(), 0, LEFT_BORDER | CONVERT_TWIPS },
560 {OUString(SC_UNONAME_LEFTBORDER2),ATTR_BORDER, ::cppu::UnoType<table::BorderLine2>::get(), 0, LEFT_BORDER | CONVERT_TWIPS },
561 {OUString(SC_UNONAME_NUMFMT), ATTR_VALUE_FORMAT, cppu::UnoType<sal_Int32>::get(), 0, 0 },
562 {OUString(SC_UNONAME_NUMRULES), SC_WID_UNO_NUMRULES,cppu::UnoType<container::XIndexReplace>::get(), 0, 0 },
563 {OUString(SC_UNONAME_OWIDTH), SC_WID_UNO_OWIDTH, cppu::UnoType<bool>::get(), 0, 0 },
564 {OUString(SC_UNONAME_CELLORI), ATTR_STACKED, cppu::UnoType<table::CellOrientation>::get(), 0, 0 },
565 {OUString(SC_UNONAME_PADJUST), ATTR_HOR_JUSTIFY, ::cppu::UnoType<sal_Int16>::get(), 0, MID_HORJUST_ADJUST },
566 {OUString(SC_UNONAME_PBMARGIN), ATTR_MARGIN, cppu::UnoType<sal_Int32>::get(), 0, MID_MARGIN_LO_MARGIN | CONVERT_TWIPS },
567 {OUString(SC_UNONAME_PINDENT), ATTR_INDENT, cppu::UnoType<sal_Int16>::get(), 0, 0 }, //! CONVERT_TWIPS
568 {OUString(SC_UNONAME_PISCHDIST),ATTR_SCRIPTSPACE, cppu::UnoType<bool>::get(), 0, 0 },
569 {OUString(SC_UNONAME_PISFORBID),ATTR_FORBIDDEN_RULES,cppu::UnoType<bool>::get(), 0, 0 },
570 {OUString(SC_UNONAME_PISHANG), ATTR_HANGPUNCTUATION,cppu::UnoType<bool>::get(), 0, 0 },
571 {OUString(SC_UNONAME_PISHYPHEN),ATTR_HYPHENATE, cppu::UnoType<bool>::get(), 0, 0 },
572 {OUString(SC_UNONAME_PLASTADJ), ATTR_HOR_JUSTIFY, ::cppu::UnoType<sal_Int16>::get(), 0, MID_HORJUST_ADJUST },
573 {OUString(SC_UNONAME_PLMARGIN), ATTR_MARGIN, cppu::UnoType<sal_Int32>::get(), 0, MID_MARGIN_L_MARGIN | CONVERT_TWIPS },
574 {OUString(SC_UNONAME_PRMARGIN), ATTR_MARGIN, cppu::UnoType<sal_Int32>::get(), 0, MID_MARGIN_R_MARGIN | CONVERT_TWIPS },
575 {OUString(SC_UNONAME_PTMARGIN), ATTR_MARGIN, cppu::UnoType<sal_Int32>::get(), 0, MID_MARGIN_UP_MARGIN | CONVERT_TWIPS },
576 {OUString(SC_UNONAME_POS), SC_WID_UNO_POS, cppu::UnoType<awt::Point>::get(), 0 | beans::PropertyAttribute::READONLY, 0 },
577 {OUString(SC_UNONAME_RIGHTBORDER),ATTR_BORDER, ::cppu::UnoType<table::BorderLine>::get(), 0, RIGHT_BORDER | CONVERT_TWIPS },
578 {OUString(SC_UNONAME_RIGHTBORDER2),ATTR_BORDER, ::cppu::UnoType<table::BorderLine2>::get(), 0, RIGHT_BORDER | CONVERT_TWIPS },
579 {OUString(SC_UNONAME_ROTANG), ATTR_ROTATE_VALUE, cppu::UnoType<sal_Int32>::get(), 0, 0 },
580 {OUString(SC_UNONAME_ROTREF), ATTR_ROTATE_MODE, cppu::UnoType<sal_Int32>::get(), 0, 0 },
581 {OUString(SC_UNONAME_SHADOW), ATTR_SHADOW, cppu::UnoType<table::ShadowFormat>::get(), 0, 0 | CONVERT_TWIPS },
582 {OUString(SC_UNONAME_SHRINK_TO_FIT), ATTR_SHRINKTOFIT, cppu::UnoType<bool>::get(), 0, 0 },
583 {OUString(SC_UNONAME_SIZE), SC_WID_UNO_SIZE, cppu::UnoType<awt::Size>::get(), 0 | beans::PropertyAttribute::READONLY, 0 },
584 {OUString(SC_UNONAME_TBLBORD), SC_WID_UNO_TBLBORD, cppu::UnoType<table::TableBorder>::get(), 0, 0 | CONVERT_TWIPS },
585 {OUString(SC_UNONAME_TBLBORD2), SC_WID_UNO_TBLBORD2, cppu::UnoType<table::TableBorder2>::get(), 0, 0 | CONVERT_TWIPS },
586 {OUString(SC_UNONAME_TOPBORDER),ATTR_BORDER, ::cppu::UnoType<table::BorderLine>::get(), 0, TOP_BORDER | CONVERT_TWIPS },
587 {OUString(SC_UNONAME_TOPBORDER2),ATTR_BORDER, ::cppu::UnoType<table::BorderLine2>::get(), 0, TOP_BORDER | CONVERT_TWIPS },
588 {OUString(SC_UNONAME_USERDEF), ATTR_USERDEF, cppu::UnoType<container::XNameContainer>::get(), 0, 0 },
589 {OUString(SC_UNONAME_VALIDAT), SC_WID_UNO_VALIDAT, cppu::UnoType<beans::XPropertySet>::get(), 0, 0 },
590 {OUString(SC_UNONAME_VALILOC), SC_WID_UNO_VALILOC, cppu::UnoType<beans::XPropertySet>::get(), 0, 0 },
591 {OUString(SC_UNONAME_VALIXML), SC_WID_UNO_VALIXML, cppu::UnoType<beans::XPropertySet>::get(), 0, 0 },
592 {OUString(SC_UNONAME_CELLVJUS), ATTR_VER_JUSTIFY, cppu::UnoType<sal_Int32>::get(), 0, 0 },
593 {OUString(SC_UNONAME_CELLVJUS_METHOD), ATTR_VER_JUSTIFY_METHOD, ::cppu::UnoType<sal_Int32>::get(), 0, 0 },
594 {OUString(SC_UNONAME_CELLWID), SC_WID_UNO_CELLWID, cppu::UnoType<sal_Int32>::get(), 0, 0 },
595 {OUString(SC_UNONAME_WRITING), ATTR_WRITINGDIR, cppu::UnoType<sal_Int16>::get(), 0, 0 },
596 { OUString(), 0, css::uno::Type(), 0, 0 }
598 static SfxItemPropertySet aColumnPropertySet( aColumnPropertyMap_Impl );
599 return &aColumnPropertySet;
602 static const SfxItemPropertySet* lcl_GetRowPropertySet()
604 static const SfxItemPropertyMapEntry aRowPropertyMap_Impl[] =
606 {OUString(SC_UNONAME_ABSNAME), SC_WID_UNO_ABSNAME, cppu::UnoType<OUString>::get(), 0 | beans::PropertyAttribute::READONLY, 0 },
607 {OUString(SC_UNONAME_ASIANVERT),ATTR_VERTICAL_ASIAN,cppu::UnoType<bool>::get(), 0, 0 },
608 {OUString(SC_UNONAME_BOTTBORDER),ATTR_BORDER, ::cppu::UnoType<table::BorderLine>::get(), 0, BOTTOM_BORDER | CONVERT_TWIPS },
609 {OUString(SC_UNONAME_BOTTBORDER2),ATTR_BORDER, ::cppu::UnoType<table::BorderLine2>::get(), 0, BOTTOM_BORDER | CONVERT_TWIPS },
610 {OUString(SC_UNONAME_CELLBACK), ATTR_BACKGROUND, cppu::UnoType<sal_Int32>::get(), 0, MID_BACK_COLOR },
611 {OUString(SC_UNONAME_CELLPRO), ATTR_PROTECTION, cppu::UnoType<util::CellProtection>::get(), 0, 0 },
612 {OUString(SC_UNONAME_CELLSTYL), SC_WID_UNO_CELLSTYL,cppu::UnoType<OUString>::get(), 0, 0 },
613 {OUString(SC_UNONAME_CCOLOR), ATTR_FONT_COLOR, cppu::UnoType<sal_Int32>::get(), 0, 0 },
614 {OUString(SC_UNONAME_COUTL), ATTR_FONT_CONTOUR, cppu::UnoType<bool>::get(), 0, 0 },
615 {OUString(SC_UNONAME_CCROSS), ATTR_FONT_CROSSEDOUT,cppu::UnoType<bool>::get(), 0, MID_CROSSED_OUT },
616 {OUString(SC_UNONAME_CEMPHAS), ATTR_FONT_EMPHASISMARK,cppu::UnoType<sal_Int16>::get(), 0, MID_EMPHASIS },
617 {OUString(SC_UNONAME_CFONT), ATTR_FONT, cppu::UnoType<sal_Int16>::get(), 0, MID_FONT_FAMILY },
618 {OUString(SC_UNONAME_CFCHARS), ATTR_FONT, cppu::UnoType<sal_Int16>::get(), 0, MID_FONT_CHAR_SET },
619 {OUString(SC_UNO_CJK_CFCHARS), ATTR_CJK_FONT, cppu::UnoType<sal_Int16>::get(), 0, MID_FONT_CHAR_SET },
620 {OUString(SC_UNO_CTL_CFCHARS), ATTR_CTL_FONT, cppu::UnoType<sal_Int16>::get(), 0, MID_FONT_CHAR_SET },
621 {OUString(SC_UNONAME_CFFAMIL), ATTR_FONT, cppu::UnoType<sal_Int16>::get(), 0, MID_FONT_FAMILY },
622 {OUString(SC_UNO_CJK_CFFAMIL), ATTR_CJK_FONT, cppu::UnoType<sal_Int16>::get(), 0, MID_FONT_FAMILY },
623 {OUString(SC_UNO_CTL_CFFAMIL), ATTR_CTL_FONT, cppu::UnoType<sal_Int16>::get(), 0, MID_FONT_FAMILY },
624 {OUString(SC_UNONAME_CFNAME), ATTR_FONT, cppu::UnoType<OUString>::get(), 0, MID_FONT_FAMILY_NAME },
625 {OUString(SC_UNO_CJK_CFNAME), ATTR_CJK_FONT, cppu::UnoType<OUString>::get(), 0, MID_FONT_FAMILY_NAME },
626 {OUString(SC_UNO_CTL_CFNAME), ATTR_CTL_FONT, cppu::UnoType<OUString>::get(), 0, MID_FONT_FAMILY_NAME },
627 {OUString(SC_UNONAME_CFPITCH), ATTR_FONT, cppu::UnoType<sal_Int16>::get(), 0, MID_FONT_PITCH },
628 {OUString(SC_UNO_CJK_CFPITCH), ATTR_CJK_FONT, cppu::UnoType<sal_Int16>::get(), 0, MID_FONT_PITCH },
629 {OUString(SC_UNO_CTL_CFPITCH), ATTR_CTL_FONT, cppu::UnoType<sal_Int16>::get(), 0, MID_FONT_PITCH },
630 {OUString(SC_UNONAME_CFSTYLE), ATTR_FONT, cppu::UnoType<OUString>::get(), 0, MID_FONT_STYLE_NAME },
631 {OUString(SC_UNO_CJK_CFSTYLE), ATTR_CJK_FONT, cppu::UnoType<OUString>::get(), 0, MID_FONT_STYLE_NAME },
632 {OUString(SC_UNO_CTL_CFSTYLE), ATTR_CTL_FONT, cppu::UnoType<OUString>::get(), 0, MID_FONT_STYLE_NAME },
633 {OUString(SC_UNONAME_CHEIGHT), ATTR_FONT_HEIGHT, cppu::UnoType<float>::get(), 0, MID_FONTHEIGHT | CONVERT_TWIPS },
634 {OUString(SC_UNO_CJK_CHEIGHT), ATTR_CJK_FONT_HEIGHT,cppu::UnoType<float>::get(), 0, MID_FONTHEIGHT | CONVERT_TWIPS },
635 {OUString(SC_UNO_CTL_CHEIGHT), ATTR_CTL_FONT_HEIGHT,cppu::UnoType<float>::get(), 0, MID_FONTHEIGHT | CONVERT_TWIPS },
636 {OUString(SC_UNONAME_CLOCAL), ATTR_FONT_LANGUAGE, cppu::UnoType<lang::Locale>::get(), 0, MID_LANG_LOCALE },
637 {OUString(SC_UNO_CJK_CLOCAL), ATTR_CJK_FONT_LANGUAGE,cppu::UnoType<lang::Locale>::get(), 0, MID_LANG_LOCALE },
638 {OUString(SC_UNO_CTL_CLOCAL), ATTR_CTL_FONT_LANGUAGE,cppu::UnoType<lang::Locale>::get(), 0, MID_LANG_LOCALE },
639 {OUString(SC_UNONAME_COVER), ATTR_FONT_OVERLINE, cppu::UnoType<sal_Int16>::get(), 0, MID_TL_STYLE },
640 {OUString(SC_UNONAME_COVRLCOL), ATTR_FONT_OVERLINE, cppu::UnoType<sal_Int32>::get(), 0, MID_TL_COLOR },
641 {OUString(SC_UNONAME_COVRLHAS), ATTR_FONT_OVERLINE, cppu::UnoType<bool>::get(), 0, MID_TL_HASCOLOR },
642 {OUString(SC_UNONAME_CPOST), ATTR_FONT_POSTURE, cppu::UnoType<awt::FontSlant>::get(), 0, MID_POSTURE },
643 {OUString(SC_UNO_CJK_CPOST), ATTR_CJK_FONT_POSTURE,cppu::UnoType<awt::FontSlant>::get(), 0, MID_POSTURE },
644 {OUString(SC_UNO_CTL_CPOST), ATTR_CTL_FONT_POSTURE,cppu::UnoType<awt::FontSlant>::get(), 0, MID_POSTURE },
645 {OUString(SC_UNONAME_CRELIEF), ATTR_FONT_RELIEF, cppu::UnoType<sal_Int16>::get(), 0, MID_RELIEF },
646 {OUString(SC_UNONAME_CSHADD), ATTR_FONT_SHADOWED, cppu::UnoType<bool>::get(), 0, 0 },
647 {OUString(SC_UNONAME_CSTRIKE), ATTR_FONT_CROSSEDOUT,cppu::UnoType<sal_Int16>::get(), 0, MID_CROSS_OUT },
648 {OUString(SC_UNONAME_CUNDER), ATTR_FONT_UNDERLINE,cppu::UnoType<sal_Int16>::get(), 0, MID_TL_STYLE },
649 {OUString(SC_UNONAME_CUNDLCOL), ATTR_FONT_UNDERLINE,cppu::UnoType<sal_Int32>::get(), 0, MID_TL_COLOR },
650 {OUString(SC_UNONAME_CUNDLHAS), ATTR_FONT_UNDERLINE,cppu::UnoType<bool>::get(), 0, MID_TL_HASCOLOR },
651 {OUString(SC_UNONAME_CWEIGHT), ATTR_FONT_WEIGHT, cppu::UnoType<float>::get(), 0, MID_WEIGHT },
652 {OUString(SC_UNO_CJK_CWEIGHT), ATTR_CJK_FONT_WEIGHT,cppu::UnoType<float>::get(), 0, MID_WEIGHT },
653 {OUString(SC_UNO_CTL_CWEIGHT), ATTR_CTL_FONT_WEIGHT,cppu::UnoType<float>::get(), 0, MID_WEIGHT },
654 {OUString(SC_UNONAME_CWORDMOD), ATTR_FONT_WORDLINE, cppu::UnoType<bool>::get(), 0, 0 },
655 {OUString(SC_UNONAME_CHCOLHDR), SC_WID_UNO_CHCOLHDR,cppu::UnoType<bool>::get(), 0, 0 },
656 {OUString(SC_UNONAME_CHROWHDR), SC_WID_UNO_CHROWHDR,cppu::UnoType<bool>::get(), 0, 0 },
657 {OUString(SC_UNONAME_CONDFMT), SC_WID_UNO_CONDFMT, cppu::UnoType<sheet::XSheetConditionalEntries>::get(), 0, 0 },
658 {OUString(SC_UNONAME_CONDLOC), SC_WID_UNO_CONDLOC, cppu::UnoType<sheet::XSheetConditionalEntries>::get(), 0, 0 },
659 {OUString(SC_UNONAME_CONDXML), SC_WID_UNO_CONDXML, cppu::UnoType<sheet::XSheetConditionalEntries>::get(), 0, 0 },
660 {OUString(SC_UNONAME_DIAGONAL_BLTR), ATTR_BORDER_BLTR, ::cppu::UnoType<table::BorderLine>::get(), 0, 0 | CONVERT_TWIPS },
661 {OUString(SC_UNONAME_DIAGONAL_BLTR2), ATTR_BORDER_BLTR, ::cppu::UnoType<table::BorderLine2>::get(), 0, 0 | CONVERT_TWIPS },
662 {OUString(SC_UNONAME_DIAGONAL_TLBR), ATTR_BORDER_TLBR, ::cppu::UnoType<table::BorderLine>::get(), 0, 0 | CONVERT_TWIPS },
663 {OUString(SC_UNONAME_DIAGONAL_TLBR2), ATTR_BORDER_TLBR, ::cppu::UnoType<table::BorderLine2>::get(), 0, 0 | CONVERT_TWIPS },
664 {OUString(SC_UNONAME_CELLHGT), SC_WID_UNO_CELLHGT, cppu::UnoType<sal_Int32>::get(), 0, 0 },
665 {OUString(SC_UNONAME_CELLHJUS), ATTR_HOR_JUSTIFY, cppu::UnoType<table::CellHoriJustify>::get(), 0, MID_HORJUST_HORJUST },
666 {OUString(SC_UNONAME_CELLHJUS_METHOD), ATTR_HOR_JUSTIFY_METHOD, ::cppu::UnoType<sal_Int32>::get(), 0, 0 },
667 {OUString(SC_UNONAME_CELLTRAN), ATTR_BACKGROUND, cppu::UnoType<bool>::get(), 0, MID_GRAPHIC_TRANSPARENT },
668 {OUString(SC_UNONAME_CELLFILT), SC_WID_UNO_CELLFILT,cppu::UnoType<bool>::get(), 0, 0 },
669 {OUString(SC_UNONAME_MANPAGE), SC_WID_UNO_MANPAGE, cppu::UnoType<bool>::get(), 0, 0 },
670 {OUString(SC_UNONAME_NEWPAGE), SC_WID_UNO_NEWPAGE, cppu::UnoType<bool>::get(), 0, 0 },
671 {OUString(SC_UNONAME_WRAP), ATTR_LINEBREAK, cppu::UnoType<bool>::get(), 0, 0 },
672 {OUString(SC_UNONAME_CELLVIS), SC_WID_UNO_CELLVIS, cppu::UnoType<bool>::get(), 0, 0 },
673 {OUString(SC_UNONAME_LEFTBORDER),ATTR_BORDER, ::cppu::UnoType<table::BorderLine>::get(), 0, LEFT_BORDER | CONVERT_TWIPS },
674 {OUString(SC_UNONAME_LEFTBORDER2),ATTR_BORDER, ::cppu::UnoType<table::BorderLine2>::get(), 0, LEFT_BORDER | CONVERT_TWIPS },
675 {OUString(SC_UNONAME_NUMFMT), ATTR_VALUE_FORMAT, cppu::UnoType<sal_Int32>::get(), 0, 0 },
676 {OUString(SC_UNONAME_NUMRULES), SC_WID_UNO_NUMRULES,cppu::UnoType<container::XIndexReplace>::get(), 0, 0 },
677 {OUString(SC_UNONAME_OHEIGHT), SC_WID_UNO_OHEIGHT, cppu::UnoType<bool>::get(), 0, 0 },
678 {OUString(SC_UNONAME_CELLORI), ATTR_STACKED, cppu::UnoType<table::CellOrientation>::get(), 0, 0 },
679 {OUString(SC_UNONAME_PADJUST), ATTR_HOR_JUSTIFY, ::cppu::UnoType<sal_Int16>::get(), 0, MID_HORJUST_ADJUST },
680 {OUString(SC_UNONAME_PBMARGIN), ATTR_MARGIN, cppu::UnoType<sal_Int32>::get(), 0, MID_MARGIN_LO_MARGIN | CONVERT_TWIPS },
681 {OUString(SC_UNONAME_PINDENT), ATTR_INDENT, cppu::UnoType<sal_Int16>::get(), 0, 0 }, //! CONVERT_TWIPS
682 {OUString(SC_UNONAME_PISCHDIST),ATTR_SCRIPTSPACE, cppu::UnoType<bool>::get(), 0, 0 },
683 {OUString(SC_UNONAME_PISFORBID),ATTR_FORBIDDEN_RULES,cppu::UnoType<bool>::get(), 0, 0 },
684 {OUString(SC_UNONAME_PISHANG), ATTR_HANGPUNCTUATION,cppu::UnoType<bool>::get(), 0, 0 },
685 {OUString(SC_UNONAME_PISHYPHEN),ATTR_HYPHENATE, cppu::UnoType<bool>::get(), 0, 0 },
686 {OUString(SC_UNONAME_PLASTADJ), ATTR_HOR_JUSTIFY, ::cppu::UnoType<sal_Int16>::get(), 0, MID_HORJUST_ADJUST },
687 {OUString(SC_UNONAME_PLMARGIN), ATTR_MARGIN, cppu::UnoType<sal_Int32>::get(), 0, MID_MARGIN_L_MARGIN | CONVERT_TWIPS },
688 {OUString(SC_UNONAME_PRMARGIN), ATTR_MARGIN, cppu::UnoType<sal_Int32>::get(), 0, MID_MARGIN_R_MARGIN | CONVERT_TWIPS },
689 {OUString(SC_UNONAME_PTMARGIN), ATTR_MARGIN, cppu::UnoType<sal_Int32>::get(), 0, MID_MARGIN_UP_MARGIN | CONVERT_TWIPS },
690 {OUString(SC_UNONAME_POS), SC_WID_UNO_POS, cppu::UnoType<awt::Point>::get(), 0 | beans::PropertyAttribute::READONLY, 0 },
691 {OUString(SC_UNONAME_RIGHTBORDER),ATTR_BORDER, ::cppu::UnoType<table::BorderLine>::get(), 0, RIGHT_BORDER | CONVERT_TWIPS },
692 {OUString(SC_UNONAME_RIGHTBORDER2),ATTR_BORDER, ::cppu::UnoType<table::BorderLine2>::get(), 0, RIGHT_BORDER | CONVERT_TWIPS },
693 {OUString(SC_UNONAME_ROTANG), ATTR_ROTATE_VALUE, cppu::UnoType<sal_Int32>::get(), 0, 0 },
694 {OUString(SC_UNONAME_ROTREF), ATTR_ROTATE_MODE, cppu::UnoType<sal_Int32>::get(), 0, 0 },
695 {OUString(SC_UNONAME_SHADOW), ATTR_SHADOW, cppu::UnoType<table::ShadowFormat>::get(), 0, 0 | CONVERT_TWIPS },
696 {OUString(SC_UNONAME_SHRINK_TO_FIT), ATTR_SHRINKTOFIT, cppu::UnoType<bool>::get(), 0, 0 },
697 {OUString(SC_UNONAME_SIZE), SC_WID_UNO_SIZE, cppu::UnoType<awt::Size>::get(), 0 | beans::PropertyAttribute::READONLY, 0 },
698 {OUString(SC_UNONAME_TBLBORD), SC_WID_UNO_TBLBORD, cppu::UnoType<table::TableBorder>::get(), 0, 0 | CONVERT_TWIPS },
699 {OUString(SC_UNONAME_TBLBORD2), SC_WID_UNO_TBLBORD2, cppu::UnoType<table::TableBorder2>::get(), 0, 0 | CONVERT_TWIPS },
700 {OUString(SC_UNONAME_TOPBORDER),ATTR_BORDER, ::cppu::UnoType<table::BorderLine>::get(), 0, TOP_BORDER | CONVERT_TWIPS },
701 {OUString(SC_UNONAME_TOPBORDER2),ATTR_BORDER, ::cppu::UnoType<table::BorderLine2>::get(), 0, TOP_BORDER | CONVERT_TWIPS },
702 {OUString(SC_UNONAME_USERDEF), ATTR_USERDEF, cppu::UnoType<container::XNameContainer>::get(), 0, 0 },
703 {OUString(SC_UNONAME_VALIDAT), SC_WID_UNO_VALIDAT, cppu::UnoType<beans::XPropertySet>::get(), 0, 0 },
704 {OUString(SC_UNONAME_VALILOC), SC_WID_UNO_VALILOC, cppu::UnoType<beans::XPropertySet>::get(), 0, 0 },
705 {OUString(SC_UNONAME_VALIXML), SC_WID_UNO_VALIXML, cppu::UnoType<beans::XPropertySet>::get(), 0, 0 },
706 {OUString(SC_UNONAME_CELLVJUS), ATTR_VER_JUSTIFY, cppu::UnoType<sal_Int32>::get(), 0, 0 },
707 {OUString(SC_UNONAME_CELLVJUS_METHOD), ATTR_VER_JUSTIFY_METHOD, ::cppu::UnoType<sal_Int32>::get(), 0, 0 },
708 {OUString(SC_UNONAME_WRITING), ATTR_WRITINGDIR, cppu::UnoType<sal_Int16>::get(), 0, 0 },
709 { OUString(), 0, css::uno::Type(), 0, 0 }
711 static SfxItemPropertySet aRowPropertySet( aRowPropertyMap_Impl );
712 return &aRowPropertySet;
715 static const SfxItemPropertySet* lcl_GetSheetPropertySet()
717 static const SfxItemPropertyMapEntry aSheetPropertyMap_Impl[] =
719 {OUString(SC_UNONAME_ABSNAME), SC_WID_UNO_ABSNAME, cppu::UnoType<OUString>::get(), 0 | beans::PropertyAttribute::READONLY, 0 },
720 {OUString(SC_UNONAME_ASIANVERT),ATTR_VERTICAL_ASIAN,cppu::UnoType<bool>::get(), 0, 0 },
721 {OUString(SC_UNONAME_AUTOPRINT),SC_WID_UNO_AUTOPRINT,cppu::UnoType<bool>::get(), 0, 0 },
722 {OUString(SC_UNONAME_BORDCOL), SC_WID_UNO_BORDCOL, cppu::UnoType<sal_Int32>::get(), 0, 0 },
723 {OUString(SC_UNONAME_BOTTBORDER),ATTR_BORDER, ::cppu::UnoType<table::BorderLine>::get(), 0, BOTTOM_BORDER | CONVERT_TWIPS },
724 {OUString(SC_UNONAME_BOTTBORDER2),ATTR_BORDER, ::cppu::UnoType<table::BorderLine2>::get(), 0, BOTTOM_BORDER | CONVERT_TWIPS },
725 {OUString(SC_UNONAME_CELLBACK), ATTR_BACKGROUND, cppu::UnoType<sal_Int32>::get(), 0, MID_BACK_COLOR },
726 {OUString(SC_UNONAME_CELLPRO), ATTR_PROTECTION, cppu::UnoType<util::CellProtection>::get(), 0, 0 },
727 {OUString(SC_UNONAME_CELLSTYL), SC_WID_UNO_CELLSTYL,cppu::UnoType<OUString>::get(), 0, 0 },
728 {OUString(SC_UNONAME_CCOLOR), ATTR_FONT_COLOR, cppu::UnoType<sal_Int32>::get(), 0, 0 },
729 {OUString(SC_UNONAME_COUTL), ATTR_FONT_CONTOUR, cppu::UnoType<bool>::get(), 0, 0 },
730 {OUString(SC_UNONAME_CCROSS), ATTR_FONT_CROSSEDOUT,cppu::UnoType<bool>::get(), 0, MID_CROSSED_OUT },
731 {OUString(SC_UNONAME_CEMPHAS), ATTR_FONT_EMPHASISMARK,cppu::UnoType<sal_Int16>::get(), 0, MID_EMPHASIS },
732 {OUString(SC_UNONAME_CFONT), ATTR_FONT, cppu::UnoType<sal_Int16>::get(), 0, MID_FONT_FAMILY },
733 {OUString(SC_UNONAME_CFCHARS), ATTR_FONT, cppu::UnoType<sal_Int16>::get(), 0, MID_FONT_CHAR_SET },
734 {OUString(SC_UNO_CJK_CFCHARS), ATTR_CJK_FONT, cppu::UnoType<sal_Int16>::get(), 0, MID_FONT_CHAR_SET },
735 {OUString(SC_UNO_CTL_CFCHARS), ATTR_CTL_FONT, cppu::UnoType<sal_Int16>::get(), 0, MID_FONT_CHAR_SET },
736 {OUString(SC_UNONAME_CFFAMIL), ATTR_FONT, cppu::UnoType<sal_Int16>::get(), 0, MID_FONT_FAMILY },
737 {OUString(SC_UNO_CJK_CFFAMIL), ATTR_CJK_FONT, cppu::UnoType<sal_Int16>::get(), 0, MID_FONT_FAMILY },
738 {OUString(SC_UNO_CTL_CFFAMIL), ATTR_CTL_FONT, cppu::UnoType<sal_Int16>::get(), 0, MID_FONT_FAMILY },
739 {OUString(SC_UNONAME_CFNAME), ATTR_FONT, cppu::UnoType<OUString>::get(), 0, MID_FONT_FAMILY_NAME },
740 {OUString(SC_UNO_CJK_CFNAME), ATTR_CJK_FONT, cppu::UnoType<OUString>::get(), 0, MID_FONT_FAMILY_NAME },
741 {OUString(SC_UNO_CTL_CFNAME), ATTR_CTL_FONT, cppu::UnoType<OUString>::get(), 0, MID_FONT_FAMILY_NAME },
742 {OUString(SC_UNONAME_CFPITCH), ATTR_FONT, cppu::UnoType<sal_Int16>::get(), 0, MID_FONT_PITCH },
743 {OUString(SC_UNO_CJK_CFPITCH), ATTR_CJK_FONT, cppu::UnoType<sal_Int16>::get(), 0, MID_FONT_PITCH },
744 {OUString(SC_UNO_CTL_CFPITCH), ATTR_CTL_FONT, cppu::UnoType<sal_Int16>::get(), 0, MID_FONT_PITCH },
745 {OUString(SC_UNONAME_CFSTYLE), ATTR_FONT, cppu::UnoType<OUString>::get(), 0, MID_FONT_STYLE_NAME },
746 {OUString(SC_UNO_CJK_CFSTYLE), ATTR_CJK_FONT, cppu::UnoType<OUString>::get(), 0, MID_FONT_STYLE_NAME },
747 {OUString(SC_UNO_CTL_CFSTYLE), ATTR_CTL_FONT, cppu::UnoType<OUString>::get(), 0, MID_FONT_STYLE_NAME },
748 {OUString(SC_UNONAME_CHEIGHT), ATTR_FONT_HEIGHT, cppu::UnoType<float>::get(), 0, MID_FONTHEIGHT | CONVERT_TWIPS },
749 {OUString(SC_UNO_CJK_CHEIGHT), ATTR_CJK_FONT_HEIGHT,cppu::UnoType<float>::get(), 0, MID_FONTHEIGHT | CONVERT_TWIPS },
750 {OUString(SC_UNO_CTL_CHEIGHT), ATTR_CTL_FONT_HEIGHT,cppu::UnoType<float>::get(), 0, MID_FONTHEIGHT | CONVERT_TWIPS },
751 {OUString(SC_UNONAME_CLOCAL), ATTR_FONT_LANGUAGE, cppu::UnoType<lang::Locale>::get(), 0, MID_LANG_LOCALE },
752 {OUString(SC_UNO_CJK_CLOCAL), ATTR_CJK_FONT_LANGUAGE,cppu::UnoType<lang::Locale>::get(), 0, MID_LANG_LOCALE },
753 {OUString(SC_UNO_CTL_CLOCAL), ATTR_CTL_FONT_LANGUAGE,cppu::UnoType<lang::Locale>::get(), 0, MID_LANG_LOCALE },
754 {OUString(SC_UNONAME_COVER), ATTR_FONT_OVERLINE, cppu::UnoType<sal_Int16>::get(), 0, MID_TL_STYLE },
755 {OUString(SC_UNONAME_COVRLCOL), ATTR_FONT_OVERLINE, cppu::UnoType<sal_Int32>::get(), 0, MID_TL_COLOR },
756 {OUString(SC_UNONAME_COVRLHAS), ATTR_FONT_OVERLINE, cppu::UnoType<bool>::get(), 0, MID_TL_HASCOLOR },
757 {OUString(SC_UNONAME_CPOST), ATTR_FONT_POSTURE, cppu::UnoType<awt::FontSlant>::get(), 0, MID_POSTURE },
758 {OUString(SC_UNO_CJK_CPOST), ATTR_CJK_FONT_POSTURE,cppu::UnoType<awt::FontSlant>::get(), 0, MID_POSTURE },
759 {OUString(SC_UNO_CTL_CPOST), ATTR_CTL_FONT_POSTURE,cppu::UnoType<awt::FontSlant>::get(), 0, MID_POSTURE },
760 {OUString(SC_UNONAME_CRELIEF), ATTR_FONT_RELIEF, cppu::UnoType<sal_Int16>::get(), 0, MID_RELIEF },
761 {OUString(SC_UNONAME_CSHADD), ATTR_FONT_SHADOWED, cppu::UnoType<bool>::get(), 0, 0 },
762 {OUString(SC_UNONAME_CSTRIKE), ATTR_FONT_CROSSEDOUT,cppu::UnoType<sal_Int16>::get(), 0, MID_CROSS_OUT },
763 {OUString(SC_UNONAME_CUNDER), ATTR_FONT_UNDERLINE,cppu::UnoType<sal_Int16>::get(), 0, MID_TL_STYLE },
764 {OUString(SC_UNONAME_CUNDLCOL), ATTR_FONT_UNDERLINE,cppu::UnoType<sal_Int32>::get(), 0, MID_TL_COLOR },
765 {OUString(SC_UNONAME_CUNDLHAS), ATTR_FONT_UNDERLINE,cppu::UnoType<bool>::get(), 0, MID_TL_HASCOLOR },
766 {OUString(SC_UNONAME_CWEIGHT), ATTR_FONT_WEIGHT, cppu::UnoType<float>::get(), 0, MID_WEIGHT },
767 {OUString(SC_UNO_CJK_CWEIGHT), ATTR_CJK_FONT_WEIGHT,cppu::UnoType<float>::get(), 0, MID_WEIGHT },
768 {OUString(SC_UNO_CTL_CWEIGHT), ATTR_CTL_FONT_WEIGHT,cppu::UnoType<float>::get(), 0, MID_WEIGHT },
769 {OUString(SC_UNONAME_CWORDMOD), ATTR_FONT_WORDLINE, cppu::UnoType<bool>::get(), 0, 0 },
770 {OUString(SC_UNONAME_CHCOLHDR), SC_WID_UNO_CHCOLHDR,cppu::UnoType<bool>::get(), 0, 0 },
771 {OUString(SC_UNONAME_CHROWHDR), SC_WID_UNO_CHROWHDR,cppu::UnoType<bool>::get(), 0, 0 },
772 {OUString(SC_UNONAME_CONDFMT), SC_WID_UNO_CONDFMT, cppu::UnoType<sheet::XSheetConditionalEntries>::get(), 0, 0 },
773 {OUString(SC_UNONAME_CONDLOC), SC_WID_UNO_CONDLOC, cppu::UnoType<sheet::XSheetConditionalEntries>::get(), 0, 0 },
774 {OUString(SC_UNONAME_CONDXML), SC_WID_UNO_CONDXML, cppu::UnoType<sheet::XSheetConditionalEntries>::get(), 0, 0 },
775 {OUString(SC_UNONAME_COPYBACK), SC_WID_UNO_COPYBACK,cppu::UnoType<bool>::get(), 0, 0 },
776 {OUString(SC_UNONAME_COPYFORM), SC_WID_UNO_COPYFORM,cppu::UnoType<bool>::get(), 0, 0 },
777 {OUString(SC_UNONAME_COPYSTYL), SC_WID_UNO_COPYSTYL,cppu::UnoType<bool>::get(), 0, 0 },
778 {OUString(SC_UNONAME_DIAGONAL_BLTR), ATTR_BORDER_BLTR, ::cppu::UnoType<table::BorderLine>::get(), 0, 0 | CONVERT_TWIPS },
779 {OUString(SC_UNONAME_DIAGONAL_BLTR2), ATTR_BORDER_BLTR, ::cppu::UnoType<table::BorderLine2>::get(), 0, 0 | CONVERT_TWIPS },
780 {OUString(SC_UNONAME_DIAGONAL_TLBR), ATTR_BORDER_TLBR, ::cppu::UnoType<table::BorderLine>::get(), 0, 0 | CONVERT_TWIPS },
781 {OUString(SC_UNONAME_DIAGONAL_TLBR2), ATTR_BORDER_TLBR, ::cppu::UnoType<table::BorderLine2>::get(), 0, 0 | CONVERT_TWIPS },
782 {OUString(SC_UNONAME_CELLHJUS), ATTR_HOR_JUSTIFY, cppu::UnoType<table::CellHoriJustify>::get(), 0, MID_HORJUST_HORJUST },
783 {OUString(SC_UNONAME_CELLHJUS_METHOD), ATTR_HOR_JUSTIFY_METHOD, ::cppu::UnoType<sal_Int32>::get(), 0, 0 },
784 {OUString(SC_UNONAME_ISACTIVE), SC_WID_UNO_ISACTIVE,cppu::UnoType<bool>::get(), 0, 0 },
785 {OUString(SC_UNONAME_CELLTRAN), ATTR_BACKGROUND, cppu::UnoType<bool>::get(), 0, MID_GRAPHIC_TRANSPARENT },
786 {OUString(SC_UNONAME_WRAP), ATTR_LINEBREAK, cppu::UnoType<bool>::get(), 0, 0 },
787 {OUString(SC_UNONAME_CELLVIS), SC_WID_UNO_CELLVIS, cppu::UnoType<bool>::get(), 0, 0 },
788 {OUString(SC_UNONAME_LEFTBORDER),ATTR_BORDER, ::cppu::UnoType<table::BorderLine>::get(), 0, LEFT_BORDER | CONVERT_TWIPS },
789 {OUString(SC_UNONAME_LEFTBORDER2),ATTR_BORDER, ::cppu::UnoType<table::BorderLine2>::get(), 0, LEFT_BORDER | CONVERT_TWIPS },
790 {OUString(SC_UNO_LINKDISPBIT), SC_WID_UNO_LINKDISPBIT,cppu::UnoType<awt::XBitmap>::get(), 0 | beans::PropertyAttribute::READONLY, 0 },
791 {OUString(SC_UNO_LINKDISPNAME), SC_WID_UNO_LINKDISPNAME,cppu::UnoType<OUString>::get(), 0 | beans::PropertyAttribute::READONLY, 0 },
792 {OUString(SC_UNONAME_NUMFMT), ATTR_VALUE_FORMAT, cppu::UnoType<sal_Int32>::get(), 0, 0 },
793 {OUString(SC_UNONAME_NUMRULES), SC_WID_UNO_NUMRULES,cppu::UnoType<container::XIndexReplace>::get(), 0, 0 },
794 {OUString(SC_UNONAME_CELLORI), ATTR_STACKED, cppu::UnoType<table::CellOrientation>::get(), 0, 0 },
795 {OUString(SC_UNONAME_PAGESTL), SC_WID_UNO_PAGESTL, cppu::UnoType<OUString>::get(), 0, 0 },
796 {OUString(SC_UNONAME_PADJUST), ATTR_HOR_JUSTIFY, ::cppu::UnoType<sal_Int16>::get(), 0, MID_HORJUST_ADJUST },
797 {OUString(SC_UNONAME_PBMARGIN), ATTR_MARGIN, cppu::UnoType<sal_Int32>::get(), 0, MID_MARGIN_LO_MARGIN | CONVERT_TWIPS },
798 {OUString(SC_UNONAME_PINDENT), ATTR_INDENT, cppu::UnoType<sal_Int16>::get(), 0, 0 }, //! CONVERT_TWIPS
799 {OUString(SC_UNONAME_PISCHDIST),ATTR_SCRIPTSPACE, cppu::UnoType<bool>::get(), 0, 0 },
800 {OUString(SC_UNONAME_PISFORBID),ATTR_FORBIDDEN_RULES,cppu::UnoType<bool>::get(), 0, 0 },
801 {OUString(SC_UNONAME_PISHANG), ATTR_HANGPUNCTUATION,cppu::UnoType<bool>::get(), 0, 0 },
802 {OUString(SC_UNONAME_PISHYPHEN),ATTR_HYPHENATE, cppu::UnoType<bool>::get(), 0, 0 },
803 {OUString(SC_UNONAME_PLASTADJ), ATTR_HOR_JUSTIFY, ::cppu::UnoType<sal_Int16>::get(), 0, MID_HORJUST_ADJUST },
804 {OUString(SC_UNONAME_PLMARGIN), ATTR_MARGIN, cppu::UnoType<sal_Int32>::get(), 0, MID_MARGIN_L_MARGIN | CONVERT_TWIPS },
805 {OUString(SC_UNONAME_PRMARGIN), ATTR_MARGIN, cppu::UnoType<sal_Int32>::get(), 0, MID_MARGIN_R_MARGIN | CONVERT_TWIPS },
806 {OUString(SC_UNONAME_PTMARGIN), ATTR_MARGIN, cppu::UnoType<sal_Int32>::get(), 0, MID_MARGIN_UP_MARGIN | CONVERT_TWIPS },
807 {OUString(SC_UNONAME_POS), SC_WID_UNO_POS, cppu::UnoType<awt::Point>::get(), 0 | beans::PropertyAttribute::READONLY, 0 },
808 {OUString(SC_UNONAME_PRINTBORD),SC_WID_UNO_PRINTBORD,cppu::UnoType<bool>::get(), 0, 0 },
809 {OUString(SC_UNONAME_PROTECT), SC_WID_UNO_PROTECT, cppu::UnoType<bool>::get(), 0, 0 },
810 {OUString(SC_UNONAME_RIGHTBORDER),ATTR_BORDER, ::cppu::UnoType<table::BorderLine>::get(), 0, RIGHT_BORDER | CONVERT_TWIPS },
811 {OUString(SC_UNONAME_RIGHTBORDER2),ATTR_BORDER, ::cppu::UnoType<table::BorderLine2>::get(), 0, RIGHT_BORDER | CONVERT_TWIPS },
812 {OUString(SC_UNONAME_ROTANG), ATTR_ROTATE_VALUE, cppu::UnoType<sal_Int32>::get(), 0, 0 },
813 {OUString(SC_UNONAME_ROTREF), ATTR_ROTATE_MODE, cppu::UnoType<sal_Int32>::get(), 0, 0 },
814 {OUString(SC_UNONAME_SHADOW), ATTR_SHADOW, cppu::UnoType<table::ShadowFormat>::get(), 0, 0 | CONVERT_TWIPS },
815 {OUString(SC_UNONAME_SHOWBORD), SC_WID_UNO_SHOWBORD,cppu::UnoType<bool>::get(), 0, 0 },
816 {OUString(SC_UNONAME_SHRINK_TO_FIT), ATTR_SHRINKTOFIT, cppu::UnoType<bool>::get(), 0, 0 },
817 {OUString(SC_UNONAME_SIZE), SC_WID_UNO_SIZE, cppu::UnoType<awt::Size>::get(), 0 | beans::PropertyAttribute::READONLY, 0 },
818 {OUString(SC_UNONAME_TBLBORD), SC_WID_UNO_TBLBORD, cppu::UnoType<table::TableBorder>::get(), 0, 0 | CONVERT_TWIPS },
819 {OUString(SC_UNONAME_TBLBORD2), SC_WID_UNO_TBLBORD2, cppu::UnoType<table::TableBorder2>::get(), 0, 0 | CONVERT_TWIPS },
820 {OUString(SC_UNONAME_TABLAYOUT),SC_WID_UNO_TABLAYOUT,cppu::UnoType<sal_Int16>::get(), 0, 0 },
821 {OUString(SC_UNONAME_CONDFORMAT), SC_WID_UNO_CONDFORMAT, cppu::UnoType<sheet::XConditionalFormats>::get(), 0, 0},
822 {OUString(SC_UNONAME_TOPBORDER),ATTR_BORDER, ::cppu::UnoType<table::BorderLine>::get(), 0, TOP_BORDER | CONVERT_TWIPS },
823 {OUString(SC_UNONAME_TOPBORDER2),ATTR_BORDER, ::cppu::UnoType<table::BorderLine2>::get(), 0, TOP_BORDER | CONVERT_TWIPS },
824 {OUString(SC_UNONAME_USERDEF), ATTR_USERDEF, cppu::UnoType<container::XNameContainer>::get(), 0, 0 },
825 {OUString(SC_UNONAME_VALIDAT), SC_WID_UNO_VALIDAT, cppu::UnoType<beans::XPropertySet>::get(), 0, 0 },
826 {OUString(SC_UNONAME_VALILOC), SC_WID_UNO_VALILOC, cppu::UnoType<beans::XPropertySet>::get(), 0, 0 },
827 {OUString(SC_UNONAME_VALIXML), SC_WID_UNO_VALIXML, cppu::UnoType<beans::XPropertySet>::get(), 0, 0 },
828 {OUString(SC_UNONAME_CELLVJUS), ATTR_VER_JUSTIFY, cppu::UnoType<sal_Int32>::get(), 0, 0 },
829 {OUString(SC_UNONAME_CELLVJUS_METHOD), ATTR_VER_JUSTIFY_METHOD, ::cppu::UnoType<sal_Int32>::get(), 0, 0 },
830 {OUString(SC_UNONAME_WRITING), ATTR_WRITINGDIR, cppu::UnoType<sal_Int16>::get(), 0, 0 },
831 {OUString(SC_UNONAME_TABCOLOR), SC_WID_UNO_TABCOLOR, cppu::UnoType<sal_Int32>::get(), 0, 0 },
832 {OUString(SC_UNO_CODENAME), SC_WID_UNO_CODENAME, cppu::UnoType<OUString>::get(), 0, 0},
833 {OUString(SC_UNO_NAMEDRANGES), SC_WID_UNO_NAMES, cppu::UnoType<sheet::XNamedRanges>::get(), 0, 0 },
834 { OUString(), 0, css::uno::Type(), 0, 0 }
836 static SfxItemPropertySet aSheetPropertySet( aSheetPropertyMap_Impl );
837 return &aSheetPropertySet;
840 static const SfxItemPropertyMapEntry* lcl_GetEditPropertyMap()
842 static const SfxItemPropertyMapEntry aEditPropertyMap_Impl[] =
844 SVX_UNOEDIT_CHAR_PROPERTIES,
845 SVX_UNOEDIT_FONT_PROPERTIES,
846 SVX_UNOEDIT_PARA_PROPERTIES,
847 SVX_UNOEDIT_NUMBERING_PROPERTIE, // for completeness of service ParagraphProperties
848 {OUString(SC_UNONAME_TEXTUSER), EE_CHAR_XMLATTRIBS, cppu::UnoType<container::XNameContainer>::get(), 0, 0},
849 {OUString(SC_UNONAME_USERDEF), EE_PARA_XMLATTRIBS, cppu::UnoType<container::XNameContainer>::get(), 0, 0},
850 { OUString(), 0, css::uno::Type(), 0, 0 }
852 return aEditPropertyMap_Impl;
854 static const SvxItemPropertySet* lcl_GetEditPropertySet()
856 static SvxItemPropertySet aEditPropertySet( lcl_GetEditPropertyMap(), SdrObject::GetGlobalDrawObjectItemPool() );
857 return &aEditPropertySet;
860 using sc::HMMToTwips;
861 using sc::TwipsToHMM;
863 #define SCCHARPROPERTIES_SERVICE "com.sun.star.style.CharacterProperties"
864 #define SCPARAPROPERTIES_SERVICE "com.sun.star.style.ParagraphProperties"
865 #define SCCELLPROPERTIES_SERVICE "com.sun.star.table.CellProperties"
866 #define SCCELLRANGE_SERVICE "com.sun.star.table.CellRange"
867 #define SCCELL_SERVICE "com.sun.star.table.Cell"
868 #define SCSHEETCELLRANGES_SERVICE "com.sun.star.sheet.SheetCellRanges"
869 #define SCSHEETCELLRANGE_SERVICE "com.sun.star.sheet.SheetCellRange"
870 #define SCSPREADSHEET_SERVICE "com.sun.star.sheet.Spreadsheet"
871 #define SCSHEETCELL_SERVICE "com.sun.star.sheet.SheetCell"
873 SC_SIMPLE_SERVICE_INFO( ScCellFormatsEnumeration, "ScCellFormatsEnumeration", "com.sun.star.sheet.CellFormatRangesEnumeration" )
874 SC_SIMPLE_SERVICE_INFO( ScCellFormatsObj, "ScCellFormatsObj", "com.sun.star.sheet.CellFormatRanges" )
875 SC_SIMPLE_SERVICE_INFO( ScUniqueCellFormatsEnumeration, "ScUniqueCellFormatsEnumeration", "com.sun.star.sheet.UniqueCellFormatRangesEnumeration" )
876 SC_SIMPLE_SERVICE_INFO( ScUniqueCellFormatsObj, "ScUniqueCellFormatsObj", "com.sun.star.sheet.UniqueCellFormatRanges" )
877 SC_SIMPLE_SERVICE_INFO( ScCellRangesBase, "ScCellRangesBase", "stardiv.unknown" )
878 SC_SIMPLE_SERVICE_INFO( ScCellsEnumeration, "ScCellsEnumeration", "com.sun.star.sheet.CellsEnumeration" )
879 SC_SIMPLE_SERVICE_INFO( ScCellsObj, "ScCellsObj", "com.sun.star.sheet.Cells" )
880 SC_SIMPLE_SERVICE_INFO( ScTableColumnObj, "ScTableColumnObj", "com.sun.star.table.TableColumn" )
881 SC_SIMPLE_SERVICE_INFO( ScTableRowObj, "ScTableRowObj", "com.sun.star.table.TableRow" )
883 //! ScLinkListener in anderes File verschieben !!!
885 ScLinkListener::~ScLinkListener()
889 void ScLinkListener::Notify( const SfxHint& rHint )
891 aLink.Call( const_cast<SfxHint*>(&rHint) );
894 static void lcl_CopyProperties( beans::XPropertySet& rDest, beans::XPropertySet& rSource )
896 uno::Reference<beans::XPropertySetInfo> xInfo(rSource.getPropertySetInfo());
897 if (xInfo.is())
899 uno::Sequence<beans::Property> aSeq(xInfo->getProperties());
900 const beans::Property* pAry = aSeq.getConstArray();
901 sal_uLong nCount = aSeq.getLength();
902 for (sal_uLong i=0; i<nCount; i++)
904 OUString aName(pAry[i].Name);
905 rDest.setPropertyValue( aName, rSource.getPropertyValue( aName ) );
910 static SCTAB lcl_FirstTab( const ScRangeList& rRanges )
912 OSL_ENSURE(rRanges.size() >= 1, "was fuer Ranges ?!?!");
913 const ScRange* pFirst = rRanges[ 0 ];
914 if (pFirst)
915 return pFirst->aStart.Tab();
917 return 0; // soll nicht sein
920 static bool lcl_WholeSheet( const ScRangeList& rRanges )
922 if ( rRanges.size() == 1 )
924 const ScRange* pRange = rRanges[0];
925 if ( pRange && pRange->aStart.Col() == 0 && pRange->aEnd.Col() == MAXCOL &&
926 pRange->aStart.Row() == 0 && pRange->aEnd.Row() == MAXROW )
927 return true;
929 return false;
932 namespace {
933 template<typename BorderLineType>
934 const ::editeng::SvxBorderLine* lcl_getBorderLine(
935 ::editeng::SvxBorderLine& rLine, const BorderLineType& rStruct )
937 // Convert from 1/100mm to Twips.
938 if (!SvxBoxItem::LineToSvxLine( rStruct, rLine, true))
939 return NULL;
941 if ( rLine.GetOutWidth() || rLine.GetInWidth() || rLine.GetDistance() )
942 return &rLine;
943 else
944 return NULL;
948 const ::editeng::SvxBorderLine* ScHelperFunctions::GetBorderLine(
949 ::editeng::SvxBorderLine& rLine, const table::BorderLine& rStruct )
951 return lcl_getBorderLine( rLine, rStruct);
954 const ::editeng::SvxBorderLine* ScHelperFunctions::GetBorderLine(
955 ::editeng::SvxBorderLine& rLine, const table::BorderLine2& rStruct )
957 return lcl_getBorderLine( rLine, rStruct);
960 namespace {
961 template<typename TableBorderType>
962 void lcl_fillBoxItems( SvxBoxItem& rOuter, SvxBoxInfoItem& rInner, const TableBorderType& rBorder )
964 ::editeng::SvxBorderLine aLine;
965 rOuter.SetDistance( static_cast<sal_uInt16>(HMMToTwips( rBorder.Distance )) );
966 rOuter.SetLine( ScHelperFunctions::GetBorderLine( aLine, rBorder.TopLine ), SvxBoxItemLine::TOP );
967 rOuter.SetLine( ScHelperFunctions::GetBorderLine( aLine, rBorder.BottomLine ), SvxBoxItemLine::BOTTOM );
968 rOuter.SetLine( ScHelperFunctions::GetBorderLine( aLine, rBorder.LeftLine ), SvxBoxItemLine::LEFT );
969 rOuter.SetLine( ScHelperFunctions::GetBorderLine( aLine, rBorder.RightLine ), SvxBoxItemLine::RIGHT );
970 rInner.SetLine( ScHelperFunctions::GetBorderLine( aLine, rBorder.HorizontalLine ), SvxBoxInfoItemLine::HORI );
971 rInner.SetLine( ScHelperFunctions::GetBorderLine( aLine, rBorder.VerticalLine ), SvxBoxInfoItemLine::VERT );
972 rInner.SetValid( SvxBoxInfoItemValidFlags::TOP, rBorder.IsTopLineValid );
973 rInner.SetValid( SvxBoxInfoItemValidFlags::BOTTOM, rBorder.IsBottomLineValid );
974 rInner.SetValid( SvxBoxInfoItemValidFlags::LEFT, rBorder.IsLeftLineValid );
975 rInner.SetValid( SvxBoxInfoItemValidFlags::RIGHT, rBorder.IsRightLineValid );
976 rInner.SetValid( SvxBoxInfoItemValidFlags::HORI, rBorder.IsHorizontalLineValid );
977 rInner.SetValid( SvxBoxInfoItemValidFlags::VERT, rBorder.IsVerticalLineValid );
978 rInner.SetValid( SvxBoxInfoItemValidFlags::DISTANCE, rBorder.IsDistanceValid );
979 rInner.SetTable( true );
983 void ScHelperFunctions::FillBoxItems( SvxBoxItem& rOuter, SvxBoxInfoItem& rInner, const table::TableBorder& rBorder )
985 lcl_fillBoxItems( rOuter, rInner, rBorder);
988 void ScHelperFunctions::FillBoxItems( SvxBoxItem& rOuter, SvxBoxInfoItem& rInner, const table::TableBorder2& rBorder )
990 lcl_fillBoxItems( rOuter, rInner, rBorder);
993 void ScHelperFunctions::FillBorderLine( table::BorderLine& rStruct, const ::editeng::SvxBorderLine* pLine )
995 // Convert from Twips to 1/100mm.
996 table::BorderLine2 aStruct( SvxBoxItem::SvxLineToLine( pLine, true));
997 rStruct = aStruct;
1000 void ScHelperFunctions::FillBorderLine( table::BorderLine2& rStruct, const ::editeng::SvxBorderLine* pLine )
1002 rStruct = SvxBoxItem::SvxLineToLine( pLine, true);
1005 namespace {
1006 template<typename TableBorderItem>
1007 void lcl_fillTableBorder( TableBorderItem& rBorder, const SvxBoxItem& rOuter, const SvxBoxInfoItem& rInner,
1008 bool bInvalidateHorVerDist )
1010 ScHelperFunctions::FillBorderLine( rBorder.TopLine, rOuter.GetTop() );
1011 ScHelperFunctions::FillBorderLine( rBorder.BottomLine, rOuter.GetBottom() );
1012 ScHelperFunctions::FillBorderLine( rBorder.LeftLine, rOuter.GetLeft() );
1013 ScHelperFunctions::FillBorderLine( rBorder.RightLine, rOuter.GetRight() );
1014 ScHelperFunctions::FillBorderLine( rBorder.HorizontalLine, rInner.GetHori() );
1015 ScHelperFunctions::FillBorderLine( rBorder.VerticalLine, rInner.GetVert() );
1017 rBorder.Distance = rOuter.GetDistance();
1018 rBorder.IsTopLineValid = rInner.IsValid(SvxBoxInfoItemValidFlags::TOP);
1019 rBorder.IsBottomLineValid = rInner.IsValid(SvxBoxInfoItemValidFlags::BOTTOM);
1020 rBorder.IsLeftLineValid = rInner.IsValid(SvxBoxInfoItemValidFlags::LEFT);
1021 rBorder.IsRightLineValid = rInner.IsValid(SvxBoxInfoItemValidFlags::RIGHT);
1022 rBorder.IsHorizontalLineValid = !bInvalidateHorVerDist && rInner.IsValid(SvxBoxInfoItemValidFlags::HORI);
1023 rBorder.IsVerticalLineValid = !bInvalidateHorVerDist && rInner.IsValid(SvxBoxInfoItemValidFlags::VERT);
1024 rBorder.IsDistanceValid = !bInvalidateHorVerDist && rInner.IsValid(SvxBoxInfoItemValidFlags::DISTANCE);
1028 void ScHelperFunctions::AssignTableBorderToAny( uno::Any& rAny,
1029 const SvxBoxItem& rOuter, const SvxBoxInfoItem& rInner, bool bInvalidateHorVerDist )
1031 table::TableBorder aBorder;
1032 lcl_fillTableBorder( aBorder, rOuter, rInner, bInvalidateHorVerDist);
1033 rAny <<= aBorder;
1036 void ScHelperFunctions::AssignTableBorder2ToAny( uno::Any& rAny,
1037 const SvxBoxItem& rOuter, const SvxBoxInfoItem& rInner, bool bInvalidateHorVerDist )
1039 table::TableBorder2 aBorder;
1040 lcl_fillTableBorder( aBorder, rOuter, rInner, bInvalidateHorVerDist);
1041 rAny <<= aBorder;
1044 //! lcl_ApplyBorder nach docfunc verschieben!
1046 void ScHelperFunctions::ApplyBorder( ScDocShell* pDocShell, const ScRangeList& rRanges,
1047 const SvxBoxItem& rOuter, const SvxBoxInfoItem& rInner )
1049 ScDocument& rDoc = pDocShell->GetDocument();
1050 bool bUndo(rDoc.IsUndoEnabled());
1051 ScDocument* pUndoDoc = NULL;
1052 if (bUndo)
1053 pUndoDoc = new ScDocument( SCDOCMODE_UNDO );
1054 size_t nCount = rRanges.size();
1055 for (size_t i = 0; i < nCount; ++i)
1057 ScRange aRange( *rRanges[ i ] );
1058 SCTAB nTab = aRange.aStart.Tab();
1060 if (bUndo)
1062 if ( i==0 )
1063 pUndoDoc->InitUndo( &rDoc, nTab, nTab );
1064 else
1065 pUndoDoc->AddUndoTab( nTab, nTab );
1066 rDoc.CopyToDocument( aRange, IDF_ATTRIB, false, pUndoDoc );
1069 ScMarkData aMark;
1070 aMark.SetMarkArea( aRange );
1071 aMark.SelectTable( nTab, true );
1073 rDoc.ApplySelectionFrame( aMark, &rOuter, &rInner );
1074 // RowHeight bei Umrandung alleine nicht noetig
1077 if (bUndo)
1079 pDocShell->GetUndoManager()->AddUndoAction(
1080 new ScUndoBorder( pDocShell, rRanges, pUndoDoc, rOuter, rInner ) );
1083 for (size_t i = 0; i < nCount; ++i )
1084 pDocShell->PostPaint( *rRanges[ i ], PAINT_GRID, SC_PF_LINES | SC_PF_TESTMERGE );
1086 pDocShell->SetDocumentModified();
1089 //! move lcl_PutDataArray to docfunc?
1090 //! merge loop with ScFunctionAccess::callFunction
1092 static bool lcl_PutDataArray( ScDocShell& rDocShell, const ScRange& rRange,
1093 const uno::Sequence< uno::Sequence<uno::Any> >& aData )
1095 ScDocument& rDoc = rDocShell.GetDocument();
1096 SCTAB nTab = rRange.aStart.Tab();
1097 SCCOL nStartCol = rRange.aStart.Col();
1098 SCROW nStartRow = rRange.aStart.Row();
1099 SCCOL nEndCol = rRange.aEnd.Col();
1100 SCROW nEndRow = rRange.aEnd.Row();
1101 bool bUndo(rDoc.IsUndoEnabled());
1103 if ( !rDoc.IsBlockEditable( nTab, nStartCol,nStartRow, nEndCol,nEndRow ) )
1105 //! error message
1106 return false;
1109 long nCols = 0;
1110 long nRows = aData.getLength();
1111 const uno::Sequence<uno::Any>* pArray = aData.getConstArray();
1112 if ( nRows )
1113 nCols = pArray[0].getLength();
1115 if ( nCols != nEndCol-nStartCol+1 || nRows != nEndRow-nStartRow+1 )
1117 //! error message?
1118 return false;
1121 ScDocument* pUndoDoc = NULL;
1122 if ( bUndo )
1124 pUndoDoc = new ScDocument( SCDOCMODE_UNDO );
1125 pUndoDoc->InitUndo( &rDoc, nTab, nTab );
1126 rDoc.CopyToDocument( rRange, IDF_CONTENTS|IDF_NOCAPTIONS, false, pUndoDoc );
1129 rDoc.DeleteAreaTab( nStartCol, nStartRow, nEndCol, nEndRow, nTab, IDF_CONTENTS );
1131 bool bError = false;
1132 SCROW nDocRow = nStartRow;
1133 for (long nRow=0; nRow<nRows; nRow++)
1135 const uno::Sequence<uno::Any>& rColSeq = pArray[nRow];
1136 if ( rColSeq.getLength() == nCols )
1138 SCCOL nDocCol = nStartCol;
1139 const uno::Any* pColArr = rColSeq.getConstArray();
1140 for (long nCol=0; nCol<nCols; nCol++)
1142 ScAddress aPos(nDocCol, nDocRow, nTab);
1144 const uno::Any& rElement = pColArr[nCol];
1145 switch( rElement.getValueTypeClass() )
1147 case uno::TypeClass_VOID:
1149 // void = "no value"
1150 rDoc.SetError( nDocCol, nDocRow, nTab, NOTAVAILABLE );
1152 break;
1154 // #87871# accept integer types because Basic passes a floating point
1155 // variable as byte, short or long if it's an integer number.
1156 case uno::TypeClass_BYTE:
1157 case uno::TypeClass_SHORT:
1158 case uno::TypeClass_UNSIGNED_SHORT:
1159 case uno::TypeClass_LONG:
1160 case uno::TypeClass_UNSIGNED_LONG:
1161 case uno::TypeClass_FLOAT:
1162 case uno::TypeClass_DOUBLE:
1164 double fVal(0.0);
1165 rElement >>= fVal;
1166 rDoc.SetValue(aPos, fVal);
1168 break;
1170 case uno::TypeClass_STRING:
1172 OUString aUStr;
1173 rElement >>= aUStr;
1174 if ( !aUStr.isEmpty() )
1176 ScSetStringParam aParam;
1177 aParam.setTextInput();
1178 rDoc.SetString(aPos, aUStr, &aParam);
1181 break;
1183 // accept Sequence<FormulaToken> for formula cells
1184 case uno::TypeClass_SEQUENCE:
1186 uno::Sequence< sheet::FormulaToken > aTokens;
1187 if ( rElement >>= aTokens )
1189 ScTokenArray aTokenArray;
1190 ScTokenConversion::ConvertToTokenArray( rDoc, aTokenArray, aTokens );
1191 rDoc.SetFormula(aPos, aTokenArray);
1193 else
1194 bError = true;
1196 break;
1198 default:
1199 bError = true; // invalid type
1201 ++nDocCol;
1204 else
1205 bError = true; // wrong size
1207 ++nDocRow;
1210 bool bHeight = rDocShell.AdjustRowHeight( nStartRow, nEndRow, nTab );
1212 if ( pUndoDoc )
1214 ScMarkData aDestMark;
1215 aDestMark.SelectOneTable( nTab );
1216 rDocShell.GetUndoManager()->AddUndoAction(
1217 new ScUndoPaste(
1218 &rDocShell, ScRange(nStartCol, nStartRow, nTab, nEndCol, nEndRow, nTab),
1219 aDestMark, pUndoDoc, NULL, IDF_CONTENTS, NULL, false));
1222 if (!bHeight)
1223 rDocShell.PostPaint( rRange, PAINT_GRID ); // AdjustRowHeight may have painted already
1225 rDocShell.SetDocumentModified();
1227 return !bError;
1230 static bool lcl_PutFormulaArray( ScDocShell& rDocShell, const ScRange& rRange,
1231 const uno::Sequence< uno::Sequence<OUString> >& aData,
1232 const formula::FormulaGrammar::Grammar eGrammar )
1234 ScDocument& rDoc = rDocShell.GetDocument();
1235 SCTAB nTab = rRange.aStart.Tab();
1236 SCCOL nStartCol = rRange.aStart.Col();
1237 SCROW nStartRow = rRange.aStart.Row();
1238 SCCOL nEndCol = rRange.aEnd.Col();
1239 SCROW nEndRow = rRange.aEnd.Row();
1240 bool bUndo(rDoc.IsUndoEnabled());
1242 if ( !rDoc.IsBlockEditable( nTab, nStartCol,nStartRow, nEndCol,nEndRow ) )
1244 //! error message
1245 return false;
1248 long nCols = 0;
1249 long nRows = aData.getLength();
1250 const uno::Sequence<OUString>* pArray = aData.getConstArray();
1251 if ( nRows )
1252 nCols = pArray[0].getLength();
1254 if ( nCols != nEndCol-nStartCol+1 || nRows != nEndRow-nStartRow+1 )
1256 //! error message?
1257 return false;
1260 ScDocument* pUndoDoc = NULL;
1261 if ( bUndo )
1263 pUndoDoc = new ScDocument( SCDOCMODE_UNDO );
1264 pUndoDoc->InitUndo( &rDoc, nTab, nTab );
1265 rDoc.CopyToDocument( rRange, IDF_CONTENTS, false, pUndoDoc );
1268 rDoc.DeleteAreaTab( nStartCol, nStartRow, nEndCol, nEndRow, nTab, IDF_CONTENTS );
1270 bool bError = false;
1271 SCROW nDocRow = nStartRow;
1272 for (long nRow=0; nRow<nRows; nRow++)
1274 const uno::Sequence<OUString>& rColSeq = pArray[nRow];
1275 if ( rColSeq.getLength() == nCols )
1277 SCCOL nDocCol = nStartCol;
1278 const OUString* pColArr = rColSeq.getConstArray();
1279 for (long nCol=0; nCol<nCols; nCol++)
1281 OUString aText(pColArr[nCol]);
1282 ScAddress aPos( nDocCol, nDocRow, nTab );
1284 ScInputStringType aRes =
1285 ScStringUtil::parseInputString(
1286 *rDoc.GetFormatTable(), aText, LANGUAGE_ENGLISH_US);
1287 switch (aRes.meType)
1289 case ScInputStringType::Formula:
1290 rDoc.SetFormula(aPos, aRes.maText, eGrammar);
1291 break;
1292 case ScInputStringType::Number:
1293 rDoc.SetValue(aPos, aRes.mfValue);
1294 break;
1295 case ScInputStringType::Text:
1296 rDoc.SetTextCell(aPos, aRes.maText);
1297 break;
1298 default:
1302 ++nDocCol;
1305 else
1306 bError = true; // wrong size
1308 ++nDocRow;
1311 bool bHeight = rDocShell.AdjustRowHeight( nStartRow, nEndRow, nTab );
1313 if ( pUndoDoc )
1315 ScMarkData aDestMark;
1316 aDestMark.SelectOneTable( nTab );
1317 rDocShell.GetUndoManager()->AddUndoAction(
1318 new ScUndoPaste( &rDocShell,
1319 ScRange(nStartCol, nStartRow, nTab, nEndCol, nEndRow, nTab), aDestMark,
1320 pUndoDoc, NULL, IDF_CONTENTS, NULL, false));
1323 if (!bHeight)
1324 rDocShell.PostPaint( rRange, PAINT_GRID ); // AdjustRowHeight may have painted already
1326 rDocShell.SetDocumentModified();
1328 return !bError;
1331 // used in ScCellRangeObj::getFormulaArray and ScCellObj::GetInputString_Impl
1332 static OUString lcl_GetInputString( ScDocument& rDoc, const ScAddress& rPos, bool bEnglish )
1334 ScRefCellValue aCell;
1335 aCell.assign(rDoc, rPos);
1336 if (aCell.isEmpty())
1337 return EMPTY_OUSTRING;
1339 OUString aVal;
1341 CellType eType = aCell.meType;
1342 if (eType == CELLTYPE_FORMULA)
1344 ScFormulaCell* pForm = aCell.mpFormula;
1345 pForm->GetFormula( aVal, formula::FormulaGrammar::mapAPItoGrammar( bEnglish, false));
1346 return aVal;
1349 SvNumberFormatter* pFormatter = bEnglish ? ScGlobal::GetEnglishFormatter() :
1350 rDoc.GetFormatTable();
1351 // Since the English formatter was constructed with
1352 // LANGUAGE_ENGLISH_US the "General" format has index key 0,
1353 // we don't have to query.
1354 sal_uInt32 nNumFmt = bEnglish ? 0 : rDoc.GetNumberFormat(rPos);
1356 if (eType == CELLTYPE_EDIT)
1358 // GetString an der EditCell macht Leerzeichen aus Umbruechen,
1359 // hier werden die Umbrueche aber gebraucht
1360 const EditTextObject* pData = aCell.mpEditText;
1361 if (pData)
1363 EditEngine& rEngine = rDoc.GetEditEngine();
1364 rEngine.SetText(*pData);
1365 aVal = rEngine.GetText(LINEEND_LF);
1368 else
1369 ScCellFormat::GetInputString(aCell, nNumFmt, aVal, *pFormatter, &rDoc);
1371 // ggf. ein ' davorhaengen wie in ScTabViewShell::UpdateInputHandler
1372 if ( eType == CELLTYPE_STRING || eType == CELLTYPE_EDIT )
1374 double fDummy;
1375 OUString aTempString = aVal;
1376 bool bIsNumberFormat(pFormatter->IsNumberFormat(aTempString, nNumFmt, fDummy));
1377 if ( bIsNumberFormat )
1378 aTempString = "'" + aTempString;
1379 else if ( aTempString.startsWith("'") )
1381 // if the string starts with a "'", add another one because setFormula
1382 // strips one (like text input, except for "text" number formats)
1383 if ( bEnglish || ( pFormatter->GetType(nNumFmt) != css::util::NumberFormat::TEXT ) )
1384 aTempString = "'" + aTempString;
1386 aVal = aTempString;
1388 return aVal;
1391 ScCellRangesBase::ScCellRangesBase(ScDocShell* pDocSh, const ScRange& rR) :
1392 pPropSet(lcl_GetCellsPropertySet()),
1393 pDocShell( pDocSh ),
1394 pValueListener( NULL ),
1395 pCurrentFlat( NULL ),
1396 pCurrentDeep( NULL ),
1397 pCurrentDataSet( NULL ),
1398 pNoDfltCurrentDataSet( NULL ),
1399 pMarkData( NULL ),
1400 nObjectId( 0 ),
1401 bChartColAsHdr( false ),
1402 bChartRowAsHdr( false ),
1403 bCursorOnly( false ),
1404 bGotDataChangedHint( false ),
1405 aValueListeners( 0 )
1407 // this is a hack to get m_wThis initialized; ideally there would be
1408 // factory functions doing this but there are so many subclasses of this...
1409 ++m_refCount;
1411 m_wThis = uno::Reference<uno::XInterface>(
1412 static_cast<cppu::OWeakObject*>(this));
1414 --m_refCount;
1416 ScRange aCellRange(rR);
1417 aCellRange.Justify();
1418 aRanges.Append( aCellRange );
1420 if (pDocShell) // Null if created with createInstance
1422 ScDocument& rDoc = pDocShell->GetDocument();
1423 rDoc.AddUnoObject(*this);
1424 nObjectId = rDoc.GetNewUnoId();
1428 ScCellRangesBase::ScCellRangesBase(ScDocShell* pDocSh, const ScRangeList& rR) :
1429 pPropSet(lcl_GetCellsPropertySet()),
1430 pDocShell( pDocSh ),
1431 pValueListener( NULL ),
1432 pCurrentFlat( NULL ),
1433 pCurrentDeep( NULL ),
1434 pCurrentDataSet( NULL ),
1435 pNoDfltCurrentDataSet( NULL ),
1436 pMarkData( NULL ),
1437 aRanges( rR ),
1438 nObjectId( 0 ),
1439 bChartColAsHdr( false ),
1440 bChartRowAsHdr( false ),
1441 bCursorOnly( false ),
1442 bGotDataChangedHint( false ),
1443 aValueListeners( 0 )
1445 // this is a hack to get m_wThis initialized; ideally there would be
1446 // factory functions doing this but there are so many subclasses of this...
1447 ++m_refCount;
1449 m_wThis = uno::Reference<uno::XInterface>(
1450 static_cast<cppu::OWeakObject*>(this));
1452 --m_refCount;
1454 if (pDocShell) // Null if created with createInstance
1456 ScDocument& rDoc = pDocShell->GetDocument();
1457 rDoc.AddUnoObject(*this);
1458 nObjectId = rDoc.GetNewUnoId();
1462 ScCellRangesBase::~ScCellRangesBase()
1464 SolarMutexGuard g;
1466 // call RemoveUnoObject first, so no notification can happen
1467 // during ForgetCurrentAttrs
1469 if (pDocShell)
1470 pDocShell->GetDocument().RemoveUnoObject(*this);
1472 ForgetCurrentAttrs();
1473 ForgetMarkData();
1475 delete pValueListener;
1477 //! XChartDataChangeEventListener abmelden ??
1478 //! (ChartCollection haelt dann auch dieses Objekt fest!)
1481 void ScCellRangesBase::ForgetCurrentAttrs()
1483 delete pCurrentFlat;
1484 delete pCurrentDeep;
1485 delete pCurrentDataSet;
1486 delete pNoDfltCurrentDataSet;
1487 pCurrentFlat = NULL;
1488 pCurrentDeep = NULL;
1489 pCurrentDataSet = NULL;
1490 pNoDfltCurrentDataSet = NULL;
1492 // #i62483# pMarkData can remain unchanged, is deleted only if the range changes (RefChanged)
1495 void ScCellRangesBase::ForgetMarkData()
1497 delete pMarkData;
1498 pMarkData = NULL;
1501 const ScPatternAttr* ScCellRangesBase::GetCurrentAttrsFlat()
1503 // get and cache direct cell attributes for this object's range
1505 if ( !pCurrentFlat && pDocShell )
1507 ScDocument& rDoc = pDocShell->GetDocument();
1508 pCurrentFlat = rDoc.CreateSelectionPattern( *GetMarkData(), false );
1510 return pCurrentFlat;
1513 const ScPatternAttr* ScCellRangesBase::GetCurrentAttrsDeep()
1515 // get and cache cell attributes (incl. styles) for this object's range
1517 if ( !pCurrentDeep && pDocShell )
1519 ScDocument& rDoc = pDocShell->GetDocument();
1520 pCurrentDeep = rDoc.CreateSelectionPattern( *GetMarkData(), true );
1522 return pCurrentDeep;
1525 SfxItemSet* ScCellRangesBase::GetCurrentDataSet(bool bNoDflt)
1527 if(!pCurrentDataSet)
1529 const ScPatternAttr* pPattern = GetCurrentAttrsDeep();
1530 if ( pPattern )
1532 // Dontcare durch Default ersetzen, damit man immer eine Reflection hat
1533 pCurrentDataSet = new SfxItemSet( pPattern->GetItemSet() );
1534 pNoDfltCurrentDataSet = new SfxItemSet( pPattern->GetItemSet() );
1535 pCurrentDataSet->ClearInvalidItems();
1538 return bNoDflt ? pNoDfltCurrentDataSet : pCurrentDataSet;
1541 const ScMarkData* ScCellRangesBase::GetMarkData()
1543 if (!pMarkData)
1545 pMarkData = new ScMarkData();
1546 pMarkData->MarkFromRangeList( aRanges, false );
1548 return pMarkData;
1551 void ScCellRangesBase::Notify( SfxBroadcaster&, const SfxHint& rHint )
1553 uno::Reference<uno::XInterface> const xThis(m_wThis);
1554 if (!xThis.is())
1555 { // fdo#72695: if UNO object is already dead, don't revive it with event
1556 if (dynamic_cast<const SfxSimpleHint*>(&rHint) &&
1557 SFX_HINT_DYING == static_cast<const SfxSimpleHint&>(rHint).GetId())
1558 { // if the document dies, must reset to avoid crash in dtor!
1559 ForgetCurrentAttrs();
1560 pDocShell = nullptr;
1562 return;
1564 if ( dynamic_cast<const ScUpdateRefHint*>(&rHint) )
1566 const ScUpdateRefHint& rRef = static_cast<const ScUpdateRefHint&>(rHint);
1568 ScDocument& rDoc = pDocShell->GetDocument();
1569 boost::scoped_ptr<ScRangeList> pUndoRanges;
1570 if ( rDoc.HasUnoRefUndo() )
1571 pUndoRanges.reset(new ScRangeList( aRanges ));
1573 if ( aRanges.UpdateReference( rRef.GetMode(), &rDoc, rRef.GetRange(),
1574 rRef.GetDx(), rRef.GetDy(), rRef.GetDz() ) )
1576 if ( rRef.GetMode() == URM_INSDEL
1577 && aRanges.size() == 1
1578 && ScTableSheetObj::getImplementation(xThis)
1581 // #101755#; the range size of a sheet does not change
1582 ScRange* pR = aRanges.front();
1583 if (pR)
1585 pR->aStart.SetCol(0);
1586 pR->aStart.SetRow(0);
1587 pR->aEnd.SetCol(MAXCOL);
1588 pR->aEnd.SetRow(MAXROW);
1591 RefChanged();
1593 // any change of the range address is broadcast to value (modify) listeners
1594 if ( !aValueListeners.empty() )
1595 bGotDataChangedHint = true;
1597 if ( pUndoRanges )
1598 rDoc.AddUnoRefChange( nObjectId, *pUndoRanges );
1601 else if ( dynamic_cast<const SfxSimpleHint*>(&rHint) )
1603 sal_uLong nId = static_cast<const SfxSimpleHint&>(rHint).GetId();
1604 if ( nId == SFX_HINT_DYING )
1606 ForgetCurrentAttrs();
1607 pDocShell = NULL; // invalid
1609 if ( !aValueListeners.empty() )
1611 // dispose listeners
1613 lang::EventObject aEvent;
1614 aEvent.Source.set(static_cast<cppu::OWeakObject*>(this));
1615 for ( sal_uInt16 n=0; n<aValueListeners.size(); n++ )
1616 aValueListeners[n]->disposing( aEvent );
1618 aValueListeners.clear();
1620 // The listeners can't have the last ref to this, as it's still held
1621 // by the DocShell.
1624 else if ( nId == SFX_HINT_DATACHANGED )
1626 // document content changed -> forget cached attributes
1627 ForgetCurrentAttrs();
1629 if ( bGotDataChangedHint && pDocShell )
1631 // This object was notified of content changes, so one call
1632 // for each listener is generated now.
1633 // The calls can't be executed directly because the document's
1634 // UNO broadcaster list must not be modified.
1635 // Instead, add to the document's list of listener calls,
1636 // which will be executed directly after the broadcast of
1637 // SFX_HINT_DATACHANGED.
1639 lang::EventObject aEvent;
1640 aEvent.Source.set((cppu::OWeakObject*)this);
1642 // the EventObject holds a Ref to this object until after the listener calls
1644 ScDocument& rDoc = pDocShell->GetDocument();
1645 for ( sal_uInt16 n=0; n<aValueListeners.size(); n++ )
1646 rDoc.AddUnoListenerCall( aValueListeners[n], aEvent );
1648 bGotDataChangedHint = false;
1651 else if ( nId == SC_HINT_CALCALL )
1653 // broadcast from DoHardRecalc - set bGotDataChangedHint
1654 // (SFX_HINT_DATACHANGED follows separately)
1656 if ( !aValueListeners.empty() )
1657 bGotDataChangedHint = true;
1660 else if ( dynamic_cast<const ScUnoRefUndoHint*>(&rHint) )
1662 const ScUnoRefUndoHint& rUndoHint = static_cast<const ScUnoRefUndoHint&>(rHint);
1663 if ( rUndoHint.GetObjectId() == nObjectId )
1665 // restore ranges from hint
1667 aRanges = rUndoHint.GetRanges();
1669 RefChanged();
1670 if ( !aValueListeners.empty() )
1671 bGotDataChangedHint = true; // need to broadcast the undo, too
1676 void ScCellRangesBase::RefChanged()
1678 //! adjust XChartDataChangeEventListener
1680 if ( pValueListener && !aValueListeners.empty() )
1682 pValueListener->EndListeningAll();
1684 ScDocument& rDoc = pDocShell->GetDocument();
1685 for ( size_t i = 0, nCount = aRanges.size(); i < nCount; ++i )
1686 rDoc.StartListeningArea( *aRanges[ i ], false, pValueListener );
1689 ForgetCurrentAttrs();
1690 ForgetMarkData();
1693 ScDocument* ScCellRangesBase::GetDocument() const
1695 if (pDocShell)
1696 return &pDocShell->GetDocument();
1697 else
1698 return NULL;
1701 void ScCellRangesBase::InitInsertRange(ScDocShell* pDocSh, const ScRange& rR)
1703 if ( !pDocShell && pDocSh )
1705 pDocShell = pDocSh;
1707 ScRange aCellRange(rR);
1708 aCellRange.Justify();
1709 aRanges.RemoveAll();
1710 aRanges.Append( aCellRange );
1712 pDocShell->GetDocument().AddUnoObject(*this);
1714 RefChanged(); // Range im Range-Objekt anpassen
1718 void ScCellRangesBase::AddRange(const ScRange& rRange, const bool bMergeRanges)
1720 if (bMergeRanges)
1721 aRanges.Join(rRange);
1722 else
1723 aRanges.Append(rRange);
1724 RefChanged();
1727 void ScCellRangesBase::SetNewRange(const ScRange& rNew)
1729 ScRange aCellRange(rNew);
1730 aCellRange.Justify();
1732 aRanges.RemoveAll();
1733 aRanges.Append( aCellRange );
1734 RefChanged();
1737 void ScCellRangesBase::SetNewRanges(const ScRangeList& rNew)
1739 aRanges = rNew;
1740 RefChanged();
1743 void ScCellRangesBase::SetCursorOnly( bool bSet )
1745 // set for a selection object that is created from the cursor position
1746 // without anything selected (may contain several sheets)
1748 bCursorOnly = bSet;
1751 uno::Any SAL_CALL ScCellRangesBase::queryInterface( const uno::Type& rType )
1752 throw(uno::RuntimeException, std::exception)
1754 SC_QUERYINTERFACE( beans::XPropertySet )
1755 SC_QUERYINTERFACE( beans::XMultiPropertySet )
1756 SC_QUERYINTERFACE( beans::XTolerantMultiPropertySet )
1757 SC_QUERYINTERFACE( beans::XPropertyState )
1758 SC_QUERYINTERFACE( sheet::XSheetOperation )
1759 SC_QUERYINTERFACE( chart::XChartDataArray )
1760 SC_QUERYINTERFACE( chart::XChartData )
1761 SC_QUERYINTERFACE( util::XIndent )
1762 SC_QUERYINTERFACE( sheet::XCellRangesQuery )
1763 SC_QUERYINTERFACE( sheet::XFormulaQuery )
1764 SC_QUERYINTERFACE( util::XReplaceable )
1765 SC_QUERYINTERFACE( util::XSearchable )
1766 SC_QUERYINTERFACE( util::XModifyBroadcaster )
1767 SC_QUERYINTERFACE( lang::XServiceInfo )
1768 SC_QUERYINTERFACE( lang::XUnoTunnel )
1769 SC_QUERYINTERFACE( lang::XTypeProvider )
1771 return OWeakObject::queryInterface( rType );
1774 void SAL_CALL ScCellRangesBase::acquire() throw()
1776 OWeakObject::acquire();
1779 void SAL_CALL ScCellRangesBase::release() throw()
1781 OWeakObject::release();
1784 uno::Sequence<uno::Type> SAL_CALL ScCellRangesBase::getTypes() throw(uno::RuntimeException, std::exception)
1786 static uno::Sequence<uno::Type> aTypes;
1787 if ( aTypes.getLength() == 0 )
1789 aTypes.realloc(13);
1790 uno::Type* pPtr = aTypes.getArray();
1791 pPtr[0] = cppu::UnoType<beans::XPropertySet>::get();
1792 pPtr[1] = cppu::UnoType<beans::XMultiPropertySet>::get();
1793 pPtr[2] = cppu::UnoType<beans::XPropertyState>::get();
1794 pPtr[3] = cppu::UnoType<sheet::XSheetOperation>::get();
1795 pPtr[4] = cppu::UnoType<chart::XChartDataArray>::get();
1796 pPtr[5] = cppu::UnoType<util::XIndent>::get();
1797 pPtr[6] = cppu::UnoType<sheet::XCellRangesQuery>::get();
1798 pPtr[7] = cppu::UnoType<sheet::XFormulaQuery>::get();
1799 pPtr[8] = cppu::UnoType<util::XReplaceable>::get();
1800 pPtr[9] = cppu::UnoType<util::XModifyBroadcaster>::get();
1801 pPtr[10]= cppu::UnoType<lang::XServiceInfo>::get();
1802 pPtr[11]= cppu::UnoType<lang::XUnoTunnel>::get();
1803 pPtr[12]= cppu::UnoType<lang::XTypeProvider>::get();
1805 return aTypes;
1808 uno::Sequence<sal_Int8> SAL_CALL ScCellRangesBase::getImplementationId()
1809 throw(uno::RuntimeException, std::exception)
1811 return css::uno::Sequence<sal_Int8>();
1814 void ScCellRangesBase::PaintRanges_Impl( sal_uInt16 nPart )
1816 for (size_t i = 0, nCount = aRanges.size(); i < nCount; ++i)
1817 pDocShell->PostPaint( *aRanges[ i ], nPart );
1820 // XSheetOperation
1822 double SAL_CALL ScCellRangesBase::computeFunction( sheet::GeneralFunction nFunction )
1823 throw(uno::Exception, uno::RuntimeException, std::exception)
1825 SolarMutexGuard aGuard;
1826 ScMarkData aMark(*GetMarkData());
1827 aMark.MarkToSimple();
1828 if (!aMark.IsMarked())
1829 aMark.SetMarkNegative(true); // um Dummy Position angeben zu koennen
1831 ScAddress aDummy; // wenn nicht Marked, ignoriert wegen Negative
1832 double fVal;
1833 ScSubTotalFunc eFunc = ScDPUtil::toSubTotalFunc(nFunction);
1834 ScDocument& rDoc = pDocShell->GetDocument();
1835 if ( !rDoc.GetSelectionFunction( eFunc, aDummy, aMark, fVal ) )
1837 throw uno::RuntimeException(); //! own exception?
1840 return fVal;
1843 void SAL_CALL ScCellRangesBase::clearContents( sal_Int32 nContentFlags ) throw(uno::RuntimeException, std::exception)
1845 SolarMutexGuard aGuard;
1846 if ( !aRanges.empty() )
1848 // only for clearContents: EDITATTR is only used if no contents are deleted
1849 InsertDeleteFlags nDelFlags = InsertDeleteFlags::fromInt(nContentFlags) & IDF_ALL;
1850 if ( ( nDelFlags & IDF_EDITATTR ) && ( nDelFlags & IDF_CONTENTS ) == IDF_NONE )
1851 nDelFlags |= IDF_EDITATTR;
1853 pDocShell->GetDocFunc().DeleteContents( *GetMarkData(), nDelFlags, true, true );
1855 // sonst ist nichts zu tun
1858 // XPropertyState
1860 const SfxItemPropertyMap& ScCellRangesBase::GetItemPropertyMap()
1862 return pPropSet->getPropertyMap();
1865 static void lcl_GetPropertyWhich( const SfxItemPropertySimpleEntry* pEntry,
1866 sal_uInt16& rItemWhich )
1868 // Which-ID des betroffenen Items, auch wenn das Item die Property
1869 // nicht alleine behandeln kann
1870 if ( pEntry )
1872 if ( IsScItemWid( pEntry->nWID ) )
1873 rItemWhich = pEntry->nWID;
1874 else
1875 switch ( pEntry->nWID )
1877 case SC_WID_UNO_TBLBORD:
1878 case SC_WID_UNO_TBLBORD2:
1879 rItemWhich = ATTR_BORDER;
1880 break;
1881 case SC_WID_UNO_CONDFMT:
1882 case SC_WID_UNO_CONDLOC:
1883 case SC_WID_UNO_CONDXML:
1884 rItemWhich = ATTR_CONDITIONAL;
1885 break;
1886 case SC_WID_UNO_VALIDAT:
1887 case SC_WID_UNO_VALILOC:
1888 case SC_WID_UNO_VALIXML:
1889 rItemWhich = ATTR_VALIDDATA;
1890 break;
1896 beans::PropertyState ScCellRangesBase::GetOnePropertyState( sal_uInt16 nItemWhich, const SfxItemPropertySimpleEntry* pEntry )
1898 beans::PropertyState eRet = beans::PropertyState_DIRECT_VALUE;
1899 if ( nItemWhich ) // item wid (from map or special case)
1901 // For items that contain several properties (like background),
1902 // "ambiguous" is returned too often here
1904 // for PropertyState, don't look at styles
1905 const ScPatternAttr* pPattern = GetCurrentAttrsFlat();
1906 if ( pPattern )
1908 SfxItemState eState = pPattern->GetItemSet().GetItemState( nItemWhich, false );
1910 if ( nItemWhich == ATTR_VALUE_FORMAT && eState == SfxItemState::DEFAULT )
1911 eState = pPattern->GetItemSet().GetItemState( ATTR_LANGUAGE_FORMAT, false );
1913 if ( eState == SfxItemState::SET )
1914 eRet = beans::PropertyState_DIRECT_VALUE;
1915 else if ( eState == SfxItemState::DEFAULT )
1916 eRet = beans::PropertyState_DEFAULT_VALUE;
1917 else if ( eState == SfxItemState::DONTCARE )
1918 eRet = beans::PropertyState_AMBIGUOUS_VALUE;
1919 else
1921 OSL_FAIL("unbekannter ItemState");
1925 else if ( pEntry )
1927 if ( pEntry->nWID == SC_WID_UNO_CHCOLHDR || pEntry->nWID == SC_WID_UNO_CHROWHDR || pEntry->nWID == SC_WID_UNO_ABSNAME )
1928 eRet = beans::PropertyState_DIRECT_VALUE;
1929 else if ( pEntry->nWID == SC_WID_UNO_CELLSTYL )
1931 // a style is always set, there's no default state
1932 const ScStyleSheet* pStyle = pDocShell->GetDocument().GetSelectionStyle(*GetMarkData());
1933 if (pStyle)
1934 eRet = beans::PropertyState_DIRECT_VALUE;
1935 else
1936 eRet = beans::PropertyState_AMBIGUOUS_VALUE;
1938 else if ( pEntry->nWID == SC_WID_UNO_NUMRULES )
1939 eRet = beans::PropertyState_DEFAULT_VALUE; // numbering rules are always default
1941 return eRet;
1944 beans::PropertyState SAL_CALL ScCellRangesBase::getPropertyState( const OUString& aPropertyName )
1945 throw(beans::UnknownPropertyException, uno::RuntimeException, std::exception)
1947 SolarMutexGuard aGuard;
1948 if ( aRanges.empty() )
1949 throw uno::RuntimeException();
1951 const SfxItemPropertyMap& rMap = GetItemPropertyMap(); // from derived class
1952 sal_uInt16 nItemWhich = 0;
1953 const SfxItemPropertySimpleEntry* pEntry = rMap.getByName( aPropertyName );
1954 lcl_GetPropertyWhich( pEntry, nItemWhich );
1955 return GetOnePropertyState( nItemWhich, pEntry );
1958 uno::Sequence<beans::PropertyState> SAL_CALL ScCellRangesBase::getPropertyStates(
1959 const uno::Sequence<OUString>& aPropertyNames )
1960 throw(beans::UnknownPropertyException, uno::RuntimeException, std::exception)
1962 SolarMutexGuard aGuard;
1964 const SfxItemPropertyMap& rPropertyMap = GetItemPropertyMap(); // from derived class
1966 uno::Sequence<beans::PropertyState> aRet(aPropertyNames.getLength());
1967 beans::PropertyState* pStates = aRet.getArray();
1968 for(sal_Int32 i = 0; i < aPropertyNames.getLength(); i++)
1970 sal_uInt16 nItemWhich = 0;
1971 const SfxItemPropertySimpleEntry* pEntry = rPropertyMap.getByName( aPropertyNames[i] );
1972 lcl_GetPropertyWhich( pEntry, nItemWhich );
1973 pStates[i] = GetOnePropertyState(nItemWhich, pEntry);
1975 return aRet;
1978 void SAL_CALL ScCellRangesBase::setPropertyToDefault( const OUString& aPropertyName )
1979 throw(beans::UnknownPropertyException, uno::RuntimeException, std::exception)
1981 SolarMutexGuard aGuard;
1982 if ( pDocShell )
1984 const SfxItemPropertyMap& rPropertyMap = GetItemPropertyMap(); // from derived class
1985 sal_uInt16 nItemWhich = 0;
1986 const SfxItemPropertySimpleEntry* pEntry = rPropertyMap.getByName( aPropertyName );
1987 lcl_GetPropertyWhich( pEntry, nItemWhich );
1988 if ( nItemWhich ) // item wid (from map or special case)
1990 if ( !aRanges.empty() ) // leer = nichts zu tun
1992 //! Bei Items, die mehrere Properties enthalten (z.B. Hintergrund)
1993 //! wird hier zuviel zurueckgesetzt
1994 //! for ATTR_ROTATE_VALUE, also reset ATTR_ORIENTATION?
1996 sal_uInt16 aWIDs[3];
1997 aWIDs[0] = nItemWhich;
1998 if ( nItemWhich == ATTR_VALUE_FORMAT )
2000 aWIDs[1] = ATTR_LANGUAGE_FORMAT; // language for number formats
2001 aWIDs[2] = 0;
2003 else
2004 aWIDs[1] = 0;
2005 pDocShell->GetDocFunc().ClearItems( *GetMarkData(), aWIDs, true );
2008 else if ( pEntry )
2010 if ( pEntry->nWID == SC_WID_UNO_CHCOLHDR )
2011 bChartColAsHdr = false;
2012 else if ( pEntry->nWID == SC_WID_UNO_CHROWHDR )
2013 bChartRowAsHdr = false;
2014 else if ( pEntry->nWID == SC_WID_UNO_CELLSTYL )
2016 OUString aStyleName( ScGlobal::GetRscString( STR_STYLENAME_STANDARD ) );
2017 pDocShell->GetDocFunc().ApplyStyle( *GetMarkData(), aStyleName, true, true );
2023 uno::Any SAL_CALL ScCellRangesBase::getPropertyDefault( const OUString& aPropertyName )
2024 throw(beans::UnknownPropertyException, lang::WrappedTargetException,
2025 uno::RuntimeException, std::exception)
2027 //! mit getPropertyValue zusammenfassen
2029 SolarMutexGuard aGuard;
2030 uno::Any aAny;
2032 if ( pDocShell )
2034 ScDocument& rDoc = pDocShell->GetDocument();
2035 const SfxItemPropertyMap& rPropertyMap = GetItemPropertyMap(); // from derived class
2036 const SfxItemPropertySimpleEntry* pEntry = rPropertyMap.getByName( aPropertyName );
2037 if ( pEntry )
2039 if ( IsScItemWid( pEntry->nWID ) )
2041 const ScPatternAttr* pPattern = rDoc.GetDefPattern();
2042 if ( pPattern )
2044 const SfxItemSet& rSet = pPattern->GetItemSet();
2046 switch ( pEntry->nWID ) // fuer Item-Spezial-Behandlungen
2048 case ATTR_VALUE_FORMAT:
2049 // default has no language set
2050 aAny <<= (sal_Int32)( static_cast<const SfxUInt32Item&>(rSet.Get(pEntry->nWID)).GetValue() );
2051 break;
2052 case ATTR_INDENT:
2053 aAny <<= (sal_Int16)( TwipsToHMM(static_cast<const SfxUInt16Item&>(
2054 rSet.Get(pEntry->nWID)).GetValue()) );
2055 break;
2056 default:
2057 pPropSet->getPropertyValue(aPropertyName, rSet, aAny);
2061 else
2062 switch ( pEntry->nWID )
2064 case SC_WID_UNO_CHCOLHDR:
2065 case SC_WID_UNO_CHROWHDR:
2066 ScUnoHelpFunctions::SetBoolInAny( aAny, false );
2067 break;
2068 case SC_WID_UNO_CELLSTYL:
2069 aAny <<= OUString( ScStyleNameConversion::DisplayToProgrammaticName(
2070 ScGlobal::GetRscString(STR_STYLENAME_STANDARD), SFX_STYLE_FAMILY_PARA ) );
2071 break;
2072 case SC_WID_UNO_TBLBORD:
2073 case SC_WID_UNO_TBLBORD2:
2075 const ScPatternAttr* pPattern = rDoc.GetDefPattern();
2076 if ( pPattern )
2078 if (pEntry->nWID == SC_WID_UNO_TBLBORD2)
2079 ScHelperFunctions::AssignTableBorder2ToAny( aAny,
2080 static_cast<const SvxBoxItem&>(pPattern->GetItem(ATTR_BORDER)),
2081 static_cast<const SvxBoxInfoItem&>(pPattern->GetItem(ATTR_BORDER_INNER)) );
2082 else
2083 ScHelperFunctions::AssignTableBorderToAny( aAny,
2084 static_cast<const SvxBoxItem&>(pPattern->GetItem(ATTR_BORDER)),
2085 static_cast<const SvxBoxInfoItem&>(pPattern->GetItem(ATTR_BORDER_INNER)) );
2088 break;
2089 case SC_WID_UNO_CONDFMT:
2090 case SC_WID_UNO_CONDLOC:
2091 case SC_WID_UNO_CONDXML:
2093 bool bEnglish = ( pEntry->nWID != SC_WID_UNO_CONDLOC );
2094 bool bXML = ( pEntry->nWID == SC_WID_UNO_CONDXML );
2095 formula::FormulaGrammar::Grammar eGrammar = (bXML ?
2096 rDoc.GetStorageGrammar() :
2097 formula::FormulaGrammar::mapAPItoGrammar( bEnglish, bXML));
2099 aAny <<= uno::Reference<sheet::XSheetConditionalEntries>(
2100 new ScTableConditionalFormat( &rDoc, 0, aRanges[0]->aStart.Tab(), eGrammar ));
2102 break;
2103 case SC_WID_UNO_VALIDAT:
2104 case SC_WID_UNO_VALILOC:
2105 case SC_WID_UNO_VALIXML:
2107 bool bEnglish = ( pEntry->nWID != SC_WID_UNO_VALILOC );
2108 bool bXML = ( pEntry->nWID == SC_WID_UNO_VALIXML );
2109 formula::FormulaGrammar::Grammar eGrammar = (bXML ?
2110 rDoc.GetStorageGrammar() :
2111 formula::FormulaGrammar::mapAPItoGrammar( bEnglish, bXML));
2113 aAny <<= uno::Reference<beans::XPropertySet>(
2114 new ScTableValidationObj( &rDoc, 0, eGrammar ));
2116 break;
2117 case SC_WID_UNO_NUMRULES:
2119 aAny <<= uno::Reference<container::XIndexReplace>(ScStyleObj::CreateEmptyNumberingRules());
2121 break;
2126 return aAny;
2129 // XPropertySet
2131 uno::Reference<beans::XPropertySetInfo> SAL_CALL ScCellRangesBase::getPropertySetInfo()
2132 throw(uno::RuntimeException, std::exception)
2134 SolarMutexGuard aGuard;
2135 static uno::Reference<beans::XPropertySetInfo> aRef(
2136 new SfxItemPropertySetInfo( pPropSet->getPropertyMap() ));
2137 return aRef;
2140 static void lcl_SetCellProperty( const SfxItemPropertySimpleEntry& rEntry, const uno::Any& rValue,
2141 ScPatternAttr& rPattern, ScDocument &rDoc,
2142 sal_uInt16& rFirstItemId, sal_uInt16& rSecondItemId )
2144 rFirstItemId = rEntry.nWID;
2145 rSecondItemId = 0;
2147 SfxItemSet& rSet = rPattern.GetItemSet();
2148 switch ( rEntry.nWID )
2150 case ATTR_VALUE_FORMAT:
2152 // language for number formats
2153 SvNumberFormatter* pFormatter = rDoc.GetFormatTable();
2154 sal_uLong nOldFormat = static_cast<const SfxUInt32Item&>(rSet.Get( ATTR_VALUE_FORMAT )).GetValue();
2155 LanguageType eOldLang = static_cast<const SvxLanguageItem&>(rSet.Get( ATTR_LANGUAGE_FORMAT )).GetLanguage();
2156 nOldFormat = pFormatter->GetFormatForLanguageIfBuiltIn( nOldFormat, eOldLang );
2158 sal_Int32 nIntVal = 0;
2159 if ( rValue >>= nIntVal )
2161 sal_uLong nNewFormat = (sal_uLong)nIntVal;
2162 rSet.Put( SfxUInt32Item( ATTR_VALUE_FORMAT, nNewFormat ) );
2164 const SvNumberformat* pNewEntry = pFormatter->GetEntry( nNewFormat );
2165 LanguageType eNewLang =
2166 pNewEntry ? pNewEntry->GetLanguage() : LANGUAGE_DONTKNOW;
2167 if ( eNewLang != eOldLang && eNewLang != LANGUAGE_DONTKNOW )
2169 rSet.Put( SvxLanguageItem( eNewLang, ATTR_LANGUAGE_FORMAT ) );
2171 // if only language is changed,
2172 // don't touch number format attribute
2173 sal_uLong nNewMod = nNewFormat % SV_COUNTRY_LANGUAGE_OFFSET;
2174 if ( nNewMod == ( nOldFormat % SV_COUNTRY_LANGUAGE_OFFSET ) &&
2175 nNewMod <= SV_MAX_ANZ_STANDARD_FORMATE )
2177 rFirstItemId = 0; // don't use ATTR_VALUE_FORMAT value
2180 rSecondItemId = ATTR_LANGUAGE_FORMAT;
2183 else
2184 throw lang::IllegalArgumentException();
2186 break;
2187 case ATTR_INDENT:
2189 sal_Int16 nIntVal = 0;
2190 if ( rValue >>= nIntVal )
2191 rSet.Put( SfxUInt16Item( rEntry.nWID, (sal_uInt16)HMMToTwips(nIntVal) ) );
2192 else
2193 throw lang::IllegalArgumentException();
2195 break;
2196 case ATTR_ROTATE_VALUE:
2198 sal_Int32 nRotVal = 0;
2199 if ( rValue >>= nRotVal )
2201 // stored value is always between 0 and 360 deg.
2202 nRotVal %= 36000;
2203 if ( nRotVal < 0 )
2204 nRotVal += 36000;
2206 rSet.Put( SfxInt32Item( ATTR_ROTATE_VALUE, nRotVal ) );
2208 else
2209 throw lang::IllegalArgumentException();
2211 break;
2212 case ATTR_STACKED:
2214 table::CellOrientation eOrient;
2215 if( rValue >>= eOrient )
2217 switch( eOrient )
2219 case table::CellOrientation_STANDARD:
2220 rSet.Put( SfxBoolItem( ATTR_STACKED, false ) );
2221 break;
2222 case table::CellOrientation_TOPBOTTOM:
2223 rSet.Put( SfxBoolItem( ATTR_STACKED, false ) );
2224 rSet.Put( SfxInt32Item( ATTR_ROTATE_VALUE, 27000 ) );
2225 rSecondItemId = ATTR_ROTATE_VALUE;
2226 break;
2227 case table::CellOrientation_BOTTOMTOP:
2228 rSet.Put( SfxBoolItem( ATTR_STACKED, false ) );
2229 rSet.Put( SfxInt32Item( ATTR_ROTATE_VALUE, 9000 ) );
2230 rSecondItemId = ATTR_ROTATE_VALUE;
2231 break;
2232 case table::CellOrientation_STACKED:
2233 rSet.Put( SfxBoolItem( ATTR_STACKED, true ) );
2234 break;
2235 default:
2237 // added to avoid warnings
2242 break;
2243 default:
2245 lcl_GetCellsPropertySet()->setPropertyValue(rEntry, rValue, rSet);
2250 void SAL_CALL ScCellRangesBase::setPropertyValue(
2251 const OUString& aPropertyName, const uno::Any& aValue )
2252 throw(beans::UnknownPropertyException, beans::PropertyVetoException,
2253 lang::IllegalArgumentException, lang::WrappedTargetException,
2254 uno::RuntimeException, std::exception)
2256 SolarMutexGuard aGuard;
2258 if ( !pDocShell || aRanges.empty() )
2259 throw uno::RuntimeException();
2261 const SfxItemPropertyMap& rPropertyMap = GetItemPropertyMap(); // from derived class
2262 const SfxItemPropertySimpleEntry* pEntry = rPropertyMap.getByName( aPropertyName );
2263 if ( !pEntry )
2264 throw beans::UnknownPropertyException();
2266 SetOnePropertyValue( pEntry, aValue );
2269 void ScCellRangesBase::SetOnePropertyValue( const SfxItemPropertySimpleEntry* pEntry, const uno::Any& aValue )
2270 throw(lang::IllegalArgumentException, uno::RuntimeException, std::exception)
2272 if ( pEntry )
2274 if ( IsScItemWid( pEntry->nWID ) )
2276 if ( !aRanges.empty() ) // leer = nichts zu tun
2278 ScDocument& rDoc = pDocShell->GetDocument();
2280 // Fuer Teile von zusammengesetzten Items mit mehreren Properties (z.B. Hintergrund)
2281 // muss vorher das alte Item aus dem Dokument geholt werden
2282 //! Das kann hier aber nicht erkannt werden
2283 //! -> eigenes Flag im PropertyMap-Eintrag, oder was ???
2284 //! Item direkt von einzelner Position im Bereich holen?
2285 // ClearInvalidItems, damit auf jeden Fall ein Item vom richtigen Typ da ist
2287 ScPatternAttr aPattern( *GetCurrentAttrsDeep() );
2288 SfxItemSet& rSet = aPattern.GetItemSet();
2289 rSet.ClearInvalidItems();
2291 sal_uInt16 nFirstItem, nSecondItem;
2292 lcl_SetCellProperty( *pEntry, aValue, aPattern, rDoc, nFirstItem, nSecondItem );
2294 for (sal_uInt16 nWhich = ATTR_PATTERN_START; nWhich <= ATTR_PATTERN_END; nWhich++)
2295 if ( nWhich != nFirstItem && nWhich != nSecondItem )
2296 rSet.ClearItem(nWhich);
2298 pDocShell->GetDocFunc().ApplyAttributes( *GetMarkData(), aPattern, true, true );
2301 else // implemented here
2302 switch ( pEntry->nWID )
2304 case EE_CHAR_ESCAPEMENT: // Specifically for xlsx import
2306 sal_Int32 nValue = 0;
2307 aValue >>= nValue;
2308 if (nValue)
2310 for (size_t i = 0, n = aRanges.size(); i < n; ++i)
2312 ScRange aRange = *aRanges[i];
2314 /* TODO: Iterate through the range */
2315 ScAddress aAddr = aRange.aStart;
2316 ScDocument& rDoc = pDocShell->GetDocument();
2317 ScRefCellValue aCell;
2318 aCell.assign(rDoc, aAddr);
2320 OUString aStr = aCell.getString(&rDoc);
2321 EditEngine aEngine( rDoc.GetEnginePool() );
2322 aEngine.SetEditTextObjectPool(rDoc.GetEditPool());
2324 /* EE_CHAR_ESCAPEMENT seems to be set on the cell _only_ when
2325 * there are no other attribs for the cell.
2326 * So, it is safe to overwrite the complete attribute set.
2327 * If there is a need - getting CellType and processing
2328 * the attributes could be considered.
2330 SfxItemSet aAttr = aEngine.GetEmptyItemSet();
2331 aEngine.SetText(aStr);
2332 if( nValue < 0 ) // Subscript
2333 aAttr.Put( SvxEscapementItem( SVX_ESCAPEMENT_SUBSCRIPT, EE_CHAR_ESCAPEMENT ) );
2334 else // Superscript
2335 aAttr.Put( SvxEscapementItem( SVX_ESCAPEMENT_SUPERSCRIPT, EE_CHAR_ESCAPEMENT ) );
2336 aEngine.QuickSetAttribs(aAttr, ESelection(0, 0, 0, aStr.getLength()));
2338 // The cell will own the text object instance.
2339 rDoc.SetEditText(aRanges[0]->aStart, aEngine.CreateTextObject());
2343 break;
2344 case SC_WID_UNO_CHCOLHDR:
2345 // chart header flags are set for this object, not stored with document
2346 bChartColAsHdr = ScUnoHelpFunctions::GetBoolFromAny( aValue );
2347 break;
2348 case SC_WID_UNO_CHROWHDR:
2349 bChartRowAsHdr = ScUnoHelpFunctions::GetBoolFromAny( aValue );
2350 break;
2351 case SC_WID_UNO_CELLSTYL:
2353 OUString aStrVal;
2354 aValue >>= aStrVal;
2355 OUString aString(ScStyleNameConversion::ProgrammaticToDisplayName(
2356 aStrVal, SFX_STYLE_FAMILY_PARA ));
2357 pDocShell->GetDocFunc().ApplyStyle( *GetMarkData(), aString, true, true );
2359 break;
2360 case SC_WID_UNO_TBLBORD:
2362 table::TableBorder aBorder;
2363 if ( !aRanges.empty() && ( aValue >>= aBorder ) ) // empty = nothing to do
2365 SvxBoxItem aOuter(ATTR_BORDER);
2366 SvxBoxInfoItem aInner(ATTR_BORDER_INNER);
2367 ScHelperFunctions::FillBoxItems( aOuter, aInner, aBorder );
2369 ScHelperFunctions::ApplyBorder( pDocShell, aRanges, aOuter, aInner ); //! docfunc
2372 break;
2373 case SC_WID_UNO_TBLBORD2:
2375 table::TableBorder2 aBorder2;
2376 if ( !aRanges.empty() && ( aValue >>= aBorder2 ) ) // empty = nothing to do
2378 SvxBoxItem aOuter(ATTR_BORDER);
2379 SvxBoxInfoItem aInner(ATTR_BORDER_INNER);
2380 ScHelperFunctions::FillBoxItems( aOuter, aInner, aBorder2 );
2382 ScHelperFunctions::ApplyBorder( pDocShell, aRanges, aOuter, aInner ); //! docfunc
2385 break;
2386 case SC_WID_UNO_CONDFMT:
2387 case SC_WID_UNO_CONDLOC:
2388 case SC_WID_UNO_CONDXML:
2390 uno::Reference<sheet::XSheetConditionalEntries> xInterface(aValue, uno::UNO_QUERY);
2391 if ( !aRanges.empty() && xInterface.is() ) // leer = nichts zu tun
2393 ScTableConditionalFormat* pFormat =
2394 ScTableConditionalFormat::getImplementation( xInterface );
2395 if (pFormat)
2397 ScDocument& rDoc = pDocShell->GetDocument();
2398 bool bEnglish = ( pEntry->nWID != SC_WID_UNO_CONDLOC );
2399 bool bXML = ( pEntry->nWID == SC_WID_UNO_CONDXML );
2400 formula::FormulaGrammar::Grammar eGrammar = (bXML ?
2401 formula::FormulaGrammar::GRAM_UNSPECIFIED :
2402 formula::FormulaGrammar::mapAPItoGrammar( bEnglish, bXML));
2404 SCTAB nTab = aRanges.front()->aStart.Tab();
2405 // To remove conditional formats for all cells in aRanges we need to:
2406 // Remove conditional format data from cells' attributes
2407 rDoc.RemoveCondFormatData( aRanges, nTab, 0 );
2408 // And also remove ranges from conditional formats list
2409 for (size_t i = 0; i < aRanges.size(); ++i)
2411 rDoc.GetCondFormList( aRanges[i]->aStart.Tab() )->DeleteArea(
2412 aRanges[i]->aStart.Col(), aRanges[i]->aStart.Row(),
2413 aRanges[i]->aEnd.Col(), aRanges[i]->aEnd.Row() );
2416 // Then we can apply new conditional format if there is one
2417 if (pFormat->getCount())
2419 ScConditionalFormat* pNew = new ScConditionalFormat( 0, &rDoc ); // Index wird beim Einfuegen gesetzt
2420 pFormat->FillFormat( *pNew, &rDoc, eGrammar );
2421 pNew->SetRange( aRanges );
2422 pDocShell->GetDocFunc().ReplaceConditionalFormat( 0, pNew, nTab, aRanges );
2425 // and repaint
2426 for (size_t i = 0; i < aRanges.size(); ++i)
2427 pDocShell->PostPaint(*aRanges[i], PAINT_GRID);
2428 pDocShell->SetDocumentModified();
2432 break;
2433 case SC_WID_UNO_VALIDAT:
2434 case SC_WID_UNO_VALILOC:
2435 case SC_WID_UNO_VALIXML:
2437 uno::Reference<beans::XPropertySet> xInterface(aValue, uno::UNO_QUERY);
2438 if ( !aRanges.empty() && xInterface.is() ) // leer = nichts zu tun
2440 ScTableValidationObj* pValidObj =
2441 ScTableValidationObj::getImplementation( xInterface );
2442 if (pValidObj)
2444 ScDocument& rDoc = pDocShell->GetDocument();
2445 bool bEnglish = ( pEntry->nWID != SC_WID_UNO_VALILOC );
2446 bool bXML = ( pEntry->nWID == SC_WID_UNO_VALIXML );
2447 formula::FormulaGrammar::Grammar eGrammar = (bXML ?
2448 formula::FormulaGrammar::GRAM_UNSPECIFIED :
2449 formula::FormulaGrammar::mapAPItoGrammar( bEnglish, bXML));
2451 boost::scoped_ptr<ScValidationData> pNewData(
2452 pValidObj->CreateValidationData( &rDoc, eGrammar ));
2453 sal_uLong nIndex = rDoc.AddValidationEntry( *pNewData );
2454 pNewData.reset();
2456 ScPatternAttr aPattern( rDoc.GetPool() );
2457 aPattern.GetItemSet().Put( SfxUInt32Item( ATTR_VALIDDATA, nIndex ) );
2458 pDocShell->GetDocFunc().ApplyAttributes( *GetMarkData(), aPattern, true, true );
2462 break;
2463 // SC_WID_UNO_NUMRULES is ignored...
2468 uno::Any SAL_CALL ScCellRangesBase::getPropertyValue( const OUString& aPropertyName )
2469 throw(beans::UnknownPropertyException, lang::WrappedTargetException,
2470 uno::RuntimeException, std::exception)
2472 SolarMutexGuard aGuard;
2474 if ( !pDocShell || aRanges.empty() )
2475 throw uno::RuntimeException();
2477 const SfxItemPropertyMap& rPropertyMap = GetItemPropertyMap(); // from derived class
2478 const SfxItemPropertySimpleEntry* pEntry = rPropertyMap.getByName( aPropertyName );
2479 if ( !pEntry )
2480 throw beans::UnknownPropertyException();
2482 uno::Any aAny;
2483 GetOnePropertyValue( pEntry, aAny );
2484 return aAny;
2487 void ScCellRangesBase::GetOnePropertyValue( const SfxItemPropertySimpleEntry* pEntry, uno::Any& rAny )
2488 throw(uno::RuntimeException, std::exception)
2490 if ( pEntry )
2492 if ( IsScItemWid( pEntry->nWID ) )
2494 SfxItemSet* pDataSet = GetCurrentDataSet();
2495 if ( pDataSet )
2497 switch ( pEntry->nWID ) // fuer Item-Spezial-Behandlungen
2499 case ATTR_VALUE_FORMAT:
2501 ScDocument& rDoc = pDocShell->GetDocument();
2503 sal_uLong nOldFormat = static_cast<const SfxUInt32Item&>(
2504 pDataSet->Get( ATTR_VALUE_FORMAT )).GetValue();
2505 LanguageType eOldLang = static_cast<const SvxLanguageItem&>(
2506 pDataSet->Get( ATTR_LANGUAGE_FORMAT )).GetLanguage();
2507 nOldFormat = rDoc.GetFormatTable()->
2508 GetFormatForLanguageIfBuiltIn( nOldFormat, eOldLang );
2509 rAny <<= (sal_Int32)( nOldFormat );
2511 break;
2512 case ATTR_INDENT:
2513 rAny <<= (sal_Int16)( TwipsToHMM(static_cast<const SfxUInt16Item&>(
2514 pDataSet->Get(pEntry->nWID)).GetValue()) );
2515 break;
2516 case ATTR_STACKED:
2518 sal_Int32 nRot = static_cast<const SfxInt32Item&>(pDataSet->Get(ATTR_ROTATE_VALUE)).GetValue();
2519 bool bStacked = static_cast<const SfxBoolItem&>(pDataSet->Get(pEntry->nWID)).GetValue();
2520 SvxOrientationItem( nRot, bStacked, 0 ).QueryValue( rAny );
2522 break;
2523 default:
2524 pPropSet->getPropertyValue(*pEntry, *pDataSet, rAny);
2528 else // implemented here
2529 switch ( pEntry->nWID )
2531 case SC_WID_UNO_CHCOLHDR:
2532 ScUnoHelpFunctions::SetBoolInAny( rAny, bChartColAsHdr );
2533 break;
2534 case SC_WID_UNO_CHROWHDR:
2535 ScUnoHelpFunctions::SetBoolInAny( rAny, bChartRowAsHdr );
2536 break;
2537 case SC_WID_UNO_CELLSTYL:
2539 OUString aStyleName;
2540 const ScStyleSheet* pStyle = pDocShell->GetDocument().GetSelectionStyle(*GetMarkData());
2541 if (pStyle)
2542 aStyleName = pStyle->GetName();
2543 rAny <<= OUString( ScStyleNameConversion::DisplayToProgrammaticName(
2544 aStyleName, SFX_STYLE_FAMILY_PARA ) );
2546 break;
2547 case SC_WID_UNO_TBLBORD:
2548 case SC_WID_UNO_TBLBORD2:
2550 //! loop throgh all ranges
2551 if ( !aRanges.empty() )
2553 const ScRange* pFirst = aRanges[ 0 ];
2554 SvxBoxItem aOuter(ATTR_BORDER);
2555 SvxBoxInfoItem aInner(ATTR_BORDER_INNER);
2557 ScDocument& rDoc = pDocShell->GetDocument();
2558 ScMarkData aMark;
2559 aMark.SetMarkArea( *pFirst );
2560 aMark.SelectTable( pFirst->aStart.Tab(), true );
2561 rDoc.GetSelectionFrame( aMark, aOuter, aInner );
2563 if (pEntry->nWID == SC_WID_UNO_TBLBORD2)
2564 ScHelperFunctions::AssignTableBorder2ToAny( rAny, aOuter, aInner);
2565 else
2566 ScHelperFunctions::AssignTableBorderToAny( rAny, aOuter, aInner);
2569 break;
2570 case SC_WID_UNO_CONDFMT:
2571 case SC_WID_UNO_CONDLOC:
2572 case SC_WID_UNO_CONDXML:
2574 const ScPatternAttr* pPattern = GetCurrentAttrsDeep();
2575 if ( pPattern )
2577 ScDocument& rDoc = pDocShell->GetDocument();
2578 bool bEnglish = ( pEntry->nWID != SC_WID_UNO_CONDLOC );
2579 bool bXML = ( pEntry->nWID == SC_WID_UNO_CONDXML );
2580 formula::FormulaGrammar::Grammar eGrammar = (bXML ?
2581 rDoc.GetStorageGrammar() :
2582 formula::FormulaGrammar::mapAPItoGrammar( bEnglish, bXML));
2583 const std::vector<sal_uInt32>& rIndex = static_cast<const ScCondFormatItem&>(
2584 pPattern->GetItem(ATTR_CONDITIONAL)).GetCondFormatData();
2585 sal_uLong nIndex = 0;
2586 if(!rIndex.empty())
2587 nIndex = rIndex[0];
2588 rAny <<= uno::Reference<sheet::XSheetConditionalEntries>(
2589 new ScTableConditionalFormat( &rDoc, nIndex, aRanges.front()->aStart.Tab(), eGrammar ));
2592 break;
2593 case SC_WID_UNO_VALIDAT:
2594 case SC_WID_UNO_VALILOC:
2595 case SC_WID_UNO_VALIXML:
2597 const ScPatternAttr* pPattern = GetCurrentAttrsDeep();
2598 if ( pPattern )
2600 ScDocument& rDoc = pDocShell->GetDocument();
2601 bool bEnglish = ( pEntry->nWID != SC_WID_UNO_VALILOC );
2602 bool bXML = ( pEntry->nWID == SC_WID_UNO_VALIXML );
2603 formula::FormulaGrammar::Grammar eGrammar = (bXML ?
2604 rDoc.GetStorageGrammar() :
2605 formula::FormulaGrammar::mapAPItoGrammar( bEnglish, bXML));
2606 sal_uLong nIndex = static_cast<const SfxUInt32Item&>(
2607 pPattern->GetItem(ATTR_VALIDDATA)).GetValue();
2608 rAny <<= uno::Reference<beans::XPropertySet>(
2609 new ScTableValidationObj( &rDoc, nIndex, eGrammar ));
2612 break;
2613 case SC_WID_UNO_NUMRULES:
2615 // always return empty numbering rules object
2616 rAny <<= uno::Reference<container::XIndexReplace>(ScStyleObj::CreateEmptyNumberingRules());
2618 break;
2619 case SC_WID_UNO_ABSNAME:
2621 OUString sRet;
2622 aRanges.Format(sRet, SCR_ABS_3D, &pDocShell->GetDocument());
2623 rAny <<= sRet;
2629 void SAL_CALL ScCellRangesBase::addPropertyChangeListener( const OUString& /* aPropertyName */,
2630 const uno::Reference<beans::XPropertyChangeListener>& /* aListener */)
2631 throw(beans::UnknownPropertyException,
2632 lang::WrappedTargetException, uno::RuntimeException, std::exception)
2634 SolarMutexGuard aGuard;
2635 if ( aRanges.empty() )
2636 throw uno::RuntimeException();
2638 OSL_FAIL("not implemented");
2641 void SAL_CALL ScCellRangesBase::removePropertyChangeListener( const OUString& /* aPropertyName */,
2642 const uno::Reference<beans::XPropertyChangeListener>& /* aListener */)
2643 throw(beans::UnknownPropertyException,
2644 lang::WrappedTargetException, uno::RuntimeException, std::exception)
2646 SolarMutexGuard aGuard;
2647 if ( aRanges.empty() )
2648 throw uno::RuntimeException();
2650 OSL_FAIL("not implemented");
2653 void SAL_CALL ScCellRangesBase::addVetoableChangeListener( const OUString&,
2654 const uno::Reference<beans::XVetoableChangeListener>&)
2655 throw(beans::UnknownPropertyException,
2656 lang::WrappedTargetException, uno::RuntimeException, std::exception)
2658 OSL_FAIL("not implemented");
2661 void SAL_CALL ScCellRangesBase::removeVetoableChangeListener( const OUString&,
2662 const uno::Reference<beans::XVetoableChangeListener>&)
2663 throw(beans::UnknownPropertyException,
2664 lang::WrappedTargetException, uno::RuntimeException, std::exception)
2666 OSL_FAIL("not implemented");
2669 // XMultiPropertySet
2671 void SAL_CALL ScCellRangesBase::setPropertyValues( const uno::Sequence< OUString >& aPropertyNames,
2672 const uno::Sequence< uno::Any >& aValues )
2673 throw (beans::PropertyVetoException,
2674 lang::IllegalArgumentException,
2675 lang::WrappedTargetException,
2676 uno::RuntimeException, std::exception)
2678 SolarMutexGuard aGuard;
2680 sal_Int32 nCount(aPropertyNames.getLength());
2681 sal_Int32 nValues(aValues.getLength());
2682 if (nCount != nValues)
2683 throw lang::IllegalArgumentException();
2685 if ( pDocShell && nCount )
2687 const SfxItemPropertyMap& rPropertyMap = GetItemPropertyMap(); // from derived class
2688 const OUString* pNames = aPropertyNames.getConstArray();
2689 const uno::Any* pValues = aValues.getConstArray();
2691 boost::scoped_array<const SfxItemPropertySimpleEntry*> pEntryArray(new const SfxItemPropertySimpleEntry*[nCount]);
2693 sal_Int32 i;
2694 for(i = 0; i < nCount; i++)
2696 // first loop: find all properties in map, but handle only CellStyle
2697 // (CellStyle must be set before any other cell properties)
2699 const SfxItemPropertySimpleEntry* pEntry = rPropertyMap.getByName( pNames[i] );
2700 pEntryArray[i] = pEntry;
2701 if (pEntry)
2703 if ( pEntry->nWID == SC_WID_UNO_CELLSTYL )
2707 SetOnePropertyValue( pEntry, pValues[i] );
2709 catch ( lang::IllegalArgumentException& )
2711 OSL_FAIL("exception when setting cell style"); // not supposed to happen
2717 ScDocument& rDoc = pDocShell->GetDocument();
2718 boost::scoped_ptr<ScPatternAttr> pOldPattern;
2719 boost::scoped_ptr<ScPatternAttr> pNewPattern;
2721 for(i = 0; i < nCount; i++)
2723 // second loop: handle other properties
2725 const SfxItemPropertySimpleEntry* pEntry = pEntryArray[i];
2726 if ( pEntry )
2728 if ( IsScItemWid( pEntry->nWID ) ) // can be handled by SfxItemPropertySet
2730 if ( !pOldPattern )
2732 pOldPattern.reset(new ScPatternAttr( *GetCurrentAttrsDeep() ));
2733 pOldPattern->GetItemSet().ClearInvalidItems();
2734 pNewPattern.reset(new ScPatternAttr( rDoc.GetPool() ));
2737 // collect items in pNewPattern, apply with one call after the loop
2739 sal_uInt16 nFirstItem, nSecondItem;
2740 lcl_SetCellProperty( *pEntry, pValues[i], *pOldPattern, rDoc, nFirstItem, nSecondItem );
2742 // put only affected items into new set
2743 if ( nFirstItem )
2744 pNewPattern->GetItemSet().Put( pOldPattern->GetItemSet().Get( nFirstItem ) );
2745 if ( nSecondItem )
2746 pNewPattern->GetItemSet().Put( pOldPattern->GetItemSet().Get( nSecondItem ) );
2748 else if ( pEntry->nWID != SC_WID_UNO_CELLSTYL ) // CellStyle is handled above
2750 // call virtual method to set a single property
2751 SetOnePropertyValue( pEntry, pValues[i] );
2756 if ( pNewPattern && !aRanges.empty() )
2757 pDocShell->GetDocFunc().ApplyAttributes( *GetMarkData(), *pNewPattern, true, true );
2761 uno::Sequence<uno::Any> SAL_CALL ScCellRangesBase::getPropertyValues(
2762 const uno::Sequence< OUString >& aPropertyNames )
2763 throw (uno::RuntimeException, std::exception)
2765 SolarMutexGuard aGuard;
2767 const SfxItemPropertyMap& rPropertyMap = GetItemPropertyMap(); // from derived class
2769 uno::Sequence<uno::Any> aRet(aPropertyNames.getLength());
2770 uno::Any* pProperties = aRet.getArray();
2771 for(sal_Int32 i = 0; i < aPropertyNames.getLength(); i++)
2773 const SfxItemPropertySimpleEntry* pEntry = rPropertyMap.getByName( aPropertyNames[i] );
2774 GetOnePropertyValue( pEntry, pProperties[i] );
2776 return aRet;
2779 void SAL_CALL ScCellRangesBase::addPropertiesChangeListener( const uno::Sequence< OUString >& /* aPropertyNames */,
2780 const uno::Reference< beans::XPropertiesChangeListener >& /* xListener */ )
2781 throw (uno::RuntimeException, std::exception)
2783 OSL_FAIL("not implemented");
2786 void SAL_CALL ScCellRangesBase::removePropertiesChangeListener( const uno::Reference< beans::XPropertiesChangeListener >& /* xListener */ )
2787 throw (uno::RuntimeException, std::exception)
2789 OSL_FAIL("not implemented");
2792 void SAL_CALL ScCellRangesBase::firePropertiesChangeEvent( const uno::Sequence< OUString >& /* aPropertyNames */,
2793 const uno::Reference< beans::XPropertiesChangeListener >& /* xListener */ )
2794 throw (uno::RuntimeException, std::exception)
2796 OSL_FAIL("not implemented");
2799 IMPL_LINK( ScCellRangesBase, ValueListenerHdl, SfxHint*, pHint )
2801 if ( pDocShell && pHint && dynamic_cast<const SfxSimpleHint*>(pHint) &&
2802 (static_cast<const SfxSimpleHint*>(pHint)->GetId() & SC_HINT_DATACHANGED))
2804 // This may be called several times for a single change, if several formulas
2805 // in the range are notified. So only a flag is set that is checked when
2806 // SFX_HINT_DATACHANGED is received.
2808 bGotDataChangedHint = true;
2810 return 0;
2813 // XTolerantMultiPropertySet
2814 uno::Sequence< beans::SetPropertyTolerantFailed > SAL_CALL ScCellRangesBase::setPropertyValuesTolerant( const uno::Sequence< OUString >& aPropertyNames,
2815 const uno::Sequence< uno::Any >& aValues )
2816 throw (lang::IllegalArgumentException, uno::RuntimeException, std::exception)
2818 SolarMutexGuard aGuard;
2820 sal_Int32 nCount(aPropertyNames.getLength());
2821 sal_Int32 nValues(aValues.getLength());
2822 if (nCount != nValues)
2823 throw lang::IllegalArgumentException();
2825 if ( pDocShell && nCount )
2827 uno::Sequence < beans::SetPropertyTolerantFailed > aReturns(nCount);
2828 beans::SetPropertyTolerantFailed* pReturns = aReturns.getArray();
2830 const SfxItemPropertyMap& rPropertyMap = GetItemPropertyMap(); // from derived class
2831 const OUString* pNames = aPropertyNames.getConstArray();
2832 const uno::Any* pValues = aValues.getConstArray();
2834 boost::scoped_array<const SfxItemPropertySimpleEntry*> pMapArray(new const SfxItemPropertySimpleEntry*[nCount]);
2836 sal_Int32 i;
2837 for(i = 0; i < nCount; i++)
2839 // first loop: find all properties in map, but handle only CellStyle
2840 // (CellStyle must be set before any other cell properties)
2842 const SfxItemPropertySimpleEntry* pEntry = rPropertyMap.getByName( pNames[i] );
2843 pMapArray[i] = pEntry;
2844 if (pEntry)
2846 if ( pEntry->nWID == SC_WID_UNO_CELLSTYL )
2850 SetOnePropertyValue( pEntry, pValues[i] );
2852 catch ( lang::IllegalArgumentException& )
2854 OSL_FAIL("exception when setting cell style"); // not supposed to happen
2860 ScDocument& rDoc = pDocShell->GetDocument();
2861 boost::scoped_ptr<ScPatternAttr> pOldPattern;
2862 boost::scoped_ptr<ScPatternAttr> pNewPattern;
2864 sal_Int32 nFailed(0);
2865 for(i = 0; i < nCount; i++)
2867 // second loop: handle other properties
2869 const SfxItemPropertySimpleEntry* pEntry = pMapArray[i];
2870 if ( pEntry && ((pEntry->nFlags & beans::PropertyAttribute::READONLY) == 0))
2872 if ( IsScItemWid( pEntry->nWID ) ) // can be handled by SfxItemPropertySet
2874 if ( !pOldPattern )
2876 pOldPattern.reset(new ScPatternAttr( *GetCurrentAttrsDeep() ));
2877 pOldPattern->GetItemSet().ClearInvalidItems();
2878 pNewPattern.reset(new ScPatternAttr( rDoc.GetPool() ));
2881 // collect items in pNewPattern, apply with one call after the loop
2883 sal_uInt16 nFirstItem, nSecondItem;
2886 lcl_SetCellProperty( *pEntry, pValues[i], *pOldPattern, rDoc, nFirstItem, nSecondItem );
2888 // put only affected items into new set
2889 if ( nFirstItem )
2890 pNewPattern->GetItemSet().Put( pOldPattern->GetItemSet().Get( nFirstItem ) );
2891 if ( nSecondItem )
2892 pNewPattern->GetItemSet().Put( pOldPattern->GetItemSet().Get( nSecondItem ) );
2894 catch ( lang::IllegalArgumentException& )
2896 pReturns[nFailed].Name = pNames[i];
2897 pReturns[nFailed++].Result = beans::TolerantPropertySetResultType::ILLEGAL_ARGUMENT;
2900 else if ( pEntry->nWID != SC_WID_UNO_CELLSTYL ) // CellStyle is handled above
2902 // call virtual method to set a single property
2905 SetOnePropertyValue( pEntry, pValues[i] );
2907 catch ( lang::IllegalArgumentException& )
2909 pReturns[nFailed].Name = pNames[i];
2910 pReturns[nFailed++].Result = beans::TolerantPropertySetResultType::ILLEGAL_ARGUMENT;
2914 else
2916 pReturns[nFailed].Name = pNames[i];
2917 if (pEntry)
2918 pReturns[nFailed++].Result = beans::TolerantPropertySetResultType::PROPERTY_VETO;
2919 else
2920 pReturns[nFailed++].Result = beans::TolerantPropertySetResultType::UNKNOWN_PROPERTY;
2924 if ( pNewPattern && !aRanges.empty() )
2925 pDocShell->GetDocFunc().ApplyAttributes( *GetMarkData(), *pNewPattern, true, true );
2927 aReturns.realloc(nFailed);
2929 return aReturns;
2931 return uno::Sequence < beans::SetPropertyTolerantFailed >();
2934 uno::Sequence< beans::GetPropertyTolerantResult > SAL_CALL ScCellRangesBase::getPropertyValuesTolerant( const uno::Sequence< OUString >& aPropertyNames )
2935 throw (uno::RuntimeException, std::exception)
2937 SolarMutexGuard aGuard;
2939 sal_Int32 nCount(aPropertyNames.getLength());
2940 uno::Sequence < beans::GetPropertyTolerantResult > aReturns(nCount);
2941 beans::GetPropertyTolerantResult* pReturns = aReturns.getArray();
2943 const SfxItemPropertyMap& rPropertyMap = GetItemPropertyMap(); // from derived class
2945 for(sal_Int32 i = 0; i < nCount; i++)
2947 const SfxItemPropertySimpleEntry* pEntry = rPropertyMap.getByName( aPropertyNames[i] );
2948 if (!pEntry)
2950 pReturns[i].Result = beans::TolerantPropertySetResultType::UNKNOWN_PROPERTY;
2952 else
2954 sal_uInt16 nItemWhich = 0;
2955 lcl_GetPropertyWhich( pEntry, nItemWhich );
2956 pReturns[i].State = GetOnePropertyState( nItemWhich, pEntry );
2957 GetOnePropertyValue( pEntry, pReturns[i].Value );
2958 pReturns[i].Result = beans::TolerantPropertySetResultType::SUCCESS;
2961 return aReturns;
2964 uno::Sequence< beans::GetDirectPropertyTolerantResult > SAL_CALL ScCellRangesBase::getDirectPropertyValuesTolerant( const uno::Sequence< OUString >& aPropertyNames )
2965 throw (uno::RuntimeException, std::exception)
2967 SolarMutexGuard aGuard;
2969 sal_Int32 nCount(aPropertyNames.getLength());
2970 uno::Sequence < beans::GetDirectPropertyTolerantResult > aReturns(nCount);
2971 beans::GetDirectPropertyTolerantResult* pReturns = aReturns.getArray();
2973 const SfxItemPropertyMap& rPropertyMap = GetItemPropertyMap(); // from derived class
2975 sal_Int32 j = 0;
2976 for(sal_Int32 i = 0; i < nCount; i++)
2978 const SfxItemPropertySimpleEntry* pEntry = rPropertyMap.getByName( aPropertyNames[i] );
2979 if (!pEntry)
2981 pReturns[i].Result = beans::TolerantPropertySetResultType::UNKNOWN_PROPERTY;
2983 else
2985 sal_uInt16 nItemWhich = 0;
2986 lcl_GetPropertyWhich( pEntry, nItemWhich );
2987 pReturns[j].State = GetOnePropertyState( nItemWhich, pEntry );
2988 if (pReturns[j].State == beans::PropertyState_DIRECT_VALUE)
2990 GetOnePropertyValue( pEntry, pReturns[j].Value );
2991 pReturns[j].Result = beans::TolerantPropertySetResultType::SUCCESS;
2992 pReturns[j].Name = aPropertyNames[i];
2993 ++j;
2997 if (j < nCount)
2998 aReturns.realloc(j);
2999 return aReturns;
3002 // XIndent
3004 void SAL_CALL ScCellRangesBase::decrementIndent() throw(::com::sun::star::uno::RuntimeException, std::exception)
3006 SolarMutexGuard aGuard;
3007 if ( pDocShell && !aRanges.empty() ) // leer = nichts zu tun
3009 //#97041#; put only MultiMarked ScMarkData in ChangeIndent
3010 ScMarkData aMarkData(*GetMarkData());
3011 aMarkData.MarkToMulti();
3012 pDocShell->GetDocFunc().ChangeIndent( aMarkData, false, true );
3016 void SAL_CALL ScCellRangesBase::incrementIndent() throw(::com::sun::star::uno::RuntimeException, std::exception)
3018 SolarMutexGuard aGuard;
3019 if ( pDocShell && !aRanges.empty() ) // leer = nichts zu tun
3021 //#97041#; put only MultiMarked ScMarkData in ChangeIndent
3022 ScMarkData aMarkData(*GetMarkData());
3023 aMarkData.MarkToMulti();
3024 pDocShell->GetDocFunc().ChangeIndent( aMarkData, true, true );
3028 // XChartData
3030 ScMemChart* ScCellRangesBase::CreateMemChart_Impl() const
3032 if ( pDocShell && !aRanges.empty() )
3034 ScRangeListRef xChartRanges;
3035 if ( aRanges.size() == 1 )
3037 // ganze Tabelle sinnvoll begrenzen (auf belegten Datenbereich)
3038 // (nur hier, Listener werden auf den ganzen Bereich angemeldet)
3039 //! direkt testen, ob es ein ScTableSheetObj ist?
3041 const ScRange* pRange = aRanges[0];
3042 if ( pRange->aStart.Col() == 0 && pRange->aEnd.Col() == MAXCOL &&
3043 pRange->aStart.Row() == 0 && pRange->aEnd.Row() == MAXROW )
3045 SCTAB nTab = pRange->aStart.Tab();
3047 SCCOL nStartX;
3048 SCROW nStartY; // Anfang holen
3049 if (!pDocShell->GetDocument().GetDataStart( nTab, nStartX, nStartY ))
3051 nStartX = 0;
3052 nStartY = 0;
3055 SCCOL nEndX;
3056 SCROW nEndY; // Ende holen
3057 if (!pDocShell->GetDocument().GetTableArea( nTab, nEndX, nEndY ))
3059 nEndX = 0;
3060 nEndY = 0;
3063 xChartRanges = new ScRangeList;
3064 xChartRanges->Append( ScRange( nStartX, nStartY, nTab, nEndX, nEndY, nTab ) );
3067 if (!xChartRanges.Is()) // sonst Ranges direkt uebernehmen
3068 xChartRanges = new ScRangeList(aRanges);
3069 ScChartArray aArr( &pDocShell->GetDocument(), xChartRanges, OUString() );
3071 // RowAsHdr = ColHeaders und umgekehrt
3072 aArr.SetHeaders( bChartRowAsHdr, bChartColAsHdr );
3074 return aArr.CreateMemChart();
3076 return NULL;
3079 uno::Sequence< uno::Sequence<double> > SAL_CALL ScCellRangesBase::getData()
3080 throw(uno::RuntimeException, std::exception)
3082 SolarMutexGuard aGuard;
3083 boost::scoped_ptr<ScMemChart> pMemChart(CreateMemChart_Impl());
3084 if ( pMemChart )
3086 sal_Int32 nColCount = pMemChart->GetColCount();
3087 sal_Int32 nRowCount = static_cast<sal_Int32>(pMemChart->GetRowCount());
3089 uno::Sequence< uno::Sequence<double> > aRowSeq( nRowCount );
3090 uno::Sequence<double>* pRowAry = aRowSeq.getArray();
3091 for (sal_Int32 nRow = 0; nRow < nRowCount; nRow++)
3093 uno::Sequence<double> aColSeq( nColCount );
3094 double* pColAry = aColSeq.getArray();
3095 for (sal_Int32 nCol = 0; nCol < nColCount; nCol++)
3096 pColAry[nCol] = pMemChart->GetData( nCol, nRow );
3098 pRowAry[nRow] = aColSeq;
3101 return aRowSeq;
3104 return uno::Sequence< uno::Sequence<double> >(0);
3107 ScRangeListRef ScCellRangesBase::GetLimitedChartRanges_Impl( long nDataColumns, long nDataRows ) const
3109 if ( aRanges.size() == 1 )
3111 const ScRange* pRange = aRanges[0];
3112 if ( pRange->aStart.Col() == 0 && pRange->aEnd.Col() == MAXCOL &&
3113 pRange->aStart.Row() == 0 && pRange->aEnd.Row() == MAXROW )
3115 // if aRanges is a complete sheet, limit to given size
3117 SCTAB nTab = pRange->aStart.Tab();
3119 long nEndColumn = nDataColumns - 1 + ( bChartColAsHdr ? 1 : 0 );
3120 if ( nEndColumn < 0 )
3121 nEndColumn = 0;
3122 if ( nEndColumn > MAXCOL )
3123 nEndColumn = MAXCOL;
3125 long nEndRow = nDataRows - 1 + ( bChartRowAsHdr ? 1 : 0 );
3126 if ( nEndRow < 0 )
3127 nEndRow = 0;
3128 if ( nEndRow > MAXROW )
3129 nEndRow = MAXROW;
3131 ScRangeListRef xChartRanges = new ScRangeList;
3132 xChartRanges->Append( ScRange( 0, 0, nTab, (SCCOL)nEndColumn, (SCROW)nEndRow, nTab ) );
3133 return xChartRanges;
3137 return new ScRangeList(aRanges); // as-is
3140 void SAL_CALL ScCellRangesBase::setData( const uno::Sequence< uno::Sequence<double> >& aData )
3141 throw(uno::RuntimeException, std::exception)
3143 SolarMutexGuard aGuard;
3144 bool bDone = false;
3145 long nRowCount = aData.getLength();
3146 long nColCount = nRowCount ? aData[0].getLength() : 0;
3147 ScRangeListRef xChartRanges = GetLimitedChartRanges_Impl( nColCount, nRowCount );
3148 if ( pDocShell && xChartRanges.Is() )
3150 ScDocument& rDoc = pDocShell->GetDocument();
3151 ScChartArray aArr( &rDoc, xChartRanges, OUString() );
3152 aArr.SetHeaders( bChartRowAsHdr, bChartColAsHdr ); // RowAsHdr = ColHeaders
3153 const ScChartPositionMap* pPosMap = aArr.GetPositionMap();
3154 if (pPosMap)
3156 if ( pPosMap->GetColCount() == static_cast<SCCOL>(nColCount) &&
3157 pPosMap->GetRowCount() == static_cast<SCROW>(nRowCount) )
3159 for (long nRow=0; nRow<nRowCount; nRow++)
3161 const uno::Sequence<double>& rRowSeq = aData[nRow];
3162 const double* pArray = rRowSeq.getConstArray();
3163 nColCount = rRowSeq.getLength();
3164 for (long nCol=0; nCol<nColCount; nCol++)
3166 const ScAddress* pPos = pPosMap->GetPosition(
3167 sal::static_int_cast<SCCOL>(nCol),
3168 sal::static_int_cast<SCROW>(nRow) );
3169 if (pPos)
3171 double fVal = pArray[nCol];
3172 if ( fVal == DBL_MIN )
3173 rDoc.SetEmptyCell(*pPos);
3174 else
3175 rDoc.SetValue(*pPos, pArray[nCol]);
3180 //! undo
3181 PaintRanges_Impl( PAINT_GRID );
3182 pDocShell->SetDocumentModified();
3183 ForceChartListener_Impl(); // call listeners for this object synchronously
3184 bDone = true;
3189 if (!bDone)
3190 throw uno::RuntimeException();
3193 uno::Sequence<OUString> SAL_CALL ScCellRangesBase::getRowDescriptions()
3194 throw(uno::RuntimeException, std::exception)
3196 SolarMutexGuard aGuard;
3197 boost::scoped_ptr<ScMemChart> pMemChart(CreateMemChart_Impl());
3198 if ( pMemChart )
3200 sal_Int32 nRowCount = static_cast<sal_Int32>(pMemChart->GetRowCount());
3201 uno::Sequence<OUString> aSeq( nRowCount );
3202 OUString* pAry = aSeq.getArray();
3203 for (sal_Int32 nRow = 0; nRow < nRowCount; nRow++)
3204 pAry[nRow] = pMemChart->GetRowText(nRow);
3206 return aSeq;
3208 return uno::Sequence<OUString>(0);
3211 void SAL_CALL ScCellRangesBase::setRowDescriptions(
3212 const uno::Sequence<OUString>& aRowDescriptions )
3213 throw(uno::RuntimeException, std::exception)
3215 SolarMutexGuard aGuard;
3216 bool bDone = false;
3217 if ( bChartColAsHdr )
3219 long nRowCount = aRowDescriptions.getLength();
3220 ScRangeListRef xChartRanges = GetLimitedChartRanges_Impl( 1, nRowCount );
3221 if ( pDocShell && xChartRanges.Is() )
3223 ScDocument& rDoc = pDocShell->GetDocument();
3224 ScChartArray aArr( &rDoc, xChartRanges, OUString() );
3225 aArr.SetHeaders( bChartRowAsHdr, bChartColAsHdr ); // RowAsHdr = ColHeaders
3226 const ScChartPositionMap* pPosMap = aArr.GetPositionMap();
3227 if (pPosMap)
3229 if ( pPosMap->GetRowCount() == static_cast<SCROW>(nRowCount) )
3231 const OUString* pArray = aRowDescriptions.getConstArray();
3232 for (long nRow=0; nRow<nRowCount; nRow++)
3234 const ScAddress* pPos = pPosMap->GetRowHeaderPosition(
3235 static_cast<SCSIZE>(nRow) );
3236 if (pPos)
3238 const OUString& aStr = pArray[nRow];
3239 if (aStr.isEmpty())
3240 rDoc.SetEmptyCell(*pPos);
3241 else
3243 ScSetStringParam aParam;
3244 aParam.setTextInput();
3245 rDoc.SetString(*pPos, aStr, &aParam);
3250 //! undo
3251 PaintRanges_Impl( PAINT_GRID );
3252 pDocShell->SetDocumentModified();
3253 ForceChartListener_Impl(); // call listeners for this object synchronously
3254 bDone = true;
3260 if (!bDone)
3261 throw uno::RuntimeException();
3264 uno::Sequence<OUString> SAL_CALL ScCellRangesBase::getColumnDescriptions()
3265 throw(uno::RuntimeException, std::exception)
3267 SolarMutexGuard aGuard;
3268 boost::scoped_ptr<ScMemChart> pMemChart(CreateMemChart_Impl());
3269 if ( pMemChart )
3271 sal_Int32 nColCount = pMemChart->GetColCount();
3272 uno::Sequence<OUString> aSeq( nColCount );
3273 OUString* pAry = aSeq.getArray();
3274 for (sal_Int32 nCol = 0; nCol < nColCount; nCol++)
3275 pAry[nCol] = pMemChart->GetColText(nCol);
3277 return aSeq;
3279 return uno::Sequence<OUString>(0);
3282 void SAL_CALL ScCellRangesBase::setColumnDescriptions(
3283 const uno::Sequence<OUString>& aColumnDescriptions )
3284 throw(uno::RuntimeException, std::exception)
3286 SolarMutexGuard aGuard;
3287 bool bDone = false;
3288 if ( bChartRowAsHdr )
3290 long nColCount = aColumnDescriptions.getLength();
3291 ScRangeListRef xChartRanges = GetLimitedChartRanges_Impl( nColCount, 1 );
3292 if ( pDocShell && xChartRanges.Is() )
3294 ScDocument& rDoc = pDocShell->GetDocument();
3295 ScChartArray aArr( &rDoc, xChartRanges, OUString() );
3296 aArr.SetHeaders( bChartRowAsHdr, bChartColAsHdr ); // RowAsHdr = ColHeaders
3297 const ScChartPositionMap* pPosMap = aArr.GetPositionMap();
3298 if (pPosMap)
3300 if ( pPosMap->GetColCount() == static_cast<SCCOL>(nColCount) )
3302 const OUString* pArray = aColumnDescriptions.getConstArray();
3303 for (long nCol=0; nCol<nColCount; nCol++)
3305 const ScAddress* pPos = pPosMap->GetColHeaderPosition(
3306 sal::static_int_cast<SCCOL>(nCol) );
3307 if (pPos)
3309 const OUString& aStr = pArray[nCol];
3310 if (aStr.isEmpty())
3311 rDoc.SetEmptyCell(*pPos);
3312 else
3314 ScSetStringParam aParam;
3315 aParam.setTextInput();
3316 rDoc.SetString(*pPos, aStr, &aParam);
3321 //! undo
3322 PaintRanges_Impl( PAINT_GRID );
3323 pDocShell->SetDocumentModified();
3324 ForceChartListener_Impl(); // call listeners for this object synchronously
3325 bDone = true;
3331 if (!bDone)
3332 throw uno::RuntimeException();
3335 void ScCellRangesBase::ForceChartListener_Impl()
3337 // call Update immediately so the caller to setData etc. can
3338 // regognize the listener call
3340 if (!pDocShell)
3341 return;
3343 ScChartListenerCollection* pColl = pDocShell->GetDocument().GetChartListenerCollection();
3344 if (!pColl)
3345 return;
3347 ScChartListenerCollection::ListenersType& rListeners = pColl->getListeners();
3348 ScChartListenerCollection::ListenersType::iterator it = rListeners.begin(), itEnd = rListeners.end();
3349 for (; it != itEnd; ++it)
3351 ScChartListener* p = it->second;
3352 OSL_ASSERT(p);
3353 if (p->GetUnoSource() == static_cast<chart::XChartData*>(this) && p->IsDirty())
3354 p->Update();
3358 void SAL_CALL ScCellRangesBase::addChartDataChangeEventListener( const uno::Reference<
3359 chart::XChartDataChangeEventListener >& aListener )
3360 throw(uno::RuntimeException, std::exception)
3362 SolarMutexGuard aGuard;
3363 if ( pDocShell && !aRanges.empty() )
3365 //! auf doppelte testen?
3367 ScDocument& rDoc = pDocShell->GetDocument();
3368 ScRangeListRef aRangesRef( new ScRangeList(aRanges) );
3369 ScChartListenerCollection* pColl = rDoc.GetChartListenerCollection();
3370 OUString aName = pColl->getUniqueName(OUString("__Uno"));
3371 if (aName.isEmpty())
3372 // failed to create unique name.
3373 return;
3375 ScChartListener* pListener = new ScChartListener( aName, &rDoc, aRangesRef );
3376 pListener->SetUno( aListener, this );
3377 pColl->insert( pListener );
3378 pListener->StartListeningTo();
3382 void SAL_CALL ScCellRangesBase::removeChartDataChangeEventListener( const uno::Reference<
3383 chart::XChartDataChangeEventListener >& aListener )
3384 throw (uno::RuntimeException, std::exception)
3386 SolarMutexGuard aGuard;
3387 if ( pDocShell && !aRanges.empty() )
3389 ScDocument& rDoc = pDocShell->GetDocument();
3390 ScChartListenerCollection* pColl = rDoc.GetChartListenerCollection();
3391 pColl->FreeUno( aListener, this );
3395 double SAL_CALL ScCellRangesBase::getNotANumber() throw(::com::sun::star::uno::RuntimeException, std::exception)
3397 // im ScChartArray wird DBL_MIN verwendet, weil das Chart es so will
3398 return DBL_MIN;
3401 sal_Bool SAL_CALL ScCellRangesBase::isNotANumber( double nNumber ) throw(uno::RuntimeException, std::exception)
3403 // im ScChartArray wird DBL_MIN verwendet, weil das Chart es so will
3404 return (nNumber == DBL_MIN);
3407 // XModifyBroadcaster
3409 void SAL_CALL ScCellRangesBase::addModifyListener(const uno::Reference<util::XModifyListener>& aListener)
3410 throw (uno::RuntimeException, std::exception)
3412 SolarMutexGuard aGuard;
3413 if ( aRanges.empty() )
3414 throw uno::RuntimeException();
3416 uno::Reference<util::XModifyListener> *pObj =
3417 new uno::Reference<util::XModifyListener>( aListener );
3418 aValueListeners.push_back( pObj );
3420 if ( aValueListeners.size() == 1 )
3422 if (!pValueListener)
3423 pValueListener = new ScLinkListener( LINK( this, ScCellRangesBase, ValueListenerHdl ) );
3425 ScDocument& rDoc = pDocShell->GetDocument();
3426 for ( size_t i = 0, nCount = aRanges.size(); i < nCount; i++)
3427 rDoc.StartListeningArea( *aRanges[ i ], false, pValueListener );
3429 acquire(); // don't lose this object (one ref for all listeners)
3433 void SAL_CALL ScCellRangesBase::removeModifyListener( const uno::Reference<util::XModifyListener>& aListener )
3434 throw(uno::RuntimeException, std::exception)
3437 SolarMutexGuard aGuard;
3438 if ( aRanges.empty() )
3439 throw uno::RuntimeException();
3441 acquire(); // in case the listeners have the last ref - released below
3443 sal_uInt16 nCount = aValueListeners.size();
3444 for ( sal_uInt16 n=nCount; n--; )
3446 uno::Reference<util::XModifyListener>& rObj = aValueListeners[n];
3447 if ( rObj == aListener )
3449 aValueListeners.erase( aValueListeners.begin() + n );
3451 if ( aValueListeners.empty() )
3453 if (pValueListener)
3454 pValueListener->EndListeningAll();
3456 release(); // release the ref for the listeners
3459 break;
3463 release(); // might delete this object
3466 // XCellRangesQuery
3468 uno::Reference<sheet::XSheetCellRanges> SAL_CALL ScCellRangesBase::queryVisibleCells()
3469 throw(uno::RuntimeException, std::exception)
3471 SolarMutexGuard aGuard;
3472 if (pDocShell)
3474 //! fuer alle Tabellen getrennt, wenn Markierungen pro Tabelle getrennt sind!
3475 SCTAB nTab = lcl_FirstTab(aRanges);
3477 ScMarkData aMarkData(*GetMarkData());
3479 ScDocument& rDoc = pDocShell->GetDocument();
3480 SCCOL nCol = 0, nLastCol;
3481 while (nCol <= MAXCOL)
3483 if (rDoc.ColHidden(nCol, nTab, NULL, &nLastCol))
3484 // hidden columns. Unselect them.
3485 aMarkData.SetMultiMarkArea(ScRange(nCol, 0, nTab, nLastCol, MAXROW, nTab), false);
3487 nCol = nLastCol + 1;
3490 SCROW nRow = 0, nLastRow;
3491 while (nRow <= MAXROW)
3493 if (rDoc.RowHidden(nRow, nTab, NULL, &nLastRow))
3494 // These rows are hidden. Unselect them.
3495 aMarkData.SetMultiMarkArea(ScRange(0, nRow, nTab, MAXCOL, nLastRow, nTab), false);
3497 nRow = nLastRow + 1;
3500 ScRangeList aNewRanges;
3501 aMarkData.FillRangeListWithMarks( &aNewRanges, false );
3502 return new ScCellRangesObj( pDocShell, aNewRanges );
3505 return NULL;
3508 uno::Reference<sheet::XSheetCellRanges> SAL_CALL ScCellRangesBase::queryEmptyCells()
3509 throw(uno::RuntimeException, std::exception)
3511 SolarMutexGuard aGuard;
3512 if (pDocShell)
3514 ScDocument& rDoc = pDocShell->GetDocument();
3516 ScMarkData aMarkData(*GetMarkData());
3518 // belegte Zellen wegmarkieren
3519 for (size_t i = 0, nCount = aRanges.size(); i < nCount; ++i)
3521 ScRange aRange = *aRanges[ i ];
3523 ScCellIterator aIter( &rDoc, aRange );
3524 for (bool bHasCell = aIter.first(); bHasCell; bHasCell = aIter.next())
3526 // Notizen zaehlen als nicht-leer
3527 if (!aIter.isEmpty())
3528 aMarkData.SetMultiMarkArea(aIter.GetPos(), false);
3532 ScRangeList aNewRanges;
3533 // IsMultiMarked reicht hier nicht (wird beim deselektieren nicht zurueckgesetzt)
3534 //if (aMarkData.HasAnyMultiMarks()) // #i20044# should be set for all empty range
3535 aMarkData.FillRangeListWithMarks( &aNewRanges, false );
3537 return new ScCellRangesObj( pDocShell, aNewRanges ); // aNewRanges kann leer sein
3540 return NULL;
3543 uno::Reference<sheet::XSheetCellRanges> SAL_CALL ScCellRangesBase::queryContentCells(
3544 sal_Int16 nContentFlags )
3545 throw(uno::RuntimeException, std::exception)
3547 SolarMutexGuard aGuard;
3548 if (pDocShell)
3550 ScDocument& rDoc = pDocShell->GetDocument();
3552 ScMarkData aMarkData;
3554 // passende Zellen selektieren
3555 for ( size_t i = 0, nCount = aRanges.size(); i < nCount; ++i )
3557 ScRange aRange = *aRanges[ i ];
3559 ScCellIterator aIter( &rDoc, aRange );
3560 for (bool bHasCell = aIter.first(); bHasCell; bHasCell = aIter.next())
3562 bool bAdd = false;
3563 switch (aIter.getType())
3565 case CELLTYPE_STRING:
3566 if ( nContentFlags & sheet::CellFlags::STRING )
3567 bAdd = true;
3568 break;
3569 case CELLTYPE_EDIT:
3570 if ( (nContentFlags & sheet::CellFlags::STRING) || (nContentFlags & sheet::CellFlags::FORMATTED) )
3571 bAdd = true;
3572 break;
3573 case CELLTYPE_FORMULA:
3574 if ( nContentFlags & sheet::CellFlags::FORMULA )
3575 bAdd = true;
3576 break;
3577 case CELLTYPE_VALUE:
3578 if ( (nContentFlags & (sheet::CellFlags::VALUE|sheet::CellFlags::DATETIME))
3579 == (sheet::CellFlags::VALUE|sheet::CellFlags::DATETIME) )
3580 bAdd = true;
3581 else
3583 // Date/Time Erkennung
3585 sal_uLong nIndex = (sal_uLong)static_cast<const SfxUInt32Item*>(rDoc.GetAttr(
3586 aIter.GetPos(), ATTR_VALUE_FORMAT))->GetValue();
3587 short nTyp = rDoc.GetFormatTable()->GetType(nIndex);
3588 if ((nTyp == css::util::NumberFormat::DATE) || (nTyp == css::util::NumberFormat::TIME) ||
3589 (nTyp == css::util::NumberFormat::DATETIME))
3591 if ( nContentFlags & sheet::CellFlags::DATETIME )
3592 bAdd = true;
3594 else
3596 if ( nContentFlags & sheet::CellFlags::VALUE )
3597 bAdd = true;
3600 break;
3601 default:
3603 // added to avoid warnings
3607 if (bAdd)
3608 aMarkData.SetMultiMarkArea(aIter.GetPos(), true);
3613 ScRangeList aNewRanges;
3614 if (aMarkData.IsMultiMarked())
3615 aMarkData.FillRangeListWithMarks( &aNewRanges, false );
3617 return new ScCellRangesObj( pDocShell, aNewRanges ); // aNewRanges kann leer sein
3620 return NULL;
3623 uno::Reference<sheet::XSheetCellRanges> SAL_CALL ScCellRangesBase::queryFormulaCells(
3624 sal_Int32 nResultFlags )
3625 throw(uno::RuntimeException, std::exception)
3627 SolarMutexGuard aGuard;
3628 if (pDocShell)
3630 ScDocument& rDoc = pDocShell->GetDocument();
3632 ScMarkData aMarkData;
3634 // passende Zellen selektieren
3635 for ( size_t i = 0, nCount = aRanges.size(); i < nCount; ++i )
3637 ScRange aRange = *aRanges[ i ];
3639 ScCellIterator aIter( &rDoc, aRange );
3640 for (bool bHasCell = aIter.first(); bHasCell; bHasCell = aIter.next())
3642 if (aIter.getType() == CELLTYPE_FORMULA)
3644 ScFormulaCell* pFCell = aIter.getFormulaCell();
3645 bool bAdd = false;
3646 if (pFCell->GetErrCode())
3648 if ( nResultFlags & sheet::FormulaResult::ERROR )
3649 bAdd = true;
3651 else if (pFCell->IsValue())
3653 if ( nResultFlags & sheet::FormulaResult::VALUE )
3654 bAdd = true;
3656 else // String
3658 if ( nResultFlags & sheet::FormulaResult::STRING )
3659 bAdd = true;
3662 if (bAdd)
3663 aMarkData.SetMultiMarkArea(aIter.GetPos(), true);
3668 ScRangeList aNewRanges;
3669 if (aMarkData.IsMultiMarked())
3670 aMarkData.FillRangeListWithMarks( &aNewRanges, false );
3672 return new ScCellRangesObj( pDocShell, aNewRanges ); // aNewRanges kann leer sein
3675 return NULL;
3678 uno::Reference<sheet::XSheetCellRanges> ScCellRangesBase::QueryDifferences_Impl(
3679 const table::CellAddress& aCompare, bool bColumnDiff)
3681 if (pDocShell)
3683 size_t nRangeCount = aRanges.size();
3684 size_t i;
3685 ScDocument& rDoc = pDocShell->GetDocument();
3686 ScMarkData aMarkData;
3688 SCCOLROW nCmpPos = bColumnDiff ? (SCCOLROW)aCompare.Row : (SCCOLROW)aCompare.Column;
3690 // zuerst alles selektieren, wo ueberhaupt etwas in der Vergleichsspalte steht
3691 // (fuer gleiche Zellen wird die Selektion im zweiten Schritt aufgehoben)
3693 SCTAB nTab = lcl_FirstTab(aRanges); //! fuer alle Tabellen, wenn Markierungen pro Tabelle!
3694 ScRange aCmpRange, aCellRange;
3695 if (bColumnDiff)
3696 aCmpRange = ScRange( 0,nCmpPos,nTab, MAXCOL,nCmpPos,nTab );
3697 else
3698 aCmpRange = ScRange( static_cast<SCCOL>(nCmpPos),0,nTab, static_cast<SCCOL>(nCmpPos),MAXROW,nTab );
3699 ScCellIterator aCmpIter( &rDoc, aCmpRange );
3700 for (bool bHasCell = aCmpIter.first(); bHasCell; bHasCell = aCmpIter.next())
3702 SCCOLROW nCellPos = bColumnDiff ? static_cast<SCCOLROW>(aCmpIter.GetPos().Col()) : static_cast<SCCOLROW>(aCmpIter.GetPos().Row());
3703 if (bColumnDiff)
3704 aCellRange = ScRange( static_cast<SCCOL>(nCellPos),0,nTab,
3705 static_cast<SCCOL>(nCellPos),MAXROW,nTab );
3706 else
3707 aCellRange = ScRange( 0,nCellPos,nTab, MAXCOL,nCellPos,nTab );
3709 for (i=0; i<nRangeCount; i++)
3711 ScRange aRange( *aRanges[ i ] );
3712 if ( aRange.Intersects( aCellRange ) )
3714 if (bColumnDiff)
3716 aRange.aStart.SetCol(static_cast<SCCOL>(nCellPos));
3717 aRange.aEnd.SetCol(static_cast<SCCOL>(nCellPos));
3719 else
3721 aRange.aStart.SetRow(nCellPos);
3722 aRange.aEnd.SetRow(nCellPos);
3724 aMarkData.SetMultiMarkArea( aRange );
3729 // alle nichtleeren Zellen mit der Vergleichsspalte vergleichen und entsprechend
3730 // selektieren oder aufheben
3732 ScAddress aCmpAddr;
3733 for (i=0; i<nRangeCount; i++)
3735 ScRange aRange( *aRanges[ i ] );
3737 ScCellIterator aIter( &rDoc, aRange );
3738 for (bool bHasCell = aIter.first(); bHasCell; bHasCell = aIter.next())
3740 if (bColumnDiff)
3741 aCmpAddr = ScAddress( aIter.GetPos().Col(), nCmpPos, aIter.GetPos().Tab() );
3742 else
3743 aCmpAddr = ScAddress( static_cast<SCCOL>(nCmpPos), aIter.GetPos().Row(), aIter.GetPos().Tab() );
3745 ScRange aOneRange(aIter.GetPos());
3746 if (!aIter.equalsWithoutFormat(aCmpAddr))
3747 aMarkData.SetMultiMarkArea( aOneRange );
3748 else
3749 aMarkData.SetMultiMarkArea( aOneRange, false ); // deselect
3753 ScRangeList aNewRanges;
3754 if (aMarkData.IsMultiMarked())
3755 aMarkData.FillRangeListWithMarks( &aNewRanges, false );
3757 return new ScCellRangesObj( pDocShell, aNewRanges ); // aNewRanges kann leer sein
3759 return NULL;
3762 uno::Reference<sheet::XSheetCellRanges > SAL_CALL ScCellRangesBase::queryColumnDifferences(
3763 const table::CellAddress& aCompare ) throw(uno::RuntimeException, std::exception)
3765 SolarMutexGuard aGuard;
3766 return QueryDifferences_Impl( aCompare, true );
3769 uno::Reference<sheet::XSheetCellRanges> SAL_CALL ScCellRangesBase::queryRowDifferences(
3770 const table::CellAddress& aCompare ) throw(uno::RuntimeException, std::exception)
3772 SolarMutexGuard aGuard;
3773 return QueryDifferences_Impl( aCompare, false );
3776 uno::Reference<sheet::XSheetCellRanges> SAL_CALL ScCellRangesBase::queryIntersection(
3777 const table::CellRangeAddress& aRange ) throw(uno::RuntimeException, std::exception)
3779 SolarMutexGuard aGuard;
3780 ScRange aMask( (SCCOL)aRange.StartColumn, (SCROW)aRange.StartRow, aRange.Sheet,
3781 (SCCOL)aRange.EndColumn, (SCROW)aRange.EndRow, aRange.Sheet );
3783 ScRangeList aNew;
3784 for ( size_t i = 0, nCount = aRanges.size(); i < nCount; ++i )
3786 ScRange aTemp( *aRanges[ i ] );
3787 if ( aTemp.Intersects( aMask ) )
3788 aNew.Join( ScRange( std::max( aTemp.aStart.Col(), aMask.aStart.Col() ),
3789 std::max( aTemp.aStart.Row(), aMask.aStart.Row() ),
3790 std::max( aTemp.aStart.Tab(), aMask.aStart.Tab() ),
3791 std::min( aTemp.aEnd.Col(), aMask.aEnd.Col() ),
3792 std::min( aTemp.aEnd.Row(), aMask.aEnd.Row() ),
3793 std::min( aTemp.aEnd.Tab(), aMask.aEnd.Tab() ) ) );
3796 return new ScCellRangesObj( pDocShell, aNew ); // kann leer sein
3799 // XFormulaQuery
3801 uno::Reference<sheet::XSheetCellRanges> SAL_CALL ScCellRangesBase::queryPrecedents(
3802 sal_Bool bRecursive ) throw(uno::RuntimeException, std::exception)
3804 SolarMutexGuard aGuard;
3805 if ( pDocShell )
3807 ScDocument& rDoc = pDocShell->GetDocument();
3809 ScRangeList aNewRanges(aRanges);
3810 bool bFound;
3813 bFound = false;
3815 // aMarkData uses aNewRanges, not aRanges, so GetMarkData can't be used
3816 ScMarkData aMarkData;
3817 aMarkData.MarkFromRangeList( aNewRanges, false );
3818 aMarkData.MarkToMulti(); // needed for IsAllMarked
3820 for (size_t nR = 0, nCount = aNewRanges.size(); nR<nCount; ++nR)
3822 ScRange aRange( *aNewRanges[ nR] );
3823 ScCellIterator aIter( &rDoc, aRange );
3824 for (bool bHasCell = aIter.first(); bHasCell; bHasCell = aIter.next())
3826 if (aIter.getType() != CELLTYPE_FORMULA)
3827 continue;
3829 ScDetectiveRefIter aRefIter(aIter.getFormulaCell());
3830 ScRange aRefRange;
3831 while ( aRefIter.GetNextRef( aRefRange) )
3833 if ( bRecursive && !bFound && !aMarkData.IsAllMarked( aRefRange ) )
3834 bFound = true;
3835 aMarkData.SetMultiMarkArea(aRefRange, true);
3840 aMarkData.FillRangeListWithMarks( &aNewRanges, true );
3842 while ( bRecursive && bFound );
3844 return new ScCellRangesObj( pDocShell, aNewRanges );
3847 return NULL;
3850 uno::Reference<sheet::XSheetCellRanges> SAL_CALL ScCellRangesBase::queryDependents(
3851 sal_Bool bRecursive ) throw(uno::RuntimeException, std::exception)
3853 SolarMutexGuard aGuard;
3854 if ( pDocShell )
3856 ScDocument& rDoc = pDocShell->GetDocument();
3858 ScRangeList aNewRanges(aRanges);
3859 bool bFound;
3862 bFound = false;
3864 // aMarkData uses aNewRanges, not aRanges, so GetMarkData can't be used
3865 ScMarkData aMarkData;
3866 aMarkData.MarkFromRangeList( aNewRanges, false );
3867 aMarkData.MarkToMulti(); // needed for IsAllMarked
3869 SCTAB nTab = lcl_FirstTab(aNewRanges); //! alle Tabellen
3871 ScCellIterator aCellIter( &rDoc, ScRange(0, 0, nTab, MAXCOL, MAXROW, nTab) );
3872 for (bool bHasCell = aCellIter.first(); bHasCell; bHasCell = aCellIter.next())
3874 if (aCellIter.getType() != CELLTYPE_FORMULA)
3875 continue;
3877 bool bMark = false;
3878 ScDetectiveRefIter aIter(aCellIter.getFormulaCell());
3879 ScRange aRefRange;
3880 while ( aIter.GetNextRef( aRefRange) )
3882 size_t nRangesCount = aNewRanges.size();
3883 for (size_t nR = 0; nR < nRangesCount; ++nR)
3885 ScRange aRange( *aNewRanges[ nR ] );
3886 if (aRange.Intersects(aRefRange))
3887 bMark = true; // von Teil des Ranges abhaengig
3890 if (bMark)
3892 ScRange aCellRange(aCellIter.GetPos());
3893 if ( bRecursive && !bFound && !aMarkData.IsAllMarked( aCellRange ) )
3894 bFound = true;
3895 aMarkData.SetMultiMarkArea(aCellRange, true);
3899 aMarkData.FillRangeListWithMarks( &aNewRanges, true );
3901 while ( bRecursive && bFound );
3903 return new ScCellRangesObj( pDocShell, aNewRanges );
3906 return NULL;
3909 // XSearchable
3911 uno::Reference<util::XSearchDescriptor> SAL_CALL ScCellRangesBase::createSearchDescriptor()
3912 throw(uno::RuntimeException, std::exception)
3914 SolarMutexGuard aGuard;
3915 return new ScCellSearchObj;
3918 uno::Reference<container::XIndexAccess> SAL_CALL ScCellRangesBase::findAll(
3919 const uno::Reference<util::XSearchDescriptor>& xDesc )
3920 throw(uno::RuntimeException,
3921 std::exception)
3923 SolarMutexGuard aGuard;
3924 // Wenn nichts gefunden wird, soll Null zurueckgegeben werden (?)
3925 uno::Reference<container::XIndexAccess> xRet;
3926 if ( pDocShell && xDesc.is() )
3928 ScCellSearchObj* pSearch = ScCellSearchObj::getImplementation( xDesc );
3929 if (pSearch)
3931 SvxSearchItem* pSearchItem = pSearch->GetSearchItem();
3932 if (pSearchItem)
3934 ScDocument& rDoc = pDocShell->GetDocument();
3935 pSearchItem->SetCommand( SvxSearchCmd::FIND_ALL );
3936 // immer nur innerhalb dieses Objekts
3937 pSearchItem->SetSelection( !lcl_WholeSheet(aRanges) );
3939 ScMarkData aMark(*GetMarkData());
3941 OUString aDummyUndo;
3942 ScRangeList aMatchedRanges;
3943 SCCOL nCol = 0;
3944 SCROW nRow = 0;
3945 SCTAB nTab = 0;
3946 bool bFound = rDoc.SearchAndReplace(
3947 *pSearchItem, nCol, nRow, nTab, aMark, aMatchedRanges, aDummyUndo, NULL);
3948 if (bFound)
3950 // bei findAll immer CellRanges, egal wieviel gefunden wurde
3951 xRet.set(new ScCellRangesObj( pDocShell, aMatchedRanges ));
3956 return xRet;
3959 uno::Reference<uno::XInterface> ScCellRangesBase::Find_Impl(
3960 const uno::Reference<util::XSearchDescriptor>& xDesc,
3961 const ScAddress* pLastPos )
3963 uno::Reference<uno::XInterface> xRet;
3964 if ( pDocShell && xDesc.is() )
3966 ScCellSearchObj* pSearch = ScCellSearchObj::getImplementation( xDesc );
3967 if (pSearch)
3969 SvxSearchItem* pSearchItem = pSearch->GetSearchItem();
3970 if (pSearchItem)
3972 ScDocument& rDoc = pDocShell->GetDocument();
3973 pSearchItem->SetCommand( SvxSearchCmd::FIND );
3974 // immer nur innerhalb dieses Objekts
3975 pSearchItem->SetSelection( !lcl_WholeSheet(aRanges) );
3977 ScMarkData aMark(*GetMarkData());
3979 SCCOL nCol;
3980 SCROW nRow;
3981 SCTAB nTab;
3982 if (pLastPos)
3983 pLastPos->GetVars( nCol, nRow, nTab );
3984 else
3986 nTab = lcl_FirstTab(aRanges); //! mehrere Tabellen?
3987 ScDocument::GetSearchAndReplaceStart( *pSearchItem, nCol, nRow );
3990 OUString aDummyUndo;
3991 ScRangeList aMatchedRanges;
3992 bool bFound = rDoc.SearchAndReplace(
3993 *pSearchItem, nCol, nRow, nTab, aMark, aMatchedRanges, aDummyUndo, NULL);
3994 if (bFound)
3996 ScAddress aFoundPos( nCol, nRow, nTab );
3997 xRet.set((cppu::OWeakObject*) new ScCellObj( pDocShell, aFoundPos ));
4002 return xRet;
4005 uno::Reference<uno::XInterface> SAL_CALL ScCellRangesBase::findFirst(
4006 const uno::Reference<util::XSearchDescriptor>& xDesc )
4007 throw(uno::RuntimeException, std::exception)
4009 SolarMutexGuard aGuard;
4010 return Find_Impl( xDesc, NULL );
4013 uno::Reference<uno::XInterface> SAL_CALL ScCellRangesBase::findNext(
4014 const uno::Reference<uno::XInterface>& xStartAt,
4015 const uno::Reference<util::XSearchDescriptor >& xDesc )
4016 throw(uno::RuntimeException, std::exception)
4018 SolarMutexGuard aGuard;
4019 if ( xStartAt.is() )
4021 ScCellRangesBase* pRangesImp = ScCellRangesBase::getImplementation( xStartAt );
4022 if ( pRangesImp && pRangesImp->GetDocShell() == pDocShell )
4024 const ScRangeList& rStartRanges = pRangesImp->GetRangeList();
4025 if ( rStartRanges.size() == 1 )
4027 ScAddress aStartPos = rStartRanges[ 0 ]->aStart;
4028 return Find_Impl( xDesc, &aStartPos );
4032 return NULL;
4035 // XReplaceable
4037 uno::Reference<util::XReplaceDescriptor> SAL_CALL ScCellRangesBase::createReplaceDescriptor()
4038 throw(uno::RuntimeException, std::exception)
4040 SolarMutexGuard aGuard;
4041 return new ScCellSearchObj;
4044 sal_Int32 SAL_CALL ScCellRangesBase::replaceAll( const uno::Reference<util::XSearchDescriptor>& xDesc )
4045 throw(uno::RuntimeException,
4046 std::exception)
4048 SolarMutexGuard aGuard;
4049 sal_Int32 nReplaced = 0;
4050 if ( pDocShell && xDesc.is() )
4052 ScCellSearchObj* pSearch = ScCellSearchObj::getImplementation( xDesc );
4053 if (pSearch)
4055 SvxSearchItem* pSearchItem = pSearch->GetSearchItem();
4056 if (pSearchItem)
4058 ScDocument& rDoc = pDocShell->GetDocument();
4059 bool bUndo(rDoc.IsUndoEnabled());
4060 pSearchItem->SetCommand( SvxSearchCmd::REPLACE_ALL );
4061 // immer nur innerhalb dieses Objekts
4062 pSearchItem->SetSelection( !lcl_WholeSheet(aRanges) );
4064 ScMarkData aMark(*GetMarkData());
4066 SCTAB nTabCount = rDoc.GetTableCount();
4067 bool bProtected = !pDocShell->IsEditable();
4068 ScMarkData::iterator itr = aMark.begin(), itrEnd = aMark.end();
4069 for (; itr != itrEnd && *itr < nTabCount; ++itr)
4070 if ( rDoc.IsTabProtected(*itr) )
4071 bProtected = true;
4072 if (bProtected)
4074 //! Exception, oder was?
4076 else
4078 SCTAB nTab = aMark.GetFirstSelected(); // bei SearchAndReplace nicht benutzt
4079 SCCOL nCol = 0;
4080 SCROW nRow = 0;
4082 OUString aUndoStr;
4083 ScDocument* pUndoDoc = NULL;
4084 if (bUndo)
4086 pUndoDoc = new ScDocument( SCDOCMODE_UNDO );
4087 pUndoDoc->InitUndo( &rDoc, nTab, nTab );
4089 itr = aMark.begin();
4090 for (; itr != itrEnd && *itr < nTabCount; ++itr)
4091 if ( *itr != nTab && bUndo)
4092 pUndoDoc->AddUndoTab( *itr, *itr );
4093 boost::scoped_ptr<ScMarkData> pUndoMark;
4094 if (bUndo)
4095 pUndoMark.reset(new ScMarkData(aMark));
4097 bool bFound = false;
4098 if (bUndo)
4100 ScRangeList aMatchedRanges;
4101 bFound = rDoc.SearchAndReplace(
4102 *pSearchItem, nCol, nRow, nTab, aMark, aMatchedRanges, aUndoStr, pUndoDoc );
4104 if (bFound)
4106 nReplaced = pUndoDoc->GetCellCount();
4108 pDocShell->GetUndoManager()->AddUndoAction(
4109 new ScUndoReplace( pDocShell, *pUndoMark, nCol, nRow, nTab,
4110 aUndoStr, pUndoDoc, pSearchItem ) );
4112 pDocShell->PostPaintGridAll();
4113 pDocShell->SetDocumentModified();
4115 else
4117 delete pUndoDoc;
4118 // nReplaced bleibt 0
4124 return nReplaced;
4127 // XUnoTunnel
4129 sal_Int64 SAL_CALL ScCellRangesBase::getSomething(
4130 const uno::Sequence<sal_Int8 >& rId ) throw(uno::RuntimeException, std::exception)
4132 if ( rId.getLength() == 16 &&
4133 0 == memcmp( getUnoTunnelId().getConstArray(),
4134 rId.getConstArray(), 16 ) )
4136 return sal::static_int_cast<sal_Int64>(reinterpret_cast<sal_IntPtr>(this));
4138 return 0;
4141 namespace
4143 class theScCellRangesBaseUnoTunnelId : public rtl::Static< UnoTunnelIdInit, theScCellRangesBaseUnoTunnelId> {};
4146 const uno::Sequence<sal_Int8>& ScCellRangesBase::getUnoTunnelId()
4148 return theScCellRangesBaseUnoTunnelId::get().getSeq();
4151 ScCellRangesBase* ScCellRangesBase::getImplementation(const uno::Reference<uno::XInterface>& rObj)
4153 ScCellRangesBase* pRet = NULL;
4154 uno::Reference<lang::XUnoTunnel> xUT(rObj, uno::UNO_QUERY);
4155 if (xUT.is())
4156 pRet = reinterpret_cast<ScCellRangesBase*>(sal::static_int_cast<sal_IntPtr>(xUT->getSomething(getUnoTunnelId())));
4157 return pRet;
4160 typedef boost::ptr_vector<ScNamedEntry> ScNamedEntryArr_Impl;
4162 struct ScCellRangesObj::Impl
4164 ScNamedEntryArr_Impl m_aNamedEntries;
4167 ScCellRangesObj::ScCellRangesObj(ScDocShell* pDocSh, const ScRangeList& rR)
4168 : ScCellRangesBase(pDocSh, rR)
4169 , m_pImpl(new Impl)
4173 ScCellRangesObj::~ScCellRangesObj()
4177 void ScCellRangesObj::RefChanged()
4179 ScCellRangesBase::RefChanged();
4181 // nix weiter...
4184 uno::Any SAL_CALL ScCellRangesObj::queryInterface( const uno::Type& rType )
4185 throw(uno::RuntimeException, std::exception)
4187 SC_QUERYINTERFACE( sheet::XSheetCellRangeContainer )
4188 SC_QUERYINTERFACE( sheet::XSheetCellRanges )
4189 SC_QUERYINTERFACE( container::XIndexAccess )
4190 SC_QUERY_MULTIPLE( container::XElementAccess, container::XIndexAccess )
4191 SC_QUERYINTERFACE( container::XEnumerationAccess )
4192 SC_QUERYINTERFACE( container::XNameContainer )
4193 SC_QUERYINTERFACE( container::XNameReplace )
4194 SC_QUERYINTERFACE( container::XNameAccess )
4196 return ScCellRangesBase::queryInterface( rType );
4199 void SAL_CALL ScCellRangesObj::acquire() throw()
4201 ScCellRangesBase::acquire();
4204 void SAL_CALL ScCellRangesObj::release() throw()
4206 ScCellRangesBase::release();
4209 uno::Sequence<uno::Type> SAL_CALL ScCellRangesObj::getTypes() throw(uno::RuntimeException, std::exception)
4211 static uno::Sequence<uno::Type> aTypes;
4212 if ( aTypes.getLength() == 0 )
4214 uno::Sequence<uno::Type> aParentTypes(ScCellRangesBase::getTypes());
4215 long nParentLen = aParentTypes.getLength();
4216 const uno::Type* pParentPtr = aParentTypes.getConstArray();
4218 aTypes.realloc( nParentLen + 3 );
4219 uno::Type* pPtr = aTypes.getArray();
4220 pPtr[nParentLen + 0] = cppu::UnoType<sheet::XSheetCellRangeContainer>::get();
4221 pPtr[nParentLen + 1] = cppu::UnoType<container::XNameContainer>::get();
4222 pPtr[nParentLen + 2] = cppu::UnoType<container::XEnumerationAccess>::get();
4224 for (long i=0; i<nParentLen; i++)
4225 pPtr[i] = pParentPtr[i]; // parent types first
4227 return aTypes;
4230 uno::Sequence<sal_Int8> SAL_CALL ScCellRangesObj::getImplementationId()
4231 throw(uno::RuntimeException, std::exception)
4233 return css::uno::Sequence<sal_Int8>();
4236 // XCellRanges
4238 ScCellRangeObj* ScCellRangesObj::GetObjectByIndex_Impl(sal_Int32 nIndex) const
4240 ScDocShell* pDocSh = GetDocShell();
4241 const ScRangeList& rRanges = GetRangeList();
4242 if ( pDocSh && nIndex >= 0 && nIndex < sal::static_int_cast<sal_Int32>(rRanges.size()) )
4244 ScRange aRange( *rRanges[ nIndex ] );
4245 if ( aRange.aStart == aRange.aEnd )
4246 return new ScCellObj( pDocSh, aRange.aStart );
4247 else
4248 return new ScCellRangeObj( pDocSh, aRange );
4251 return NULL; // keine DocShell oder falscher Index
4254 uno::Sequence<table::CellRangeAddress> SAL_CALL ScCellRangesObj::getRangeAddresses()
4255 throw(uno::RuntimeException, std::exception)
4257 SolarMutexGuard aGuard;
4258 ScDocShell* pDocSh = GetDocShell();
4259 const ScRangeList& rRanges = GetRangeList();
4260 size_t nCount = rRanges.size();
4261 if ( pDocSh && nCount )
4263 table::CellRangeAddress aRangeAddress;
4264 uno::Sequence<table::CellRangeAddress> aSeq(nCount);
4265 table::CellRangeAddress* pAry = aSeq.getArray();
4266 for ( size_t i=0; i < nCount; i++)
4268 ScUnoConversion::FillApiRange( aRangeAddress, *rRanges[ i ] );
4269 pAry[i] = aRangeAddress;
4271 return aSeq;
4274 return uno::Sequence<table::CellRangeAddress>(0); // leer ist moeglich
4277 uno::Reference<container::XEnumerationAccess> SAL_CALL ScCellRangesObj::getCells()
4278 throw(uno::RuntimeException, std::exception)
4280 SolarMutexGuard aGuard;
4282 // getCells with empty range list is possible (no exception),
4283 // the resulting enumeration just has no elements
4284 // (same behaviour as a valid range with no cells)
4285 // This is handled in ScCellsEnumeration ctor.
4287 const ScRangeList& rRanges = GetRangeList();
4288 ScDocShell* pDocSh = GetDocShell();
4289 if (pDocSh)
4290 return new ScCellsObj( pDocSh, rRanges );
4291 return NULL;
4294 OUString SAL_CALL ScCellRangesObj::getRangeAddressesAsString()
4295 throw(uno::RuntimeException, std::exception)
4297 SolarMutexGuard aGuard;
4298 OUString aString;
4299 ScDocShell* pDocSh = GetDocShell();
4300 const ScRangeList& rRanges = GetRangeList();
4301 if (pDocSh)
4302 rRanges.Format( aString, SCA_VALID | SCA_TAB_3D, &pDocSh->GetDocument() );
4303 return aString;
4306 // XSheetCellRangeContainer
4308 void SAL_CALL ScCellRangesObj::addRangeAddress( const table::CellRangeAddress& rRange,
4309 sal_Bool bMergeRanges )
4310 throw(::com::sun::star::uno::RuntimeException, std::exception)
4312 SolarMutexGuard aGuard;
4313 ScRange aRange(static_cast<SCCOL>(rRange.StartColumn),
4314 static_cast<SCROW>(rRange.StartRow),
4315 static_cast<SCTAB>(rRange.Sheet),
4316 static_cast<SCCOL>(rRange.EndColumn),
4317 static_cast<SCROW>(rRange.EndRow),
4318 static_cast<SCTAB>(rRange.Sheet));
4319 AddRange(aRange, bMergeRanges);
4322 static void lcl_RemoveNamedEntry( ScNamedEntryArr_Impl& rNamedEntries, const ScRange& rRange )
4324 sal_uInt16 nCount = rNamedEntries.size();
4325 for ( sal_uInt16 n=nCount; n--; )
4326 if ( rNamedEntries[n].GetRange() == rRange )
4327 rNamedEntries.erase( rNamedEntries.begin() + n );
4330 void SAL_CALL ScCellRangesObj::removeRangeAddress( const table::CellRangeAddress& rRange )
4331 throw(::com::sun::star::container::NoSuchElementException,
4332 ::com::sun::star::uno::RuntimeException, std::exception)
4334 SolarMutexGuard aGuard;
4335 const ScRangeList& rRanges = GetRangeList();
4337 ScRangeList aSheetRanges;
4338 ScRangeList aNotSheetRanges;
4339 for (size_t i = 0; i < rRanges.size(); ++i)
4341 if (rRanges[ i]->aStart.Tab() == rRange.Sheet)
4343 aSheetRanges.Append( *rRanges[ i ] );
4345 else
4347 aNotSheetRanges.Append( *rRanges[ i ] );
4350 ScMarkData aMarkData;
4351 aMarkData.MarkFromRangeList( aSheetRanges, false );
4352 ScRange aRange(static_cast<SCCOL>(rRange.StartColumn),
4353 static_cast<SCROW>(rRange.StartRow),
4354 static_cast<SCTAB>(rRange.Sheet),
4355 static_cast<SCCOL>(rRange.EndColumn),
4356 static_cast<SCROW>(rRange.EndRow),
4357 static_cast<SCTAB>(rRange.Sheet));
4358 if (aMarkData.GetTableSelect( aRange.aStart.Tab() ))
4360 aMarkData.MarkToMulti();
4361 if (aMarkData.IsAllMarked( aRange ) )
4363 aMarkData.SetMultiMarkArea( aRange, false );
4364 lcl_RemoveNamedEntry(m_pImpl->m_aNamedEntries, aRange);
4366 else
4367 throw container::NoSuchElementException();
4369 SetNewRanges(aNotSheetRanges);
4370 ScRangeList aNew;
4371 aMarkData.FillRangeListWithMarks( &aNew, false );
4372 for ( size_t j = 0; j < aNew.size(); ++j)
4374 AddRange(*aNew[ j ], false);
4378 void SAL_CALL ScCellRangesObj::addRangeAddresses( const uno::Sequence<table::CellRangeAddress >& rRanges,
4379 sal_Bool bMergeRanges )
4380 throw(::com::sun::star::uno::RuntimeException, std::exception)
4382 SolarMutexGuard aGuard;
4383 sal_Int32 nCount(rRanges.getLength());
4384 if (nCount)
4386 const table::CellRangeAddress* pRanges = rRanges.getConstArray();
4387 for (sal_Int32 i = 0; i < rRanges.getLength(); i++, pRanges++)
4389 ScRange aRange(static_cast<SCCOL>(pRanges->StartColumn),
4390 static_cast<SCROW>(pRanges->StartRow),
4391 static_cast<SCTAB>(pRanges->Sheet),
4392 static_cast<SCCOL>(pRanges->EndColumn),
4393 static_cast<SCROW>(pRanges->EndRow),
4394 static_cast<SCTAB>(pRanges->Sheet));
4395 AddRange(aRange, bMergeRanges);
4400 void SAL_CALL ScCellRangesObj::removeRangeAddresses( const uno::Sequence<table::CellRangeAddress >& rRangeSeq )
4401 throw(::com::sun::star::container::NoSuchElementException,
4402 ::com::sun::star::uno::RuntimeException, std::exception)
4404 // use sometimes a better/faster implementation
4405 sal_uInt32 nCount(rRangeSeq.getLength());
4406 if (nCount)
4408 const table::CellRangeAddress* pRanges = rRangeSeq.getConstArray();
4409 for (sal_uInt32 i=0; i < nCount; ++i, ++pRanges)
4411 removeRangeAddress(*pRanges);
4416 // XNameContainer
4418 static void lcl_RemoveNamedEntry( ScNamedEntryArr_Impl& rNamedEntries, const OUString& rName )
4420 sal_uInt16 nCount = rNamedEntries.size();
4421 for ( sal_uInt16 n=nCount; n--; )
4422 if ( rNamedEntries[n].GetName() == rName )
4423 rNamedEntries.erase( rNamedEntries.begin() + n );
4426 void SAL_CALL ScCellRangesObj::insertByName( const OUString& aName, const uno::Any& aElement )
4427 throw (lang::IllegalArgumentException, container::ElementExistException,
4428 lang::WrappedTargetException, uno::RuntimeException,
4429 std::exception)
4431 SolarMutexGuard aGuard;
4432 ScDocShell* pDocSh = GetDocShell();
4433 bool bDone = false;
4435 //! Type of aElement can be some specific interface instead of XInterface
4437 uno::Reference<uno::XInterface> xInterface(aElement, uno::UNO_QUERY);
4438 if ( pDocSh && xInterface.is() )
4440 ScCellRangesBase* pRangesImp = ScCellRangesBase::getImplementation( xInterface );
4441 if ( pRangesImp && pRangesImp->GetDocShell() == pDocSh )
4443 // if explicit name is given and already existing, throw exception
4445 OUString aNamStr(aName);
4446 if ( !aNamStr.isEmpty() )
4448 size_t nNamedCount = m_pImpl->m_aNamedEntries.size();
4449 for (size_t n = 0; n < nNamedCount; n++)
4451 if (m_pImpl->m_aNamedEntries[n].GetName() == aNamStr)
4452 throw container::ElementExistException();
4456 ScRangeList aNew(GetRangeList());
4457 const ScRangeList& rAddRanges = pRangesImp->GetRangeList();
4458 size_t nAddCount = rAddRanges.size();
4459 for ( size_t i = 0; i < nAddCount; i++ )
4460 aNew.Join( *rAddRanges[ i ] );
4461 SetNewRanges(aNew);
4462 bDone = true;
4464 if ( !aName.isEmpty() && nAddCount == 1 )
4466 // if a name is given, also insert into list of named entries
4467 // (only possible for a single range)
4468 // name is not in m_pImpl->m_aNamedEntries (tested above)
4470 ScNamedEntry* pEntry = new ScNamedEntry( aNamStr, *rAddRanges[ 0 ] );
4471 m_pImpl->m_aNamedEntries.push_back(pEntry);
4476 if (!bDone)
4478 // invalid element - double names are handled above
4479 throw lang::IllegalArgumentException();
4483 static bool lcl_FindRangeByName( const ScRangeList& rRanges, ScDocShell* pDocSh,
4484 const OUString& rName, size_t& rIndex )
4486 if (pDocSh)
4488 OUString aRangeStr;
4489 ScDocument& rDoc = pDocSh->GetDocument();
4490 for ( size_t i = 0, nCount = rRanges.size(); i < nCount; i++ )
4492 aRangeStr = rRanges[ i ]->Format(SCA_VALID | SCA_TAB_3D, &rDoc);
4493 if ( aRangeStr == rName )
4495 rIndex = i;
4496 return true;
4500 return false; // nicht gefunden
4503 static bool lcl_FindRangeOrEntry( const ScNamedEntryArr_Impl& rNamedEntries,
4504 const ScRangeList& rRanges, ScDocShell* pDocSh,
4505 const OUString& rName, ScRange& rFound )
4507 // exact range in list?
4509 size_t nIndex = 0;
4510 if ( lcl_FindRangeByName( rRanges, pDocSh, rName, nIndex ) )
4512 rFound = *rRanges[ nIndex ];
4513 return true;
4516 // range contained in selection? (sheet must be specified)
4518 ScRange aCellRange;
4519 sal_uInt16 nParse = aCellRange.ParseAny( rName, &pDocSh->GetDocument() );
4520 if ( ( nParse & ( SCA_VALID | SCA_TAB_3D ) ) == ( SCA_VALID | SCA_TAB_3D ) )
4522 ScMarkData aMarkData;
4523 aMarkData.MarkFromRangeList( rRanges, false );
4524 aMarkData.MarkToMulti(); // needed for IsAllMarked
4525 if ( aMarkData.IsAllMarked( aCellRange ) )
4527 rFound = aCellRange;
4528 return true;
4532 // named entry in this object?
4534 if ( !rNamedEntries.empty() )
4536 for ( sal_uInt16 n=0; n<rNamedEntries.size(); n++ )
4537 if ( rNamedEntries[n].GetName() == rName )
4539 // test if named entry is contained in rRanges
4541 const ScRange& rComp = rNamedEntries[n].GetRange();
4542 ScMarkData aMarkData;
4543 aMarkData.MarkFromRangeList( rRanges, false );
4544 aMarkData.MarkToMulti(); // needed for IsAllMarked
4545 if ( aMarkData.IsAllMarked( rComp ) )
4547 rFound = rComp;
4548 return true;
4553 return false; // not found
4556 void SAL_CALL ScCellRangesObj::removeByName( const OUString& aName )
4557 throw(container::NoSuchElementException,
4558 lang::WrappedTargetException, uno::RuntimeException, std::exception)
4560 SolarMutexGuard aGuard;
4561 bool bDone = false;
4562 OUString aNameStr(aName);
4563 ScDocShell* pDocSh = GetDocShell();
4564 const ScRangeList& rRanges = GetRangeList();
4565 size_t nIndex = 0;
4566 if ( lcl_FindRangeByName( rRanges, pDocSh, aNameStr, nIndex ) )
4568 // einzelnen Range weglassen
4569 ScRangeList aNew;
4570 for ( size_t i = 0, nCount = rRanges.size(); i < nCount; i++ )
4571 if (i != nIndex)
4572 aNew.Append( *rRanges[ i ] );
4573 SetNewRanges(aNew);
4574 bDone = true;
4576 else if (pDocSh)
4578 // deselect any ranges (parsed or named entry)
4579 ScRangeList aDiff;
4580 bool bValid = ( aDiff.Parse( aNameStr, &pDocSh->GetDocument() ) & SCA_VALID ) != 0;
4581 if (!bValid && !m_pImpl->m_aNamedEntries.empty())
4583 sal_uInt16 nCount = m_pImpl->m_aNamedEntries.size();
4584 for (sal_uInt16 n=0; n<nCount && !bValid; n++)
4585 if (m_pImpl->m_aNamedEntries[n].GetName() == aNameStr)
4587 aDiff.RemoveAll();
4588 aDiff.Append(m_pImpl->m_aNamedEntries[n].GetRange());
4589 bValid = true;
4592 if ( bValid )
4594 ScMarkData aMarkData;
4595 aMarkData.MarkFromRangeList( rRanges, false );
4597 for ( size_t i = 0, nDiffCount = aDiff.size(); i < nDiffCount; i++ )
4599 ScRange* pDiffRange = aDiff[ i ];
4600 if (aMarkData.GetTableSelect( pDiffRange->aStart.Tab() ))
4601 aMarkData.SetMultiMarkArea( *pDiffRange, false );
4604 ScRangeList aNew;
4605 aMarkData.FillRangeListWithMarks( &aNew, false );
4606 SetNewRanges(aNew);
4608 bDone = true; //! error if range was not selected before?
4612 if (!m_pImpl->m_aNamedEntries.empty())
4613 lcl_RemoveNamedEntry(m_pImpl->m_aNamedEntries, aNameStr);
4615 if (!bDone)
4616 throw container::NoSuchElementException(); // not found
4619 // XNameReplace
4621 void SAL_CALL ScCellRangesObj::replaceByName( const OUString& aName, const uno::Any& aElement )
4622 throw(lang::IllegalArgumentException, container::NoSuchElementException,
4623 lang::WrappedTargetException, uno::RuntimeException, std::exception)
4625 SolarMutexGuard aGuard;
4626 //! zusammenfassen?
4627 removeByName( aName );
4628 insertByName( aName, aElement );
4631 // XNameAccess
4633 uno::Any SAL_CALL ScCellRangesObj::getByName( const OUString& aName )
4634 throw(container::NoSuchElementException,
4635 lang::WrappedTargetException, uno::RuntimeException, std::exception)
4637 SolarMutexGuard aGuard;
4638 uno::Any aRet;
4640 OUString aNameStr(aName);
4641 ScDocShell* pDocSh = GetDocShell();
4642 const ScRangeList& rRanges = GetRangeList();
4643 ScRange aRange;
4644 if (lcl_FindRangeOrEntry(m_pImpl->m_aNamedEntries, rRanges,
4645 pDocSh, aNameStr, aRange))
4647 uno::Reference<table::XCellRange> xRange;
4648 if ( aRange.aStart == aRange.aEnd )
4649 xRange.set(new ScCellObj( pDocSh, aRange.aStart ));
4650 else
4651 xRange.set(new ScCellRangeObj( pDocSh, aRange ));
4652 aRet <<= xRange;
4654 else
4655 throw container::NoSuchElementException();
4656 return aRet;
4659 static bool lcl_FindEntryName( const ScNamedEntryArr_Impl& rNamedEntries,
4660 const ScRange& rRange, OUString& rName )
4662 sal_uInt16 nCount = rNamedEntries.size();
4663 for (sal_uInt16 i=0; i<nCount; i++)
4664 if (rNamedEntries[i].GetRange() == rRange)
4666 rName = rNamedEntries[i].GetName();
4667 return true;
4669 return false;
4672 uno::Sequence<OUString> SAL_CALL ScCellRangesObj::getElementNames()
4673 throw(uno::RuntimeException, std::exception)
4675 SolarMutexGuard aGuard;
4677 ScDocShell* pDocSh = GetDocShell();
4678 const ScRangeList& rRanges = GetRangeList();
4679 if (pDocSh)
4681 OUString aRangeStr;
4682 ScDocument& rDoc = pDocSh->GetDocument();
4683 size_t nCount = rRanges.size();
4685 uno::Sequence<OUString> aSeq(nCount);
4686 OUString* pAry = aSeq.getArray();
4687 for (size_t i=0; i < nCount; i++)
4689 // use given name if for exactly this range, otherwise just format
4690 ScRange aRange = *rRanges[ i ];
4691 if (m_pImpl->m_aNamedEntries.empty() ||
4692 !lcl_FindEntryName(m_pImpl->m_aNamedEntries, aRange, aRangeStr))
4694 aRangeStr = aRange.Format(SCA_VALID | SCA_TAB_3D, &rDoc);
4696 pAry[i] = aRangeStr;
4698 return aSeq;
4700 return uno::Sequence<OUString>(0);
4703 sal_Bool SAL_CALL ScCellRangesObj::hasByName( const OUString& aName )
4704 throw(uno::RuntimeException, std::exception)
4706 SolarMutexGuard aGuard;
4707 OUString aNameStr(aName);
4708 ScDocShell* pDocSh = GetDocShell();
4709 const ScRangeList& rRanges = GetRangeList();
4710 ScRange aRange;
4711 return lcl_FindRangeOrEntry(m_pImpl->m_aNamedEntries, rRanges, pDocSh,
4712 aNameStr, aRange);
4715 // XEnumerationAccess
4717 uno::Reference<container::XEnumeration> SAL_CALL ScCellRangesObj::createEnumeration()
4718 throw(uno::RuntimeException, std::exception)
4720 SolarMutexGuard aGuard;
4721 return new ScIndexEnumeration(this, OUString("com.sun.star.sheet.SheetCellRangesEnumeration"));
4724 // XIndexAccess
4726 sal_Int32 SAL_CALL ScCellRangesObj::getCount() throw(uno::RuntimeException, std::exception)
4728 SolarMutexGuard aGuard;
4729 const ScRangeList& rRanges = GetRangeList();
4730 return rRanges.size();
4733 uno::Any SAL_CALL ScCellRangesObj::getByIndex( sal_Int32 nIndex )
4734 throw(lang::IndexOutOfBoundsException,
4735 lang::WrappedTargetException, uno::RuntimeException, std::exception)
4737 SolarMutexGuard aGuard;
4738 uno::Reference<table::XCellRange> xRange(GetObjectByIndex_Impl(nIndex));
4739 if (xRange.is())
4740 return uno::makeAny(xRange);
4741 else
4742 throw lang::IndexOutOfBoundsException();
4745 uno::Type SAL_CALL ScCellRangesObj::getElementType() throw(uno::RuntimeException, std::exception)
4747 SolarMutexGuard aGuard;
4748 return cppu::UnoType<table::XCellRange>::get();
4751 sal_Bool SAL_CALL ScCellRangesObj::hasElements() throw(uno::RuntimeException, std::exception)
4753 SolarMutexGuard aGuard;
4754 const ScRangeList& rRanges = GetRangeList();
4755 return !rRanges.empty();
4758 // XServiceInfo
4759 OUString SAL_CALL ScCellRangesObj::getImplementationName() throw(uno::RuntimeException, std::exception)
4761 return OUString( "ScCellRangesObj" );
4764 sal_Bool SAL_CALL ScCellRangesObj::supportsService( const OUString& rServiceName )
4765 throw(uno::RuntimeException, std::exception)
4767 return cppu::supportsService(this, rServiceName);
4770 uno::Sequence<OUString> SAL_CALL ScCellRangesObj::getSupportedServiceNames()
4771 throw(uno::RuntimeException, std::exception)
4773 uno::Sequence<OUString> aRet(4);
4774 OUString* pArray = aRet.getArray();
4775 pArray[0] = SCSHEETCELLRANGES_SERVICE;
4776 pArray[1] = SCCELLPROPERTIES_SERVICE;
4777 pArray[2] = SCCHARPROPERTIES_SERVICE;
4778 pArray[3] = SCPARAPROPERTIES_SERVICE;
4779 return aRet;
4782 uno::Reference<table::XCellRange> ScCellRangeObj::CreateRangeFromDoc( ScDocument* pDoc, const ScRange& rR )
4784 SfxObjectShell* pObjSh = pDoc->GetDocumentShell();
4785 if ( pObjSh && pObjSh->ISA(ScDocShell) )
4786 return new ScCellRangeObj( static_cast<ScDocShell*>(pObjSh), rR );
4787 return NULL;
4790 ScCellRangeObj::ScCellRangeObj(ScDocShell* pDocSh, const ScRange& rR) :
4791 ScCellRangesBase( pDocSh, rR ),
4792 pRangePropSet( lcl_GetRangePropertySet() ),
4793 aRange( rR )
4795 aRange.Justify(); // Anfang / Ende richtig
4798 ScCellRangeObj::~ScCellRangeObj()
4802 void ScCellRangeObj::RefChanged()
4804 ScCellRangesBase::RefChanged();
4806 const ScRangeList& rRanges = GetRangeList();
4807 OSL_ENSURE(rRanges.size() == 1, "was fuer Ranges ?!?!");
4808 if ( !rRanges.empty() )
4810 const ScRange* pFirst = rRanges[0];
4811 aRange = ScRange(*pFirst);
4812 aRange.Justify();
4816 uno::Any SAL_CALL ScCellRangeObj::queryInterface( const uno::Type& rType )
4817 throw(uno::RuntimeException, std::exception)
4819 SC_QUERYINTERFACE( sheet::XCellRangeAddressable )
4820 SC_QUERYINTERFACE( table::XCellRange )
4821 SC_QUERYINTERFACE( sheet::XSheetCellRange )
4822 SC_QUERYINTERFACE( sheet::XArrayFormulaRange )
4823 SC_QUERYINTERFACE( sheet::XArrayFormulaTokens )
4824 SC_QUERYINTERFACE( sheet::XCellRangeData )
4825 SC_QUERYINTERFACE( sheet::XCellRangeFormula )
4826 SC_QUERYINTERFACE( sheet::XMultipleOperation )
4827 SC_QUERYINTERFACE( util::XMergeable )
4828 SC_QUERYINTERFACE( sheet::XCellSeries )
4829 SC_QUERYINTERFACE( table::XAutoFormattable )
4830 SC_QUERYINTERFACE( util::XSortable )
4831 SC_QUERYINTERFACE( sheet::XSheetFilterableEx )
4832 SC_QUERYINTERFACE( sheet::XSheetFilterable )
4833 SC_QUERYINTERFACE( sheet::XSubTotalCalculatable )
4834 SC_QUERYINTERFACE( table::XColumnRowRange )
4835 SC_QUERYINTERFACE( util::XImportable )
4836 SC_QUERYINTERFACE( sheet::XCellFormatRangesSupplier )
4837 SC_QUERYINTERFACE( sheet::XUniqueCellFormatRangesSupplier )
4839 return ScCellRangesBase::queryInterface( rType );
4842 void SAL_CALL ScCellRangeObj::acquire() throw()
4844 ScCellRangesBase::acquire();
4847 void SAL_CALL ScCellRangeObj::release() throw()
4849 ScCellRangesBase::release();
4852 uno::Sequence<uno::Type> SAL_CALL ScCellRangeObj::getTypes() throw(uno::RuntimeException, std::exception)
4854 static uno::Sequence<uno::Type> aTypes;
4855 if ( aTypes.getLength() == 0 )
4857 uno::Sequence<uno::Type> aParentTypes(ScCellRangesBase::getTypes());
4858 long nParentLen = aParentTypes.getLength();
4859 const uno::Type* pParentPtr = aParentTypes.getConstArray();
4861 aTypes.realloc( nParentLen + 17 );
4862 uno::Type* pPtr = aTypes.getArray();
4863 pPtr[nParentLen + 0] = cppu::UnoType<sheet::XCellRangeAddressable>::get();
4864 pPtr[nParentLen + 1] = cppu::UnoType<sheet::XSheetCellRange>::get();
4865 pPtr[nParentLen + 2] = cppu::UnoType<sheet::XArrayFormulaRange>::get();
4866 pPtr[nParentLen + 3] = cppu::UnoType<sheet::XArrayFormulaTokens>::get();
4867 pPtr[nParentLen + 4] = cppu::UnoType<sheet::XCellRangeData>::get();
4868 pPtr[nParentLen + 5] = cppu::UnoType<sheet::XCellRangeFormula>::get();
4869 pPtr[nParentLen + 6] = cppu::UnoType<sheet::XMultipleOperation>::get();
4870 pPtr[nParentLen + 7] = cppu::UnoType<util::XMergeable>::get();
4871 pPtr[nParentLen + 8] = cppu::UnoType<sheet::XCellSeries>::get();
4872 pPtr[nParentLen + 9] = cppu::UnoType<table::XAutoFormattable>::get();
4873 pPtr[nParentLen +10] = cppu::UnoType<util::XSortable>::get();
4874 pPtr[nParentLen +11] = cppu::UnoType<sheet::XSheetFilterableEx>::get();
4875 pPtr[nParentLen +12] = cppu::UnoType<sheet::XSubTotalCalculatable>::get();
4876 pPtr[nParentLen +13] = cppu::UnoType<table::XColumnRowRange>::get();
4877 pPtr[nParentLen +14] = cppu::UnoType<util::XImportable>::get();
4878 pPtr[nParentLen +15] = cppu::UnoType<sheet::XCellFormatRangesSupplier>::get();
4879 pPtr[nParentLen +16] = cppu::UnoType<sheet::XUniqueCellFormatRangesSupplier>::get();
4881 for (long i=0; i<nParentLen; i++)
4882 pPtr[i] = pParentPtr[i]; // parent types first
4884 return aTypes;
4887 uno::Sequence<sal_Int8> SAL_CALL ScCellRangeObj::getImplementationId()
4888 throw(uno::RuntimeException, std::exception)
4890 return css::uno::Sequence<sal_Int8>();
4893 // XCellRange
4895 // ColumnCount / RowCount sind weggefallen
4896 //! werden im Writer fuer Tabellen noch gebraucht ???
4898 uno::Reference<table::XCell> ScCellRangeObj::GetCellByPosition_Impl(
4899 sal_Int32 nColumn, sal_Int32 nRow )
4900 throw(lang::IndexOutOfBoundsException, uno::RuntimeException)
4902 ScDocShell* pDocSh = GetDocShell();
4903 if (!pDocSh)
4904 throw uno::RuntimeException();
4906 if ( nColumn >= 0 && nRow >= 0 )
4908 sal_Int32 nPosX = aRange.aStart.Col() + nColumn;
4909 sal_Int32 nPosY = aRange.aStart.Row() + nRow;
4911 if ( nPosX <= aRange.aEnd.Col() && nPosY <= aRange.aEnd.Row() )
4913 ScAddress aNew( (SCCOL)nPosX, (SCROW)nPosY, aRange.aStart.Tab() );
4914 return new ScCellObj( pDocSh, aNew );
4918 throw lang::IndexOutOfBoundsException();
4921 uno::Reference<table::XCell> SAL_CALL ScCellRangeObj::getCellByPosition(
4922 sal_Int32 nColumn, sal_Int32 nRow )
4923 throw(lang::IndexOutOfBoundsException, uno::RuntimeException, std::exception)
4925 SolarMutexGuard aGuard;
4927 return GetCellByPosition_Impl(nColumn, nRow);
4930 uno::Reference<table::XCellRange> SAL_CALL ScCellRangeObj::getCellRangeByPosition(
4931 sal_Int32 nLeft, sal_Int32 nTop, sal_Int32 nRight, sal_Int32 nBottom )
4932 throw(lang::IndexOutOfBoundsException, uno::RuntimeException, std::exception)
4934 SolarMutexGuard aGuard;
4936 ScDocShell* pDocSh = GetDocShell();
4937 if (!pDocSh)
4938 throw uno::RuntimeException();
4940 if ( nLeft >= 0 && nTop >= 0 && nRight >= 0 && nBottom >= 0 )
4942 sal_Int32 nStartX = aRange.aStart.Col() + nLeft;
4943 sal_Int32 nStartY = aRange.aStart.Row() + nTop;
4944 sal_Int32 nEndX = aRange.aStart.Col() + nRight;
4945 sal_Int32 nEndY = aRange.aStart.Row() + nBottom;
4947 if ( nStartX <= nEndX && nEndX <= aRange.aEnd.Col() &&
4948 nStartY <= nEndY && nEndY <= aRange.aEnd.Row() )
4950 ScRange aNew( (SCCOL)nStartX, (SCROW)nStartY, aRange.aStart.Tab(),
4951 (SCCOL)nEndX, (SCROW)nEndY, aRange.aEnd.Tab() );
4952 return new ScCellRangeObj( pDocSh, aNew );
4956 throw lang::IndexOutOfBoundsException();
4959 uno::Reference<table::XCellRange> SAL_CALL ScCellRangeObj::getCellRangeByName(
4960 const OUString& aName ) throw(uno::RuntimeException, std::exception)
4962 return getCellRangeByName( aName, ScAddress::detailsOOOa1 );
4965 uno::Reference<table::XCellRange> ScCellRangeObj::getCellRangeByName(
4966 const OUString& aName, const ScAddress::Details& rDetails ) throw(uno::RuntimeException)
4968 // name refers to the whole document (with the range's table as default),
4969 // valid only if the range is within this range
4971 SolarMutexGuard aGuard;
4972 ScDocShell* pDocSh = GetDocShell();
4973 if ( pDocSh )
4975 ScDocument& rDoc = pDocSh->GetDocument();
4976 SCTAB nTab = aRange.aStart.Tab();
4978 ScRange aCellRange;
4979 bool bFound = false;
4980 OUString aString(aName);
4981 sal_uInt16 nParse = aCellRange.ParseAny( aString, &rDoc, rDetails );
4982 if ( nParse & SCA_VALID )
4984 if ( !(nParse & SCA_TAB_3D) ) // keine Tabelle angegeben -> auf dieser Tabelle
4986 aCellRange.aStart.SetTab(nTab);
4987 aCellRange.aEnd.SetTab(nTab);
4989 bFound = true;
4991 else
4993 ScRangeUtil aRangeUtil;
4994 if ( ScRangeUtil::MakeRangeFromName( aString, &rDoc, nTab, aCellRange, RUTL_NAMES ) ||
4995 ScRangeUtil::MakeRangeFromName( aString, &rDoc, nTab, aCellRange, RUTL_DBASE ) )
4996 bFound = true;
4999 if (bFound) // valid only if within this object's range
5001 if (!aRange.In(aCellRange))
5002 bFound = false;
5005 if (bFound)
5007 if ( aCellRange.aStart == aCellRange.aEnd )
5008 return new ScCellObj( pDocSh, aCellRange.aStart );
5009 else
5010 return new ScCellRangeObj( pDocSh, aCellRange );
5014 throw uno::RuntimeException();
5017 // XColumnRowRange
5019 uno::Reference<table::XTableColumns> SAL_CALL ScCellRangeObj::getColumns() throw(uno::RuntimeException, std::exception)
5021 SolarMutexGuard aGuard;
5022 ScDocShell* pDocSh = GetDocShell();
5023 if (pDocSh)
5024 return new ScTableColumnsObj( pDocSh, aRange.aStart.Tab(),
5025 aRange.aStart.Col(), aRange.aEnd.Col() );
5027 OSL_FAIL("Dokument ungueltig");
5028 return NULL;
5031 uno::Reference<table::XTableRows> SAL_CALL ScCellRangeObj::getRows() throw(uno::RuntimeException, std::exception)
5033 SolarMutexGuard aGuard;
5034 ScDocShell* pDocSh = GetDocShell();
5035 if (pDocSh)
5036 return new ScTableRowsObj( pDocSh, aRange.aStart.Tab(),
5037 aRange.aStart.Row(), aRange.aEnd.Row() );
5039 OSL_FAIL("Dokument ungueltig");
5040 return NULL;
5043 // XAddressableCellRange
5045 table::CellRangeAddress SAL_CALL ScCellRangeObj::getRangeAddress() throw(uno::RuntimeException, std::exception)
5047 SolarMutexGuard aGuard;
5048 table::CellRangeAddress aRet;
5049 ScUnoConversion::FillApiRange( aRet, aRange );
5050 return aRet;
5053 // XSheetCellRange
5055 uno::Reference<sheet::XSpreadsheet> SAL_CALL ScCellRangeObj::getSpreadsheet()
5056 throw(uno::RuntimeException, std::exception)
5058 SolarMutexGuard aGuard;
5059 ScDocShell* pDocSh = GetDocShell();
5060 if (pDocSh)
5061 return new ScTableSheetObj( pDocSh, aRange.aStart.Tab() );
5063 OSL_FAIL("Dokument ungueltig");
5064 return NULL;
5067 // XArrayFormulaRange
5069 OUString SAL_CALL ScCellRangeObj::getArrayFormula() throw(uno::RuntimeException, std::exception)
5071 SolarMutexGuard aGuard;
5073 // Matrix-Formel, wenn eindeutig Teil einer Matrix,
5074 // also wenn Anfang und Ende des Blocks zur selben Matrix gehoeren.
5075 // Sonst Leerstring.
5077 ScDocShell* pDocSh = GetDocShell();
5078 if (!pDocSh)
5079 return EMPTY_OUSTRING;
5081 OUString aFormula;
5083 ScDocument& rDoc = pDocSh->GetDocument();
5084 ScRefCellValue aCell1;
5085 ScRefCellValue aCell2;
5086 aCell1.assign(rDoc, aRange.aStart);
5087 aCell2.assign(rDoc, aRange.aEnd);
5088 if (aCell1.meType == CELLTYPE_FORMULA && aCell2.meType == CELLTYPE_FORMULA)
5090 const ScFormulaCell* pFCell1 = aCell1.mpFormula;
5091 const ScFormulaCell* pFCell2 = aCell2.mpFormula;
5092 ScAddress aStart1;
5093 ScAddress aStart2;
5094 if (pFCell1->GetMatrixOrigin(aStart1) && pFCell2->GetMatrixOrigin(aStart2))
5096 if (aStart1 == aStart2) // beides dieselbe Matrix
5097 pFCell1->GetFormula(aFormula); // egal, von welcher Zelle
5100 return aFormula;
5103 void ScCellRangeObj::SetArrayFormula_Impl(const OUString& rFormula,
5104 const OUString& rFormulaNmsp, const formula::FormulaGrammar::Grammar eGrammar)
5105 throw (uno::RuntimeException, std::exception)
5107 ScDocShell* pDocSh = GetDocShell();
5108 if (pDocSh)
5110 if ( !rFormula.isEmpty() )
5112 if ( ScTableSheetObj::getImplementation( (cppu::OWeakObject*)this ) )
5114 // don't set array formula for sheet object
5115 throw uno::RuntimeException();
5118 pDocSh->GetDocFunc().EnterMatrix( aRange, NULL, NULL, rFormula, true, true, rFormulaNmsp, eGrammar );
5120 else
5122 // empty string -> erase array formula
5123 ScMarkData aMark;
5124 aMark.SetMarkArea( aRange );
5125 aMark.SelectTable( aRange.aStart.Tab(), true );
5126 pDocSh->GetDocFunc().DeleteContents( aMark, IDF_CONTENTS, true, true );
5131 void SAL_CALL ScCellRangeObj::setArrayFormula( const OUString& aFormula )
5132 throw(uno::RuntimeException, std::exception)
5134 SolarMutexGuard aGuard;
5135 // GRAM_PODF_A1 for API compatibility.
5136 SetArrayFormula_Impl( aFormula, OUString(), formula::FormulaGrammar::GRAM_PODF_A1);
5139 // XArrayFormulaTokens
5140 uno::Sequence<sheet::FormulaToken> SAL_CALL ScCellRangeObj::getArrayTokens()
5141 throw (uno::RuntimeException, std::exception)
5143 SolarMutexGuard aGuard;
5145 // same cell logic as in getArrayFormula
5147 uno::Sequence<sheet::FormulaToken> aSequence;
5148 ScDocShell* pDocSh = GetDocShell();
5149 if (!pDocSh)
5150 return aSequence;
5152 ScDocument& rDoc = pDocSh->GetDocument();
5153 ScRefCellValue aCell1;
5154 ScRefCellValue aCell2;
5155 aCell1.assign(rDoc, aRange.aStart);
5156 aCell2.assign(rDoc, aRange.aEnd);
5157 if (aCell1.meType == CELLTYPE_FORMULA && aCell2.meType == CELLTYPE_FORMULA)
5159 const ScFormulaCell* pFCell1 = aCell1.mpFormula;
5160 const ScFormulaCell* pFCell2 = aCell2.mpFormula;
5161 ScAddress aStart1;
5162 ScAddress aStart2;
5163 if (pFCell1->GetMatrixOrigin(aStart1) && pFCell2->GetMatrixOrigin(aStart2))
5165 if (aStart1 == aStart2)
5167 const ScTokenArray* pTokenArray = pFCell1->GetCode();
5168 if (pTokenArray)
5169 (void)ScTokenConversion::ConvertToTokenSequence(rDoc, aSequence, *pTokenArray);
5174 return aSequence;
5177 void SAL_CALL ScCellRangeObj::setArrayTokens( const uno::Sequence<sheet::FormulaToken>& rTokens ) throw(uno::RuntimeException, std::exception)
5179 SolarMutexGuard aGuard;
5180 ScDocShell* pDocSh = GetDocShell();
5181 if ( pDocSh )
5183 if ( rTokens.getLength() )
5185 if ( ScTableSheetObj::getImplementation( (cppu::OWeakObject*)this ) )
5187 throw uno::RuntimeException();
5190 ScDocument& rDoc = pDocSh->GetDocument();
5191 ScTokenArray aTokenArray;
5192 (void)ScTokenConversion::ConvertToTokenArray( rDoc, aTokenArray, rTokens );
5194 // Actually GRAM_PODF_A1 is a don't-care here because of the token
5195 // array being set, it fits with other API compatibility grammars
5196 // though.
5197 pDocSh->GetDocFunc().EnterMatrix( aRange, NULL, &aTokenArray, EMPTY_OUSTRING, true, true, EMPTY_OUSTRING, formula::FormulaGrammar::GRAM_PODF_A1 );
5199 else
5201 // empty sequence -> erase array formula
5202 ScMarkData aMark;
5203 aMark.SetMarkArea( aRange );
5204 aMark.SelectTable( aRange.aStart.Tab(), true );
5205 pDocSh->GetDocFunc().DeleteContents( aMark, IDF_CONTENTS, true, true );
5210 // XCellRangeData
5212 uno::Sequence< uno::Sequence<uno::Any> > SAL_CALL ScCellRangeObj::getDataArray()
5213 throw(uno::RuntimeException, std::exception)
5215 SolarMutexGuard aGuard;
5217 if ( ScTableSheetObj::getImplementation( (cppu::OWeakObject*)this ) )
5219 // don't create a data array for the sheet
5220 throw uno::RuntimeException();
5223 ScDocShell* pDocSh = GetDocShell();
5224 if (pDocSh)
5226 uno::Any aAny;
5227 // bAllowNV = TRUE: errors as void
5228 if ( ScRangeToSequence::FillMixedArray( aAny, &pDocSh->GetDocument(), aRange, true ) )
5230 uno::Sequence< uno::Sequence<uno::Any> > aSeq;
5231 if ( aAny >>= aSeq )
5232 return aSeq; // success
5236 throw uno::RuntimeException(); // no other exceptions specified
5239 void SAL_CALL ScCellRangeObj::setDataArray(
5240 const uno::Sequence< uno::Sequence<uno::Any> >& aArray )
5241 throw(uno::RuntimeException, std::exception)
5243 SolarMutexGuard aGuard;
5245 bool bDone = false;
5246 ScDocShell* pDocSh = GetDocShell();
5247 if (pDocSh)
5249 //! move lcl_PutDataArray to docfunc?
5250 bDone = lcl_PutDataArray( *pDocSh, aRange, aArray );
5253 if (!bDone)
5254 throw uno::RuntimeException(); // no other exceptions specified
5257 // XCellRangeFormula
5259 uno::Sequence< uno::Sequence<OUString> > SAL_CALL ScCellRangeObj::getFormulaArray()
5260 throw(uno::RuntimeException, std::exception)
5262 SolarMutexGuard aGuard;
5264 if ( ScTableSheetObj::getImplementation( (cppu::OWeakObject*)this ) )
5266 // don't create a data array for the sheet
5267 throw uno::RuntimeException();
5270 ScDocShell* pDocSh = GetDocShell();
5271 if (pDocSh)
5273 SCCOL nStartCol = aRange.aStart.Col();
5274 SCROW nStartRow = aRange.aStart.Row();
5275 SCCOL nEndCol = aRange.aEnd.Col();
5276 SCROW nEndRow = aRange.aEnd.Row();
5277 SCCOL nColCount = nEndCol + 1 - nStartCol;
5278 SCROW nRowCount = nEndRow + 1 - nStartRow;
5279 SCTAB nTab = aRange.aStart.Tab();
5281 uno::Sequence< uno::Sequence<OUString> > aRowSeq( nRowCount );
5282 uno::Sequence<OUString>* pRowAry = aRowSeq.getArray();
5283 for (SCROW nRowIndex = 0; nRowIndex < nRowCount; nRowIndex++)
5285 uno::Sequence<OUString> aColSeq( nColCount );
5286 OUString* pColAry = aColSeq.getArray();
5287 for (SCCOL nColIndex = 0; nColIndex < nColCount; nColIndex++)
5288 pColAry[nColIndex] = lcl_GetInputString( pDocSh->GetDocument(),
5289 ScAddress( nStartCol+nColIndex, nStartRow+nRowIndex, nTab ), true );
5291 pRowAry[nRowIndex] = aColSeq;
5294 return aRowSeq;
5297 throw uno::RuntimeException(); // no other exceptions specified
5300 void SAL_CALL ScCellRangeObj::setFormulaArray(
5301 const uno::Sequence< uno::Sequence<OUString> >& aArray )
5302 throw(uno::RuntimeException, std::exception)
5304 SolarMutexGuard aGuard;
5306 bool bDone = false;
5307 ScDocShell* pDocSh = GetDocShell();
5308 if (pDocSh)
5310 ScExternalRefManager::ApiGuard aExtRefGuard(&pDocSh->GetDocument());
5312 // GRAM_PODF_A1 for API compatibility.
5313 bDone = lcl_PutFormulaArray( *pDocSh, aRange, aArray, formula::FormulaGrammar::GRAM_PODF_A1 );
5316 if (!bDone)
5317 throw uno::RuntimeException(); // no other exceptions specified
5320 // XMultipleOperation
5322 void SAL_CALL ScCellRangeObj::setTableOperation( const table::CellRangeAddress& aFormulaRange,
5323 sheet::TableOperationMode nMode,
5324 const table::CellAddress& aColumnCell,
5325 const table::CellAddress& aRowCell )
5326 throw(uno::RuntimeException, std::exception)
5328 SolarMutexGuard aGuard;
5329 ScDocShell* pDocSh = GetDocShell();
5330 if (pDocSh)
5332 bool bError = false;
5333 ScTabOpParam aParam;
5334 aParam.aRefFormulaCell = ScRefAddress( (SCCOL)aFormulaRange.StartColumn,
5335 (SCROW)aFormulaRange.StartRow, aFormulaRange.Sheet,
5336 false, false, false );
5337 aParam.aRefFormulaEnd = ScRefAddress( (SCCOL)aFormulaRange.EndColumn,
5338 (SCROW)aFormulaRange.EndRow, aFormulaRange.Sheet,
5339 false, false, false );
5340 aParam.aRefRowCell = ScRefAddress( (SCCOL)aRowCell.Column,
5341 (SCROW)aRowCell.Row, aRowCell.Sheet,
5342 false, false, false );
5343 aParam.aRefColCell = ScRefAddress( (SCCOL)aColumnCell.Column,
5344 (SCROW)aColumnCell.Row, aColumnCell.Sheet,
5345 false, false, false );
5347 switch (nMode)
5349 case sheet::TableOperationMode_COLUMN:
5350 aParam.meMode = ScTabOpParam::Column;
5351 break;
5352 case sheet::TableOperationMode_ROW:
5353 aParam.meMode = ScTabOpParam::Row;
5354 break;
5355 case sheet::TableOperationMode_BOTH:
5356 aParam.meMode = ScTabOpParam::Both;
5357 break;
5358 default:
5359 bError = true;
5362 if (!bError)
5363 pDocSh->GetDocFunc().TabOp( aRange, NULL, aParam, true, true );
5367 // XMergeable
5369 void SAL_CALL ScCellRangeObj::merge( sal_Bool bMerge ) throw(uno::RuntimeException, std::exception)
5371 SolarMutexGuard aGuard;
5372 ScDocShell* pDocSh = GetDocShell();
5373 if ( pDocSh )
5375 ScCellMergeOption aMergeOption(
5376 aRange.aStart.Col(), aRange.aStart.Row(),
5377 aRange.aEnd.Col(), aRange.aEnd.Row(), false);
5378 aMergeOption.maTabs.insert(aRange.aStart.Tab());
5379 if ( bMerge )
5380 pDocSh->GetDocFunc().MergeCells( aMergeOption, false, true, true );
5381 else
5382 pDocSh->GetDocFunc().UnmergeCells( aMergeOption, true );
5384 //! Fehler abfangen?
5388 sal_Bool SAL_CALL ScCellRangeObj::getIsMerged() throw(uno::RuntimeException, std::exception)
5390 SolarMutexGuard aGuard;
5391 ScDocShell* pDocSh = GetDocShell();
5392 return pDocSh && pDocSh->GetDocument().HasAttrib( aRange, HASATTR_MERGED );
5395 // XCellSeries
5397 void SAL_CALL ScCellRangeObj::fillSeries( sheet::FillDirection nFillDirection,
5398 sheet::FillMode nFillMode, sheet::FillDateMode nFillDateMode,
5399 double fStep, double fEndValue ) throw(uno::RuntimeException, std::exception)
5401 SolarMutexGuard aGuard;
5402 ScDocShell* pDocSh = GetDocShell();
5403 if ( pDocSh )
5405 bool bError = false;
5407 FillDir eDir = FILL_TO_BOTTOM;
5408 switch (nFillDirection)
5410 case sheet::FillDirection_TO_BOTTOM:
5411 eDir = FILL_TO_BOTTOM;
5412 break;
5413 case sheet::FillDirection_TO_RIGHT:
5414 eDir = FILL_TO_RIGHT;
5415 break;
5416 case sheet::FillDirection_TO_TOP:
5417 eDir = FILL_TO_TOP;
5418 break;
5419 case sheet::FillDirection_TO_LEFT:
5420 eDir = FILL_TO_LEFT;
5421 break;
5422 default:
5423 bError = true;
5426 FillCmd eCmd = FILL_SIMPLE;
5427 switch ( nFillMode )
5429 case sheet::FillMode_SIMPLE:
5430 eCmd = FILL_SIMPLE;
5431 break;
5432 case sheet::FillMode_LINEAR:
5433 eCmd = FILL_LINEAR;
5434 break;
5435 case sheet::FillMode_GROWTH:
5436 eCmd = FILL_GROWTH;
5437 break;
5438 case sheet::FillMode_DATE:
5439 eCmd = FILL_DATE;
5440 break;
5441 case sheet::FillMode_AUTO:
5442 eCmd = FILL_AUTO;
5443 break;
5444 default:
5445 bError = true;
5448 FillDateCmd eDateCmd = FILL_DAY;
5449 switch ( nFillDateMode )
5451 case sheet::FillDateMode_FILL_DATE_DAY:
5452 eDateCmd = FILL_DAY;
5453 break;
5454 case sheet::FillDateMode_FILL_DATE_WEEKDAY:
5455 eDateCmd = FILL_WEEKDAY;
5456 break;
5457 case sheet::FillDateMode_FILL_DATE_MONTH:
5458 eDateCmd = FILL_MONTH;
5459 break;
5460 case sheet::FillDateMode_FILL_DATE_YEAR:
5461 eDateCmd = FILL_YEAR;
5462 break;
5463 default:
5464 bError = true;
5467 if (!bError)
5468 pDocSh->GetDocFunc().FillSeries( aRange, NULL, eDir, eCmd, eDateCmd,
5469 MAXDOUBLE, fStep, fEndValue, true, true );
5473 void SAL_CALL ScCellRangeObj::fillAuto( sheet::FillDirection nFillDirection,
5474 sal_Int32 nSourceCount ) throw(uno::RuntimeException, std::exception)
5476 SolarMutexGuard aGuard;
5477 ScDocShell* pDocSh = GetDocShell();
5478 if ( pDocSh && nSourceCount )
5480 ScRange aSourceRange(aRange);
5481 SCsCOLROW nCount = 0; // "Dest-Count"
5482 FillDir eDir = FILL_TO_BOTTOM;
5483 bool bError = false;
5484 switch (nFillDirection)
5486 case sheet::FillDirection_TO_BOTTOM:
5487 aSourceRange.aEnd.SetRow( static_cast<SCROW>( aSourceRange.aStart.Row() + nSourceCount - 1 ) );
5488 nCount = aRange.aEnd.Row() - aSourceRange.aEnd.Row();
5489 eDir = FILL_TO_BOTTOM;
5490 break;
5491 case sheet::FillDirection_TO_RIGHT:
5492 aSourceRange.aEnd.SetCol( static_cast<SCCOL>( aSourceRange.aStart.Col() + nSourceCount - 1 ) );
5493 nCount = aRange.aEnd.Col() - aSourceRange.aEnd.Col();
5494 eDir = FILL_TO_RIGHT;
5495 break;
5496 case sheet::FillDirection_TO_TOP:
5497 aSourceRange.aStart.SetRow( static_cast<SCROW>( aSourceRange.aEnd.Row() - nSourceCount + 1 ) );
5498 nCount = aSourceRange.aStart.Row() - aRange.aStart.Row();
5499 eDir = FILL_TO_TOP;
5500 break;
5501 case sheet::FillDirection_TO_LEFT:
5502 aSourceRange.aStart.SetCol( static_cast<SCCOL>( aSourceRange.aEnd.Col() - nSourceCount + 1 ) );
5503 nCount = aSourceRange.aStart.Col() - aRange.aStart.Col();
5504 eDir = FILL_TO_LEFT;
5505 break;
5506 default:
5507 bError = true;
5509 if (nCount < 0 || nCount > MAXROW) // overflow
5510 bError = true;
5512 if (!bError)
5513 pDocSh->GetDocFunc().FillAuto( aSourceRange, NULL, eDir, nCount, true, true );
5517 // XAutoFormattable
5519 void SAL_CALL ScCellRangeObj::autoFormat( const OUString& aName )
5520 throw(lang::IllegalArgumentException, uno::RuntimeException, std::exception)
5522 SolarMutexGuard aGuard;
5523 ScDocShell* pDocSh = GetDocShell();
5524 if ( pDocSh )
5526 ScAutoFormat* pAutoFormat = ScGlobal::GetOrCreateAutoFormat();
5527 ScAutoFormat::const_iterator it = pAutoFormat->find(aName);
5528 if (it != pAutoFormat->end())
5530 ScAutoFormat::const_iterator itBeg = pAutoFormat->begin();
5531 size_t nIndex = std::distance(itBeg, it);
5532 pDocSh->GetDocFunc().AutoFormat(aRange, NULL, nIndex, true, true);
5534 else
5535 throw lang::IllegalArgumentException();
5539 // XSortable
5541 uno::Sequence<beans::PropertyValue> SAL_CALL ScCellRangeObj::createSortDescriptor()
5542 throw(uno::RuntimeException, std::exception)
5544 SolarMutexGuard aGuard;
5545 ScSortParam aParam;
5546 ScDocShell* pDocSh = GetDocShell();
5547 if ( pDocSh )
5549 // DB-Bereich anlegen erst beim Ausfuehren, per API immer genau den Bereich
5550 ScDBData* pData = pDocSh->GetDBData( aRange, SC_DB_OLD, SC_DBSEL_FORCE_MARK );
5551 if (pData)
5553 pData->GetSortParam(aParam);
5555 // im SortDescriptor sind die Fields innerhalb des Bereichs gezaehlt
5556 ScRange aDBRange;
5557 pData->GetArea(aDBRange);
5558 SCCOLROW nFieldStart = aParam.bByRow ?
5559 static_cast<SCCOLROW>(aDBRange.aStart.Col()) :
5560 static_cast<SCCOLROW>(aDBRange.aStart.Row());
5561 for (sal_uInt16 i=0; i<aParam.GetSortKeyCount(); i++)
5562 if ( aParam.maKeyState[i].bDoSort && aParam.maKeyState[i].nField >= nFieldStart )
5563 aParam.maKeyState[i].nField -= nFieldStart;
5567 uno::Sequence<beans::PropertyValue> aSeq( ScSortDescriptor::GetPropertyCount() );
5568 ScSortDescriptor::FillProperties( aSeq, aParam );
5569 return aSeq;
5572 void SAL_CALL ScCellRangeObj::sort( const uno::Sequence<beans::PropertyValue>& aDescriptor )
5573 throw(uno::RuntimeException, std::exception)
5575 SolarMutexGuard aGuard;
5576 ScDocShell* pDocSh = GetDocShell();
5577 if (pDocSh)
5579 sal_uInt16 i;
5580 ScSortParam aParam;
5581 ScDBData* pData = pDocSh->GetDBData( aRange, SC_DB_MAKE, SC_DBSEL_FORCE_MARK ); // ggf. Bereich anlegen
5582 if (pData)
5584 // alten Einstellungen holen, falls nicht alles neu gesetzt wird
5585 pData->GetSortParam(aParam);
5586 SCCOLROW nOldStart = aParam.bByRow ?
5587 static_cast<SCCOLROW>(aRange.aStart.Col()) :
5588 static_cast<SCCOLROW>(aRange.aStart.Row());
5589 for (i=0; i<aParam.GetSortKeyCount(); i++)
5590 if ( aParam.maKeyState[i].bDoSort && aParam.maKeyState[i].nField >= nOldStart )
5591 aParam.maKeyState[i].nField -= nOldStart;
5594 ScSortDescriptor::FillSortParam( aParam, aDescriptor );
5596 // im SortDescriptor sind die Fields innerhalb des Bereichs gezaehlt
5597 // ByRow kann bei FillSortParam umgesetzt worden sein
5598 SCCOLROW nFieldStart = aParam.bByRow ?
5599 static_cast<SCCOLROW>(aRange.aStart.Col()) :
5600 static_cast<SCCOLROW>(aRange.aStart.Row());
5601 for (i=0; i<aParam.GetSortKeyCount(); i++)
5602 aParam.maKeyState[i].nField += nFieldStart;
5604 SCTAB nTab = aRange.aStart.Tab();
5605 aParam.nCol1 = aRange.aStart.Col();
5606 aParam.nRow1 = aRange.aStart.Row();
5607 aParam.nCol2 = aRange.aEnd.Col();
5608 aParam.nRow2 = aRange.aEnd.Row();
5610 pDocSh->GetDBData( aRange, SC_DB_MAKE, SC_DBSEL_FORCE_MARK ); // ggf. Bereich anlegen
5612 ScDBDocFunc aFunc(*pDocSh); // Bereich muss angelegt sein
5613 (void)aFunc.Sort( nTab, aParam, true, true, true );
5617 // XFilterable
5619 uno::Reference<sheet::XSheetFilterDescriptor> SAL_CALL ScCellRangeObj::createFilterDescriptor(
5620 sal_Bool bEmpty ) throw(uno::RuntimeException, std::exception)
5622 SolarMutexGuard aGuard;
5623 ScDocShell* pDocSh = GetDocShell();
5624 ScFilterDescriptor* pNew = new ScFilterDescriptor(pDocSh);
5625 if ( !bEmpty && pDocSh )
5627 // DB-Bereich anlegen erst beim Ausfuehren, per API immer genau den Bereich
5628 ScDBData* pData = pDocSh->GetDBData( aRange, SC_DB_OLD, SC_DBSEL_FORCE_MARK );
5629 if (pData)
5631 ScQueryParam aParam;
5632 pData->GetQueryParam(aParam);
5633 // im FilterDescriptor sind die Fields innerhalb des Bereichs gezaehlt
5634 ScRange aDBRange;
5635 pData->GetArea(aDBRange);
5636 SCCOLROW nFieldStart = aParam.bByRow ?
5637 static_cast<SCCOLROW>(aDBRange.aStart.Col()) :
5638 static_cast<SCCOLROW>(aDBRange.aStart.Row());
5639 SCSIZE nCount = aParam.GetEntryCount();
5640 for (SCSIZE i=0; i<nCount; i++)
5642 ScQueryEntry& rEntry = aParam.GetEntry(i);
5643 if (rEntry.bDoQuery && rEntry.nField >= nFieldStart)
5644 rEntry.nField -= nFieldStart;
5646 pNew->SetParam(aParam);
5649 return pNew;
5652 void SAL_CALL ScCellRangeObj::filter( const uno::Reference<sheet::XSheetFilterDescriptor>& xDescriptor )
5653 throw(uno::RuntimeException, std::exception)
5655 SolarMutexGuard aGuard;
5657 // das koennte theoretisch ein fremdes Objekt sein, also nur das
5658 // oeffentliche XSheetFilterDescriptor Interface benutzen, um
5659 // die Daten in ein ScFilterDescriptor Objekt zu kopieren:
5660 //! wenn es schon ein ScFilterDescriptor ist, direkt per getImplementation?
5662 ScDocShell* pDocSh = GetDocShell();
5663 ScFilterDescriptor aImpl(pDocSh);
5664 uno::Reference< sheet::XSheetFilterDescriptor2 > xDescriptor2( xDescriptor, uno::UNO_QUERY );
5665 if ( xDescriptor2.is() )
5667 aImpl.setFilterFields2( xDescriptor2->getFilterFields2() );
5669 else
5671 aImpl.setFilterFields( xDescriptor->getFilterFields() );
5673 // Rest sind jetzt Properties...
5675 uno::Reference<beans::XPropertySet> xPropSet( xDescriptor, uno::UNO_QUERY );
5676 if (xPropSet.is())
5677 lcl_CopyProperties( aImpl, *(beans::XPropertySet*)xPropSet.get() );
5679 // ausfuehren...
5681 if (pDocSh)
5683 ScQueryParam aParam = aImpl.GetParam();
5684 // im FilterDescriptor sind die Fields innerhalb des Bereichs gezaehlt
5685 SCCOLROW nFieldStart = aParam.bByRow ?
5686 static_cast<SCCOLROW>(aRange.aStart.Col()) :
5687 static_cast<SCCOLROW>(aRange.aStart.Row());
5688 SCSIZE nCount = aParam.GetEntryCount();
5689 svl::SharedStringPool& rPool = pDocSh->GetDocument().GetSharedStringPool();
5690 for (SCSIZE i=0; i<nCount; i++)
5692 ScQueryEntry& rEntry = aParam.GetEntry(i);
5693 if (rEntry.bDoQuery)
5695 rEntry.nField += nFieldStart;
5696 // Im Dialog wird immer der String angezeigt -> muss zum Wert passen
5697 ScQueryEntry::QueryItemsType& rItems = rEntry.GetQueryItems();
5698 rItems.resize(1);
5699 ScQueryEntry::Item& rItem = rItems.front();
5700 if (rItem.meType != ScQueryEntry::ByString)
5702 OUString aStr;
5703 pDocSh->GetDocument().GetFormatTable()->GetInputLineString(rItem.mfVal, 0, aStr);
5704 rItem.maString = rPool.intern(aStr);
5709 SCTAB nTab = aRange.aStart.Tab();
5710 aParam.nCol1 = aRange.aStart.Col();
5711 aParam.nRow1 = aRange.aStart.Row();
5712 aParam.nCol2 = aRange.aEnd.Col();
5713 aParam.nRow2 = aRange.aEnd.Row();
5715 pDocSh->GetDBData( aRange, SC_DB_MAKE, SC_DBSEL_FORCE_MARK ); // ggf. Bereich anlegen
5717 //! keep source range in filter descriptor
5718 //! if created by createFilterDescriptorByObject ???
5720 ScDBDocFunc aFunc(*pDocSh);
5721 aFunc.Query( nTab, aParam, NULL, true, true ); // Bereich muss angelegt sein
5725 //! get/setAutoFilter als Properties!!!
5727 // XAdvancedFilterSource
5729 uno::Reference<sheet::XSheetFilterDescriptor> SAL_CALL ScCellRangeObj::createFilterDescriptorByObject(
5730 const uno::Reference<sheet::XSheetFilterable>& xObject )
5731 throw(uno::RuntimeException, std::exception)
5733 SolarMutexGuard aGuard;
5735 // this ist hier nicht der Bereich, der gefiltert wird, sondern der
5736 // Bereich mit der Abfrage...
5738 uno::Reference<sheet::XCellRangeAddressable> xAddr( xObject, uno::UNO_QUERY );
5740 ScDocShell* pDocSh = GetDocShell();
5741 if ( pDocSh && xAddr.is() )
5743 //! Test, ob xObject im selben Dokument ist
5745 ScFilterDescriptor* pNew = new ScFilterDescriptor(pDocSh); //! stattdessen vom Objekt?
5747 ScQueryParam aParam = pNew->GetParam();
5748 aParam.bHasHeader = true;
5750 table::CellRangeAddress aDataAddress(xAddr->getRangeAddress());
5751 aParam.nCol1 = (SCCOL)aDataAddress.StartColumn;
5752 aParam.nRow1 = (SCROW)aDataAddress.StartRow;
5753 aParam.nCol2 = (SCCOL)aDataAddress.EndColumn;
5754 aParam.nRow2 = (SCROW)aDataAddress.EndRow;
5755 aParam.nTab = aDataAddress.Sheet;
5757 ScDocument& rDoc = pDocSh->GetDocument();
5758 bool bOk = rDoc.CreateQueryParam(
5759 aRange.aStart.Col(), aRange.aStart.Row(),
5760 aRange.aEnd.Col(), aRange.aEnd.Row(),
5761 aRange.aStart.Tab(), aParam );
5762 if ( bOk )
5764 // im FilterDescriptor sind die Fields innerhalb des Bereichs gezaehlt
5765 SCCOLROW nFieldStart = aParam.bByRow ?
5766 static_cast<SCCOLROW>(aDataAddress.StartColumn) :
5767 static_cast<SCCOLROW>(aDataAddress.StartRow);
5768 SCSIZE nCount = aParam.GetEntryCount();
5769 for (SCSIZE i=0; i<nCount; i++)
5771 ScQueryEntry& rEntry = aParam.GetEntry(i);
5772 if (rEntry.bDoQuery && rEntry.nField >= nFieldStart)
5773 rEntry.nField -= nFieldStart;
5776 pNew->SetParam( aParam );
5777 return pNew;
5779 else
5781 delete pNew;
5782 return NULL; // ungueltig -> null
5786 OSL_FAIL("kein Dokument oder kein Bereich");
5787 return NULL;
5790 // XSubTotalSource
5792 uno::Reference<sheet::XSubTotalDescriptor> SAL_CALL ScCellRangeObj::createSubTotalDescriptor(
5793 sal_Bool bEmpty ) throw(uno::RuntimeException, std::exception)
5795 SolarMutexGuard aGuard;
5796 ScSubTotalDescriptor* pNew = new ScSubTotalDescriptor;
5797 ScDocShell* pDocSh = GetDocShell();
5798 if ( !bEmpty && pDocSh )
5800 // DB-Bereich anlegen erst beim Ausfuehren, per API immer genau den Bereich
5801 ScDBData* pData = pDocSh->GetDBData( aRange, SC_DB_OLD, SC_DBSEL_FORCE_MARK );
5802 if (pData)
5804 ScSubTotalParam aParam;
5805 pData->GetSubTotalParam(aParam);
5806 // im SubTotalDescriptor sind die Fields innerhalb des Bereichs gezaehlt
5807 ScRange aDBRange;
5808 pData->GetArea(aDBRange);
5809 SCCOL nFieldStart = aDBRange.aStart.Col();
5810 for (sal_uInt16 i=0; i<MAXSUBTOTAL; i++)
5812 if ( aParam.bGroupActive[i] )
5814 if ( aParam.nField[i] >= nFieldStart )
5815 aParam.nField[i] = sal::static_int_cast<SCCOL>( aParam.nField[i] - nFieldStart );
5816 for (SCCOL j=0; j<aParam.nSubTotals[i]; j++)
5817 if ( aParam.pSubTotals[i][j] >= nFieldStart )
5818 aParam.pSubTotals[i][j] = sal::static_int_cast<SCCOL>( aParam.pSubTotals[i][j] - nFieldStart );
5821 pNew->SetParam(aParam);
5824 return pNew;
5827 void SAL_CALL ScCellRangeObj::applySubTotals(
5828 const uno::Reference<sheet::XSubTotalDescriptor>& xDescriptor,
5829 sal_Bool bReplace)
5830 throw (uno::RuntimeException, std::exception)
5832 SolarMutexGuard aGuard;
5834 if (!xDescriptor.is()) return;
5836 ScDocShell* pDocSh = GetDocShell();
5837 ScSubTotalDescriptorBase* pImp =
5838 ScSubTotalDescriptorBase::getImplementation( xDescriptor );
5840 if (pDocSh && pImp)
5842 ScSubTotalParam aParam;
5843 pImp->GetData(aParam); // virtuelle Methode der Basisklasse
5845 // im SubTotalDescriptor sind die Fields innerhalb des Bereichs gezaehlt
5846 SCCOL nFieldStart = aRange.aStart.Col();
5847 for (sal_uInt16 i=0; i<MAXSUBTOTAL; i++)
5849 if ( aParam.bGroupActive[i] )
5851 aParam.nField[i] = sal::static_int_cast<SCCOL>( aParam.nField[i] + nFieldStart );
5852 for (SCCOL j=0; j<aParam.nSubTotals[i]; j++)
5853 aParam.pSubTotals[i][j] = sal::static_int_cast<SCCOL>( aParam.pSubTotals[i][j] + nFieldStart );
5857 aParam.bReplace = bReplace;
5859 SCTAB nTab = aRange.aStart.Tab();
5860 aParam.nCol1 = aRange.aStart.Col();
5861 aParam.nRow1 = aRange.aStart.Row();
5862 aParam.nCol2 = aRange.aEnd.Col();
5863 aParam.nRow2 = aRange.aEnd.Row();
5865 pDocSh->GetDBData( aRange, SC_DB_MAKE, SC_DBSEL_FORCE_MARK ); // ggf. Bereich anlegen
5867 ScDBDocFunc aFunc(*pDocSh);
5868 aFunc.DoSubTotals( nTab, aParam, NULL, true, true ); // Bereich muss angelegt sein
5872 void SAL_CALL ScCellRangeObj::removeSubTotals() throw(uno::RuntimeException, std::exception)
5874 SolarMutexGuard aGuard;
5876 ScDocShell* pDocSh = GetDocShell();
5877 if (pDocSh)
5879 ScSubTotalParam aParam;
5880 ScDBData* pData = pDocSh->GetDBData( aRange, SC_DB_OLD, SC_DBSEL_FORCE_MARK );
5881 if (pData)
5882 pData->GetSubTotalParam(aParam); // auch bei Remove die Feld-Eintraege behalten
5884 aParam.bRemoveOnly = true;
5886 SCTAB nTab = aRange.aStart.Tab();
5887 aParam.nCol1 = aRange.aStart.Col();
5888 aParam.nRow1 = aRange.aStart.Row();
5889 aParam.nCol2 = aRange.aEnd.Col();
5890 aParam.nRow2 = aRange.aEnd.Row();
5892 pDocSh->GetDBData( aRange, SC_DB_MAKE, SC_DBSEL_FORCE_MARK ); // ggf. Bereich anlegen
5894 ScDBDocFunc aFunc(*pDocSh);
5895 aFunc.DoSubTotals( nTab, aParam, NULL, true, true ); // Bereich muss angelegt sein
5899 uno::Sequence<beans::PropertyValue> SAL_CALL ScCellRangeObj::createImportDescriptor( sal_Bool bEmpty )
5900 throw(uno::RuntimeException, std::exception)
5902 SolarMutexGuard aGuard;
5903 ScImportParam aParam;
5904 ScDocShell* pDocSh = GetDocShell();
5905 if ( !bEmpty && pDocSh )
5907 // DB-Bereich anlegen erst beim Ausfuehren, per API immer genau den Bereich
5908 ScDBData* pData = pDocSh->GetDBData( aRange, SC_DB_OLD, SC_DBSEL_FORCE_MARK );
5909 if (pData)
5910 pData->GetImportParam(aParam);
5913 uno::Sequence<beans::PropertyValue> aSeq( ScImportDescriptor::GetPropertyCount() );
5914 ScImportDescriptor::FillProperties( aSeq, aParam );
5915 return aSeq;
5918 void SAL_CALL ScCellRangeObj::doImport( const uno::Sequence<beans::PropertyValue>& aDescriptor )
5919 throw(uno::RuntimeException, std::exception)
5921 SolarMutexGuard aGuard;
5922 ScDocShell* pDocSh = GetDocShell();
5923 if (pDocSh)
5925 ScImportParam aParam;
5926 ScImportDescriptor::FillImportParam( aParam, aDescriptor );
5928 SCTAB nTab = aRange.aStart.Tab();
5929 aParam.nCol1 = aRange.aStart.Col();
5930 aParam.nRow1 = aRange.aStart.Row();
5931 aParam.nCol2 = aRange.aEnd.Col();
5932 aParam.nRow2 = aRange.aEnd.Row();
5934 //! TODO: could we get passed a valid result set by any means?
5936 pDocSh->GetDBData( aRange, SC_DB_MAKE, SC_DBSEL_FORCE_MARK ); // ggf. Bereich anlegen
5938 ScDBDocFunc aFunc(*pDocSh); // Bereich muss angelegt sein
5939 aFunc.DoImport( nTab, aParam, NULL, true ); //! Api-Flag as parameter
5943 // XCellFormatRangesSupplier
5945 uno::Reference<container::XIndexAccess> SAL_CALL ScCellRangeObj::getCellFormatRanges()
5946 throw(uno::RuntimeException, std::exception)
5948 SolarMutexGuard aGuard;
5949 ScDocShell* pDocSh = GetDocShell();
5950 if ( pDocSh )
5951 return new ScCellFormatsObj( pDocSh, aRange );
5952 return NULL;
5955 // XUniqueCellFormatRangesSupplier
5957 uno::Reference<container::XIndexAccess> SAL_CALL ScCellRangeObj::getUniqueCellFormatRanges()
5958 throw(uno::RuntimeException, std::exception)
5960 SolarMutexGuard aGuard;
5961 ScDocShell* pDocSh = GetDocShell();
5962 if ( pDocSh )
5963 return new ScUniqueCellFormatsObj( pDocSh, aRange );
5964 return NULL;
5967 // XPropertySet erweitert fuer Range-Properties
5969 uno::Reference<beans::XPropertySetInfo> SAL_CALL ScCellRangeObj::getPropertySetInfo()
5970 throw(uno::RuntimeException, std::exception)
5972 SolarMutexGuard aGuard;
5973 static uno::Reference<beans::XPropertySetInfo> aRef(
5974 new SfxItemPropertySetInfo( pRangePropSet->getPropertyMap() ));
5975 return aRef;
5978 void ScCellRangeObj::SetOnePropertyValue( const SfxItemPropertySimpleEntry* pEntry, const uno::Any& aValue )
5979 throw(lang::IllegalArgumentException, uno::RuntimeException, std::exception)
5981 // Range has only Position and Size in addition to ScCellRangesBase, both are ReadOnly
5982 // -> nothing to do here
5984 ScCellRangesBase::SetOnePropertyValue( pEntry, aValue );
5987 void ScCellRangeObj::GetOnePropertyValue( const SfxItemPropertySimpleEntry* pEntry, uno::Any& rAny )
5988 throw(uno::RuntimeException, std::exception)
5990 if ( pEntry )
5992 if ( pEntry->nWID == SC_WID_UNO_POS )
5994 ScDocShell* pDocSh = GetDocShell();
5995 if (pDocSh)
5997 // GetMMRect converts using HMM_PER_TWIPS, like the DrawingLayer
5998 Rectangle aMMRect(pDocSh->GetDocument().GetMMRect(
5999 aRange.aStart.Col(), aRange.aStart.Row(),
6000 aRange.aEnd.Col(), aRange.aEnd.Row(), aRange.aStart.Tab() ));
6001 awt::Point aPos( aMMRect.Left(), aMMRect.Top() );
6002 rAny <<= aPos;
6005 else if ( pEntry->nWID == SC_WID_UNO_SIZE )
6007 ScDocShell* pDocSh = GetDocShell();
6008 if (pDocSh)
6010 // GetMMRect converts using HMM_PER_TWIPS, like the DrawingLayer
6011 Rectangle aMMRect = pDocSh->GetDocument().GetMMRect(
6012 aRange.aStart.Col(), aRange.aStart.Row(),
6013 aRange.aEnd.Col(), aRange.aEnd.Row(), aRange.aStart.Tab() );
6014 Size aSize(aMMRect.GetSize());
6015 awt::Size aAwtSize( aSize.Width(), aSize.Height() );
6016 rAny <<= aAwtSize;
6019 else
6020 ScCellRangesBase::GetOnePropertyValue( pEntry, rAny );
6024 const SfxItemPropertyMap& ScCellRangeObj::GetItemPropertyMap()
6026 return pRangePropSet->getPropertyMap();
6029 // XServiceInfo
6031 OUString SAL_CALL ScCellRangeObj::getImplementationName() throw(uno::RuntimeException, std::exception)
6033 return OUString( "ScCellRangeObj" );
6036 sal_Bool SAL_CALL ScCellRangeObj::supportsService( const OUString& rServiceName )
6037 throw(uno::RuntimeException, std::exception)
6039 return cppu::supportsService(this, rServiceName);
6042 uno::Sequence<OUString> SAL_CALL ScCellRangeObj::getSupportedServiceNames()
6043 throw(uno::RuntimeException, std::exception)
6045 uno::Sequence<OUString> aRet(5);
6046 OUString* pArray = aRet.getArray();
6047 pArray[0] = SCSHEETCELLRANGE_SERVICE;
6048 pArray[1] = SCCELLRANGE_SERVICE;
6049 pArray[2] = SCCELLPROPERTIES_SERVICE;
6050 pArray[3] = SCCHARPROPERTIES_SERVICE;
6051 pArray[4] = SCPARAPROPERTIES_SERVICE;
6052 return aRet;
6055 const SvxItemPropertySet* ScCellObj::GetEditPropertySet()
6057 return lcl_GetEditPropertySet();
6060 const SfxItemPropertyMap& ScCellObj::GetCellPropertyMap()
6062 return lcl_GetCellPropertySet()->getPropertyMap();
6065 ScCellObj::ScCellObj(ScDocShell* pDocSh, const ScAddress& rP) :
6066 ScCellRangeObj( pDocSh, ScRange(rP,rP) ),
6067 pCellPropSet( lcl_GetCellPropertySet() ),
6068 aCellPos( rP ),
6069 nActionLockCount( 0 )
6071 // pUnoText is allocated on demand (GetUnoText)
6072 // can't be aggregated because getString/setString is handled here
6075 SvxUnoText& ScCellObj::GetUnoText()
6077 if (!mxUnoText.is())
6079 mxUnoText.set(new ScCellTextObj(GetDocShell(), aCellPos));
6080 if (nActionLockCount)
6082 ScCellEditSource* pEditSource =
6083 static_cast<ScCellEditSource*> (mxUnoText->GetEditSource());
6084 if (pEditSource)
6085 pEditSource->SetDoUpdateData(false);
6088 return *mxUnoText;
6091 ScCellObj::~ScCellObj()
6095 void ScCellObj::RefChanged()
6097 ScCellRangeObj::RefChanged();
6099 const ScRangeList& rRanges = GetRangeList();
6100 OSL_ENSURE(rRanges.size() == 1, "was fuer Ranges ?!?!");
6101 if ( !rRanges.empty() )
6103 const ScRange* pFirst = rRanges[ 0 ];
6104 aCellPos = pFirst->aStart;
6108 uno::Any SAL_CALL ScCellObj::queryInterface( const uno::Type& rType ) throw(uno::RuntimeException, std::exception)
6110 SC_QUERYINTERFACE( table::XCell )
6111 SC_QUERYINTERFACE( table::XCell2 )
6112 SC_QUERYINTERFACE( sheet::XFormulaTokens )
6113 SC_QUERYINTERFACE( sheet::XCellAddressable )
6114 SC_QUERYINTERFACE( text::XText )
6115 SC_QUERYINTERFACE( text::XSimpleText )
6116 SC_QUERYINTERFACE( text::XTextRange )
6117 SC_QUERYINTERFACE( container::XEnumerationAccess )
6118 SC_QUERYINTERFACE( container::XElementAccess )
6119 SC_QUERYINTERFACE( sheet::XSheetAnnotationAnchor )
6120 SC_QUERYINTERFACE( text::XTextFieldsSupplier )
6121 SC_QUERYINTERFACE( document::XActionLockable )
6123 return ScCellRangeObj::queryInterface( rType );
6126 void SAL_CALL ScCellObj::acquire() throw()
6128 ScCellRangeObj::acquire();
6131 void SAL_CALL ScCellObj::release() throw()
6133 ScCellRangeObj::release();
6136 uno::Sequence<uno::Type> SAL_CALL ScCellObj::getTypes() throw(uno::RuntimeException, std::exception)
6138 static uno::Sequence<uno::Type> aTypes;
6139 if ( aTypes.getLength() == 0 )
6141 uno::Sequence<uno::Type> aParentTypes(ScCellRangeObj::getTypes());
6142 long nParentLen = aParentTypes.getLength();
6143 const uno::Type* pParentPtr = aParentTypes.getConstArray();
6145 aTypes.realloc( nParentLen + 9 );
6146 uno::Type* pPtr = aTypes.getArray();
6147 pPtr[nParentLen + 0] = cppu::UnoType<table::XCell>::get();
6148 pPtr[nParentLen + 1] = cppu::UnoType<sheet::XCellAddressable>::get();
6149 pPtr[nParentLen + 2] = cppu::UnoType<text::XText>::get();
6150 pPtr[nParentLen + 3] = cppu::UnoType<container::XEnumerationAccess>::get();
6151 pPtr[nParentLen + 4] = cppu::UnoType<sheet::XSheetAnnotationAnchor>::get();
6152 pPtr[nParentLen + 5] = cppu::UnoType<text::XTextFieldsSupplier>::get();
6153 pPtr[nParentLen + 6] = cppu::UnoType<document::XActionLockable>::get();
6154 pPtr[nParentLen + 7] = cppu::UnoType<sheet::XFormulaTokens>::get();
6155 pPtr[nParentLen + 8] = cppu::UnoType<table::XCell2>::get();
6157 for (long i=0; i<nParentLen; i++)
6158 pPtr[i] = pParentPtr[i]; // parent types first
6160 return aTypes;
6163 uno::Sequence<sal_Int8> SAL_CALL ScCellObj::getImplementationId() throw(uno::RuntimeException, std::exception)
6165 return css::uno::Sequence<sal_Int8>();
6168 // Hilfsfunktionen
6170 OUString ScCellObj::GetInputString_Impl(bool bEnglish) const // fuer getFormula / FormulaLocal
6172 if (GetDocShell())
6173 return lcl_GetInputString( GetDocShell()->GetDocument(), aCellPos, bEnglish );
6174 return OUString();
6177 OUString ScCellObj::GetOutputString_Impl() const
6179 ScDocShell* pDocSh = GetDocShell();
6180 OUString aVal;
6181 if ( pDocSh )
6183 ScDocument& rDoc = pDocSh->GetDocument();
6184 ScRefCellValue aCell;
6185 aCell.assign(rDoc, aCellPos);
6187 aVal = ScCellFormat::GetOutputString(rDoc, aCellPos, aCell);
6189 return aVal;
6192 void ScCellObj::SetString_Impl(const OUString& rString, bool bInterpret, bool bEnglish)
6194 ScDocShell* pDocSh = GetDocShell();
6195 if ( pDocSh )
6197 // GRAM_PODF_A1 for API compatibility.
6198 (void)pDocSh->GetDocFunc().SetCellText(
6199 aCellPos, rString, bInterpret, bEnglish, true, formula::FormulaGrammar::GRAM_PODF_A1 );
6203 double ScCellObj::GetValue_Impl() const
6205 ScDocShell* pDocSh = GetDocShell();
6206 if ( pDocSh )
6207 return pDocSh->GetDocument().GetValue( aCellPos );
6209 return 0.0;
6212 void ScCellObj::SetValue_Impl(double fValue)
6214 ScDocShell* pDocSh = GetDocShell();
6215 if ( pDocSh )
6216 pDocSh->GetDocFunc().SetValueCell(aCellPos, fValue, false);
6219 // only for XML import
6221 void ScCellObj::InputEnglishString( const OUString& rText )
6223 // This is like a mixture of setFormula and property FormulaLocal:
6224 // The cell's number format is checked for "text", a new cell format may be set,
6225 // but all parsing is in English.
6227 ScDocShell* pDocSh = GetDocShell();
6228 if (!pDocSh)
6229 return;
6231 OUString aString(rText);
6232 ScDocument& rDoc = pDocSh->GetDocument();
6233 SvNumberFormatter* pFormatter = rDoc.GetFormatTable();
6234 sal_uInt32 nOldFormat = rDoc.GetNumberFormat( aCellPos );
6235 if (pFormatter->GetType(nOldFormat) == css::util::NumberFormat::TEXT)
6237 SetString_Impl(aString, false, false); // text cell
6238 return;
6241 ScDocFunc &rFunc = pDocSh->GetDocFunc();
6243 ScInputStringType aRes =
6244 ScStringUtil::parseInputString(*pFormatter, aString, LANGUAGE_ENGLISH_US);
6246 if (aRes.meType != ScInputStringType::Unknown)
6248 if ((nOldFormat % SV_COUNTRY_LANGUAGE_OFFSET) == 0 && aRes.mnFormatType)
6250 // apply a format for the recognized type and the old format's language
6251 sal_uInt32 nNewFormat = ScGlobal::GetStandardFormat(*pFormatter, nOldFormat, aRes.mnFormatType);
6252 if (nNewFormat != nOldFormat)
6254 ScPatternAttr aPattern( rDoc.GetPool() );
6255 aPattern.GetItemSet().Put( SfxUInt32Item( ATTR_VALUE_FORMAT, nNewFormat ) );
6256 // ATTR_LANGUAGE_FORMAT remains unchanged
6257 rFunc.ApplyAttributes( *GetMarkData(), aPattern, true, true );
6261 switch (aRes.meType)
6263 case ScInputStringType::Formula:
6264 rFunc.SetFormulaCell(
6265 aCellPos,
6266 new ScFormulaCell(&rDoc, aCellPos, aRes.maText, formula::FormulaGrammar::GRAM_PODF_A1),
6267 false);
6268 break;
6269 case ScInputStringType::Number:
6270 rFunc.SetValueCell(aCellPos, aRes.mfValue, false);
6271 break;
6272 case ScInputStringType::Text:
6273 rFunc.SetStringOrEditCell(aCellPos, aRes.maText, false);
6274 break;
6275 default:
6276 SetString_Impl(aString, false, false); // probably empty string
6280 // XText
6282 uno::Reference<text::XTextCursor> SAL_CALL ScCellObj::createTextCursor()
6283 throw(uno::RuntimeException, std::exception)
6285 SolarMutexGuard aGuard;
6286 return new ScCellTextCursor( *this );
6289 uno::Reference<text::XTextCursor> SAL_CALL ScCellObj::createTextCursorByRange(
6290 const uno::Reference<text::XTextRange>& aTextPosition )
6291 throw(uno::RuntimeException, std::exception)
6293 SolarMutexGuard aGuard;
6294 SvxUnoTextCursor* pCursor = new ScCellTextCursor( *this );
6295 uno::Reference<text::XTextCursor> xCursor(pCursor);
6297 SvxUnoTextRangeBase* pRange = SvxUnoTextRangeBase::getImplementation( aTextPosition );
6298 if(pRange)
6299 pCursor->SetSelection( pRange->GetSelection() );
6300 else
6302 ScCellTextCursor* pOther = ScCellTextCursor::getImplementation( aTextPosition );
6303 if(pOther)
6304 pCursor->SetSelection( pOther->GetSelection() );
6305 else
6306 throw uno::RuntimeException();
6309 return xCursor;
6312 OUString SAL_CALL ScCellObj::getString() throw(uno::RuntimeException, std::exception)
6314 SolarMutexGuard aGuard;
6315 return GetOutputString_Impl();
6318 void SAL_CALL ScCellObj::setString( const OUString& aText ) throw(uno::RuntimeException, std::exception)
6320 SolarMutexGuard aGuard;
6321 OUString aString(aText);
6322 SetString_Impl(aString, false, false); // immer Text
6324 // don't create pUnoText here if not there
6325 if (mxUnoText.is())
6326 mxUnoText->SetSelection(ESelection( 0,0, 0,aString.getLength() ));
6329 void SAL_CALL ScCellObj::insertString( const uno::Reference<text::XTextRange>& xRange,
6330 const OUString& aString, sal_Bool bAbsorb )
6331 throw(uno::RuntimeException, std::exception)
6333 // special handling for ScCellTextCursor is no longer needed,
6334 // SvxUnoText::insertString checks for SvxUnoTextRangeBase instead of SvxUnoTextRange
6336 SolarMutexGuard aGuard;
6337 GetUnoText().insertString(xRange, aString, bAbsorb);
6340 void SAL_CALL ScCellObj::insertControlCharacter( const uno::Reference<text::XTextRange>& xRange,
6341 sal_Int16 nControlCharacter, sal_Bool bAbsorb )
6342 throw(lang::IllegalArgumentException, uno::RuntimeException, std::exception)
6344 SolarMutexGuard aGuard;
6345 GetUnoText().insertControlCharacter(xRange, nControlCharacter, bAbsorb);
6348 void SAL_CALL ScCellObj::insertTextContent( const uno::Reference<text::XTextRange >& xRange,
6349 const uno::Reference<text::XTextContent >& xContent,
6350 sal_Bool bAbsorb )
6351 throw(lang::IllegalArgumentException, uno::RuntimeException, std::exception)
6353 SolarMutexGuard aGuard;
6354 ScDocShell* pDocSh = GetDocShell();
6355 if ( pDocSh && xContent.is() )
6357 ScEditFieldObj* pCellField = ScEditFieldObj::getImplementation(xContent);
6358 SvxUnoTextRangeBase* pTextRange = ScCellTextCursor::getImplementation( xRange );
6360 if ( pCellField && !pCellField->IsInserted() && pTextRange )
6362 SvxEditSource* pEditSource = pTextRange->GetEditSource();
6363 ESelection aSelection(pTextRange->GetSelection());
6365 if (!bAbsorb)
6367 // nicht ersetzen -> hinten anhaengen
6368 aSelection.Adjust();
6369 aSelection.nStartPara = aSelection.nEndPara;
6370 aSelection.nStartPos = aSelection.nEndPos;
6373 if (pCellField->GetFieldType() == text::textfield::Type::TABLE)
6374 pCellField->setPropertyValue(SC_UNONAME_TABLEPOS, uno::makeAny<sal_Int32>(aCellPos.Tab()));
6376 SvxFieldItem aItem = pCellField->CreateFieldItem();
6377 SvxTextForwarder* pForwarder = pEditSource->GetTextForwarder();
6378 pForwarder->QuickInsertField( aItem, aSelection );
6379 pEditSource->UpdateData();
6381 // neue Selektion: ein Zeichen
6382 aSelection.Adjust();
6383 aSelection.nEndPara = aSelection.nStartPara;
6384 aSelection.nEndPos = aSelection.nStartPos + 1;
6385 uno::Reference<text::XTextRange> xParent(this);
6386 pCellField->InitDoc(
6387 xParent, new ScCellEditSource(pDocSh, aCellPos), aSelection);
6389 // for bAbsorb=FALSE, the new selection must be behind the inserted content
6390 // (the xml filter relies on this)
6391 if (!bAbsorb)
6392 aSelection.nStartPos = aSelection.nEndPos;
6394 pTextRange->SetSelection( aSelection );
6396 return;
6399 GetUnoText().insertTextContent(xRange, xContent, bAbsorb);
6402 void SAL_CALL ScCellObj::removeTextContent( const uno::Reference<text::XTextContent>& xContent )
6403 throw(container::NoSuchElementException, uno::RuntimeException, std::exception)
6405 SolarMutexGuard aGuard;
6406 if ( xContent.is() )
6408 ScEditFieldObj* pCellField = ScEditFieldObj::getImplementation(xContent);
6409 if ( pCellField && pCellField->IsInserted() )
6411 //! Testen, ob das Feld in dieser Zelle ist
6412 pCellField->DeleteField();
6413 return;
6416 GetUnoText().removeTextContent(xContent);
6419 uno::Reference<text::XText> SAL_CALL ScCellObj::getText() throw(uno::RuntimeException, std::exception)
6421 SolarMutexGuard aGuard;
6422 return this;
6425 uno::Reference<text::XTextRange> SAL_CALL ScCellObj::getStart() throw(uno::RuntimeException, std::exception)
6427 SolarMutexGuard aGuard;
6428 return GetUnoText().getStart();
6431 uno::Reference<text::XTextRange> SAL_CALL ScCellObj::getEnd() throw(uno::RuntimeException, std::exception)
6433 SolarMutexGuard aGuard;
6434 return GetUnoText().getEnd();
6437 uno::Reference<container::XEnumeration> SAL_CALL ScCellObj::createEnumeration()
6438 throw(uno::RuntimeException, std::exception)
6440 SolarMutexGuard aGuard;
6441 return GetUnoText().createEnumeration();
6444 uno::Type SAL_CALL ScCellObj::getElementType() throw(uno::RuntimeException, std::exception)
6446 SolarMutexGuard aGuard;
6447 return GetUnoText().getElementType();
6450 sal_Bool SAL_CALL ScCellObj::hasElements() throw(uno::RuntimeException, std::exception)
6452 SolarMutexGuard aGuard;
6453 return GetUnoText().hasElements();
6456 // XCell
6458 OUString SAL_CALL ScCellObj::getFormula() throw(uno::RuntimeException, std::exception)
6460 SolarMutexGuard aGuard;
6461 return GetInputString_Impl( true /* English */ );
6464 void SAL_CALL ScCellObj::setFormula( const OUString& aFormula ) throw(uno::RuntimeException, std::exception)
6466 SolarMutexGuard aGuard;
6467 OUString aString(aFormula);
6468 SetString_Impl(aString, true, true); // Interpret as English
6471 double SAL_CALL ScCellObj::getValue() throw(uno::RuntimeException, std::exception)
6473 SolarMutexGuard aGuard;
6474 return GetValue_Impl();
6477 void SAL_CALL ScCellObj::setValue( double nValue ) throw(uno::RuntimeException, std::exception)
6479 SolarMutexGuard aGuard;
6480 SetValue_Impl(nValue);
6483 void SAL_CALL ScCellObj::setFormulaString( const OUString& aFormula) throw(uno::RuntimeException, std::exception)
6485 SolarMutexGuard aGuard;
6486 ScDocShell *pDocSh = GetDocShell();
6487 if( pDocSh )
6489 ScFormulaCell* pCell = new ScFormulaCell( &pDocSh->GetDocument(), aCellPos );
6490 pCell->SetHybridFormula( aFormula, formula::FormulaGrammar::GRAM_NATIVE );
6491 pDocSh->GetDocFunc().SetFormulaCell(aCellPos, pCell, false);
6494 void SAL_CALL ScCellObj::setFormulaResult( double nValue ) throw(uno::RuntimeException, std::exception)
6496 SolarMutexGuard aGuard;
6497 ScDocShell* pDocSh = GetDocShell();
6498 if ( pDocSh && pDocSh->GetDocument().GetCellType( aCellPos ) == CELLTYPE_FORMULA )
6500 ScFormulaCell* pCell = pDocSh->GetDocument().GetFormulaCell(aCellPos);
6501 if (!pCell)
6502 return;
6503 pCell->SetHybridDouble( nValue );
6504 pCell->ResetDirty();
6505 pCell->SetChanged(false);
6509 table::CellContentType SAL_CALL ScCellObj::getType() throw(uno::RuntimeException, std::exception)
6511 SolarMutexGuard aGuard;
6512 table::CellContentType eRet = table::CellContentType_EMPTY;
6513 ScDocShell* pDocSh = GetDocShell();
6514 if (pDocSh)
6516 CellType eCalcType = pDocSh->GetDocument().GetCellType( aCellPos );
6517 switch (eCalcType)
6519 case CELLTYPE_VALUE:
6520 eRet = table::CellContentType_VALUE;
6521 break;
6522 case CELLTYPE_STRING:
6523 case CELLTYPE_EDIT:
6524 eRet = table::CellContentType_TEXT;
6525 break;
6526 case CELLTYPE_FORMULA:
6527 eRet = table::CellContentType_FORMULA;
6528 break;
6529 default:
6530 eRet = table::CellContentType_EMPTY;
6533 else
6535 OSL_FAIL("keine DocShell"); //! Exception oder so?
6538 return eRet;
6541 table::CellContentType ScCellObj::GetResultType_Impl()
6543 ScDocShell* pDocSh = GetDocShell();
6544 if ( pDocSh )
6546 ScRefCellValue aCell;
6547 aCell.assign(pDocSh->GetDocument(), aCellPos);
6548 if (aCell.meType == CELLTYPE_FORMULA)
6550 bool bValue = aCell.mpFormula->IsValue();
6551 return bValue ? table::CellContentType_VALUE : table::CellContentType_TEXT;
6554 return getType(); // wenn keine Formel
6557 sal_Int32 SAL_CALL ScCellObj::getError() throw(uno::RuntimeException, std::exception)
6559 SolarMutexGuard aGuard;
6560 ScDocShell* pDocSh = GetDocShell();
6561 if (!pDocSh)
6563 OSL_FAIL("keine DocShell"); //! Exception oder so?
6564 return 0;
6567 sal_uInt16 nError = 0;
6568 ScRefCellValue aCell;
6569 aCell.assign(pDocSh->GetDocument(), aCellPos);
6570 if (aCell.meType == CELLTYPE_FORMULA)
6571 nError = aCell.mpFormula->GetErrCode();
6573 return nError;
6576 // XFormulaTokens
6578 uno::Sequence<sheet::FormulaToken> SAL_CALL ScCellObj::getTokens()
6579 throw (uno::RuntimeException, std::exception)
6581 SolarMutexGuard aGuard;
6582 uno::Sequence<sheet::FormulaToken> aSequence;
6583 ScDocShell* pDocSh = GetDocShell();
6584 if (!pDocSh)
6585 return aSequence;
6587 ScDocument& rDoc = pDocSh->GetDocument();
6588 ScRefCellValue aCell;
6589 aCell.assign(rDoc, aCellPos);
6590 if (aCell.meType == CELLTYPE_FORMULA)
6592 ScTokenArray* pTokenArray = aCell.mpFormula->GetCode();
6593 if (pTokenArray)
6594 ScTokenConversion::ConvertToTokenSequence(rDoc, aSequence, *pTokenArray);
6596 return aSequence;
6599 void SAL_CALL ScCellObj::setTokens( const uno::Sequence<sheet::FormulaToken>& rTokens ) throw(uno::RuntimeException, std::exception)
6601 SolarMutexGuard aGuard;
6602 ScDocShell* pDocSh = GetDocShell();
6603 if ( pDocSh )
6605 ScDocument& rDoc = pDocSh->GetDocument();
6606 ScTokenArray aTokenArray;
6607 (void)ScTokenConversion::ConvertToTokenArray( rDoc, aTokenArray, rTokens );
6609 ScFormulaCell* pNewCell = new ScFormulaCell(&rDoc, aCellPos, aTokenArray);
6610 (void)pDocSh->GetDocFunc().SetFormulaCell(aCellPos, pNewCell, false);
6614 // XCellAddressable
6616 table::CellAddress SAL_CALL ScCellObj::getCellAddress() throw(uno::RuntimeException, std::exception)
6618 SolarMutexGuard aGuard;
6619 table::CellAddress aAdr;
6620 aAdr.Sheet = aCellPos.Tab();
6621 aAdr.Column = aCellPos.Col();
6622 aAdr.Row = aCellPos.Row();
6623 return aAdr;
6626 // XSheetAnnotationAnchor
6628 uno::Reference<sheet::XSheetAnnotation> SAL_CALL ScCellObj::getAnnotation()
6629 throw(uno::RuntimeException, std::exception)
6631 SolarMutexGuard aGuard;
6632 ScDocShell* pDocSh = GetDocShell();
6633 if ( pDocSh )
6634 return new ScAnnotationObj( pDocSh, aCellPos );
6636 OSL_FAIL("getAnnotation ohne DocShell");
6637 return NULL;
6640 // XFieldTypesSupplier
6642 uno::Reference<container::XEnumerationAccess> SAL_CALL ScCellObj::getTextFields()
6643 throw(uno::RuntimeException, std::exception)
6645 SolarMutexGuard aGuard;
6646 ScDocShell* pDocSh = GetDocShell();
6647 if ( pDocSh )
6649 uno::Reference<text::XTextRange> xContent(this);
6650 return new ScCellFieldsObj(xContent, pDocSh, aCellPos);
6653 return NULL;
6656 uno::Reference<container::XNameAccess> SAL_CALL ScCellObj::getTextFieldMasters()
6657 throw(uno::RuntimeException, std::exception)
6659 // sowas gibts nicht im Calc (?)
6660 return NULL;
6663 // XPropertySet erweitert fuer Zell-Properties
6665 uno::Reference<beans::XPropertySetInfo> SAL_CALL ScCellObj::getPropertySetInfo()
6666 throw(uno::RuntimeException, std::exception)
6668 SolarMutexGuard aGuard;
6669 static uno::Reference<beans::XPropertySetInfo> aRef(
6670 new SfxItemPropertySetInfo( pCellPropSet->getPropertyMap() ));
6671 return aRef;
6674 void ScCellObj::SetOnePropertyValue( const SfxItemPropertySimpleEntry* pEntry, const uno::Any& aValue )
6675 throw(lang::IllegalArgumentException, uno::RuntimeException, std::exception)
6677 if ( pEntry )
6679 if ( pEntry->nWID == SC_WID_UNO_FORMLOC )
6681 OUString aStrVal;
6682 aValue >>= aStrVal;
6683 OUString aString(aStrVal);
6684 SetString_Impl(aString, true, false); // lokal interpretieren
6686 else if ( pEntry->nWID == SC_WID_UNO_FORMRT )
6688 // Read-Only
6689 //! Exception oder so...
6691 else
6692 ScCellRangeObj::SetOnePropertyValue( pEntry, aValue );
6696 void ScCellObj::GetOnePropertyValue( const SfxItemPropertySimpleEntry* pEntry, uno::Any& rAny )
6697 throw(uno::RuntimeException, std::exception)
6699 if ( pEntry )
6701 if ( pEntry->nWID == SC_WID_UNO_FORMLOC )
6703 // sal_False = lokal
6704 rAny <<= OUString( GetInputString_Impl(false) );
6706 else if ( pEntry->nWID == SC_WID_UNO_FORMRT )
6708 table::CellContentType eType = GetResultType_Impl();
6709 rAny <<= eType;
6711 else
6712 ScCellRangeObj::GetOnePropertyValue(pEntry, rAny);
6716 const SfxItemPropertyMap& ScCellObj::GetItemPropertyMap()
6718 return pCellPropSet->getPropertyMap();
6721 // XServiceInfo
6723 OUString SAL_CALL ScCellObj::getImplementationName() throw(uno::RuntimeException, std::exception)
6725 return OUString( "ScCellObj" );
6728 sal_Bool SAL_CALL ScCellObj::supportsService( const OUString& rServiceName )
6729 throw(uno::RuntimeException, std::exception)
6731 return cppu::supportsService(this, rServiceName);
6734 uno::Sequence<OUString> SAL_CALL ScCellObj::getSupportedServiceNames()
6735 throw(uno::RuntimeException, std::exception)
6737 uno::Sequence<OUString> aRet(7);
6738 OUString* pArray = aRet.getArray();
6739 pArray[0] = SCSHEETCELL_SERVICE;
6740 pArray[1] = SCCELL_SERVICE;
6741 pArray[2] = SCCELLPROPERTIES_SERVICE;
6742 pArray[3] = SCCHARPROPERTIES_SERVICE;
6743 pArray[4] = SCPARAPROPERTIES_SERVICE;
6744 pArray[5] = SCSHEETCELLRANGE_SERVICE;
6745 pArray[6] = SCCELLRANGE_SERVICE;
6746 return aRet;
6749 // XActionLockable
6751 sal_Bool SAL_CALL ScCellObj::isActionLocked() throw(uno::RuntimeException, std::exception)
6753 SolarMutexGuard aGuard;
6754 return nActionLockCount != 0;
6757 void SAL_CALL ScCellObj::addActionLock() throw(uno::RuntimeException, std::exception)
6759 SolarMutexGuard aGuard;
6760 if (!nActionLockCount)
6762 if (mxUnoText.is())
6764 ScCellEditSource* pEditSource =
6765 static_cast<ScCellEditSource*> (mxUnoText->GetEditSource());
6766 if (pEditSource)
6767 pEditSource->SetDoUpdateData(false);
6770 nActionLockCount++;
6773 void SAL_CALL ScCellObj::removeActionLock() throw(uno::RuntimeException, std::exception)
6775 SolarMutexGuard aGuard;
6776 if (nActionLockCount > 0)
6778 nActionLockCount--;
6779 if (!nActionLockCount)
6781 if (mxUnoText.is())
6783 ScCellEditSource* pEditSource =
6784 static_cast<ScCellEditSource*> (mxUnoText->GetEditSource());
6785 if (pEditSource)
6787 pEditSource->SetDoUpdateData(true);
6788 if (pEditSource->IsDirty())
6789 pEditSource->UpdateData();
6796 void SAL_CALL ScCellObj::setActionLocks( sal_Int16 nLock ) throw(uno::RuntimeException, std::exception)
6798 SolarMutexGuard aGuard;
6799 if (mxUnoText.is())
6801 ScCellEditSource* pEditSource =
6802 static_cast<ScCellEditSource*> (mxUnoText->GetEditSource());
6803 if (pEditSource)
6805 pEditSource->SetDoUpdateData(nLock == 0);
6806 if ((nActionLockCount > 0) && (nLock == 0) && pEditSource->IsDirty())
6807 pEditSource->UpdateData();
6810 nActionLockCount = nLock;
6813 sal_Int16 SAL_CALL ScCellObj::resetActionLocks() throw(uno::RuntimeException, std::exception)
6815 SolarMutexGuard aGuard;
6816 sal_uInt16 nRet(nActionLockCount);
6817 if (mxUnoText.is())
6819 ScCellEditSource* pEditSource =
6820 static_cast<ScCellEditSource*> (mxUnoText->GetEditSource());
6821 if (pEditSource)
6823 pEditSource->SetDoUpdateData(true);
6824 if (pEditSource->IsDirty())
6825 pEditSource->UpdateData();
6828 nActionLockCount = 0;
6829 return nRet;
6832 ScTableSheetObj::ScTableSheetObj( ScDocShell* pDocSh, SCTAB nTab ) :
6833 ScCellRangeObj( pDocSh, ScRange(0,0,nTab, MAXCOL,MAXROW,nTab) ),
6834 pSheetPropSet(lcl_GetSheetPropertySet())
6838 ScTableSheetObj::~ScTableSheetObj()
6842 void ScTableSheetObj::InitInsertSheet(ScDocShell* pDocSh, SCTAB nTab)
6844 InitInsertRange( pDocSh, ScRange(0,0,nTab, MAXCOL,MAXROW,nTab) );
6847 uno::Any SAL_CALL ScTableSheetObj::queryInterface( const uno::Type& rType ) throw(uno::RuntimeException, std::exception)
6849 SC_QUERYINTERFACE( sheet::XSpreadsheet )
6850 SC_QUERYINTERFACE( container::XNamed )
6851 SC_QUERYINTERFACE( sheet::XSheetPageBreak )
6852 SC_QUERYINTERFACE( sheet::XCellRangeMovement )
6853 SC_QUERYINTERFACE( table::XTableChartsSupplier )
6854 SC_QUERYINTERFACE( sheet::XDataPilotTablesSupplier )
6855 SC_QUERYINTERFACE( sheet::XScenariosSupplier )
6856 SC_QUERYINTERFACE( sheet::XSheetAnnotationsSupplier )
6857 SC_QUERYINTERFACE( drawing::XDrawPageSupplier )
6858 SC_QUERYINTERFACE( sheet::XPrintAreas )
6859 SC_QUERYINTERFACE( sheet::XSheetAuditing )
6860 SC_QUERYINTERFACE( sheet::XSheetOutline )
6861 SC_QUERYINTERFACE( util::XProtectable )
6862 SC_QUERYINTERFACE( sheet::XScenario )
6863 SC_QUERYINTERFACE( sheet::XScenarioEnhanced )
6864 SC_QUERYINTERFACE( sheet::XSheetLinkable )
6865 SC_QUERYINTERFACE( sheet::XExternalSheetName )
6866 SC_QUERYINTERFACE( document::XEventsSupplier )
6868 return ScCellRangeObj::queryInterface( rType );
6871 void SAL_CALL ScTableSheetObj::acquire() throw()
6873 ScCellRangeObj::acquire();
6876 void SAL_CALL ScTableSheetObj::release() throw()
6878 ScCellRangeObj::release();
6881 uno::Sequence<uno::Type> SAL_CALL ScTableSheetObj::getTypes() throw(uno::RuntimeException, std::exception)
6883 static uno::Sequence<uno::Type> aTypes;
6884 if ( aTypes.getLength() == 0 )
6886 uno::Sequence<uno::Type> aParentTypes = ScCellRangeObj::getTypes();
6887 long nParentLen = aParentTypes.getLength();
6888 const uno::Type* pParentPtr = aParentTypes.getConstArray();
6890 aTypes.realloc( nParentLen + 18 );
6891 uno::Type* pPtr = aTypes.getArray();
6892 pPtr[nParentLen + 0] = cppu::UnoType<sheet::XSpreadsheet>::get();
6893 pPtr[nParentLen + 1] = cppu::UnoType<container::XNamed>::get();
6894 pPtr[nParentLen + 2] = cppu::UnoType<sheet::XSheetPageBreak>::get();
6895 pPtr[nParentLen + 3] = cppu::UnoType<sheet::XCellRangeMovement>::get();
6896 pPtr[nParentLen + 4] = cppu::UnoType<table::XTableChartsSupplier>::get();
6897 pPtr[nParentLen + 5] = cppu::UnoType<sheet::XDataPilotTablesSupplier>::get();
6898 pPtr[nParentLen + 6] = cppu::UnoType<sheet::XScenariosSupplier>::get();
6899 pPtr[nParentLen + 7] = cppu::UnoType<sheet::XSheetAnnotationsSupplier>::get();
6900 pPtr[nParentLen + 8] = cppu::UnoType<drawing::XDrawPageSupplier>::get();
6901 pPtr[nParentLen + 9] = cppu::UnoType<sheet::XPrintAreas>::get();
6902 pPtr[nParentLen +10] = cppu::UnoType<sheet::XSheetAuditing>::get();
6903 pPtr[nParentLen +11] = cppu::UnoType<sheet::XSheetOutline>::get();
6904 pPtr[nParentLen +12] = cppu::UnoType<util::XProtectable>::get();
6905 pPtr[nParentLen +13] = cppu::UnoType<sheet::XScenario>::get();
6906 pPtr[nParentLen +14] = cppu::UnoType<sheet::XScenarioEnhanced>::get();
6907 pPtr[nParentLen +15] = cppu::UnoType<sheet::XSheetLinkable>::get();
6908 pPtr[nParentLen +16] = cppu::UnoType<sheet::XExternalSheetName>::get();
6909 pPtr[nParentLen +17] = cppu::UnoType<document::XEventsSupplier>::get();
6911 for (long i=0; i<nParentLen; i++)
6912 pPtr[i] = pParentPtr[i]; // parent types first
6914 return aTypes;
6917 uno::Sequence<sal_Int8> SAL_CALL ScTableSheetObj::getImplementationId() throw(uno::RuntimeException, std::exception)
6919 return css::uno::Sequence<sal_Int8>();
6922 // Hilfsfunktionen
6924 SCTAB ScTableSheetObj::GetTab_Impl() const
6926 const ScRangeList& rRanges = GetRangeList();
6927 OSL_ENSURE(rRanges.size() == 1, "was fuer Ranges ?!?!");
6928 if ( !rRanges.empty() )
6930 const ScRange* pFirst = rRanges[ 0 ];
6931 return pFirst->aStart.Tab();
6933 return 0; // soll nicht sein
6936 // former XSheet
6938 uno::Reference<table::XTableCharts> SAL_CALL ScTableSheetObj::getCharts() throw(uno::RuntimeException, std::exception)
6940 SolarMutexGuard aGuard;
6941 ScDocShell* pDocSh = GetDocShell();
6942 if ( pDocSh )
6943 return new ScChartsObj( pDocSh, GetTab_Impl() );
6945 OSL_FAIL("kein Dokument");
6946 return NULL;
6949 uno::Reference<sheet::XDataPilotTables> SAL_CALL ScTableSheetObj::getDataPilotTables()
6950 throw(uno::RuntimeException, std::exception)
6952 SolarMutexGuard aGuard;
6953 ScDocShell* pDocSh = GetDocShell();
6954 if ( pDocSh )
6955 return new ScDataPilotTablesObj( pDocSh, GetTab_Impl() );
6957 OSL_FAIL("kein Dokument");
6958 return NULL;
6961 uno::Reference<sheet::XScenarios> SAL_CALL ScTableSheetObj::getScenarios() throw(uno::RuntimeException, std::exception)
6963 SolarMutexGuard aGuard;
6964 ScDocShell* pDocSh = GetDocShell();
6966 if ( pDocSh )
6967 return new ScScenariosObj( pDocSh, GetTab_Impl() );
6969 OSL_FAIL("kein Dokument");
6970 return NULL;
6973 uno::Reference<sheet::XSheetAnnotations> SAL_CALL ScTableSheetObj::getAnnotations()
6974 throw(uno::RuntimeException, std::exception)
6976 SolarMutexGuard aGuard;
6977 ScDocShell* pDocSh = GetDocShell();
6979 if ( pDocSh )
6980 return new ScAnnotationsObj( pDocSh, GetTab_Impl() );
6982 OSL_FAIL("kein Dokument");
6983 return NULL;
6986 uno::Reference<table::XCellRange> SAL_CALL ScTableSheetObj::getCellRangeByName(
6987 const OUString& rRange ) throw(uno::RuntimeException, std::exception)
6989 SolarMutexGuard aGuard;
6990 return ScCellRangeObj::getCellRangeByName( rRange );
6993 uno::Reference<sheet::XSheetCellCursor> SAL_CALL ScTableSheetObj::createCursor()
6994 throw(uno::RuntimeException, std::exception)
6996 SolarMutexGuard aGuard;
6997 ScDocShell* pDocSh = GetDocShell();
6998 if ( pDocSh )
7000 //! einzelne Zelle oder ganze Tabelle???????
7001 SCTAB nTab = GetTab_Impl();
7002 return new ScCellCursorObj( pDocSh, ScRange( 0,0,nTab, MAXCOL,MAXROW,nTab ) );
7004 return NULL;
7007 uno::Reference<sheet::XSheetCellCursor> SAL_CALL ScTableSheetObj::createCursorByRange(
7008 const uno::Reference<sheet::XSheetCellRange>& xCellRange )
7009 throw(uno::RuntimeException, std::exception)
7011 SolarMutexGuard aGuard;
7012 ScDocShell* pDocSh = GetDocShell();
7013 if ( pDocSh && xCellRange.is() )
7015 ScCellRangesBase* pRangesImp = ScCellRangesBase::getImplementation( xCellRange );
7016 if (pRangesImp)
7018 const ScRangeList& rRanges = pRangesImp->GetRangeList();
7019 OSL_ENSURE( rRanges.size() == 1, "Range? Ranges?" );
7020 return new ScCellCursorObj( pDocSh, *rRanges[ 0 ] );
7023 return NULL;
7026 // XSheetCellRange
7028 uno::Reference<sheet::XSpreadsheet> SAL_CALL ScTableSheetObj::getSpreadsheet()
7029 throw(uno::RuntimeException, std::exception)
7031 SolarMutexGuard aGuard;
7032 return this; //!???
7035 // XCellRange
7037 uno::Reference<table::XCell> SAL_CALL ScTableSheetObj::getCellByPosition(
7038 sal_Int32 nColumn, sal_Int32 nRow )
7039 throw(lang::IndexOutOfBoundsException, uno::RuntimeException, std::exception)
7041 SolarMutexGuard aGuard;
7042 return ScCellRangeObj::GetCellByPosition_Impl(nColumn, nRow);
7045 uno::Reference<table::XCellRange> SAL_CALL ScTableSheetObj::getCellRangeByPosition(
7046 sal_Int32 nLeft, sal_Int32 nTop, sal_Int32 nRight, sal_Int32 nBottom )
7047 throw(lang::IndexOutOfBoundsException, uno::RuntimeException, std::exception)
7049 SolarMutexGuard aGuard;
7050 return ScCellRangeObj::getCellRangeByPosition(nLeft,nTop,nRight,nBottom);
7053 uno::Sequence<sheet::TablePageBreakData> SAL_CALL ScTableSheetObj::getColumnPageBreaks()
7054 throw(uno::RuntimeException, std::exception)
7056 SolarMutexGuard aGuard;
7057 ScDocShell* pDocSh = GetDocShell();
7058 if ( pDocSh )
7060 ScDocument& rDoc = pDocSh->GetDocument();
7061 SCTAB nTab = GetTab_Impl();
7063 Size aSize(rDoc.GetPageSize( nTab ));
7064 if (aSize.Width() && aSize.Height()) // effektive Groesse schon gesetzt?
7065 rDoc.UpdatePageBreaks( nTab );
7066 else
7068 // Umbrueche updaten wie in ScDocShell::PageStyleModified:
7069 ScPrintFunc aPrintFunc( pDocSh, pDocSh->GetPrinter(), nTab );
7070 aPrintFunc.UpdatePages();
7073 SCCOL nCount = 0;
7074 SCCOL nCol;
7075 for (nCol=0; nCol<=MAXCOL; nCol++)
7076 if (rDoc.HasColBreak(nCol, nTab))
7077 ++nCount;
7079 sheet::TablePageBreakData aData;
7080 uno::Sequence<sheet::TablePageBreakData> aSeq(nCount);
7081 sheet::TablePageBreakData* pAry = aSeq.getArray();
7082 sal_uInt16 nPos = 0;
7083 for (nCol=0; nCol<=MAXCOL; nCol++)
7085 ScBreakType nBreak = rDoc.HasColBreak(nCol, nTab);
7086 if (nBreak)
7088 aData.Position = nCol;
7089 aData.ManualBreak = (nBreak & BREAK_MANUAL);
7090 pAry[nPos] = aData;
7091 ++nPos;
7094 return aSeq;
7096 return uno::Sequence<sheet::TablePageBreakData>(0);
7099 uno::Sequence<sheet::TablePageBreakData> SAL_CALL ScTableSheetObj::getRowPageBreaks()
7100 throw(uno::RuntimeException, std::exception)
7102 SolarMutexGuard aGuard;
7103 ScDocShell* pDocSh = GetDocShell();
7104 if ( pDocSh )
7106 ScDocument& rDoc = pDocSh->GetDocument();
7107 SCTAB nTab = GetTab_Impl();
7109 Size aSize(rDoc.GetPageSize( nTab ));
7110 if (aSize.Width() && aSize.Height()) // effektive Groesse schon gesetzt?
7111 rDoc.UpdatePageBreaks( nTab );
7112 else
7114 // Umbrueche updaten wie in ScDocShell::PageStyleModified:
7115 ScPrintFunc aPrintFunc( pDocSh, pDocSh->GetPrinter(), nTab );
7116 aPrintFunc.UpdatePages();
7118 return rDoc.GetRowBreakData(nTab);
7120 return uno::Sequence<sheet::TablePageBreakData>(0);
7123 void SAL_CALL ScTableSheetObj::removeAllManualPageBreaks() throw(uno::RuntimeException, std::exception)
7125 SolarMutexGuard aGuard;
7126 ScDocShell* pDocSh = GetDocShell();
7127 if ( pDocSh )
7129 //! docfunc Funktion, auch fuer ScViewFunc::RemoveManualBreaks
7131 ScDocument& rDoc = pDocSh->GetDocument();
7132 bool bUndo (rDoc.IsUndoEnabled());
7133 SCTAB nTab = GetTab_Impl();
7135 if (bUndo)
7137 ScDocument* pUndoDoc = new ScDocument( SCDOCMODE_UNDO );
7138 pUndoDoc->InitUndo( &rDoc, nTab, nTab, true, true );
7139 rDoc.CopyToDocument( 0,0,nTab, MAXCOL,MAXROW,nTab, IDF_NONE, false, pUndoDoc );
7140 pDocSh->GetUndoManager()->AddUndoAction(
7141 new ScUndoRemoveBreaks( pDocSh, nTab, pUndoDoc ) );
7144 rDoc.RemoveManualBreaks(nTab);
7145 rDoc.UpdatePageBreaks(nTab);
7147 //? UpdatePageBreakData( sal_True );
7148 pDocSh->SetDocumentModified();
7149 pDocSh->PostPaint(ScRange(0, 0, nTab, MAXCOL, MAXROW, nTab), PAINT_GRID);
7153 // XNamed
7155 OUString SAL_CALL ScTableSheetObj::getName() throw(uno::RuntimeException, std::exception)
7157 SolarMutexGuard aGuard;
7158 OUString aName;
7159 ScDocShell* pDocSh = GetDocShell();
7160 if ( pDocSh )
7161 pDocSh->GetDocument().GetName( GetTab_Impl(), aName );
7162 return aName;
7165 void SAL_CALL ScTableSheetObj::setName( const OUString& aNewName )
7166 throw(uno::RuntimeException, std::exception)
7168 SolarMutexGuard aGuard;
7169 ScDocShell* pDocSh = GetDocShell();
7170 if ( pDocSh )
7172 OUString aString(aNewName);
7173 pDocSh->GetDocFunc().RenameTable( GetTab_Impl(), aString, true, true );
7177 // XDrawPageSupplier
7179 uno::Reference<drawing::XDrawPage> SAL_CALL ScTableSheetObj::getDrawPage()
7180 throw(uno::RuntimeException, std::exception)
7182 SolarMutexGuard aGuard;
7183 ScDocShell* pDocSh = GetDocShell();
7184 if ( pDocSh )
7186 ScDrawLayer* pDrawLayer = pDocSh->MakeDrawLayer();
7187 OSL_ENSURE(pDrawLayer,"kann Draw-Layer nicht anlegen");
7189 SCTAB nTab = GetTab_Impl();
7190 SdrPage* pPage = pDrawLayer->GetPage(static_cast<sal_uInt16>(nTab));
7191 OSL_ENSURE(pPage,"Draw-Page nicht gefunden");
7192 if (pPage)
7193 return uno::Reference<drawing::XDrawPage> (pPage->getUnoPage(), uno::UNO_QUERY);
7195 // Das DrawPage-Objekt meldet sich als Listener am SdrModel an
7196 // und sollte von dort alle Aktionen mitbekommen
7198 return NULL;
7201 // XCellMovement
7203 void SAL_CALL ScTableSheetObj::insertCells( const table::CellRangeAddress& rRangeAddress,
7204 sheet::CellInsertMode nMode ) throw(uno::RuntimeException, std::exception)
7206 SolarMutexGuard aGuard;
7207 ScDocShell* pDocSh = GetDocShell();
7208 if ( pDocSh )
7210 bool bDo = true;
7211 InsCellCmd eCmd = INS_NONE;
7212 switch (nMode)
7214 case sheet::CellInsertMode_NONE: bDo = false; break;
7215 case sheet::CellInsertMode_DOWN: eCmd = INS_CELLSDOWN; break;
7216 case sheet::CellInsertMode_RIGHT: eCmd = INS_CELLSRIGHT; break;
7217 case sheet::CellInsertMode_ROWS: eCmd = INS_INSROWS; break;
7218 case sheet::CellInsertMode_COLUMNS: eCmd = INS_INSCOLS; break;
7219 default:
7220 OSL_FAIL("insertCells: falscher Mode");
7221 bDo = false;
7224 if (bDo)
7226 OSL_ENSURE( rRangeAddress.Sheet == GetTab_Impl(), "falsche Tabelle in CellRangeAddress" );
7227 ScRange aScRange;
7228 ScUnoConversion::FillScRange( aScRange, rRangeAddress );
7229 pDocSh->GetDocFunc().InsertCells( aScRange, NULL, eCmd, true, true );
7234 void SAL_CALL ScTableSheetObj::removeRange( const table::CellRangeAddress& rRangeAddress,
7235 sheet::CellDeleteMode nMode ) throw(uno::RuntimeException, std::exception)
7237 SolarMutexGuard aGuard;
7238 ScDocShell* pDocSh = GetDocShell();
7239 if ( pDocSh )
7241 bool bDo = true;
7242 DelCellCmd eCmd = DEL_NONE;
7243 switch (nMode)
7245 case sheet::CellDeleteMode_NONE: bDo = false; break;
7246 case sheet::CellDeleteMode_UP: eCmd = DEL_CELLSUP; break;
7247 case sheet::CellDeleteMode_LEFT: eCmd = DEL_CELLSLEFT; break;
7248 case sheet::CellDeleteMode_ROWS: eCmd = DEL_DELROWS; break;
7249 case sheet::CellDeleteMode_COLUMNS: eCmd = DEL_DELCOLS; break;
7250 default:
7251 OSL_FAIL("deleteCells: falscher Mode");
7252 bDo = false;
7255 if (bDo)
7257 OSL_ENSURE( rRangeAddress.Sheet == GetTab_Impl(), "falsche Tabelle in CellRangeAddress" );
7258 ScRange aScRange;
7259 ScUnoConversion::FillScRange( aScRange, rRangeAddress );
7260 pDocSh->GetDocFunc().DeleteCells( aScRange, NULL, eCmd, true, true );
7265 void SAL_CALL ScTableSheetObj::moveRange( const table::CellAddress& aDestination,
7266 const table::CellRangeAddress& aSource )
7267 throw(uno::RuntimeException, std::exception)
7269 SolarMutexGuard aGuard;
7270 ScDocShell* pDocSh = GetDocShell();
7271 if ( pDocSh )
7273 OSL_ENSURE( aSource.Sheet == GetTab_Impl(), "falsche Tabelle in CellRangeAddress" );
7274 ScRange aSourceRange;
7275 ScUnoConversion::FillScRange( aSourceRange, aSource );
7276 ScAddress aDestPos( (SCCOL)aDestination.Column, (SCROW)aDestination.Row, aDestination.Sheet );
7277 pDocSh->GetDocFunc().MoveBlock( aSourceRange, aDestPos, true, true, true, true );
7281 void SAL_CALL ScTableSheetObj::copyRange( const table::CellAddress& aDestination,
7282 const table::CellRangeAddress& aSource )
7283 throw(uno::RuntimeException, std::exception)
7285 SolarMutexGuard aGuard;
7286 ScDocShell* pDocSh = GetDocShell();
7287 if ( pDocSh )
7289 OSL_ENSURE( aSource.Sheet == GetTab_Impl(), "falsche Tabelle in CellRangeAddress" );
7290 ScRange aSourceRange;
7291 ScUnoConversion::FillScRange( aSourceRange, aSource );
7292 ScAddress aDestPos( (SCCOL)aDestination.Column, (SCROW)aDestination.Row, aDestination.Sheet );
7293 pDocSh->GetDocFunc().MoveBlock( aSourceRange, aDestPos, false, true, true, true );
7297 // XPrintAreas
7299 void ScTableSheetObj::PrintAreaUndo_Impl( ScPrintRangeSaver* pOldRanges )
7301 // Umbrueche und Undo
7302 ScDocShell* pDocSh = GetDocShell();
7304 if(pDocSh)
7306 ScDocument& rDoc = pDocSh->GetDocument();
7307 const bool bUndo(rDoc.IsUndoEnabled());
7308 const SCTAB nTab(GetTab_Impl());
7310 if(bUndo)
7312 pDocSh->GetUndoManager()->AddUndoAction(
7313 new ScUndoPrintRange(
7314 pDocSh,
7315 nTab,
7316 pOldRanges,
7317 rDoc.CreatePrintRangeSaver())); // create new ranges
7319 // #i120105# ownership of old ranges has changed, mark as consumed
7320 pOldRanges = 0;
7323 ScPrintFunc(pDocSh, pDocSh->GetPrinter(), nTab).UpdatePages();
7324 SfxBindings* pBindings = pDocSh->GetViewBindings();
7326 if(pBindings)
7328 pBindings->Invalidate(SID_DELETE_PRINTAREA);
7331 pDocSh->SetDocumentModified();
7334 // #i120105# pOldRanges not used, need to cleanup
7335 delete pOldRanges;
7338 uno::Sequence<table::CellRangeAddress> SAL_CALL ScTableSheetObj::getPrintAreas()
7339 throw(uno::RuntimeException, std::exception)
7341 SolarMutexGuard aGuard;
7342 ScDocShell* pDocSh = GetDocShell();
7343 if ( pDocSh )
7345 ScDocument& rDoc = pDocSh->GetDocument();
7346 SCTAB nTab = GetTab_Impl();
7347 sal_uInt16 nCount = rDoc.GetPrintRangeCount( nTab );
7349 table::CellRangeAddress aRangeAddress;
7350 uno::Sequence<table::CellRangeAddress> aSeq(nCount);
7351 table::CellRangeAddress* pAry = aSeq.getArray();
7352 for (sal_uInt16 i=0; i<nCount; i++)
7354 const ScRange* pRange = rDoc.GetPrintRange( nTab, i );
7355 OSL_ENSURE(pRange,"wo ist der Druckbereich");
7356 if (pRange)
7358 ScUnoConversion::FillApiRange( aRangeAddress, *pRange );
7359 aRangeAddress.Sheet = nTab; // core does not care about sheet index
7360 pAry[i] = aRangeAddress;
7363 return aSeq;
7365 return uno::Sequence<table::CellRangeAddress>();
7368 void SAL_CALL ScTableSheetObj::setPrintAreas(
7369 const uno::Sequence<table::CellRangeAddress>& aPrintAreas )
7370 throw(uno::RuntimeException, std::exception)
7372 SolarMutexGuard aGuard;
7373 ScDocShell* pDocSh = GetDocShell();
7374 if ( pDocSh )
7376 ScPrintRangeSaver* pOldRanges = NULL;
7377 ScDocument& rDoc = pDocSh->GetDocument();
7378 SCTAB nTab = GetTab_Impl();
7380 if ( rDoc.IsUndoEnabled() )
7381 pOldRanges = rDoc.CreatePrintRangeSaver();
7383 sal_uInt16 nCount = (sal_uInt16) aPrintAreas.getLength();
7384 rDoc.ClearPrintRanges( nTab );
7385 if (nCount)
7387 ScRange aPrintRange;
7388 const table::CellRangeAddress* pAry = aPrintAreas.getConstArray();
7389 for (sal_uInt16 i=0; i<nCount; i++)
7391 ScUnoConversion::FillScRange( aPrintRange, pAry[i] );
7392 rDoc.AddPrintRange( nTab, aPrintRange );
7396 if ( rDoc.IsUndoEnabled() )
7397 PrintAreaUndo_Impl( pOldRanges ); // Undo, Umbrueche, Modified etc.
7401 sal_Bool SAL_CALL ScTableSheetObj::getPrintTitleColumns() throw(uno::RuntimeException, std::exception)
7403 SolarMutexGuard aGuard;
7404 ScDocShell* pDocSh = GetDocShell();
7405 if ( pDocSh )
7407 ScDocument& rDoc = pDocSh->GetDocument();
7408 SCTAB nTab = GetTab_Impl();
7409 return ( rDoc.GetRepeatColRange(nTab) != NULL );
7411 return false;
7414 void SAL_CALL ScTableSheetObj::setPrintTitleColumns( sal_Bool bPrintTitleColumns )
7415 throw(uno::RuntimeException, std::exception)
7417 SolarMutexGuard aGuard;
7418 ScDocShell* pDocSh = GetDocShell();
7419 if ( pDocSh )
7421 ScDocument& rDoc = pDocSh->GetDocument();
7422 SCTAB nTab = GetTab_Impl();
7424 ScPrintRangeSaver* pOldRanges = rDoc.CreatePrintRangeSaver();
7426 if ( bPrintTitleColumns )
7428 if ( !rDoc.GetRepeatColRange( nTab ) ) // keinen bestehenden Bereich veraendern
7430 ScRange aNew( 0, 0, nTab, 0, 0, nTab ); // Default
7431 rDoc.SetRepeatColRange( nTab, &aNew ); // einschalten
7434 else
7435 rDoc.SetRepeatColRange( nTab, NULL ); // abschalten
7437 PrintAreaUndo_Impl( pOldRanges ); // Undo, Umbrueche, Modified etc.
7439 //! zuletzt gesetzten Bereich beim Abschalten merken und beim Einschalten wiederherstellen ???
7443 table::CellRangeAddress SAL_CALL ScTableSheetObj::getTitleColumns() throw(uno::RuntimeException, std::exception)
7445 SolarMutexGuard aGuard;
7446 table::CellRangeAddress aRet;
7447 ScDocShell* pDocSh = GetDocShell();
7448 if ( pDocSh )
7450 ScDocument& rDoc = pDocSh->GetDocument();
7451 SCTAB nTab = GetTab_Impl();
7452 const ScRange* pRange = rDoc.GetRepeatColRange(nTab);
7453 if (pRange)
7455 ScUnoConversion::FillApiRange( aRet, *pRange );
7456 aRet.Sheet = nTab; // core does not care about sheet index
7459 return aRet;
7462 void SAL_CALL ScTableSheetObj::setTitleColumns( const table::CellRangeAddress& aTitleColumns )
7463 throw(uno::RuntimeException, std::exception)
7465 SolarMutexGuard aGuard;
7466 ScDocShell* pDocSh = GetDocShell();
7467 if ( pDocSh )
7469 ScDocument& rDoc = pDocSh->GetDocument();
7470 SCTAB nTab = GetTab_Impl();
7472 ScPrintRangeSaver* pOldRanges = rDoc.CreatePrintRangeSaver();
7474 ScRange aNew;
7475 ScUnoConversion::FillScRange( aNew, aTitleColumns );
7476 rDoc.SetRepeatColRange( nTab, &aNew ); // immer auch einschalten
7478 PrintAreaUndo_Impl( pOldRanges ); // Undo, Umbrueche, Modified etc.
7482 sal_Bool SAL_CALL ScTableSheetObj::getPrintTitleRows() throw(uno::RuntimeException, std::exception)
7484 SolarMutexGuard aGuard;
7485 ScDocShell* pDocSh = GetDocShell();
7486 if ( pDocSh )
7488 ScDocument& rDoc = pDocSh->GetDocument();
7489 SCTAB nTab = GetTab_Impl();
7490 return ( rDoc.GetRepeatRowRange(nTab) != NULL );
7492 return false;
7495 void SAL_CALL ScTableSheetObj::setPrintTitleRows( sal_Bool bPrintTitleRows )
7496 throw(uno::RuntimeException, std::exception)
7498 SolarMutexGuard aGuard;
7499 ScDocShell* pDocSh = GetDocShell();
7500 if ( pDocSh )
7502 ScDocument& rDoc = pDocSh->GetDocument();
7503 SCTAB nTab = GetTab_Impl();
7505 ScPrintRangeSaver* pOldRanges = rDoc.CreatePrintRangeSaver();
7507 if ( bPrintTitleRows )
7509 if ( !rDoc.GetRepeatRowRange( nTab ) ) // keinen bestehenden Bereich veraendern
7511 ScRange aNew( 0, 0, nTab, 0, 0, nTab ); // Default
7512 rDoc.SetRepeatRowRange( nTab, &aNew ); // einschalten
7515 else
7516 rDoc.SetRepeatRowRange( nTab, NULL ); // abschalten
7518 PrintAreaUndo_Impl( pOldRanges ); // Undo, Umbrueche, Modified etc.
7520 //! zuletzt gesetzten Bereich beim Abschalten merken und beim Einschalten wiederherstellen ???
7524 table::CellRangeAddress SAL_CALL ScTableSheetObj::getTitleRows() throw(uno::RuntimeException, std::exception)
7526 SolarMutexGuard aGuard;
7527 table::CellRangeAddress aRet;
7528 ScDocShell* pDocSh = GetDocShell();
7529 if ( pDocSh )
7531 ScDocument& rDoc = pDocSh->GetDocument();
7532 SCTAB nTab = GetTab_Impl();
7533 const ScRange* pRange = rDoc.GetRepeatRowRange(nTab);
7534 if (pRange)
7536 ScUnoConversion::FillApiRange( aRet, *pRange );
7537 aRet.Sheet = nTab; // core does not care about sheet index
7540 return aRet;
7543 void SAL_CALL ScTableSheetObj::setTitleRows( const table::CellRangeAddress& aTitleRows )
7544 throw(uno::RuntimeException, std::exception)
7546 SolarMutexGuard aGuard;
7547 ScDocShell* pDocSh = GetDocShell();
7548 if ( pDocSh )
7550 ScDocument& rDoc = pDocSh->GetDocument();
7551 SCTAB nTab = GetTab_Impl();
7553 ScPrintRangeSaver* pOldRanges = rDoc.CreatePrintRangeSaver();
7555 ScRange aNew;
7556 ScUnoConversion::FillScRange( aNew, aTitleRows );
7557 rDoc.SetRepeatRowRange( nTab, &aNew ); // immer auch einschalten
7559 PrintAreaUndo_Impl( pOldRanges ); // Undo, Umbrueche, Modified etc.
7563 // XSheetLinkable
7565 sheet::SheetLinkMode SAL_CALL ScTableSheetObj::getLinkMode() throw(uno::RuntimeException, std::exception)
7567 SolarMutexGuard aGuard;
7568 sheet::SheetLinkMode eRet = sheet::SheetLinkMode_NONE;
7569 ScDocShell* pDocSh = GetDocShell();
7570 if ( pDocSh )
7572 sal_uInt8 nMode = pDocSh->GetDocument().GetLinkMode( GetTab_Impl() );
7573 if ( nMode == SC_LINK_NORMAL )
7574 eRet = sheet::SheetLinkMode_NORMAL;
7575 else if ( nMode == SC_LINK_VALUE )
7576 eRet = sheet::SheetLinkMode_VALUE;
7578 return eRet;
7581 void SAL_CALL ScTableSheetObj::setLinkMode( sheet::SheetLinkMode nLinkMode )
7582 throw(uno::RuntimeException, std::exception)
7584 SolarMutexGuard aGuard;
7586 //! Filter und Options aus altem Link suchen
7588 OUString aUrl(getLinkUrl());
7589 OUString aSheet(getLinkSheetName());
7591 OUString aEmpty;
7592 link( aUrl, aSheet, aEmpty, aEmpty, nLinkMode );
7595 OUString SAL_CALL ScTableSheetObj::getLinkUrl() throw(uno::RuntimeException, std::exception)
7597 SolarMutexGuard aGuard;
7598 OUString aFile;
7599 ScDocShell* pDocSh = GetDocShell();
7600 if ( pDocSh )
7601 aFile = pDocSh->GetDocument().GetLinkDoc( GetTab_Impl() );
7602 return aFile;
7605 void SAL_CALL ScTableSheetObj::setLinkUrl( const OUString& aLinkUrl )
7606 throw(uno::RuntimeException, std::exception)
7608 SolarMutexGuard aGuard;
7610 //! Filter und Options aus altem Link suchen
7612 sheet::SheetLinkMode eMode = getLinkMode();
7613 OUString aSheet(getLinkSheetName());
7615 OUString aEmpty;
7616 link( aLinkUrl, aSheet, aEmpty, aEmpty, eMode );
7619 OUString SAL_CALL ScTableSheetObj::getLinkSheetName() throw(uno::RuntimeException, std::exception)
7621 SolarMutexGuard aGuard;
7622 OUString aSheet;
7623 ScDocShell* pDocSh = GetDocShell();
7624 if ( pDocSh )
7625 aSheet = pDocSh->GetDocument().GetLinkTab( GetTab_Impl() );
7626 return aSheet;
7629 void SAL_CALL ScTableSheetObj::setLinkSheetName( const OUString& aLinkSheetName )
7630 throw(uno::RuntimeException, std::exception)
7632 SolarMutexGuard aGuard;
7634 //! Filter und Options aus altem Link suchen
7636 sheet::SheetLinkMode eMode = getLinkMode();
7637 OUString aUrl(getLinkUrl());
7639 OUString aEmpty;
7640 link( aUrl, aLinkSheetName, aEmpty, aEmpty, eMode );
7643 void SAL_CALL ScTableSheetObj::link( const OUString& aUrl, const OUString& aSheetName,
7644 const OUString& aFilterName, const OUString& aFilterOptions,
7645 sheet::SheetLinkMode nMode ) throw(uno::RuntimeException, std::exception)
7647 SolarMutexGuard aGuard;
7648 ScDocShell* pDocSh = GetDocShell();
7649 if ( pDocSh )
7651 ScDocument& rDoc = pDocSh->GetDocument();
7652 SCTAB nTab = GetTab_Impl();
7654 OUString aFileString = aUrl;
7655 OUString aFilterString = aFilterName;
7656 OUString aOptString = aFilterOptions;
7657 OUString aSheetString = aSheetName;
7659 aFileString = ScGlobal::GetAbsDocName( aFileString, pDocSh );
7660 if (aFilterString.isEmpty())
7661 ScDocumentLoader::GetFilterName( aFileString, aFilterString, aOptString, true, false );
7663 // remove application prefix from filter name here, so the filter options
7664 // aren't reset when the filter name is changed in ScTableLink::DataChanged
7665 ScDocumentLoader::RemoveAppPrefix( aFilterString );
7667 sal_uInt8 nLinkMode = SC_LINK_NONE;
7668 if ( nMode == sheet::SheetLinkMode_NORMAL )
7669 nLinkMode = SC_LINK_NORMAL;
7670 else if ( nMode == sheet::SheetLinkMode_VALUE )
7671 nLinkMode = SC_LINK_VALUE;
7673 sal_uLong nRefresh = 0;
7674 rDoc.SetLink( nTab, nLinkMode, aFileString, aFilterString, aOptString, aSheetString, nRefresh );
7676 pDocSh->UpdateLinks(); // ggf. Link eintragen oder loeschen
7677 SfxBindings* pBindings = pDocSh->GetViewBindings();
7678 if (pBindings)
7679 pBindings->Invalidate(SID_LINKS);
7681 //! Undo fuer Link-Daten an der Table
7683 if ( nLinkMode != SC_LINK_NONE && rDoc.IsExecuteLinkEnabled() ) // Link updaten
7685 // Update immer, auch wenn der Link schon da war
7686 //! Update nur fuer die betroffene Tabelle???
7688 sfx2::LinkManager* pLinkManager = rDoc.GetLinkManager();
7689 sal_uInt16 nCount = pLinkManager->GetLinks().size();
7690 for ( sal_uInt16 i=0; i<nCount; i++ )
7692 ::sfx2::SvBaseLink* pBase = *pLinkManager->GetLinks()[i];
7693 if (pBase->ISA(ScTableLink))
7695 ScTableLink* pTabLink = static_cast<ScTableLink*>(pBase);
7696 if ( aFileString.equals(pTabLink->GetFileName()) )
7697 pTabLink->Update(); // inkl. Paint&Undo
7699 //! Der Dateiname sollte nur einmal vorkommen (?)
7704 //! Notify fuer ScSheetLinkObj Objekte!!!
7708 // XSheetAuditing
7710 sal_Bool SAL_CALL ScTableSheetObj::hideDependents( const table::CellAddress& aPosition )
7711 throw(uno::RuntimeException, std::exception)
7713 SolarMutexGuard aGuard;
7714 ScDocShell* pDocSh = GetDocShell();
7715 if ( pDocSh )
7717 SCTAB nTab = GetTab_Impl();
7718 OSL_ENSURE( aPosition.Sheet == nTab, "falsche Tabelle in CellAddress" );
7719 ScAddress aPos( (SCCOL)aPosition.Column, (SCROW)aPosition.Row, nTab );
7720 return pDocSh->GetDocFunc().DetectiveDelSucc( aPos );
7722 return false;
7725 sal_Bool SAL_CALL ScTableSheetObj::hidePrecedents( const table::CellAddress& aPosition )
7726 throw(uno::RuntimeException, std::exception)
7728 SolarMutexGuard aGuard;
7729 ScDocShell* pDocSh = GetDocShell();
7730 if ( pDocSh )
7732 SCTAB nTab = GetTab_Impl();
7733 OSL_ENSURE( aPosition.Sheet == nTab, "falsche Tabelle in CellAddress" );
7734 ScAddress aPos( (SCCOL)aPosition.Column, (SCROW)aPosition.Row, nTab );
7735 return pDocSh->GetDocFunc().DetectiveDelPred( aPos );
7737 return false;
7740 sal_Bool SAL_CALL ScTableSheetObj::showDependents( const table::CellAddress& aPosition )
7741 throw(uno::RuntimeException, std::exception)
7743 SolarMutexGuard aGuard;
7744 ScDocShell* pDocSh = GetDocShell();
7745 if ( pDocSh )
7747 SCTAB nTab = GetTab_Impl();
7748 OSL_ENSURE( aPosition.Sheet == nTab, "falsche Tabelle in CellAddress" );
7749 ScAddress aPos( (SCCOL)aPosition.Column, (SCROW)aPosition.Row, nTab );
7750 return pDocSh->GetDocFunc().DetectiveAddSucc( aPos );
7752 return false;
7755 sal_Bool SAL_CALL ScTableSheetObj::showPrecedents( const table::CellAddress& aPosition )
7756 throw(uno::RuntimeException, std::exception)
7758 SolarMutexGuard aGuard;
7759 ScDocShell* pDocSh = GetDocShell();
7760 if ( pDocSh )
7762 SCTAB nTab = GetTab_Impl();
7763 OSL_ENSURE( aPosition.Sheet == nTab, "falsche Tabelle in CellAddress" );
7764 ScAddress aPos( (SCCOL)aPosition.Column, (SCROW)aPosition.Row, nTab );
7765 return pDocSh->GetDocFunc().DetectiveAddPred( aPos );
7767 return false;
7770 sal_Bool SAL_CALL ScTableSheetObj::showErrors( const table::CellAddress& aPosition )
7771 throw(uno::RuntimeException, std::exception)
7773 SolarMutexGuard aGuard;
7774 ScDocShell* pDocSh = GetDocShell();
7775 if ( pDocSh )
7777 SCTAB nTab = GetTab_Impl();
7778 OSL_ENSURE( aPosition.Sheet == nTab, "falsche Tabelle in CellAddress" );
7779 ScAddress aPos( (SCCOL)aPosition.Column, (SCROW)aPosition.Row, nTab );
7780 return pDocSh->GetDocFunc().DetectiveAddError( aPos );
7782 return false;
7785 sal_Bool SAL_CALL ScTableSheetObj::showInvalid() throw(uno::RuntimeException, std::exception)
7787 SolarMutexGuard aGuard;
7788 ScDocShell* pDocSh = GetDocShell();
7789 if ( pDocSh )
7790 return pDocSh->GetDocFunc().DetectiveMarkInvalid( GetTab_Impl() );
7791 return false;
7794 void SAL_CALL ScTableSheetObj::clearArrows() throw(uno::RuntimeException, std::exception)
7796 SolarMutexGuard aGuard;
7797 ScDocShell* pDocSh = GetDocShell();
7798 if ( pDocSh )
7799 pDocSh->GetDocFunc().DetectiveDelAll( GetTab_Impl() );
7802 // XSheetOutline
7804 void SAL_CALL ScTableSheetObj::group( const table::CellRangeAddress& rGroupRange,
7805 table::TableOrientation nOrientation )
7806 throw (uno::RuntimeException,
7807 std::exception)
7809 SolarMutexGuard aGuard;
7810 ScDocShell* pDocSh = GetDocShell();
7811 if ( pDocSh )
7813 bool bColumns = ( nOrientation == table::TableOrientation_COLUMNS );
7814 ScRange aGroupRange;
7815 ScUnoConversion::FillScRange( aGroupRange, rGroupRange );
7816 ScOutlineDocFunc aFunc(*pDocSh);
7817 aFunc.MakeOutline( aGroupRange, bColumns, true, true );
7821 void SAL_CALL ScTableSheetObj::ungroup( const table::CellRangeAddress& rGroupRange,
7822 table::TableOrientation nOrientation )
7823 throw (uno::RuntimeException,
7824 std::exception)
7826 SolarMutexGuard aGuard;
7827 ScDocShell* pDocSh = GetDocShell();
7828 if ( pDocSh )
7830 bool bColumns = ( nOrientation == table::TableOrientation_COLUMNS );
7831 ScRange aGroupRange;
7832 ScUnoConversion::FillScRange( aGroupRange, rGroupRange );
7833 ScOutlineDocFunc aFunc(*pDocSh);
7834 aFunc.RemoveOutline( aGroupRange, bColumns, true, true );
7838 void SAL_CALL ScTableSheetObj::autoOutline( const table::CellRangeAddress& rCellRange )
7839 throw(uno::RuntimeException, std::exception)
7841 SolarMutexGuard aGuard;
7842 ScDocShell* pDocSh = GetDocShell();
7843 if ( pDocSh )
7845 ScRange aFormulaRange;
7846 ScUnoConversion::FillScRange( aFormulaRange, rCellRange );
7847 ScOutlineDocFunc aFunc(*pDocSh);
7848 aFunc.AutoOutline( aFormulaRange, true );
7852 void SAL_CALL ScTableSheetObj::clearOutline()
7853 throw(uno::RuntimeException, std::exception)
7855 SolarMutexGuard aGuard;
7856 ScDocShell* pDocSh = GetDocShell();
7857 if ( pDocSh )
7859 SCTAB nTab = GetTab_Impl();
7860 ScOutlineDocFunc aFunc(*pDocSh);
7861 aFunc.RemoveAllOutlines( nTab, true );
7865 void SAL_CALL ScTableSheetObj::hideDetail( const table::CellRangeAddress& rCellRange )
7866 throw(uno::RuntimeException, std::exception)
7868 SolarMutexGuard aGuard;
7869 ScDocShell* pDocSh = GetDocShell();
7870 if ( pDocSh )
7872 ScRange aMarkRange;
7873 ScUnoConversion::FillScRange( aMarkRange, rCellRange );
7874 ScOutlineDocFunc aFunc(*pDocSh);
7875 aFunc.HideMarkedOutlines( aMarkRange, true );
7879 void SAL_CALL ScTableSheetObj::showDetail( const table::CellRangeAddress& rCellRange )
7880 throw(uno::RuntimeException, std::exception)
7882 SolarMutexGuard aGuard;
7883 ScDocShell* pDocSh = GetDocShell();
7884 if ( pDocSh )
7886 ScRange aMarkRange;
7887 ScUnoConversion::FillScRange( aMarkRange, rCellRange );
7888 ScOutlineDocFunc aFunc(*pDocSh);
7889 aFunc.ShowMarkedOutlines( aMarkRange, true );
7893 void SAL_CALL ScTableSheetObj::showLevel( sal_Int16 nLevel, table::TableOrientation nOrientation )
7894 throw(uno::RuntimeException, std::exception)
7896 SolarMutexGuard aGuard;
7897 ScDocShell* pDocSh = GetDocShell();
7898 if ( pDocSh )
7900 bool bColumns = ( nOrientation == table::TableOrientation_COLUMNS );
7901 SCTAB nTab = GetTab_Impl();
7902 ScOutlineDocFunc aFunc(*pDocSh);
7903 aFunc.SelectLevel( nTab, bColumns, nLevel, true, true );
7907 // XProtectable
7909 void SAL_CALL ScTableSheetObj::protect( const OUString& aPassword )
7910 throw(uno::RuntimeException, std::exception)
7912 SolarMutexGuard aGuard;
7913 ScDocShell* pDocSh = GetDocShell();
7914 // #i108245# if already protected, don't change anything
7915 if ( pDocSh && !pDocSh->GetDocument().IsTabProtected( GetTab_Impl() ) )
7917 OUString aString(aPassword);
7918 pDocSh->GetDocFunc().Protect( GetTab_Impl(), aString, true );
7922 void SAL_CALL ScTableSheetObj::unprotect( const OUString& aPassword )
7923 throw(lang::IllegalArgumentException, uno::RuntimeException, std::exception)
7925 SolarMutexGuard aGuard;
7926 ScDocShell* pDocSh = GetDocShell();
7927 if ( pDocSh )
7929 OUString aString(aPassword);
7930 bool bDone = pDocSh->GetDocFunc().Unprotect( GetTab_Impl(), aString, true );
7931 if (!bDone)
7932 throw lang::IllegalArgumentException();
7936 sal_Bool SAL_CALL ScTableSheetObj::isProtected() throw(uno::RuntimeException, std::exception)
7938 SolarMutexGuard aGuard;
7939 ScDocShell* pDocSh = GetDocShell();
7940 if ( pDocSh )
7941 return pDocSh->GetDocument().IsTabProtected( GetTab_Impl() );
7943 OSL_FAIL("keine DocShell"); //! Exception oder so?
7944 return false;
7947 // XScenario
7949 sal_Bool SAL_CALL ScTableSheetObj::getIsScenario() throw(uno::RuntimeException, std::exception)
7951 SolarMutexGuard aGuard;
7952 ScDocShell* pDocSh = GetDocShell();
7953 if ( pDocSh )
7954 return pDocSh->GetDocument().IsScenario( GetTab_Impl() );
7956 return false;
7959 OUString SAL_CALL ScTableSheetObj::getScenarioComment() throw(uno::RuntimeException, std::exception)
7961 SolarMutexGuard aGuard;
7962 ScDocShell* pDocSh = GetDocShell();
7963 if ( pDocSh )
7965 OUString aComment;
7966 Color aColor;
7967 sal_uInt16 nFlags;
7968 pDocSh->GetDocument().GetScenarioData( GetTab_Impl(), aComment, aColor, nFlags );
7969 return aComment;
7971 return OUString();
7974 void SAL_CALL ScTableSheetObj::setScenarioComment( const OUString& aScenarioComment )
7975 throw(uno::RuntimeException, std::exception)
7977 SolarMutexGuard aGuard;
7978 ScDocShell* pDocSh = GetDocShell();
7979 if ( pDocSh )
7981 ScDocument& rDoc = pDocSh->GetDocument();
7982 SCTAB nTab = GetTab_Impl();
7984 OUString aName;
7985 OUString aComment;
7986 Color aColor;
7987 sal_uInt16 nFlags;
7988 rDoc.GetName( nTab, aName );
7989 rDoc.GetScenarioData( nTab, aComment, aColor, nFlags );
7991 aComment = aScenarioComment;
7993 pDocSh->ModifyScenario( nTab, aName, aComment, aColor, nFlags );
7997 void SAL_CALL ScTableSheetObj::addRanges( const uno::Sequence<table::CellRangeAddress>& rScenRanges )
7998 throw(uno::RuntimeException, std::exception)
8000 SolarMutexGuard aGuard;
8001 ScDocShell* pDocSh = GetDocShell();
8002 if ( pDocSh )
8004 ScDocument& rDoc = pDocSh->GetDocument();
8005 SCTAB nTab = GetTab_Impl();
8007 if (rDoc.IsScenario(nTab))
8009 ScMarkData aMarkData;
8010 aMarkData.SelectTable( nTab, true );
8012 sal_uInt16 nRangeCount = (sal_uInt16)rScenRanges.getLength();
8013 if (nRangeCount)
8015 const table::CellRangeAddress* pAry = rScenRanges.getConstArray();
8016 for (sal_uInt16 i=0; i<nRangeCount; i++)
8018 OSL_ENSURE( pAry[i].Sheet == nTab, "addRanges mit falscher Tab" );
8019 ScRange aOneRange( (SCCOL)pAry[i].StartColumn, (SCROW)pAry[i].StartRow, nTab,
8020 (SCCOL)pAry[i].EndColumn, (SCROW)pAry[i].EndRow, nTab );
8022 aMarkData.SetMultiMarkArea( aOneRange );
8026 // Szenario-Ranges sind durch Attribut gekennzeichnet
8027 ScPatternAttr aPattern( rDoc.GetPool() );
8028 aPattern.GetItemSet().Put( ScMergeFlagAttr( SC_MF_SCENARIO ) );
8029 aPattern.GetItemSet().Put( ScProtectionAttr( true ) );
8030 pDocSh->GetDocFunc().ApplyAttributes( aMarkData, aPattern, true, true );
8035 void SAL_CALL ScTableSheetObj::apply() throw(uno::RuntimeException, std::exception)
8037 SolarMutexGuard aGuard;
8038 ScDocShell* pDocSh = GetDocShell();
8039 if ( pDocSh )
8041 ScDocument& rDoc = pDocSh->GetDocument();
8042 SCTAB nTab = GetTab_Impl();
8043 OUString aName;
8044 rDoc.GetName( nTab, aName ); // Name dieses Szenarios
8046 SCTAB nDestTab = nTab;
8047 while ( nDestTab > 0 && rDoc.IsScenario(nDestTab) )
8048 --nDestTab;
8050 if ( !rDoc.IsScenario(nDestTab) )
8051 pDocSh->UseScenario( nDestTab, aName );
8053 //! sonst Fehler oder so
8057 // XScenarioEnhanced
8059 uno::Sequence< table::CellRangeAddress > SAL_CALL ScTableSheetObj::getRanges( )
8060 throw(uno::RuntimeException, std::exception)
8062 SolarMutexGuard aGuard;
8063 ScDocShell* pDocSh = GetDocShell();
8064 if ( pDocSh )
8066 ScDocument& rDoc = pDocSh->GetDocument();
8067 SCTAB nTab = GetTab_Impl();
8068 const ScRangeList* pRangeList = rDoc.GetScenarioRanges(nTab);
8069 if (pRangeList)
8071 size_t nCount = pRangeList->size();
8072 uno::Sequence< table::CellRangeAddress > aRetRanges( nCount );
8073 table::CellRangeAddress* pAry = aRetRanges.getArray();
8074 for( size_t nIndex = 0; nIndex < nCount; nIndex++ )
8076 const ScRange* pRange = (*pRangeList)[nIndex];
8077 pAry->StartColumn = pRange->aStart.Col();
8078 pAry->StartRow = pRange->aStart.Row();
8079 pAry->EndColumn = pRange->aEnd.Col();
8080 pAry->EndRow = pRange->aEnd.Row();
8081 pAry->Sheet = pRange->aStart.Tab();
8082 ++pAry;
8084 return aRetRanges;
8087 return uno::Sequence< table::CellRangeAddress > ();
8090 // XExternalSheetName
8092 void ScTableSheetObj::setExternalName( const OUString& aUrl, const OUString& aSheetName )
8093 throw (container::ElementExistException, uno::RuntimeException, std::exception)
8095 SolarMutexGuard aGuard;
8096 ScDocShell* pDocSh = GetDocShell();
8097 if ( pDocSh )
8099 ScDocument& rDoc = pDocSh->GetDocument();
8100 const SCTAB nTab = GetTab_Impl();
8101 const OUString aAbsDocName( ScGlobal::GetAbsDocName( aUrl, pDocSh ) );
8102 const OUString aDocTabName( ScGlobal::GetDocTabName( aAbsDocName, aSheetName ) );
8103 if ( !rDoc.RenameTab( nTab, aDocTabName, false /*bUpdateRef*/, true /*bExternalDocument*/ ) )
8105 throw container::ElementExistException( OUString(), *this );
8110 // XEventsSupplier
8112 uno::Reference<container::XNameReplace> SAL_CALL ScTableSheetObj::getEvents() throw (uno::RuntimeException, std::exception)
8114 SolarMutexGuard aGuard;
8115 ScDocShell* pDocSh = GetDocShell();
8116 if ( pDocSh )
8117 return new ScSheetEventsObj( pDocSh, GetTab_Impl() );
8119 return NULL;
8122 // XPropertySet erweitert fuer Sheet-Properties
8124 uno::Reference<beans::XPropertySetInfo> SAL_CALL ScTableSheetObj::getPropertySetInfo()
8125 throw(uno::RuntimeException, std::exception)
8127 SolarMutexGuard aGuard;
8128 static uno::Reference<beans::XPropertySetInfo> aRef(
8129 new SfxItemPropertySetInfo( pSheetPropSet->getPropertyMap() ));
8130 return aRef;
8133 void ScTableSheetObj::SetOnePropertyValue( const SfxItemPropertySimpleEntry* pEntry, const uno::Any& aValue )
8134 throw(lang::IllegalArgumentException, uno::RuntimeException,
8135 std::exception)
8137 if ( pEntry )
8139 if ( IsScItemWid( pEntry->nWID ) )
8141 // for Item WIDs, call ScCellRangesBase directly
8142 ScCellRangesBase::SetOnePropertyValue(pEntry, aValue);
8143 return;
8146 // own properties
8148 ScDocShell* pDocSh = GetDocShell();
8149 if (!pDocSh)
8150 return; //! Exception oder so?
8151 ScDocument& rDoc = pDocSh->GetDocument();
8152 SCTAB nTab = GetTab_Impl();
8153 ScDocFunc &rFunc = pDocSh->GetDocFunc();
8155 if ( pEntry->nWID == SC_WID_UNO_PAGESTL )
8157 OUString aStrVal;
8158 aValue >>= aStrVal;
8159 OUString aNewStr(ScStyleNameConversion::ProgrammaticToDisplayName(
8160 aStrVal, SFX_STYLE_FAMILY_PAGE ));
8162 //! Undo? (auch bei SID_STYLE_APPLY an der View)
8164 if ( rDoc.GetPageStyle( nTab ) != aNewStr )
8166 rDoc.SetPageStyle( nTab, aNewStr );
8167 if (!rDoc.IsImportingXML())
8169 ScPrintFunc( pDocSh, pDocSh->GetPrinter(), nTab ).UpdatePages();
8171 SfxBindings* pBindings = pDocSh->GetViewBindings();
8172 if (pBindings)
8174 pBindings->Invalidate( SID_STYLE_FAMILY4 );
8175 pBindings->Invalidate( SID_STATUS_PAGESTYLE );
8176 pBindings->Invalidate( FID_RESET_PRINTZOOM );
8177 pBindings->Invalidate( SID_ATTR_PARA_LEFT_TO_RIGHT );
8178 pBindings->Invalidate( SID_ATTR_PARA_RIGHT_TO_LEFT );
8181 pDocSh->SetDocumentModified();
8184 else if ( pEntry->nWID == SC_WID_UNO_CELLVIS )
8186 bool bVis = ScUnoHelpFunctions::GetBoolFromAny( aValue );
8187 rFunc.SetTableVisible( nTab, bVis, true );
8189 else if ( pEntry->nWID == SC_WID_UNO_ISACTIVE )
8191 if (rDoc.IsScenario(nTab))
8192 rDoc.SetActiveScenario( nTab, ScUnoHelpFunctions::GetBoolFromAny( aValue ) );
8194 else if ( pEntry->nWID == SC_WID_UNO_BORDCOL )
8196 if (rDoc.IsScenario(nTab))
8198 sal_Int32 nNewColor = 0;
8199 if (aValue >>= nNewColor)
8201 OUString aName;
8202 OUString aComment;
8203 Color aColor;
8204 sal_uInt16 nFlags;
8205 rDoc.GetName( nTab, aName );
8206 rDoc.GetScenarioData( nTab, aComment, aColor, nFlags );
8208 aColor = Color(static_cast<sal_uInt32>(nNewColor));
8210 pDocSh->ModifyScenario( nTab, aName, aComment, aColor, nFlags );
8214 else if ( pEntry->nWID == SC_WID_UNO_PROTECT )
8216 if (rDoc.IsScenario(nTab))
8218 OUString aName;
8219 OUString aComment;
8220 Color aColor;
8221 sal_uInt16 nFlags;
8222 rDoc.GetName( nTab, aName );
8223 rDoc.GetScenarioData( nTab, aComment, aColor, nFlags );
8224 bool bModify(false);
8226 if (ScUnoHelpFunctions::GetBoolFromAny( aValue ))
8228 if (!(nFlags & SC_SCENARIO_PROTECT))
8230 nFlags |= SC_SCENARIO_PROTECT;
8231 bModify = true;
8234 else
8236 if (nFlags & SC_SCENARIO_PROTECT)
8238 nFlags -= SC_SCENARIO_PROTECT;
8239 bModify = true;
8243 if (bModify)
8244 pDocSh->ModifyScenario( nTab, aName, aComment, aColor, nFlags );
8247 else if ( pEntry->nWID == SC_WID_UNO_SHOWBORD )
8249 if (rDoc.IsScenario(nTab))
8251 OUString aName;
8252 OUString aComment;
8253 Color aColor;
8254 sal_uInt16 nFlags;
8255 rDoc.GetName( nTab, aName );
8256 rDoc.GetScenarioData( nTab, aComment, aColor, nFlags );
8257 bool bModify(false);
8259 if (ScUnoHelpFunctions::GetBoolFromAny( aValue ))
8261 if (!(nFlags & SC_SCENARIO_SHOWFRAME))
8263 nFlags |= SC_SCENARIO_SHOWFRAME;
8264 bModify = true;
8267 else
8269 if (nFlags & SC_SCENARIO_SHOWFRAME)
8271 nFlags -= SC_SCENARIO_SHOWFRAME;
8272 bModify = true;
8276 if (bModify)
8277 pDocSh->ModifyScenario( nTab, aName, aComment, aColor, nFlags );
8280 else if ( pEntry->nWID == SC_WID_UNO_PRINTBORD )
8282 if (rDoc.IsScenario(nTab))
8284 OUString aName;
8285 OUString aComment;
8286 Color aColor;
8287 sal_uInt16 nFlags;
8288 rDoc.GetName( nTab, aName );
8289 rDoc.GetScenarioData( nTab, aComment, aColor, nFlags );
8290 bool bModify(false);
8292 if (ScUnoHelpFunctions::GetBoolFromAny( aValue ))
8294 if (!(nFlags & SC_SCENARIO_PRINTFRAME))
8296 nFlags |= SC_SCENARIO_PRINTFRAME;
8297 bModify = true;
8300 else
8302 if (nFlags & SC_SCENARIO_PRINTFRAME)
8304 nFlags -= SC_SCENARIO_PRINTFRAME;
8305 bModify = true;
8309 if (bModify)
8310 pDocSh->ModifyScenario( nTab, aName, aComment, aColor, nFlags );
8313 else if ( pEntry->nWID == SC_WID_UNO_COPYBACK )
8315 if (rDoc.IsScenario(nTab))
8317 OUString aName;
8318 OUString aComment;
8319 Color aColor;
8320 sal_uInt16 nFlags;
8321 rDoc.GetName( nTab, aName );
8322 rDoc.GetScenarioData( nTab, aComment, aColor, nFlags );
8323 bool bModify(false);
8325 if (ScUnoHelpFunctions::GetBoolFromAny( aValue ))
8327 if (!(nFlags & SC_SCENARIO_TWOWAY))
8329 nFlags |= SC_SCENARIO_TWOWAY;
8330 bModify = true;
8333 else
8335 if (nFlags & SC_SCENARIO_TWOWAY)
8337 nFlags -= SC_SCENARIO_TWOWAY;
8338 bModify = true;
8342 if (bModify)
8343 pDocSh->ModifyScenario( nTab, aName, aComment, aColor, nFlags );
8346 else if ( pEntry->nWID == SC_WID_UNO_COPYSTYL )
8348 if (rDoc.IsScenario(nTab))
8350 OUString aName;
8351 OUString aComment;
8352 Color aColor;
8353 sal_uInt16 nFlags;
8354 rDoc.GetName( nTab, aName );
8355 rDoc.GetScenarioData( nTab, aComment, aColor, nFlags );
8356 bool bModify(false);
8358 if (ScUnoHelpFunctions::GetBoolFromAny( aValue ))
8360 if (!(nFlags & SC_SCENARIO_ATTRIB))
8362 nFlags |= SC_SCENARIO_ATTRIB;
8363 bModify = true;
8366 else
8368 if (nFlags & SC_SCENARIO_ATTRIB)
8370 nFlags -= SC_SCENARIO_ATTRIB;
8371 bModify = true;
8375 if (bModify)
8376 pDocSh->ModifyScenario( nTab, aName, aComment, aColor, nFlags );
8379 else if ( pEntry->nWID == SC_WID_UNO_COPYFORM )
8381 if (rDoc.IsScenario(nTab))
8383 OUString aName;
8384 OUString aComment;
8385 Color aColor;
8386 sal_uInt16 nFlags;
8387 rDoc.GetName( nTab, aName );
8388 rDoc.GetScenarioData( nTab, aComment, aColor, nFlags );
8389 bool bModify(false);
8391 if (ScUnoHelpFunctions::GetBoolFromAny( aValue ))
8393 if (nFlags & SC_SCENARIO_VALUE)
8395 nFlags -= SC_SCENARIO_VALUE;
8396 bModify = true;
8399 else
8401 if (!(nFlags & SC_SCENARIO_VALUE))
8403 nFlags |= SC_SCENARIO_VALUE;
8404 bModify = true;
8408 if (bModify)
8409 pDocSh->ModifyScenario( nTab, aName, aComment, aColor, nFlags );
8412 else if ( pEntry->nWID == SC_WID_UNO_TABLAYOUT )
8414 sal_Int16 nValue = 0;
8415 if (aValue >>= nValue)
8417 if (nValue == com::sun::star::text::WritingMode2::RL_TB)
8418 rFunc.SetLayoutRTL(nTab, true, true);
8419 else
8420 rFunc.SetLayoutRTL(nTab, false, true);
8423 else if ( pEntry->nWID == SC_WID_UNO_AUTOPRINT )
8425 bool bAutoPrint = ScUnoHelpFunctions::GetBoolFromAny( aValue );
8426 if (bAutoPrint)
8427 rDoc.SetPrintEntireSheet( nTab ); // clears all print ranges
8428 else
8430 if (rDoc.IsPrintEntireSheet( nTab ))
8431 rDoc.ClearPrintRanges( nTab ); // if this flag is true, there are no PrintRanges, so Clear clears only the flag.
8434 else if ( pEntry->nWID == SC_WID_UNO_TABCOLOR )
8436 sal_Int32 nColor = COL_AUTO;
8437 if ( aValue >>= nColor )
8439 const Color aColor( static_cast< ColorData >( nColor ) );
8440 if ( rDoc.GetTabBgColor( nTab ) != aColor )
8441 rFunc.SetTabBgColor( nTab, aColor, true, true );
8444 else if ( pEntry->nWID == SC_WID_UNO_CODENAME )
8446 OUString aCodeName;
8447 if ( pDocSh && ( aValue >>= aCodeName ) )
8449 pDocSh->GetDocument().SetCodeName( GetTab_Impl(), aCodeName );
8452 else if (pEntry->nWID == SC_WID_UNO_CONDFORMAT)
8454 uno::Reference<sheet::XConditionalFormats> xCondFormat;
8455 if (aValue >>= xCondFormat)
8457 // how to set the format correctly
8460 else
8461 ScCellRangeObj::SetOnePropertyValue(pEntry, aValue); // base class, no Item WID
8465 void ScTableSheetObj::GetOnePropertyValue( const SfxItemPropertySimpleEntry* pEntry,
8466 uno::Any& rAny )
8467 throw(uno::RuntimeException,
8468 std::exception)
8470 if ( pEntry )
8472 ScDocShell* pDocSh = GetDocShell();
8473 if (!pDocSh)
8474 throw uno::RuntimeException();
8475 ScDocument& rDoc = pDocSh->GetDocument();
8476 SCTAB nTab = GetTab_Impl();
8478 if ( pEntry->nWID == SC_WID_UNO_NAMES )
8480 rAny <<= uno::Reference<sheet::XNamedRanges>(new ScLocalNamedRangesObj(pDocSh, this));
8482 else if ( pEntry->nWID == SC_WID_UNO_PAGESTL )
8484 rAny <<= OUString( ScStyleNameConversion::DisplayToProgrammaticName(
8485 rDoc.GetPageStyle( nTab ), SFX_STYLE_FAMILY_PAGE ) );
8487 else if ( pEntry->nWID == SC_WID_UNO_CELLVIS )
8489 bool bVis = rDoc.IsVisible( nTab );
8490 ScUnoHelpFunctions::SetBoolInAny( rAny, bVis );
8492 else if ( pEntry->nWID == SC_WID_UNO_LINKDISPBIT )
8494 // no target bitmaps for individual entries (would be all equal)
8495 // ScLinkTargetTypeObj::SetLinkTargetBitmap( aAny, SC_LINKTARGETTYPE_SHEET );
8497 else if ( pEntry->nWID == SC_WID_UNO_LINKDISPNAME )
8499 // LinkDisplayName for hyperlink dialog
8500 rAny <<= getName(); // sheet name
8502 else if ( pEntry->nWID == SC_WID_UNO_ISACTIVE )
8504 if (rDoc.IsScenario(nTab))
8505 ScUnoHelpFunctions::SetBoolInAny( rAny, rDoc.IsActiveScenario( nTab ));
8507 else if ( pEntry->nWID == SC_WID_UNO_BORDCOL )
8509 if (rDoc.IsScenario(nTab))
8511 OUString aComment;
8512 Color aColor;
8513 sal_uInt16 nFlags;
8514 rDoc.GetScenarioData( nTab, aComment, aColor, nFlags );
8516 rAny <<= static_cast<sal_Int32>(aColor.GetColor());
8519 else if ( pEntry->nWID == SC_WID_UNO_PROTECT )
8521 if (rDoc.IsScenario(nTab))
8523 OUString aComment;
8524 Color aColor;
8525 sal_uInt16 nFlags;
8526 rDoc.GetScenarioData( nTab, aComment, aColor, nFlags );
8528 ScUnoHelpFunctions::SetBoolInAny( rAny, (nFlags & SC_SCENARIO_PROTECT) != 0 );
8531 else if ( pEntry->nWID == SC_WID_UNO_SHOWBORD )
8533 if (rDoc.IsScenario(nTab))
8535 OUString aComment;
8536 Color aColor;
8537 sal_uInt16 nFlags;
8538 rDoc.GetScenarioData( nTab, aComment, aColor, nFlags );
8540 ScUnoHelpFunctions::SetBoolInAny( rAny, (nFlags & SC_SCENARIO_SHOWFRAME) != 0 );
8543 else if ( pEntry->nWID == SC_WID_UNO_PRINTBORD )
8545 if (rDoc.IsScenario(nTab))
8547 OUString aComment;
8548 Color aColor;
8549 sal_uInt16 nFlags;
8550 rDoc.GetScenarioData( nTab, aComment, aColor, nFlags );
8552 ScUnoHelpFunctions::SetBoolInAny( rAny, (nFlags & SC_SCENARIO_PRINTFRAME) != 0 );
8555 else if ( pEntry->nWID == SC_WID_UNO_COPYBACK )
8557 if (rDoc.IsScenario(nTab))
8559 OUString aComment;
8560 Color aColor;
8561 sal_uInt16 nFlags;
8562 rDoc.GetScenarioData( nTab, aComment, aColor, nFlags );
8564 ScUnoHelpFunctions::SetBoolInAny( rAny, (nFlags & SC_SCENARIO_TWOWAY) != 0 );
8567 else if ( pEntry->nWID == SC_WID_UNO_COPYSTYL )
8569 if (rDoc.IsScenario(nTab))
8571 OUString aComment;
8572 Color aColor;
8573 sal_uInt16 nFlags;
8574 rDoc.GetScenarioData( nTab, aComment, aColor, nFlags );
8576 ScUnoHelpFunctions::SetBoolInAny( rAny, (nFlags & SC_SCENARIO_ATTRIB) != 0 );
8579 else if ( pEntry->nWID == SC_WID_UNO_COPYFORM )
8581 if (rDoc.IsScenario(nTab))
8583 OUString aComment;
8584 Color aColor;
8585 sal_uInt16 nFlags;
8586 rDoc.GetScenarioData( nTab, aComment, aColor, nFlags );
8588 ScUnoHelpFunctions::SetBoolInAny( rAny, !(nFlags & SC_SCENARIO_VALUE));
8591 else if ( pEntry->nWID == SC_WID_UNO_TABLAYOUT )
8593 if (rDoc.IsLayoutRTL(nTab))
8594 rAny <<= sal_Int16(com::sun::star::text::WritingMode2::RL_TB);
8595 else
8596 rAny <<= sal_Int16(com::sun::star::text::WritingMode2::LR_TB);
8598 else if ( pEntry->nWID == SC_WID_UNO_AUTOPRINT )
8600 bool bAutoPrint = rDoc.IsPrintEntireSheet( nTab );
8601 ScUnoHelpFunctions::SetBoolInAny( rAny, bAutoPrint );
8603 else if ( pEntry->nWID == SC_WID_UNO_TABCOLOR )
8605 rAny <<= sal_Int32(rDoc.GetTabBgColor(nTab).GetColor());
8607 else if ( pEntry->nWID == SC_WID_UNO_CODENAME )
8609 OUString aCodeName;
8610 if ( pDocSh )
8611 pDocSh->GetDocument().GetCodeName( GetTab_Impl(), aCodeName );
8612 rAny <<= OUString( aCodeName );
8614 else if (pEntry->nWID == SC_WID_UNO_CONDFORMAT)
8616 rAny <<= uno::Reference<sheet::XConditionalFormats>(new ScCondFormatsObj(pDocSh, nTab));
8618 else
8619 ScCellRangeObj::GetOnePropertyValue(pEntry, rAny);
8623 const SfxItemPropertyMap& ScTableSheetObj::GetItemPropertyMap()
8625 return pSheetPropSet->getPropertyMap();
8628 // XServiceInfo
8630 OUString SAL_CALL ScTableSheetObj::getImplementationName() throw(uno::RuntimeException, std::exception)
8632 return OUString( "ScTableSheetObj" );
8635 sal_Bool SAL_CALL ScTableSheetObj::supportsService( const OUString& rServiceName )
8636 throw(uno::RuntimeException, std::exception)
8638 return cppu::supportsService(this, rServiceName);
8641 uno::Sequence<OUString> SAL_CALL ScTableSheetObj::getSupportedServiceNames()
8642 throw(uno::RuntimeException, std::exception)
8644 uno::Sequence<OUString> aRet(7);
8645 OUString* pArray = aRet.getArray();
8646 pArray[0] = SCSPREADSHEET_SERVICE;
8647 pArray[1] = SCSHEETCELLRANGE_SERVICE;
8648 pArray[2] = SCCELLRANGE_SERVICE;
8649 pArray[3] = SCCELLPROPERTIES_SERVICE;
8650 pArray[4] = SCCHARPROPERTIES_SERVICE;
8651 pArray[5] = SCPARAPROPERTIES_SERVICE;
8652 pArray[6] = SCLINKTARGET_SERVICE;
8653 return aRet;
8656 // XUnoTunnel
8658 sal_Int64 SAL_CALL ScTableSheetObj::getSomething(
8659 const uno::Sequence<sal_Int8 >& rId ) throw(uno::RuntimeException, std::exception)
8661 if ( rId.getLength() == 16 &&
8662 0 == memcmp( getUnoTunnelId().getConstArray(),
8663 rId.getConstArray(), 16 ) )
8665 return sal::static_int_cast<sal_Int64>(reinterpret_cast<sal_IntPtr>(this));
8668 return ScCellRangeObj::getSomething( rId );
8671 namespace
8673 class theScTableSheetObjUnoTunnelId : public rtl::Static< UnoTunnelIdInit, theScTableSheetObjUnoTunnelId> {};
8676 const uno::Sequence<sal_Int8>& ScTableSheetObj::getUnoTunnelId()
8678 return theScTableSheetObjUnoTunnelId::get().getSeq();
8681 ScTableSheetObj* ScTableSheetObj::getImplementation(const uno::Reference<uno::XInterface>& rObj)
8683 ScTableSheetObj* pRet = NULL;
8684 uno::Reference<lang::XUnoTunnel> xUT(rObj, uno::UNO_QUERY);
8685 if (xUT.is())
8686 pRet = reinterpret_cast<ScTableSheetObj*>(sal::static_int_cast<sal_IntPtr>(xUT->getSomething(getUnoTunnelId())));
8687 return pRet;
8690 ScTableColumnObj::ScTableColumnObj( ScDocShell* pDocSh, SCCOL nCol, SCTAB nTab ) :
8691 ScCellRangeObj( pDocSh, ScRange(nCol,0,nTab, nCol,MAXROW,nTab) ),
8692 pColPropSet(lcl_GetColumnPropertySet())
8696 ScTableColumnObj::~ScTableColumnObj()
8700 uno::Any SAL_CALL ScTableColumnObj::queryInterface( const uno::Type& rType ) throw(uno::RuntimeException, std::exception)
8702 SC_QUERYINTERFACE( container::XNamed )
8704 return ScCellRangeObj::queryInterface( rType );
8707 void SAL_CALL ScTableColumnObj::acquire() throw()
8709 ScCellRangeObj::acquire();
8712 void SAL_CALL ScTableColumnObj::release() throw()
8714 ScCellRangeObj::release();
8717 uno::Sequence<uno::Type> SAL_CALL ScTableColumnObj::getTypes() throw(uno::RuntimeException, std::exception)
8719 static uno::Sequence<uno::Type> aTypes;
8720 if ( aTypes.getLength() == 0 )
8722 uno::Sequence<uno::Type> aParentTypes(ScCellRangeObj::getTypes());
8723 long nParentLen = aParentTypes.getLength();
8724 const uno::Type* pParentPtr = aParentTypes.getConstArray();
8726 aTypes.realloc( nParentLen + 1 );
8727 uno::Type* pPtr = aTypes.getArray();
8728 pPtr[nParentLen + 0] = cppu::UnoType<container::XNamed>::get();
8730 for (long i=0; i<nParentLen; i++)
8731 pPtr[i] = pParentPtr[i]; // parent types first
8733 return aTypes;
8736 uno::Sequence<sal_Int8> SAL_CALL ScTableColumnObj::getImplementationId() throw(uno::RuntimeException, std::exception)
8738 return css::uno::Sequence<sal_Int8>();
8741 // XNamed
8743 OUString SAL_CALL ScTableColumnObj::getName() throw(uno::RuntimeException, std::exception)
8745 SolarMutexGuard aGuard;
8747 const ScRange& rRange = GetRange();
8748 OSL_ENSURE(rRange.aStart.Col() == rRange.aEnd.Col(), "too many columns");
8749 SCCOL nCol = rRange.aStart.Col();
8751 return ScColToAlpha( nCol ); // from global.hxx
8754 void SAL_CALL ScTableColumnObj::setName( const OUString& /* aNewName */ )
8755 throw(uno::RuntimeException, std::exception)
8757 SolarMutexGuard aGuard;
8758 throw uno::RuntimeException(); // read-only
8761 // XPropertySet erweitert fuer Spalten-Properties
8763 uno::Reference<beans::XPropertySetInfo> SAL_CALL ScTableColumnObj::getPropertySetInfo()
8764 throw(uno::RuntimeException, std::exception)
8766 SolarMutexGuard aGuard;
8767 static uno::Reference<beans::XPropertySetInfo> aRef(
8768 new SfxItemPropertySetInfo( pColPropSet->getPropertyMap() ));
8769 return aRef;
8772 void ScTableColumnObj::SetOnePropertyValue(const SfxItemPropertySimpleEntry* pEntry, const uno::Any& aValue)
8773 throw(lang::IllegalArgumentException, uno::RuntimeException,
8774 std::exception)
8776 if ( pEntry )
8778 if ( IsScItemWid( pEntry->nWID ) )
8780 // for Item WIDs, call ScCellRangesBase directly
8781 ScCellRangesBase::SetOnePropertyValue(pEntry, aValue);
8782 return;
8785 // own properties
8787 ScDocShell* pDocSh = GetDocShell();
8788 if (!pDocSh)
8789 return; //! Exception oder so?
8790 const ScRange& rRange = GetRange();
8791 OSL_ENSURE(rRange.aStart.Col() == rRange.aEnd.Col(), "zuviele Spalten");
8792 SCCOL nCol = rRange.aStart.Col();
8793 SCTAB nTab = rRange.aStart.Tab();
8794 ScDocFunc &rFunc = pDocSh->GetDocFunc();
8796 std::vector<sc::ColRowSpan> aColArr(1, sc::ColRowSpan(nCol,nCol));
8798 if ( pEntry->nWID == SC_WID_UNO_CELLWID )
8800 sal_Int32 nNewWidth = 0;
8801 if ( aValue >>= nNewWidth )
8803 // property is 1/100mm, column width is twips
8804 nNewWidth = HMMToTwips(nNewWidth);
8805 rFunc.SetWidthOrHeight(
8806 true, aColArr, nTab, SC_SIZE_ORIGINAL, (sal_uInt16)nNewWidth, true, true);
8809 else if ( pEntry->nWID == SC_WID_UNO_CELLVIS )
8811 bool bVis = ScUnoHelpFunctions::GetBoolFromAny( aValue );
8812 ScSizeMode eMode = bVis ? SC_SIZE_SHOW : SC_SIZE_DIRECT;
8813 rFunc.SetWidthOrHeight(true, aColArr, nTab, eMode, 0, true, true);
8814 // SC_SIZE_DIRECT mit Groesse 0 blendet aus
8816 else if ( pEntry->nWID == SC_WID_UNO_OWIDTH )
8818 bool bOpt = ScUnoHelpFunctions::GetBoolFromAny( aValue );
8819 if (bOpt)
8820 rFunc.SetWidthOrHeight(
8821 true, aColArr, nTab, SC_SIZE_OPTIMAL, STD_EXTRA_WIDTH, true, true);
8822 // sal_False bei Spalten momentan ohne Auswirkung
8824 else if ( pEntry->nWID == SC_WID_UNO_NEWPAGE || pEntry->nWID == SC_WID_UNO_MANPAGE )
8826 bool bSet = ScUnoHelpFunctions::GetBoolFromAny( aValue );
8827 if (bSet)
8828 rFunc.InsertPageBreak( true, rRange.aStart, true, true, true );
8829 else
8830 rFunc.RemovePageBreak( true, rRange.aStart, true, true, true );
8832 else
8833 ScCellRangeObj::SetOnePropertyValue(pEntry, aValue); // base class, no Item WID
8837 void ScTableColumnObj::GetOnePropertyValue( const SfxItemPropertySimpleEntry* pEntry, uno::Any& rAny )
8838 throw(uno::RuntimeException, std::exception)
8840 if ( pEntry )
8842 ScDocShell* pDocSh = GetDocShell();
8843 if (!pDocSh)
8844 throw uno::RuntimeException();
8846 ScDocument& rDoc = pDocSh->GetDocument();
8847 const ScRange& rRange = GetRange();
8848 OSL_ENSURE(rRange.aStart.Col() == rRange.aEnd.Col(), "zuviele Spalten");
8849 SCCOL nCol = rRange.aStart.Col();
8850 SCTAB nTab = rRange.aStart.Tab();
8852 if ( pEntry->nWID == SC_WID_UNO_CELLWID )
8854 // for hidden column, return original height
8855 sal_uInt16 nWidth = rDoc.GetOriginalWidth( nCol, nTab );
8856 // property is 1/100mm, column width is twips
8857 nWidth = (sal_uInt16) TwipsToHMM(nWidth);
8858 rAny <<= (sal_Int32)( nWidth );
8860 else if ( pEntry->nWID == SC_WID_UNO_CELLVIS )
8862 bool bHidden = rDoc.ColHidden(nCol, nTab);
8863 ScUnoHelpFunctions::SetBoolInAny( rAny, !bHidden );
8865 else if ( pEntry->nWID == SC_WID_UNO_OWIDTH )
8867 //! momentan immer gesetzt ??!?!
8868 bool bOpt = !(rDoc.GetColFlags( nCol, nTab ) & CR_MANUALSIZE);
8869 ScUnoHelpFunctions::SetBoolInAny( rAny, bOpt );
8871 else if ( pEntry->nWID == SC_WID_UNO_NEWPAGE )
8873 ScBreakType nBreak = rDoc.HasColBreak(nCol, nTab);
8874 ScUnoHelpFunctions::SetBoolInAny( rAny, nBreak != BREAK_NONE );
8876 else if ( pEntry->nWID == SC_WID_UNO_MANPAGE )
8878 ScBreakType nBreak = rDoc.HasColBreak(nCol, nTab);
8879 ScUnoHelpFunctions::SetBoolInAny(rAny, (nBreak & BREAK_MANUAL) != 0);
8881 else
8882 ScCellRangeObj::GetOnePropertyValue(pEntry, rAny);
8886 const SfxItemPropertyMap& ScTableColumnObj::GetItemPropertyMap()
8888 return pColPropSet->getPropertyMap();
8891 ScTableRowObj::ScTableRowObj(ScDocShell* pDocSh, SCROW nRow, SCTAB nTab) :
8892 ScCellRangeObj( pDocSh, ScRange(0,nRow,nTab, MAXCOL,nRow,nTab) ),
8893 pRowPropSet(lcl_GetRowPropertySet())
8897 ScTableRowObj::~ScTableRowObj()
8901 // XPropertySet erweitert fuer Zeilen-Properties
8903 uno::Reference<beans::XPropertySetInfo> SAL_CALL ScTableRowObj::getPropertySetInfo()
8904 throw(uno::RuntimeException, std::exception)
8906 SolarMutexGuard aGuard;
8907 static uno::Reference<beans::XPropertySetInfo> aRef(
8908 new SfxItemPropertySetInfo( pRowPropSet->getPropertyMap() ));
8909 return aRef;
8912 void ScTableRowObj::SetOnePropertyValue( const SfxItemPropertySimpleEntry* pEntry, const uno::Any& aValue )
8913 throw(lang::IllegalArgumentException, uno::RuntimeException, std::exception)
8915 if ( pEntry )
8917 if ( IsScItemWid( pEntry->nWID ) )
8919 // for Item WIDs, call ScCellRangesBase directly
8920 ScCellRangesBase::SetOnePropertyValue(pEntry, aValue);
8921 return;
8924 // own properties
8926 ScDocShell* pDocSh = GetDocShell();
8927 if (!pDocSh)
8928 return; //! Exception oder so?
8929 ScDocument& rDoc = pDocSh->GetDocument();
8930 const ScRange& rRange = GetRange();
8931 OSL_ENSURE(rRange.aStart.Row() == rRange.aEnd.Row(), "zuviele Zeilen");
8932 SCROW nRow = rRange.aStart.Row();
8933 SCTAB nTab = rRange.aStart.Tab();
8934 ScDocFunc &rFunc = pDocSh->GetDocFunc();
8936 std::vector<sc::ColRowSpan> aRowArr(1, sc::ColRowSpan(nRow,nRow));
8938 if ( pEntry->nWID == SC_WID_UNO_CELLHGT )
8940 sal_Int32 nNewHeight = 0;
8941 if ( aValue >>= nNewHeight )
8943 // property is 1/100mm, row height is twips
8944 nNewHeight = HMMToTwips(nNewHeight);
8945 rFunc.SetWidthOrHeight(
8946 false, aRowArr, nTab, SC_SIZE_ORIGINAL, (sal_uInt16)nNewHeight, true, true);
8949 else if ( pEntry->nWID == SC_WID_UNO_CELLVIS )
8951 bool bVis = ScUnoHelpFunctions::GetBoolFromAny( aValue );
8952 ScSizeMode eMode = bVis ? SC_SIZE_SHOW : SC_SIZE_DIRECT;
8953 rFunc.SetWidthOrHeight(false, aRowArr, nTab, eMode, 0, true, true);
8954 // SC_SIZE_DIRECT mit Groesse 0 blendet aus
8956 else if ( pEntry->nWID == SC_WID_UNO_CELLFILT )
8958 bool bFil = ScUnoHelpFunctions::GetBoolFromAny( aValue );
8959 // SC_SIZE_DIRECT mit Groesse 0 blendet aus
8960 rDoc.SetRowFiltered(nRow, nRow, nTab, bFil);
8962 else if ( pEntry->nWID == SC_WID_UNO_OHEIGHT )
8964 bool bOpt = ScUnoHelpFunctions::GetBoolFromAny( aValue );
8965 if (bOpt)
8966 rFunc.SetWidthOrHeight(false, aRowArr, nTab, SC_SIZE_OPTIMAL, 0, true, true);
8967 else
8969 // set current height again manually
8970 sal_uInt16 nHeight = rDoc.GetOriginalHeight( nRow, nTab );
8971 rFunc.SetWidthOrHeight(false, aRowArr, nTab, SC_SIZE_ORIGINAL, nHeight, true, true);
8974 else if ( pEntry->nWID == SC_WID_UNO_NEWPAGE || pEntry->nWID == SC_WID_UNO_MANPAGE )
8976 bool bSet = ScUnoHelpFunctions::GetBoolFromAny( aValue );
8977 if (bSet)
8978 rFunc.InsertPageBreak( false, rRange.aStart, true, true, true );
8979 else
8980 rFunc.RemovePageBreak( false, rRange.aStart, true, true, true );
8982 else
8983 ScCellRangeObj::SetOnePropertyValue(pEntry, aValue); // base class, no Item WID
8987 void ScTableRowObj::GetOnePropertyValue( const SfxItemPropertySimpleEntry* pEntry, uno::Any& rAny )
8988 throw(uno::RuntimeException, std::exception)
8990 if ( pEntry )
8992 ScDocShell* pDocSh = GetDocShell();
8993 if (!pDocSh)
8994 throw uno::RuntimeException();
8995 ScDocument& rDoc = pDocSh->GetDocument();
8996 const ScRange& rRange = GetRange();
8997 OSL_ENSURE(rRange.aStart.Row() == rRange.aEnd.Row(), "zuviele Zeilen");
8998 SCROW nRow = rRange.aStart.Row();
8999 SCTAB nTab = rRange.aStart.Tab();
9001 if ( pEntry->nWID == SC_WID_UNO_CELLHGT )
9003 // for hidden row, return original height
9004 sal_uInt16 nHeight = rDoc.GetOriginalHeight( nRow, nTab );
9005 // property is 1/100mm, row height is twips
9006 nHeight = (sal_uInt16) TwipsToHMM(nHeight);
9007 rAny <<= (sal_Int32)( nHeight );
9009 else if ( pEntry->nWID == SC_WID_UNO_CELLVIS )
9011 bool bHidden = rDoc.RowHidden(nRow, nTab);
9012 ScUnoHelpFunctions::SetBoolInAny( rAny, !bHidden );
9014 else if ( pEntry->nWID == SC_WID_UNO_CELLFILT )
9016 bool bVis = rDoc.RowFiltered(nRow, nTab);
9017 ScUnoHelpFunctions::SetBoolInAny( rAny, bVis );
9019 else if ( pEntry->nWID == SC_WID_UNO_OHEIGHT )
9021 bool bOpt = !(rDoc.GetRowFlags( nRow, nTab ) & CR_MANUALSIZE);
9022 ScUnoHelpFunctions::SetBoolInAny( rAny, bOpt );
9024 else if ( pEntry->nWID == SC_WID_UNO_NEWPAGE )
9026 ScBreakType nBreak = rDoc.HasRowBreak(nRow, nTab);
9027 ScUnoHelpFunctions::SetBoolInAny( rAny, nBreak != BREAK_NONE );
9029 else if ( pEntry->nWID == SC_WID_UNO_MANPAGE )
9031 bool bBreak = (rDoc.HasRowBreak(nRow, nTab) & BREAK_MANUAL) != 0;
9032 ScUnoHelpFunctions::SetBoolInAny( rAny, bBreak );
9034 else
9035 ScCellRangeObj::GetOnePropertyValue(pEntry, rAny);
9039 const SfxItemPropertyMap& ScTableRowObj::GetItemPropertyMap()
9041 return pRowPropSet->getPropertyMap();
9044 ScCellsObj::ScCellsObj(ScDocShell* pDocSh, const ScRangeList& rR) :
9045 pDocShell( pDocSh ),
9046 aRanges( rR )
9048 pDocShell->GetDocument().AddUnoObject(*this);
9051 ScCellsObj::~ScCellsObj()
9053 SolarMutexGuard g;
9055 if (pDocShell)
9056 pDocShell->GetDocument().RemoveUnoObject(*this);
9059 void ScCellsObj::Notify( SfxBroadcaster&, const SfxHint& rHint )
9061 if ( dynamic_cast<const ScUpdateRefHint*>(&rHint) )
9063 const ScUpdateRefHint& rRef = static_cast<const ScUpdateRefHint&>(rHint);
9064 aRanges.UpdateReference( rRef.GetMode(), &pDocShell->GetDocument(), rRef.GetRange(),
9065 rRef.GetDx(), rRef.GetDy(), rRef.GetDz() );
9067 else if ( dynamic_cast<const SfxSimpleHint*>(&rHint) &&
9068 static_cast<const SfxSimpleHint&>(rHint).GetId() == SFX_HINT_DYING )
9070 pDocShell = NULL; // ungueltig geworden
9074 // XEnumerationAccess
9076 uno::Reference<container::XEnumeration> SAL_CALL ScCellsObj::createEnumeration()
9077 throw(uno::RuntimeException, std::exception)
9079 SolarMutexGuard aGuard;
9080 if (pDocShell)
9081 return new ScCellsEnumeration( pDocShell, aRanges );
9082 return NULL;
9085 uno::Type SAL_CALL ScCellsObj::getElementType() throw(uno::RuntimeException, std::exception)
9087 SolarMutexGuard aGuard;
9088 return cppu::UnoType<table::XCell>::get();
9091 sal_Bool SAL_CALL ScCellsObj::hasElements() throw(uno::RuntimeException, std::exception)
9093 SolarMutexGuard aGuard;
9094 bool bHas = false;
9095 if ( pDocShell )
9097 //! schneller selber testen?
9099 uno::Reference<container::XEnumeration> xEnum(new ScCellsEnumeration( pDocShell, aRanges ));
9100 bHas = xEnum->hasMoreElements();
9102 return bHas;
9105 ScCellsEnumeration::ScCellsEnumeration(ScDocShell* pDocSh, const ScRangeList& rR) :
9106 pDocShell( pDocSh ),
9107 aRanges( rR ),
9108 pMark( NULL ),
9109 bAtEnd( false )
9111 ScDocument& rDoc = pDocShell->GetDocument();
9112 rDoc.AddUnoObject(*this);
9114 if ( aRanges.empty() )
9115 bAtEnd = true;
9116 else
9118 SCTAB nTab = 0;
9119 const ScRange* pFirst = aRanges[ 0 ];
9120 if (pFirst)
9121 nTab = pFirst->aStart.Tab();
9122 aPos = ScAddress(0,0,nTab);
9123 CheckPos_Impl(); // aPos auf erste passende Zelle setzen
9127 void ScCellsEnumeration::CheckPos_Impl()
9129 if (!pDocShell)
9130 return;
9132 bool bFound = false;
9133 ScDocument& rDoc = pDocShell->GetDocument();
9134 ScRefCellValue aCell;
9135 aCell.assign(rDoc, aPos);
9136 if (!aCell.isEmpty())
9138 if (!pMark)
9140 pMark = new ScMarkData;
9141 pMark->MarkFromRangeList(aRanges, false);
9142 pMark->MarkToMulti(); // needed for GetNextMarkedCell
9144 bFound = pMark->IsCellMarked(aPos.Col(), aPos.Row());
9146 if (!bFound)
9147 Advance_Impl();
9150 ScCellsEnumeration::~ScCellsEnumeration()
9152 SolarMutexGuard g;
9154 if (pDocShell)
9155 pDocShell->GetDocument().RemoveUnoObject(*this);
9156 delete pMark;
9159 void ScCellsEnumeration::Advance_Impl()
9161 OSL_ENSURE(!bAtEnd,"zuviel Advance_Impl");
9162 if (!pMark)
9164 pMark = new ScMarkData;
9165 pMark->MarkFromRangeList( aRanges, false );
9166 pMark->MarkToMulti(); // needed for GetNextMarkedCell
9169 SCCOL nCol = aPos.Col();
9170 SCROW nRow = aPos.Row();
9171 SCTAB nTab = aPos.Tab();
9172 bool bFound = pDocShell->GetDocument().GetNextMarkedCell( nCol, nRow, nTab, *pMark );
9173 if (bFound)
9174 aPos.Set( nCol, nRow, nTab );
9175 else
9176 bAtEnd = true; // kommt nix mehr
9179 void ScCellsEnumeration::Notify( SfxBroadcaster&, const SfxHint& rHint )
9181 const ScUpdateRefHint* pRefHint = dynamic_cast<const ScUpdateRefHint*>(&rHint);
9182 if ( pRefHint )
9184 if (pDocShell)
9186 aRanges.UpdateReference( pRefHint->GetMode(), &pDocShell->GetDocument(), pRefHint->GetRange(),
9187 pRefHint->GetDx(), pRefHint->GetDy(), pRefHint->GetDz() );
9189 delete pMark; // aus verschobenen Bereichen neu erzeugen
9190 pMark = NULL;
9192 if (!bAtEnd) // aPos anpassen
9194 ScRangeList aNew;
9195 aNew.Append(ScRange(aPos));
9196 aNew.UpdateReference( pRefHint->GetMode(), &pDocShell->GetDocument(), pRefHint->GetRange(),
9197 pRefHint->GetDx(), pRefHint->GetDy(), pRefHint->GetDz() );
9198 if (aNew.size()==1)
9200 aPos = aNew[ 0 ]->aStart;
9201 CheckPos_Impl();
9206 else if ( dynamic_cast<const SfxSimpleHint*>(&rHint) &&
9207 static_cast<const SfxSimpleHint&>(rHint).GetId() == SFX_HINT_DYING )
9209 pDocShell = NULL; // ungueltig geworden
9213 // XEnumeration
9215 sal_Bool SAL_CALL ScCellsEnumeration::hasMoreElements() throw(uno::RuntimeException, std::exception)
9217 SolarMutexGuard aGuard;
9218 return !bAtEnd;
9221 uno::Any SAL_CALL ScCellsEnumeration::nextElement() throw(container::NoSuchElementException,
9222 lang::WrappedTargetException, uno::RuntimeException, std::exception)
9224 SolarMutexGuard aGuard;
9225 if (pDocShell && !bAtEnd)
9227 // Interface-Typ muss zu ScCellsObj::getElementType passen
9229 ScAddress aTempPos(aPos);
9230 Advance_Impl();
9231 return uno::makeAny(uno::Reference<table::XCell>(new ScCellObj( pDocShell, aTempPos )));
9234 throw container::NoSuchElementException(); // no more elements
9237 ScCellFormatsObj::ScCellFormatsObj(ScDocShell* pDocSh, const ScRange& rRange) :
9238 pDocShell( pDocSh ),
9239 aTotalRange( rRange )
9241 ScDocument& rDoc = pDocShell->GetDocument();
9242 rDoc.AddUnoObject(*this);
9244 OSL_ENSURE( aTotalRange.aStart.Tab() == aTotalRange.aEnd.Tab(), "unterschiedliche Tabellen" );
9247 ScCellFormatsObj::~ScCellFormatsObj()
9249 SolarMutexGuard g;
9251 if (pDocShell)
9252 pDocShell->GetDocument().RemoveUnoObject(*this);
9255 void ScCellFormatsObj::Notify( SfxBroadcaster&, const SfxHint& rHint )
9257 if ( dynamic_cast<const ScUpdateRefHint*>(&rHint) )
9259 //! aTotalRange...
9261 else if ( dynamic_cast<const SfxSimpleHint*>(&rHint) &&
9262 static_cast<const SfxSimpleHint&>(rHint).GetId() == SFX_HINT_DYING )
9264 pDocShell = NULL; // ungueltig geworden
9268 ScCellRangeObj* ScCellFormatsObj::GetObjectByIndex_Impl(long nIndex) const
9270 //! direkt auf die AttrArrays zugreifen !!!!
9272 ScCellRangeObj* pRet = NULL;
9273 if (pDocShell)
9275 ScDocument& rDoc = pDocShell->GetDocument();
9276 long nPos = 0;
9277 ScAttrRectIterator aIter( &rDoc, aTotalRange.aStart.Tab(),
9278 aTotalRange.aStart.Col(), aTotalRange.aStart.Row(),
9279 aTotalRange.aEnd.Col(), aTotalRange.aEnd.Row() );
9280 SCCOL nCol1, nCol2;
9281 SCROW nRow1, nRow2;
9282 while ( aIter.GetNext( nCol1, nCol2, nRow1, nRow2 ) )
9284 if ( nPos == nIndex )
9286 SCTAB nTab = aTotalRange.aStart.Tab();
9287 ScRange aNext( nCol1, nRow1, nTab, nCol2, nRow2, nTab );
9289 if ( aNext.aStart == aNext.aEnd )
9290 pRet = new ScCellObj( pDocShell, aNext.aStart );
9291 else
9292 pRet = new ScCellRangeObj( pDocShell, aNext );
9294 ++nPos;
9297 return pRet;
9300 // XIndexAccess
9302 sal_Int32 SAL_CALL ScCellFormatsObj::getCount() throw(uno::RuntimeException, std::exception)
9304 SolarMutexGuard aGuard;
9306 //! direkt auf die AttrArrays zugreifen !!!!
9308 long nCount = 0;
9309 if (pDocShell)
9311 ScDocument& rDoc = pDocShell->GetDocument();
9312 ScAttrRectIterator aIter( &rDoc, aTotalRange.aStart.Tab(),
9313 aTotalRange.aStart.Col(), aTotalRange.aStart.Row(),
9314 aTotalRange.aEnd.Col(), aTotalRange.aEnd.Row() );
9315 SCCOL nCol1, nCol2;
9316 SCROW nRow1, nRow2;
9317 while ( aIter.GetNext( nCol1, nCol2, nRow1, nRow2 ) )
9318 ++nCount;
9320 return nCount;
9323 uno::Any SAL_CALL ScCellFormatsObj::getByIndex( sal_Int32 nIndex )
9324 throw(lang::IndexOutOfBoundsException,
9325 lang::WrappedTargetException, uno::RuntimeException, std::exception)
9327 SolarMutexGuard aGuard;
9329 uno::Reference<table::XCellRange> xRange(GetObjectByIndex_Impl(nIndex));
9330 if (xRange.is())
9331 return uno::makeAny(xRange);
9332 else
9333 throw lang::IndexOutOfBoundsException();
9336 uno::Type SAL_CALL ScCellFormatsObj::getElementType() throw(uno::RuntimeException, std::exception)
9338 SolarMutexGuard aGuard;
9339 return cppu::UnoType<table::XCellRange>::get();
9342 sal_Bool SAL_CALL ScCellFormatsObj::hasElements() throw(uno::RuntimeException, std::exception)
9344 SolarMutexGuard aGuard;
9345 return ( getCount() != 0 ); //! immer groesser 0 ??
9348 // XEnumerationAccess
9350 uno::Reference<container::XEnumeration> SAL_CALL ScCellFormatsObj::createEnumeration()
9351 throw(uno::RuntimeException, std::exception)
9353 SolarMutexGuard aGuard;
9354 if (pDocShell)
9355 return new ScCellFormatsEnumeration( pDocShell, aTotalRange );
9356 return NULL;
9359 ScCellFormatsEnumeration::ScCellFormatsEnumeration(ScDocShell* pDocSh, const ScRange& rRange) :
9360 pDocShell( pDocSh ),
9361 nTab( rRange.aStart.Tab() ),
9362 pIter( NULL ),
9363 bAtEnd( false ),
9364 bDirty( false )
9366 ScDocument& rDoc = pDocShell->GetDocument();
9367 rDoc.AddUnoObject(*this);
9369 OSL_ENSURE( rRange.aStart.Tab() == rRange.aEnd.Tab(),
9370 "CellFormatsEnumeration: unterschiedliche Tabellen" );
9372 pIter = new ScAttrRectIterator( &rDoc, nTab,
9373 rRange.aStart.Col(), rRange.aStart.Row(),
9374 rRange.aEnd.Col(), rRange.aEnd.Row() );
9375 Advance_Impl();
9378 ScCellFormatsEnumeration::~ScCellFormatsEnumeration()
9380 SolarMutexGuard g;
9382 if (pDocShell)
9383 pDocShell->GetDocument().RemoveUnoObject(*this);
9384 delete pIter;
9387 void ScCellFormatsEnumeration::Advance_Impl()
9389 OSL_ENSURE(!bAtEnd,"zuviel Advance_Impl");
9391 if ( pIter )
9393 if ( bDirty )
9395 pIter->DataChanged(); // AttrArray-Index neu suchen
9396 bDirty = false;
9399 SCCOL nCol1, nCol2;
9400 SCROW nRow1, nRow2;
9401 if ( pIter->GetNext( nCol1, nCol2, nRow1, nRow2 ) )
9402 aNext = ScRange( nCol1, nRow1, nTab, nCol2, nRow2, nTab );
9403 else
9404 bAtEnd = true; // kommt nix mehr
9406 else
9407 bAtEnd = true; // Dok weggekommen oder so
9410 ScCellRangeObj* ScCellFormatsEnumeration::NextObject_Impl()
9412 ScCellRangeObj* pRet = NULL;
9413 if (pDocShell && !bAtEnd)
9415 if ( aNext.aStart == aNext.aEnd )
9416 pRet = new ScCellObj( pDocShell, aNext.aStart );
9417 else
9418 pRet = new ScCellRangeObj( pDocShell, aNext );
9419 Advance_Impl();
9421 return pRet;
9424 void ScCellFormatsEnumeration::Notify( SfxBroadcaster&, const SfxHint& rHint )
9426 if ( dynamic_cast<const ScUpdateRefHint*>(&rHint) )
9428 //! und nun ???
9430 else if ( dynamic_cast<const SfxSimpleHint*>(&rHint) )
9432 sal_uLong nId = static_cast<const SfxSimpleHint&>(rHint).GetId();
9433 if ( nId == SFX_HINT_DYING )
9435 pDocShell = NULL; // ungueltig geworden
9436 delete pIter;
9437 pIter = NULL;
9439 else if ( nId == SFX_HINT_DATACHANGED )
9441 bDirty = true; // AttrArray-Index evtl. ungueltig geworden
9446 // XEnumeration
9448 sal_Bool SAL_CALL ScCellFormatsEnumeration::hasMoreElements() throw(uno::RuntimeException, std::exception)
9450 SolarMutexGuard aGuard;
9451 return !bAtEnd;
9454 uno::Any SAL_CALL ScCellFormatsEnumeration::nextElement() throw(container::NoSuchElementException,
9455 lang::WrappedTargetException, uno::RuntimeException, std::exception)
9457 SolarMutexGuard aGuard;
9459 if ( bAtEnd || !pDocShell )
9460 throw container::NoSuchElementException(); // no more elements
9462 // Interface-Typ muss zu ScCellFormatsObj::getElementType passen
9464 return uno::makeAny(uno::Reference<table::XCellRange> (NextObject_Impl()));
9467 ScUniqueCellFormatsObj::ScUniqueCellFormatsObj(ScDocShell* pDocSh, const ScRange& rRange) :
9468 pDocShell( pDocSh ),
9469 aTotalRange( rRange ),
9470 aRangeLists()
9472 pDocShell->GetDocument().AddUnoObject(*this);
9474 OSL_ENSURE( aTotalRange.aStart.Tab() == aTotalRange.aEnd.Tab(), "unterschiedliche Tabellen" );
9476 GetObjects_Impl();
9479 ScUniqueCellFormatsObj::~ScUniqueCellFormatsObj()
9481 SolarMutexGuard g;
9483 if (pDocShell)
9484 pDocShell->GetDocument().RemoveUnoObject(*this);
9487 void ScUniqueCellFormatsObj::Notify( SfxBroadcaster&, const SfxHint& rHint )
9489 if ( dynamic_cast<const ScUpdateRefHint*>(&rHint) )
9491 //! aTotalRange...
9493 else if ( dynamic_cast<const SfxSimpleHint*>(&rHint) )
9495 sal_uLong nId = static_cast<const SfxSimpleHint&>(rHint).GetId();
9496 if ( nId == SFX_HINT_DYING )
9497 pDocShell = NULL; // ungueltig geworden
9501 // Fill the list of formats from the document
9503 // hash code to access the range lists by ScPatternAttr pointer
9504 struct ScPatternHashCode
9506 size_t operator()( const ScPatternAttr* pPattern ) const
9508 return reinterpret_cast<size_t>(pPattern);
9512 // Hash map to find a range by its start row
9513 typedef std::unordered_map< SCROW, ScRange > ScRowRangeHashMap;
9515 typedef std::vector<ScRange> ScRangeVector;
9517 // Hash map entry.
9518 // The Join method depends on the column-wise order of ScAttrRectIterator
9519 class ScUniqueFormatsEntry
9521 enum EntryState { STATE_EMPTY, STATE_SINGLE, STATE_COMPLEX };
9523 EntryState eState;
9524 ScRange aSingleRange;
9525 ScRowRangeHashMap aJoinedRanges; // "active" ranges to be merged
9526 ScRangeVector aCompletedRanges; // ranges that will no longer be touched
9527 ScRangeListRef aReturnRanges; // result as ScRangeList for further use
9529 public:
9530 ScUniqueFormatsEntry() : eState( STATE_EMPTY ) {}
9531 ~ScUniqueFormatsEntry() {}
9533 void Join( const ScRange& rNewRange );
9534 const ScRangeList& GetRanges();
9535 void Clear() { aReturnRanges.Clear(); } // aJoinedRanges and aCompletedRanges are cleared in GetRanges
9538 void ScUniqueFormatsEntry::Join( const ScRange& rNewRange )
9540 // Special-case handling for single range
9542 if ( eState == STATE_EMPTY )
9544 aSingleRange = rNewRange;
9545 eState = STATE_SINGLE;
9546 return;
9548 if ( eState == STATE_SINGLE )
9550 if ( aSingleRange.aStart.Row() == rNewRange.aStart.Row() &&
9551 aSingleRange.aEnd.Row() == rNewRange.aEnd.Row() &&
9552 aSingleRange.aEnd.Col() + 1 == rNewRange.aStart.Col() )
9554 aSingleRange.aEnd.SetCol( rNewRange.aEnd.Col() );
9555 return; // still a single range
9558 SCROW nSingleRow = aSingleRange.aStart.Row();
9559 aJoinedRanges.insert( ScRowRangeHashMap::value_type( nSingleRow, aSingleRange ) );
9560 eState = STATE_COMPLEX;
9561 // continue normally
9564 // This is called in the order of ScAttrRectIterator results.
9565 // rNewRange can only be joined with an existing entry if it's the same rows, starting in the next column.
9566 // If the old entry for the start row extends to a different end row, or ends in a different column, it
9567 // can be moved to aCompletedRanges because it can't be joined with following iterator results.
9568 // Everything happens within one sheet, so Tab can be ignored.
9570 SCROW nStartRow = rNewRange.aStart.Row();
9571 ScRowRangeHashMap::iterator aIter( aJoinedRanges.find( nStartRow ) ); // find the active entry for the start row
9572 if ( aIter != aJoinedRanges.end() )
9574 ScRange& rOldRange = aIter->second;
9575 if ( rOldRange.aEnd.Row() == rNewRange.aEnd.Row() &&
9576 rOldRange.aEnd.Col() + 1 == rNewRange.aStart.Col() )
9578 // extend existing range
9579 rOldRange.aEnd.SetCol( rNewRange.aEnd.Col() );
9581 else
9583 // move old range to aCompletedRanges, keep rNewRange for joining
9584 aCompletedRanges.push_back( rOldRange );
9585 rOldRange = rNewRange; // replace in hash map
9588 else
9590 // keep rNewRange for joining
9591 aJoinedRanges.insert( ScRowRangeHashMap::value_type( nStartRow, rNewRange ) );
9595 const ScRangeList& ScUniqueFormatsEntry::GetRanges()
9597 if ( eState == STATE_SINGLE )
9599 aReturnRanges = new ScRangeList;
9600 aReturnRanges->Append( aSingleRange );
9601 return *aReturnRanges;
9604 // move remaining entries from aJoinedRanges to aCompletedRanges
9606 ScRowRangeHashMap::const_iterator aJoinedEnd = aJoinedRanges.end();
9607 for ( ScRowRangeHashMap::const_iterator aJoinedIter = aJoinedRanges.begin(); aJoinedIter != aJoinedEnd; ++aJoinedIter )
9608 aCompletedRanges.push_back( aJoinedIter->second );
9609 aJoinedRanges.clear();
9611 // sort all ranges for a predictable API result
9613 std::sort( aCompletedRanges.begin(), aCompletedRanges.end() );
9615 // fill and return ScRangeList
9617 aReturnRanges = new ScRangeList;
9618 ScRangeVector::const_iterator aCompEnd( aCompletedRanges.end() );
9619 for ( ScRangeVector::const_iterator aCompIter( aCompletedRanges.begin() ); aCompIter != aCompEnd; ++aCompIter )
9620 aReturnRanges->Append( *aCompIter );
9621 aCompletedRanges.clear();
9623 return *aReturnRanges;
9626 typedef std::unordered_map< const ScPatternAttr*, ScUniqueFormatsEntry, ScPatternHashCode > ScUniqueFormatsHashMap;
9628 // function object to sort the range lists by start of first range
9629 struct ScUniqueFormatsOrder
9631 bool operator()( const ScRangeList& rList1, const ScRangeList& rList2 ) const
9633 // all range lists have at least one entry
9634 OSL_ENSURE( rList1.size() > 0 && rList2.size() > 0, "ScUniqueFormatsOrder: empty list" );
9636 // compare start positions using ScAddress comparison operator
9637 return ( rList1[ 0 ]->aStart < rList2[ 0 ]->aStart );
9641 void ScUniqueCellFormatsObj::GetObjects_Impl()
9643 if (pDocShell)
9645 ScDocument& rDoc = pDocShell->GetDocument();
9646 SCTAB nTab = aTotalRange.aStart.Tab();
9647 ScAttrRectIterator aIter( &rDoc, nTab,
9648 aTotalRange.aStart.Col(), aTotalRange.aStart.Row(),
9649 aTotalRange.aEnd.Col(), aTotalRange.aEnd.Row() );
9650 SCCOL nCol1, nCol2;
9651 SCROW nRow1, nRow2;
9653 // Collect the ranges for each format in a hash map, to avoid nested loops
9655 ScUniqueFormatsHashMap aHashMap;
9656 while (aIter.GetNext( nCol1, nCol2, nRow1, nRow2 ) )
9658 ScRange aRange( nCol1, nRow1, nTab, nCol2, nRow2, nTab );
9659 const ScPatternAttr* pPattern = rDoc.GetPattern(nCol1, nRow1, nTab);
9660 aHashMap[pPattern].Join( aRange );
9663 // Fill the vector aRangeLists with the range lists from the hash map
9665 aRangeLists.reserve( aHashMap.size() );
9666 ScUniqueFormatsHashMap::iterator aMapIter( aHashMap.begin() );
9667 ScUniqueFormatsHashMap::iterator aMapEnd( aHashMap.end() );
9668 while ( aMapIter != aMapEnd )
9670 ScUniqueFormatsEntry& rEntry = aMapIter->second;
9671 const ScRangeList& rRanges = rEntry.GetRanges();
9672 aRangeLists.push_back( rRanges ); // copy ScRangeList
9673 rEntry.Clear(); // free memory, don't hold both copies of all ranges
9674 ++aMapIter;
9677 // Sort the vector by first range's start position, to avoid random shuffling
9678 // due to using the ScPatterAttr pointers
9680 ScUniqueFormatsOrder aComp;
9681 ::std::sort( aRangeLists.begin(), aRangeLists.end(), aComp );
9685 // XIndexAccess
9687 sal_Int32 SAL_CALL ScUniqueCellFormatsObj::getCount() throw(uno::RuntimeException, std::exception)
9689 SolarMutexGuard aGuard;
9691 return aRangeLists.size();
9694 uno::Any SAL_CALL ScUniqueCellFormatsObj::getByIndex( sal_Int32 nIndex )
9695 throw(lang::IndexOutOfBoundsException,
9696 lang::WrappedTargetException, uno::RuntimeException, std::exception)
9698 SolarMutexGuard aGuard;
9700 if(static_cast<sal_uInt32>(nIndex) < aRangeLists.size())
9701 return uno::makeAny(uno::Reference<sheet::XSheetCellRangeContainer>(new ScCellRangesObj(pDocShell, aRangeLists[nIndex])));
9702 else
9703 throw lang::IndexOutOfBoundsException();
9706 uno::Type SAL_CALL ScUniqueCellFormatsObj::getElementType() throw(uno::RuntimeException, std::exception)
9708 SolarMutexGuard aGuard;
9709 return cppu::UnoType<sheet::XSheetCellRangeContainer>::get();
9712 sal_Bool SAL_CALL ScUniqueCellFormatsObj::hasElements() throw(uno::RuntimeException, std::exception)
9714 SolarMutexGuard aGuard;
9715 return ( aRangeLists.size() != 0 );
9718 // XEnumerationAccess
9720 uno::Reference<container::XEnumeration> SAL_CALL ScUniqueCellFormatsObj::createEnumeration()
9721 throw(uno::RuntimeException, std::exception)
9723 SolarMutexGuard aGuard;
9724 if (pDocShell)
9725 return new ScUniqueCellFormatsEnumeration( pDocShell, aRangeLists );
9726 return NULL;
9729 ScUniqueCellFormatsEnumeration::ScUniqueCellFormatsEnumeration(ScDocShell* pDocSh, const ScMyRangeLists& rRangeLists) :
9730 aRangeLists(rRangeLists),
9731 pDocShell( pDocSh ),
9732 nCurrentPosition(0)
9734 pDocShell->GetDocument().AddUnoObject(*this);
9737 ScUniqueCellFormatsEnumeration::~ScUniqueCellFormatsEnumeration()
9739 SolarMutexGuard g;
9741 if (pDocShell)
9742 pDocShell->GetDocument().RemoveUnoObject(*this);
9745 void ScUniqueCellFormatsEnumeration::Notify( SfxBroadcaster&, const SfxHint& rHint )
9747 if ( dynamic_cast<const ScUpdateRefHint*>(&rHint) )
9749 //! und nun ???
9751 else if ( dynamic_cast<const SfxSimpleHint*>(&rHint) )
9753 sal_uLong nId = static_cast<const SfxSimpleHint&>(rHint).GetId();
9754 if ( nId == SFX_HINT_DYING )
9755 pDocShell = NULL; // ungueltig geworden
9759 // XEnumeration
9761 sal_Bool SAL_CALL ScUniqueCellFormatsEnumeration::hasMoreElements() throw(uno::RuntimeException, std::exception)
9763 SolarMutexGuard aGuard;
9764 return static_cast<sal_uInt32>(nCurrentPosition) < aRangeLists.size();
9767 uno::Any SAL_CALL ScUniqueCellFormatsEnumeration::nextElement() throw(container::NoSuchElementException,
9768 lang::WrappedTargetException, uno::RuntimeException, std::exception)
9770 SolarMutexGuard aGuard;
9772 if ( !hasMoreElements() || !pDocShell )
9773 throw container::NoSuchElementException(); // no more elements
9775 // Interface-Typ muss zu ScCellFormatsObj::getElementType passen
9777 return uno::makeAny(uno::Reference<sheet::XSheetCellRangeContainer>(new ScCellRangesObj(pDocShell, aRangeLists[nCurrentPosition++])));
9780 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */