File: | home/maarten/src/libreoffice/core/sc/source/ui/unoobj/cellsuno.cxx |
Warning: | line 1437, column 9 Called C++ object pointer is null |
Press '?' to see keyboard shortcuts
Keyboard shortcuts:
1 | /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ | |||
2 | /* | |||
3 | * This file is part of the LibreOffice project. | |||
4 | * | |||
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/. | |||
8 | * | |||
9 | * This file incorporates work covered by the following license notice: | |||
10 | * | |||
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 . | |||
18 | */ | |||
19 | ||||
20 | #include <scitems.hxx> | |||
21 | #include <editeng/eeitem.hxx> | |||
22 | #include <o3tl/safeint.hxx> | |||
23 | #include <svx/svdpool.hxx> | |||
24 | ||||
25 | #include <vcl/svapp.hxx> | |||
26 | #include <svx/algitem.hxx> | |||
27 | #include <editeng/borderline.hxx> | |||
28 | #include <editeng/boxitem.hxx> | |||
29 | #include <editeng/brushitem.hxx> | |||
30 | #include <editeng/editeng.hxx> | |||
31 | #include <editeng/flditem.hxx> | |||
32 | #include <editeng/justifyitem.hxx> | |||
33 | #include <editeng/editobj.hxx> | |||
34 | #include <editeng/unoipset.hxx> | |||
35 | #include <editeng/langitem.hxx> | |||
36 | #include <sfx2/linkmgr.hxx> | |||
37 | #include <svl/srchitem.hxx> | |||
38 | #include <svl/sharedstringpool.hxx> | |||
39 | #include <svx/unomid.hxx> | |||
40 | #include <editeng/unoprnms.hxx> | |||
41 | #include <editeng/unotext.hxx> | |||
42 | #include <svx/svdpage.hxx> | |||
43 | #include <sfx2/bindings.hxx> | |||
44 | #include <svl/zforlist.hxx> | |||
45 | #include <svl/zformat.hxx> | |||
46 | #include <cppuhelper/supportsservice.hxx> | |||
47 | #include <float.h> | |||
48 | ||||
49 | #include <com/sun/star/awt/XBitmap.hpp> | |||
50 | #include <com/sun/star/util/CellProtection.hpp> | |||
51 | #include <com/sun/star/table/CellHoriJustify.hpp> | |||
52 | #include <com/sun/star/table/CellOrientation.hpp> | |||
53 | #include <com/sun/star/table/ShadowFormat.hpp> | |||
54 | #include <com/sun/star/table/TableBorder.hpp> | |||
55 | #include <com/sun/star/table/TableBorder2.hpp> | |||
56 | #include <com/sun/star/sheet/CellFlags.hpp> | |||
57 | #include <com/sun/star/sheet/FormulaResult.hpp> | |||
58 | #include <com/sun/star/beans/PropertyAttribute.hpp> | |||
59 | #include <com/sun/star/lang/IndexOutOfBoundsException.hpp> | |||
60 | #include <com/sun/star/lang/Locale.hpp> | |||
61 | #include <com/sun/star/beans/TolerantPropertySetResultType.hpp> | |||
62 | #include <com/sun/star/beans/SetPropertyTolerantFailed.hpp> | |||
63 | #include <com/sun/star/text/WritingMode2.hpp> | |||
64 | #include <com/sun/star/text/textfield/Type.hpp> | |||
65 | #include <com/sun/star/sheet/XConditionalFormats.hpp> | |||
66 | ||||
67 | #include <autoform.hxx> | |||
68 | #include <cellvalue.hxx> | |||
69 | #include <cellmergeoption.hxx> | |||
70 | #include <cellsuno.hxx> | |||
71 | #include <cursuno.hxx> | |||
72 | #include <textuno.hxx> | |||
73 | #include <editsrc.hxx> | |||
74 | #include <notesuno.hxx> | |||
75 | #include <fielduno.hxx> | |||
76 | #include <docuno.hxx> | |||
77 | #include <datauno.hxx> | |||
78 | #include <dapiuno.hxx> | |||
79 | #include <chartuno.hxx> | |||
80 | #include <fmtuno.hxx> | |||
81 | #include <miscuno.hxx> | |||
82 | #include <convuno.hxx> | |||
83 | #include <srchuno.hxx> | |||
84 | #include <nameuno.hxx> | |||
85 | #include <targuno.hxx> | |||
86 | #include <tokenuno.hxx> | |||
87 | #include <eventuno.hxx> | |||
88 | #include <docsh.hxx> | |||
89 | #include <markdata.hxx> | |||
90 | #include <patattr.hxx> | |||
91 | #include <docpool.hxx> | |||
92 | #include <docfunc.hxx> | |||
93 | #include <dbdocfun.hxx> | |||
94 | #include <olinefun.hxx> | |||
95 | #include <hints.hxx> | |||
96 | #include <formulacell.hxx> | |||
97 | #include <undotab.hxx> | |||
98 | #include <undoblk.hxx> | |||
99 | #include <stlsheet.hxx> | |||
100 | #include <dbdata.hxx> | |||
101 | #include <attrib.hxx> | |||
102 | #include <chartarr.hxx> | |||
103 | #include <chartlis.hxx> | |||
104 | #include <drwlayer.hxx> | |||
105 | #include <printfun.hxx> | |||
106 | #include <prnsave.hxx> | |||
107 | #include <tablink.hxx> | |||
108 | #include <dociter.hxx> | |||
109 | #include <rangeutl.hxx> | |||
110 | #include <conditio.hxx> | |||
111 | #include <validat.hxx> | |||
112 | #include <sc.hrc> | |||
113 | #include <cellform.hxx> | |||
114 | #include <globstr.hrc> | |||
115 | #include <scresid.hxx> | |||
116 | #include <unonames.hxx> | |||
117 | #include <styleuno.hxx> | |||
118 | #include <rangeseq.hxx> | |||
119 | #include <unowids.hxx> | |||
120 | #include <paramisc.hxx> | |||
121 | #include <queryentry.hxx> | |||
122 | #include <formula/errorcodes.hxx> | |||
123 | #include <unoreflist.hxx> | |||
124 | #include <formula/grammar.hxx> | |||
125 | #include <editeng/escapementitem.hxx> | |||
126 | #include <stringutil.hxx> | |||
127 | #include <formulaiter.hxx> | |||
128 | #include <tokenarray.hxx> | |||
129 | #include <stylehelper.hxx> | |||
130 | #include <dputil.hxx> | |||
131 | #include <sortparam.hxx> | |||
132 | #include <condformatuno.hxx> | |||
133 | #include <TablePivotCharts.hxx> | |||
134 | #include <table.hxx> | |||
135 | #include <refundo.hxx> | |||
136 | #include <columnspanset.hxx> | |||
137 | ||||
138 | #include <memory> | |||
139 | ||||
140 | using namespace com::sun::star; | |||
141 | ||||
142 | namespace { | |||
143 | ||||
144 | class ScNamedEntry | |||
145 | { | |||
146 | OUString aName; | |||
147 | ScRange aRange; | |||
148 | ||||
149 | public: | |||
150 | ScNamedEntry(const OUString& rN, const ScRange& rR) : | |||
151 | aName(rN), aRange(rR) {} | |||
152 | ||||
153 | const OUString& GetName() const { return aName; } | |||
154 | const ScRange& GetRange() const { return aRange; } | |||
155 | }; | |||
156 | ||||
157 | } | |||
158 | ||||
159 | // The names in the maps must be sorted according to strcmp! | |||
160 | //! Instead of Which-ID 0 use special IDs and do not compare via names! | |||
161 | ||||
162 | // Left/Right/Top/BottomBorder are mapped directly to the core items, | |||
163 | // not collected/applied to the borders of a range -> ATTR_BORDER can be used directly | |||
164 | ||||
165 | static const SfxItemPropertySet* lcl_GetCellsPropertySet() | |||
166 | { | |||
167 | static const SfxItemPropertyMapEntry aCellsPropertyMap_Impl[] = | |||
168 | { | |||
169 | {u"" SC_UNONAME_ABSNAME"AbsoluteName", SC_WID_UNO_ABSNAME( 1200 + 39 ), cppu::UnoType<OUString>::get(), 0 | beans::PropertyAttribute::READONLY, 0 }, | |||
170 | {u"" SC_UNONAME_ASIANVERT"AsianVerticalMode",ATTR_VERTICAL_ASIAN,cppu::UnoType<bool>::get(), 0, 0 }, | |||
171 | {u"" SC_UNONAME_BOTTBORDER"BottomBorder",ATTR_BORDER, ::cppu::UnoType<table::BorderLine>::get(), 0, BOTTOM_BORDER4 | CONVERT_TWIPS0x80 }, | |||
172 | {u"" SC_UNONAME_BOTTBORDER2"BottomBorder2",ATTR_BORDER, ::cppu::UnoType<table::BorderLine2>::get(), 0, BOTTOM_BORDER4 | CONVERT_TWIPS0x80 }, | |||
173 | {u"" SC_UNONAME_CELLBACK"CellBackColor", ATTR_BACKGROUND, cppu::UnoType<sal_Int32>::get(), 0, MID_BACK_COLOR0 }, | |||
174 | {u"" SC_UNONAME_CELLPRO"CellProtection", ATTR_PROTECTION, cppu::UnoType<util::CellProtection>::get(), 0, 0 }, | |||
175 | {u"" SC_UNONAME_CELLSTYL"CellStyle", SC_WID_UNO_CELLSTYL( 1200 + 0 ),cppu::UnoType<OUString>::get(), 0, 0 }, | |||
176 | {u"" SC_UNONAME_CCOLOR"CharColor", ATTR_FONT_COLOR, cppu::UnoType<sal_Int32>::get(), 0, 0 }, | |||
177 | {u"" SC_UNONAME_COUTL"CharContoured", ATTR_FONT_CONTOUR, cppu::UnoType<bool>::get(), 0, 0 }, | |||
178 | {u"" SC_UNONAME_CCROSS"CharCrossedOut", ATTR_FONT_CROSSEDOUT,cppu::UnoType<bool>::get(), 0, MID_CROSSED_OUT0 }, | |||
179 | {u"" SC_UNONAME_CEMPHAS"CharEmphasis", ATTR_FONT_EMPHASISMARK,cppu::UnoType<sal_Int16>::get(), 0, MID_EMPHASIS0 }, | |||
180 | {u"" SC_UNONAME_CFONT"CharFont", ATTR_FONT, cppu::UnoType<sal_Int16>::get(), 0, MID_FONT_FAMILY3 }, | |||
181 | {u"" SC_UNONAME_CFCHARS"CharFontCharSet", ATTR_FONT, cppu::UnoType<sal_Int16>::get(), 0, MID_FONT_CHAR_SET4 }, | |||
182 | {u"" SC_UNO_CJK_CFCHARS"CharFontCharSetAsian", ATTR_CJK_FONT, cppu::UnoType<sal_Int16>::get(), 0, MID_FONT_CHAR_SET4 }, | |||
183 | {u"" SC_UNO_CTL_CFCHARS"CharFontCharSetComplex", ATTR_CTL_FONT, cppu::UnoType<sal_Int16>::get(), 0, MID_FONT_CHAR_SET4 }, | |||
184 | {u"" SC_UNONAME_CFFAMIL"CharFontFamily", ATTR_FONT, cppu::UnoType<sal_Int16>::get(), 0, MID_FONT_FAMILY3 }, | |||
185 | {u"" SC_UNO_CJK_CFFAMIL"CharFontFamilyAsian", ATTR_CJK_FONT, cppu::UnoType<sal_Int16>::get(), 0, MID_FONT_FAMILY3 }, | |||
186 | {u"" SC_UNO_CTL_CFFAMIL"CharFontFamilyComplex", ATTR_CTL_FONT, cppu::UnoType<sal_Int16>::get(), 0, MID_FONT_FAMILY3 }, | |||
187 | {u"" SC_UNONAME_CFNAME"CharFontName", ATTR_FONT, cppu::UnoType<OUString>::get(), 0, MID_FONT_FAMILY_NAME1 }, | |||
188 | {u"" SC_UNO_CJK_CFNAME"CharFontNameAsian", ATTR_CJK_FONT, cppu::UnoType<OUString>::get(), 0, MID_FONT_FAMILY_NAME1 }, | |||
189 | {u"" SC_UNO_CTL_CFNAME"CharFontNameComplex", ATTR_CTL_FONT, cppu::UnoType<OUString>::get(), 0, MID_FONT_FAMILY_NAME1 }, | |||
190 | {u"" SC_UNONAME_CFPITCH"CharFontPitch", ATTR_FONT, cppu::UnoType<sal_Int16>::get(), 0, MID_FONT_PITCH5 }, | |||
191 | {u"" SC_UNO_CJK_CFPITCH"CharFontPitchAsian", ATTR_CJK_FONT, cppu::UnoType<sal_Int16>::get(), 0, MID_FONT_PITCH5 }, | |||
192 | {u"" SC_UNO_CTL_CFPITCH"CharFontPitchComplex", ATTR_CTL_FONT, cppu::UnoType<sal_Int16>::get(), 0, MID_FONT_PITCH5 }, | |||
193 | {u"" SC_UNONAME_CFSTYLE"CharFontStyleName", ATTR_FONT, cppu::UnoType<OUString>::get(), 0, MID_FONT_STYLE_NAME2 }, | |||
194 | {u"" SC_UNO_CJK_CFSTYLE"CharFontStyleNameAsian", ATTR_CJK_FONT, cppu::UnoType<OUString>::get(), 0, MID_FONT_STYLE_NAME2 }, | |||
195 | {u"" SC_UNO_CTL_CFSTYLE"CharFontStyleNameComplex", ATTR_CTL_FONT, cppu::UnoType<OUString>::get(), 0, MID_FONT_STYLE_NAME2 }, | |||
196 | {u"" SC_UNONAME_CHEIGHT"CharHeight", ATTR_FONT_HEIGHT, cppu::UnoType<float>::get(), 0, MID_FONTHEIGHT1 | CONVERT_TWIPS0x80 }, | |||
197 | {u"" SC_UNO_CJK_CHEIGHT"CharHeightAsian", ATTR_CJK_FONT_HEIGHT,cppu::UnoType<float>::get(), 0, MID_FONTHEIGHT1 | CONVERT_TWIPS0x80 }, | |||
198 | {u"" SC_UNO_CTL_CHEIGHT"CharHeightComplex", ATTR_CTL_FONT_HEIGHT,cppu::UnoType<float>::get(), 0, MID_FONTHEIGHT1 | CONVERT_TWIPS0x80 }, | |||
199 | {u"" SC_UNONAME_CLOCAL"CharLocale", ATTR_FONT_LANGUAGE, cppu::UnoType<lang::Locale>::get(), 0, MID_LANG_LOCALE1 }, | |||
200 | {u"" SC_UNO_CJK_CLOCAL"CharLocaleAsian", ATTR_CJK_FONT_LANGUAGE,cppu::UnoType<lang::Locale>::get(), 0, MID_LANG_LOCALE1 }, | |||
201 | {u"" SC_UNO_CTL_CLOCAL"CharLocaleComplex", ATTR_CTL_FONT_LANGUAGE,cppu::UnoType<lang::Locale>::get(), 0, MID_LANG_LOCALE1 }, | |||
202 | {u"" SC_UNONAME_COVER"CharOverline", ATTR_FONT_OVERLINE, cppu::UnoType<sal_Int16>::get(), 0, MID_TL_STYLE1 }, | |||
203 | {u"" SC_UNONAME_COVRLCOL"CharOverlineColor", ATTR_FONT_OVERLINE, cppu::UnoType<sal_Int32>::get(), 0, MID_TL_COLOR2 }, | |||
204 | {u"" SC_UNONAME_COVRLHAS"CharOverlineHasColor", ATTR_FONT_OVERLINE, cppu::UnoType<bool>::get(), 0, MID_TL_HASCOLOR3 }, | |||
205 | {u"" SC_UNONAME_CPOST"CharPosture", ATTR_FONT_POSTURE, cppu::UnoType<awt::FontSlant>::get(), 0, MID_POSTURE1 }, | |||
206 | {u"" SC_UNO_CJK_CPOST"CharPostureAsian", ATTR_CJK_FONT_POSTURE,cppu::UnoType<awt::FontSlant>::get(), 0, MID_POSTURE1 }, | |||
207 | {u"" SC_UNO_CTL_CPOST"CharPostureComplex", ATTR_CTL_FONT_POSTURE,cppu::UnoType<awt::FontSlant>::get(), 0, MID_POSTURE1 }, | |||
208 | {u"" SC_UNONAME_CRELIEF"CharRelief", ATTR_FONT_RELIEF, cppu::UnoType<sal_Int16>::get(), 0, MID_RELIEF0 }, | |||
209 | {u"" SC_UNONAME_CSHADD"CharShadowed", ATTR_FONT_SHADOWED, cppu::UnoType<bool>::get(), 0, 0 }, | |||
210 | {u"" SC_UNONAME_CSTRIKE"CharStrikeout", ATTR_FONT_CROSSEDOUT,cppu::UnoType<sal_Int16>::get(), 0, MID_CROSS_OUT1 }, | |||
211 | {u"" SC_UNONAME_CUNDER"CharUnderline", ATTR_FONT_UNDERLINE,cppu::UnoType<sal_Int16>::get(), 0, MID_TL_STYLE1 }, | |||
212 | {u"" SC_UNONAME_CUNDLCOL"CharUnderlineColor", ATTR_FONT_UNDERLINE,cppu::UnoType<sal_Int32>::get(), 0, MID_TL_COLOR2 }, | |||
213 | {u"" SC_UNONAME_CUNDLHAS"CharUnderlineHasColor", ATTR_FONT_UNDERLINE,cppu::UnoType<bool>::get(), 0, MID_TL_HASCOLOR3 }, | |||
214 | {u"" SC_UNONAME_CWEIGHT"CharWeight", ATTR_FONT_WEIGHT, cppu::UnoType<float>::get(), 0, MID_WEIGHT1 }, | |||
215 | {u"" SC_UNO_CJK_CWEIGHT"CharWeightAsian", ATTR_CJK_FONT_WEIGHT,cppu::UnoType<float>::get(), 0, MID_WEIGHT1 }, | |||
216 | {u"" SC_UNO_CTL_CWEIGHT"CharWeightComplex", ATTR_CTL_FONT_WEIGHT,cppu::UnoType<float>::get(), 0, MID_WEIGHT1 }, | |||
217 | {u"" SC_UNONAME_CWORDMOD"CharWordMode", ATTR_FONT_WORDLINE, cppu::UnoType<bool>::get(), 0, 0 }, | |||
218 | {u"" SC_UNONAME_CHCOLHDR"ChartColumnAsLabel", SC_WID_UNO_CHCOLHDR( 1200 + 1 ),cppu::UnoType<bool>::get(), 0, 0 }, | |||
219 | {u"" SC_UNONAME_CHROWHDR"ChartRowAsLabel", SC_WID_UNO_CHROWHDR( 1200 + 2 ),cppu::UnoType<bool>::get(), 0, 0 }, | |||
220 | {u"" SC_UNONAME_CONDFMT"ConditionalFormat", SC_WID_UNO_CONDFMT( 1200 + 3 ), cppu::UnoType<sheet::XSheetConditionalEntries>::get(), 0, 0 }, | |||
221 | {u"" SC_UNONAME_CONDLOC"ConditionalFormatLocal", SC_WID_UNO_CONDLOC( 1200 + 4 ), cppu::UnoType<sheet::XSheetConditionalEntries>::get(), 0, 0 }, | |||
222 | {u"" SC_UNONAME_CONDXML"ConditionalFormatXML", SC_WID_UNO_CONDXML( 1200 + 5 ), cppu::UnoType<sheet::XSheetConditionalEntries>::get(), 0, 0 }, | |||
223 | {u"" SC_UNONAME_DIAGONAL_BLTR"DiagonalBLTR", ATTR_BORDER_BLTR, ::cppu::UnoType<table::BorderLine>::get(), 0, 0 | CONVERT_TWIPS0x80 }, | |||
224 | {u"" SC_UNONAME_DIAGONAL_BLTR2"DiagonalBLTR2", ATTR_BORDER_BLTR, ::cppu::UnoType<table::BorderLine2>::get(), 0, 0 | CONVERT_TWIPS0x80 }, | |||
225 | {u"" SC_UNONAME_DIAGONAL_TLBR"DiagonalTLBR", ATTR_BORDER_TLBR, ::cppu::UnoType<table::BorderLine>::get(), 0, 0 | CONVERT_TWIPS0x80 }, | |||
226 | {u"" SC_UNONAME_DIAGONAL_TLBR2"DiagonalTLBR2", ATTR_BORDER_TLBR, ::cppu::UnoType<table::BorderLine2>::get(), 0, 0 | CONVERT_TWIPS0x80 }, | |||
227 | {u"" SC_UNONAME_CELLHJUS"HoriJustify", ATTR_HOR_JUSTIFY, cppu::UnoType<table::CellHoriJustify>::get(), 0, MID_HORJUST_HORJUST0 }, | |||
228 | {u"" SC_UNONAME_CELLHJUS_METHOD"HoriJustifyMethod", ATTR_HOR_JUSTIFY_METHOD, ::cppu::UnoType<sal_Int32>::get(), 0, 0 }, | |||
229 | {u"" SC_UNONAME_CELLTRAN"IsCellBackgroundTransparent", ATTR_BACKGROUND, cppu::UnoType<bool>::get(), 0, MID_GRAPHIC_TRANSPARENT3 }, | |||
230 | {u"" SC_UNONAME_WRAP"IsTextWrapped", ATTR_LINEBREAK, cppu::UnoType<bool>::get(), 0, 0 }, | |||
231 | {u"" SC_UNONAME_LEFTBORDER"LeftBorder",ATTR_BORDER, ::cppu::UnoType<table::BorderLine>::get(), 0, LEFT_BORDER1 | CONVERT_TWIPS0x80 }, | |||
232 | {u"" SC_UNONAME_LEFTBORDER2"LeftBorder2",ATTR_BORDER, ::cppu::UnoType<table::BorderLine2>::get(), 0, LEFT_BORDER1 | CONVERT_TWIPS0x80 }, | |||
233 | {u"" SC_UNONAME_NUMFMT"NumberFormat", ATTR_VALUE_FORMAT, cppu::UnoType<sal_Int32>::get(), 0, 0 }, | |||
234 | {u"" SC_UNONAME_NUMRULES"NumberingRules", SC_WID_UNO_NUMRULES( 1200 + 28 ),cppu::UnoType<container::XIndexReplace>::get(), 0, 0 }, | |||
235 | {u"" SC_UNONAME_CELLORI"Orientation", ATTR_STACKED, cppu::UnoType<table::CellOrientation>::get(), 0, 0 }, | |||
236 | {u"" SC_UNONAME_PADJUST"ParaAdjust", ATTR_HOR_JUSTIFY, ::cppu::UnoType<sal_Int16>::get(), 0, MID_HORJUST_ADJUST1 }, | |||
237 | {u"" SC_UNONAME_PBMARGIN"ParaBottomMargin", ATTR_MARGIN, cppu::UnoType<sal_Int32>::get(), 0, MID_MARGIN_LO_MARGIN5 | CONVERT_TWIPS0x80 }, | |||
238 | {u"" SC_UNONAME_PINDENT"ParaIndent", ATTR_INDENT, cppu::UnoType<sal_Int16>::get(), 0, 0 }, //! CONVERT_TWIPS | |||
239 | {u"" SC_UNONAME_PISCHDIST"ParaIsCharacterDistance",ATTR_SCRIPTSPACE, cppu::UnoType<bool>::get(), 0, 0 }, | |||
240 | {u"" SC_UNONAME_PISFORBID"ParaIsForbiddenRules",ATTR_FORBIDDEN_RULES,cppu::UnoType<bool>::get(), 0, 0 }, | |||
241 | {u"" SC_UNONAME_PISHANG"ParaIsHangingPunctuation", ATTR_HANGPUNCTUATION,cppu::UnoType<bool>::get(), 0, 0 }, | |||
242 | {u"" SC_UNONAME_PISHYPHEN"ParaIsHyphenation",ATTR_HYPHENATE, cppu::UnoType<bool>::get(), 0, 0 }, | |||
243 | {u"" SC_UNONAME_PLASTADJ"ParaLastLineAdjust", ATTR_HOR_JUSTIFY, ::cppu::UnoType<sal_Int16>::get(), 0, MID_HORJUST_ADJUST1 }, | |||
244 | {u"" SC_UNONAME_PLMARGIN"ParaLeftMargin", ATTR_MARGIN, cppu::UnoType<sal_Int32>::get(), 0, MID_MARGIN_L_MARGIN2 | CONVERT_TWIPS0x80 }, | |||
245 | {u"" SC_UNONAME_PRMARGIN"ParaRightMargin", ATTR_MARGIN, cppu::UnoType<sal_Int32>::get(), 0, MID_MARGIN_R_MARGIN3 | CONVERT_TWIPS0x80 }, | |||
246 | {u"" SC_UNONAME_PTMARGIN"ParaTopMargin", ATTR_MARGIN, cppu::UnoType<sal_Int32>::get(), 0, MID_MARGIN_UP_MARGIN4 | CONVERT_TWIPS0x80 }, | |||
247 | {u"" SC_UNONAME_RIGHTBORDER"RightBorder",ATTR_BORDER, ::cppu::UnoType<table::BorderLine>::get(), 0, RIGHT_BORDER2 | CONVERT_TWIPS0x80 }, | |||
248 | {u"" SC_UNONAME_RIGHTBORDER2"RightBorder2",ATTR_BORDER, ::cppu::UnoType<table::BorderLine2>::get(), 0, RIGHT_BORDER2 | CONVERT_TWIPS0x80 }, | |||
249 | {u"" SC_UNONAME_ROTANG"RotateAngle", ATTR_ROTATE_VALUE, cppu::UnoType<sal_Int32>::get(), 0, 0 }, | |||
250 | {u"" SC_UNONAME_ROTREF"RotateReference", ATTR_ROTATE_MODE, cppu::UnoType<sal_Int32>::get(), 0, 0 }, | |||
251 | {u"" SC_UNONAME_SHADOW"ShadowFormat", ATTR_SHADOW, cppu::UnoType<table::ShadowFormat>::get(), 0, 0 | CONVERT_TWIPS0x80 }, | |||
252 | {u"" SC_UNONAME_SHRINK_TO_FIT"ShrinkToFit", ATTR_SHRINKTOFIT, cppu::UnoType<bool>::get(), 0, 0 }, | |||
253 | {u"" SC_UNONAME_TBLBORD"TableBorder", SC_WID_UNO_TBLBORD( 1200 + 6 ), cppu::UnoType<table::TableBorder>::get(), 0, 0 | CONVERT_TWIPS0x80 }, | |||
254 | {u"" SC_UNONAME_TBLBORD2"TableBorder2", SC_WID_UNO_TBLBORD2( 1200 + 43 ), cppu::UnoType<table::TableBorder2>::get(), 0, 0 | CONVERT_TWIPS0x80 }, | |||
255 | {u"" SC_UNONAME_TOPBORDER"TopBorder",ATTR_BORDER, ::cppu::UnoType<table::BorderLine>::get(), 0, TOP_BORDER3 | CONVERT_TWIPS0x80 }, | |||
256 | {u"" SC_UNONAME_TOPBORDER2"TopBorder2",ATTR_BORDER, ::cppu::UnoType<table::BorderLine2>::get(), 0, TOP_BORDER3 | CONVERT_TWIPS0x80 }, | |||
257 | {u"" SC_UNONAME_USERDEF"UserDefinedAttributes", ATTR_USERDEF, cppu::UnoType<container::XNameContainer>::get(), 0, 0 }, | |||
258 | {u"" SC_UNONAME_VALIDAT"Validation", SC_WID_UNO_VALIDAT( 1200 + 7 ), cppu::UnoType<beans::XPropertySet>::get(), 0, 0 }, | |||
259 | {u"" SC_UNONAME_VALILOC"ValidationLocal", SC_WID_UNO_VALILOC( 1200 + 8 ), cppu::UnoType<beans::XPropertySet>::get(), 0, 0 }, | |||
260 | {u"" SC_UNONAME_VALIXML"ValidationXML", SC_WID_UNO_VALIXML( 1200 + 9 ), cppu::UnoType<beans::XPropertySet>::get(), 0, 0 }, | |||
261 | {u"" SC_UNONAME_CELLVJUS"VertJustify", ATTR_VER_JUSTIFY, cppu::UnoType<sal_Int32>::get(), 0, 0 }, | |||
262 | {u"" SC_UNONAME_CELLVJUS_METHOD"VertJustifyMethod", ATTR_VER_JUSTIFY_METHOD, ::cppu::UnoType<sal_Int32>::get(), 0, 0 }, | |||
263 | {u"" SC_UNONAME_WRITING"WritingMode", ATTR_WRITINGDIR, cppu::UnoType<sal_Int16>::get(), 0, 0 }, | |||
264 | {u"" SC_UNONAME_HYPERLINK"Hyperlink", ATTR_HYPERLINK, cppu::UnoType<OUString>::get(), 0, 0 }, | |||
265 | {u"" SC_UNONAME_FORMATID"FormatID", SC_WID_UNO_FORMATID( 1200 + 45 ), cppu::UnoType<sal_uInt64>::get(), 0, 0 }, | |||
266 | { u"", 0, css::uno::Type(), 0, 0 } | |||
267 | }; | |||
268 | static SfxItemPropertySet aCellsPropertySet( aCellsPropertyMap_Impl ); | |||
269 | return &aCellsPropertySet; | |||
270 | } | |||
271 | ||||
272 | // CellRange contains all entries from Cells, plus its own entries | |||
273 | // with Which-ID 0 (those are needed only for getPropertySetInfo). | |||
274 | ||||
275 | static const SfxItemPropertySet* lcl_GetRangePropertySet() | |||
276 | { | |||
277 | static const SfxItemPropertyMapEntry aRangePropertyMap_Impl[] = | |||
278 | { | |||
279 | {u"" SC_UNONAME_ABSNAME"AbsoluteName", SC_WID_UNO_ABSNAME( 1200 + 39 ), cppu::UnoType<OUString>::get(), 0 | beans::PropertyAttribute::READONLY, 0 }, | |||
280 | {u"" SC_UNONAME_ASIANVERT"AsianVerticalMode",ATTR_VERTICAL_ASIAN,cppu::UnoType<bool>::get(), 0, 0 }, | |||
281 | {u"" SC_UNONAME_BOTTBORDER"BottomBorder",ATTR_BORDER, ::cppu::UnoType<table::BorderLine>::get(), 0, BOTTOM_BORDER4 | CONVERT_TWIPS0x80 }, | |||
282 | {u"" SC_UNONAME_BOTTBORDER2"BottomBorder2",ATTR_BORDER, ::cppu::UnoType<table::BorderLine2>::get(), 0, BOTTOM_BORDER4 | CONVERT_TWIPS0x80 }, | |||
283 | {u"" SC_UNONAME_CELLBACK"CellBackColor", ATTR_BACKGROUND, cppu::UnoType<sal_Int32>::get(), 0, MID_BACK_COLOR0 }, | |||
284 | {u"" SC_UNONAME_CELLPRO"CellProtection", ATTR_PROTECTION, cppu::UnoType<util::CellProtection>::get(), 0, 0 }, | |||
285 | {u"" SC_UNONAME_CELLSTYL"CellStyle", SC_WID_UNO_CELLSTYL( 1200 + 0 ),cppu::UnoType<OUString>::get(), 0, 0 }, | |||
286 | {u"" SC_UNONAME_CCOLOR"CharColor", ATTR_FONT_COLOR, cppu::UnoType<sal_Int32>::get(), 0, 0 }, | |||
287 | {u"" SC_UNONAME_COUTL"CharContoured", ATTR_FONT_CONTOUR, cppu::UnoType<bool>::get(), 0, 0 }, | |||
288 | {u"" SC_UNONAME_CCROSS"CharCrossedOut", ATTR_FONT_CROSSEDOUT,cppu::UnoType<bool>::get(), 0, MID_CROSSED_OUT0 }, | |||
289 | {u"" SC_UNONAME_CEMPHAS"CharEmphasis", ATTR_FONT_EMPHASISMARK,cppu::UnoType<sal_Int16>::get(), 0, MID_EMPHASIS0 }, | |||
290 | {u"" SC_UNONAME_CFONT"CharFont", ATTR_FONT, cppu::UnoType<sal_Int16>::get(), 0, MID_FONT_FAMILY3 }, | |||
291 | {u"" SC_UNONAME_CFCHARS"CharFontCharSet", ATTR_FONT, cppu::UnoType<sal_Int16>::get(), 0, MID_FONT_CHAR_SET4 }, | |||
292 | {u"" SC_UNO_CJK_CFCHARS"CharFontCharSetAsian", ATTR_CJK_FONT, cppu::UnoType<sal_Int16>::get(), 0, MID_FONT_CHAR_SET4 }, | |||
293 | {u"" SC_UNO_CTL_CFCHARS"CharFontCharSetComplex", ATTR_CTL_FONT, cppu::UnoType<sal_Int16>::get(), 0, MID_FONT_CHAR_SET4 }, | |||
294 | {u"" SC_UNONAME_CFFAMIL"CharFontFamily", ATTR_FONT, cppu::UnoType<sal_Int16>::get(), 0, MID_FONT_FAMILY3 }, | |||
295 | {u"" SC_UNO_CJK_CFFAMIL"CharFontFamilyAsian", ATTR_CJK_FONT, cppu::UnoType<sal_Int16>::get(), 0, MID_FONT_FAMILY3 }, | |||
296 | {u"" SC_UNO_CTL_CFFAMIL"CharFontFamilyComplex", ATTR_CTL_FONT, cppu::UnoType<sal_Int16>::get(), 0, MID_FONT_FAMILY3 }, | |||
297 | {u"" SC_UNONAME_CFNAME"CharFontName", ATTR_FONT, cppu::UnoType<OUString>::get(), 0, MID_FONT_FAMILY_NAME1 }, | |||
298 | {u"" SC_UNO_CJK_CFNAME"CharFontNameAsian", ATTR_CJK_FONT, cppu::UnoType<OUString>::get(), 0, MID_FONT_FAMILY_NAME1 }, | |||
299 | {u"" SC_UNO_CTL_CFNAME"CharFontNameComplex", ATTR_CTL_FONT, cppu::UnoType<OUString>::get(), 0, MID_FONT_FAMILY_NAME1 }, | |||
300 | {u"" SC_UNONAME_CFPITCH"CharFontPitch", ATTR_FONT, cppu::UnoType<sal_Int16>::get(), 0, MID_FONT_PITCH5 }, | |||
301 | {u"" SC_UNO_CJK_CFPITCH"CharFontPitchAsian", ATTR_CJK_FONT, cppu::UnoType<sal_Int16>::get(), 0, MID_FONT_PITCH5 }, | |||
302 | {u"" SC_UNO_CTL_CFPITCH"CharFontPitchComplex", ATTR_CTL_FONT, cppu::UnoType<sal_Int16>::get(), 0, MID_FONT_PITCH5 }, | |||
303 | {u"" SC_UNONAME_CFSTYLE"CharFontStyleName", ATTR_FONT, cppu::UnoType<OUString>::get(), 0, MID_FONT_STYLE_NAME2 }, | |||
304 | {u"" SC_UNO_CJK_CFSTYLE"CharFontStyleNameAsian", ATTR_CJK_FONT, cppu::UnoType<OUString>::get(), 0, MID_FONT_STYLE_NAME2 }, | |||
305 | {u"" SC_UNO_CTL_CFSTYLE"CharFontStyleNameComplex", ATTR_CTL_FONT, cppu::UnoType<OUString>::get(), 0, MID_FONT_STYLE_NAME2 }, | |||
306 | {u"" SC_UNONAME_CHEIGHT"CharHeight", ATTR_FONT_HEIGHT, cppu::UnoType<float>::get(), 0, MID_FONTHEIGHT1 | CONVERT_TWIPS0x80 }, | |||
307 | {u"" SC_UNO_CJK_CHEIGHT"CharHeightAsian", ATTR_CJK_FONT_HEIGHT,cppu::UnoType<float>::get(), 0, MID_FONTHEIGHT1 | CONVERT_TWIPS0x80 }, | |||
308 | {u"" SC_UNO_CTL_CHEIGHT"CharHeightComplex", ATTR_CTL_FONT_HEIGHT,cppu::UnoType<float>::get(), 0, MID_FONTHEIGHT1 | CONVERT_TWIPS0x80 }, | |||
309 | {u"" SC_UNONAME_CLOCAL"CharLocale", ATTR_FONT_LANGUAGE, cppu::UnoType<lang::Locale>::get(), 0, MID_LANG_LOCALE1 }, | |||
310 | {u"" SC_UNO_CJK_CLOCAL"CharLocaleAsian", ATTR_CJK_FONT_LANGUAGE,cppu::UnoType<lang::Locale>::get(), 0, MID_LANG_LOCALE1 }, | |||
311 | {u"" SC_UNO_CTL_CLOCAL"CharLocaleComplex", ATTR_CTL_FONT_LANGUAGE,cppu::UnoType<lang::Locale>::get(), 0, MID_LANG_LOCALE1 }, | |||
312 | {u"" SC_UNONAME_COVER"CharOverline", ATTR_FONT_OVERLINE, cppu::UnoType<sal_Int16>::get(), 0, MID_TL_STYLE1 }, | |||
313 | {u"" SC_UNONAME_COVRLCOL"CharOverlineColor", ATTR_FONT_OVERLINE, cppu::UnoType<sal_Int32>::get(), 0, MID_TL_COLOR2 }, | |||
314 | {u"" SC_UNONAME_COVRLHAS"CharOverlineHasColor", ATTR_FONT_OVERLINE, cppu::UnoType<bool>::get(), 0, MID_TL_HASCOLOR3 }, | |||
315 | {u"" SC_UNONAME_CPOST"CharPosture", ATTR_FONT_POSTURE, cppu::UnoType<awt::FontSlant>::get(), 0, MID_POSTURE1 }, | |||
316 | {u"" SC_UNO_CJK_CPOST"CharPostureAsian", ATTR_CJK_FONT_POSTURE,cppu::UnoType<awt::FontSlant>::get(), 0, MID_POSTURE1 }, | |||
317 | {u"" SC_UNO_CTL_CPOST"CharPostureComplex", ATTR_CTL_FONT_POSTURE,cppu::UnoType<awt::FontSlant>::get(), 0, MID_POSTURE1 }, | |||
318 | {u"" SC_UNONAME_CRELIEF"CharRelief", ATTR_FONT_RELIEF, cppu::UnoType<sal_Int16>::get(), 0, MID_RELIEF0 }, | |||
319 | {u"" SC_UNONAME_CSHADD"CharShadowed", ATTR_FONT_SHADOWED, cppu::UnoType<bool>::get(), 0, 0 }, | |||
320 | {u"" SC_UNONAME_CSTRIKE"CharStrikeout", ATTR_FONT_CROSSEDOUT,cppu::UnoType<sal_Int16>::get(), 0, MID_CROSS_OUT1 }, | |||
321 | {u"" SC_UNONAME_CUNDER"CharUnderline", ATTR_FONT_UNDERLINE,cppu::UnoType<sal_Int16>::get(), 0, MID_TL_STYLE1 }, | |||
322 | {u"" SC_UNONAME_CUNDLCOL"CharUnderlineColor", ATTR_FONT_UNDERLINE,cppu::UnoType<sal_Int32>::get(), 0, MID_TL_COLOR2 }, | |||
323 | {u"" SC_UNONAME_CUNDLHAS"CharUnderlineHasColor", ATTR_FONT_UNDERLINE,cppu::UnoType<bool>::get(), 0, MID_TL_HASCOLOR3 }, | |||
324 | {u"" SC_UNONAME_CWEIGHT"CharWeight", ATTR_FONT_WEIGHT, cppu::UnoType<float>::get(), 0, MID_WEIGHT1 }, | |||
325 | {u"" SC_UNO_CJK_CWEIGHT"CharWeightAsian", ATTR_CJK_FONT_WEIGHT,cppu::UnoType<float>::get(), 0, MID_WEIGHT1 }, | |||
326 | {u"" SC_UNO_CTL_CWEIGHT"CharWeightComplex", ATTR_CTL_FONT_WEIGHT,cppu::UnoType<float>::get(), 0, MID_WEIGHT1 }, | |||
327 | {u"" SC_UNONAME_CWORDMOD"CharWordMode", ATTR_FONT_WORDLINE, cppu::UnoType<bool>::get(), 0, 0 }, | |||
328 | {u"" SC_UNONAME_CHCOLHDR"ChartColumnAsLabel", SC_WID_UNO_CHCOLHDR( 1200 + 1 ),cppu::UnoType<bool>::get(), 0, 0 }, | |||
329 | {u"" SC_UNONAME_CHROWHDR"ChartRowAsLabel", SC_WID_UNO_CHROWHDR( 1200 + 2 ),cppu::UnoType<bool>::get(), 0, 0 }, | |||
330 | {u"" SC_UNONAME_CONDFMT"ConditionalFormat", SC_WID_UNO_CONDFMT( 1200 + 3 ), cppu::UnoType<sheet::XSheetConditionalEntries>::get(), 0, 0 }, | |||
331 | {u"" SC_UNONAME_CONDLOC"ConditionalFormatLocal", SC_WID_UNO_CONDLOC( 1200 + 4 ), cppu::UnoType<sheet::XSheetConditionalEntries>::get(), 0, 0 }, | |||
332 | {u"" SC_UNONAME_CONDXML"ConditionalFormatXML", SC_WID_UNO_CONDXML( 1200 + 5 ), cppu::UnoType<sheet::XSheetConditionalEntries>::get(), 0, 0 }, | |||
333 | {u"" SC_UNONAME_DIAGONAL_BLTR"DiagonalBLTR", ATTR_BORDER_BLTR, ::cppu::UnoType<table::BorderLine>::get(), 0, 0 | CONVERT_TWIPS0x80 }, | |||
334 | {u"" SC_UNONAME_DIAGONAL_BLTR2"DiagonalBLTR2", ATTR_BORDER_BLTR, ::cppu::UnoType<table::BorderLine2>::get(), 0, 0 | CONVERT_TWIPS0x80 }, | |||
335 | {u"" SC_UNONAME_DIAGONAL_TLBR"DiagonalTLBR", ATTR_BORDER_TLBR, ::cppu::UnoType<table::BorderLine>::get(), 0, 0 | CONVERT_TWIPS0x80 }, | |||
336 | {u"" SC_UNONAME_DIAGONAL_TLBR2"DiagonalTLBR2", ATTR_BORDER_TLBR, ::cppu::UnoType<table::BorderLine2>::get(), 0, 0 | CONVERT_TWIPS0x80 }, | |||
337 | {u"" SC_UNONAME_CELLHJUS"HoriJustify", ATTR_HOR_JUSTIFY, cppu::UnoType<table::CellHoriJustify>::get(), 0, MID_HORJUST_HORJUST0 }, | |||
338 | {u"" SC_UNONAME_CELLHJUS_METHOD"HoriJustifyMethod", ATTR_HOR_JUSTIFY_METHOD, ::cppu::UnoType<sal_Int32>::get(), 0, 0 }, | |||
339 | {u"" SC_UNONAME_CELLTRAN"IsCellBackgroundTransparent", ATTR_BACKGROUND, cppu::UnoType<bool>::get(), 0, MID_GRAPHIC_TRANSPARENT3 }, | |||
340 | {u"" SC_UNONAME_WRAP"IsTextWrapped", ATTR_LINEBREAK, cppu::UnoType<bool>::get(), 0, 0 }, | |||
341 | {u"" SC_UNONAME_LEFTBORDER"LeftBorder",ATTR_BORDER, ::cppu::UnoType<table::BorderLine>::get(), 0, LEFT_BORDER1 | CONVERT_TWIPS0x80 }, | |||
342 | {u"" SC_UNONAME_LEFTBORDER2"LeftBorder2",ATTR_BORDER, ::cppu::UnoType<table::BorderLine2>::get(), 0, LEFT_BORDER1 | CONVERT_TWIPS0x80 }, | |||
343 | {u"" SC_UNONAME_NUMFMT"NumberFormat", ATTR_VALUE_FORMAT, cppu::UnoType<sal_Int32>::get(), 0, 0 }, | |||
344 | {u"" SC_UNONAME_NUMRULES"NumberingRules", SC_WID_UNO_NUMRULES( 1200 + 28 ),cppu::UnoType<container::XIndexReplace>::get(), 0, 0 }, | |||
345 | {u"" SC_UNONAME_CELLORI"Orientation", ATTR_STACKED, cppu::UnoType<table::CellOrientation>::get(), 0, 0 }, | |||
346 | {u"" SC_UNONAME_PADJUST"ParaAdjust", ATTR_HOR_JUSTIFY, ::cppu::UnoType<sal_Int16>::get(), 0, MID_HORJUST_ADJUST1 }, | |||
347 | {u"" SC_UNONAME_PBMARGIN"ParaBottomMargin", ATTR_MARGIN, cppu::UnoType<sal_Int32>::get(), 0, MID_MARGIN_LO_MARGIN5 | CONVERT_TWIPS0x80 }, | |||
348 | {u"" SC_UNONAME_PINDENT"ParaIndent", ATTR_INDENT, cppu::UnoType<sal_Int16>::get(), 0, 0 }, //! CONVERT_TWIPS | |||
349 | {u"" SC_UNONAME_PISCHDIST"ParaIsCharacterDistance",ATTR_SCRIPTSPACE, cppu::UnoType<bool>::get(), 0, 0 }, | |||
350 | {u"" SC_UNONAME_PISFORBID"ParaIsForbiddenRules",ATTR_FORBIDDEN_RULES,cppu::UnoType<bool>::get(), 0, 0 }, | |||
351 | {u"" SC_UNONAME_PISHANG"ParaIsHangingPunctuation", ATTR_HANGPUNCTUATION,cppu::UnoType<bool>::get(), 0, 0 }, | |||
352 | {u"" SC_UNONAME_PISHYPHEN"ParaIsHyphenation",ATTR_HYPHENATE, cppu::UnoType<bool>::get(), 0, 0 }, | |||
353 | {u"" SC_UNONAME_PLASTADJ"ParaLastLineAdjust", ATTR_HOR_JUSTIFY, ::cppu::UnoType<sal_Int16>::get(), 0, MID_HORJUST_ADJUST1 }, | |||
354 | {u"" SC_UNONAME_PLMARGIN"ParaLeftMargin", ATTR_MARGIN, cppu::UnoType<sal_Int32>::get(), 0, MID_MARGIN_L_MARGIN2 | CONVERT_TWIPS0x80 }, | |||
355 | {u"" SC_UNONAME_PRMARGIN"ParaRightMargin", ATTR_MARGIN, cppu::UnoType<sal_Int32>::get(), 0, MID_MARGIN_R_MARGIN3 | CONVERT_TWIPS0x80 }, | |||
356 | {u"" SC_UNONAME_PTMARGIN"ParaTopMargin", ATTR_MARGIN, cppu::UnoType<sal_Int32>::get(), 0, MID_MARGIN_UP_MARGIN4 | CONVERT_TWIPS0x80 }, | |||
357 | {u"" SC_UNONAME_POS"Position", SC_WID_UNO_POS( 1200 + 10 ), cppu::UnoType<awt::Point>::get(), 0 | beans::PropertyAttribute::READONLY, 0 }, | |||
358 | {u"" SC_UNONAME_RIGHTBORDER"RightBorder",ATTR_BORDER, ::cppu::UnoType<table::BorderLine>::get(), 0, RIGHT_BORDER2 | CONVERT_TWIPS0x80 }, | |||
359 | {u"" SC_UNONAME_RIGHTBORDER2"RightBorder2",ATTR_BORDER, ::cppu::UnoType<table::BorderLine2>::get(), 0, RIGHT_BORDER2 | CONVERT_TWIPS0x80 }, | |||
360 | {u"" SC_UNONAME_ROTANG"RotateAngle", ATTR_ROTATE_VALUE, cppu::UnoType<sal_Int32>::get(), 0, 0 }, | |||
361 | {u"" SC_UNONAME_ROTREF"RotateReference", ATTR_ROTATE_MODE, cppu::UnoType<sal_Int32>::get(), 0, 0 }, | |||
362 | {u"" SC_UNONAME_SHADOW"ShadowFormat", ATTR_SHADOW, cppu::UnoType<table::ShadowFormat>::get(), 0, 0 | CONVERT_TWIPS0x80 }, | |||
363 | {u"" SC_UNONAME_SHRINK_TO_FIT"ShrinkToFit", ATTR_SHRINKTOFIT, cppu::UnoType<bool>::get(), 0, 0 }, | |||
364 | {u"" SC_UNONAME_SIZE"Size", SC_WID_UNO_SIZE( 1200 + 11 ), cppu::UnoType<awt::Size>::get(), 0 | beans::PropertyAttribute::READONLY, 0 }, | |||
365 | {u"" SC_UNONAME_TBLBORD"TableBorder", SC_WID_UNO_TBLBORD( 1200 + 6 ), cppu::UnoType<table::TableBorder>::get(), 0, 0 | CONVERT_TWIPS0x80 }, | |||
366 | {u"" SC_UNONAME_TBLBORD2"TableBorder2", SC_WID_UNO_TBLBORD2( 1200 + 43 ), cppu::UnoType<table::TableBorder2>::get(), 0, 0 | CONVERT_TWIPS0x80 }, | |||
367 | {u"" SC_UNONAME_TOPBORDER"TopBorder",ATTR_BORDER, ::cppu::UnoType<table::BorderLine>::get(), 0, TOP_BORDER3 | CONVERT_TWIPS0x80 }, | |||
368 | {u"" SC_UNONAME_TOPBORDER2"TopBorder2",ATTR_BORDER, ::cppu::UnoType<table::BorderLine2>::get(), 0, TOP_BORDER3 | CONVERT_TWIPS0x80 }, | |||
369 | {u"" SC_UNONAME_USERDEF"UserDefinedAttributes", ATTR_USERDEF, cppu::UnoType<container::XNameContainer>::get(), 0, 0 }, | |||
370 | {u"" SC_UNONAME_VALIDAT"Validation", SC_WID_UNO_VALIDAT( 1200 + 7 ), cppu::UnoType<beans::XPropertySet>::get(), 0, 0 }, | |||
371 | {u"" SC_UNONAME_VALILOC"ValidationLocal", SC_WID_UNO_VALILOC( 1200 + 8 ), cppu::UnoType<beans::XPropertySet>::get(), 0, 0 }, | |||
372 | {u"" SC_UNONAME_VALIXML"ValidationXML", SC_WID_UNO_VALIXML( 1200 + 9 ), cppu::UnoType<beans::XPropertySet>::get(), 0, 0 }, | |||
373 | {u"" SC_UNONAME_CELLVJUS"VertJustify", ATTR_VER_JUSTIFY, cppu::UnoType<sal_Int32>::get(), 0, 0 }, | |||
374 | {u"" SC_UNONAME_CELLVJUS_METHOD"VertJustifyMethod", ATTR_VER_JUSTIFY_METHOD, ::cppu::UnoType<sal_Int32>::get(), 0, 0 }, | |||
375 | {u"" SC_UNONAME_WRITING"WritingMode", ATTR_WRITINGDIR, cppu::UnoType<sal_Int16>::get(), 0, 0 }, | |||
376 | {u"" SC_UNONAME_FORMATID"FormatID", SC_WID_UNO_FORMATID( 1200 + 45 ), cppu::UnoType<sal_uInt64>::get(), 0, 0 }, | |||
377 | { u"", 0, css::uno::Type(), 0, 0 } | |||
378 | }; | |||
379 | static SfxItemPropertySet aRangePropertySet( aRangePropertyMap_Impl ); | |||
380 | return &aRangePropertySet; | |||
381 | } | |||
382 | ||||
383 | // Cell contains entries from CellRange, plus its own entries | |||
384 | // with Which-ID 0 (those are needed only for getPropertySetInfo). | |||
385 | ||||
386 | static const SfxItemPropertySet* lcl_GetCellPropertySet() | |||
387 | { | |||
388 | static const SfxItemPropertyMapEntry aCellPropertyMap_Impl[] = | |||
389 | { | |||
390 | {u"" SC_UNONAME_ABSNAME"AbsoluteName", SC_WID_UNO_ABSNAME( 1200 + 39 ), cppu::UnoType<OUString>::get(), 0 | beans::PropertyAttribute::READONLY, 0 }, | |||
391 | {u"" SC_UNONAME_ASIANVERT"AsianVerticalMode",ATTR_VERTICAL_ASIAN,cppu::UnoType<bool>::get(), 0, 0 }, | |||
392 | {u"" SC_UNONAME_BOTTBORDER"BottomBorder",ATTR_BORDER, ::cppu::UnoType<table::BorderLine>::get(), 0, BOTTOM_BORDER4 | CONVERT_TWIPS0x80 }, | |||
393 | {u"" SC_UNONAME_BOTTBORDER2"BottomBorder2",ATTR_BORDER, ::cppu::UnoType<table::BorderLine2>::get(), 0, BOTTOM_BORDER4 | CONVERT_TWIPS0x80 }, | |||
394 | {u"" SC_UNONAME_CELLBACK"CellBackColor", ATTR_BACKGROUND, cppu::UnoType<sal_Int32>::get(), 0, MID_BACK_COLOR0 }, | |||
395 | {u"" SC_UNONAME_CELLPRO"CellProtection", ATTR_PROTECTION, cppu::UnoType<util::CellProtection>::get(), 0, 0 }, | |||
396 | {u"" SC_UNONAME_CELLSTYL"CellStyle", SC_WID_UNO_CELLSTYL( 1200 + 0 ),cppu::UnoType<OUString>::get(), 0, 0 }, | |||
397 | {u"" SC_UNONAME_CCOLOR"CharColor", ATTR_FONT_COLOR, cppu::UnoType<sal_Int32>::get(), 0, 0 }, | |||
398 | {u"" SC_UNONAME_COUTL"CharContoured", ATTR_FONT_CONTOUR, cppu::UnoType<bool>::get(), 0, 0 }, | |||
399 | {u"" SC_UNONAME_CCROSS"CharCrossedOut", ATTR_FONT_CROSSEDOUT,cppu::UnoType<bool>::get(), 0, MID_CROSSED_OUT0 }, | |||
400 | {u"" SC_UNONAME_CEMPHAS"CharEmphasis", ATTR_FONT_EMPHASISMARK,cppu::UnoType<sal_Int16>::get(), 0, MID_EMPHASIS0 }, | |||
401 | {u"" SC_UNONAME_CFONT"CharFont", ATTR_FONT, cppu::UnoType<sal_Int16>::get(), 0, MID_FONT_FAMILY3 }, | |||
402 | {u"" SC_UNONAME_CFCHARS"CharFontCharSet", ATTR_FONT, cppu::UnoType<sal_Int16>::get(), 0, MID_FONT_CHAR_SET4 }, | |||
403 | {u"" SC_UNO_CJK_CFCHARS"CharFontCharSetAsian", ATTR_CJK_FONT, cppu::UnoType<sal_Int16>::get(), 0, MID_FONT_CHAR_SET4 }, | |||
404 | {u"" SC_UNO_CTL_CFCHARS"CharFontCharSetComplex", ATTR_CTL_FONT, cppu::UnoType<sal_Int16>::get(), 0, MID_FONT_CHAR_SET4 }, | |||
405 | {u"" SC_UNONAME_CFFAMIL"CharFontFamily", ATTR_FONT, cppu::UnoType<sal_Int16>::get(), 0, MID_FONT_FAMILY3 }, | |||
406 | {u"" SC_UNO_CJK_CFFAMIL"CharFontFamilyAsian", ATTR_CJK_FONT, cppu::UnoType<sal_Int16>::get(), 0, MID_FONT_FAMILY3 }, | |||
407 | {u"" SC_UNO_CTL_CFFAMIL"CharFontFamilyComplex", ATTR_CTL_FONT, cppu::UnoType<sal_Int16>::get(), 0, MID_FONT_FAMILY3 }, | |||
408 | {u"" SC_UNONAME_CFNAME"CharFontName", ATTR_FONT, cppu::UnoType<OUString>::get(), 0, MID_FONT_FAMILY_NAME1 }, | |||
409 | {u"" SC_UNO_CJK_CFNAME"CharFontNameAsian", ATTR_CJK_FONT, cppu::UnoType<OUString>::get(), 0, MID_FONT_FAMILY_NAME1 }, | |||
410 | {u"" SC_UNO_CTL_CFNAME"CharFontNameComplex", ATTR_CTL_FONT, cppu::UnoType<OUString>::get(), 0, MID_FONT_FAMILY_NAME1 }, | |||
411 | {u"" SC_UNONAME_CFPITCH"CharFontPitch", ATTR_FONT, cppu::UnoType<sal_Int16>::get(), 0, MID_FONT_PITCH5 }, | |||
412 | {u"" SC_UNO_CJK_CFPITCH"CharFontPitchAsian", ATTR_CJK_FONT, cppu::UnoType<sal_Int16>::get(), 0, MID_FONT_PITCH5 }, | |||
413 | {u"" SC_UNO_CTL_CFPITCH"CharFontPitchComplex", ATTR_CTL_FONT, cppu::UnoType<sal_Int16>::get(), 0, MID_FONT_PITCH5 }, | |||
414 | {u"" SC_UNONAME_CFSTYLE"CharFontStyleName", ATTR_FONT, cppu::UnoType<OUString>::get(), 0, MID_FONT_STYLE_NAME2 }, | |||
415 | {u"" SC_UNO_CJK_CFSTYLE"CharFontStyleNameAsian", ATTR_CJK_FONT, cppu::UnoType<OUString>::get(), 0, MID_FONT_STYLE_NAME2 }, | |||
416 | {u"" SC_UNO_CTL_CFSTYLE"CharFontStyleNameComplex", ATTR_CTL_FONT, cppu::UnoType<OUString>::get(), 0, MID_FONT_STYLE_NAME2 }, | |||
417 | {u"" SC_UNONAME_CHEIGHT"CharHeight", ATTR_FONT_HEIGHT, cppu::UnoType<float>::get(), 0, MID_FONTHEIGHT1 | CONVERT_TWIPS0x80 }, | |||
418 | {u"" SC_UNO_CJK_CHEIGHT"CharHeightAsian", ATTR_CJK_FONT_HEIGHT,cppu::UnoType<float>::get(), 0, MID_FONTHEIGHT1 | CONVERT_TWIPS0x80 }, | |||
419 | {u"" SC_UNO_CTL_CHEIGHT"CharHeightComplex", ATTR_CTL_FONT_HEIGHT,cppu::UnoType<float>::get(), 0, MID_FONTHEIGHT1 | CONVERT_TWIPS0x80 }, | |||
420 | {u"" SC_UNONAME_CLOCAL"CharLocale", ATTR_FONT_LANGUAGE, cppu::UnoType<lang::Locale>::get(), 0, MID_LANG_LOCALE1 }, | |||
421 | {u"" SC_UNO_CJK_CLOCAL"CharLocaleAsian", ATTR_CJK_FONT_LANGUAGE,cppu::UnoType<lang::Locale>::get(), 0, MID_LANG_LOCALE1 }, | |||
422 | {u"" SC_UNO_CTL_CLOCAL"CharLocaleComplex", ATTR_CTL_FONT_LANGUAGE,cppu::UnoType<lang::Locale>::get(), 0, MID_LANG_LOCALE1 }, | |||
423 | {u"" SC_UNONAME_COVER"CharOverline", ATTR_FONT_OVERLINE, cppu::UnoType<sal_Int16>::get(), 0, MID_TL_STYLE1 }, | |||
424 | {u"" SC_UNONAME_COVRLCOL"CharOverlineColor", ATTR_FONT_OVERLINE, cppu::UnoType<sal_Int32>::get(), 0, MID_TL_COLOR2 }, | |||
425 | {u"" SC_UNONAME_COVRLHAS"CharOverlineHasColor", ATTR_FONT_OVERLINE, cppu::UnoType<bool>::get(), 0, MID_TL_HASCOLOR3 }, | |||
426 | {u"" SC_UNONAME_CPOST"CharPosture", ATTR_FONT_POSTURE, cppu::UnoType<awt::FontSlant>::get(), 0, MID_POSTURE1 }, | |||
427 | {u"" SC_UNO_CJK_CPOST"CharPostureAsian", ATTR_CJK_FONT_POSTURE,cppu::UnoType<awt::FontSlant>::get(), 0, MID_POSTURE1 }, | |||
428 | {u"" SC_UNO_CTL_CPOST"CharPostureComplex", ATTR_CTL_FONT_POSTURE,cppu::UnoType<awt::FontSlant>::get(), 0, MID_POSTURE1 }, | |||
429 | {u"" SC_UNONAME_CRELIEF"CharRelief", ATTR_FONT_RELIEF, cppu::UnoType<sal_Int16>::get(), 0, MID_RELIEF0 }, | |||
430 | {u"" SC_UNONAME_CSHADD"CharShadowed", ATTR_FONT_SHADOWED, cppu::UnoType<bool>::get(), 0, 0 }, | |||
431 | {u"" SC_UNONAME_CSTRIKE"CharStrikeout", ATTR_FONT_CROSSEDOUT,cppu::UnoType<sal_Int16>::get(), 0, MID_CROSS_OUT1 }, | |||
432 | {u"" SC_UNONAME_CUNDER"CharUnderline", ATTR_FONT_UNDERLINE,cppu::UnoType<sal_Int16>::get(), 0, MID_TL_STYLE1 }, | |||
433 | {u"" SC_UNONAME_CUNDLCOL"CharUnderlineColor", ATTR_FONT_UNDERLINE,cppu::UnoType<sal_Int32>::get(), 0, MID_TL_COLOR2 }, | |||
434 | {u"" SC_UNONAME_CUNDLHAS"CharUnderlineHasColor", ATTR_FONT_UNDERLINE,cppu::UnoType<bool>::get(), 0, MID_TL_HASCOLOR3 }, | |||
435 | {u"" SC_UNONAME_CWEIGHT"CharWeight", ATTR_FONT_WEIGHT, cppu::UnoType<float>::get(), 0, MID_WEIGHT1 }, | |||
436 | {u"" SC_UNO_CJK_CWEIGHT"CharWeightAsian", ATTR_CJK_FONT_WEIGHT,cppu::UnoType<float>::get(), 0, MID_WEIGHT1 }, | |||
437 | {u"" SC_UNO_CTL_CWEIGHT"CharWeightComplex", ATTR_CTL_FONT_WEIGHT,cppu::UnoType<float>::get(), 0, MID_WEIGHT1 }, | |||
438 | {u"" SC_UNONAME_CWORDMOD"CharWordMode", ATTR_FONT_WORDLINE, cppu::UnoType<bool>::get(), 0, 0 }, | |||
439 | {u"" SC_UNONAME_CHCOLHDR"ChartColumnAsLabel", SC_WID_UNO_CHCOLHDR( 1200 + 1 ),cppu::UnoType<bool>::get(), 0, 0 }, | |||
440 | {u"" SC_UNONAME_CHROWHDR"ChartRowAsLabel", SC_WID_UNO_CHROWHDR( 1200 + 2 ),cppu::UnoType<bool>::get(), 0, 0 }, | |||
441 | {u"" SC_UNONAME_CONDFMT"ConditionalFormat", SC_WID_UNO_CONDFMT( 1200 + 3 ), cppu::UnoType<sheet::XSheetConditionalEntries>::get(), 0, 0 }, | |||
442 | {u"" SC_UNONAME_CONDLOC"ConditionalFormatLocal", SC_WID_UNO_CONDLOC( 1200 + 4 ), cppu::UnoType<sheet::XSheetConditionalEntries>::get(), 0, 0 }, | |||
443 | {u"" SC_UNONAME_CONDXML"ConditionalFormatXML", SC_WID_UNO_CONDXML( 1200 + 5 ), cppu::UnoType<sheet::XSheetConditionalEntries>::get(), 0, 0 }, | |||
444 | {u"" SC_UNONAME_DIAGONAL_BLTR"DiagonalBLTR", ATTR_BORDER_BLTR, ::cppu::UnoType<table::BorderLine>::get(), 0, 0 | CONVERT_TWIPS0x80 }, | |||
445 | {u"" SC_UNONAME_DIAGONAL_BLTR2"DiagonalBLTR2", ATTR_BORDER_BLTR, ::cppu::UnoType<table::BorderLine2>::get(), 0, 0 | CONVERT_TWIPS0x80 }, | |||
446 | {u"" SC_UNONAME_DIAGONAL_TLBR"DiagonalTLBR", ATTR_BORDER_TLBR, ::cppu::UnoType<table::BorderLine>::get(), 0, 0 | CONVERT_TWIPS0x80 }, | |||
447 | {u"" SC_UNONAME_DIAGONAL_TLBR2"DiagonalTLBR2", ATTR_BORDER_TLBR, ::cppu::UnoType<table::BorderLine2>::get(), 0, 0 | CONVERT_TWIPS0x80 }, | |||
448 | {u"" SC_UNONAME_FORMLOC"FormulaLocal", SC_WID_UNO_FORMLOC( 1200 + 12 ), cppu::UnoType<OUString>::get(), 0, 0 }, | |||
449 | {u"" SC_UNONAME_FORMRT"FormulaResultType", SC_WID_UNO_FORMRT( 1200 + 13 ), cppu::UnoType<table::CellContentType>::get(), 0 | beans::PropertyAttribute::READONLY, 0 }, | |||
450 | {u"" SC_UNONAME_CELLCONTENTTYPE"CellContentType", SC_WID_UNO_CELLCONTENTTYPE( 1200 + 47 ), cppu::UnoType<table::CellContentType>::get(), 0 | beans::PropertyAttribute::READONLY, 0 }, | |||
451 | {u"" SC_UNONAME_FORMRT2"FormulaResultType2", SC_WID_UNO_FORMRT2( 1200 + 46 ), cppu::UnoType<sal_Int32>::get(), 0 | beans::PropertyAttribute::READONLY, 0 }, | |||
452 | {u"" SC_UNONAME_CELLHJUS"HoriJustify", ATTR_HOR_JUSTIFY, cppu::UnoType<table::CellHoriJustify>::get(), 0, MID_HORJUST_HORJUST0 }, | |||
453 | {u"" SC_UNONAME_CELLHJUS_METHOD"HoriJustifyMethod", ATTR_HOR_JUSTIFY_METHOD, ::cppu::UnoType<sal_Int32>::get(), 0, 0 }, | |||
454 | {u"" SC_UNONAME_CELLTRAN"IsCellBackgroundTransparent", ATTR_BACKGROUND, cppu::UnoType<bool>::get(), 0, MID_GRAPHIC_TRANSPARENT3 }, | |||
455 | {u"" SC_UNONAME_WRAP"IsTextWrapped", ATTR_LINEBREAK, cppu::UnoType<bool>::get(), 0, 0 }, | |||
456 | {u"" SC_UNONAME_LEFTBORDER"LeftBorder",ATTR_BORDER, ::cppu::UnoType<table::BorderLine>::get(), 0, LEFT_BORDER1 | CONVERT_TWIPS0x80 }, | |||
457 | {u"" SC_UNONAME_LEFTBORDER2"LeftBorder2",ATTR_BORDER, ::cppu::UnoType<table::BorderLine2>::get(), 0, LEFT_BORDER1 | CONVERT_TWIPS0x80 }, | |||
458 | {u"" SC_UNONAME_NUMFMT"NumberFormat", ATTR_VALUE_FORMAT, cppu::UnoType<sal_Int32>::get(), 0, 0 }, | |||
459 | {u"" SC_UNONAME_NUMRULES"NumberingRules", SC_WID_UNO_NUMRULES( 1200 + 28 ),cppu::UnoType<container::XIndexReplace>::get(), 0, 0 }, | |||
460 | {u"" SC_UNONAME_CELLORI"Orientation", ATTR_STACKED, cppu::UnoType<table::CellOrientation>::get(), 0, 0 }, | |||
461 | {u"" SC_UNONAME_PADJUST"ParaAdjust", ATTR_HOR_JUSTIFY, ::cppu::UnoType<sal_Int16>::get(), 0, MID_HORJUST_ADJUST1 }, | |||
462 | {u"" SC_UNONAME_PBMARGIN"ParaBottomMargin", ATTR_MARGIN, cppu::UnoType<sal_Int32>::get(), 0, MID_MARGIN_LO_MARGIN5 | CONVERT_TWIPS0x80 }, | |||
463 | {u"" SC_UNONAME_PINDENT"ParaIndent", ATTR_INDENT, cppu::UnoType<sal_Int16>::get(), 0, 0 }, //! CONVERT_TWIPS | |||
464 | {u"" SC_UNONAME_PISCHDIST"ParaIsCharacterDistance",ATTR_SCRIPTSPACE, cppu::UnoType<bool>::get(), 0, 0 }, | |||
465 | {u"" SC_UNONAME_PISFORBID"ParaIsForbiddenRules",ATTR_FORBIDDEN_RULES,cppu::UnoType<bool>::get(), 0, 0 }, | |||
466 | {u"" SC_UNONAME_PISHANG"ParaIsHangingPunctuation", ATTR_HANGPUNCTUATION,cppu::UnoType<bool>::get(), 0, 0 }, | |||
467 | {u"" SC_UNONAME_PISHYPHEN"ParaIsHyphenation",ATTR_HYPHENATE, cppu::UnoType<bool>::get(), 0, 0 }, | |||
468 | {u"" SC_UNONAME_PLASTADJ"ParaLastLineAdjust", ATTR_HOR_JUSTIFY, ::cppu::UnoType<sal_Int16>::get(), 0, MID_HORJUST_ADJUST1 }, | |||
469 | {u"" SC_UNONAME_PLMARGIN"ParaLeftMargin", ATTR_MARGIN, cppu::UnoType<sal_Int32>::get(), 0, MID_MARGIN_L_MARGIN2 | CONVERT_TWIPS0x80 }, | |||
470 | {u"" SC_UNONAME_PRMARGIN"ParaRightMargin", ATTR_MARGIN, cppu::UnoType<sal_Int32>::get(), 0, MID_MARGIN_R_MARGIN3 | CONVERT_TWIPS0x80 }, | |||
471 | {u"" SC_UNONAME_PTMARGIN"ParaTopMargin", ATTR_MARGIN, cppu::UnoType<sal_Int32>::get(), 0, MID_MARGIN_UP_MARGIN4 | CONVERT_TWIPS0x80 }, | |||
472 | {u"" SC_UNONAME_POS"Position", SC_WID_UNO_POS( 1200 + 10 ), cppu::UnoType<awt::Point>::get(), 0 | beans::PropertyAttribute::READONLY, 0 }, | |||
473 | {u"" SC_UNONAME_RIGHTBORDER"RightBorder",ATTR_BORDER, ::cppu::UnoType<table::BorderLine>::get(), 0, RIGHT_BORDER2 | CONVERT_TWIPS0x80 }, | |||
474 | {u"" SC_UNONAME_RIGHTBORDER2"RightBorder2",ATTR_BORDER, ::cppu::UnoType<table::BorderLine2>::get(), 0, RIGHT_BORDER2 | CONVERT_TWIPS0x80 }, | |||
475 | {u"" SC_UNONAME_ROTANG"RotateAngle", ATTR_ROTATE_VALUE, cppu::UnoType<sal_Int32>::get(), 0, 0 }, | |||
476 | {u"" SC_UNONAME_ROTREF"RotateReference", ATTR_ROTATE_MODE, cppu::UnoType<sal_Int32>::get(), 0, 0 }, | |||
477 | {u"" SC_UNONAME_SHADOW"ShadowFormat", ATTR_SHADOW, cppu::UnoType<table::ShadowFormat>::get(), 0, 0 | CONVERT_TWIPS0x80 }, | |||
478 | {u"" SC_UNONAME_SHRINK_TO_FIT"ShrinkToFit", ATTR_SHRINKTOFIT, cppu::UnoType<bool>::get(), 0, 0 }, | |||
479 | {u"" SC_UNONAME_SIZE"Size", SC_WID_UNO_SIZE( 1200 + 11 ), cppu::UnoType<awt::Size>::get(), 0 | beans::PropertyAttribute::READONLY, 0 }, | |||
480 | {u"" SC_UNONAME_TBLBORD"TableBorder", SC_WID_UNO_TBLBORD( 1200 + 6 ), cppu::UnoType<table::TableBorder>::get(), 0, 0 | CONVERT_TWIPS0x80 }, | |||
481 | {u"" SC_UNONAME_TBLBORD2"TableBorder2", SC_WID_UNO_TBLBORD2( 1200 + 43 ), cppu::UnoType<table::TableBorder2>::get(), 0, 0 | CONVERT_TWIPS0x80 }, | |||
482 | {u"" SC_UNONAME_TOPBORDER"TopBorder",ATTR_BORDER, ::cppu::UnoType<table::BorderLine>::get(), 0, TOP_BORDER3 | CONVERT_TWIPS0x80 }, | |||
483 | {u"" SC_UNONAME_TOPBORDER2"TopBorder2",ATTR_BORDER, ::cppu::UnoType<table::BorderLine2>::get(), 0, TOP_BORDER3 | CONVERT_TWIPS0x80 }, | |||
484 | {u"" SC_UNONAME_USERDEF"UserDefinedAttributes", ATTR_USERDEF, cppu::UnoType<container::XNameContainer>::get(), 0, 0 }, | |||
485 | {u"" SC_UNONAME_VALIDAT"Validation", SC_WID_UNO_VALIDAT( 1200 + 7 ), cppu::UnoType<beans::XPropertySet>::get(), 0, 0 }, | |||
486 | {u"" SC_UNONAME_VALILOC"ValidationLocal", SC_WID_UNO_VALILOC( 1200 + 8 ), cppu::UnoType<beans::XPropertySet>::get(), 0, 0 }, | |||
487 | {u"" SC_UNONAME_VALIXML"ValidationXML", SC_WID_UNO_VALIXML( 1200 + 9 ), cppu::UnoType<beans::XPropertySet>::get(), 0, 0 }, | |||
488 | {u"" SC_UNONAME_CELLVJUS"VertJustify", ATTR_VER_JUSTIFY, cppu::UnoType<sal_Int32>::get(), 0, 0 }, | |||
489 | {u"" SC_UNONAME_CELLVJUS_METHOD"VertJustifyMethod", ATTR_VER_JUSTIFY_METHOD, ::cppu::UnoType<sal_Int32>::get(), 0, 0 }, | |||
490 | {u"" SC_UNONAME_WRITING"WritingMode", ATTR_WRITINGDIR, cppu::UnoType<sal_Int16>::get(), 0, 0 }, | |||
491 | {u"" UNO_NAME_EDIT_CHAR_ESCAPEMENT"CharEscapement", EE_CHAR_ESCAPEMENT, cppu::UnoType<sal_Int32>::get(), 0, 0 }, | |||
492 | {u"" SC_UNONAME_HYPERLINK"Hyperlink", ATTR_HYPERLINK, cppu::UnoType<OUString>::get(), 0, 0 }, | |||
493 | {u"" SC_UNONAME_FORMATID"FormatID", SC_WID_UNO_FORMATID( 1200 + 45 ), cppu::UnoType<sal_uInt64>::get(), 0, 0 }, | |||
494 | { u"", 0, css::uno::Type(), 0, 0 } | |||
495 | }; | |||
496 | static SfxItemPropertySet aCellPropertySet( aCellPropertyMap_Impl ); | |||
497 | return &aCellPropertySet; | |||
498 | } | |||
499 | ||||
500 | // Column and Row contain all entries from CellRange, plus its own entries | |||
501 | // with Which-ID 0 (those are needed only for getPropertySetInfo). | |||
502 | ||||
503 | static const SfxItemPropertySet* lcl_GetColumnPropertySet() | |||
504 | { | |||
505 | static const SfxItemPropertyMapEntry aColumnPropertyMap_Impl[] = | |||
506 | { | |||
507 | {u"" SC_UNONAME_ABSNAME"AbsoluteName", SC_WID_UNO_ABSNAME( 1200 + 39 ), cppu::UnoType<OUString>::get(), 0 | beans::PropertyAttribute::READONLY, 0 }, | |||
508 | {u"" SC_UNONAME_ASIANVERT"AsianVerticalMode",ATTR_VERTICAL_ASIAN,cppu::UnoType<bool>::get(), 0, 0 }, | |||
509 | {u"" SC_UNONAME_BOTTBORDER"BottomBorder",ATTR_BORDER, ::cppu::UnoType<table::BorderLine>::get(), 0, BOTTOM_BORDER4 | CONVERT_TWIPS0x80 }, | |||
510 | {u"" SC_UNONAME_BOTTBORDER2"BottomBorder2",ATTR_BORDER, ::cppu::UnoType<table::BorderLine2>::get(), 0, BOTTOM_BORDER4 | CONVERT_TWIPS0x80 }, | |||
511 | {u"" SC_UNONAME_CELLBACK"CellBackColor", ATTR_BACKGROUND, cppu::UnoType<sal_Int32>::get(), 0, MID_BACK_COLOR0 }, | |||
512 | {u"" SC_UNONAME_CELLPRO"CellProtection", ATTR_PROTECTION, cppu::UnoType<util::CellProtection>::get(), 0, 0 }, | |||
513 | {u"" SC_UNONAME_CELLSTYL"CellStyle", SC_WID_UNO_CELLSTYL( 1200 + 0 ),cppu::UnoType<OUString>::get(), 0, 0 }, | |||
514 | {u"" SC_UNONAME_CCOLOR"CharColor", ATTR_FONT_COLOR, cppu::UnoType<sal_Int32>::get(), 0, 0 }, | |||
515 | {u"" SC_UNONAME_COUTL"CharContoured", ATTR_FONT_CONTOUR, cppu::UnoType<bool>::get(), 0, 0 }, | |||
516 | {u"" SC_UNONAME_CCROSS"CharCrossedOut", ATTR_FONT_CROSSEDOUT,cppu::UnoType<bool>::get(), 0, MID_CROSSED_OUT0 }, | |||
517 | {u"" SC_UNONAME_CEMPHAS"CharEmphasis", ATTR_FONT_EMPHASISMARK,cppu::UnoType<sal_Int16>::get(), 0, MID_EMPHASIS0 }, | |||
518 | {u"" SC_UNONAME_CFONT"CharFont", ATTR_FONT, cppu::UnoType<sal_Int16>::get(), 0, MID_FONT_FAMILY3 }, | |||
519 | {u"" SC_UNONAME_CFCHARS"CharFontCharSet", ATTR_FONT, cppu::UnoType<sal_Int16>::get(), 0, MID_FONT_CHAR_SET4 }, | |||
520 | {u"" SC_UNO_CJK_CFCHARS"CharFontCharSetAsian", ATTR_CJK_FONT, cppu::UnoType<sal_Int16>::get(), 0, MID_FONT_CHAR_SET4 }, | |||
521 | {u"" SC_UNO_CTL_CFCHARS"CharFontCharSetComplex", ATTR_CTL_FONT, cppu::UnoType<sal_Int16>::get(), 0, MID_FONT_CHAR_SET4 }, | |||
522 | {u"" SC_UNONAME_CFFAMIL"CharFontFamily", ATTR_FONT, cppu::UnoType<sal_Int16>::get(), 0, MID_FONT_FAMILY3 }, | |||
523 | {u"" SC_UNO_CJK_CFFAMIL"CharFontFamilyAsian", ATTR_CJK_FONT, cppu::UnoType<sal_Int16>::get(), 0, MID_FONT_FAMILY3 }, | |||
524 | {u"" SC_UNO_CTL_CFFAMIL"CharFontFamilyComplex", ATTR_CTL_FONT, cppu::UnoType<sal_Int16>::get(), 0, MID_FONT_FAMILY3 }, | |||
525 | {u"" SC_UNONAME_CFNAME"CharFontName", ATTR_FONT, cppu::UnoType<OUString>::get(), 0, MID_FONT_FAMILY_NAME1 }, | |||
526 | {u"" SC_UNO_CJK_CFNAME"CharFontNameAsian", ATTR_CJK_FONT, cppu::UnoType<OUString>::get(), 0, MID_FONT_FAMILY_NAME1 }, | |||
527 | {u"" SC_UNO_CTL_CFNAME"CharFontNameComplex", ATTR_CTL_FONT, cppu::UnoType<OUString>::get(), 0, MID_FONT_FAMILY_NAME1 }, | |||
528 | {u"" SC_UNONAME_CFPITCH"CharFontPitch", ATTR_FONT, cppu::UnoType<sal_Int16>::get(), 0, MID_FONT_PITCH5 }, | |||
529 | {u"" SC_UNO_CJK_CFPITCH"CharFontPitchAsian", ATTR_CJK_FONT, cppu::UnoType<sal_Int16>::get(), 0, MID_FONT_PITCH5 }, | |||
530 | {u"" SC_UNO_CTL_CFPITCH"CharFontPitchComplex", ATTR_CTL_FONT, cppu::UnoType<sal_Int16>::get(), 0, MID_FONT_PITCH5 }, | |||
531 | {u"" SC_UNONAME_CFSTYLE"CharFontStyleName", ATTR_FONT, cppu::UnoType<OUString>::get(), 0, MID_FONT_STYLE_NAME2 }, | |||
532 | {u"" SC_UNO_CJK_CFSTYLE"CharFontStyleNameAsian", ATTR_CJK_FONT, cppu::UnoType<OUString>::get(), 0, MID_FONT_STYLE_NAME2 }, | |||
533 | {u"" SC_UNO_CTL_CFSTYLE"CharFontStyleNameComplex", ATTR_CTL_FONT, cppu::UnoType<OUString>::get(), 0, MID_FONT_STYLE_NAME2 }, | |||
534 | {u"" SC_UNONAME_CHEIGHT"CharHeight", ATTR_FONT_HEIGHT, cppu::UnoType<float>::get(), 0, MID_FONTHEIGHT1 | CONVERT_TWIPS0x80 }, | |||
535 | {u"" SC_UNO_CJK_CHEIGHT"CharHeightAsian", ATTR_CJK_FONT_HEIGHT,cppu::UnoType<float>::get(), 0, MID_FONTHEIGHT1 | CONVERT_TWIPS0x80 }, | |||
536 | {u"" SC_UNO_CTL_CHEIGHT"CharHeightComplex", ATTR_CTL_FONT_HEIGHT,cppu::UnoType<float>::get(), 0, MID_FONTHEIGHT1 | CONVERT_TWIPS0x80 }, | |||
537 | {u"" SC_UNONAME_CLOCAL"CharLocale", ATTR_FONT_LANGUAGE, cppu::UnoType<lang::Locale>::get(), 0, MID_LANG_LOCALE1 }, | |||
538 | {u"" SC_UNO_CJK_CLOCAL"CharLocaleAsian", ATTR_CJK_FONT_LANGUAGE,cppu::UnoType<lang::Locale>::get(), 0, MID_LANG_LOCALE1 }, | |||
539 | {u"" SC_UNO_CTL_CLOCAL"CharLocaleComplex", ATTR_CTL_FONT_LANGUAGE,cppu::UnoType<lang::Locale>::get(), 0, MID_LANG_LOCALE1 }, | |||
540 | {u"" SC_UNONAME_COVER"CharOverline", ATTR_FONT_OVERLINE, cppu::UnoType<sal_Int16>::get(), 0, MID_TL_STYLE1 }, | |||
541 | {u"" SC_UNONAME_COVRLCOL"CharOverlineColor", ATTR_FONT_OVERLINE, cppu::UnoType<sal_Int32>::get(), 0, MID_TL_COLOR2 }, | |||
542 | {u"" SC_UNONAME_COVRLHAS"CharOverlineHasColor", ATTR_FONT_OVERLINE, cppu::UnoType<bool>::get(), 0, MID_TL_HASCOLOR3 }, | |||
543 | {u"" SC_UNONAME_CPOST"CharPosture", ATTR_FONT_POSTURE, cppu::UnoType<awt::FontSlant>::get(), 0, MID_POSTURE1 }, | |||
544 | {u"" SC_UNO_CJK_CPOST"CharPostureAsian", ATTR_CJK_FONT_POSTURE,cppu::UnoType<awt::FontSlant>::get(), 0, MID_POSTURE1 }, | |||
545 | {u"" SC_UNO_CTL_CPOST"CharPostureComplex", ATTR_CTL_FONT_POSTURE,cppu::UnoType<awt::FontSlant>::get(), 0, MID_POSTURE1 }, | |||
546 | {u"" SC_UNONAME_CRELIEF"CharRelief", ATTR_FONT_RELIEF, cppu::UnoType<sal_Int16>::get(), 0, MID_RELIEF0 }, | |||
547 | {u"" SC_UNONAME_CSHADD"CharShadowed", ATTR_FONT_SHADOWED, cppu::UnoType<bool>::get(), 0, 0 }, | |||
548 | {u"" SC_UNONAME_CSTRIKE"CharStrikeout", ATTR_FONT_CROSSEDOUT,cppu::UnoType<sal_Int16>::get(), 0, MID_CROSS_OUT1 }, | |||
549 | {u"" SC_UNONAME_CUNDER"CharUnderline", ATTR_FONT_UNDERLINE,cppu::UnoType<sal_Int16>::get(), 0, MID_TL_STYLE1 }, | |||
550 | {u"" SC_UNONAME_CUNDLCOL"CharUnderlineColor", ATTR_FONT_UNDERLINE,cppu::UnoType<sal_Int32>::get(), 0, MID_TL_COLOR2 }, | |||
551 | {u"" SC_UNONAME_CUNDLHAS"CharUnderlineHasColor", ATTR_FONT_UNDERLINE,cppu::UnoType<bool>::get(), 0, MID_TL_HASCOLOR3 }, | |||
552 | {u"" SC_UNONAME_CWEIGHT"CharWeight", ATTR_FONT_WEIGHT, cppu::UnoType<float>::get(), 0, MID_WEIGHT1 }, | |||
553 | {u"" SC_UNO_CJK_CWEIGHT"CharWeightAsian", ATTR_CJK_FONT_WEIGHT,cppu::UnoType<float>::get(), 0, MID_WEIGHT1 }, | |||
554 | {u"" SC_UNO_CTL_CWEIGHT"CharWeightComplex", ATTR_CTL_FONT_WEIGHT,cppu::UnoType<float>::get(), 0, MID_WEIGHT1 }, | |||
555 | {u"" SC_UNONAME_CWORDMOD"CharWordMode", ATTR_FONT_WORDLINE, cppu::UnoType<bool>::get(), 0, 0 }, | |||
556 | {u"" SC_UNONAME_CHCOLHDR"ChartColumnAsLabel", SC_WID_UNO_CHCOLHDR( 1200 + 1 ),cppu::UnoType<bool>::get(), 0, 0 }, | |||
557 | {u"" SC_UNONAME_CHROWHDR"ChartRowAsLabel", SC_WID_UNO_CHROWHDR( 1200 + 2 ),cppu::UnoType<bool>::get(), 0, 0 }, | |||
558 | {u"" SC_UNONAME_CONDFMT"ConditionalFormat", SC_WID_UNO_CONDFMT( 1200 + 3 ), cppu::UnoType<sheet::XSheetConditionalEntries>::get(), 0, 0 }, | |||
559 | {u"" SC_UNONAME_CONDLOC"ConditionalFormatLocal", SC_WID_UNO_CONDLOC( 1200 + 4 ), cppu::UnoType<sheet::XSheetConditionalEntries>::get(), 0, 0 }, | |||
560 | {u"" SC_UNONAME_CONDXML"ConditionalFormatXML", SC_WID_UNO_CONDXML( 1200 + 5 ), cppu::UnoType<sheet::XSheetConditionalEntries>::get(), 0, 0 }, | |||
561 | {u"" SC_UNONAME_DIAGONAL_BLTR"DiagonalBLTR", ATTR_BORDER_BLTR, ::cppu::UnoType<table::BorderLine>::get(), 0, 0 | CONVERT_TWIPS0x80 }, | |||
562 | {u"" SC_UNONAME_DIAGONAL_BLTR2"DiagonalBLTR2", ATTR_BORDER_BLTR, ::cppu::UnoType<table::BorderLine2>::get(), 0, 0 | CONVERT_TWIPS0x80 }, | |||
563 | {u"" SC_UNONAME_DIAGONAL_TLBR"DiagonalTLBR", ATTR_BORDER_TLBR, ::cppu::UnoType<table::BorderLine>::get(), 0, 0 | CONVERT_TWIPS0x80 }, | |||
564 | {u"" SC_UNONAME_DIAGONAL_TLBR2"DiagonalTLBR2", ATTR_BORDER_TLBR, ::cppu::UnoType<table::BorderLine2>::get(), 0, 0 | CONVERT_TWIPS0x80 }, | |||
565 | {u"" SC_UNONAME_CELLHJUS"HoriJustify", ATTR_HOR_JUSTIFY, cppu::UnoType<table::CellHoriJustify>::get(), 0, MID_HORJUST_HORJUST0 }, | |||
566 | {u"" SC_UNONAME_CELLHJUS_METHOD"HoriJustifyMethod", ATTR_HOR_JUSTIFY_METHOD, ::cppu::UnoType<sal_Int32>::get(), 0, 0 }, | |||
567 | {u"" SC_UNONAME_CELLTRAN"IsCellBackgroundTransparent", ATTR_BACKGROUND, cppu::UnoType<bool>::get(), 0, MID_GRAPHIC_TRANSPARENT3 }, | |||
568 | {u"" SC_UNONAME_MANPAGE"IsManualPageBreak", SC_WID_UNO_MANPAGE( 1200 + 21 ), cppu::UnoType<bool>::get(), 0, 0 }, | |||
569 | {u"" SC_UNONAME_NEWPAGE"IsStartOfNewPage", SC_WID_UNO_NEWPAGE( 1200 + 20 ), cppu::UnoType<bool>::get(), 0, 0 }, | |||
570 | {u"" SC_UNONAME_WRAP"IsTextWrapped", ATTR_LINEBREAK, cppu::UnoType<bool>::get(), 0, 0 }, | |||
571 | {u"" SC_UNONAME_CELLVIS"IsVisible", SC_WID_UNO_CELLVIS( 1200 + 15 ), cppu::UnoType<bool>::get(), 0, 0 }, | |||
572 | {u"" SC_UNONAME_LEFTBORDER"LeftBorder",ATTR_BORDER, ::cppu::UnoType<table::BorderLine>::get(), 0, LEFT_BORDER1 | CONVERT_TWIPS0x80 }, | |||
573 | {u"" SC_UNONAME_LEFTBORDER2"LeftBorder2",ATTR_BORDER, ::cppu::UnoType<table::BorderLine2>::get(), 0, LEFT_BORDER1 | CONVERT_TWIPS0x80 }, | |||
574 | {u"" SC_UNONAME_NUMFMT"NumberFormat", ATTR_VALUE_FORMAT, cppu::UnoType<sal_Int32>::get(), 0, 0 }, | |||
575 | {u"" SC_UNONAME_NUMRULES"NumberingRules", SC_WID_UNO_NUMRULES( 1200 + 28 ),cppu::UnoType<container::XIndexReplace>::get(), 0, 0 }, | |||
576 | {u"" SC_UNONAME_OWIDTH"OptimalWidth", SC_WID_UNO_OWIDTH( 1200 + 19 ), cppu::UnoType<bool>::get(), 0, 0 }, | |||
577 | {u"" SC_UNONAME_CELLORI"Orientation", ATTR_STACKED, cppu::UnoType<table::CellOrientation>::get(), 0, 0 }, | |||
578 | {u"" SC_UNONAME_PADJUST"ParaAdjust", ATTR_HOR_JUSTIFY, ::cppu::UnoType<sal_Int16>::get(), 0, MID_HORJUST_ADJUST1 }, | |||
579 | {u"" SC_UNONAME_PBMARGIN"ParaBottomMargin", ATTR_MARGIN, cppu::UnoType<sal_Int32>::get(), 0, MID_MARGIN_LO_MARGIN5 | CONVERT_TWIPS0x80 }, | |||
580 | {u"" SC_UNONAME_PINDENT"ParaIndent", ATTR_INDENT, cppu::UnoType<sal_Int16>::get(), 0, 0 }, //! CONVERT_TWIPS | |||
581 | {u"" SC_UNONAME_PISCHDIST"ParaIsCharacterDistance",ATTR_SCRIPTSPACE, cppu::UnoType<bool>::get(), 0, 0 }, | |||
582 | {u"" SC_UNONAME_PISFORBID"ParaIsForbiddenRules",ATTR_FORBIDDEN_RULES,cppu::UnoType<bool>::get(), 0, 0 }, | |||
583 | {u"" SC_UNONAME_PISHANG"ParaIsHangingPunctuation", ATTR_HANGPUNCTUATION,cppu::UnoType<bool>::get(), 0, 0 }, | |||
584 | {u"" SC_UNONAME_PISHYPHEN"ParaIsHyphenation",ATTR_HYPHENATE, cppu::UnoType<bool>::get(), 0, 0 }, | |||
585 | {u"" SC_UNONAME_PLASTADJ"ParaLastLineAdjust", ATTR_HOR_JUSTIFY, ::cppu::UnoType<sal_Int16>::get(), 0, MID_HORJUST_ADJUST1 }, | |||
586 | {u"" SC_UNONAME_PLMARGIN"ParaLeftMargin", ATTR_MARGIN, cppu::UnoType<sal_Int32>::get(), 0, MID_MARGIN_L_MARGIN2 | CONVERT_TWIPS0x80 }, | |||
587 | {u"" SC_UNONAME_PRMARGIN"ParaRightMargin", ATTR_MARGIN, cppu::UnoType<sal_Int32>::get(), 0, MID_MARGIN_R_MARGIN3 | CONVERT_TWIPS0x80 }, | |||
588 | {u"" SC_UNONAME_PTMARGIN"ParaTopMargin", ATTR_MARGIN, cppu::UnoType<sal_Int32>::get(), 0, MID_MARGIN_UP_MARGIN4 | CONVERT_TWIPS0x80 }, | |||
589 | {u"" SC_UNONAME_POS"Position", SC_WID_UNO_POS( 1200 + 10 ), cppu::UnoType<awt::Point>::get(), 0 | beans::PropertyAttribute::READONLY, 0 }, | |||
590 | {u"" SC_UNONAME_RIGHTBORDER"RightBorder",ATTR_BORDER, ::cppu::UnoType<table::BorderLine>::get(), 0, RIGHT_BORDER2 | CONVERT_TWIPS0x80 }, | |||
591 | {u"" SC_UNONAME_RIGHTBORDER2"RightBorder2",ATTR_BORDER, ::cppu::UnoType<table::BorderLine2>::get(), 0, RIGHT_BORDER2 | CONVERT_TWIPS0x80 }, | |||
592 | {u"" SC_UNONAME_ROTANG"RotateAngle", ATTR_ROTATE_VALUE, cppu::UnoType<sal_Int32>::get(), 0, 0 }, | |||
593 | {u"" SC_UNONAME_ROTREF"RotateReference", ATTR_ROTATE_MODE, cppu::UnoType<sal_Int32>::get(), 0, 0 }, | |||
594 | {u"" SC_UNONAME_SHADOW"ShadowFormat", ATTR_SHADOW, cppu::UnoType<table::ShadowFormat>::get(), 0, 0 | CONVERT_TWIPS0x80 }, | |||
595 | {u"" SC_UNONAME_SHRINK_TO_FIT"ShrinkToFit", ATTR_SHRINKTOFIT, cppu::UnoType<bool>::get(), 0, 0 }, | |||
596 | {u"" SC_UNONAME_SIZE"Size", SC_WID_UNO_SIZE( 1200 + 11 ), cppu::UnoType<awt::Size>::get(), 0 | beans::PropertyAttribute::READONLY, 0 }, | |||
597 | {u"" SC_UNONAME_TBLBORD"TableBorder", SC_WID_UNO_TBLBORD( 1200 + 6 ), cppu::UnoType<table::TableBorder>::get(), 0, 0 | CONVERT_TWIPS0x80 }, | |||
598 | {u"" SC_UNONAME_TBLBORD2"TableBorder2", SC_WID_UNO_TBLBORD2( 1200 + 43 ), cppu::UnoType<table::TableBorder2>::get(), 0, 0 | CONVERT_TWIPS0x80 }, | |||
599 | {u"" SC_UNONAME_TOPBORDER"TopBorder",ATTR_BORDER, ::cppu::UnoType<table::BorderLine>::get(), 0, TOP_BORDER3 | CONVERT_TWIPS0x80 }, | |||
600 | {u"" SC_UNONAME_TOPBORDER2"TopBorder2",ATTR_BORDER, ::cppu::UnoType<table::BorderLine2>::get(), 0, TOP_BORDER3 | CONVERT_TWIPS0x80 }, | |||
601 | {u"" SC_UNONAME_USERDEF"UserDefinedAttributes", ATTR_USERDEF, cppu::UnoType<container::XNameContainer>::get(), 0, 0 }, | |||
602 | {u"" SC_UNONAME_VALIDAT"Validation", SC_WID_UNO_VALIDAT( 1200 + 7 ), cppu::UnoType<beans::XPropertySet>::get(), 0, 0 }, | |||
603 | {u"" SC_UNONAME_VALILOC"ValidationLocal", SC_WID_UNO_VALILOC( 1200 + 8 ), cppu::UnoType<beans::XPropertySet>::get(), 0, 0 }, | |||
604 | {u"" SC_UNONAME_VALIXML"ValidationXML", SC_WID_UNO_VALIXML( 1200 + 9 ), cppu::UnoType<beans::XPropertySet>::get(), 0, 0 }, | |||
605 | {u"" SC_UNONAME_CELLVJUS"VertJustify", ATTR_VER_JUSTIFY, cppu::UnoType<sal_Int32>::get(), 0, 0 }, | |||
606 | {u"" SC_UNONAME_CELLVJUS_METHOD"VertJustifyMethod", ATTR_VER_JUSTIFY_METHOD, ::cppu::UnoType<sal_Int32>::get(), 0, 0 }, | |||
607 | {u"" SC_UNONAME_CELLWID"Width", SC_WID_UNO_CELLWID( 1200 + 18 ), cppu::UnoType<sal_Int32>::get(), 0, 0 }, | |||
608 | {u"" SC_UNONAME_WRITING"WritingMode", ATTR_WRITINGDIR, cppu::UnoType<sal_Int16>::get(), 0, 0 }, | |||
609 | { u"", 0, css::uno::Type(), 0, 0 } | |||
610 | }; | |||
611 | static SfxItemPropertySet aColumnPropertySet( aColumnPropertyMap_Impl ); | |||
612 | return &aColumnPropertySet; | |||
613 | } | |||
614 | ||||
615 | static const SfxItemPropertySet* lcl_GetRowPropertySet() | |||
616 | { | |||
617 | static const SfxItemPropertyMapEntry aRowPropertyMap_Impl[] = | |||
618 | { | |||
619 | {u"" SC_UNONAME_ABSNAME"AbsoluteName", SC_WID_UNO_ABSNAME( 1200 + 39 ), cppu::UnoType<OUString>::get(), 0 | beans::PropertyAttribute::READONLY, 0 }, | |||
620 | {u"" SC_UNONAME_ASIANVERT"AsianVerticalMode",ATTR_VERTICAL_ASIAN,cppu::UnoType<bool>::get(), 0, 0 }, | |||
621 | {u"" SC_UNONAME_BOTTBORDER"BottomBorder",ATTR_BORDER, ::cppu::UnoType<table::BorderLine>::get(), 0, BOTTOM_BORDER4 | CONVERT_TWIPS0x80 }, | |||
622 | {u"" SC_UNONAME_BOTTBORDER2"BottomBorder2",ATTR_BORDER, ::cppu::UnoType<table::BorderLine2>::get(), 0, BOTTOM_BORDER4 | CONVERT_TWIPS0x80 }, | |||
623 | {u"" SC_UNONAME_CELLBACK"CellBackColor", ATTR_BACKGROUND, cppu::UnoType<sal_Int32>::get(), 0, MID_BACK_COLOR0 }, | |||
624 | {u"" SC_UNONAME_CELLPRO"CellProtection", ATTR_PROTECTION, cppu::UnoType<util::CellProtection>::get(), 0, 0 }, | |||
625 | {u"" SC_UNONAME_CELLSTYL"CellStyle", SC_WID_UNO_CELLSTYL( 1200 + 0 ),cppu::UnoType<OUString>::get(), 0, 0 }, | |||
626 | {u"" SC_UNONAME_CCOLOR"CharColor", ATTR_FONT_COLOR, cppu::UnoType<sal_Int32>::get(), 0, 0 }, | |||
627 | {u"" SC_UNONAME_COUTL"CharContoured", ATTR_FONT_CONTOUR, cppu::UnoType<bool>::get(), 0, 0 }, | |||
628 | {u"" SC_UNONAME_CCROSS"CharCrossedOut", ATTR_FONT_CROSSEDOUT,cppu::UnoType<bool>::get(), 0, MID_CROSSED_OUT0 }, | |||
629 | {u"" SC_UNONAME_CEMPHAS"CharEmphasis", ATTR_FONT_EMPHASISMARK,cppu::UnoType<sal_Int16>::get(), 0, MID_EMPHASIS0 }, | |||
630 | {u"" SC_UNONAME_CFONT"CharFont", ATTR_FONT, cppu::UnoType<sal_Int16>::get(), 0, MID_FONT_FAMILY3 }, | |||
631 | {u"" SC_UNONAME_CFCHARS"CharFontCharSet", ATTR_FONT, cppu::UnoType<sal_Int16>::get(), 0, MID_FONT_CHAR_SET4 }, | |||
632 | {u"" SC_UNO_CJK_CFCHARS"CharFontCharSetAsian", ATTR_CJK_FONT, cppu::UnoType<sal_Int16>::get(), 0, MID_FONT_CHAR_SET4 }, | |||
633 | {u"" SC_UNO_CTL_CFCHARS"CharFontCharSetComplex", ATTR_CTL_FONT, cppu::UnoType<sal_Int16>::get(), 0, MID_FONT_CHAR_SET4 }, | |||
634 | {u"" SC_UNONAME_CFFAMIL"CharFontFamily", ATTR_FONT, cppu::UnoType<sal_Int16>::get(), 0, MID_FONT_FAMILY3 }, | |||
635 | {u"" SC_UNO_CJK_CFFAMIL"CharFontFamilyAsian", ATTR_CJK_FONT, cppu::UnoType<sal_Int16>::get(), 0, MID_FONT_FAMILY3 }, | |||
636 | {u"" SC_UNO_CTL_CFFAMIL"CharFontFamilyComplex", ATTR_CTL_FONT, cppu::UnoType<sal_Int16>::get(), 0, MID_FONT_FAMILY3 }, | |||
637 | {u"" SC_UNONAME_CFNAME"CharFontName", ATTR_FONT, cppu::UnoType<OUString>::get(), 0, MID_FONT_FAMILY_NAME1 }, | |||
638 | {u"" SC_UNO_CJK_CFNAME"CharFontNameAsian", ATTR_CJK_FONT, cppu::UnoType<OUString>::get(), 0, MID_FONT_FAMILY_NAME1 }, | |||
639 | {u"" SC_UNO_CTL_CFNAME"CharFontNameComplex", ATTR_CTL_FONT, cppu::UnoType<OUString>::get(), 0, MID_FONT_FAMILY_NAME1 }, | |||
640 | {u"" SC_UNONAME_CFPITCH"CharFontPitch", ATTR_FONT, cppu::UnoType<sal_Int16>::get(), 0, MID_FONT_PITCH5 }, | |||
641 | {u"" SC_UNO_CJK_CFPITCH"CharFontPitchAsian", ATTR_CJK_FONT, cppu::UnoType<sal_Int16>::get(), 0, MID_FONT_PITCH5 }, | |||
642 | {u"" SC_UNO_CTL_CFPITCH"CharFontPitchComplex", ATTR_CTL_FONT, cppu::UnoType<sal_Int16>::get(), 0, MID_FONT_PITCH5 }, | |||
643 | {u"" SC_UNONAME_CFSTYLE"CharFontStyleName", ATTR_FONT, cppu::UnoType<OUString>::get(), 0, MID_FONT_STYLE_NAME2 }, | |||
644 | {u"" SC_UNO_CJK_CFSTYLE"CharFontStyleNameAsian", ATTR_CJK_FONT, cppu::UnoType<OUString>::get(), 0, MID_FONT_STYLE_NAME2 }, | |||
645 | {u"" SC_UNO_CTL_CFSTYLE"CharFontStyleNameComplex", ATTR_CTL_FONT, cppu::UnoType<OUString>::get(), 0, MID_FONT_STYLE_NAME2 }, | |||
646 | {u"" SC_UNONAME_CHEIGHT"CharHeight", ATTR_FONT_HEIGHT, cppu::UnoType<float>::get(), 0, MID_FONTHEIGHT1 | CONVERT_TWIPS0x80 }, | |||
647 | {u"" SC_UNO_CJK_CHEIGHT"CharHeightAsian", ATTR_CJK_FONT_HEIGHT,cppu::UnoType<float>::get(), 0, MID_FONTHEIGHT1 | CONVERT_TWIPS0x80 }, | |||
648 | {u"" SC_UNO_CTL_CHEIGHT"CharHeightComplex", ATTR_CTL_FONT_HEIGHT,cppu::UnoType<float>::get(), 0, MID_FONTHEIGHT1 | CONVERT_TWIPS0x80 }, | |||
649 | {u"" SC_UNONAME_CLOCAL"CharLocale", ATTR_FONT_LANGUAGE, cppu::UnoType<lang::Locale>::get(), 0, MID_LANG_LOCALE1 }, | |||
650 | {u"" SC_UNO_CJK_CLOCAL"CharLocaleAsian", ATTR_CJK_FONT_LANGUAGE,cppu::UnoType<lang::Locale>::get(), 0, MID_LANG_LOCALE1 }, | |||
651 | {u"" SC_UNO_CTL_CLOCAL"CharLocaleComplex", ATTR_CTL_FONT_LANGUAGE,cppu::UnoType<lang::Locale>::get(), 0, MID_LANG_LOCALE1 }, | |||
652 | {u"" SC_UNONAME_COVER"CharOverline", ATTR_FONT_OVERLINE, cppu::UnoType<sal_Int16>::get(), 0, MID_TL_STYLE1 }, | |||
653 | {u"" SC_UNONAME_COVRLCOL"CharOverlineColor", ATTR_FONT_OVERLINE, cppu::UnoType<sal_Int32>::get(), 0, MID_TL_COLOR2 }, | |||
654 | {u"" SC_UNONAME_COVRLHAS"CharOverlineHasColor", ATTR_FONT_OVERLINE, cppu::UnoType<bool>::get(), 0, MID_TL_HASCOLOR3 }, | |||
655 | {u"" SC_UNONAME_CPOST"CharPosture", ATTR_FONT_POSTURE, cppu::UnoType<awt::FontSlant>::get(), 0, MID_POSTURE1 }, | |||
656 | {u"" SC_UNO_CJK_CPOST"CharPostureAsian", ATTR_CJK_FONT_POSTURE,cppu::UnoType<awt::FontSlant>::get(), 0, MID_POSTURE1 }, | |||
657 | {u"" SC_UNO_CTL_CPOST"CharPostureComplex", ATTR_CTL_FONT_POSTURE,cppu::UnoType<awt::FontSlant>::get(), 0, MID_POSTURE1 }, | |||
658 | {u"" SC_UNONAME_CRELIEF"CharRelief", ATTR_FONT_RELIEF, cppu::UnoType<sal_Int16>::get(), 0, MID_RELIEF0 }, | |||
659 | {u"" SC_UNONAME_CSHADD"CharShadowed", ATTR_FONT_SHADOWED, cppu::UnoType<bool>::get(), 0, 0 }, | |||
660 | {u"" SC_UNONAME_CSTRIKE"CharStrikeout", ATTR_FONT_CROSSEDOUT,cppu::UnoType<sal_Int16>::get(), 0, MID_CROSS_OUT1 }, | |||
661 | {u"" SC_UNONAME_CUNDER"CharUnderline", ATTR_FONT_UNDERLINE,cppu::UnoType<sal_Int16>::get(), 0, MID_TL_STYLE1 }, | |||
662 | {u"" SC_UNONAME_CUNDLCOL"CharUnderlineColor", ATTR_FONT_UNDERLINE,cppu::UnoType<sal_Int32>::get(), 0, MID_TL_COLOR2 }, | |||
663 | {u"" SC_UNONAME_CUNDLHAS"CharUnderlineHasColor", ATTR_FONT_UNDERLINE,cppu::UnoType<bool>::get(), 0, MID_TL_HASCOLOR3 }, | |||
664 | {u"" SC_UNONAME_CWEIGHT"CharWeight", ATTR_FONT_WEIGHT, cppu::UnoType<float>::get(), 0, MID_WEIGHT1 }, | |||
665 | {u"" SC_UNO_CJK_CWEIGHT"CharWeightAsian", ATTR_CJK_FONT_WEIGHT,cppu::UnoType<float>::get(), 0, MID_WEIGHT1 }, | |||
666 | {u"" SC_UNO_CTL_CWEIGHT"CharWeightComplex", ATTR_CTL_FONT_WEIGHT,cppu::UnoType<float>::get(), 0, MID_WEIGHT1 }, | |||
667 | {u"" SC_UNONAME_CWORDMOD"CharWordMode", ATTR_FONT_WORDLINE, cppu::UnoType<bool>::get(), 0, 0 }, | |||
668 | {u"" SC_UNONAME_CHCOLHDR"ChartColumnAsLabel", SC_WID_UNO_CHCOLHDR( 1200 + 1 ),cppu::UnoType<bool>::get(), 0, 0 }, | |||
669 | {u"" SC_UNONAME_CHROWHDR"ChartRowAsLabel", SC_WID_UNO_CHROWHDR( 1200 + 2 ),cppu::UnoType<bool>::get(), 0, 0 }, | |||
670 | {u"" SC_UNONAME_CONDFMT"ConditionalFormat", SC_WID_UNO_CONDFMT( 1200 + 3 ), cppu::UnoType<sheet::XSheetConditionalEntries>::get(), 0, 0 }, | |||
671 | {u"" SC_UNONAME_CONDLOC"ConditionalFormatLocal", SC_WID_UNO_CONDLOC( 1200 + 4 ), cppu::UnoType<sheet::XSheetConditionalEntries>::get(), 0, 0 }, | |||
672 | {u"" SC_UNONAME_CONDXML"ConditionalFormatXML", SC_WID_UNO_CONDXML( 1200 + 5 ), cppu::UnoType<sheet::XSheetConditionalEntries>::get(), 0, 0 }, | |||
673 | {u"" SC_UNONAME_DIAGONAL_BLTR"DiagonalBLTR", ATTR_BORDER_BLTR, ::cppu::UnoType<table::BorderLine>::get(), 0, 0 | CONVERT_TWIPS0x80 }, | |||
674 | {u"" SC_UNONAME_DIAGONAL_BLTR2"DiagonalBLTR2", ATTR_BORDER_BLTR, ::cppu::UnoType<table::BorderLine2>::get(), 0, 0 | CONVERT_TWIPS0x80 }, | |||
675 | {u"" SC_UNONAME_DIAGONAL_TLBR"DiagonalTLBR", ATTR_BORDER_TLBR, ::cppu::UnoType<table::BorderLine>::get(), 0, 0 | CONVERT_TWIPS0x80 }, | |||
676 | {u"" SC_UNONAME_DIAGONAL_TLBR2"DiagonalTLBR2", ATTR_BORDER_TLBR, ::cppu::UnoType<table::BorderLine2>::get(), 0, 0 | CONVERT_TWIPS0x80 }, | |||
677 | {u"" SC_UNONAME_CELLHGT"Height", SC_WID_UNO_CELLHGT( 1200 + 22 ), cppu::UnoType<sal_Int32>::get(), 0, 0 }, | |||
678 | {u"" SC_UNONAME_CELLHJUS"HoriJustify", ATTR_HOR_JUSTIFY, cppu::UnoType<table::CellHoriJustify>::get(), 0, MID_HORJUST_HORJUST0 }, | |||
679 | {u"" SC_UNONAME_CELLHJUS_METHOD"HoriJustifyMethod", ATTR_HOR_JUSTIFY_METHOD, ::cppu::UnoType<sal_Int32>::get(), 0, 0 }, | |||
680 | {u"" SC_UNONAME_CELLTRAN"IsCellBackgroundTransparent", ATTR_BACKGROUND, cppu::UnoType<bool>::get(), 0, MID_GRAPHIC_TRANSPARENT3 }, | |||
681 | {u"" SC_UNONAME_CELLFILT"IsFiltered", SC_WID_UNO_CELLFILT( 1200 + 23 ),cppu::UnoType<bool>::get(), 0, 0 }, | |||
682 | {u"" SC_UNONAME_MANPAGE"IsManualPageBreak", SC_WID_UNO_MANPAGE( 1200 + 21 ), cppu::UnoType<bool>::get(), 0, 0 }, | |||
683 | {u"" SC_UNONAME_NEWPAGE"IsStartOfNewPage", SC_WID_UNO_NEWPAGE( 1200 + 20 ), cppu::UnoType<bool>::get(), 0, 0 }, | |||
684 | {u"" SC_UNONAME_WRAP"IsTextWrapped", ATTR_LINEBREAK, cppu::UnoType<bool>::get(), 0, 0 }, | |||
685 | {u"" SC_UNONAME_CELLVIS"IsVisible", SC_WID_UNO_CELLVIS( 1200 + 15 ), cppu::UnoType<bool>::get(), 0, 0 }, | |||
686 | {u"" SC_UNONAME_LEFTBORDER"LeftBorder",ATTR_BORDER, ::cppu::UnoType<table::BorderLine>::get(), 0, LEFT_BORDER1 | CONVERT_TWIPS0x80 }, | |||
687 | {u"" SC_UNONAME_LEFTBORDER2"LeftBorder2",ATTR_BORDER, ::cppu::UnoType<table::BorderLine2>::get(), 0, LEFT_BORDER1 | CONVERT_TWIPS0x80 }, | |||
688 | {u"" SC_UNONAME_NUMFMT"NumberFormat", ATTR_VALUE_FORMAT, cppu::UnoType<sal_Int32>::get(), 0, 0 }, | |||
689 | {u"" SC_UNONAME_NUMRULES"NumberingRules", SC_WID_UNO_NUMRULES( 1200 + 28 ),cppu::UnoType<container::XIndexReplace>::get(), 0, 0 }, | |||
690 | {u"" SC_UNONAME_OHEIGHT"OptimalHeight", SC_WID_UNO_OHEIGHT( 1200 + 24 ), cppu::UnoType<bool>::get(), 0, 0 }, | |||
691 | {u"" SC_UNONAME_CELLORI"Orientation", ATTR_STACKED, cppu::UnoType<table::CellOrientation>::get(), 0, 0 }, | |||
692 | {u"" SC_UNONAME_PADJUST"ParaAdjust", ATTR_HOR_JUSTIFY, ::cppu::UnoType<sal_Int16>::get(), 0, MID_HORJUST_ADJUST1 }, | |||
693 | {u"" SC_UNONAME_PBMARGIN"ParaBottomMargin", ATTR_MARGIN, cppu::UnoType<sal_Int32>::get(), 0, MID_MARGIN_LO_MARGIN5 | CONVERT_TWIPS0x80 }, | |||
694 | {u"" SC_UNONAME_PINDENT"ParaIndent", ATTR_INDENT, cppu::UnoType<sal_Int16>::get(), 0, 0 }, //! CONVERT_TWIPS | |||
695 | {u"" SC_UNONAME_PISCHDIST"ParaIsCharacterDistance",ATTR_SCRIPTSPACE, cppu::UnoType<bool>::get(), 0, 0 }, | |||
696 | {u"" SC_UNONAME_PISFORBID"ParaIsForbiddenRules",ATTR_FORBIDDEN_RULES,cppu::UnoType<bool>::get(), 0, 0 }, | |||
697 | {u"" SC_UNONAME_PISHANG"ParaIsHangingPunctuation", ATTR_HANGPUNCTUATION,cppu::UnoType<bool>::get(), 0, 0 }, | |||
698 | {u"" SC_UNONAME_PISHYPHEN"ParaIsHyphenation",ATTR_HYPHENATE, cppu::UnoType<bool>::get(), 0, 0 }, | |||
699 | {u"" SC_UNONAME_PLASTADJ"ParaLastLineAdjust", ATTR_HOR_JUSTIFY, ::cppu::UnoType<sal_Int16>::get(), 0, MID_HORJUST_ADJUST1 }, | |||
700 | {u"" SC_UNONAME_PLMARGIN"ParaLeftMargin", ATTR_MARGIN, cppu::UnoType<sal_Int32>::get(), 0, MID_MARGIN_L_MARGIN2 | CONVERT_TWIPS0x80 }, | |||
701 | {u"" SC_UNONAME_PRMARGIN"ParaRightMargin", ATTR_MARGIN, cppu::UnoType<sal_Int32>::get(), 0, MID_MARGIN_R_MARGIN3 | CONVERT_TWIPS0x80 }, | |||
702 | {u"" SC_UNONAME_PTMARGIN"ParaTopMargin", ATTR_MARGIN, cppu::UnoType<sal_Int32>::get(), 0, MID_MARGIN_UP_MARGIN4 | CONVERT_TWIPS0x80 }, | |||
703 | {u"" SC_UNONAME_POS"Position", SC_WID_UNO_POS( 1200 + 10 ), cppu::UnoType<awt::Point>::get(), 0 | beans::PropertyAttribute::READONLY, 0 }, | |||
704 | {u"" SC_UNONAME_RIGHTBORDER"RightBorder",ATTR_BORDER, ::cppu::UnoType<table::BorderLine>::get(), 0, RIGHT_BORDER2 | CONVERT_TWIPS0x80 }, | |||
705 | {u"" SC_UNONAME_RIGHTBORDER2"RightBorder2",ATTR_BORDER, ::cppu::UnoType<table::BorderLine2>::get(), 0, RIGHT_BORDER2 | CONVERT_TWIPS0x80 }, | |||
706 | {u"" SC_UNONAME_ROTANG"RotateAngle", ATTR_ROTATE_VALUE, cppu::UnoType<sal_Int32>::get(), 0, 0 }, | |||
707 | {u"" SC_UNONAME_ROTREF"RotateReference", ATTR_ROTATE_MODE, cppu::UnoType<sal_Int32>::get(), 0, 0 }, | |||
708 | {u"" SC_UNONAME_SHADOW"ShadowFormat", ATTR_SHADOW, cppu::UnoType<table::ShadowFormat>::get(), 0, 0 | CONVERT_TWIPS0x80 }, | |||
709 | {u"" SC_UNONAME_SHRINK_TO_FIT"ShrinkToFit", ATTR_SHRINKTOFIT, cppu::UnoType<bool>::get(), 0, 0 }, | |||
710 | {u"" SC_UNONAME_SIZE"Size", SC_WID_UNO_SIZE( 1200 + 11 ), cppu::UnoType<awt::Size>::get(), 0 | beans::PropertyAttribute::READONLY, 0 }, | |||
711 | {u"" SC_UNONAME_TBLBORD"TableBorder", SC_WID_UNO_TBLBORD( 1200 + 6 ), cppu::UnoType<table::TableBorder>::get(), 0, 0 | CONVERT_TWIPS0x80 }, | |||
712 | {u"" SC_UNONAME_TBLBORD2"TableBorder2", SC_WID_UNO_TBLBORD2( 1200 + 43 ), cppu::UnoType<table::TableBorder2>::get(), 0, 0 | CONVERT_TWIPS0x80 }, | |||
713 | {u"" SC_UNONAME_TOPBORDER"TopBorder",ATTR_BORDER, ::cppu::UnoType<table::BorderLine>::get(), 0, TOP_BORDER3 | CONVERT_TWIPS0x80 }, | |||
714 | {u"" SC_UNONAME_TOPBORDER2"TopBorder2",ATTR_BORDER, ::cppu::UnoType<table::BorderLine2>::get(), 0, TOP_BORDER3 | CONVERT_TWIPS0x80 }, | |||
715 | {u"" SC_UNONAME_USERDEF"UserDefinedAttributes", ATTR_USERDEF, cppu::UnoType<container::XNameContainer>::get(), 0, 0 }, | |||
716 | {u"" SC_UNONAME_VALIDAT"Validation", SC_WID_UNO_VALIDAT( 1200 + 7 ), cppu::UnoType<beans::XPropertySet>::get(), 0, 0 }, | |||
717 | {u"" SC_UNONAME_VALILOC"ValidationLocal", SC_WID_UNO_VALILOC( 1200 + 8 ), cppu::UnoType<beans::XPropertySet>::get(), 0, 0 }, | |||
718 | {u"" SC_UNONAME_VALIXML"ValidationXML", SC_WID_UNO_VALIXML( 1200 + 9 ), cppu::UnoType<beans::XPropertySet>::get(), 0, 0 }, | |||
719 | {u"" SC_UNONAME_CELLVJUS"VertJustify", ATTR_VER_JUSTIFY, cppu::UnoType<sal_Int32>::get(), 0, 0 }, | |||
720 | {u"" SC_UNONAME_CELLVJUS_METHOD"VertJustifyMethod", ATTR_VER_JUSTIFY_METHOD, ::cppu::UnoType<sal_Int32>::get(), 0, 0 }, | |||
721 | {u"" SC_UNONAME_WRITING"WritingMode", ATTR_WRITINGDIR, cppu::UnoType<sal_Int16>::get(), 0, 0 }, | |||
722 | { u"", 0, css::uno::Type(), 0, 0 } | |||
723 | }; | |||
724 | static SfxItemPropertySet aRowPropertySet( aRowPropertyMap_Impl ); | |||
725 | return &aRowPropertySet; | |||
726 | } | |||
727 | ||||
728 | static const SfxItemPropertySet* lcl_GetSheetPropertySet() | |||
729 | { | |||
730 | static const SfxItemPropertyMapEntry aSheetPropertyMap_Impl[] = | |||
731 | { | |||
732 | {u"" SC_UNONAME_ABSNAME"AbsoluteName", SC_WID_UNO_ABSNAME( 1200 + 39 ), cppu::UnoType<OUString>::get(), 0 | beans::PropertyAttribute::READONLY, 0 }, | |||
733 | {u"" SC_UNONAME_ASIANVERT"AsianVerticalMode",ATTR_VERTICAL_ASIAN,cppu::UnoType<bool>::get(), 0, 0 }, | |||
734 | {u"" SC_UNONAME_AUTOPRINT"AutomaticPrintArea",SC_WID_UNO_AUTOPRINT( 1200 + 38 ),cppu::UnoType<bool>::get(), 0, 0 }, | |||
735 | {u"" SC_UNONAME_BORDCOL"BorderColor", SC_WID_UNO_BORDCOL( 1200 + 30 ), cppu::UnoType<sal_Int32>::get(), 0, 0 }, | |||
736 | {u"" SC_UNONAME_BOTTBORDER"BottomBorder",ATTR_BORDER, ::cppu::UnoType<table::BorderLine>::get(), 0, BOTTOM_BORDER4 | CONVERT_TWIPS0x80 }, | |||
737 | {u"" SC_UNONAME_BOTTBORDER2"BottomBorder2",ATTR_BORDER, ::cppu::UnoType<table::BorderLine2>::get(), 0, BOTTOM_BORDER4 | CONVERT_TWIPS0x80 }, | |||
738 | {u"" SC_UNONAME_CELLBACK"CellBackColor", ATTR_BACKGROUND, cppu::UnoType<sal_Int32>::get(), 0, MID_BACK_COLOR0 }, | |||
739 | {u"" SC_UNONAME_CELLPRO"CellProtection", ATTR_PROTECTION, cppu::UnoType<util::CellProtection>::get(), 0, 0 }, | |||
740 | {u"" SC_UNONAME_CELLSTYL"CellStyle", SC_WID_UNO_CELLSTYL( 1200 + 0 ),cppu::UnoType<OUString>::get(), 0, 0 }, | |||
741 | {u"" SC_UNONAME_CCOLOR"CharColor", ATTR_FONT_COLOR, cppu::UnoType<sal_Int32>::get(), 0, 0 }, | |||
742 | {u"" SC_UNONAME_COUTL"CharContoured", ATTR_FONT_CONTOUR, cppu::UnoType<bool>::get(), 0, 0 }, | |||
743 | {u"" SC_UNONAME_CCROSS"CharCrossedOut", ATTR_FONT_CROSSEDOUT,cppu::UnoType<bool>::get(), 0, MID_CROSSED_OUT0 }, | |||
744 | {u"" SC_UNONAME_CEMPHAS"CharEmphasis", ATTR_FONT_EMPHASISMARK,cppu::UnoType<sal_Int16>::get(), 0, MID_EMPHASIS0 }, | |||
745 | {u"" SC_UNONAME_CFONT"CharFont", ATTR_FONT, cppu::UnoType<sal_Int16>::get(), 0, MID_FONT_FAMILY3 }, | |||
746 | {u"" SC_UNONAME_CFCHARS"CharFontCharSet", ATTR_FONT, cppu::UnoType<sal_Int16>::get(), 0, MID_FONT_CHAR_SET4 }, | |||
747 | {u"" SC_UNO_CJK_CFCHARS"CharFontCharSetAsian", ATTR_CJK_FONT, cppu::UnoType<sal_Int16>::get(), 0, MID_FONT_CHAR_SET4 }, | |||
748 | {u"" SC_UNO_CTL_CFCHARS"CharFontCharSetComplex", ATTR_CTL_FONT, cppu::UnoType<sal_Int16>::get(), 0, MID_FONT_CHAR_SET4 }, | |||
749 | {u"" SC_UNONAME_CFFAMIL"CharFontFamily", ATTR_FONT, cppu::UnoType<sal_Int16>::get(), 0, MID_FONT_FAMILY3 }, | |||
750 | {u"" SC_UNO_CJK_CFFAMIL"CharFontFamilyAsian", ATTR_CJK_FONT, cppu::UnoType<sal_Int16>::get(), 0, MID_FONT_FAMILY3 }, | |||
751 | {u"" SC_UNO_CTL_CFFAMIL"CharFontFamilyComplex", ATTR_CTL_FONT, cppu::UnoType<sal_Int16>::get(), 0, MID_FONT_FAMILY3 }, | |||
752 | {u"" SC_UNONAME_CFNAME"CharFontName", ATTR_FONT, cppu::UnoType<OUString>::get(), 0, MID_FONT_FAMILY_NAME1 }, | |||
753 | {u"" SC_UNO_CJK_CFNAME"CharFontNameAsian", ATTR_CJK_FONT, cppu::UnoType<OUString>::get(), 0, MID_FONT_FAMILY_NAME1 }, | |||
754 | {u"" SC_UNO_CTL_CFNAME"CharFontNameComplex", ATTR_CTL_FONT, cppu::UnoType<OUString>::get(), 0, MID_FONT_FAMILY_NAME1 }, | |||
755 | {u"" SC_UNONAME_CFPITCH"CharFontPitch", ATTR_FONT, cppu::UnoType<sal_Int16>::get(), 0, MID_FONT_PITCH5 }, | |||
756 | {u"" SC_UNO_CJK_CFPITCH"CharFontPitchAsian", ATTR_CJK_FONT, cppu::UnoType<sal_Int16>::get(), 0, MID_FONT_PITCH5 }, | |||
757 | {u"" SC_UNO_CTL_CFPITCH"CharFontPitchComplex", ATTR_CTL_FONT, cppu::UnoType<sal_Int16>::get(), 0, MID_FONT_PITCH5 }, | |||
758 | {u"" SC_UNONAME_CFSTYLE"CharFontStyleName", ATTR_FONT, cppu::UnoType<OUString>::get(), 0, MID_FONT_STYLE_NAME2 }, | |||
759 | {u"" SC_UNO_CJK_CFSTYLE"CharFontStyleNameAsian", ATTR_CJK_FONT, cppu::UnoType<OUString>::get(), 0, MID_FONT_STYLE_NAME2 }, | |||
760 | {u"" SC_UNO_CTL_CFSTYLE"CharFontStyleNameComplex", ATTR_CTL_FONT, cppu::UnoType<OUString>::get(), 0, MID_FONT_STYLE_NAME2 }, | |||
761 | {u"" SC_UNONAME_CHEIGHT"CharHeight", ATTR_FONT_HEIGHT, cppu::UnoType<float>::get(), 0, MID_FONTHEIGHT1 | CONVERT_TWIPS0x80 }, | |||
762 | {u"" SC_UNO_CJK_CHEIGHT"CharHeightAsian", ATTR_CJK_FONT_HEIGHT,cppu::UnoType<float>::get(), 0, MID_FONTHEIGHT1 | CONVERT_TWIPS0x80 }, | |||
763 | {u"" SC_UNO_CTL_CHEIGHT"CharHeightComplex", ATTR_CTL_FONT_HEIGHT,cppu::UnoType<float>::get(), 0, MID_FONTHEIGHT1 | CONVERT_TWIPS0x80 }, | |||
764 | {u"" SC_UNONAME_CLOCAL"CharLocale", ATTR_FONT_LANGUAGE, cppu::UnoType<lang::Locale>::get(), 0, MID_LANG_LOCALE1 }, | |||
765 | {u"" SC_UNO_CJK_CLOCAL"CharLocaleAsian", ATTR_CJK_FONT_LANGUAGE,cppu::UnoType<lang::Locale>::get(), 0, MID_LANG_LOCALE1 }, | |||
766 | {u"" SC_UNO_CTL_CLOCAL"CharLocaleComplex", ATTR_CTL_FONT_LANGUAGE,cppu::UnoType<lang::Locale>::get(), 0, MID_LANG_LOCALE1 }, | |||
767 | {u"" SC_UNONAME_COVER"CharOverline", ATTR_FONT_OVERLINE, cppu::UnoType<sal_Int16>::get(), 0, MID_TL_STYLE1 }, | |||
768 | {u"" SC_UNONAME_COVRLCOL"CharOverlineColor", ATTR_FONT_OVERLINE, cppu::UnoType<sal_Int32>::get(), 0, MID_TL_COLOR2 }, | |||
769 | {u"" SC_UNONAME_COVRLHAS"CharOverlineHasColor", ATTR_FONT_OVERLINE, cppu::UnoType<bool>::get(), 0, MID_TL_HASCOLOR3 }, | |||
770 | {u"" SC_UNONAME_CPOST"CharPosture", ATTR_FONT_POSTURE, cppu::UnoType<awt::FontSlant>::get(), 0, MID_POSTURE1 }, | |||
771 | {u"" SC_UNO_CJK_CPOST"CharPostureAsian", ATTR_CJK_FONT_POSTURE,cppu::UnoType<awt::FontSlant>::get(), 0, MID_POSTURE1 }, | |||
772 | {u"" SC_UNO_CTL_CPOST"CharPostureComplex", ATTR_CTL_FONT_POSTURE,cppu::UnoType<awt::FontSlant>::get(), 0, MID_POSTURE1 }, | |||
773 | {u"" SC_UNONAME_CRELIEF"CharRelief", ATTR_FONT_RELIEF, cppu::UnoType<sal_Int16>::get(), 0, MID_RELIEF0 }, | |||
774 | {u"" SC_UNONAME_CSHADD"CharShadowed", ATTR_FONT_SHADOWED, cppu::UnoType<bool>::get(), 0, 0 }, | |||
775 | {u"" SC_UNONAME_CSTRIKE"CharStrikeout", ATTR_FONT_CROSSEDOUT,cppu::UnoType<sal_Int16>::get(), 0, MID_CROSS_OUT1 }, | |||
776 | {u"" SC_UNONAME_CUNDER"CharUnderline", ATTR_FONT_UNDERLINE,cppu::UnoType<sal_Int16>::get(), 0, MID_TL_STYLE1 }, | |||
777 | {u"" SC_UNONAME_CUNDLCOL"CharUnderlineColor", ATTR_FONT_UNDERLINE,cppu::UnoType<sal_Int32>::get(), 0, MID_TL_COLOR2 }, | |||
778 | {u"" SC_UNONAME_CUNDLHAS"CharUnderlineHasColor", ATTR_FONT_UNDERLINE,cppu::UnoType<bool>::get(), 0, MID_TL_HASCOLOR3 }, | |||
779 | {u"" SC_UNONAME_CWEIGHT"CharWeight", ATTR_FONT_WEIGHT, cppu::UnoType<float>::get(), 0, MID_WEIGHT1 }, | |||
780 | {u"" SC_UNO_CJK_CWEIGHT"CharWeightAsian", ATTR_CJK_FONT_WEIGHT,cppu::UnoType<float>::get(), 0, MID_WEIGHT1 }, | |||
781 | {u"" SC_UNO_CTL_CWEIGHT"CharWeightComplex", ATTR_CTL_FONT_WEIGHT,cppu::UnoType<float>::get(), 0, MID_WEIGHT1 }, | |||
782 | {u"" SC_UNONAME_CWORDMOD"CharWordMode", ATTR_FONT_WORDLINE, cppu::UnoType<bool>::get(), 0, 0 }, | |||
783 | {u"" SC_UNONAME_CHCOLHDR"ChartColumnAsLabel", SC_WID_UNO_CHCOLHDR( 1200 + 1 ),cppu::UnoType<bool>::get(), 0, 0 }, | |||
784 | {u"" SC_UNONAME_CHROWHDR"ChartRowAsLabel", SC_WID_UNO_CHROWHDR( 1200 + 2 ),cppu::UnoType<bool>::get(), 0, 0 }, | |||
785 | {u"" SC_UNONAME_CONDFMT"ConditionalFormat", SC_WID_UNO_CONDFMT( 1200 + 3 ), cppu::UnoType<sheet::XSheetConditionalEntries>::get(), 0, 0 }, | |||
786 | {u"" SC_UNONAME_CONDLOC"ConditionalFormatLocal", SC_WID_UNO_CONDLOC( 1200 + 4 ), cppu::UnoType<sheet::XSheetConditionalEntries>::get(), 0, 0 }, | |||
787 | {u"" SC_UNONAME_CONDXML"ConditionalFormatXML", SC_WID_UNO_CONDXML( 1200 + 5 ), cppu::UnoType<sheet::XSheetConditionalEntries>::get(), 0, 0 }, | |||
788 | {u"" SC_UNONAME_COPYBACK"CopyBack", SC_WID_UNO_COPYBACK( 1200 + 34 ),cppu::UnoType<bool>::get(), 0, 0 }, | |||
789 | {u"" SC_UNONAME_COPYFORM"CopyFormulas", SC_WID_UNO_COPYFORM( 1200 + 36 ),cppu::UnoType<bool>::get(), 0, 0 }, | |||
790 | {u"" SC_UNONAME_COPYSTYL"CopyStyles", SC_WID_UNO_COPYSTYL( 1200 + 35 ),cppu::UnoType<bool>::get(), 0, 0 }, | |||
791 | {u"" SC_UNONAME_DIAGONAL_BLTR"DiagonalBLTR", ATTR_BORDER_BLTR, ::cppu::UnoType<table::BorderLine>::get(), 0, 0 | CONVERT_TWIPS0x80 }, | |||
792 | {u"" SC_UNONAME_DIAGONAL_BLTR2"DiagonalBLTR2", ATTR_BORDER_BLTR, ::cppu::UnoType<table::BorderLine2>::get(), 0, 0 | CONVERT_TWIPS0x80 }, | |||
793 | {u"" SC_UNONAME_DIAGONAL_TLBR"DiagonalTLBR", ATTR_BORDER_TLBR, ::cppu::UnoType<table::BorderLine>::get(), 0, 0 | CONVERT_TWIPS0x80 }, | |||
794 | {u"" SC_UNONAME_DIAGONAL_TLBR2"DiagonalTLBR2", ATTR_BORDER_TLBR, ::cppu::UnoType<table::BorderLine2>::get(), 0, 0 | CONVERT_TWIPS0x80 }, | |||
795 | {u"" SC_UNONAME_CELLHJUS"HoriJustify", ATTR_HOR_JUSTIFY, cppu::UnoType<table::CellHoriJustify>::get(), 0, MID_HORJUST_HORJUST0 }, | |||
796 | {u"" SC_UNONAME_CELLHJUS_METHOD"HoriJustifyMethod", ATTR_HOR_JUSTIFY_METHOD, ::cppu::UnoType<sal_Int32>::get(), 0, 0 }, | |||
797 | {u"" SC_UNONAME_ISACTIVE"IsActive", SC_WID_UNO_ISACTIVE( 1200 + 29 ),cppu::UnoType<bool>::get(), 0, 0 }, | |||
798 | {u"" SC_UNONAME_CELLTRAN"IsCellBackgroundTransparent", ATTR_BACKGROUND, cppu::UnoType<bool>::get(), 0, MID_GRAPHIC_TRANSPARENT3 }, | |||
799 | {u"" SC_UNONAME_WRAP"IsTextWrapped", ATTR_LINEBREAK, cppu::UnoType<bool>::get(), 0, 0 }, | |||
800 | {u"" SC_UNONAME_CELLVIS"IsVisible", SC_WID_UNO_CELLVIS( 1200 + 15 ), cppu::UnoType<bool>::get(), 0, 0 }, | |||
801 | {u"" SC_UNONAME_LEFTBORDER"LeftBorder",ATTR_BORDER, ::cppu::UnoType<table::BorderLine>::get(), 0, LEFT_BORDER1 | CONVERT_TWIPS0x80 }, | |||
802 | {u"" SC_UNONAME_LEFTBORDER2"LeftBorder2",ATTR_BORDER, ::cppu::UnoType<table::BorderLine2>::get(), 0, LEFT_BORDER1 | CONVERT_TWIPS0x80 }, | |||
803 | {u"" SC_UNO_LINKDISPBIT"LinkDisplayBitmap", SC_WID_UNO_LINKDISPBIT( 1200 + 16 ),cppu::UnoType<awt::XBitmap>::get(), 0 | beans::PropertyAttribute::READONLY, 0 }, | |||
804 | {u"" SC_UNO_LINKDISPNAME"LinkDisplayName", SC_WID_UNO_LINKDISPNAME( 1200 + 17 ),cppu::UnoType<OUString>::get(), 0 | beans::PropertyAttribute::READONLY, 0 }, | |||
805 | {u"" SC_UNONAME_NUMFMT"NumberFormat", ATTR_VALUE_FORMAT, cppu::UnoType<sal_Int32>::get(), 0, 0 }, | |||
806 | {u"" SC_UNONAME_NUMRULES"NumberingRules", SC_WID_UNO_NUMRULES( 1200 + 28 ),cppu::UnoType<container::XIndexReplace>::get(), 0, 0 }, | |||
807 | {u"" SC_UNONAME_CELLORI"Orientation", ATTR_STACKED, cppu::UnoType<table::CellOrientation>::get(), 0, 0 }, | |||
808 | {u"" SC_UNONAME_PAGESTL"PageStyle", SC_WID_UNO_PAGESTL( 1200 + 14 ), cppu::UnoType<OUString>::get(), 0, 0 }, | |||
809 | {u"" SC_UNONAME_PADJUST"ParaAdjust", ATTR_HOR_JUSTIFY, ::cppu::UnoType<sal_Int16>::get(), 0, MID_HORJUST_ADJUST1 }, | |||
810 | {u"" SC_UNONAME_PBMARGIN"ParaBottomMargin", ATTR_MARGIN, cppu::UnoType<sal_Int32>::get(), 0, MID_MARGIN_LO_MARGIN5 | CONVERT_TWIPS0x80 }, | |||
811 | {u"" SC_UNONAME_PINDENT"ParaIndent", ATTR_INDENT, cppu::UnoType<sal_Int16>::get(), 0, 0 }, //! CONVERT_TWIPS | |||
812 | {u"" SC_UNONAME_PISCHDIST"ParaIsCharacterDistance",ATTR_SCRIPTSPACE, cppu::UnoType<bool>::get(), 0, 0 }, | |||
813 | {u"" SC_UNONAME_PISFORBID"ParaIsForbiddenRules",ATTR_FORBIDDEN_RULES,cppu::UnoType<bool>::get(), 0, 0 }, | |||
814 | {u"" SC_UNONAME_PISHANG"ParaIsHangingPunctuation", ATTR_HANGPUNCTUATION,cppu::UnoType<bool>::get(), 0, 0 }, | |||
815 | {u"" SC_UNONAME_PISHYPHEN"ParaIsHyphenation",ATTR_HYPHENATE, cppu::UnoType<bool>::get(), 0, 0 }, | |||
816 | {u"" SC_UNONAME_PLASTADJ"ParaLastLineAdjust", ATTR_HOR_JUSTIFY, ::cppu::UnoType<sal_Int16>::get(), 0, MID_HORJUST_ADJUST1 }, | |||
817 | {u"" SC_UNONAME_PLMARGIN"ParaLeftMargin", ATTR_MARGIN, cppu::UnoType<sal_Int32>::get(), 0, MID_MARGIN_L_MARGIN2 | CONVERT_TWIPS0x80 }, | |||
818 | {u"" SC_UNONAME_PRMARGIN"ParaRightMargin", ATTR_MARGIN, cppu::UnoType<sal_Int32>::get(), 0, MID_MARGIN_R_MARGIN3 | CONVERT_TWIPS0x80 }, | |||
819 | {u"" SC_UNONAME_PTMARGIN"ParaTopMargin", ATTR_MARGIN, cppu::UnoType<sal_Int32>::get(), 0, MID_MARGIN_UP_MARGIN4 | CONVERT_TWIPS0x80 }, | |||
820 | {u"" SC_UNONAME_POS"Position", SC_WID_UNO_POS( 1200 + 10 ), cppu::UnoType<awt::Point>::get(), 0 | beans::PropertyAttribute::READONLY, 0 }, | |||
821 | {u"" SC_UNONAME_PRINTBORD"PrintBorder",SC_WID_UNO_PRINTBORD( 1200 + 33 ),cppu::UnoType<bool>::get(), 0, 0 }, | |||
822 | {u"" SC_UNONAME_PROTECT"Protected", SC_WID_UNO_PROTECT( 1200 + 31 ), cppu::UnoType<bool>::get(), 0, 0 }, | |||
823 | {u"" SC_UNONAME_RIGHTBORDER"RightBorder",ATTR_BORDER, ::cppu::UnoType<table::BorderLine>::get(), 0, RIGHT_BORDER2 | CONVERT_TWIPS0x80 }, | |||
824 | {u"" SC_UNONAME_RIGHTBORDER2"RightBorder2",ATTR_BORDER, ::cppu::UnoType<table::BorderLine2>::get(), 0, RIGHT_BORDER2 | CONVERT_TWIPS0x80 }, | |||
825 | {u"" SC_UNONAME_ROTANG"RotateAngle", ATTR_ROTATE_VALUE, cppu::UnoType<sal_Int32>::get(), 0, 0 }, | |||
826 | {u"" SC_UNONAME_ROTREF"RotateReference", ATTR_ROTATE_MODE, cppu::UnoType<sal_Int32>::get(), 0, 0 }, | |||
827 | {u"" SC_UNONAME_SHADOW"ShadowFormat", ATTR_SHADOW, cppu::UnoType<table::ShadowFormat>::get(), 0, 0 | CONVERT_TWIPS0x80 }, | |||
828 | {u"" SC_UNONAME_SHOWBORD"ShowBorder", SC_WID_UNO_SHOWBORD( 1200 + 32 ),cppu::UnoType<bool>::get(), 0, 0 }, | |||
829 | {u"" SC_UNONAME_SHRINK_TO_FIT"ShrinkToFit", ATTR_SHRINKTOFIT, cppu::UnoType<bool>::get(), 0, 0 }, | |||
830 | {u"" SC_UNONAME_SIZE"Size", SC_WID_UNO_SIZE( 1200 + 11 ), cppu::UnoType<awt::Size>::get(), 0 | beans::PropertyAttribute::READONLY, 0 }, | |||
831 | {u"" SC_UNONAME_TBLBORD"TableBorder", SC_WID_UNO_TBLBORD( 1200 + 6 ), cppu::UnoType<table::TableBorder>::get(), 0, 0 | CONVERT_TWIPS0x80 }, | |||
832 | {u"" SC_UNONAME_TBLBORD2"TableBorder2", SC_WID_UNO_TBLBORD2( 1200 + 43 ), cppu::UnoType<table::TableBorder2>::get(), 0, 0 | CONVERT_TWIPS0x80 }, | |||
833 | {u"" SC_UNONAME_TABLAYOUT"TableLayout",SC_WID_UNO_TABLAYOUT( 1200 + 37 ),cppu::UnoType<sal_Int16>::get(), 0, 0 }, | |||
834 | {u"" SC_UNONAME_CONDFORMAT"ConditionalFormats", SC_WID_UNO_CONDFORMAT( 1200 + 44 ), cppu::UnoType<sheet::XConditionalFormats>::get(), 0, 0}, | |||
835 | {u"" SC_UNONAME_TOPBORDER"TopBorder",ATTR_BORDER, ::cppu::UnoType<table::BorderLine>::get(), 0, TOP_BORDER3 | CONVERT_TWIPS0x80 }, | |||
836 | {u"" SC_UNONAME_TOPBORDER2"TopBorder2",ATTR_BORDER, ::cppu::UnoType<table::BorderLine2>::get(), 0, TOP_BORDER3 | CONVERT_TWIPS0x80 }, | |||
837 | {u"" SC_UNONAME_USERDEF"UserDefinedAttributes", ATTR_USERDEF, cppu::UnoType<container::XNameContainer>::get(), 0, 0 }, | |||
838 | {u"" SC_UNONAME_VALIDAT"Validation", SC_WID_UNO_VALIDAT( 1200 + 7 ), cppu::UnoType<beans::XPropertySet>::get(), 0, 0 }, | |||
839 | {u"" SC_UNONAME_VALILOC"ValidationLocal", SC_WID_UNO_VALILOC( 1200 + 8 ), cppu::UnoType<beans::XPropertySet>::get(), 0, 0 }, | |||
840 | {u"" SC_UNONAME_VALIXML"ValidationXML", SC_WID_UNO_VALIXML( 1200 + 9 ), cppu::UnoType<beans::XPropertySet>::get(), 0, 0 }, | |||
841 | {u"" SC_UNONAME_CELLVJUS"VertJustify", ATTR_VER_JUSTIFY, cppu::UnoType<sal_Int32>::get(), 0, 0 }, | |||
842 | {u"" SC_UNONAME_CELLVJUS_METHOD"VertJustifyMethod", ATTR_VER_JUSTIFY_METHOD, ::cppu::UnoType<sal_Int32>::get(), 0, 0 }, | |||
843 | {u"" SC_UNONAME_WRITING"WritingMode", ATTR_WRITINGDIR, cppu::UnoType<sal_Int16>::get(), 0, 0 }, | |||
844 | {u"" SC_UNONAME_TABCOLOR"TabColor", SC_WID_UNO_TABCOLOR( 1200 + 41 ), cppu::UnoType<sal_Int32>::get(), 0, 0 }, | |||
845 | {u"" SC_UNO_CODENAME"CodeName", SC_WID_UNO_CODENAME( 1200 + 40 ), cppu::UnoType<OUString>::get(), 0, 0}, | |||
846 | {u"" SC_UNO_NAMEDRANGES"NamedRanges", SC_WID_UNO_NAMES( 1200 + 42 ), cppu::UnoType<sheet::XNamedRanges>::get(), 0, 0 }, | |||
847 | { u"", 0, css::uno::Type(), 0, 0 } | |||
848 | }; | |||
849 | static SfxItemPropertySet aSheetPropertySet( aSheetPropertyMap_Impl ); | |||
850 | return &aSheetPropertySet; | |||
851 | } | |||
852 | ||||
853 | static const SfxItemPropertyMapEntry* lcl_GetEditPropertyMap() | |||
854 | { | |||
855 | static const SfxItemPropertyMapEntry aEditPropertyMap_Impl[] = | |||
856 | { | |||
857 | SVX_UNOEDIT_CHAR_PROPERTIES{ u"" "CharHeight", EE_CHAR_FONTHEIGHT, cppu::UnoType<float >::get(), 0, 1|0x80 }, { u"CharScaleWidth", EE_CHAR_FONTWIDTH , ::cppu::UnoType<sal_Int16>::get(), 0, 0 }, { u"" "CharFontName" , EE_CHAR_FONTINFO, ::cppu::UnoType<OUString>::get(), 0 , 1 }, { u"" "CharFontStyleName",EE_CHAR_FONTINFO, ::cppu::UnoType <OUString>::get(), 0, 2 }, { u"" "CharFontFamily", EE_CHAR_FONTINFO , ::cppu::UnoType<sal_Int16>::get(), 0, 3 }, { u"" "CharFontCharSet" , EE_CHAR_FONTINFO, ::cppu::UnoType<sal_Int16>::get(), 0 , 4 }, { u"" "CharFontPitch", EE_CHAR_FONTINFO, ::cppu::UnoType <sal_Int16>::get(), 0, 5 }, { u"" "CharPosture", EE_CHAR_ITALIC , ::cppu::UnoType<css::awt::FontSlant>::get(),0, 1 }, { u"" "CharWeight", EE_CHAR_WEIGHT, cppu::UnoType<float> ::get(), 0, 1 }, { u"" "CharLocale", EE_CHAR_LANGUAGE, ::cppu ::UnoType<css::lang::Locale>::get(),0, 1 }, { u"" "CharColor" , EE_CHAR_COLOR, ::cppu::UnoType<sal_Int32>::get(), 0, 0 }, { u"" "CharTransparence",EE_CHAR_COLOR, ::cppu::UnoType< sal_Int16>::get(), 0, 1 }, { u"CharBackColor", EE_CHAR_BKGCOLOR , ::cppu::UnoType<sal_Int32>::get(), 0, 0 }, { u"CharBackTransparent" , EE_CHAR_BKGCOLOR, ::cppu::UnoType<bool>::get(), 0, 3 } , { u"" "CharEscapement", EE_CHAR_ESCAPEMENT, ::cppu::UnoType <sal_Int16>::get(), 0, 0 }, { u"" "CharUnderline", EE_CHAR_UNDERLINE , ::cppu::UnoType<sal_Int16>::get(), 0, 1 }, { u"CharUnderlineColor" , EE_CHAR_UNDERLINE, ::cppu::UnoType<sal_Int32>::get(), 0, 2 }, { u"CharUnderlineHasColor", EE_CHAR_UNDERLINE, cppu:: UnoType<bool>::get(), 0, 3 } , { u"" "CharOverline", EE_CHAR_OVERLINE , ::cppu::UnoType<sal_Int16>::get(), 0, 1 }, { u"CharOverlineColor" , EE_CHAR_OVERLINE, ::cppu::UnoType<sal_Int32>::get(), 0 , 2 }, { u"CharOverlineHasColor", EE_CHAR_OVERLINE, cppu::UnoType <bool>::get(), 0, 3 } , { u"" "CharCrossedOut", EE_CHAR_STRIKEOUT , cppu::UnoType<bool>::get(), 0, 0 }, { u"" "CharStrikeout" , EE_CHAR_STRIKEOUT, ::cppu::UnoType<sal_Int16>::get(), 0, 1}, { u"" "CharCaseMap", EE_CHAR_CASEMAP, ::cppu::UnoType <sal_Int16>::get(), 0, 0 }, { u"" "CharShadowed", EE_CHAR_SHADOW , cppu::UnoType<bool>::get(), 0, 0 }, { u"CharContoured" , EE_CHAR_OUTLINE, cppu::UnoType<bool>::get(), 0, 0 }, { u"CharEscapementHeight", EE_CHAR_ESCAPEMENT, cppu::UnoType< sal_Int8>::get(), 0, 1 }, { u"CharAutoKerning", EE_CHAR_PAIRKERNING ,cppu::UnoType<bool>::get(), 0, 0 } , { u"CharKerning", EE_CHAR_KERNING, ::cppu::UnoType<sal_Int16>::get() , 0 , 0 }, { u"CharWordMode", EE_CHAR_WLM, cppu::UnoType<bool> ::get(), 0, 0 }, { u"CharEmphasis", EE_CHAR_EMPHASISMARK, ::cppu ::UnoType<sal_Int16>::get(), 0, 0}, { u"" "CharHeightAsian" , EE_CHAR_FONTHEIGHT_CJK, cppu::UnoType<float>::get(), 0 , 1|0x80 }, { u"" "CharFontNameAsian", EE_CHAR_FONTINFO_CJK, :: cppu::UnoType<OUString>::get(), 0, 1 }, { u"" "CharFontStyleNameAsian" , EE_CHAR_FONTINFO_CJK, ::cppu::UnoType<OUString>::get( ), 0, 2 }, { u"" "CharFontFamilyAsian", EE_CHAR_FONTINFO_CJK, ::cppu::UnoType<sal_Int16>::get(), 0, 3 }, { u"" "CharFontCharSetAsian" , EE_CHAR_FONTINFO_CJK, ::cppu::UnoType<sal_Int16>::get (), 0, 4 }, { u"" "CharFontPitchAsian", EE_CHAR_FONTINFO_CJK, ::cppu::UnoType<sal_Int16>::get(), 0, 5 }, { u"" "CharPostureAsian" , EE_CHAR_ITALIC_CJK, ::cppu::UnoType<css::awt::FontSlant> ::get(),0, 1 }, { u"" "CharWeightAsian", EE_CHAR_WEIGHT_CJK, cppu ::UnoType<float>::get(), 0, 1 }, { u"" "CharLocaleAsian" , EE_CHAR_LANGUAGE_CJK, ::cppu::UnoType<css::lang::Locale> ::get(),0, 1 }, { u"" "CharHeightComplex", EE_CHAR_FONTHEIGHT_CTL , cppu::UnoType<float>::get(), 0, 1|0x80 }, { u"" "CharFontNameComplex" , EE_CHAR_FONTINFO_CTL, ::cppu::UnoType<OUString>::get( ), 0, 1 }, { u"" "CharFontStyleNameComplex",EE_CHAR_FONTINFO_CTL , ::cppu::UnoType<OUString>::get(), 0, 2 }, { u"" "CharFontFamilyComplex" , EE_CHAR_FONTINFO_CTL, ::cppu::UnoType<sal_Int16>::get (), 0, 3 }, { u"" "CharFontCharSetComplex", EE_CHAR_FONTINFO_CTL , ::cppu::UnoType<sal_Int16>::get(), 0, 4 }, { u"" "CharFontPitchComplex" , EE_CHAR_FONTINFO_CTL, ::cppu::UnoType<sal_Int16>::get (), 0, 5 }, { u"" "CharPostureComplex", EE_CHAR_ITALIC_CTL, :: cppu::UnoType<css::awt::FontSlant>::get(),0, 1 }, { u"" "CharWeightComplex", EE_CHAR_WEIGHT_CTL, cppu::UnoType<float >::get(), 0, 1 }, { u"" "CharLocaleComplex", EE_CHAR_LANGUAGE_CTL , ::cppu::UnoType<css::lang::Locale>::get(),0, 1 }, { u"CharRelief" , EE_CHAR_RELIEF, ::cppu::UnoType<sal_Int16>::get(), 0, 0 }, { u"CharInteropGrabBag", EE_CHAR_GRABBAG, cppu::UnoType <css::uno::Sequence<css::beans::PropertyValue >>:: get(), 0, 0}, | |||
858 | SVX_UNOEDIT_FONT_PROPERTIES{u"" "FontDescriptor", 3900, cppu::UnoType<css::awt::FontDescriptor >::get(), 0, 1 }, | |||
859 | SVX_UNOEDIT_PARA_PROPERTIES{u"" "ParaAdjust", EE_PARA_JUST, ::cppu::UnoType<sal_Int16 >::get(), 0, 0 }, {u"" "ParaBottomMargin", EE_PARA_ULSPACE , ::cppu::UnoType<sal_Int32>::get(), 0, 4, PropertyMoreFlags ::METRIC_ITEM }, {u"" "ParaIsHyphenation", EE_PARA_HYPHENATE, ::cppu::UnoType<bool>::get(), 0, 0 }, {u"ParaHyphenationNoCaps" , EE_PARA_HYPHENATE_NO_CAPS, ::cppu::UnoType<bool>::get (), 0, 0 }, {u"" "ParaLastLineAdjust", EE_PARA_JUST, ::cppu:: UnoType<sal_Int16>::get(), 0, 1 }, {u"" "ParaLeftMargin" , EE_PARA_LRSPACE, ::cppu::UnoType<sal_Int32>::get(), 0 , 11, PropertyMoreFlags::METRIC_ITEM }, {u"" "ParaLineSpacing" , EE_PARA_SBL, cppu::UnoType<css::style::LineSpacing>:: get(), 0, 0x80}, {u"" "ParaRightMargin", EE_PARA_LRSPACE, ::cppu ::UnoType<sal_Int32>::get(), 0, 5, PropertyMoreFlags::METRIC_ITEM }, {u"" "ParaTabStops", EE_PARA_TABS, cppu::UnoType<css:: uno::Sequence< css::style::TabStop >>::get(), 0, 0 } , {u"" "ParaTopMargin", EE_PARA_ULSPACE, ::cppu::UnoType<sal_Int32 >::get(), 0, 3, PropertyMoreFlags::METRIC_ITEM }, {u"" "ParaFirstLineIndent" , EE_PARA_LRSPACE, ::cppu::UnoType<sal_Int32>::get(), 0 , 8, PropertyMoreFlags::METRIC_ITEM}, {u"" "ParaIsHangingPunctuation" ,EE_PARA_HANGINGPUNCTUATION, cppu::UnoType<bool>::get() , 0 ,0 }, {u"" "ParaIsCharacterDistance", EE_PARA_ASIANCJKSPACING , cppu::UnoType<bool>::get(), 0 ,0 }, {u"" "ParaIsForbiddenRules" , EE_PARA_FORBIDDENRULES, cppu::UnoType<bool>::get(), 0 ,0 }, {u"WritingMode", EE_PARA_WRITINGDIR, ::cppu::UnoType< sal_Int16>::get(), 0, 0 }, | |||
860 | SVX_UNOEDIT_NUMBERING_PROPERTIE{u"" "NumberingRules", EE_PARA_NUMBULLET, cppu::UnoType<css ::container::XIndexReplace>::get(), 0, 0 }, {u"" "NumberingIsNumber" , EE_PARA_BULLETSTATE,cppu::UnoType<bool>::get(), 0, 0 }, // for completeness of service ParagraphProperties | |||
861 | {u"" SC_UNONAME_TEXTUSER"TextUserDefinedAttributes", EE_CHAR_XMLATTRIBS, cppu::UnoType<container::XNameContainer>::get(), 0, 0}, | |||
862 | {u"" SC_UNONAME_USERDEF"UserDefinedAttributes", EE_PARA_XMLATTRIBS, cppu::UnoType<container::XNameContainer>::get(), 0, 0}, | |||
863 | { u"", 0, css::uno::Type(), 0, 0 } | |||
864 | }; | |||
865 | return aEditPropertyMap_Impl; | |||
866 | } | |||
867 | static const SvxItemPropertySet* lcl_GetEditPropertySet() | |||
868 | { | |||
869 | static SvxItemPropertySet aEditPropertySet( lcl_GetEditPropertyMap(), SdrObject::GetGlobalDrawObjectItemPool() ); | |||
870 | return &aEditPropertySet; | |||
871 | } | |||
872 | ||||
873 | using sc::HMMToTwips; | |||
874 | using sc::TwipsToHMM; | |||
875 | ||||
876 | #define SCCHARPROPERTIES_SERVICE"com.sun.star.style.CharacterProperties" "com.sun.star.style.CharacterProperties" | |||
877 | #define SCPARAPROPERTIES_SERVICE"com.sun.star.style.ParagraphProperties" "com.sun.star.style.ParagraphProperties" | |||
878 | #define SCCELLPROPERTIES_SERVICE"com.sun.star.table.CellProperties" "com.sun.star.table.CellProperties" | |||
879 | #define SCCELLRANGE_SERVICE"com.sun.star.table.CellRange" "com.sun.star.table.CellRange" | |||
880 | #define SCCELL_SERVICE"com.sun.star.table.Cell" "com.sun.star.table.Cell" | |||
881 | #define SCSHEETCELLRANGES_SERVICE"com.sun.star.sheet.SheetCellRanges" "com.sun.star.sheet.SheetCellRanges" | |||
882 | #define SCSHEETCELLRANGE_SERVICE"com.sun.star.sheet.SheetCellRange" "com.sun.star.sheet.SheetCellRange" | |||
883 | #define SCSPREADSHEET_SERVICE"com.sun.star.sheet.Spreadsheet" "com.sun.star.sheet.Spreadsheet" | |||
884 | #define SCSHEETCELL_SERVICE"com.sun.star.sheet.SheetCell" "com.sun.star.sheet.SheetCell" | |||
885 | ||||
886 | SC_SIMPLE_SERVICE_INFO( ScCellFormatsEnumeration, "ScCellFormatsEnumeration", "com.sun.star.sheet.CellFormatRangesEnumeration" )OUString ScCellFormatsEnumeration::getImplementationName() { return "ScCellFormatsEnumeration"; } sal_Bool ScCellFormatsEnumeration ::supportsService( const OUString& ServiceName ) { return cppu::supportsService(this, ServiceName); } css::uno::Sequence < OUString > ScCellFormatsEnumeration::getSupportedServiceNames () { css::uno::Sequence< OUString > aRet { "com.sun.star.sheet.CellFormatRangesEnumeration" }; return aRet; } | |||
887 | SC_SIMPLE_SERVICE_INFO( ScCellFormatsObj, "ScCellFormatsObj", "com.sun.star.sheet.CellFormatRanges" )OUString ScCellFormatsObj::getImplementationName() { return "ScCellFormatsObj" ; } sal_Bool ScCellFormatsObj::supportsService( const OUString & ServiceName ) { return cppu::supportsService(this, ServiceName ); } css::uno::Sequence< OUString > ScCellFormatsObj::getSupportedServiceNames () { css::uno::Sequence< OUString > aRet { "com.sun.star.sheet.CellFormatRanges" }; return aRet; } | |||
888 | SC_SIMPLE_SERVICE_INFO( ScUniqueCellFormatsEnumeration, "ScUniqueCellFormatsEnumeration", "com.sun.star.sheet.UniqueCellFormatRangesEnumeration" )OUString ScUniqueCellFormatsEnumeration::getImplementationName () { return "ScUniqueCellFormatsEnumeration"; } sal_Bool ScUniqueCellFormatsEnumeration ::supportsService( const OUString& ServiceName ) { return cppu::supportsService(this, ServiceName); } css::uno::Sequence < OUString > ScUniqueCellFormatsEnumeration::getSupportedServiceNames () { css::uno::Sequence< OUString > aRet { "com.sun.star.sheet.UniqueCellFormatRangesEnumeration" }; return aRet; } | |||
889 | SC_SIMPLE_SERVICE_INFO( ScUniqueCellFormatsObj, "ScUniqueCellFormatsObj", "com.sun.star.sheet.UniqueCellFormatRanges" )OUString ScUniqueCellFormatsObj::getImplementationName() { return "ScUniqueCellFormatsObj"; } sal_Bool ScUniqueCellFormatsObj:: supportsService( const OUString& ServiceName ) { return cppu ::supportsService(this, ServiceName); } css::uno::Sequence< OUString > ScUniqueCellFormatsObj::getSupportedServiceNames () { css::uno::Sequence< OUString > aRet { "com.sun.star.sheet.UniqueCellFormatRanges" }; return aRet; } | |||
890 | SC_SIMPLE_SERVICE_INFO( ScCellRangesBase, "ScCellRangesBase", "stardiv.unknown" )OUString ScCellRangesBase::getImplementationName() { return "ScCellRangesBase" ; } sal_Bool ScCellRangesBase::supportsService( const OUString & ServiceName ) { return cppu::supportsService(this, ServiceName ); } css::uno::Sequence< OUString > ScCellRangesBase::getSupportedServiceNames () { css::uno::Sequence< OUString > aRet { "stardiv.unknown" }; return aRet; } | |||
891 | SC_SIMPLE_SERVICE_INFO( ScCellsEnumeration, "ScCellsEnumeration", "com.sun.star.sheet.CellsEnumeration" )OUString ScCellsEnumeration::getImplementationName() { return "ScCellsEnumeration"; } sal_Bool ScCellsEnumeration::supportsService ( const OUString& ServiceName ) { return cppu::supportsService (this, ServiceName); } css::uno::Sequence< OUString > ScCellsEnumeration ::getSupportedServiceNames() { css::uno::Sequence< OUString > aRet { "com.sun.star.sheet.CellsEnumeration" }; return aRet ; } | |||
892 | SC_SIMPLE_SERVICE_INFO( ScCellsObj, "ScCellsObj", "com.sun.star.sheet.Cells" )OUString ScCellsObj::getImplementationName() { return "ScCellsObj" ; } sal_Bool ScCellsObj::supportsService( const OUString& ServiceName ) { return cppu::supportsService(this, ServiceName ); } css::uno::Sequence< OUString > ScCellsObj::getSupportedServiceNames () { css::uno::Sequence< OUString > aRet { "com.sun.star.sheet.Cells" }; return aRet; } | |||
893 | SC_SIMPLE_SERVICE_INFO( ScTableColumnObj, "ScTableColumnObj", "com.sun.star.table.TableColumn" )OUString ScTableColumnObj::getImplementationName() { return "ScTableColumnObj" ; } sal_Bool ScTableColumnObj::supportsService( const OUString & ServiceName ) { return cppu::supportsService(this, ServiceName ); } css::uno::Sequence< OUString > ScTableColumnObj::getSupportedServiceNames () { css::uno::Sequence< OUString > aRet { "com.sun.star.table.TableColumn" }; return aRet; } | |||
894 | SC_SIMPLE_SERVICE_INFO( ScTableRowObj, "ScTableRowObj", "com.sun.star.table.TableRow" )OUString ScTableRowObj::getImplementationName() { return "ScTableRowObj" ; } sal_Bool ScTableRowObj::supportsService( const OUString& ServiceName ) { return cppu::supportsService(this, ServiceName ); } css::uno::Sequence< OUString > ScTableRowObj::getSupportedServiceNames () { css::uno::Sequence< OUString > aRet { "com.sun.star.table.TableRow" }; return aRet; } | |||
895 | ||||
896 | //! move ScLinkListener into another file !!! | |||
897 | ||||
898 | ScLinkListener::~ScLinkListener() | |||
899 | { | |||
900 | } | |||
901 | ||||
902 | void ScLinkListener::Notify( const SfxHint& rHint ) | |||
903 | { | |||
904 | aLink.Call( rHint ); | |||
905 | } | |||
906 | ||||
907 | static void lcl_CopyProperties( beans::XPropertySet& rDest, beans::XPropertySet& rSource ) | |||
908 | { | |||
909 | uno::Reference<beans::XPropertySetInfo> xInfo(rSource.getPropertySetInfo()); | |||
910 | if (xInfo.is()) | |||
911 | { | |||
912 | const uno::Sequence<beans::Property> aSeq(xInfo->getProperties()); | |||
913 | for (const beans::Property& rProp : aSeq) | |||
914 | { | |||
915 | OUString aName(rProp.Name); | |||
916 | rDest.setPropertyValue( aName, rSource.getPropertyValue( aName ) ); | |||
917 | } | |||
918 | } | |||
919 | } | |||
920 | ||||
921 | static SCTAB lcl_FirstTab( const ScRangeList& rRanges ) | |||
922 | { | |||
923 | if (rRanges.empty()) | |||
924 | throw std::out_of_range("empty range"); | |||
925 | const ScRange & rFirst = rRanges[0]; | |||
926 | return rFirst.aStart.Tab(); | |||
927 | } | |||
928 | ||||
929 | static bool lcl_WholeSheet( const ScDocument& rDoc, const ScRangeList& rRanges ) | |||
930 | { | |||
931 | if ( rRanges.size() == 1 ) | |||
932 | { | |||
933 | const ScRange & rRange = rRanges[0]; | |||
934 | if ( rRange.aStart.Col() == 0 && rRange.aEnd.Col() == rDoc.MaxCol() && | |||
935 | rRange.aStart.Row() == 0 && rRange.aEnd.Row() == rDoc.MaxRow() ) | |||
936 | return true; | |||
937 | } | |||
938 | return false; | |||
939 | } | |||
940 | ||||
941 | namespace { | |||
942 | template<typename BorderLineType> | |||
943 | const ::editeng::SvxBorderLine* lcl_getBorderLine( | |||
944 | ::editeng::SvxBorderLine& rLine, const BorderLineType& rStruct ) | |||
945 | { | |||
946 | // Convert from 1/100mm to Twips. | |||
947 | if (!SvxBoxItem::LineToSvxLine( rStruct, rLine, true)) | |||
948 | return nullptr; | |||
949 | ||||
950 | if ( rLine.GetOutWidth() || rLine.GetInWidth() || rLine.GetDistance() ) | |||
951 | return &rLine; | |||
952 | else | |||
953 | return nullptr; | |||
954 | } | |||
955 | } | |||
956 | ||||
957 | const ::editeng::SvxBorderLine* ScHelperFunctions::GetBorderLine( | |||
958 | ::editeng::SvxBorderLine& rLine, const table::BorderLine& rStruct ) | |||
959 | { | |||
960 | return lcl_getBorderLine( rLine, rStruct); | |||
961 | } | |||
962 | ||||
963 | const ::editeng::SvxBorderLine* ScHelperFunctions::GetBorderLine( | |||
964 | ::editeng::SvxBorderLine& rLine, const table::BorderLine2& rStruct ) | |||
965 | { | |||
966 | return lcl_getBorderLine( rLine, rStruct); | |||
967 | } | |||
968 | ||||
969 | namespace { | |||
970 | template<typename TableBorderType> | |||
971 | void lcl_fillBoxItems( SvxBoxItem& rOuter, SvxBoxInfoItem& rInner, const TableBorderType& rBorder ) | |||
972 | { | |||
973 | ::editeng::SvxBorderLine aLine; | |||
974 | rOuter.SetAllDistances(static_cast<sal_uInt16>(HMMToTwips(rBorder.Distance))); | |||
975 | rOuter.SetLine( ScHelperFunctions::GetBorderLine( aLine, rBorder.TopLine ), SvxBoxItemLine::TOP ); | |||
976 | rOuter.SetLine( ScHelperFunctions::GetBorderLine( aLine, rBorder.BottomLine ), SvxBoxItemLine::BOTTOM ); | |||
977 | rOuter.SetLine( ScHelperFunctions::GetBorderLine( aLine, rBorder.LeftLine ), SvxBoxItemLine::LEFT ); | |||
978 | rOuter.SetLine( ScHelperFunctions::GetBorderLine( aLine, rBorder.RightLine ), SvxBoxItemLine::RIGHT ); | |||
979 | rInner.SetLine( ScHelperFunctions::GetBorderLine( aLine, rBorder.HorizontalLine ), SvxBoxInfoItemLine::HORI ); | |||
980 | rInner.SetLine( ScHelperFunctions::GetBorderLine( aLine, rBorder.VerticalLine ), SvxBoxInfoItemLine::VERT ); | |||
981 | rInner.SetValid( SvxBoxInfoItemValidFlags::TOP, rBorder.IsTopLineValid ); | |||
982 | rInner.SetValid( SvxBoxInfoItemValidFlags::BOTTOM, rBorder.IsBottomLineValid ); | |||
983 | rInner.SetValid( SvxBoxInfoItemValidFlags::LEFT, rBorder.IsLeftLineValid ); | |||
984 | rInner.SetValid( SvxBoxInfoItemValidFlags::RIGHT, rBorder.IsRightLineValid ); | |||
985 | rInner.SetValid( SvxBoxInfoItemValidFlags::HORI, rBorder.IsHorizontalLineValid ); | |||
986 | rInner.SetValid( SvxBoxInfoItemValidFlags::VERT, rBorder.IsVerticalLineValid ); | |||
987 | rInner.SetValid( SvxBoxInfoItemValidFlags::DISTANCE, rBorder.IsDistanceValid ); | |||
988 | rInner.SetTable( true ); | |||
989 | } | |||
990 | } | |||
991 | ||||
992 | void ScHelperFunctions::FillBoxItems( SvxBoxItem& rOuter, SvxBoxInfoItem& rInner, const table::TableBorder& rBorder ) | |||
993 | { | |||
994 | lcl_fillBoxItems( rOuter, rInner, rBorder); | |||
995 | } | |||
996 | ||||
997 | void ScHelperFunctions::FillBoxItems( SvxBoxItem& rOuter, SvxBoxInfoItem& rInner, const table::TableBorder2& rBorder ) | |||
998 | { | |||
999 | lcl_fillBoxItems( rOuter, rInner, rBorder); | |||
1000 | } | |||
1001 | ||||
1002 | void ScHelperFunctions::FillBorderLine( table::BorderLine& rStruct, const ::editeng::SvxBorderLine* pLine ) | |||
1003 | { | |||
1004 | // Convert from Twips to 1/100mm. | |||
1005 | table::BorderLine2 aStruct( SvxBoxItem::SvxLineToLine( pLine, true)); | |||
1006 | rStruct = aStruct; | |||
1007 | } | |||
1008 | ||||
1009 | void ScHelperFunctions::FillBorderLine( table::BorderLine2& rStruct, const ::editeng::SvxBorderLine* pLine ) | |||
1010 | { | |||
1011 | rStruct = SvxBoxItem::SvxLineToLine( pLine, true); | |||
1012 | } | |||
1013 | ||||
1014 | namespace { | |||
1015 | template<typename TableBorderItem> | |||
1016 | void lcl_fillTableBorder( TableBorderItem& rBorder, const SvxBoxItem& rOuter, const SvxBoxInfoItem& rInner, | |||
1017 | bool bInvalidateHorVerDist ) | |||
1018 | { | |||
1019 | ScHelperFunctions::FillBorderLine( rBorder.TopLine, rOuter.GetTop() ); | |||
1020 | ScHelperFunctions::FillBorderLine( rBorder.BottomLine, rOuter.GetBottom() ); | |||
1021 | ScHelperFunctions::FillBorderLine( rBorder.LeftLine, rOuter.GetLeft() ); | |||
1022 | ScHelperFunctions::FillBorderLine( rBorder.RightLine, rOuter.GetRight() ); | |||
1023 | ScHelperFunctions::FillBorderLine( rBorder.HorizontalLine, rInner.GetHori() ); | |||
1024 | ScHelperFunctions::FillBorderLine( rBorder.VerticalLine, rInner.GetVert() ); | |||
1025 | ||||
1026 | rBorder.Distance = rOuter.GetSmallestDistance(); | |||
1027 | rBorder.IsTopLineValid = rInner.IsValid(SvxBoxInfoItemValidFlags::TOP); | |||
1028 | rBorder.IsBottomLineValid = rInner.IsValid(SvxBoxInfoItemValidFlags::BOTTOM); | |||
1029 | rBorder.IsLeftLineValid = rInner.IsValid(SvxBoxInfoItemValidFlags::LEFT); | |||
1030 | rBorder.IsRightLineValid = rInner.IsValid(SvxBoxInfoItemValidFlags::RIGHT); | |||
1031 | rBorder.IsHorizontalLineValid = !bInvalidateHorVerDist && rInner.IsValid(SvxBoxInfoItemValidFlags::HORI); | |||
1032 | rBorder.IsVerticalLineValid = !bInvalidateHorVerDist && rInner.IsValid(SvxBoxInfoItemValidFlags::VERT); | |||
1033 | rBorder.IsDistanceValid = !bInvalidateHorVerDist && rInner.IsValid(SvxBoxInfoItemValidFlags::DISTANCE); | |||
1034 | } | |||
1035 | } | |||
1036 | ||||
1037 | void ScHelperFunctions::AssignTableBorderToAny( uno::Any& rAny, | |||
1038 | const SvxBoxItem& rOuter, const SvxBoxInfoItem& rInner, bool bInvalidateHorVerDist ) | |||
1039 | { | |||
1040 | table::TableBorder aBorder; | |||
1041 | lcl_fillTableBorder( aBorder, rOuter, rInner, bInvalidateHorVerDist); | |||
1042 | rAny <<= aBorder; | |||
1043 | } | |||
1044 | ||||
1045 | void ScHelperFunctions::AssignTableBorder2ToAny( uno::Any& rAny, | |||
1046 | const SvxBoxItem& rOuter, const SvxBoxInfoItem& rInner, bool bInvalidateHorVerDist ) | |||
1047 | { | |||
1048 | table::TableBorder2 aBorder; | |||
1049 | lcl_fillTableBorder( aBorder, rOuter, rInner, bInvalidateHorVerDist); | |||
1050 | rAny <<= aBorder; | |||
1051 | } | |||
1052 | ||||
1053 | //! move lcl_ApplyBorder to docfunc ! | |||
1054 | ||||
1055 | void ScHelperFunctions::ApplyBorder( ScDocShell* pDocShell, const ScRangeList& rRanges, | |||
1056 | const SvxBoxItem& rOuter, const SvxBoxInfoItem& rInner ) | |||
1057 | { | |||
1058 | ScDocument& rDoc = pDocShell->GetDocument(); | |||
1059 | bool bUndo(rDoc.IsUndoEnabled()); | |||
1060 | ScDocumentUniquePtr pUndoDoc; | |||
1061 | if (bUndo) | |||
1062 | pUndoDoc.reset(new ScDocument( SCDOCMODE_UNDO )); | |||
1063 | size_t nCount = rRanges.size(); | |||
1064 | for (size_t i = 0; i < nCount; ++i) | |||
1065 | { | |||
1066 | ScRange const & rRange = rRanges[ i ]; | |||
1067 | SCTAB nTab = rRange.aStart.Tab(); | |||
1068 | ||||
1069 | if (bUndo) | |||
1070 | { | |||
1071 | if ( i==0 ) | |||
1072 | pUndoDoc->InitUndo( rDoc, nTab, nTab ); | |||
1073 | else | |||
1074 | pUndoDoc->AddUndoTab( nTab, nTab ); | |||
1075 | rDoc.CopyToDocument(rRange, InsertDeleteFlags::ATTRIB, false, *pUndoDoc); | |||
1076 | } | |||
1077 | ||||
1078 | ScMarkData aMark(rDoc.GetSheetLimits()); | |||
1079 | aMark.SetMarkArea( rRange ); | |||
1080 | aMark.SelectTable( nTab, true ); | |||
1081 | ||||
1082 | rDoc.ApplySelectionFrame(aMark, rOuter, &rInner); | |||
1083 | // don't need RowHeight if there is only a border | |||
1084 | } | |||
1085 | ||||
1086 | if (bUndo) | |||
1087 | { | |||
1088 | pDocShell->GetUndoManager()->AddUndoAction( | |||
1089 | std::make_unique<ScUndoBorder>( pDocShell, rRanges, std::move(pUndoDoc), rOuter, rInner ) ); | |||
1090 | } | |||
1091 | ||||
1092 | for (size_t i = 0; i < nCount; ++i ) | |||
1093 | pDocShell->PostPaint( rRanges[ i ], PaintPartFlags::Grid, SC_PF_LINES1 | SC_PF_TESTMERGE2 ); | |||
1094 | ||||
1095 | pDocShell->SetDocumentModified(); | |||
1096 | } | |||
1097 | ||||
1098 | //! move lcl_PutDataArray to docfunc? | |||
1099 | //! merge loop with ScFunctionAccess::callFunction | |||
1100 | ||||
1101 | static bool lcl_PutDataArray( ScDocShell& rDocShell, const ScRange& rRange, | |||
1102 | const uno::Sequence< uno::Sequence<uno::Any> >& aData ) | |||
1103 | { | |||
1104 | ScDocument& rDoc = rDocShell.GetDocument(); | |||
1105 | SCTAB nTab = rRange.aStart.Tab(); | |||
1106 | SCCOL nStartCol = rRange.aStart.Col(); | |||
1107 | SCROW nStartRow = rRange.aStart.Row(); | |||
1108 | SCCOL nEndCol = rRange.aEnd.Col(); | |||
1109 | SCROW nEndRow = rRange.aEnd.Row(); | |||
1110 | bool bUndo(rDoc.IsUndoEnabled()); | |||
1111 | ||||
1112 | if ( !rDoc.IsBlockEditable( nTab, nStartCol,nStartRow, nEndCol,nEndRow ) ) | |||
1113 | { | |||
1114 | //! error message | |||
1115 | return false; | |||
1116 | } | |||
1117 | ||||
1118 | long nCols = 0; | |||
1119 | long nRows = aData.getLength(); | |||
1120 | if ( nRows ) | |||
1121 | nCols = aData[0].getLength(); | |||
1122 | ||||
1123 | if ( nCols != nEndCol-nStartCol+1 || nRows != nEndRow-nStartRow+1 ) | |||
1124 | { | |||
1125 | //! error message? | |||
1126 | return false; | |||
1127 | } | |||
1128 | ||||
1129 | ScDocumentUniquePtr pUndoDoc; | |||
1130 | if ( bUndo ) | |||
1131 | { | |||
1132 | pUndoDoc.reset(new ScDocument( SCDOCMODE_UNDO )); | |||
1133 | pUndoDoc->InitUndo( rDoc, nTab, nTab ); | |||
1134 | rDoc.CopyToDocument(rRange, InsertDeleteFlags::CONTENTS|InsertDeleteFlags::NOCAPTIONS, false, *pUndoDoc); | |||
1135 | } | |||
1136 | ||||
1137 | rDoc.DeleteAreaTab( nStartCol, nStartRow, nEndCol, nEndRow, nTab, InsertDeleteFlags::CONTENTS ); | |||
1138 | ||||
1139 | bool bError = false; | |||
1140 | SCROW nDocRow = nStartRow; | |||
1141 | for (const uno::Sequence<uno::Any>& rColSeq : aData) | |||
1142 | { | |||
1143 | if ( rColSeq.getLength() == nCols ) | |||
1144 | { | |||
1145 | SCCOL nDocCol = nStartCol; | |||
1146 | for (const uno::Any& rElement : rColSeq) | |||
1147 | { | |||
1148 | ScAddress aPos(nDocCol, nDocRow, nTab); | |||
1149 | ||||
1150 | switch( rElement.getValueTypeClass() ) | |||
1151 | { | |||
1152 | case uno::TypeClass_VOID: | |||
1153 | { | |||
1154 | // void = "no value" | |||
1155 | rDoc.SetError( nDocCol, nDocRow, nTab, FormulaError::NotAvailable ); | |||
1156 | } | |||
1157 | break; | |||
1158 | ||||
1159 | // #87871# accept integer types because Basic passes a floating point | |||
1160 | // variable as byte, short or long if it's an integer number. | |||
1161 | case uno::TypeClass_BYTE: | |||
1162 | case uno::TypeClass_SHORT: | |||
1163 | case uno::TypeClass_UNSIGNED_SHORT: | |||
1164 | case uno::TypeClass_LONG: | |||
1165 | case uno::TypeClass_UNSIGNED_LONG: | |||
1166 | case uno::TypeClass_FLOAT: | |||
1167 | case uno::TypeClass_DOUBLE: | |||
1168 | { | |||
1169 | double fVal(0.0); | |||
1170 | rElement >>= fVal; | |||
1171 | rDoc.SetValue(aPos, fVal); | |||
1172 | } | |||
1173 | break; | |||
1174 | ||||
1175 | case uno::TypeClass_STRING: | |||
1176 | { | |||
1177 | OUString aUStr; | |||
1178 | rElement >>= aUStr; | |||
1179 | if ( !aUStr.isEmpty() ) | |||
1180 | { | |||
1181 | ScSetStringParam aParam; | |||
1182 | aParam.setTextInput(); | |||
1183 | rDoc.SetString(aPos, aUStr, &aParam); | |||
1184 | } | |||
1185 | } | |||
1186 | break; | |||
1187 | ||||
1188 | // accept Sequence<FormulaToken> for formula cells | |||
1189 | case uno::TypeClass_SEQUENCE: | |||
1190 | { | |||
1191 | uno::Sequence< sheet::FormulaToken > aTokens; | |||
1192 | if ( rElement >>= aTokens ) | |||
1193 | { | |||
1194 | ScTokenArray aTokenArray(rDoc); | |||
1195 | ScTokenConversion::ConvertToTokenArray( rDoc, aTokenArray, aTokens ); | |||
1196 | rDoc.SetFormula(aPos, aTokenArray); | |||
1197 | } | |||
1198 | else | |||
1199 | bError = true; | |||
1200 | } | |||
1201 | break; | |||
1202 | ||||
1203 | default: | |||
1204 | bError = true; // invalid type | |||
1205 | } | |||
1206 | ++nDocCol; | |||
1207 | } | |||
1208 | } | |||
1209 | else | |||
1210 | bError = true; // wrong size | |||
1211 | ||||
1212 | ++nDocRow; | |||
1213 | } | |||
1214 | ||||
1215 | bool bHeight = rDocShell.AdjustRowHeight( nStartRow, nEndRow, nTab ); | |||
1216 | ||||
1217 | if ( pUndoDoc ) | |||
1218 | { | |||
1219 | ScMarkData aDestMark(rDoc.GetSheetLimits()); | |||
1220 | aDestMark.SelectOneTable( nTab ); | |||
1221 | rDocShell.GetUndoManager()->AddUndoAction( | |||
1222 | std::make_unique<ScUndoPaste>( | |||
1223 | &rDocShell, ScRange(nStartCol, nStartRow, nTab, nEndCol, nEndRow, nTab), | |||
1224 | aDestMark, std::move(pUndoDoc), nullptr, InsertDeleteFlags::CONTENTS, nullptr, false)); | |||
1225 | } | |||
1226 | ||||
1227 | if (!bHeight) | |||
1228 | rDocShell.PostPaint( rRange, PaintPartFlags::Grid ); // AdjustRowHeight may have painted already | |||
1229 | ||||
1230 | rDocShell.SetDocumentModified(); | |||
1231 | ||||
1232 | return !bError; | |||
1233 | } | |||
1234 | ||||
1235 | static bool lcl_PutFormulaArray( ScDocShell& rDocShell, const ScRange& rRange, | |||
1236 | const uno::Sequence< uno::Sequence<OUString> >& aData, | |||
1237 | const formula::FormulaGrammar::Grammar eGrammar ) | |||
1238 | { | |||
1239 | ScDocument& rDoc = rDocShell.GetDocument(); | |||
1240 | SCTAB nTab = rRange.aStart.Tab(); | |||
1241 | SCCOL nStartCol = rRange.aStart.Col(); | |||
1242 | SCROW nStartRow = rRange.aStart.Row(); | |||
1243 | SCCOL nEndCol = rRange.aEnd.Col(); | |||
1244 | SCROW nEndRow = rRange.aEnd.Row(); | |||
1245 | bool bUndo(rDoc.IsUndoEnabled()); | |||
1246 | ||||
1247 | if ( !rDoc.IsBlockEditable( nTab, nStartCol,nStartRow, nEndCol,nEndRow ) ) | |||
1248 | { | |||
1249 | //! error message | |||
1250 | return false; | |||
1251 | } | |||
1252 | ||||
1253 | long nCols = 0; | |||
1254 | long nRows = aData.getLength(); | |||
1255 | if ( nRows ) | |||
1256 | nCols = aData[0].getLength(); | |||
1257 | ||||
1258 | if ( nCols != nEndCol-nStartCol+1 || nRows != nEndRow-nStartRow+1 ) | |||
1259 | { | |||
1260 | //! error message? | |||
1261 | return false; | |||
1262 | } | |||
1263 | ||||
1264 | ScDocumentUniquePtr pUndoDoc; | |||
1265 | if ( bUndo ) | |||
1266 | { | |||
1267 | pUndoDoc.reset(new ScDocument( SCDOCMODE_UNDO )); | |||
1268 | pUndoDoc->InitUndo( rDoc, nTab, nTab ); | |||
1269 | rDoc.CopyToDocument(rRange, InsertDeleteFlags::CONTENTS, false, *pUndoDoc); | |||
1270 | } | |||
1271 | ||||
1272 | rDoc.DeleteAreaTab( nStartCol, nStartRow, nEndCol, nEndRow, nTab, InsertDeleteFlags::CONTENTS ); | |||
1273 | ||||
1274 | bool bError = false; | |||
1275 | SCROW nDocRow = nStartRow; | |||
1276 | for (const uno::Sequence<OUString>& rColSeq : aData) | |||
1277 | { | |||
1278 | if ( rColSeq.getLength() == nCols ) | |||
1279 | { | |||
1280 | SCCOL nDocCol = nStartCol; | |||
1281 | for (const OUString& aText : rColSeq) | |||
1282 | { | |||
1283 | ScAddress aPos( nDocCol, nDocRow, nTab ); | |||
1284 | ||||
1285 | ScInputStringType aRes = | |||
1286 | ScStringUtil::parseInputString( | |||
1287 | *rDoc.GetFormatTable(), aText, LANGUAGE_ENGLISH_USLanguageType(0x0409)); | |||
1288 | switch (aRes.meType) | |||
1289 | { | |||
1290 | case ScInputStringType::Formula: | |||
1291 | rDoc.SetFormula(aPos, aRes.maText, eGrammar); | |||
1292 | break; | |||
1293 | case ScInputStringType::Number: | |||
1294 | rDoc.SetValue(aPos, aRes.mfValue); | |||
1295 | break; | |||
1296 | case ScInputStringType::Text: | |||
1297 | rDoc.SetTextCell(aPos, aRes.maText); | |||
1298 | break; | |||
1299 | default: | |||
1300 | ; | |||
1301 | } | |||
1302 | ||||
1303 | ++nDocCol; | |||
1304 | } | |||
1305 | } | |||
1306 | else | |||
1307 | bError = true; // wrong size | |||
1308 | ||||
1309 | ++nDocRow; | |||
1310 | } | |||
1311 | ||||
1312 | bool bHeight = rDocShell.AdjustRowHeight( nStartRow, nEndRow, nTab ); | |||
1313 | ||||
1314 | if ( pUndoDoc ) | |||
1315 | { | |||
1316 | ScMarkData aDestMark(rDoc.GetSheetLimits()); | |||
1317 | aDestMark.SelectOneTable( nTab ); | |||
1318 | rDocShell.GetUndoManager()->AddUndoAction( | |||
1319 | std::make_unique<ScUndoPaste>( &rDocShell, | |||
1320 | ScRange(nStartCol, nStartRow, nTab, nEndCol, nEndRow, nTab), aDestMark, | |||
1321 | std::move(pUndoDoc), nullptr, InsertDeleteFlags::CONTENTS, nullptr, false)); | |||
1322 | } | |||
1323 | ||||
1324 | if (!bHeight) | |||
1325 | rDocShell.PostPaint( rRange, PaintPartFlags::Grid ); // AdjustRowHeight may have painted already | |||
1326 | ||||
1327 | rDocShell.SetDocumentModified(); | |||
1328 | ||||
1329 | return !bError; | |||
1330 | } | |||
1331 | ||||
1332 | // used in ScCellRangeObj::getFormulaArray and ScCellObj::GetInputString_Impl | |||
1333 | static OUString lcl_GetInputString( ScDocument& rDoc, const ScAddress& rPos, bool bEnglish ) | |||
1334 | { | |||
1335 | ScRefCellValue aCell(rDoc, rPos); | |||
1336 | if (aCell.isEmpty()) | |||
1337 | return EMPTY_OUSTRINGScGlobal::GetEmptyOUString(); | |||
1338 | ||||
1339 | OUString aVal; | |||
1340 | ||||
1341 | CellType eType = aCell.meType; | |||
1342 | if (eType == CELLTYPE_FORMULA) | |||
1343 | { | |||
1344 | ScFormulaCell* pForm = aCell.mpFormula; | |||
1345 | pForm->GetFormula( aVal, formula::FormulaGrammar::mapAPItoGrammar( bEnglish, false)); | |||
1346 | return aVal; | |||
1347 | } | |||
1348 | ||||
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); | |||
1355 | ||||
1356 | if (eType == CELLTYPE_EDIT) | |||
1357 | { | |||
1358 | // GetString on EditCell turns breaks into spaces, | |||
1359 | // but we need the breaks here | |||
1360 | const EditTextObject* pData = aCell.mpEditText; | |||
1361 | if (pData) | |||
1362 | { | |||
1363 | EditEngine& rEngine = rDoc.GetEditEngine(); | |||
1364 | rEngine.SetText(*pData); | |||
1365 | aVal = rEngine.GetText(); | |||
1366 | } | |||
1367 | } | |||
1368 | else | |||
1369 | ScCellFormat::GetInputString(aCell, nNumFmt, aVal, *pFormatter, rDoc); | |||
1370 | ||||
1371 | // if applicable, prepend ' like in ScTabViewShell::UpdateInputHandler | |||
1372 | if ( eType == CELLTYPE_STRING || eType == CELLTYPE_EDIT ) | |||
1373 | { | |||
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("'") ) | |||
1380 | { | |||
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) != SvNumFormatType::TEXT ) ) | |||
1384 | aTempString = "'" + aTempString; | |||
1385 | } | |||
1386 | aVal = aTempString; | |||
1387 | } | |||
1388 | return aVal; | |||
1389 | } | |||
1390 | ||||
1391 | ScCellRangesBase::ScCellRangesBase(ScDocShell* pDocSh, const ScRange& rR) : | |||
1392 | pPropSet(lcl_GetCellsPropertySet()), | |||
1393 | pDocShell( pDocSh ), | |||
1394 | nObjectId( 0 ), | |||
1395 | bChartColAsHdr( false ), | |||
1396 | bChartRowAsHdr( false ), | |||
1397 | bCursorOnly( false ), | |||
1398 | bGotDataChangedHint( false ), | |||
1399 | aValueListeners( 0 ) | |||
1400 | { | |||
1401 | // this is a hack to get m_wThis initialized; ideally there would be | |||
1402 | // factory functions doing this but there are so many subclasses of this... | |||
1403 | osl_atomic_increment(&m_refCount)__sync_add_and_fetch((&m_refCount), 1); | |||
1404 | { | |||
1405 | m_wThis = uno::Reference<uno::XInterface>( | |||
1406 | static_cast<cppu::OWeakObject*>(this)); | |||
1407 | } | |||
1408 | osl_atomic_decrement(&m_refCount)__sync_sub_and_fetch((&m_refCount), 1); | |||
1409 | ||||
1410 | ScRange aCellRange(rR); | |||
1411 | aCellRange.PutInOrder(); | |||
1412 | aRanges.push_back( aCellRange ); | |||
1413 | ||||
1414 | if (pDocShell) // Null if created with createInstance | |||
1415 | { | |||
1416 | ScDocument& rDoc = pDocShell->GetDocument(); | |||
1417 | rDoc.AddUnoObject(*this); | |||
1418 | nObjectId = rDoc.GetNewUnoId(); | |||
1419 | } | |||
1420 | } | |||
1421 | ||||
1422 | ScCellRangesBase::ScCellRangesBase(ScDocShell* pDocSh, const ScRangeList& rR) : | |||
1423 | pPropSet(lcl_GetCellsPropertySet()), | |||
1424 | pDocShell( pDocSh ), | |||
1425 | aRanges( rR ), | |||
1426 | nObjectId( 0 ), | |||
1427 | bChartColAsHdr( false ), | |||
1428 | bChartRowAsHdr( false ), | |||
1429 | bCursorOnly( false ), | |||
1430 | bGotDataChangedHint( false ), | |||
1431 | aValueListeners( 0 ) | |||
1432 | { | |||
1433 | // this is a hack to get m_wThis initialized; ideally there would be | |||
1434 | // factory functions doing this but there are so many subclasses of this... | |||
1435 | osl_atomic_increment(&m_refCount)__sync_add_and_fetch((&m_refCount), 1); | |||
1436 | { | |||
1437 | m_wThis = uno::Reference<uno::XInterface>( | |||
| ||||
1438 | static_cast<cppu::OWeakObject*>(this)); | |||
1439 | } | |||
1440 | osl_atomic_decrement(&m_refCount)__sync_sub_and_fetch((&m_refCount), 1); | |||
1441 | ||||
1442 | if (pDocShell) // Null if created with createInstance | |||
1443 | { | |||
1444 | ScDocument& rDoc = pDocShell->GetDocument(); | |||
1445 | rDoc.AddUnoObject(*this); | |||
1446 | nObjectId = rDoc.GetNewUnoId(); | |||
1447 | } | |||
1448 | } | |||
1449 | ||||
1450 | ScCellRangesBase::~ScCellRangesBase() | |||
1451 | { | |||
1452 | SolarMutexGuard g; | |||
1453 | ||||
1454 | // call RemoveUnoObject first, so no notification can happen | |||
1455 | // during ForgetCurrentAttrs | |||
1456 | ||||
1457 | if (pDocShell) | |||
1458 | pDocShell->GetDocument().RemoveUnoObject(*this); | |||
1459 | ||||
1460 | ForgetCurrentAttrs(); | |||
1461 | ForgetMarkData(); | |||
1462 | ||||
1463 | pValueListener.reset(); | |||
1464 | ||||
1465 | //! unregister XChartDataChangeEventListener ?? | |||
1466 | //! (ChartCollection will then hold this object as well!) | |||
1467 | } | |||
1468 | ||||
1469 | void ScCellRangesBase::ForgetCurrentAttrs() | |||
1470 | { | |||
1471 | pCurrentFlat.reset(); | |||
1472 | pCurrentDeep.reset(); | |||
1473 | pCurrentDataSet.reset(); | |||
1474 | pNoDfltCurrentDataSet.reset(); | |||
1475 | pCurrentDataSet = nullptr; | |||
1476 | pNoDfltCurrentDataSet = nullptr; | |||
1477 | ||||
1478 | // #i62483# pMarkData can remain unchanged, is deleted only if the range changes (RefChanged) | |||
1479 | } | |||
1480 | ||||
1481 | void ScCellRangesBase::ForgetMarkData() | |||
1482 | { | |||
1483 | pMarkData.reset(); | |||
1484 | } | |||
1485 | ||||
1486 | const ScPatternAttr* ScCellRangesBase::GetCurrentAttrsFlat() | |||
1487 | { | |||
1488 | // get and cache direct cell attributes for this object's range | |||
1489 | ||||
1490 | if ( !pCurrentFlat && pDocShell ) | |||
1491 | { | |||
1492 | ScDocument& rDoc = pDocShell->GetDocument(); | |||
1493 | pCurrentFlat = rDoc.CreateSelectionPattern( *GetMarkData(), false ); | |||
1494 | } | |||
1495 | return pCurrentFlat.get(); | |||
1496 | } | |||
1497 | ||||
1498 | const ScPatternAttr* ScCellRangesBase::GetCurrentAttrsDeep() | |||
1499 | { | |||
1500 | // get and cache cell attributes (incl. styles) for this object's range | |||
1501 | ||||
1502 | if ( !pCurrentDeep && pDocShell ) | |||
1503 | { | |||
1504 | ScDocument& rDoc = pDocShell->GetDocument(); | |||
1505 | pCurrentDeep = rDoc.CreateSelectionPattern( *GetMarkData() ); | |||
1506 | } | |||
1507 | return pCurrentDeep.get(); | |||
1508 | } | |||
1509 | ||||
1510 | SfxItemSet* ScCellRangesBase::GetCurrentDataSet(bool bNoDflt) | |||
1511 | { | |||
1512 | if(!pCurrentDataSet) | |||
1513 | { | |||
1514 | const ScPatternAttr* pPattern = GetCurrentAttrsDeep(); | |||
1515 | if ( pPattern ) | |||
1516 | { | |||
1517 | // replace Dontcare with Default, so that we always have a reflection | |||
1518 | pCurrentDataSet.reset( new SfxItemSet( pPattern->GetItemSet() ) ); | |||
1519 | pNoDfltCurrentDataSet.reset( new SfxItemSet( pPattern->GetItemSet() ) ); | |||
1520 | pCurrentDataSet->ClearInvalidItems(); | |||
1521 | } | |||
1522 | } | |||
1523 | return bNoDflt ? pNoDfltCurrentDataSet.get() : pCurrentDataSet.get(); | |||
1524 | } | |||
1525 | ||||
1526 | const ScMarkData* ScCellRangesBase::GetMarkData() | |||
1527 | { | |||
1528 | if (!pMarkData) | |||
1529 | { | |||
1530 | pMarkData.reset( new ScMarkData(GetDocument()->GetSheetLimits(), aRanges) ); | |||
1531 | } | |||
1532 | return pMarkData.get(); | |||
1533 | } | |||
1534 | ||||
1535 | void ScCellRangesBase::Notify( SfxBroadcaster&, const SfxHint& rHint ) | |||
1536 | { | |||
1537 | uno::Reference<uno::XInterface> const xThis(m_wThis); | |||
1538 | if (!xThis.is()) | |||
1539 | { // fdo#72695: if UNO object is already dead, don't revive it with event | |||
1540 | if (SfxHintId::Dying == rHint.GetId()) | |||
1541 | { // if the document dies, must reset to avoid crash in dtor! | |||
1542 | ForgetCurrentAttrs(); | |||
1543 | pDocShell = nullptr; | |||
1544 | } | |||
1545 | return; | |||
1546 | } | |||
1547 | if ( dynamic_cast<const ScUpdateRefHint*>(&rHint) ) | |||
1548 | { | |||
1549 | const ScUpdateRefHint& rRef = static_cast<const ScUpdateRefHint&>(rHint); | |||
1550 | ||||
1551 | ScDocument& rDoc = pDocShell->GetDocument(); | |||
1552 | std::unique_ptr<ScRangeList> pUndoRanges; | |||
1553 | if ( rDoc.HasUnoRefUndo() ) | |||
1554 | pUndoRanges.reset(new ScRangeList( aRanges )); | |||
1555 | ||||
1556 | if ( aRanges.UpdateReference( rRef.GetMode(), &rDoc, rRef.GetRange(), | |||
1557 | rRef.GetDx(), rRef.GetDy(), rRef.GetDz() ) ) | |||
1558 | { | |||
1559 | if ( rRef.GetMode() == URM_INSDEL | |||
1560 | && aRanges.size() == 1 | |||
1561 | && comphelper::getUnoTunnelImplementation<ScTableSheetObj>(xThis) | |||
1562 | ) | |||
1563 | { | |||
1564 | // #101755#; the range size of a sheet does not change | |||
1565 | ScRange & rR = aRanges.front(); | |||
1566 | rR.aStart.SetCol(0); | |||
1567 | rR.aStart.SetRow(0); | |||
1568 | rR.aEnd.SetCol(rDoc.MaxCol()); | |||
1569 | rR.aEnd.SetRow(rDoc.MaxRow()); | |||
1570 | } | |||
1571 | RefChanged(); | |||
1572 | ||||
1573 | // any change of the range address is broadcast to value (modify) listeners | |||
1574 | if ( !aValueListeners.empty() ) | |||
1575 | bGotDataChangedHint = true; | |||
1576 | ||||
1577 | if ( pUndoRanges ) | |||
1578 | rDoc.AddUnoRefChange( nObjectId, *pUndoRanges ); | |||
1579 | } | |||
1580 | } | |||
1581 | else if ( dynamic_cast<const ScUnoRefUndoHint*>(&rHint) ) | |||
1582 | { | |||
1583 | const ScUnoRefUndoHint& rUndoHint = static_cast<const ScUnoRefUndoHint&>(rHint); | |||
1584 | if ( rUndoHint.GetObjectId() == nObjectId ) | |||
1585 | { | |||
1586 | // restore ranges from hint | |||
1587 | ||||
1588 | aRanges = rUndoHint.GetRanges(); | |||
1589 | ||||
1590 | RefChanged(); | |||
1591 | if ( !aValueListeners.empty() ) | |||
1592 | bGotDataChangedHint = true; // need to broadcast the undo, too | |||
1593 | } | |||
1594 | } | |||
1595 | else | |||
1596 | { | |||
1597 | const SfxHintId nId = rHint.GetId(); | |||
1598 | if ( nId == SfxHintId::Dying ) | |||
1599 | { | |||
1600 | ForgetCurrentAttrs(); | |||
1601 | pDocShell = nullptr; // invalid | |||
1602 | ||||
1603 | if ( !aValueListeners.empty() ) | |||
1604 | { | |||
1605 | // dispose listeners | |||
1606 | ||||
1607 | lang::EventObject aEvent; | |||
1608 | aEvent.Source.set(static_cast<cppu::OWeakObject*>(this)); | |||
1609 | for (uno::Reference<util::XModifyListener> & xValueListener : aValueListeners) | |||
1610 | xValueListener->disposing( aEvent ); | |||
1611 | ||||
1612 | aValueListeners.clear(); | |||
1613 | ||||
1614 | // The listeners can't have the last ref to this, as it's still held | |||
1615 | // by the DocShell. | |||
1616 | } | |||
1617 | } | |||
1618 | else if ( nId == SfxHintId::DataChanged ) | |||
1619 | { | |||
1620 | // document content changed -> forget cached attributes | |||
1621 | ForgetCurrentAttrs(); | |||
1622 | ||||
1623 | if ( bGotDataChangedHint && pDocShell ) | |||
1624 | { | |||
1625 | // This object was notified of content changes, so one call | |||
1626 | // for each listener is generated now. | |||
1627 | // The calls can't be executed directly because the document's | |||
1628 | // UNO broadcaster list must not be modified. | |||
1629 | // Instead, add to the document's list of listener calls, | |||
1630 | // which will be executed directly after the broadcast of | |||
1631 | // SfxHintId::DataChanged. | |||
1632 | ||||
1633 | lang::EventObject aEvent; | |||
1634 | aEvent.Source.set(static_cast<cppu::OWeakObject*>(this)); | |||
1635 | ||||
1636 | // the EventObject holds a Ref to this object until after the listener calls | |||
1637 | ||||
1638 | ScDocument& rDoc = pDocShell->GetDocument(); | |||
1639 | for (const uno::Reference<util::XModifyListener> & xValueListener : aValueListeners) | |||
1640 | rDoc.AddUnoListenerCall( xValueListener, aEvent ); | |||
1641 | ||||
1642 | bGotDataChangedHint = false; | |||
1643 | } | |||
1644 | } | |||
1645 | else if ( nId == SfxHintId::ScCalcAll ) | |||
1646 | { | |||
1647 | // broadcast from DoHardRecalc - set bGotDataChangedHint | |||
1648 | // (SfxHintId::DataChanged follows separately) | |||
1649 | ||||
1650 | if ( !aValueListeners.empty() ) | |||
1651 | bGotDataChangedHint = true; | |||
1652 | } | |||
1653 | } | |||
1654 | } | |||
1655 | ||||
1656 | void ScCellRangesBase::RefChanged() | |||
1657 | { | |||
1658 | //! adjust XChartDataChangeEventListener | |||
1659 | ||||
1660 | if ( pValueListener && !aValueListeners.empty() ) | |||
1661 | { | |||
1662 | pValueListener->EndListeningAll(); | |||
1663 | ||||
1664 | ScDocument& rDoc = pDocShell->GetDocument(); | |||
1665 | for ( size_t i = 0, nCount = aRanges.size(); i < nCount; ++i ) | |||
1666 | rDoc.StartListeningArea( aRanges[ i ], false, pValueListener.get() ); | |||
1667 | } | |||
1668 | ||||
1669 | ForgetCurrentAttrs(); | |||
1670 | ForgetMarkData(); | |||
1671 | } | |||
1672 | ||||
1673 | ScDocument* ScCellRangesBase::GetDocument() const | |||
1674 | { | |||
1675 | if (pDocShell) | |||
1676 | return &pDocShell->GetDocument(); | |||
1677 | else | |||
1678 | return nullptr; | |||
1679 | } | |||
1680 | ||||
1681 | void ScCellRangesBase::InitInsertRange(ScDocShell* pDocSh, const ScRange& rR) | |||
1682 | { | |||
1683 | if ( pDocShell || !pDocSh ) | |||
1684 | return; | |||
1685 | ||||
1686 | pDocShell = pDocSh; | |||
1687 | ||||
1688 | ScRange aCellRange(rR); | |||
1689 | aCellRange.PutInOrder(); | |||
1690 | aRanges.RemoveAll(); | |||
1691 | aRanges.push_back( aCellRange ); | |||
1692 | ||||
1693 | pDocShell->GetDocument().AddUnoObject(*this); | |||
1694 | ||||
1695 | RefChanged(); // adjust range in range object | |||
1696 | } | |||
1697 | ||||
1698 | void ScCellRangesBase::AddRange(const ScRange& rRange, const bool bMergeRanges) | |||
1699 | { | |||
1700 | if (bMergeRanges) | |||
1701 | aRanges.Join(rRange); | |||
1702 | else | |||
1703 | aRanges.push_back(rRange); | |||
1704 | RefChanged(); | |||
1705 | } | |||
1706 | ||||
1707 | void ScCellRangesBase::SetNewRange(const ScRange& rNew) | |||
1708 | { | |||
1709 | ScRange aCellRange(rNew); | |||
1710 | aCellRange.PutInOrder(); | |||
1711 | ||||
1712 | aRanges.RemoveAll(); | |||
1713 | aRanges.push_back( aCellRange ); | |||
1714 | RefChanged(); | |||
1715 | } | |||
1716 | ||||
1717 | void ScCellRangesBase::SetNewRanges(const ScRangeList& rNew) | |||
1718 | { | |||
1719 | aRanges = rNew; | |||
1720 | RefChanged(); | |||
1721 | } | |||
1722 | ||||
1723 | void ScCellRangesBase::SetCursorOnly( bool bSet ) | |||
1724 | { | |||
1725 | // set for a selection object that is created from the cursor position | |||
1726 | // without anything selected (may contain several sheets) | |||
1727 | ||||
1728 | bCursorOnly = bSet; | |||
1729 | } | |||
1730 | ||||
1731 | void ScCellRangesBase::PaintGridRanges_Impl( ) | |||
1732 | { | |||
1733 | for (size_t i = 0, nCount = aRanges.size(); i < nCount; ++i) | |||
1734 | pDocShell->PostPaint( aRanges[ i ], PaintPartFlags::Grid ); | |||
1735 | } | |||
1736 | ||||
1737 | // XSheetOperation | |||
1738 | ||||
1739 | double SAL_CALL ScCellRangesBase::computeFunction( sheet::GeneralFunction nFunction ) | |||
1740 | { | |||
1741 | SolarMutexGuard aGuard; | |||
1742 | ScMarkData aMark(*GetMarkData()); | |||
1743 | aMark.MarkToSimple(); | |||
1744 | if (!aMark.IsMarked()) | |||
1745 | aMark.SetMarkNegative(true); // so we can enter dummy position | |||
1746 | ||||
1747 | ScAddress aDummy; // if not marked, ignored if it is negative | |||
1748 | double fVal; | |||
1749 | ScSubTotalFunc eFunc = ScDPUtil::toSubTotalFunc(static_cast<ScGeneralFunction>(nFunction)); | |||
1750 | ScDocument& rDoc = pDocShell->GetDocument(); | |||
1751 | if ( !rDoc.GetSelectionFunction( eFunc, aDummy, aMark, fVal ) ) | |||
1752 | { | |||
1753 | throw uno::RuntimeException(); //! own exception? | |||
1754 | } | |||
1755 | ||||
1756 | return fVal; | |||
1757 | } | |||
1758 | ||||
1759 | void SAL_CALL ScCellRangesBase::clearContents( sal_Int32 nContentFlags ) | |||
1760 | { | |||
1761 | SolarMutexGuard aGuard; | |||
1762 | if ( !aRanges.empty() ) | |||
1763 | { | |||
1764 | // only for clearContents: EDITATTR is only used if no contents are deleted | |||
1765 | InsertDeleteFlags nDelFlags = static_cast<InsertDeleteFlags>(nContentFlags) & InsertDeleteFlags::ALL; | |||
1766 | if ( ( nDelFlags & InsertDeleteFlags::EDITATTR ) && ( nDelFlags & InsertDeleteFlags::CONTENTS ) == InsertDeleteFlags::NONE ) | |||
1767 | nDelFlags |= InsertDeleteFlags::EDITATTR; | |||
1768 | ||||
1769 | pDocShell->GetDocFunc().DeleteContents( *GetMarkData(), nDelFlags, true, true ); | |||
1770 | } | |||
1771 | // otherwise nothing to do | |||
1772 | } | |||
1773 | ||||
1774 | // XPropertyState | |||
1775 | ||||
1776 | const SfxItemPropertyMap& ScCellRangesBase::GetItemPropertyMap() | |||
1777 | { | |||
1778 | return pPropSet->getPropertyMap(); | |||
1779 | } | |||
1780 | ||||
1781 | static void lcl_GetPropertyWhich( const SfxItemPropertySimpleEntry* pEntry, | |||
1782 | sal_uInt16& rItemWhich ) | |||
1783 | { | |||
1784 | // Which-ID of the affected items also when the item can't handle | |||
1785 | // the property by itself | |||
1786 | if ( !pEntry ) | |||
1787 | return; | |||
1788 | ||||
1789 | if ( IsScItemWid( pEntry->nWID ) ) | |||
1790 | rItemWhich = pEntry->nWID; | |||
1791 | else | |||
1792 | switch ( pEntry->nWID ) | |||
1793 | { | |||
1794 | case SC_WID_UNO_TBLBORD( 1200 + 6 ): | |||
1795 | case SC_WID_UNO_TBLBORD2( 1200 + 43 ): | |||
1796 | rItemWhich = ATTR_BORDER; | |||
1797 | break; | |||
1798 | case SC_WID_UNO_CONDFMT( 1200 + 3 ): | |||
1799 | case SC_WID_UNO_CONDLOC( 1200 + 4 ): | |||
1800 | case SC_WID_UNO_CONDXML( 1200 + 5 ): | |||
1801 | rItemWhich = ATTR_CONDITIONAL; | |||
1802 | break; | |||
1803 | case SC_WID_UNO_VALIDAT( 1200 + 7 ): | |||
1804 | case SC_WID_UNO_VALILOC( 1200 + 8 ): | |||
1805 | case SC_WID_UNO_VALIXML( 1200 + 9 ): | |||
1806 | rItemWhich = ATTR_VALIDDATA; | |||
1807 | break; | |||
1808 | } | |||
1809 | ||||
1810 | } | |||
1811 | ||||
1812 | beans::PropertyState ScCellRangesBase::GetOnePropertyState( sal_uInt16 nItemWhich, const SfxItemPropertySimpleEntry* pEntry ) | |||
1813 | { | |||
1814 | beans::PropertyState eRet = beans::PropertyState_DIRECT_VALUE; | |||
1815 | if ( nItemWhich ) // item wid (from map or special case) | |||
1816 | { | |||
1817 | // For items that contain several properties (like background), | |||
1818 | // "ambiguous" is returned too often here | |||
1819 | ||||
1820 | // for PropertyState, don't look at styles | |||
1821 | const ScPatternAttr* pPattern = GetCurrentAttrsFlat(); | |||
1822 | if ( pPattern ) | |||
1823 | { | |||
1824 | SfxItemState eState = pPattern->GetItemSet().GetItemState( nItemWhich, false ); | |||
1825 | ||||
1826 | if ( nItemWhich == ATTR_VALUE_FORMAT && eState == SfxItemState::DEFAULT ) | |||
1827 | eState = pPattern->GetItemSet().GetItemState( ATTR_LANGUAGE_FORMAT, false ); | |||
1828 | ||||
1829 | if ( eState == SfxItemState::SET ) | |||
1830 | eRet = beans::PropertyState_DIRECT_VALUE; | |||
1831 | else if ( eState == SfxItemState::DEFAULT ) | |||
1832 | eRet = beans::PropertyState_DEFAULT_VALUE; | |||
1833 | else if ( eState == SfxItemState::DONTCARE ) | |||
1834 | eRet = beans::PropertyState_AMBIGUOUS_VALUE; | |||
1835 | else | |||
1836 | { | |||
1837 | OSL_FAIL("unknown ItemState")do { if (true && (((sal_Bool)1))) { sal_detail_logFormat ((SAL_DETAIL_LOG_LEVEL_WARN), ("legacy.osl"), ("/home/maarten/src/libreoffice/core/sc/source/ui/unoobj/cellsuno.cxx" ":" "1837" ": "), "%s", "unknown ItemState"); } } while (false ); | |||
1838 | } | |||
1839 | } | |||
1840 | } | |||
1841 | else if ( pEntry ) | |||
1842 | { | |||
1843 | if ( pEntry->nWID == SC_WID_UNO_CHCOLHDR( 1200 + 1 ) || pEntry->nWID == SC_WID_UNO_CHROWHDR( 1200 + 2 ) || pEntry->nWID == SC_WID_UNO_ABSNAME( 1200 + 39 ) ) | |||
1844 | eRet = beans::PropertyState_DIRECT_VALUE; | |||
1845 | else if ( pEntry->nWID == SC_WID_UNO_CELLSTYL( 1200 + 0 ) ) | |||
1846 | { | |||
1847 | // a style is always set, there's no default state | |||
1848 | const ScStyleSheet* pStyle = pDocShell->GetDocument().GetSelectionStyle(*GetMarkData()); | |||
1849 | if (pStyle) | |||
1850 | eRet = beans::PropertyState_DIRECT_VALUE; | |||
1851 | else | |||
1852 | eRet = beans::PropertyState_AMBIGUOUS_VALUE; | |||
1853 | } | |||
1854 | else if ( pEntry->nWID == SC_WID_UNO_NUMRULES( 1200 + 28 ) ) | |||
1855 | eRet = beans::PropertyState_DEFAULT_VALUE; // numbering rules are always default | |||
1856 | } | |||
1857 | return eRet; | |||
1858 | } | |||
1859 | ||||
1860 | beans::PropertyState SAL_CALL ScCellRangesBase::getPropertyState( const OUString& aPropertyName ) | |||
1861 | { | |||
1862 | SolarMutexGuard aGuard; | |||
1863 | if ( aRanges.empty() ) | |||
1864 | throw uno::RuntimeException(); | |||
1865 | ||||
1866 | const SfxItemPropertyMap& rMap = GetItemPropertyMap(); // from derived class | |||
1867 | sal_uInt16 nItemWhich = 0; | |||
1868 | const SfxItemPropertySimpleEntry* pEntry = rMap.getByName( aPropertyName ); | |||
1869 | lcl_GetPropertyWhich( pEntry, nItemWhich ); | |||
1870 | return GetOnePropertyState( nItemWhich, pEntry ); | |||
1871 | } | |||
1872 | ||||
1873 | uno::Sequence<beans::PropertyState> SAL_CALL ScCellRangesBase::getPropertyStates( | |||
1874 | const uno::Sequence<OUString>& aPropertyNames ) | |||
1875 | { | |||
1876 | SolarMutexGuard aGuard; | |||
1877 | ||||
1878 | const SfxItemPropertyMap& rPropertyMap = GetItemPropertyMap(); // from derived class | |||
1879 | ||||
1880 | uno::Sequence<beans::PropertyState> aRet(aPropertyNames.getLength()); | |||
1881 | std::transform(aPropertyNames.begin(), aPropertyNames.end(), aRet.begin(), | |||
1882 | [this, &rPropertyMap](const auto& rName) -> beans::PropertyState { | |||
1883 | sal_uInt16 nItemWhich = 0; | |||
1884 | const SfxItemPropertySimpleEntry* pEntry = rPropertyMap.getByName( rName ); | |||
1885 | lcl_GetPropertyWhich( pEntry, nItemWhich ); | |||
1886 | return GetOnePropertyState(nItemWhich, pEntry); | |||
1887 | }); | |||
1888 | return aRet; | |||
1889 | } | |||
1890 | ||||
1891 | void SAL_CALL ScCellRangesBase::setPropertyToDefault( const OUString& aPropertyName ) | |||
1892 | { | |||
1893 | SolarMutexGuard aGuard; | |||
1894 | if ( !pDocShell ) | |||
1895 | return; | |||
1896 | ||||
1897 | const SfxItemPropertyMap& rPropertyMap = GetItemPropertyMap(); // from derived class | |||
1898 | sal_uInt16 nItemWhich = 0; | |||
1899 | const SfxItemPropertySimpleEntry* pEntry = rPropertyMap.getByName( aPropertyName ); | |||
1900 | lcl_GetPropertyWhich( pEntry, nItemWhich ); | |||
1901 | if ( nItemWhich ) // item wid (from map or special case) | |||
1902 | { | |||
1903 | if ( !aRanges.empty() ) // empty = nothing to do | |||
1904 | { | |||
1905 | //! for items that have multiple properties (e.g. background) | |||
1906 | //! too much will be reset | |||
1907 | //! for ATTR_ROTATE_VALUE, reset ATTR_ORIENTATION as well? | |||
1908 | ||||
1909 | sal_uInt16 aWIDs[3]; | |||
1910 | aWIDs[0] = nItemWhich; | |||
1911 | if ( nItemWhich == ATTR_VALUE_FORMAT ) | |||
1912 | { | |||
1913 | aWIDs[1] = ATTR_LANGUAGE_FORMAT; // language for number formats | |||
1914 | aWIDs[2] = 0; | |||
1915 | } | |||
1916 | else | |||
1917 | aWIDs[1] = 0; | |||
1918 | pDocShell->GetDocFunc().ClearItems( *GetMarkData(), aWIDs, true ); | |||
1919 | } | |||
1920 | } | |||
1921 | else if ( pEntry ) | |||
1922 | { | |||
1923 | if ( pEntry->nWID == SC_WID_UNO_CHCOLHDR( 1200 + 1 ) ) | |||
1924 | bChartColAsHdr = false; | |||
1925 | else if ( pEntry->nWID == SC_WID_UNO_CHROWHDR( 1200 + 2 ) ) | |||
1926 | bChartRowAsHdr = false; | |||
1927 | else if ( pEntry->nWID == SC_WID_UNO_CELLSTYL( 1200 + 0 ) ) | |||
1928 | { | |||
1929 | OUString aStyleName( ScResId( STR_STYLENAME_STANDARD_CELLreinterpret_cast<char const *>("STR_STYLENAME_STANDARD" "\004" u8"Default Cell Style") ) ); | |||
1930 | pDocShell->GetDocFunc().ApplyStyle( *GetMarkData(), aStyleName, true ); | |||
1931 | } | |||
1932 | } | |||
1933 | } | |||
1934 | ||||
1935 | uno::Any SAL_CALL ScCellRangesBase::getPropertyDefault( const OUString& aPropertyName ) | |||
1936 | { | |||
1937 | //! bundle with getPropertyValue | |||
1938 | ||||
1939 | SolarMutexGuard aGuard; | |||
1940 | uno::Any aAny; | |||
1941 | ||||
1942 | if ( pDocShell ) | |||
1943 | { | |||
1944 | ScDocument& rDoc = pDocShell->GetDocument(); | |||
1945 | const SfxItemPropertyMap& rPropertyMap = GetItemPropertyMap(); // from derived class | |||
1946 | const SfxItemPropertySimpleEntry* pEntry = rPropertyMap.getByName( aPropertyName ); | |||
1947 | if ( pEntry ) | |||
1948 | { | |||
1949 | if ( IsScItemWid( pEntry->nWID ) ) | |||
1950 | { | |||
1951 | const ScPatternAttr* pPattern = rDoc.GetDefPattern(); | |||
1952 | if ( pPattern ) | |||
1953 | { | |||
1954 | const SfxItemSet& rSet = pPattern->GetItemSet(); | |||
1955 | ||||
1956 | switch ( pEntry->nWID ) // for item-specific handling | |||
1957 | { | |||
1958 | case ATTR_VALUE_FORMAT: | |||
1959 | // default has no language set | |||
1960 | aAny <<= static_cast<sal_Int32>( static_cast<const SfxUInt32Item&>(rSet.Get(pEntry->nWID)).GetValue() ); | |||
1961 | break; | |||
1962 | case ATTR_INDENT: | |||
1963 | aAny <<= static_cast<sal_Int16>( TwipsToHMM(static_cast<const ScIndentItem&>( | |||
1964 | rSet.Get(pEntry->nWID)).GetValue()) ); | |||
1965 | break; | |||
1966 | default: | |||
1967 | pPropSet->getPropertyValue(aPropertyName, rSet, aAny); | |||
1968 | } | |||
1969 | } | |||
1970 | } | |||
1971 | else | |||
1972 | switch ( pEntry->nWID ) | |||
1973 | { | |||
1974 | case SC_WID_UNO_CHCOLHDR( 1200 + 1 ): | |||
1975 | case SC_WID_UNO_CHROWHDR( 1200 + 2 ): | |||
1976 | aAny <<= false; | |||
1977 | break; | |||
1978 | case SC_WID_UNO_CELLSTYL( 1200 + 0 ): | |||
1979 | aAny <<= ScStyleNameConversion::DisplayToProgrammaticName( | |||
1980 | ScResId(STR_STYLENAME_STANDARD_CELLreinterpret_cast<char const *>("STR_STYLENAME_STANDARD" "\004" u8"Default Cell Style")), SfxStyleFamily::Para ); | |||
1981 | break; | |||
1982 | case SC_WID_UNO_TBLBORD( 1200 + 6 ): | |||
1983 | case SC_WID_UNO_TBLBORD2( 1200 + 43 ): | |||
1984 | { | |||
1985 | const ScPatternAttr* pPattern = rDoc.GetDefPattern(); | |||
1986 | if ( pPattern ) | |||
1987 | { | |||
1988 | if (pEntry->nWID == SC_WID_UNO_TBLBORD2( 1200 + 43 )) | |||
1989 | ScHelperFunctions::AssignTableBorder2ToAny( aAny, | |||
1990 | pPattern->GetItem(ATTR_BORDER), | |||
1991 | pPattern->GetItem(ATTR_BORDER_INNER) ); | |||
1992 | else | |||
1993 | ScHelperFunctions::AssignTableBorderToAny( aAny, | |||
1994 | pPattern->GetItem(ATTR_BORDER), | |||
1995 | pPattern->GetItem(ATTR_BORDER_INNER) ); | |||
1996 | } | |||
1997 | } | |||
1998 | break; | |||
1999 | case SC_WID_UNO_CONDFMT( 1200 + 3 ): | |||
2000 | case SC_WID_UNO_CONDLOC( 1200 + 4 ): | |||
2001 | case SC_WID_UNO_CONDXML( 1200 + 5 ): | |||
2002 | { | |||
2003 | bool bEnglish = ( pEntry->nWID != SC_WID_UNO_CONDLOC( 1200 + 4 ) ); | |||
2004 | bool bXML = ( pEntry->nWID == SC_WID_UNO_CONDXML( 1200 + 5 ) ); | |||
2005 | formula::FormulaGrammar::Grammar eGrammar = (bXML ? | |||
2006 | rDoc.GetStorageGrammar() : | |||
2007 | formula::FormulaGrammar::mapAPItoGrammar( bEnglish, bXML)); | |||
2008 | ||||
2009 | aAny <<= uno::Reference<sheet::XSheetConditionalEntries>( | |||
2010 | new ScTableConditionalFormat( &rDoc, 0, aRanges[0].aStart.Tab(), eGrammar )); | |||
2011 | } | |||
2012 | break; | |||
2013 | case SC_WID_UNO_VALIDAT( 1200 + 7 ): | |||
2014 | case SC_WID_UNO_VALILOC( 1200 + 8 ): | |||
2015 | case SC_WID_UNO_VALIXML( 1200 + 9 ): | |||
2016 | { | |||
2017 | bool bEnglish = ( pEntry->nWID != SC_WID_UNO_VALILOC( 1200 + 8 ) ); | |||
2018 | bool bXML = ( pEntry->nWID == SC_WID_UNO_VALIXML( 1200 + 9 ) ); | |||
2019 | formula::FormulaGrammar::Grammar eGrammar = (bXML ? | |||
2020 | rDoc.GetStorageGrammar() : | |||
2021 | formula::FormulaGrammar::mapAPItoGrammar( bEnglish, bXML)); | |||
2022 | ||||
2023 | aAny <<= uno::Reference<beans::XPropertySet>( | |||
2024 | new ScTableValidationObj( rDoc, 0, eGrammar )); | |||
2025 | } | |||
2026 | break; | |||
2027 | case SC_WID_UNO_NUMRULES( 1200 + 28 ): | |||
2028 | { | |||
2029 | aAny <<= ScStyleObj::CreateEmptyNumberingRules(); | |||
2030 | } | |||
2031 | break; | |||
2032 | } | |||
2033 | } | |||
2034 | } | |||
2035 | ||||
2036 | return aAny; | |||
2037 | } | |||
2038 | ||||
2039 | // XPropertySet | |||
2040 | ||||
2041 | uno::Reference<beans::XPropertySetInfo> SAL_CALL ScCellRangesBase::getPropertySetInfo() | |||
2042 | { | |||
2043 | SolarMutexGuard aGuard; | |||
2044 | static uno::Reference<beans::XPropertySetInfo> aRef( | |||
2045 | new SfxItemPropertySetInfo( pPropSet->getPropertyMap() )); | |||
2046 | return aRef; | |||
2047 | } | |||
2048 | ||||
2049 | static void lcl_SetCellProperty( const SfxItemPropertySimpleEntry& rEntry, const uno::Any& rValue, | |||
2050 | ScPatternAttr& rPattern, const ScDocument &rDoc, | |||
2051 | sal_uInt16& rFirstItemId, sal_uInt16& rSecondItemId ) | |||
2052 | { | |||
2053 | rFirstItemId = rEntry.nWID; | |||
2054 | rSecondItemId = 0; | |||
2055 | ||||
2056 | SfxItemSet& rSet = rPattern.GetItemSet(); | |||
2057 | switch ( rEntry.nWID ) | |||
2058 | { | |||
2059 | case ATTR_VALUE_FORMAT: | |||
2060 | { | |||
2061 | // language for number formats | |||
2062 | SvNumberFormatter* pFormatter = rDoc.GetFormatTable(); | |||
2063 | sal_uLong nOldFormat = rSet.Get( ATTR_VALUE_FORMAT ).GetValue(); | |||
2064 | LanguageType eOldLang = rSet.Get( ATTR_LANGUAGE_FORMAT ).GetLanguage(); | |||
2065 | nOldFormat = pFormatter->GetFormatForLanguageIfBuiltIn( nOldFormat, eOldLang ); | |||
2066 | ||||
2067 | sal_Int32 nIntVal = 0; | |||
2068 | if ( !(rValue >>= nIntVal) ) | |||
2069 | throw lang::IllegalArgumentException(); | |||
2070 | ||||
2071 | sal_uLong nNewFormat = static_cast<sal_uLong>(nIntVal); | |||
2072 | rSet.Put( SfxUInt32Item( ATTR_VALUE_FORMAT, nNewFormat ) ); | |||
2073 | ||||
2074 | const SvNumberformat* pNewEntry = pFormatter->GetEntry( nNewFormat ); | |||
2075 | LanguageType eNewLang = | |||
2076 | pNewEntry ? pNewEntry->GetLanguage() : LANGUAGE_DONTKNOWLanguageType(0x03FF); | |||
2077 | if ( eNewLang != eOldLang && eNewLang != LANGUAGE_DONTKNOWLanguageType(0x03FF) ) | |||
2078 | { | |||
2079 | rSet.Put( SvxLanguageItem( eNewLang, ATTR_LANGUAGE_FORMAT ) ); | |||
2080 | ||||
2081 | // if only language is changed, | |||
2082 | // don't touch number format attribute | |||
2083 | sal_uLong nNewMod = nNewFormat % SV_COUNTRY_LANGUAGE_OFFSET10000; | |||
2084 | if ( nNewMod == ( nOldFormat % SV_COUNTRY_LANGUAGE_OFFSET10000 ) && | |||
2085 | nNewMod <= SV_MAX_COUNT_STANDARD_FORMATS100 ) | |||
2086 | { | |||
2087 | rFirstItemId = 0; // don't use ATTR_VALUE_FORMAT value | |||
2088 | } | |||
2089 | ||||
2090 | rSecondItemId = ATTR_LANGUAGE_FORMAT; | |||
2091 | } | |||
2092 | ||||
2093 | } | |||
2094 | break; | |||
2095 | case ATTR_INDENT: | |||
2096 | { | |||
2097 | sal_Int16 nIntVal = 0; | |||
2098 | if ( !(rValue >>= nIntVal) ) | |||
2099 | throw lang::IllegalArgumentException(); | |||
2100 | ||||
2101 | rSet.Put( ScIndentItem( static_cast<sal_uInt16>(HMMToTwips(nIntVal)) ) ); | |||
2102 | ||||
2103 | } | |||
2104 | break; | |||
2105 | case ATTR_ROTATE_VALUE: | |||
2106 | { | |||
2107 | sal_Int32 nRotVal = 0; | |||
2108 | if ( !(rValue >>= nRotVal) ) | |||
2109 | throw lang::IllegalArgumentException(); | |||
2110 | ||||
2111 | // stored value is always between 0 and 360 deg. | |||
2112 | nRotVal %= 36000; | |||
2113 | if ( nRotVal < 0 ) | |||
2114 | nRotVal += 36000; | |||
2115 | ||||
2116 | rSet.Put( ScRotateValueItem( nRotVal ) ); | |||
2117 | ||||
2118 | } | |||
2119 | break; | |||
2120 | case ATTR_STACKED: | |||
2121 | { | |||
2122 | table::CellOrientation eOrient; | |||
2123 | if( rValue >>= eOrient ) | |||
2124 | { | |||
2125 | switch( eOrient ) | |||
2126 | { | |||
2127 | case table::CellOrientation_STANDARD: | |||
2128 | rSet.Put( ScVerticalStackCell( false ) ); | |||
2129 | break; | |||
2130 | case table::CellOrientation_TOPBOTTOM: | |||
2131 | rSet.Put( ScVerticalStackCell( false ) ); | |||
2132 | rSet.Put( ScRotateValueItem( 27000 ) ); | |||
2133 | rSecondItemId = ATTR_ROTATE_VALUE; | |||
2134 | break; | |||
2135 | case table::CellOrientation_BOTTOMTOP: | |||
2136 | rSet.Put( ScVerticalStackCell( false ) ); | |||
2137 | rSet.Put( ScRotateValueItem( 9000 ) ); | |||
2138 | rSecondItemId = ATTR_ROTATE_VALUE; | |||
2139 | break; | |||
2140 | case table::CellOrientation_STACKED: | |||
2141 | rSet.Put( ScVerticalStackCell( true ) ); | |||
2142 | break; | |||
2143 | default: | |||
2144 | { | |||
2145 | // added to avoid warnings | |||
2146 | } | |||
2147 | } | |||
2148 | } | |||
2149 | } | |||
2150 | break; | |||
2151 | default: | |||
2152 | { | |||
2153 | lcl_GetCellsPropertySet()->setPropertyValue(rEntry, rValue, rSet); | |||
2154 | } | |||
2155 | } | |||
2156 | } | |||
2157 | ||||
2158 | void SAL_CALL ScCellRangesBase::setPropertyValue( | |||
2159 | const OUString& aPropertyName, const uno::Any& aValue ) | |||
2160 | { | |||
2161 | SolarMutexGuard aGuard; | |||
2162 | ||||
2163 | if ( !pDocShell || aRanges.empty() ) | |||
2164 | throw uno::RuntimeException(); | |||
2165 | ||||
2166 | const SfxItemPropertyMap& rPropertyMap = GetItemPropertyMap(); // from derived class | |||
2167 | const SfxItemPropertySimpleEntry* pEntry = rPropertyMap.getByName( aPropertyName ); | |||
2168 | if ( !pEntry ) | |||
2169 | throw beans::UnknownPropertyException(aPropertyName); | |||
2170 | ||||
2171 | SetOnePropertyValue( pEntry, aValue ); | |||
2172 | } | |||
2173 | ||||
2174 | void ScCellRangesBase::SetOnePropertyValue( const SfxItemPropertySimpleEntry* pEntry, const uno::Any& aValue ) | |||
2175 | { | |||
2176 | if ( !pEntry ) | |||
2177 | return; | |||
2178 | ||||
2179 | if ( IsScItemWid( pEntry->nWID ) ) | |||
2180 | { | |||
2181 | if ( !aRanges.empty() ) // empty = nothing to do | |||
2182 | { | |||
2183 | ScDocument& rDoc = pDocShell->GetDocument(); | |||
2184 | ||||
2185 | // For parts of compound items with multiple properties (e.g. background) | |||
2186 | // the old item has to be first fetched from the document. | |||
2187 | //! But we can't recognize this case here | |||
2188 | //! -> an extra flag in PropertyMap entry, or something like that??? | |||
2189 | //! fetch the item directly from its position in the range? | |||
2190 | // ClearInvalidItems, so that in any case we have an item with the correct type | |||
2191 | ||||
2192 | ScPatternAttr aPattern( *GetCurrentAttrsDeep() ); | |||
2193 | SfxItemSet& rSet = aPattern.GetItemSet(); | |||
2194 | rSet.ClearInvalidItems(); | |||
2195 | ||||
2196 | sal_uInt16 nFirstItem, nSecondItem; | |||
2197 | lcl_SetCellProperty( *pEntry, aValue, aPattern, rDoc, nFirstItem, nSecondItem ); | |||
2198 | ||||
2199 | for (sal_uInt16 nWhich = ATTR_PATTERN_START; nWhich <= ATTR_PATTERN_END; nWhich++) | |||
2200 | if ( nWhich != nFirstItem && nWhich != nSecondItem ) | |||
2201 | rSet.ClearItem(nWhich); | |||
2202 | ||||
2203 | pDocShell->GetDocFunc().ApplyAttributes( *GetMarkData(), aPattern, true ); | |||
2204 | } | |||
2205 | } | |||
2206 | else // implemented here | |||
2207 | switch ( pEntry->nWID ) | |||
2208 | { | |||
2209 | case EE_CHAR_ESCAPEMENT: // Specifically for xlsx import | |||
2210 | { | |||
2211 | sal_Int32 nValue = 0; | |||
2212 | aValue >>= nValue; | |||
2213 | if (nValue) | |||
2214 | { | |||
2215 | for (size_t i = 0, n = aRanges.size(); i < n; ++i) | |||
2216 | { | |||
2217 | ScRange const & rRange = aRanges[i]; | |||
2218 | ||||
2219 | /* TODO: Iterate through the range */ | |||
2220 | ScAddress aAddr = rRange.aStart; | |||
2221 | ScDocument& rDoc = pDocShell->GetDocument(); | |||
2222 | ScRefCellValue aCell(rDoc, aAddr); | |||
2223 | ||||
2224 | OUString aStr = aCell.getString(&rDoc); | |||
2225 | EditEngine aEngine( rDoc.GetEnginePool() ); | |||
2226 | aEngine.SetEditTextObjectPool(rDoc.GetEditPool()); | |||
2227 | ||||
2228 | /* EE_CHAR_ESCAPEMENT seems to be set on the cell _only_ when | |||
2229 | * there are no other attribs for the cell. | |||
2230 | * So, it is safe to overwrite the complete attribute set. | |||
2231 | * If there is a need - getting CellType and processing | |||
2232 | * the attributes could be considered. | |||
2233 | */ | |||
2234 | SfxItemSet aAttr = aEngine.GetEmptyItemSet(); | |||
2235 | aEngine.SetText(aStr); | |||
2236 | if( nValue < 0 ) // Subscript | |||
2237 | aAttr.Put( SvxEscapementItem( SvxEscapement::Subscript, EE_CHAR_ESCAPEMENT ) ); | |||
2238 | else // Superscript | |||
2239 | aAttr.Put( SvxEscapementItem( SvxEscapement::Superscript, EE_CHAR_ESCAPEMENT ) ); | |||
2240 | aEngine.QuickSetAttribs(aAttr, ESelection(0, 0, 0, aStr.getLength())); | |||
2241 | ||||
2242 | // The cell will own the text object instance. | |||
2243 | rDoc.SetEditText(aRanges[0].aStart, aEngine.CreateTextObject()); | |||
2244 | } | |||
2245 | } | |||
2246 | } | |||
2247 | break; | |||
2248 | case SC_WID_UNO_CHCOLHDR( 1200 + 1 ): | |||
2249 | // chart header flags are set for this object, not stored with document | |||
2250 | bChartColAsHdr = ScUnoHelpFunctions::GetBoolFromAny( aValue ); | |||
2251 | break; | |||
2252 | case SC_WID_UNO_CHROWHDR( 1200 + 2 ): | |||
2253 | bChartRowAsHdr = ScUnoHelpFunctions::GetBoolFromAny( aValue ); | |||
2254 | break; | |||
2255 | case SC_WID_UNO_CELLSTYL( 1200 + 0 ): | |||
2256 | { | |||
2257 | OUString aStrVal; | |||
2258 | aValue >>= aStrVal; | |||
2259 | OUString aString(ScStyleNameConversion::ProgrammaticToDisplayName( | |||
2260 | aStrVal, SfxStyleFamily::Para )); | |||
2261 | pDocShell->GetDocFunc().ApplyStyle( *GetMarkData(), aString, true ); | |||
2262 | } | |||
2263 | break; | |||
2264 | case SC_WID_UNO_TBLBORD( 1200 + 6 ): | |||
2265 | { | |||
2266 | table::TableBorder aBorder; | |||
2267 | if ( !aRanges.empty() && ( aValue >>= aBorder ) ) // empty = nothing to do | |||
2268 | { | |||
2269 | SvxBoxItem aOuter(ATTR_BORDER); | |||
2270 | SvxBoxInfoItem aInner(ATTR_BORDER_INNER); | |||
2271 | ScHelperFunctions::FillBoxItems( aOuter, aInner, aBorder ); | |||
2272 | ||||
2273 | ScHelperFunctions::ApplyBorder( pDocShell, aRanges, aOuter, aInner ); //! docfunc | |||
2274 | } | |||
2275 | } | |||
2276 | break; | |||
2277 | case SC_WID_UNO_TBLBORD2( 1200 + 43 ): | |||
2278 | { | |||
2279 | table::TableBorder2 aBorder2; | |||
2280 | if ( !aRanges.empty() && ( aValue >>= aBorder2 ) ) // empty = nothing to do | |||
2281 | { | |||
2282 | SvxBoxItem aOuter(ATTR_BORDER); | |||
2283 | SvxBoxInfoItem aInner(ATTR_BORDER_INNER); | |||
2284 | ScHelperFunctions::FillBoxItems( aOuter, aInner, aBorder2 ); | |||
2285 | ||||
2286 | ScHelperFunctions::ApplyBorder( pDocShell, aRanges, aOuter, aInner ); //! docfunc | |||
2287 | } | |||
2288 | } | |||
2289 | break; | |||
2290 | case SC_WID_UNO_CONDFMT( 1200 + 3 ): | |||
2291 | case SC_WID_UNO_CONDLOC( 1200 + 4 ): | |||
2292 | case SC_WID_UNO_CONDXML( 1200 + 5 ): | |||
2293 | { | |||
2294 | uno::Reference<sheet::XSheetConditionalEntries> xInterface(aValue, uno::UNO_QUERY); | |||
2295 | if ( !aRanges.empty() && xInterface.is() ) // empty = nothing to do | |||
2296 | { | |||
2297 | ScTableConditionalFormat* pFormat = | |||
2298 | comphelper::getUnoTunnelImplementation<ScTableConditionalFormat>( xInterface ); | |||
2299 | if (pFormat) | |||
2300 | { | |||
2301 | ScDocument& rDoc = pDocShell->GetDocument(); | |||
2302 | bool bEnglish = ( pEntry->nWID != SC_WID_UNO_CONDLOC( 1200 + 4 ) ); | |||
2303 | bool bXML = ( pEntry->nWID == SC_WID_UNO_CONDXML( 1200 + 5 ) ); | |||
2304 | formula::FormulaGrammar::Grammar eGrammar = (bXML ? | |||
2305 | formula::FormulaGrammar::GRAM_UNSPECIFIED : | |||
2306 | formula::FormulaGrammar::mapAPItoGrammar( bEnglish, bXML)); | |||
2307 | ||||
2308 | SCTAB nTab = aRanges.front().aStart.Tab(); | |||
2309 | // To remove conditional formats for all cells in aRanges we need to: | |||
2310 | // Remove conditional format data from cells' attributes | |||
2311 | rDoc.RemoveCondFormatData( aRanges, nTab, 0 ); | |||
2312 | // And also remove ranges from conditional formats list | |||
2313 | for (size_t i = 0; i < aRanges.size(); ++i) | |||
2314 | { | |||
2315 | rDoc.GetCondFormList( aRanges[i].aStart.Tab() )->DeleteArea( | |||
2316 | aRanges[i].aStart.Col(), aRanges[i].aStart.Row(), | |||
2317 | aRanges[i].aEnd.Col(), aRanges[i].aEnd.Row() ); | |||
2318 | } | |||
2319 | ||||
2320 | // Then we can apply new conditional format if there is one | |||
2321 | if (pFormat->getCount()) | |||
2322 | { | |||
2323 | auto pNew = std::make_unique<ScConditionalFormat>( 0, &rDoc ); // Index will be set on inserting | |||
2324 | pFormat->FillFormat( *pNew, rDoc, eGrammar ); | |||
2325 | pNew->SetRange( aRanges ); | |||
2326 | pDocShell->GetDocFunc().ReplaceConditionalFormat( 0, std::move(pNew), nTab, aRanges ); | |||
2327 | } | |||
2328 | ||||
2329 | // and repaint | |||
2330 | for (size_t i = 0; i < aRanges.size(); ++i) | |||
2331 | pDocShell->PostPaint(aRanges[i], PaintPartFlags::Grid); | |||
2332 | pDocShell->SetDocumentModified(); | |||
2333 | } | |||
2334 | } | |||
2335 | } | |||
2336 | break; | |||
2337 | case SC_WID_UNO_VALIDAT( 1200 + 7 ): | |||
2338 | case SC_WID_UNO_VALILOC( 1200 + 8 ): | |||
2339 | case SC_WID_UNO_VALIXML( 1200 + 9 ): | |||
2340 | { | |||
2341 | uno::Reference<beans::XPropertySet> xInterface(aValue, uno::UNO_QUERY); | |||
2342 | if ( !aRanges.empty() && xInterface.is() ) // empty = nothing to do | |||
2343 | { | |||
2344 | ScTableValidationObj* pValidObj = | |||
2345 | comphelper::getUnoTunnelImplementation<ScTableValidationObj>( xInterface ); | |||
2346 | if (pValidObj) | |||
2347 | { | |||
2348 | ScDocument& rDoc = pDocShell->GetDocument(); | |||
2349 | bool bEnglish = ( pEntry->nWID != SC_WID_UNO_VALILOC( 1200 + 8 ) ); | |||
2350 | bool bXML = ( pEntry->nWID == SC_WID_UNO_VALIXML( 1200 + 9 ) ); | |||
2351 | formula::FormulaGrammar::Grammar eGrammar = (bXML ? | |||
2352 | formula::FormulaGrammar::GRAM_UNSPECIFIED : | |||
2353 | formula::FormulaGrammar::mapAPItoGrammar( bEnglish, bXML)); | |||
2354 | ||||
2355 | std::unique_ptr<ScValidationData> pNewData( | |||
2356 | pValidObj->CreateValidationData( rDoc, eGrammar )); | |||
2357 | sal_uLong nIndex = rDoc.AddValidationEntry( *pNewData ); | |||
2358 | pNewData.reset(); | |||
2359 | ||||
2360 | ScPatternAttr aPattern( rDoc.GetPool() ); | |||
2361 | aPattern.GetItemSet().Put( SfxUInt32Item( ATTR_VALIDDATA, nIndex ) ); | |||
2362 | pDocShell->GetDocFunc().ApplyAttributes( *GetMarkData(), aPattern, true ); | |||
2363 | } | |||
2364 | } | |||
2365 | } | |||
2366 | break; | |||
2367 | // SC_WID_UNO_NUMRULES is ignored... | |||
2368 | } | |||
2369 | } | |||
2370 | ||||
2371 | uno::Any SAL_CALL ScCellRangesBase::getPropertyValue( const OUString& aPropertyName ) | |||
2372 | { | |||
2373 | SolarMutexGuard aGuard; | |||
2374 | ||||
2375 | if ( !pDocShell || aRanges.empty() ) | |||
2376 | throw uno::RuntimeException(); | |||
2377 | ||||
2378 | const SfxItemPropertyMap& rPropertyMap = GetItemPropertyMap(); // from derived class | |||
2379 | const SfxItemPropertySimpleEntry* pEntry = rPropertyMap.getByName( aPropertyName ); | |||
2380 | if ( !pEntry ) | |||
2381 | throw beans::UnknownPropertyException(aPropertyName); | |||
2382 | ||||
2383 | uno::Any aAny; | |||
2384 | GetOnePropertyValue( pEntry, aAny ); | |||
2385 | return aAny; | |||
2386 | } | |||
2387 | ||||
2388 | void ScCellRangesBase::GetOnePropertyValue( const SfxItemPropertySimpleEntry* pEntry, uno::Any& rAny ) | |||
2389 | { | |||
2390 | if ( !pEntry ) | |||
2391 | return; | |||
2392 | ||||
2393 | if ( IsScItemWid( pEntry->nWID ) ) | |||
2394 | { | |||
2395 | SfxItemSet* pDataSet = GetCurrentDataSet(); | |||
2396 | if ( pDataSet ) | |||
2397 | { | |||
2398 | switch ( pEntry->nWID ) // for special handling of items | |||
2399 | { | |||
2400 | case ATTR_VALUE_FORMAT: | |||
2401 | { | |||
2402 | ScDocument& rDoc = pDocShell->GetDocument(); | |||
2403 | ||||
2404 | sal_uLong nOldFormat = | |||
2405 | pDataSet->Get( ATTR_VALUE_FORMAT ).GetValue(); | |||
2406 | LanguageType eOldLang = | |||
2407 | pDataSet->Get( ATTR_LANGUAGE_FORMAT ).GetLanguage(); | |||
2408 | nOldFormat = rDoc.GetFormatTable()-> | |||
2409 | GetFormatForLanguageIfBuiltIn( nOldFormat, eOldLang ); | |||
2410 | rAny <<= static_cast<sal_Int32>(nOldFormat); | |||
2411 | } | |||
2412 | break; | |||
2413 | case ATTR_INDENT: | |||
2414 | rAny <<= static_cast<sal_Int16>( TwipsToHMM(static_cast<const ScIndentItem&>( | |||
2415 | pDataSet->Get(pEntry->nWID)).GetValue()) ); | |||
2416 | break; | |||
2417 | case ATTR_STACKED: | |||
2418 | { | |||
2419 | sal_Int32 nRot = pDataSet->Get(ATTR_ROTATE_VALUE).GetValue(); | |||
2420 | bool bStacked = static_cast<const ScVerticalStackCell&>(pDataSet->Get(pEntry->nWID)).GetValue(); | |||
2421 | SvxOrientationItem( nRot, bStacked, 0 ).QueryValue( rAny ); | |||
2422 | } | |||
2423 | break; | |||
2424 | default: | |||
2425 | pPropSet->getPropertyValue(*pEntry, *pDataSet, rAny); | |||
2426 | } | |||
2427 | } | |||
2428 | } | |||
2429 | else // implemented here | |||
2430 | switch ( pEntry->nWID ) | |||
2431 | { | |||
2432 | case SC_WID_UNO_CHCOLHDR( 1200 + 1 ): | |||
2433 | rAny <<= bChartColAsHdr; | |||
2434 | break; | |||
2435 | case SC_WID_UNO_CHROWHDR( 1200 + 2 ): | |||
2436 | rAny <<= bChartRowAsHdr; | |||
2437 | break; | |||
2438 | case SC_WID_UNO_CELLSTYL( 1200 + 0 ): | |||
2439 | { | |||
2440 | OUString aStyleName; | |||
2441 | const ScStyleSheet* pStyle = pDocShell->GetDocument().GetSelectionStyle(*GetMarkData()); | |||
2442 | if (pStyle) | |||
2443 | aStyleName = pStyle->GetName(); | |||
2444 | rAny <<= ScStyleNameConversion::DisplayToProgrammaticName( | |||
2445 | aStyleName, SfxStyleFamily::Para ); | |||
2446 | } | |||
2447 | break; | |||
2448 | case SC_WID_UNO_TBLBORD( 1200 + 6 ): | |||
2449 | case SC_WID_UNO_TBLBORD2( 1200 + 43 ): | |||
2450 | { | |||
2451 | //! loop through all ranges | |||
2452 | if ( !aRanges.empty() ) | |||
2453 | { | |||
2454 | const ScRange & rFirst = aRanges[ 0 ]; | |||
2455 | SvxBoxItem aOuter(ATTR_BORDER); | |||
2456 | SvxBoxInfoItem aInner(ATTR_BORDER_INNER); | |||
2457 | ||||
2458 | ScDocument& rDoc = pDocShell->GetDocument(); | |||
2459 | ScMarkData aMark(rDoc.GetSheetLimits()); | |||
2460 | aMark.SetMarkArea( rFirst ); | |||
2461 | aMark.SelectTable( rFirst.aStart.Tab(), true ); | |||
2462 | rDoc.GetSelectionFrame( aMark, aOuter, aInner ); | |||
2463 | ||||
2464 | if (pEntry->nWID == SC_WID_UNO_TBLBORD2( 1200 + 43 )) | |||
2465 | ScHelperFunctions::AssignTableBorder2ToAny( rAny, aOuter, aInner); | |||
2466 | else | |||
2467 | ScHelperFunctions::AssignTableBorderToAny( rAny, aOuter, aInner); | |||
2468 | } | |||
2469 | } | |||
2470 | break; | |||
2471 | case SC_WID_UNO_CONDFMT( 1200 + 3 ): | |||
2472 | case SC_WID_UNO_CONDLOC( 1200 + 4 ): | |||
2473 | case SC_WID_UNO_CONDXML( 1200 + 5 ): | |||
2474 | { | |||
2475 | const ScPatternAttr* pPattern = GetCurrentAttrsDeep(); | |||
2476 | if ( pPattern ) | |||
2477 | { | |||
2478 | ScDocument& rDoc = pDocShell->GetDocument(); | |||
2479 | bool bEnglish = ( pEntry->nWID != SC_WID_UNO_CONDLOC( 1200 + 4 ) ); | |||
2480 | bool bXML = ( pEntry->nWID == SC_WID_UNO_CONDXML( 1200 + 5 ) ); | |||
2481 | formula::FormulaGrammar::Grammar eGrammar = (bXML ? | |||
2482 | rDoc.GetStorageGrammar() : | |||
2483 | formula::FormulaGrammar::mapAPItoGrammar( bEnglish, bXML)); | |||
2484 | const ScCondFormatIndexes& rIndex = | |||
2485 | pPattern->GetItem(ATTR_CONDITIONAL).GetCondFormatData(); | |||
2486 | sal_uLong nIndex = 0; | |||
2487 | if(!rIndex.empty()) | |||
2488 | nIndex = rIndex[0]; | |||
2489 | rAny <<= uno::Reference<sheet::XSheetConditionalEntries>( | |||
2490 | new ScTableConditionalFormat( &rDoc, nIndex, aRanges.front().aStart.Tab(), eGrammar )); | |||
2491 | } | |||
2492 | } | |||
2493 | break; | |||
2494 | case SC_WID_UNO_VALIDAT( 1200 + 7 ): | |||
2495 | case SC_WID_UNO_VALILOC( 1200 + 8 ): | |||
2496 | case SC_WID_UNO_VALIXML( 1200 + 9 ): | |||
2497 | { | |||
2498 | const ScPatternAttr* pPattern = GetCurrentAttrsDeep(); | |||
2499 | if ( pPattern ) | |||
2500 | { | |||
2501 | ScDocument& rDoc = pDocShell->GetDocument(); | |||
2502 | bool bEnglish = ( pEntry->nWID != SC_WID_UNO_VALILOC( 1200 + 8 ) ); | |||
2503 | bool bXML = ( pEntry->nWID == SC_WID_UNO_VALIXML( 1200 + 9 ) ); | |||
2504 | formula::FormulaGrammar::Grammar eGrammar = (bXML ? | |||
2505 | rDoc.GetStorageGrammar() : | |||
2506 | formula::FormulaGrammar::mapAPItoGrammar( bEnglish, bXML)); | |||
2507 | sal_uLong nIndex = | |||
2508 | pPattern->GetItem(ATTR_VALIDDATA).GetValue(); | |||
2509 | rAny <<= uno::Reference<beans::XPropertySet>( | |||
2510 | new ScTableValidationObj( rDoc, nIndex, eGrammar )); | |||
2511 | } | |||
2512 | } | |||
2513 | break; | |||
2514 | case SC_WID_UNO_NUMRULES( 1200 + 28 ): | |||
2515 | { | |||
2516 | // always return empty numbering rules object | |||
2517 | rAny <<= ScStyleObj::CreateEmptyNumberingRules(); | |||
2518 | } | |||
2519 | break; | |||
2520 | case SC_WID_UNO_ABSNAME( 1200 + 39 ): | |||
2521 | { | |||
2522 | OUString sRet; | |||
2523 | aRanges.Format(sRet, ScRefFlags::RANGE_ABS_3D, pDocShell->GetDocument()); | |||
2524 | rAny <<= sRet; | |||
2525 | } | |||
2526 | break; | |||
2527 | case SC_WID_UNO_FORMATID( 1200 + 45 ): | |||
2528 | { | |||
2529 | const ScPatternAttr* pPattern = GetCurrentAttrsFlat(); | |||
2530 | rAny <<= pPattern->GetKey(); | |||
2531 | } | |||
2532 | break; | |||
2533 | } | |||
2534 | } | |||
2535 | ||||
2536 | void SAL_CALL ScCellRangesBase::addPropertyChangeListener( const OUString& /* aPropertyName */, | |||
2537 | const uno::Reference<beans::XPropertyChangeListener>& /* aListener */) | |||
2538 | { | |||
2539 | SolarMutexGuard aGuard; | |||
2540 | if ( aRanges.empty() ) | |||
2541 | throw uno::RuntimeException(); | |||
2542 | ||||
2543 | OSL_FAIL("not implemented")do { if (true && (((sal_Bool)1))) { sal_detail_logFormat ((SAL_DETAIL_LOG_LEVEL_WARN), ("legacy.osl"), ("/home/maarten/src/libreoffice/core/sc/source/ui/unoobj/cellsuno.cxx" ":" "2543" ": "), "%s", "not implemented"); } } while (false ); | |||
2544 | } | |||
2545 | ||||
2546 | void SAL_CALL ScCellRangesBase::removePropertyChangeListener( const OUString& /* aPropertyName */, | |||
2547 | const uno::Reference<beans::XPropertyChangeListener>& /* aListener */) | |||
2548 | { | |||
2549 | SolarMutexGuard aGuard; | |||
2550 | if ( aRanges.empty() ) | |||
2551 | throw uno::RuntimeException(); | |||
2552 | ||||
2553 | OSL_FAIL("not implemented")do { if (true && (((sal_Bool)1))) { sal_detail_logFormat ((SAL_DETAIL_LOG_LEVEL_WARN), ("legacy.osl"), ("/home/maarten/src/libreoffice/core/sc/source/ui/unoobj/cellsuno.cxx" ":" "2553" ": "), "%s", "not implemented"); } } while (false ); | |||
2554 | } | |||
2555 | ||||
2556 | void SAL_CALL ScCellRangesBase::addVetoableChangeListener( const OUString&, | |||
2557 | const uno::Reference<beans::XVetoableChangeListener>&) | |||
2558 | { | |||
2559 | OSL_FAIL("not implemented")do { if (true && (((sal_Bool)1))) { sal_detail_logFormat ((SAL_DETAIL_LOG_LEVEL_WARN), ("legacy.osl"), ("/home/maarten/src/libreoffice/core/sc/source/ui/unoobj/cellsuno.cxx" ":" "2559" ": "), "%s", "not implemented"); } } while (false ); | |||
2560 | } | |||
2561 | ||||
2562 | void SAL_CALL ScCellRangesBase::removeVetoableChangeListener( const OUString&, | |||
2563 | const uno::Reference<beans::XVetoableChangeListener>&) | |||
2564 | { | |||
2565 | OSL_FAIL("not implemented")do { if (true && (((sal_Bool)1))) { sal_detail_logFormat ((SAL_DETAIL_LOG_LEVEL_WARN), ("legacy.osl"), ("/home/maarten/src/libreoffice/core/sc/source/ui/unoobj/cellsuno.cxx" ":" "2565" ": "), "%s", "not implemented"); } } while (false ); | |||
2566 | } | |||
2567 | ||||
2568 | // XMultiPropertySet | |||
2569 | ||||
2570 | void SAL_CALL ScCellRangesBase::setPropertyValues( const uno::Sequence< OUString >& aPropertyNames, | |||
2571 | const uno::Sequence< uno::Any >& aValues ) | |||
2572 | { | |||
2573 | SolarMutexGuard aGuard; | |||
2574 | ||||
2575 | sal_Int32 nCount(aPropertyNames.getLength()); | |||
2576 | sal_Int32 nValues(aValues.getLength()); | |||
2577 | if (nCount != nValues) | |||
2578 | throw lang::IllegalArgumentException(); | |||
2579 | ||||
2580 | if ( !(pDocShell && nCount) ) | |||
2581 | return; | |||
2582 | ||||
2583 | const SfxItemPropertyMap& rPropertyMap = GetItemPropertyMap(); // from derived class | |||
2584 | const OUString* pNames = aPropertyNames.getConstArray(); | |||
2585 | const uno::Any* pValues = aValues.getConstArray(); | |||
2586 | ||||
2587 | std::unique_ptr<const SfxItemPropertySimpleEntry*[]> pEntryArray(new const SfxItemPropertySimpleEntry*[nCount]); | |||
2588 | ||||
2589 | sal_Int32 i; | |||
2590 | for(i = 0; i < nCount; i++) | |||
2591 | { | |||
2592 | // first loop: find all properties in map, but handle only CellStyle | |||
2593 | // (CellStyle must be set before any other cell properties) | |||
2594 | ||||
2595 | const SfxItemPropertySimpleEntry* pEntry = rPropertyMap.getByName( pNames[i] ); | |||
2596 | pEntryArray[i] = pEntry; | |||
2597 | if (pEntry) | |||
2598 | { | |||
2599 | if ( pEntry->nWID == SC_WID_UNO_CELLSTYL( 1200 + 0 ) ) | |||
2600 | { | |||
2601 | try | |||
2602 | { | |||
2603 | SetOnePropertyValue( pEntry, pValues[i] ); | |||
2604 | } | |||
2605 | catch ( lang::IllegalArgumentException& ) | |||
2606 | { | |||
2607 | OSL_FAIL("exception when setting cell style")do { if (true && (((sal_Bool)1))) { sal_detail_logFormat ((SAL_DETAIL_LOG_LEVEL_WARN), ("legacy.osl"), ("/home/maarten/src/libreoffice/core/sc/source/ui/unoobj/cellsuno.cxx" ":" "2607" ": "), "%s", "exception when setting cell style") ; } } while (false); // not supposed to happen | |||
2608 | } | |||
2609 | } | |||
2610 | } | |||
2611 | } | |||
2612 | ||||
2613 | ScDocument& rDoc = pDocShell->GetDocument(); | |||
2614 | std::unique_ptr<ScPatternAttr> pOldPattern; | |||
2615 | std::unique_ptr<ScPatternAttr> pNewPattern; | |||
2616 | ||||
2617 | for(i = 0; i < nCount; i++) | |||
2618 | { | |||
2619 | // second loop: handle other properties | |||
2620 | ||||
2621 | const SfxItemPropertySimpleEntry* pEntry = pEntryArray[i]; | |||
2622 | if ( pEntry ) | |||
2623 | { | |||
2624 | if ( IsScItemWid( pEntry->nWID ) ) // can be handled by SfxItemPropertySet | |||
2625 | { | |||
2626 | if ( !pOldPattern ) | |||
2627 | { | |||
2628 | pOldPattern.reset(new ScPatternAttr( *GetCurrentAttrsDeep() )); | |||
2629 | pOldPattern->GetItemSet().ClearInvalidItems(); | |||
2630 | pNewPattern.reset(new ScPatternAttr( rDoc.GetPool() )); | |||
2631 | } | |||
2632 | ||||
2633 | // collect items in pNewPattern, apply with one call after the loop | |||
2634 | ||||
2635 | sal_uInt16 nFirstItem, nSecondItem; | |||
2636 | lcl_SetCellProperty( *pEntry, pValues[i], *pOldPattern, rDoc, nFirstItem, nSecondItem ); | |||
2637 | ||||
2638 | // put only affected items into new set | |||
2639 | if ( nFirstItem ) | |||
2640 | pNewPattern->GetItemSet().Put( pOldPattern->GetItemSet().Get( nFirstItem ) ); | |||
2641 | if ( nSecondItem ) | |||
2642 | pNewPattern->GetItemSet().Put( pOldPattern->GetItemSet().Get( nSecondItem ) ); | |||
2643 | } | |||
2644 | else if ( pEntry->nWID != SC_WID_UNO_CELLSTYL( 1200 + 0 ) ) // CellStyle is handled above | |||
2645 | { | |||
2646 | // call virtual method to set a single property | |||
2647 | SetOnePropertyValue( pEntry, pValues[i] ); | |||
2648 | } | |||
2649 | } | |||
2650 | } | |||
2651 | ||||
2652 | if ( pNewPattern && !aRanges.empty() ) | |||
2653 | pDocShell->GetDocFunc().ApplyAttributes( *GetMarkData(), *pNewPattern, true ); | |||
2654 | } | |||
2655 | ||||
2656 | uno::Sequence<uno::Any> SAL_CALL ScCellRangesBase::getPropertyValues( | |||
2657 | const uno::Sequence< OUString >& aPropertyNames ) | |||
2658 | { | |||
2659 | SolarMutexGuard aGuard; | |||
2660 | ||||
2661 | const SfxItemPropertyMap& rPropertyMap = GetItemPropertyMap(); // from derived class | |||
2662 | ||||
2663 | uno::Sequence<uno::Any> aRet(aPropertyNames.getLength()); | |||
2664 | uno::Any* pProperties = aRet.getArray(); | |||
2665 | for(sal_Int32 i = 0; i < aPropertyNames.getLength(); i++) | |||
2666 | { | |||
2667 | const SfxItemPropertySimpleEntry* pEntry = rPropertyMap.getByName( aPropertyNames[i] ); | |||
2668 | GetOnePropertyValue( pEntry, pProperties[i] ); | |||
2669 | } | |||
2670 | return aRet; | |||
2671 | } | |||
2672 | ||||
2673 | void SAL_CALL ScCellRangesBase::addPropertiesChangeListener( const uno::Sequence< OUString >& /* aPropertyNames */, | |||
2674 | const uno::Reference< beans::XPropertiesChangeListener >& /* xListener */ ) | |||
2675 | { | |||
2676 | OSL_FAIL("not implemented")do { if (true && (((sal_Bool)1))) { sal_detail_logFormat ((SAL_DETAIL_LOG_LEVEL_WARN), ("legacy.osl"), ("/home/maarten/src/libreoffice/core/sc/source/ui/unoobj/cellsuno.cxx" ":" "2676" ": "), "%s", "not implemented"); } } while (false ); | |||
2677 | } | |||
2678 | ||||
2679 | void SAL_CALL ScCellRangesBase::removePropertiesChangeListener( const uno::Reference< beans::XPropertiesChangeListener >& /* xListener */ ) | |||
2680 | { | |||
2681 | OSL_FAIL("not implemented")do { if (true && (((sal_Bool)1))) { sal_detail_logFormat ((SAL_DETAIL_LOG_LEVEL_WARN), ("legacy.osl"), ("/home/maarten/src/libreoffice/core/sc/source/ui/unoobj/cellsuno.cxx" ":" "2681" ": "), "%s", "not implemented"); } } while (false ); | |||
2682 | } | |||
2683 | ||||
2684 | void SAL_CALL ScCellRangesBase::firePropertiesChangeEvent( const uno::Sequence< OUString >& /* aPropertyNames */, | |||
2685 | const uno::Reference< beans::XPropertiesChangeListener >& /* xListener */ ) | |||
2686 | { | |||
2687 | OSL_FAIL("not implemented")do { if (true && (((sal_Bool)1))) { sal_detail_logFormat ((SAL_DETAIL_LOG_LEVEL_WARN), ("legacy.osl"), ("/home/maarten/src/libreoffice/core/sc/source/ui/unoobj/cellsuno.cxx" ":" "2687" ": "), "%s", "not implemented"); } } while (false ); | |||
2688 | } | |||
2689 | ||||
2690 | IMPL_LINK( ScCellRangesBase, ValueListenerHdl, const SfxHint&, rHint, void )void ScCellRangesBase::LinkStubValueListenerHdl(void * instance , const SfxHint& data) { return static_cast<ScCellRangesBase *>(instance)->ValueListenerHdl(data); } void ScCellRangesBase ::ValueListenerHdl(const SfxHint& rHint) | |||
2691 | { | |||
2692 | if ( pDocShell && (rHint.GetId() == SfxHintId::ScDataChanged)) | |||
2693 | { | |||
2694 | // This may be called several times for a single change, if several formulas | |||
2695 | // in the range are notified. So only a flag is set that is checked when | |||
2696 | // SfxHintId::DataChanged is received. | |||
2697 | ||||
2698 | bGotDataChangedHint = true; | |||
2699 | } | |||
2700 | } | |||
2701 | ||||
2702 | // XTolerantMultiPropertySet | |||
2703 | uno::Sequence< beans::SetPropertyTolerantFailed > SAL_CALL ScCellRangesBase::setPropertyValuesTolerant( const uno::Sequence< OUString >& aPropertyNames, | |||
2704 | const uno::Sequence< uno::Any >& aValues ) | |||
2705 | { | |||
2706 | SolarMutexGuard aGuard; | |||
2707 | ||||
2708 | sal_Int32 nCount(aPropertyNames.getLength()); | |||
2709 | sal_Int32 nValues(aValues.getLength()); | |||
2710 | if (nCount != nValues) | |||
2711 | throw lang::IllegalArgumentException(); | |||
2712 | ||||
2713 | if ( pDocShell && nCount ) | |||
2714 | { | |||
2715 | uno::Sequence < beans::SetPropertyTolerantFailed > aReturns(nCount); | |||
2716 | beans::SetPropertyTolerantFailed* pReturns = aReturns.getArray(); | |||
2717 | ||||
2718 | const SfxItemPropertyMap& rPropertyMap = GetItemPropertyMap(); // from derived class | |||
2719 | const OUString* pNames = aPropertyNames.getConstArray(); | |||
2720 | const uno::Any* pValues = aValues.getConstArray(); | |||
2721 | ||||
2722 | std::unique_ptr<const SfxItemPropertySimpleEntry*[]> pMapArray(new const SfxItemPropertySimpleEntry*[nCount]); | |||
2723 | ||||
2724 | sal_Int32 i; | |||
2725 | for(i = 0; i < nCount; i++) | |||
2726 | { | |||
2727 | // first loop: find all properties in map, but handle only CellStyle | |||
2728 | // (CellStyle must be set before any other cell properties) | |||
2729 | ||||
2730 | const SfxItemPropertySimpleEntry* pEntry = rPropertyMap.getByName( pNames[i] ); | |||
2731 | pMapArray[i] = pEntry; | |||
2732 | if (pEntry) | |||
2733 | { | |||
2734 | if ( pEntry->nWID == SC_WID_UNO_CELLSTYL( 1200 + 0 ) ) | |||
2735 | { | |||
2736 | try | |||
2737 | { | |||
2738 | SetOnePropertyValue( pEntry, pValues[i] ); | |||
2739 | } | |||
2740 | catch ( lang::IllegalArgumentException& ) | |||
2741 | { | |||
2742 | OSL_FAIL("exception when setting cell style")do { if (true && (((sal_Bool)1))) { sal_detail_logFormat ((SAL_DETAIL_LOG_LEVEL_WARN), ("legacy.osl"), ("/home/maarten/src/libreoffice/core/sc/source/ui/unoobj/cellsuno.cxx" ":" "2742" ": "), "%s", "exception when setting cell style") ; } } while (false); // not supposed to happen | |||
2743 | } | |||
2744 | } | |||
2745 | } | |||
2746 | } | |||
2747 | ||||
2748 | ScDocument& rDoc = pDocShell->GetDocument(); | |||
2749 | std::unique_ptr<ScPatternAttr> pOldPattern; | |||
2750 | std::unique_ptr<ScPatternAttr> pNewPattern; | |||
2751 | ||||
2752 | sal_Int32 nFailed(0); | |||
2753 | for(i = 0; i < nCount; i++) | |||
2754 | { | |||
2755 | // second loop: handle other properties | |||
2756 | ||||
2757 | const SfxItemPropertySimpleEntry* pEntry = pMapArray[i]; | |||
2758 | if ( pEntry && ((pEntry->nFlags & beans::PropertyAttribute::READONLY) == 0)) | |||
2759 | { | |||
2760 | if ( IsScItemWid( pEntry->nWID ) ) // can be handled by SfxItemPropertySet | |||
2761 | { | |||
2762 | if ( !pOldPattern ) | |||
2763 | { | |||
2764 | pOldPattern.reset(new ScPatternAttr( *GetCurrentAttrsDeep() )); | |||
2765 | pOldPattern->GetItemSet().ClearInvalidItems(); | |||
2766 | pNewPattern.reset(new ScPatternAttr( rDoc.GetPool() )); | |||
2767 | } | |||
2768 | ||||
2769 | // collect items in pNewPattern, apply with one call after the loop | |||
2770 | try | |||
2771 | { | |||
2772 | sal_uInt16 nFirstItem, nSecondItem; | |||
2773 | lcl_SetCellProperty( *pEntry, pValues[i], *pOldPattern, rDoc, nFirstItem, nSecondItem ); | |||
2774 | ||||
2775 | // put only affected items into new set | |||
2776 | if ( nFirstItem ) | |||
2777 | pNewPattern->GetItemSet().Put( pOldPattern->GetItemSet().Get( nFirstItem ) ); | |||
2778 | if ( nSecondItem ) | |||
2779 | pNewPattern->GetItemSet().Put( pOldPattern->GetItemSet().Get( nSecondItem ) ); | |||
2780 | } | |||
2781 | catch ( lang::IllegalArgumentException& ) | |||
2782 | { | |||
2783 | pReturns[nFailed].Name = pNames[i]; | |||
2784 | pReturns[nFailed++].Result = beans::TolerantPropertySetResultType::ILLEGAL_ARGUMENT; | |||
2785 | } | |||
2786 | } | |||
2787 | else if ( pEntry->nWID != SC_WID_UNO_CELLSTYL( 1200 + 0 ) ) // CellStyle is handled above | |||
2788 | { | |||
2789 | // call virtual method to set a single property | |||
2790 | try | |||
2791 | { | |||
2792 | SetOnePropertyValue( pEntry, pValues[i] ); | |||
2793 | } | |||
2794 | catch ( lang::IllegalArgumentException& ) | |||
2795 | { | |||
2796 | pReturns[nFailed].Name = pNames[i]; | |||
2797 | pReturns[nFailed++].Result = beans::TolerantPropertySetResultType::ILLEGAL_ARGUMENT; | |||
2798 | } | |||
2799 | } | |||
2800 | } | |||
2801 | else | |||
2802 | { | |||
2803 | pReturns[nFailed].Name = pNames[i]; | |||
2804 | if (pEntry) | |||
2805 | pReturns[nFailed++].Result = beans::TolerantPropertySetResultType::PROPERTY_VETO; | |||
2806 | else | |||
2807 | pReturns[nFailed++].Result = beans::TolerantPropertySetResultType::UNKNOWN_PROPERTY; | |||
2808 | } | |||
2809 | } | |||
2810 | ||||
2811 | if ( pNewPattern && !aRanges.empty() ) | |||
2812 | pDocShell->GetDocFunc().ApplyAttributes( *GetMarkData(), *pNewPattern, true ); | |||
2813 | ||||
2814 | aReturns.realloc(nFailed); | |||
2815 | ||||
2816 | return aReturns; | |||
2817 | } | |||
2818 | return uno::Sequence < beans::SetPropertyTolerantFailed >(); | |||
2819 | } | |||
2820 | ||||
2821 | uno::Sequence< beans::GetPropertyTolerantResult > SAL_CALL ScCellRangesBase::getPropertyValuesTolerant( const uno::Sequence< OUString >& aPropertyNames ) | |||
2822 | { | |||
2823 | SolarMutexGuard aGuard; | |||
2824 | ||||
2825 | sal_Int32 nCount(aPropertyNames.getLength()); | |||
2826 | uno::Sequence < beans::GetPropertyTolerantResult > aReturns(nCount); | |||
2827 | beans::GetPropertyTolerantResult* pReturns = aReturns.getArray(); | |||
2828 | ||||
2829 | const SfxItemPropertyMap& rPropertyMap = GetItemPropertyMap(); // from derived class | |||
2830 | ||||
2831 | for(sal_Int32 i = 0; i < nCount; i++) | |||
2832 | { | |||
2833 | const SfxItemPropertySimpleEntry* pEntry = rPropertyMap.getByName( aPropertyNames[i] ); | |||
2834 | if (!pEntry) | |||
2835 | { | |||
2836 | pReturns[i].Result = beans::TolerantPropertySetResultType::UNKNOWN_PROPERTY; | |||
2837 | } | |||
2838 | else | |||
2839 | { | |||
2840 | sal_uInt16 nItemWhich = 0; | |||
2841 | lcl_GetPropertyWhich( pEntry, nItemWhich ); | |||
2842 | pReturns[i].State = GetOnePropertyState( nItemWhich, pEntry ); | |||
2843 | GetOnePropertyValue( pEntry, pReturns[i].Value ); | |||
2844 | pReturns[i].Result = beans::TolerantPropertySetResultType::SUCCESS; | |||
2845 | } | |||
2846 | } | |||
2847 | return aReturns; | |||
2848 | } | |||
2849 | ||||
2850 | uno::Sequence< beans::GetDirectPropertyTolerantResult > SAL_CALL ScCellRangesBase::getDirectPropertyValuesTolerant( const uno::Sequence< OUString >& aPropertyNames ) | |||
2851 | { | |||
2852 | SolarMutexGuard aGuard; | |||
2853 | ||||
2854 | sal_Int32 nCount(aPropertyNames.getLength()); | |||
2855 | uno::Sequence < beans::GetDirectPropertyTolerantResult > aReturns(nCount); | |||
2856 | beans::GetDirectPropertyTolerantResult* pReturns = aReturns.getArray(); | |||
2857 | ||||
2858 | const SfxItemPropertyMap& rPropertyMap = GetItemPropertyMap(); // from derived class | |||
2859 | ||||
2860 | sal_Int32 j = 0; | |||
2861 | for(sal_Int32 i = 0; i < nCount; i++) | |||
2862 | { | |||
2863 | const SfxItemPropertySimpleEntry* pEntry = rPropertyMap.getByName( aPropertyNames[i] ); | |||
2864 | if (!pEntry) | |||
2865 | { | |||
2866 | pReturns[i].Result = beans::TolerantPropertySetResultType::UNKNOWN_PROPERTY; | |||
2867 | } | |||
2868 | else | |||
2869 | { | |||
2870 | sal_uInt16 nItemWhich = 0; | |||
2871 | lcl_GetPropertyWhich( pEntry, nItemWhich ); | |||
2872 | pReturns[j].State = GetOnePropertyState( nItemWhich, pEntry ); | |||
2873 | if (pReturns[j].State == beans::PropertyState_DIRECT_VALUE) | |||
2874 | { | |||
2875 | GetOnePropertyValue( pEntry, pReturns[j].Value ); | |||
2876 | pReturns[j].Result = beans::TolerantPropertySetResultType::SUCCESS; | |||
2877 | pReturns[j].Name = aPropertyNames[i]; | |||
2878 | ++j; | |||
2879 | } | |||
2880 | } | |||
2881 | } | |||
2882 | if (j < nCount) | |||
2883 | aReturns.realloc(j); | |||
2884 | return aReturns; | |||
2885 | } | |||
2886 | ||||
2887 | // XIndent | |||
2888 | ||||
2889 | void SAL_CALL ScCellRangesBase::decrementIndent() | |||
2890 | { | |||
2891 | SolarMutexGuard aGuard; | |||
2892 | if ( pDocShell && !aRanges.empty() ) | |||
2893 | { | |||
2894 | //#97041#; put only MultiMarked ScMarkData in ChangeIndent | |||
2895 | ScMarkData aMarkData(*GetMarkData()); | |||
2896 | aMarkData.MarkToMulti(); | |||
2897 | pDocShell->GetDocFunc().ChangeIndent( aMarkData, false, true ); | |||
2898 | } | |||
2899 | } | |||
2900 | ||||
2901 | void SAL_CALL ScCellRangesBase::incrementIndent() | |||
2902 | { | |||
2903 | SolarMutexGuard aGuard; | |||
2904 | if ( pDocShell && !aRanges.empty() ) | |||
2905 | { | |||
2906 | //#97041#; put only MultiMarked ScMarkData in ChangeIndent | |||
2907 | ScMarkData aMarkData(*GetMarkData()); | |||
2908 | aMarkData.MarkToMulti(); | |||
2909 | pDocShell->GetDocFunc().ChangeIndent( aMarkData, true, true ); | |||
2910 | } | |||
2911 | } | |||
2912 | ||||
2913 | // XChartData | |||
2914 | ||||
2915 | std::unique_ptr<ScMemChart> ScCellRangesBase::CreateMemChart_Impl() const | |||
2916 | { | |||
2917 | if ( pDocShell && !aRanges.empty() ) | |||
2918 | { | |||
2919 | ScRangeListRef xChartRanges; | |||
2920 | if ( aRanges.size() == 1 ) | |||
2921 | { | |||
2922 | // set useful table limit (only occupied data area) | |||
2923 | // (only here - Listeners are registered for the whole area) | |||
2924 | //! check immediately if a ScTableSheetObj? | |||
2925 | ||||
2926 | const ScDocument & rDoc = pDocShell->GetDocument(); | |||
2927 | const ScRange & rRange = aRanges[0]; | |||
2928 | if ( rRange.aStart.Col() == 0 && rRange.aEnd.Col() == rDoc.MaxCol() && | |||
2929 | rRange.aStart.Row() == 0 && rRange.aEnd.Row() == rDoc.MaxRow() ) | |||
2930 | { | |||
2931 | SCTAB nTab = rRange.aStart.Tab(); | |||
2932 | ||||
2933 | SCCOL nStartX; | |||
2934 | SCROW nStartY; // Get start | |||
2935 | if (!pDocShell->GetDocument().GetDataStart( nTab, nStartX, nStartY )) | |||
2936 | { | |||
2937 | nStartX = 0; | |||
2938 | nStartY = 0; | |||
2939 | } | |||
2940 | ||||
2941 | SCCOL nEndX; | |||
2942 | SCROW nEndY; // Get end | |||
2943 | if (!pDocShell->GetDocument().GetTableArea( nTab, nEndX, nEndY )) | |||
2944 | { | |||
2945 | nEndX = 0; | |||
2946 | nEndY = 0; | |||
2947 | } | |||
2948 | ||||
2949 | xChartRanges = new ScRangeList( ScRange( nStartX, nStartY, nTab, nEndX, nEndY, nTab ) ); | |||
2950 | } | |||
2951 | } | |||
2952 | if (!xChartRanges.is()) // otherwise take Ranges directly | |||
2953 | xChartRanges = new ScRangeList(aRanges); | |||
2954 | ScChartArray aArr( pDocShell->GetDocument(), xChartRanges ); | |||
2955 | ||||
2956 | // RowAsHdr = ColHeaders and vice versa | |||
2957 | aArr.SetHeaders( bChartRowAsHdr, bChartColAsHdr ); | |||
2958 | ||||
2959 | return aArr.CreateMemChart(); | |||
2960 | } | |||
2961 | return nullptr; | |||
2962 | } | |||
2963 | ||||
2964 | uno::Sequence< uno::Sequence<double> > SAL_CALL ScCellRangesBase::getData() | |||
2965 | { | |||
2966 | SolarMutexGuard aGuard; | |||
2967 | std::unique_ptr<ScMemChart> pMemChart(CreateMemChart_Impl()); | |||
2968 | if ( pMemChart ) | |||
2969 | { | |||
2970 | sal_Int32 nColCount = pMemChart->GetColCount(); | |||
2971 | sal_Int32 nRowCount = static_cast<sal_Int32>(pMemChart->GetRowCount()); | |||
2972 | ||||
2973 | uno::Sequence< uno::Sequence<double> > aRowSeq( nRowCount ); | |||
2974 | uno::Sequence<double>* pRowAry = aRowSeq.getArray(); | |||
2975 | for (sal_Int32 nRow = 0; nRow < nRowCount; nRow++) | |||
2976 | { | |||
2977 | uno::Sequence<double> aColSeq( nColCount ); | |||
2978 | double* pColAry = aColSeq.getArray(); | |||
2979 | for (sal_Int32 nCol = 0; nCol < nColCount; nCol++) | |||
2980 | pColAry[nCol] = pMemChart->GetData( nCol, nRow ); | |||
2981 | ||||
2982 | pRowAry[nRow] = aColSeq; | |||
2983 | } | |||
2984 | ||||
2985 | return aRowSeq; | |||
2986 | } | |||
2987 | ||||
2988 | return uno::Sequence< uno::Sequence<double> >(0); | |||
2989 | } | |||
2990 | ||||
2991 | ScRangeListRef ScCellRangesBase::GetLimitedChartRanges_Impl( long nDataColumns, long nDataRows ) const | |||
2992 | { | |||
2993 | if ( aRanges.size() == 1 ) | |||
2994 | { | |||
2995 | const ScDocument & rDoc = pDocShell->GetDocument(); | |||
2996 | const ScRange & rRange = aRanges[0]; | |||
2997 | if ( rRange.aStart.Col() == 0 && rRange.aEnd.Col() == rDoc.MaxCol() && | |||
2998 | rRange.aStart.Row() == 0 && rRange.aEnd.Row() == rDoc.MaxRow() ) | |||
2999 | { | |||
3000 | // if aRanges is a complete sheet, limit to given size | |||
3001 | ||||
3002 | SCTAB nTab = rRange.aStart.Tab(); | |||
3003 | ||||
3004 | long nEndColumn = nDataColumns - 1 + ( bChartColAsHdr ? 1 : 0 ); | |||
3005 | if ( nEndColumn < 0 ) | |||
3006 | nEndColumn = 0; | |||
3007 | if ( nEndColumn > rDoc.MaxCol() ) | |||
3008 | nEndColumn = rDoc.MaxCol(); | |||
3009 | ||||
3010 | long nEndRow = nDataRows - 1 + ( bChartRowAsHdr ? 1 : 0 ); | |||
3011 | if ( nEndRow < 0 ) | |||
3012 | nEndRow = 0; | |||
3013 | if ( nEndRow > rDoc.MaxRow() ) | |||
3014 | nEndRow = rDoc.MaxRow(); | |||
3015 | ||||
3016 | ScRangeListRef xChartRanges = new ScRangeList( ScRange( 0, 0, nTab, static_cast<SCCOL>(nEndColumn), static_cast<SCROW>(nEndRow), nTab ) ); | |||
3017 | return xChartRanges; | |||
3018 | } | |||
3019 | } | |||
3020 | ||||
3021 | return new ScRangeList(aRanges); // as-is | |||
3022 | } | |||
3023 | ||||
3024 | void SAL_CALL ScCellRangesBase::setData( const uno::Sequence< uno::Sequence<double> >& aData ) | |||
3025 | { | |||
3026 | SolarMutexGuard aGuard; | |||
3027 | bool bDone = false; | |||
3028 | long nRowCount = aData.getLength(); | |||
3029 | long nColCount = nRowCount ? aData[0].getLength() : 0; | |||
3030 | ScRangeListRef xChartRanges = GetLimitedChartRanges_Impl( nColCount, nRowCount ); | |||
3031 | if ( pDocShell && xChartRanges.is() ) | |||
3032 | { | |||
3033 | ScDocument& rDoc = pDocShell->GetDocument(); | |||
3034 | ScChartArray aArr( rDoc, xChartRanges ); | |||
3035 | aArr.SetHeaders( bChartRowAsHdr, bChartColAsHdr ); // RowAsHdr = ColHeaders | |||
3036 | const ScChartPositionMap* pPosMap = aArr.GetPositionMap(); | |||
3037 | if (pPosMap) | |||
3038 | { | |||
3039 | if ( pPosMap->GetColCount() == static_cast<SCCOL>(nColCount) && | |||
3040 | pPosMap->GetRowCount() == static_cast<SCROW>(nRowCount) ) | |||
3041 | { | |||
3042 | for (long nRow=0; nRow<nRowCount; nRow++) | |||
3043 | { | |||
3044 | const uno::Sequence<double>& rRowSeq = aData[nRow]; | |||
3045 | const double* pArray = rRowSeq.getConstArray(); | |||
3046 | nColCount = rRowSeq.getLength(); | |||
3047 | for (long nCol=0; nCol<nColCount; nCol++) | |||
3048 | { | |||
3049 | const ScAddress* pPos = pPosMap->GetPosition( | |||
3050 | sal::static_int_cast<SCCOL>(nCol), | |||
3051 | sal::static_int_cast<SCROW>(nRow) ); | |||
3052 | if (pPos) | |||
3053 | { | |||
3054 | double fVal = pArray[nCol]; | |||
3055 | if ( fVal == DBL_MIN2.2250738585072014e-308 ) | |||
3056 | rDoc.SetEmptyCell(*pPos); | |||
3057 | else | |||
3058 | rDoc.SetValue(*pPos, pArray[nCol]); | |||
3059 | } | |||
3060 | } | |||
3061 | } | |||
3062 | ||||
3063 | //! undo | |||
3064 | PaintGridRanges_Impl(); | |||
3065 | pDocShell->SetDocumentModified(); | |||
3066 | ForceChartListener_Impl(); // call listeners for this object synchronously | |||
3067 | bDone = true; | |||
3068 | } | |||
3069 | } | |||
3070 | } | |||
3071 | ||||
3072 | if (!bDone) | |||
3073 | throw uno::RuntimeException(); | |||
3074 | } | |||
3075 | ||||
3076 | uno::Sequence<OUString> SAL_CALL ScCellRangesBase::getRowDescriptions() | |||
3077 | { | |||
3078 | SolarMutexGuard aGuard; | |||
3079 | std::unique_ptr<ScMemChart> pMemChart(CreateMemChart_Impl()); | |||
3080 | if ( pMemChart ) | |||
3081 | { | |||
3082 | sal_Int32 nRowCount = static_cast<sal_Int32>(pMemChart->GetRowCount()); | |||
3083 | uno::Sequence<OUString> aSeq( nRowCount ); | |||
3084 | OUString* pAry = aSeq.getArray(); | |||
3085 | for (sal_Int32 nRow = 0; nRow < nRowCount; nRow++) | |||
3086 | pAry[nRow] = pMemChart->GetRowText(nRow); | |||
3087 | ||||
3088 | return aSeq; | |||
3089 | } | |||
3090 | return uno::Sequence<OUString>(0); | |||
3091 | } | |||
3092 | ||||
3093 | void SAL_CALL ScCellRangesBase::setRowDescriptions( | |||
3094 | const uno::Sequence<OUString>& aRowDescriptions ) | |||
3095 | { | |||
3096 | SolarMutexGuard aGuard; | |||
3097 | bool bDone = false; | |||
3098 | if ( bChartColAsHdr ) | |||
3099 | { | |||
3100 | long nRowCount = aRowDescriptions.getLength(); | |||
3101 | ScRangeListRef xChartRanges = GetLimitedChartRanges_Impl( 1, nRowCount ); | |||
3102 | if ( pDocShell && xChartRanges.is() ) | |||
3103 | { | |||
3104 | ScDocument& rDoc = pDocShell->GetDocument(); | |||
3105 | ScChartArray aArr( rDoc, xChartRanges ); | |||
3106 | aArr.SetHeaders( bChartRowAsHdr, bChartColAsHdr ); // RowAsHdr = ColHeaders | |||
3107 | const ScChartPositionMap* pPosMap = aArr.GetPositionMap(); | |||
3108 | if (pPosMap) | |||
3109 | { | |||
3110 | if ( pPosMap->GetRowCount() == static_cast<SCROW>(nRowCount) ) | |||
3111 | { | |||
3112 | const OUString* pArray = aRowDescriptions.getConstArray(); | |||
3113 | for (long nRow=0; nRow<nRowCount; nRow++) | |||
3114 | { | |||
3115 | const ScAddress* pPos = pPosMap->GetRowHeaderPosition( | |||
3116 | static_cast<SCSIZE>(nRow) ); | |||
3117 | if (pPos) | |||
3118 | { | |||
3119 | const OUString& aStr = pArray[nRow]; | |||
3120 | if (aStr.isEmpty()) | |||
3121 | rDoc.SetEmptyCell(*pPos); | |||
3122 | else | |||
3123 | { | |||
3124 | ScSetStringParam aParam; | |||
3125 | aParam.setTextInput(); | |||
3126 | rDoc.SetString(*pPos, aStr, &aParam); | |||
3127 | } | |||
3128 | } | |||
3129 | } | |||
3130 | ||||
3131 | //! undo | |||
3132 | PaintGridRanges_Impl(); | |||
3133 | pDocShell->SetDocumentModified(); | |||
3134 | ForceChartListener_Impl(); // call listeners for this object synchronously | |||
3135 | bDone = true; | |||
3136 | } | |||
3137 | } | |||
3138 | } | |||
3139 | } | |||
3140 | ||||
3141 | if (!bDone) | |||
3142 | throw uno::RuntimeException(); | |||
3143 | } | |||
3144 | ||||
3145 | uno::Sequence<OUString> SAL_CALL ScCellRangesBase::getColumnDescriptions() | |||
3146 | { | |||
3147 | SolarMutexGuard aGuard; | |||
3148 | std::unique_ptr<ScMemChart> pMemChart(CreateMemChart_Impl()); | |||
3149 | if ( pMemChart ) | |||
3150 | { | |||
3151 | sal_Int32 nColCount = pMemChart->GetColCount(); | |||
3152 | uno::Sequence<OUString> aSeq( nColCount ); | |||
3153 | OUString* pAry = aSeq.getArray(); | |||
3154 | for (sal_Int32 nCol = 0; nCol < nColCount; nCol++) | |||
3155 | pAry[nCol] = pMemChart->GetColText(nCol); | |||
3156 | ||||
3157 | return aSeq; | |||
3158 | } | |||
3159 | return uno::Sequence<OUString>(0); | |||
3160 | } | |||
3161 | ||||
3162 | void SAL_CALL ScCellRangesBase::setColumnDescriptions( | |||
3163 | const uno::Sequence<OUString>& aColumnDescriptions ) | |||
3164 | { | |||
3165 | SolarMutexGuard aGuard; | |||
3166 | bool bDone = false; | |||
3167 | if ( bChartRowAsHdr ) | |||
3168 | { | |||
3169 | long nColCount = aColumnDescriptions.getLength(); | |||
3170 | ScRangeListRef xChartRanges = GetLimitedChartRanges_Impl( nColCount, 1 ); | |||
3171 | if ( pDocShell && xChartRanges.is() ) | |||
3172 | { | |||
3173 | ScDocument& rDoc = pDocShell->GetDocument(); | |||
3174 | ScChartArray aArr( rDoc, xChartRanges ); | |||
3175 | aArr.SetHeaders( bChartRowAsHdr, bChartColAsHdr ); // RowAsHdr = ColHeaders | |||
3176 | const ScChartPositionMap* pPosMap = aArr.GetPositionMap(); | |||
3177 | if (pPosMap) | |||
3178 | { | |||
3179 | if ( pPosMap->GetColCount() == static_cast<SCCOL>(nColCount) ) | |||
3180 | { | |||
3181 | const OUString* pArray = aColumnDescriptions.getConstArray(); | |||
3182 | for (long nCol=0; nCol<nColCount; nCol++) | |||
3183 | { | |||
3184 | const ScAddress* pPos = pPosMap->GetColHeaderPosition( | |||
3185 | sal::static_int_cast<SCCOL>(nCol) ); | |||
3186 | if (pPos) | |||
3187 | { | |||
3188 | const OUString& aStr = pArray[nCol]; | |||
3189 | if (aStr.isEmpty()) | |||
3190 | rDoc.SetEmptyCell(*pPos); | |||
3191 | else | |||
3192 | { | |||
3193 | ScSetStringParam aParam; | |||
3194 | aParam.setTextInput(); | |||
3195 | rDoc.SetString(*pPos, aStr, &aParam); | |||
3196 | } | |||
3197 | } | |||
3198 | } | |||
3199 | ||||
3200 | //! undo | |||
3201 | PaintGridRanges_Impl(); | |||
3202 | pDocShell->SetDocumentModified(); | |||
3203 | ForceChartListener_Impl(); // call listeners for this object synchronously | |||
3204 | bDone = true; | |||
3205 | } | |||
3206 | } | |||
3207 | } | |||
3208 | } | |||
3209 | ||||
3210 | if (!bDone) | |||
3211 | throw uno::RuntimeException(); | |||
3212 | } | |||
3213 | ||||
3214 | void ScCellRangesBase::ForceChartListener_Impl() | |||
3215 | { | |||
3216 | // call Update immediately so the caller to setData etc. can | |||
3217 | // recognize the listener call | |||
3218 | ||||
3219 | if (!pDocShell) | |||
3220 | return; | |||
3221 | ||||
3222 | ScChartListenerCollection* pColl = pDocShell->GetDocument().GetChartListenerCollection(); | |||
3223 | if (!pColl) | |||
3224 | return; | |||
3225 | ||||
3226 | ScChartListenerCollection::ListenersType& rListeners = pColl->getListeners(); | |||
3227 | for (auto const& it : rListeners) | |||
3228 | { | |||
3229 | ScChartListener *const p = it.second.get(); | |||
3230 | assert(p)(static_cast <bool> (p) ? void (0) : __assert_fail ("p" , "/home/maarten/src/libreoffice/core/sc/source/ui/unoobj/cellsuno.cxx" , 3230, __extension__ __PRETTY_FUNCTION__)); | |||
3231 | if (p->GetUnoSource() == static_cast<chart::XChartData*>(this) && p->IsDirty()) | |||
3232 | p->Update(); | |||
3233 | } | |||
3234 | } | |||
3235 | ||||
3236 | void SAL_CALL ScCellRangesBase::addChartDataChangeEventListener( const uno::Reference< | |||
3237 | chart::XChartDataChangeEventListener >& aListener ) | |||
3238 | { | |||
3239 | SolarMutexGuard aGuard; | |||
3240 | if ( !pDocShell || aRanges.empty() ) | |||
3241 | return; | |||
3242 | ||||
3243 | //! test for duplicates ? | |||
3244 | ||||
3245 | ScDocument& rDoc = pDocShell->GetDocument(); | |||
3246 | ScRangeListRef aRangesRef( new ScRangeList(aRanges) ); | |||
3247 | ScChartListenerCollection* pColl = rDoc.GetChartListenerCollection(); | |||
3248 | OUString aName = pColl->getUniqueName("__Uno"); | |||
3249 | if (aName.isEmpty()) | |||
3250 | // failed to create unique name. | |||
3251 | return; | |||
3252 | ||||
3253 | ScChartListener* pListener = new ScChartListener( aName, rDoc, aRangesRef ); | |||
3254 | pListener->SetUno( aListener, this ); | |||
3255 | pColl->insert( pListener ); | |||
3256 | pListener->StartListeningTo(); | |||
3257 | } | |||
3258 | ||||
3259 | void SAL_CALL ScCellRangesBase::removeChartDataChangeEventListener( const uno::Reference< | |||
3260 | chart::XChartDataChangeEventListener >& aListener ) | |||
3261 | { | |||
3262 | SolarMutexGuard aGuard; | |||
3263 | if ( pDocShell && !aRanges.empty() ) | |||
3264 | { | |||
3265 | ScDocument& rDoc = pDocShell->GetDocument(); | |||
3266 | ScChartListenerCollection* pColl = rDoc.GetChartListenerCollection(); | |||
3267 | pColl->FreeUno( aListener, this ); | |||
3268 | } | |||
3269 | } | |||
3270 | ||||
3271 | double SAL_CALL ScCellRangesBase::getNotANumber() | |||
3272 | { | |||
3273 | // use DBL_MIN in ScChartArray, because Chart wants it so | |||
3274 | return DBL_MIN2.2250738585072014e-308; | |||
3275 | } | |||
3276 | ||||
3277 | sal_Bool SAL_CALL ScCellRangesBase::isNotANumber( double nNumber ) | |||
3278 | { | |||
3279 | // use DBL_MIN in ScChartArray, because Chart wants it so | |||
3280 | return (nNumber == DBL_MIN2.2250738585072014e-308); | |||
3281 | } | |||
3282 | ||||
3283 | // XModifyBroadcaster | |||
3284 | ||||
3285 | void SAL_CALL ScCellRangesBase::addModifyListener(const uno::Reference<util::XModifyListener>& aListener) | |||
3286 | { | |||
3287 | SolarMutexGuard aGuard; | |||
3288 | if ( aRanges.empty() ) | |||
3289 | throw uno::RuntimeException(); | |||
3290 | ||||
3291 | aValueListeners.emplace_back( aListener ); | |||
3292 | ||||
3293 | if ( aValueListeners.size() == 1 ) | |||
3294 | { | |||
3295 | if (!pValueListener) | |||
3296 | pValueListener.reset( new ScLinkListener( LINK( this, ScCellRangesBase, ValueListenerHdl )::tools::detail::makeLink( ::tools::detail::castTo<ScCellRangesBase *>(this), &ScCellRangesBase::LinkStubValueListenerHdl ) ) ); | |||
3297 | ||||
3298 | ScDocument& rDoc = pDocShell->GetDocument(); | |||
3299 | for ( size_t i = 0, nCount = aRanges.size(); i < nCount; i++) | |||
3300 | rDoc.StartListeningArea( aRanges[ i ], false, pValueListener.get() ); | |||
3301 | ||||
3302 | acquire(); // don't lose this object (one ref for all listeners) | |||
3303 | } | |||
3304 | } | |||
3305 | ||||
3306 | void SAL_CALL ScCellRangesBase::removeModifyListener( const uno::Reference<util::XModifyListener>& aListener ) | |||
3307 | { | |||
3308 | ||||
3309 | SolarMutexGuard aGuard; | |||
3310 | if ( aRanges.empty() ) | |||
3311 | throw uno::RuntimeException(); | |||
3312 | ||||
3313 | rtl::Reference<ScCellRangesBase> xSelfHold(this); // in case the listeners have the last ref | |||
3314 | ||||
3315 | sal_uInt16 nCount = aValueListeners.size(); | |||
3316 | for ( sal_uInt16 n=nCount; n--; ) | |||
3317 | { | |||
3318 | uno::Reference<util::XModifyListener>& rObj = aValueListeners[n]; | |||
3319 | if ( rObj == aListener ) | |||
3320 | { | |||
3321 | aValueListeners.erase( aValueListeners.begin() + n ); | |||
3322 | ||||
3323 | if ( aValueListeners.empty() ) | |||
3324 | { | |||
3325 | if (pValueListener) | |||
3326 | pValueListener->EndListeningAll(); | |||
3327 | ||||
3328 | release(); // release the ref for the listeners | |||
3329 | } | |||
3330 | ||||
3331 | break; | |||
3332 | } | |||
3333 | } | |||
3334 | } | |||
3335 | ||||
3336 | // XCellRangesQuery | |||
3337 | ||||
3338 | uno::Reference<sheet::XSheetCellRanges> SAL_CALL ScCellRangesBase::queryVisibleCells() | |||
3339 | { | |||
3340 | SolarMutexGuard aGuard; | |||
3341 | if (pDocShell) | |||
3342 | { | |||
3343 | //! Separate for all tables, if markings separated per table | |||
3344 | SCTAB nTab = lcl_FirstTab(aRanges); | |||
3345 | ||||
3346 | ScMarkData aMarkData(*GetMarkData()); | |||
3347 | ||||
3348 | ScDocument& rDoc = pDocShell->GetDocument(); | |||
3349 | SCCOL nCol = 0, nLastCol; | |||
3350 | while (nCol <= rDoc.MaxCol()) | |||
3351 | { | |||
3352 | if (rDoc.ColHidden(nCol, nTab, nullptr, &nLastCol)) | |||
3353 | // hidden columns. Deselect them. | |||
3354 | aMarkData.SetMultiMarkArea(ScRange(nCol, 0, nTab, nLastCol, rDoc.MaxRow(), nTab), false); | |||
3355 | ||||
3356 | nCol = nLastCol + 1; | |||
3357 | } | |||
3358 | ||||
3359 | SCROW nRow = 0, nLastRow; | |||
3360 | while (nRow <= rDoc.MaxRow()) | |||
3361 | { | |||
3362 | if (rDoc.RowHidden(nRow, nTab, nullptr, &nLastRow)) | |||
3363 | // These rows are hidden. Deselect them. | |||
3364 | aMarkData.SetMultiMarkArea(ScRange(0, nRow, nTab, rDoc.MaxCol(), nLastRow, nTab), false); | |||
3365 | ||||
3366 | nRow = nLastRow + 1; | |||
3367 | } | |||
3368 | ||||
3369 | ScRangeList aNewRanges; | |||
3370 | aMarkData.FillRangeListWithMarks( &aNewRanges, false ); | |||
3371 | return new ScCellRangesObj( pDocShell, aNewRanges ); | |||
3372 | } | |||
3373 | ||||
3374 | return nullptr; | |||
3375 | } | |||
3376 | ||||
3377 | uno::Reference<sheet::XSheetCellRanges> SAL_CALL ScCellRangesBase::queryEmptyCells() | |||
3378 | { | |||
3379 | SolarMutexGuard aGuard; | |||
3380 | if (pDocShell) | |||
3381 | { | |||
3382 | ScDocument& rDoc = pDocShell->GetDocument(); | |||
3383 | ||||
3384 | ScMarkData aMarkData(*GetMarkData()); | |||
3385 | ||||
3386 | // mark occupied cells | |||
3387 | for (size_t i = 0, nCount = aRanges.size(); i < nCount; ++i) | |||
3388 | { | |||
3389 | ScRange const & rRange = aRanges[ i ]; | |||
3390 | ||||
3391 | ScCellIterator aIter(rDoc, rRange); | |||
3392 | for (bool bHasCell = aIter.first(); bHasCell; bHasCell = aIter.next()) | |||
3393 | { | |||
3394 | // notes count as non-empty | |||
3395 | if (!aIter.isEmpty()) | |||
3396 | aMarkData.SetMultiMarkArea(aIter.GetPos(), false); | |||
3397 | } | |||
3398 | } | |||
3399 | ||||
3400 | ScRangeList aNewRanges; | |||
3401 | // IsMultiMarked is not enough (will not be reset during deselecting) | |||
3402 | //if (aMarkData.HasAnyMultiMarks()) // #i20044# should be set for all empty range | |||
3403 | aMarkData.FillRangeListWithMarks( &aNewRanges, false ); | |||
3404 | ||||
3405 | return new ScCellRangesObj( pDocShell, aNewRanges ); // aNewRanges can be empty | |||
3406 | } | |||
3407 | ||||
3408 | return nullptr; | |||
3409 | } | |||
3410 | ||||
3411 | uno::Reference<sheet::XSheetCellRanges> SAL_CALL ScCellRangesBase::queryContentCells( | |||
3412 | sal_Int16 nContentFlags ) | |||
3413 | { | |||
3414 | SolarMutexGuard aGuard; | |||
3415 | if (pDocShell) | |||
3416 | { | |||
3417 | ScDocument& rDoc = pDocShell->GetDocument(); | |||
3418 | ||||
3419 | ScMarkData aMarkData(rDoc.GetSheetLimits()); | |||
3420 | ||||
3421 | // select matching cells | |||
3422 | for ( size_t i = 0, nCount = aRanges.size(); i < nCount; ++i ) | |||
3423 | { | |||
3424 | ScRange const & rRange = aRanges[ i ]; | |||
3425 | ||||
3426 | ScCellIterator aIter(rDoc, rRange); | |||
3427 | for (bool bHasCell = aIter.first(); bHasCell; bHasCell = aIter.next()) | |||
3428 | { | |||
3429 | bool bAdd = false; | |||
3430 | switch (aIter.getType()) | |||
3431 | { | |||
3432 | case CELLTYPE_STRING: | |||
3433 | if ( nContentFlags & sheet::CellFlags::STRING ) | |||
3434 | bAdd = true; | |||
3435 | break; | |||
3436 | case CELLTYPE_EDIT: | |||
3437 | if ( (nContentFlags & sheet::CellFlags::STRING) || (nContentFlags & sheet::CellFlags::FORMATTED) ) | |||
3438 | bAdd = true; | |||
3439 | break; | |||
3440 | case CELLTYPE_FORMULA: | |||
3441 | if ( nContentFlags & sheet::CellFlags::FORMULA ) | |||
3442 | bAdd = true; | |||
3443 | break; | |||
3444 | case CELLTYPE_VALUE: | |||
3445 | if ( (nContentFlags & (sheet::CellFlags::VALUE|sheet::CellFlags::DATETIME)) | |||
3446 | == (sheet::CellFlags::VALUE|sheet::CellFlags::DATETIME) ) | |||
3447 | bAdd = true; | |||
3448 | else | |||
3449 | { | |||
3450 | // date/time identification | |||
3451 | ||||
3452 | sal_uLong nIndex = static_cast<sal_uLong>(rDoc.GetAttr( | |||
3453 | aIter.GetPos(), ATTR_VALUE_FORMAT)->GetValue()); | |||
3454 | SvNumFormatType nTyp = rDoc.GetFormatTable()->GetType(nIndex); | |||
3455 | if ((nTyp == SvNumFormatType::DATE) || (nTyp == SvNumFormatType::TIME) || | |||
3456 | (nTyp == SvNumFormatType::DATETIME)) | |||
3457 | { | |||
3458 | if ( nContentFlags & sheet::CellFlags::DATETIME ) | |||
3459 | bAdd = true; | |||
3460 | } | |||
3461 | else | |||
3462 | { | |||
3463 | if ( nContentFlags & sheet::CellFlags::VALUE ) | |||
3464 | bAdd = true; | |||
3465 | } | |||
3466 | } | |||
3467 | break; | |||
3468 | default: | |||
3469 | { | |||
3470 | // added to avoid warnings | |||
3471 | } | |||
3472 | } | |||
3473 | ||||
3474 | if (bAdd) | |||
3475 | aMarkData.SetMultiMarkArea(aIter.GetPos()); | |||
3476 | } | |||
3477 | } | |||
3478 | ||||
3479 | if (nContentFlags & sheet::CellFlags::ANNOTATION) | |||
3480 | { | |||
3481 | std::vector<sc::NoteEntry> aNotes; | |||
3482 | rDoc.GetNotesInRange(aRanges, aNotes); | |||
3483 | ||||
3484 | for (const auto& i : aNotes) | |||
3485 | { | |||
3486 | aMarkData.SetMultiMarkArea(i.maPos); | |||
3487 | } | |||
3488 | } | |||
3489 | ||||
3490 | ScRangeList aNewRanges; | |||
3491 | if (aMarkData.IsMultiMarked()) | |||
3492 | aMarkData.FillRangeListWithMarks( &aNewRanges, false ); | |||
3493 | ||||
3494 | return new ScCellRangesObj( pDocShell, aNewRanges ); // aNewRanges can be empty | |||
3495 | } | |||
3496 | ||||
3497 | return nullptr; | |||
3498 | } | |||
3499 | ||||
3500 | uno::Reference<sheet::XSheetCellRanges> SAL_CALL ScCellRangesBase::queryFormulaCells( | |||
3501 | sal_Int32 nResultFlags ) | |||
3502 | { | |||
3503 | SolarMutexGuard aGuard; | |||
3504 | if (pDocShell) | |||
3505 | { | |||
3506 | ScDocument& rDoc = pDocShell->GetDocument(); | |||
3507 | ||||
3508 | ScMarkData aMarkData(rDoc.GetSheetLimits()); | |||
3509 | ||||
3510 | // select matching cells | |||
3511 | for ( size_t i = 0, nCount = aRanges.size(); i < nCount; ++i ) | |||
3512 | { | |||
3513 | ScRange const & rRange = aRanges[ i ]; | |||
3514 | ||||
3515 | ScCellIterator aIter(rDoc, rRange); | |||
3516 | for (bool bHasCell = aIter.first(); bHasCell; bHasCell = aIter.next()) | |||
3517 | { | |||
3518 | if (aIter.getType() == CELLTYPE_FORMULA) | |||
3519 | { | |||
3520 | ScFormulaCell* pFCell = aIter.getFormulaCell(); | |||
3521 | bool bAdd = false; | |||
3522 | if (pFCell->GetErrCode() != FormulaError::NONE) | |||
3523 | { | |||
3524 | if ( nResultFlags & sheet::FormulaResult::ERROR ) | |||
3525 | bAdd = true; | |||
3526 | } | |||
3527 | else if (pFCell->IsValue()) | |||
3528 | { | |||
3529 | if ( nResultFlags & sheet::FormulaResult::VALUE ) | |||
3530 | bAdd = true; | |||
3531 | } | |||
3532 | else // String | |||
3533 | { | |||
3534 | if ( nResultFlags & sheet::FormulaResult::STRING ) | |||
3535 | bAdd = true; | |||
3536 | } | |||
3537 | ||||
3538 | if (bAdd) | |||
3539 | aMarkData.SetMultiMarkArea(aIter.GetPos()); | |||
3540 | } | |||
3541 | } | |||
3542 | } | |||
3543 | ||||
3544 | ScRangeList aNewRanges; | |||
3545 | if (aMarkData.IsMultiMarked()) | |||
3546 | aMarkData.FillRangeListWithMarks( &aNewRanges, false ); | |||
3547 | ||||
3548 | return new ScCellRangesObj( pDocShell, aNewRanges ); // aNewRanges can be empty | |||
3549 | } | |||
3550 | ||||
3551 | return nullptr; | |||
3552 | } | |||
3553 | ||||
3554 | uno::Reference<sheet::XSheetCellRanges> ScCellRangesBase::QueryDifferences_Impl( | |||
3555 | const table::CellAddress& aCompare, bool bColumnDiff) | |||
3556 | { | |||
3557 | if (pDocShell) | |||
3558 | { | |||
3559 | size_t nRangeCount = aRanges.size(); | |||
3560 | size_t i; | |||
3561 | ScDocument& rDoc = pDocShell->GetDocument(); | |||
3562 | ScMarkData aMarkData(rDoc.GetSheetLimits()); | |||
3563 | ||||
3564 | SCCOLROW nCmpPos = bColumnDiff ? static_cast<SCCOLROW>(aCompare.Row) : static_cast<SCCOLROW>(aCompare.Column); | |||
3565 | ||||
3566 | // first select everything, where at all something is in the comparison column | |||
3567 | // (in the second step the selection is cancelled for equal cells) | |||
3568 | ||||
3569 | SCTAB nTab = lcl_FirstTab(aRanges); //! for all tables, if markings per table | |||
3570 | ScRange aCmpRange, aCellRange; | |||
3571 | if (bColumnDiff) | |||
3572 | aCmpRange = ScRange( 0,nCmpPos,nTab, rDoc.MaxCol(),nCmpPos,nTab ); | |||
3573 | else | |||
3574 | aCmpRange = ScRange( static_cast<SCCOL>(nCmpPos),0,nTab, static_cast<SCCOL>(nCmpPos),rDoc.MaxRow(),nTab ); | |||
3575 | ScCellIterator aCmpIter(rDoc, aCmpRange); | |||
3576 | for (bool bHasCell = aCmpIter.first(); bHasCell; bHasCell = aCmpIter.next()) | |||
3577 | { | |||
3578 | SCCOLROW nCellPos = bColumnDiff ? static_cast<SCCOLROW>(aCmpIter.GetPos().Col()) : static_cast<SCCOLROW>(aCmpIter.GetPos().Row()); | |||
3579 | if (bColumnDiff) | |||
3580 | aCellRange = ScRange( static_cast<SCCOL>(nCellPos),0,nTab, | |||
3581 | static_cast<SCCOL>(nCellPos),rDoc.MaxRow(),nTab ); | |||
3582 | else | |||
3583 | aCellRange = ScRange( 0,nCellPos,nTab, rDoc.MaxCol(),nCellPos,nTab ); | |||
3584 | ||||
3585 | for (i=0; i<nRangeCount; i++) | |||
3586 | { | |||
3587 | ScRange aRange( aRanges[ i ] ); | |||
3588 | if ( aRange.Intersects( aCellRange ) ) | |||
3589 | { | |||
3590 | if (bColumnDiff) | |||
3591 | { | |||
3592 | aRange.aStart.SetCol(static_cast<SCCOL>(nCellPos)); | |||
3593 | aRange.aEnd.SetCol(static_cast<SCCOL>(nCellPos)); | |||
3594 | } | |||
3595 | else | |||
3596 | { | |||
3597 | aRange.aStart.SetRow(nCellPos); | |||
3598 | aRange.aEnd.SetRow(nCellPos); | |||
3599 | } | |||
3600 | aMarkData.SetMultiMarkArea( aRange ); | |||
3601 | } | |||
3602 | } | |||
3603 | } | |||
3604 | ||||
3605 | // compare all not empty cells with the comparison column and accordingly | |||
3606 | // select or cancel | |||
3607 | ||||
3608 | ScAddress aCmpAddr; | |||
3609 | for (i=0; i<nRangeCount; i++) | |||
3610 | { | |||
3611 | ScRange const & rRange = aRanges[ i ]; | |||
3612 | ||||
3613 | ScCellIterator aIter( rDoc, rRange ); | |||
3614 | for (bool bHasCell = aIter.first(); bHasCell; bHasCell = aIter.next()) | |||
3615 | { | |||
3616 | if (bColumnDiff) | |||
3617 | aCmpAddr = ScAddress( aIter.GetPos().Col(), nCmpPos, aIter.GetPos().Tab() ); | |||
3618 | else | |||
3619 | aCmpAddr = ScAddress( static_cast<SCCOL>(nCmpPos), aIter.GetPos().Row(), aIter.GetPos().Tab() ); | |||
3620 | ||||
3621 | ScRange aOneRange(aIter.GetPos()); | |||
3622 | if (!aIter.equalsWithoutFormat(aCmpAddr)) | |||
3623 | aMarkData.SetMultiMarkArea( aOneRange ); | |||
3624 | else | |||
3625 | aMarkData.SetMultiMarkArea( aOneRange, false ); // deselect | |||
3626 | } | |||
3627 | } | |||
3628 | ||||
3629 | ScRangeList aNewRanges; | |||
3630 | if (aMarkData.IsMultiMarked()) | |||
3631 | aMarkData.FillRangeListWithMarks( &aNewRanges, false ); | |||
3632 | ||||
3633 | return new ScCellRangesObj( pDocShell, aNewRanges ); // aNewRanges can be empty | |||
3634 | } | |||
3635 | return nullptr; | |||
3636 | } | |||
3637 | ||||
3638 | uno::Reference<sheet::XSheetCellRanges > SAL_CALL ScCellRangesBase::queryColumnDifferences( | |||
3639 | const table::CellAddress& aCompare ) | |||
3640 | { | |||
3641 | SolarMutexGuard aGuard; | |||
3642 | return QueryDifferences_Impl( aCompare, true ); | |||
3643 | } | |||
3644 | ||||
3645 | uno::Reference<sheet::XSheetCellRanges> SAL_CALL ScCellRangesBase::queryRowDifferences( | |||
3646 | const table::CellAddress& aCompare ) | |||
3647 | { | |||
3648 | SolarMutexGuard aGuard; | |||
3649 | return QueryDifferences_Impl( aCompare, false ); | |||
3650 | } | |||
3651 | ||||
3652 | uno::Reference<sheet::XSheetCellRanges> SAL_CALL ScCellRangesBase::queryIntersection( | |||
3653 | const table::CellRangeAddress& aRange ) | |||
3654 | { | |||
3655 | SolarMutexGuard aGuard; | |||
3656 | ScRange aMask( static_cast<SCCOL>(aRange.StartColumn), static_cast<SCROW>(aRange.StartRow), aRange.Sheet, | |||
3657 | static_cast<SCCOL>(aRange.EndColumn), static_cast<SCROW>(aRange.EndRow), aRange.Sheet ); | |||
3658 | ||||
3659 | ScRangeList aNew; | |||
3660 | for ( size_t i = 0, nCount = aRanges.size(); i < nCount; ++i ) | |||
3661 | { | |||
3662 | ScRange aTemp( aRanges[ i ] ); | |||
3663 | if ( aTemp.Intersects( aMask ) ) | |||
3664 | aNew.Join( ScRange( std::max( aTemp.aStart.Col(), aMask.aStart.Col() ), | |||
3665 | std::max( aTemp.aStart.Row(), aMask.aStart.Row() ), | |||
3666 | std::max( aTemp.aStart.Tab(), aMask.aStart.Tab() ), | |||
3667 | std::min( aTemp.aEnd.Col(), aMask.aEnd.Col() ), | |||
3668 | std::min( aTemp.aEnd.Row(), aMask.aEnd.Row() ), | |||
3669 | std::min( aTemp.aEnd.Tab(), aMask.aEnd.Tab() ) ) ); | |||
3670 | } | |||
3671 | ||||
3672 | return new ScCellRangesObj( pDocShell, aNew ); // can be empty | |||
3673 | } | |||
3674 | ||||
3675 | // XFormulaQuery | |||
3676 | ||||
3677 | uno::Reference<sheet::XSheetCellRanges> SAL_CALL ScCellRangesBase::queryPrecedents( | |||
3678 | sal_Bool bRecursive ) | |||
3679 | { | |||
3680 | SolarMutexGuard aGuard; | |||
3681 | if ( pDocShell ) | |||
3682 | { | |||
3683 | ScDocument& rDoc = pDocShell->GetDocument(); | |||
3684 | ||||
3685 | ScRangeList aNewRanges(aRanges); | |||
3686 | bool bFound; | |||
3687 | do | |||
3688 | { | |||
3689 | bFound = false; | |||
3690 | ||||
3691 | // aMarkData uses aNewRanges, not aRanges, so GetMarkData can't be used | |||
3692 | ScMarkData aMarkData(rDoc.GetSheetLimits()); | |||
3693 | aMarkData.MarkFromRangeList( aNewRanges, false ); | |||
3694 | aMarkData.MarkToMulti(); // needed for IsAllMarked | |||
3695 | ||||
3696 | for (size_t nR = 0, nCount = aNewRanges.size(); nR<nCount; ++nR) | |||
3697 | { | |||
3698 | ScRange const & rRange = aNewRanges[ nR]; | |||
3699 | ScCellIterator aIter(rDoc, rRange); | |||
3700 | for (bool bHasCell = aIter.first(); bHasCell; bHasCell = aIter.next()) | |||
3701 | { | |||
3702 | if (aIter.getType() != CELLTYPE_FORMULA) | |||
3703 | continue; | |||
3704 | ||||
3705 | ScDetectiveRefIter aRefIter(rDoc, aIter.getFormulaCell()); | |||
3706 | ScRange aRefRange; | |||
3707 | while ( aRefIter.GetNextRef( aRefRange) ) | |||
3708 | { | |||
3709 | if ( bRecursive && !bFound && !aMarkData.IsAllMarked( aRefRange ) ) | |||
3710 | bFound = true; | |||
3711 | aMarkData.SetMultiMarkArea(aRefRange); | |||
3712 | } | |||
3713 | } | |||
3714 | } | |||
3715 | ||||
3716 | aMarkData.FillRangeListWithMarks( &aNewRanges, true ); | |||
3717 | } | |||
3718 | while ( bRecursive && bFound ); | |||
3719 | ||||
3720 | return new ScCellRangesObj( pDocShell, aNewRanges ); | |||
3721 | } | |||
3722 | ||||
3723 | return nullptr; | |||
3724 | } | |||
3725 | ||||
3726 | uno::Reference<sheet::XSheetCellRanges> SAL_CALL ScCellRangesBase::queryDependents( | |||
3727 | sal_Bool bRecursive ) | |||
3728 | { | |||
3729 | SolarMutexGuard aGuard; | |||
3730 | if ( pDocShell ) | |||
3731 | { | |||
3732 | ScDocument& rDoc = pDocShell->GetDocument(); | |||
3733 | ||||
3734 | ScRangeList aNewRanges(aRanges); | |||
3735 | bool bFound; | |||
3736 | do | |||
3737 | { | |||
3738 | bFound = false; | |||
3739 | ||||
3740 | // aMarkData uses aNewRanges, not aRanges, so GetMarkData can't be used | |||
3741 | ScMarkData aMarkData(rDoc.GetSheetLimits()); | |||
3742 | aMarkData.MarkFromRangeList( aNewRanges, false ); | |||
3743 | aMarkData.MarkToMulti(); // needed for IsAllMarked | |||
3744 | ||||
3745 | SCTAB nTab = lcl_FirstTab(aNewRanges); //! all tables | |||
3746 | ||||
3747 | ScCellIterator aCellIter( rDoc, ScRange(0, 0, nTab, rDoc.MaxCol(), rDoc.MaxRow(), nTab) ); | |||
3748 | for (bool bHasCell = aCellIter.first(); bHasCell; bHasCell = aCellIter.next()) | |||
3749 | { | |||
3750 | if (aCellIter.getType() != CELLTYPE_FORMULA) | |||
3751 | continue; | |||
3752 | ||||
3753 | bool bMark = false; | |||
3754 | ScDetectiveRefIter aIter(rDoc, aCellIter.getFormulaCell()); | |||
3755 | ScRange aRefRange; | |||
3756 | while ( aIter.GetNextRef( aRefRange) && !bMark ) | |||
3757 | { | |||
3758 | size_t nRangesCount = aNewRanges.size(); | |||
3759 | for (size_t nR = 0; nR < nRangesCount; ++nR) | |||
3760 | { | |||
3761 | ScRange const & rRange = aNewRanges[ nR ]; | |||
3762 | if (rRange.Intersects(aRefRange)) | |||
3763 | { | |||
3764 | bMark = true; // depending on part of Range | |||
3765 | break; | |||
3766 | } | |||
3767 | } | |||
3768 | } | |||
3769 | if (bMark) | |||
3770 | { | |||
3771 | ScRange aCellRange(aCellIter.GetPos()); | |||
3772 | if ( bRecursive && !bFound && !aMarkData.IsAllMarked( aCellRange ) ) | |||
3773 | bFound = true; | |||
3774 | aMarkData.SetMultiMarkArea(aCellRange); | |||
3775 | } | |||
3776 | } | |||
3777 | ||||
3778 | aMarkData.FillRangeListWithMarks( &aNewRanges, true ); | |||
3779 | } | |||
3780 | while ( bRecursive && bFound ); | |||
3781 | ||||
3782 | return new ScCellRangesObj( pDocShell, aNewRanges ); | |||
3783 | } | |||
3784 | ||||
3785 | return nullptr; | |||
3786 | } | |||
3787 | ||||
3788 | // XSearchable | |||
3789 | ||||
3790 | uno::Reference<util::XSearchDescriptor> SAL_CALL ScCellRangesBase::createSearchDescriptor() | |||
3791 | { | |||
3792 | SolarMutexGuard aGuard; | |||
3793 | return new ScCellSearchObj; | |||
3794 | } | |||
3795 | ||||
3796 | uno::Reference<container::XIndexAccess> SAL_CALL ScCellRangesBase::findAll( | |||
3797 | const uno::Reference<util::XSearchDescriptor>& xDesc ) | |||
3798 | { | |||
3799 | SolarMutexGuard aGuard; | |||
3800 | // should we return Null if nothing is found(?) | |||
3801 | uno::Reference<container::XIndexAccess> xRet; | |||
3802 | if ( pDocShell && xDesc.is() ) | |||
3803 | { | |||
3804 | ScCellSearchObj* pSearch = comphelper::getUnoTunnelImplementation<ScCellSearchObj>( xDesc ); | |||
3805 | if (pSearch) | |||
3806 | { | |||
3807 | SvxSearchItem* pSearchItem = pSearch->GetSearchItem(); | |||
3808 | if (pSearchItem) | |||
3809 | { | |||
3810 | ScDocument& rDoc = pDocShell->GetDocument(); | |||
3811 | pSearchItem->SetCommand( SvxSearchCmd::FIND_ALL ); | |||
3812 | // always only within this object | |||
3813 | pSearchItem->SetSelection( !lcl_WholeSheet(rDoc, aRanges) ); | |||
3814 | ||||
3815 | ScMarkData aMark(*GetMarkData()); | |||
3816 | ||||
3817 | OUString aDummyUndo; | |||
3818 | ScRangeList aMatchedRanges; | |||
3819 | SCCOL nCol = 0; | |||
3820 | SCROW nRow = 0; | |||
3821 | SCTAB nTab = 0; | |||
3822 | bool bFound = rDoc.SearchAndReplace( | |||
3823 | *pSearchItem, nCol, nRow, nTab, aMark, aMatchedRanges, aDummyUndo); | |||
3824 | if (bFound) | |||
3825 | { | |||
3826 | // on findAll always CellRanges no matter how much has been found | |||
3827 | xRet.set(new ScCellRangesObj( pDocShell, aMatchedRanges )); | |||
3828 | } | |||
3829 | } | |||
3830 | } | |||
3831 | } | |||
3832 | return xRet; | |||
3833 | } | |||
3834 | ||||
3835 | uno::Reference<uno::XInterface> ScCellRangesBase::Find_Impl( | |||
3836 | const uno::Reference<util::XSearchDescriptor>& xDesc, | |||
3837 | const ScAddress* pLastPos ) | |||
3838 | { | |||
3839 | uno::Reference<uno::XInterface> xRet; | |||
3840 | if ( pDocShell && xDesc.is() ) | |||
3841 | { | |||
3842 | ScCellSearchObj* pSearch = comphelper::getUnoTunnelImplementation<ScCellSearchObj>( xDesc ); | |||
3843 | if (pSearch) | |||
3844 | { | |||
3845 | SvxSearchItem* pSearchItem = pSearch->GetSearchItem(); | |||
3846 | if (pSearchItem) | |||
3847 | { | |||
3848 | ScDocument& rDoc = pDocShell->GetDocument(); | |||
3849 | pSearchItem->SetCommand( SvxSearchCmd::FIND ); | |||
3850 | // only always in this object | |||
3851 | pSearchItem->SetSelection( !lcl_WholeSheet(rDoc, aRanges) ); | |||
3852 | ||||
3853 | ScMarkData aMark(*GetMarkData()); | |||
3854 | ||||
3855 | SCCOL nCol; | |||
3856 | SCROW nRow; | |||
3857 | SCTAB nTab; | |||
3858 | if (pLastPos) | |||
3859 | pLastPos->GetVars( nCol, nRow, nTab ); | |||
3860 | else | |||
3861 | { | |||
3862 | nTab = lcl_FirstTab(aRanges); //! multiple sheets? | |||
3863 | rDoc.GetSearchAndReplaceStart( *pSearchItem, nCol, nRow ); | |||
3864 | } | |||
3865 | ||||
3866 | OUString aDummyUndo; | |||
3867 | ScRangeList aMatchedRanges; | |||
3868 | bool bFound = rDoc.SearchAndReplace( | |||
3869 | *pSearchItem, nCol, nRow, nTab, aMark, aMatchedRanges, aDummyUndo); | |||
3870 | if (bFound) | |||
3871 | { | |||
3872 | ScAddress aFoundPos( nCol, nRow, nTab ); | |||
3873 | xRet.set(static_cast<cppu::OWeakObject*>(new ScCellObj( pDocShell, aFoundPos ))); | |||
3874 | } | |||
3875 | } | |||
3876 | } | |||
3877 | } | |||
3878 | return xRet; | |||
3879 | } | |||
3880 | ||||
3881 | uno::Reference<uno::XInterface> SAL_CALL ScCellRangesBase::findFirst( | |||
3882 | const uno::Reference<util::XSearchDescriptor>& xDesc ) | |||
3883 | { | |||
3884 | SolarMutexGuard aGuard; | |||
3885 | return Find_Impl( xDesc, nullptr ); | |||
3886 | } | |||
3887 | ||||
3888 | uno::Reference<uno::XInterface> SAL_CALL ScCellRangesBase::findNext( | |||
3889 | const uno::Reference<uno::XInterface>& xStartAt, | |||
3890 | const uno::Reference<util::XSearchDescriptor >& xDesc ) | |||
3891 | { | |||
3892 | SolarMutexGuard aGuard; | |||
3893 | if ( xStartAt.is() ) | |||
3894 | { | |||
3895 | ScCellRangesBase* pRangesImp = comphelper::getUnoTunnelImplementation<ScCellRangesBase>( xStartAt ); | |||
3896 | if ( pRangesImp && pRangesImp->GetDocShell() == pDocShell ) | |||
3897 | { | |||
3898 | const ScRangeList& rStartRanges = pRangesImp->GetRangeList(); | |||
3899 | if ( rStartRanges.size() == 1 ) | |||
3900 | { | |||
3901 | ScAddress aStartPos = rStartRanges[ 0 ].aStart; | |||
3902 | return Find_Impl( xDesc, &aStartPos ); | |||
3903 | } | |||
3904 | } | |||
3905 | } | |||
3906 | return nullptr; | |||
3907 | } | |||
3908 | ||||
3909 | // XReplaceable | |||
3910 | ||||
3911 | uno::Reference<util::XReplaceDescriptor> SAL_CALL ScCellRangesBase::createReplaceDescriptor() | |||
3912 | { | |||
3913 | SolarMutexGuard aGuard; | |||
3914 | return new ScCellSearchObj; | |||
3915 | } | |||
3916 | ||||
3917 | sal_Int32 SAL_CALL ScCellRangesBase::replaceAll( const uno::Reference<util::XSearchDescriptor>& xDesc ) | |||
3918 | { | |||
3919 | SolarMutexGuard aGuard; | |||
3920 | sal_Int32 nReplaced = 0; | |||
3921 | if ( pDocShell && xDesc.is() ) | |||
3922 | { | |||
3923 | ScCellSearchObj* pSearch = comphelper::getUnoTunnelImplementation<ScCellSearchObj>( xDesc ); | |||
3924 | if (pSearch) | |||
3925 | { | |||
3926 | SvxSearchItem* pSearchItem = pSearch->GetSearchItem(); | |||
3927 | if (pSearchItem) | |||
3928 | { | |||
3929 | ScDocument& rDoc = pDocShell->GetDocument(); | |||
3930 | bool bUndo(rDoc.IsUndoEnabled()); | |||
3931 | pSearchItem->SetCommand( SvxSearchCmd::REPLACE_ALL ); | |||
3932 | // only always in this object | |||
3933 | pSearchItem->SetSelection( !lcl_WholeSheet(rDoc, aRanges) ); | |||
3934 | ||||
3935 | ScMarkData aMark(*GetMarkData()); | |||
3936 | ||||
3937 | SCTAB nTabCount = rDoc.GetTableCount(); | |||
3938 | bool bProtected = !pDocShell->IsEditable(); | |||
3939 | for (const auto& rTab : aMark) | |||
3940 | { | |||
3941 | if (rTab >= nTabCount) | |||
3942 | break; | |||
3943 | if ( rDoc.IsTabProtected(rTab) ) | |||
3944 | bProtected = true; | |||
3945 | } | |||
3946 | if (bProtected) | |||
3947 | { | |||
3948 | //! Exception, or what? | |||
3949 | } | |||
3950 | else | |||
3951 | { | |||
3952 | SCTAB nTab = aMark.GetFirstSelected(); // do not use if SearchAndReplace | |||
3953 | SCCOL nCol = 0; | |||
3954 | SCROW nRow = 0; | |||
3955 | ||||
3956 | OUString aUndoStr; | |||
3957 | ScDocumentUniquePtr pUndoDoc; | |||
3958 | if (bUndo) | |||
3959 | { | |||
3960 | pUndoDoc.reset(new ScDocument( SCDOCMODE_UNDO )); | |||
3961 | pUndoDoc->InitUndo( rDoc, nTab, nTab ); | |||
3962 | } | |||
3963 | for (const auto& rTab : aMark) | |||
3964 | { | |||
3965 | if (rTab >= nTabCount) | |||
3966 | break; | |||
3967 | if (rTab != nTab && bUndo) | |||
3968 | pUndoDoc->AddUndoTab( rTab, rTab ); | |||
3969 | } | |||
3970 | std::unique_ptr<ScMarkData> pUndoMark; | |||
3971 | if (bUndo) | |||
3972 | pUndoMark.reset(new ScMarkData(aMark)); | |||
3973 | ||||
3974 | bool bFound = false; | |||
3975 | if (bUndo) | |||
3976 | { | |||
3977 | ScRangeList aMatchedRanges; | |||
3978 | bFound = rDoc.SearchAndReplace( | |||
3979 | *pSearchItem, nCol, nRow, nTab, aMark, aMatchedRanges, aUndoStr, pUndoDoc.get() ); | |||
3980 | } | |||
3981 | if (bFound) | |||
3982 | { | |||
3983 | nReplaced = pUndoDoc->GetCellCount(); | |||
3984 | ||||
3985 | pDocShell->GetUndoManager()->AddUndoAction( | |||
3986 | std::make_unique<ScUndoReplace>( pDocShell, *pUndoMark, nCol, nRow, nTab, | |||
3987 | aUndoStr, std::move(pUndoDoc), pSearchItem ) ); | |||
3988 | ||||
3989 | pDocShell->PostPaintGridAll(); | |||
3990 | pDocShell->SetDocumentModified(); | |||
3991 | } | |||
3992 | } | |||
3993 | } | |||
3994 | } | |||
3995 | } | |||
3996 | return nReplaced; | |||
3997 | } | |||
3998 | ||||
3999 | // XUnoTunnel | |||
4000 | ||||
4001 | UNO3_GETIMPLEMENTATION_IMPL(ScCellRangesBase)namespace { class theScCellRangesBaseUnoTunnelId : public rtl ::Static< UnoTunnelIdInit, theScCellRangesBaseUnoTunnelId> {}; } const css::uno::Sequence< sal_Int8 > & ScCellRangesBase ::getUnoTunnelId() throw() { return theScCellRangesBaseUnoTunnelId ::get().getSeq(); }sal_Int64 ScCellRangesBase::getSomething( const css::uno::Sequence< sal_Int8 >& rId ) { if( isUnoTunnelId <ScCellRangesBase>(rId) ) { return sal::static_int_cast <sal_Int64>(reinterpret_cast<sal_IntPtr>(this)); } return 0; }; | |||
4002 | ||||
4003 | typedef std::vector<ScNamedEntry> ScNamedEntryArr_Impl; | |||
4004 | ||||
4005 | struct ScCellRangesObj::Impl | |||
4006 | { | |||
4007 | ScNamedEntryArr_Impl m_aNamedEntries; | |||
4008 | }; | |||
4009 | ||||
4010 | ScCellRangesObj::ScCellRangesObj(ScDocShell* pDocSh, const ScRangeList& rR) | |||
4011 | : ScCellRangesBase(pDocSh, rR) | |||
4012 | , m_pImpl(new Impl) | |||
4013 | { | |||
4014 | } | |||
4015 | ||||
4016 | ScCellRangesObj::~ScCellRangesObj() | |||
4017 | { | |||
4018 | } | |||
4019 | ||||
4020 | void ScCellRangesObj::RefChanged() | |||
4021 | { | |||
4022 | ScCellRangesBase::RefChanged(); | |||
4023 | } | |||
4024 | ||||
4025 | uno::Any SAL_CALL ScCellRangesObj::queryInterface( const uno::Type& rType ) | |||
4026 | { | |||
4027 | SC_QUERYINTERFACE( sheet::XSheetCellRangeContainer )if (rType == cppu::UnoType<sheet::XSheetCellRangeContainer >::get()) { return uno::makeAny(uno::Reference<sheet::XSheetCellRangeContainer >(this)); } | |||
4028 | SC_QUERYINTERFACE( sheet::XSheetCellRanges )if (rType == cppu::UnoType<sheet::XSheetCellRanges>::get ()) { return uno::makeAny(uno::Reference<sheet::XSheetCellRanges >(this)); } | |||
4029 | SC_QUERYINTERFACE( container::XIndexAccess )if (rType == cppu::UnoType<container::XIndexAccess>::get ()) { return uno::makeAny(uno::Reference<container::XIndexAccess >(this)); } | |||
4030 | SC_QUERY_MULTIPLE( container::XElementAccess, container::XIndexAccess )if (rType == cppu::UnoType<container::XElementAccess>:: get()) { uno::Any aR; aR <<= uno::Reference<container ::XElementAccess>(static_cast<container::XIndexAccess*> (this)); return aR; } | |||
4031 | SC_QUERYINTERFACE( container::XEnumerationAccess )if (rType == cppu::UnoType<container::XEnumerationAccess> ::get()) { return uno::makeAny(uno::Reference<container::XEnumerationAccess >(this)); } | |||
4032 | SC_QUERYINTERFACE( container::XNameContainer )if (rType == cppu::UnoType<container::XNameContainer>:: get()) { return uno::makeAny(uno::Reference<container::XNameContainer >(this)); } | |||
4033 | SC_QUERYINTERFACE( container::XNameReplace )if (rType == cppu::UnoType<container::XNameReplace>::get ()) { return uno::makeAny(uno::Reference<container::XNameReplace >(this)); } | |||
4034 | SC_QUERYINTERFACE( container::XNameAccess )if (rType == cppu::UnoType<container::XNameAccess>::get ()) { return uno::makeAny(uno::Reference<container::XNameAccess >(this)); } | |||
4035 | ||||
4036 | return ScCellRangesBase::queryInterface( rType ); | |||
4037 | } | |||
4038 | ||||
4039 | void SAL_CALL ScCellRangesObj::acquire() throw() | |||
4040 | { | |||
4041 | ScCellRangesBase::acquire(); | |||
4042 | } | |||
4043 | ||||
4044 | void SAL_CALL ScCellRangesObj::release() throw() | |||
4045 | { | |||
4046 | ScCellRangesBase::release(); | |||
4047 | } | |||
4048 | ||||
4049 | uno::Sequence<uno::Type> SAL_CALL ScCellRangesObj::getTypes() | |||
4050 | { | |||
4051 | static const uno::Sequence<uno::Type> aTypes = comphelper::concatSequences( | |||
4052 | ScCellRangesBase::getTypes(), | |||
4053 | uno::Sequence<uno::Type> | |||
4054 | { | |||
4055 | cppu::UnoType<sheet::XSheetCellRangeContainer>::get(), | |||
4056 | cppu::UnoType<container::XNameContainer>::get(), | |||
4057 | cppu::UnoType<container::XEnumerationAccess>::get() | |||
4058 | } ); | |||
4059 | return aTypes; | |||
4060 | } | |||
4061 | ||||
4062 | uno::Sequence<sal_Int8> SAL_CALL ScCellRangesObj::getImplementationId() | |||
4063 | { | |||
4064 | return css::uno::Sequence<sal_Int8>(); | |||
4065 | } | |||
4066 | ||||
4067 | // XCellRanges | |||
4068 | ||||
4069 | ScCellRangeObj* ScCellRangesObj::GetObjectByIndex_Impl(sal_Int32 nIndex) const | |||
4070 | { | |||
4071 | ScDocShell* pDocSh = GetDocShell(); | |||
4072 | const ScRangeList& rRanges = GetRangeList(); | |||
4073 | if ( pDocSh && nIndex >= 0 && nIndex < sal::static_int_cast<sal_Int32>(rRanges.size()) ) | |||
4074 | { | |||
4075 | ScRange const & rRange = rRanges[ nIndex ]; | |||
4076 | if ( rRange.aStart == rRange.aEnd ) | |||
4077 | return new ScCellObj( pDocSh, rRange.aStart ); | |||
4078 | else | |||
4079 | return new ScCellRangeObj( pDocSh, rRange ); | |||
4080 | } | |||
4081 | ||||
4082 | return nullptr; // no DocShell or wrong index | |||
4083 | } | |||
4084 | ||||
4085 | uno::Sequence<table::CellRangeAddress> SAL_CALL ScCellRangesObj::getRangeAddresses() | |||
4086 | { | |||
4087 | SolarMutexGuard aGuard; | |||
4088 | ScDocShell* pDocSh = GetDocShell(); | |||
4089 | const ScRangeList& rRanges = GetRangeList(); | |||
4090 | size_t nCount = rRanges.size(); | |||
4091 | if ( pDocSh && nCount ) | |||
4092 | { | |||
4093 | table::CellRangeAddress aRangeAddress; | |||
4094 | uno::Sequence<table::CellRangeAddress> aSeq(nCount); | |||
4095 | table::CellRangeAddress* pAry = aSeq.getArray(); | |||
4096 | for ( size_t i=0; i < nCount; i++) | |||
4097 | { | |||
4098 | ScUnoConversion::FillApiRange( aRangeAddress, rRanges[ i ] ); | |||
4099 | pAry[i] = aRangeAddress; | |||
4100 | } | |||
4101 | return aSeq; | |||
4102 | } | |||
4103 | ||||
4104 | return uno::Sequence<table::CellRangeAddress>(0); // can be empty | |||
4105 | } | |||
4106 | ||||
4107 | uno::Reference<container::XEnumerationAccess> SAL_CALL ScCellRangesObj::getCells() | |||
4108 | { | |||
4109 | SolarMutexGuard aGuard; | |||
4110 | ||||
4111 | // getCells with empty range list is possible (no exception), | |||
4112 | // the resulting enumeration just has no elements | |||
4113 | // (same behaviour as a valid range with no cells) | |||
4114 | // This is handled in ScCellsEnumeration ctor. | |||
4115 | ||||
4116 | const ScRangeList& rRanges = GetRangeList(); | |||
4117 | ScDocShell* pDocSh = GetDocShell(); | |||
4118 | if (pDocSh) | |||
4119 | return new ScCellsObj( pDocSh, rRanges ); | |||
4120 | return nullptr; | |||
4121 | } | |||
4122 | ||||
4123 | OUString SAL_CALL ScCellRangesObj::getRangeAddressesAsString() | |||
4124 | { | |||
4125 | SolarMutexGuard aGuard; | |||
4126 | OUString aString; | |||
4127 | ScDocShell* pDocSh = GetDocShell(); | |||
4128 | const ScRangeList& rRanges = GetRangeList(); | |||
4129 | if (pDocSh) | |||
4130 | rRanges.Format( aString, ScRefFlags::VALID | ScRefFlags::TAB_3D, pDocSh->GetDocument() ); | |||
4131 | return aString; | |||
4132 | } | |||
4133 | ||||
4134 | // XSheetCellRangeContainer | |||
4135 | ||||
4136 | void SAL_CALL ScCellRangesObj::addRangeAddress( const table::CellRangeAddress& rRange, | |||
4137 | sal_Bool bMergeRanges ) | |||
4138 | { | |||
4139 | SolarMutexGuard aGuard; | |||
4140 | ScRange aRange(static_cast<SCCOL>(rRange.StartColumn), | |||
4141 | static_cast<SCROW>(rRange.StartRow), | |||
4142 | static_cast<SCTAB>(rRange.Sheet), | |||
4143 | static_cast<SCCOL>(rRange.EndColumn), | |||
4144 | static_cast<SCROW>(rRange.EndRow), | |||
4145 | static_cast<SCTAB>(rRange.Sheet)); | |||
4146 | AddRange(aRange, bMergeRanges); | |||
4147 | } | |||
4148 | ||||
4149 | static void lcl_RemoveNamedEntry( ScNamedEntryArr_Impl& rNamedEntries, const ScRange& rRange ) | |||
4150 | { | |||
4151 | sal_uInt16 nCount = rNamedEntries.size(); | |||
4152 | for ( sal_uInt16 n=nCount; n--; ) | |||
4153 | if ( rNamedEntries[n].GetRange() == rRange ) | |||
4154 | rNamedEntries.erase( rNamedEntries.begin() + n ); | |||
4155 | } | |||
4156 | ||||
4157 | void SAL_CALL ScCellRangesObj::removeRangeAddress( const table::CellRangeAddress& rRange ) | |||
4158 | { | |||
4159 | SolarMutexGuard aGuard; | |||
4160 | const ScRangeList& rRanges = GetRangeList(); | |||
4161 | ||||
4162 | ScRangeList aSheetRanges; | |||
4163 | ScRangeList aNotSheetRanges; | |||
4164 | for (size_t i = 0; i < rRanges.size(); ++i) | |||
4165 | { | |||
4166 | if (rRanges[ i].aStart.Tab() == rRange.Sheet) | |||
4167 | { | |||
4168 | aSheetRanges.push_back( rRanges[ i ] ); | |||
4169 | } | |||
4170 | else | |||
4171 | { | |||
4172 | aNotSheetRanges.push_back( rRanges[ i ] ); | |||
4173 | } | |||
4174 | } | |||
4175 | ScMarkData aMarkData(GetDocument()->GetSheetLimits()); | |||
4176 | aMarkData.MarkFromRangeList( aSheetRanges, false ); | |||
4177 | ScRange aRange(static_cast<SCCOL>(rRange.StartColumn), | |||
4178 | static_cast<SCROW>(rRange.StartRow), | |||
4179 | static_cast<SCTAB>(rRange.Sheet), | |||
4180 | static_cast<SCCOL>(rRange.EndColumn), | |||
4181 | static_cast<SCROW>(rRange.EndRow), | |||
4182 | static_cast<SCTAB>(rRange.Sheet)); | |||
4183 | if (aMarkData.GetTableSelect( aRange.aStart.Tab() )) | |||
4184 | { | |||
4185 | aMarkData.MarkToMulti(); | |||
4186 | if (!aMarkData.IsAllMarked( aRange ) ) | |||
4187 | throw container::NoSuchElementException(); | |||
4188 | ||||
4189 | aMarkData.SetMultiMarkArea( aRange, false ); | |||
4190 | lcl_RemoveNamedEntry(m_pImpl->m_aNamedEntries, aRange); | |||
4191 | ||||
4192 | } | |||
4193 | SetNewRanges(aNotSheetRanges); | |||
4194 | ScRangeList aNew; | |||
4195 | aMarkData.FillRangeListWithMarks( &aNew, false ); | |||
4196 | for ( size_t j = 0; j < aNew.size(); ++j) | |||
4197 | { | |||
4198 | AddRange(aNew[ j ], false); | |||
4199 | } | |||
4200 | } | |||
4201 | ||||
4202 | void SAL_CALL ScCellRangesObj::addRangeAddresses( const uno::Sequence<table::CellRangeAddress >& rRanges, | |||
4203 | sal_Bool bMergeRanges ) | |||
4204 | { | |||
4205 | SolarMutexGuard aGuard; | |||
4206 | for (const table::CellRangeAddress& rRange : rRanges) | |||
4207 | { | |||
4208 | ScRange aRange(static_cast<SCCOL>(rRange.StartColumn), | |||
4209 | static_cast<SCROW>(rRange.StartRow), | |||
4210 | static_cast<SCTAB>(rRange.Sheet), | |||
4211 | static_cast<SCCOL>(rRange.EndColumn), | |||
4212 | static_cast<SCROW>(rRange.EndRow), | |||
4213 | static_cast<SCTAB>(rRange.Sheet)); | |||
4214 | AddRange(aRange, bMergeRanges); | |||
4215 | } | |||
4216 | } | |||
4217 | ||||
4218 | void SAL_CALL ScCellRangesObj::removeRangeAddresses( const uno::Sequence<table::CellRangeAddress >& rRangeSeq ) | |||
4219 | { | |||
4220 | // use sometimes a better/faster implementation | |||
4221 | for (const table::CellRangeAddress& rRange : rRangeSeq) | |||
4222 | { | |||
4223 | removeRangeAddress(rRange); | |||
4224 | } | |||
4225 | } | |||
4226 | ||||
4227 | // XNameContainer | |||
4228 | ||||
4229 | static void lcl_RemoveNamedEntry( ScNamedEntryArr_Impl& rNamedEntries, const OUString& rName ) | |||
4230 | { | |||
4231 | sal_uInt16 nCount = rNamedEntries.size(); | |||
4232 | for ( sal_uInt16 n=nCount; n--; ) | |||
4233 | if ( rNamedEntries[n].GetName() == rName ) | |||
4234 | rNamedEntries.erase( rNamedEntries.begin() + n ); | |||
4235 | } | |||
4236 | ||||
4237 | void SAL_CALL ScCellRangesObj::insertByName( const OUString& aName, const uno::Any& aElement ) | |||
4238 | { | |||
4239 | SolarMutexGuard aGuard; | |||
4240 | ScDocShell* pDocSh = GetDocShell(); | |||
4241 | bool bDone = false; | |||
4242 | ||||
4243 | //! Type of aElement can be some specific interface instead of XInterface | |||
4244 | ||||
4245 | uno::Reference<uno::XInterface> xInterface(aElement, uno::UNO_QUERY); | |||
4246 | if ( pDocSh && xInterface.is() ) | |||
4247 | { | |||
4248 | ScCellRangesBase* pRangesImp = comphelper::getUnoTunnelImplementation<ScCellRangesBase>( xInterface ); | |||
4249 | if ( pRangesImp && pRangesImp->GetDocShell() == pDocSh ) | |||
4250 | { | |||
4251 | // if explicit name is given and already existing, throw exception | |||
4252 | ||||
4253 | if ( !aName.isEmpty() ) | |||
4254 | { | |||
4255 | size_t nNamedCount = m_pImpl->m_aNamedEntries.size(); | |||
4256 | for (size_t n = 0; n < nNamedCount; n++) | |||
4257 | { | |||
4258 | if (m_pImpl->m_aNamedEntries[n].GetName() == aName) | |||
4259 | throw container::ElementExistException(); | |||
4260 | } | |||
4261 | } | |||
4262 | ||||
4263 | ScRangeList aNew(GetRangeList()); | |||
4264 | const ScRangeList& rAddRanges = pRangesImp->GetRangeList(); | |||
4265 | size_t nAddCount = rAddRanges.size(); | |||
4266 | for ( size_t i = 0; i < nAddCount; i++ ) | |||
4267 | aNew.Join( rAddRanges[ i ] ); | |||
4268 | SetNewRanges(aNew); | |||
4269 | bDone = true; | |||
4270 | ||||
4271 | if ( !aName.isEmpty() && nAddCount == 1 ) | |||
4272 | { | |||
4273 | // if a name is given, also insert into list of named entries | |||
4274 | // (only possible for a single range) | |||
4275 | // name is not in m_pImpl->m_aNamedEntries (tested above) | |||
4276 | m_pImpl->m_aNamedEntries.emplace_back( aName, rAddRanges[ 0 ] ); | |||
4277 | } | |||
4278 | } | |||
4279 | } | |||
4280 | ||||
4281 | if (!bDone) | |||
4282 | { | |||
4283 | // invalid element - double names are handled above | |||
4284 | throw lang::IllegalArgumentException(); | |||
4285 | } | |||
4286 | } | |||
4287 | ||||
4288 | static bool lcl_FindRangeByName( const ScRangeList& rRanges, ScDocShell* pDocSh, | |||
4289 | const OUString& rName, size_t& rIndex ) | |||
4290 | { | |||
4291 | if (pDocSh) | |||
4292 | { | |||
4293 | OUString aRangeStr; | |||
4294 | ScDocument& rDoc = pDocSh->GetDocument(); | |||
4295 | for ( size_t i = 0, nCount = rRanges.size(); i < nCount; i++ ) | |||
4296 | { | |||
4297 | aRangeStr = rRanges[ i ].Format(rDoc, ScRefFlags::VALID | ScRefFlags::TAB_3D); | |||
4298 | if ( aRangeStr == rName ) | |||
4299 | { | |||
4300 | rIndex = i; | |||
4301 | return true; | |||
4302 | } | |||
4303 | } | |||
4304 | } | |||
4305 | return false; | |||
4306 | } | |||
4307 | ||||
4308 | static bool lcl_FindRangeOrEntry( const ScNamedEntryArr_Impl& rNamedEntries, | |||
4309 | const ScRangeList& rRanges, ScDocShell* pDocSh, | |||
4310 | const OUString& rName, ScRange& rFound ) | |||
4311 | { | |||
4312 | // exact range in list? | |||
4313 | ||||
4314 | size_t nIndex = 0; | |||
4315 | if ( lcl_FindRangeByName( rRanges, pDocSh, rName, nIndex ) ) | |||
4316 | { | |||
4317 | rFound = rRanges[ nIndex ]; | |||
4318 | return true; | |||
4319 | } | |||
4320 | ||||
4321 | // range contained in selection? (sheet must be specified) | |||
4322 | ||||
4323 | ScRange aCellRange; | |||
4324 | ScRefFlags nParse = aCellRange.ParseAny( rName, pDocSh->GetDocument() ); | |||
4325 | if ( (nParse & ( ScRefFlags::VALID | ScRefFlags::TAB_3D )) | |||
4326 | == ( ScRefFlags::VALID | ScRefFlags::TAB_3D )) | |||
4327 | { | |||
4328 | ScMarkData aMarkData(pDocSh->GetDocument().GetSheetLimits()); | |||
4329 | aMarkData.MarkFromRangeList( rRanges, false ); | |||
4330 | aMarkData.MarkToMulti(); // needed for IsAllMarked | |||
4331 | if ( aMarkData.IsAllMarked( aCellRange ) ) | |||
4332 | { | |||
4333 | rFound = aCellRange; | |||
4334 | return true; | |||
4335 | } | |||
4336 | } | |||
4337 | ||||
4338 | // named entry in this object? | |||
4339 | ||||
4340 | for (const auto & rNamedEntry : rNamedEntries) | |||
4341 | if ( rNamedEntry.GetName() == rName ) | |||
4342 | { | |||
4343 | // test if named entry is contained in rRanges | |||
4344 | ||||
4345 | const ScRange& rComp = rNamedEntry.GetRange(); | |||
4346 | ScMarkData aMarkData(pDocSh->GetDocument().GetSheetLimits()); | |||
4347 | aMarkData.MarkFromRangeList( rRanges, false ); | |||
4348 | aMarkData.MarkToMulti(); // needed for IsAllMarked | |||
4349 | if ( aMarkData.IsAllMarked( rComp ) ) | |||
4350 | { | |||
4351 | rFound = rComp; | |||
4352 | return true; | |||
4353 | } | |||
4354 | } | |||
4355 | ||||
4356 | return false; // not found | |||
4357 | } | |||
4358 | ||||
4359 | void SAL_CALL ScCellRangesObj::removeByName( const OUString& aName ) | |||
4360 | { | |||
4361 | SolarMutexGuard aGuard; | |||
4362 | bool bDone = false; | |||
4363 | ScDocShell* pDocSh = GetDocShell(); | |||
4364 | const ScRangeList& rRanges = GetRangeList(); | |||
4365 | size_t nIndex = 0; | |||
4366 | if ( lcl_FindRangeByName( rRanges, pDocSh, aName, nIndex ) ) | |||
4367 | { | |||
4368 | // skip a single range | |||
4369 | ScRangeList aNew; | |||
4370 | for ( size_t i = 0, nCount = rRanges.size(); i < nCount; i++ ) | |||
4371 | if (i != nIndex) | |||
4372 | aNew.push_back( rRanges[ i ] ); | |||
4373 | SetNewRanges(aNew); | |||
4374 | bDone = true; | |||
4375 | } | |||
4376 | else if (pDocSh) | |||
4377 | { | |||
4378 | // deselect any ranges (parsed or named entry) | |||
4379 | ScRangeList aDiff; | |||
4380 | bool bValid = ( aDiff.Parse( aName, pDocSh->GetDocument() ) & ScRefFlags::VALID ) | |||
4381 | == ScRefFlags::VALID; | |||
4382 | if (!bValid) | |||
4383 | { | |||
4384 | sal_uInt16 nCount = m_pImpl->m_aNamedEntries.size(); | |||
4385 | for (sal_uInt16 n=0; n<nCount && !bValid; n++) | |||
4386 | if (m_pImpl->m_aNamedEntries[n].GetName() == aName) | |||
4387 | { | |||
4388 | aDiff.RemoveAll(); | |||
4389 | aDiff.push_back(m_pImpl->m_aNamedEntries[n].GetRange()); | |||
4390 | bValid = true; | |||
4391 | } | |||
4392 | } | |||
4393 | if ( bValid ) | |||
4394 | { | |||
4395 | ScMarkData aMarkData(GetDocument()->GetSheetLimits()); | |||
4396 | aMarkData.MarkFromRangeList( rRanges, false ); | |||
4397 | ||||
4398 | for ( size_t i = 0, nDiffCount = aDiff.size(); i < nDiffCount; i++ ) | |||
4399 | { | |||
4400 | ScRange const & rDiffRange = aDiff[ i ]; | |||
4401 | if (aMarkData.GetTableSelect( rDiffRange.aStart.Tab() )) | |||
4402 | aMarkData.SetMultiMarkArea( rDiffRange, false ); | |||
4403 | } | |||
4404 | ||||
4405 | ScRangeList aNew; | |||
4406 | aMarkData.FillRangeListWithMarks( &aNew, false ); | |||
4407 | SetNewRanges(aNew); | |||
4408 | ||||
4409 | bDone = true; //! error if range was not selected before? | |||
4410 | } | |||
4411 | } | |||
4412 | ||||
4413 | if (!m_pImpl->m_aNamedEntries.empty()) | |||
4414 | lcl_RemoveNamedEntry(m_pImpl->m_aNamedEntries, aName); | |||
4415 | ||||
4416 | if (!bDone) | |||
4417 | throw container::NoSuchElementException(); // not found | |||
4418 | } | |||
4419 | ||||
4420 | // XNameReplace | |||
4421 | ||||
4422 | void SAL_CALL ScCellRangesObj::replaceByName( const OUString& aName, const uno::Any& aElement ) | |||
4423 | { | |||
4424 | SolarMutexGuard aGuard; | |||
4425 | //! combine? | |||
4426 | removeByName( aName ); | |||
4427 | insertByName( aName, aElement ); | |||
4428 | } | |||
4429 | ||||
4430 | // XNameAccess | |||
4431 | ||||
4432 | uno::Any SAL_CALL ScCellRangesObj::getByName( const OUString& aName ) | |||
4433 | { | |||
4434 | SolarMutexGuard aGuard; | |||
4435 | uno::Any aRet; | |||
4436 | ||||
4437 | ScDocShell* pDocSh = GetDocShell(); | |||
4438 | const ScRangeList& rRanges = GetRangeList(); | |||
4439 | ScRange aRange; | |||
4440 | if (!lcl_FindRangeOrEntry(m_pImpl->m_aNamedEntries, rRanges, | |||
4441 | pDocSh, aName, aRange)) | |||
4442 | throw container::NoSuchElementException(); | |||
4443 | ||||
4444 | uno::Reference<table::XCellRange> xRange; | |||
4445 | if ( aRange.aStart == aRange.aEnd ) | |||
4446 | xRange.set(new ScCellObj( pDocSh, aRange.aStart )); | |||
4447 | else | |||
4448 | xRange.set(new ScCellRangeObj( pDocSh, aRange )); | |||
4449 | aRet <<= xRange; | |||
4450 | ||||
4451 | return aRet; | |||
4452 | } | |||
4453 | ||||
4454 | static bool lcl_FindEntryName( const ScNamedEntryArr_Impl& rNamedEntries, | |||
4455 | const ScRange& rRange, OUString& rName ) | |||
4456 | { | |||
4457 | sal_uInt16 nCount = rNamedEntries.size(); | |||
4458 | for (sal_uInt16 i=0; i<nCount; i++) | |||
4459 | if (rNamedEntries[i].GetRange() == rRange) | |||
4460 | { | |||
4461 | rName = rNamedEntries[i].GetName(); | |||
4462 | return true; | |||
4463 | } | |||
4464 | return false; | |||
4465 | } | |||
4466 | ||||
4467 | uno::Sequence<OUString> SAL_CALL ScCellRangesObj::getElementNames() | |||
4468 | { | |||
4469 | SolarMutexGuard aGuard; | |||
4470 | ||||
4471 | ScDocShell* pDocSh = GetDocShell(); | |||
4472 | const ScRangeList& rRanges = GetRangeList(); | |||
4473 | if (pDocSh) | |||
4474 | { | |||
4475 | OUString aRangeStr; | |||
4476 | ScDocument& rDoc = pDocSh->GetDocument(); | |||
4477 | size_t nCount = rRanges.size(); | |||
4478 | ||||
4479 | uno::Sequence<OUString> aSeq(nCount); | |||
4480 | OUString* pAry = aSeq.getArray(); | |||
4481 | for (size_t i=0; i < nCount; i++) | |||
4482 | { | |||
4483 | // use given name if for exactly this range, otherwise just format | |||
4484 | ScRange const & rRange = rRanges[ i ]; | |||
4485 | if (m_pImpl->m_aNamedEntries.empty() || | |||
4486 | !lcl_FindEntryName(m_pImpl->m_aNamedEntries, rRange, aRangeStr)) | |||
4487 | { | |||
4488 | aRangeStr = rRange.Format(rDoc, ScRefFlags::VALID | ScRefFlags::TAB_3D); | |||
4489 | } | |||
4490 | pAry[i] = aRangeStr; | |||
4491 | } | |||
4492 | return aSeq; | |||
4493 | } | |||
4494 | return uno::Sequence<OUString>(0); | |||
4495 | } | |||
4496 | ||||
4497 | sal_Bool SAL_CALL ScCellRangesObj::hasByName( const OUString& aName ) | |||
4498 | { | |||
4499 | SolarMutexGuard aGuard; | |||
4500 | ScDocShell* pDocSh = GetDocShell(); | |||
4501 | const ScRangeList& rRanges = GetRangeList(); | |||
4502 | ScRange aRange; | |||
4503 | return lcl_FindRangeOrEntry(m_pImpl->m_aNamedEntries, rRanges, pDocSh, | |||
4504 | aName, aRange); | |||
4505 | } | |||
4506 | ||||
4507 | // XEnumerationAccess | |||
4508 | ||||
4509 | uno::Reference<container::XEnumeration> SAL_CALL ScCellRangesObj::createEnumeration() | |||
4510 | { | |||
4511 | SolarMutexGuard aGuard; | |||
4512 | return new ScIndexEnumeration(this, "com.sun.star.sheet.SheetCellRangesEnumeration"); | |||
4513 | } | |||
4514 | ||||
4515 | // XIndexAccess | |||
4516 | ||||
4517 | sal_Int32 SAL_CALL ScCellRangesObj::getCount() | |||
4518 | { | |||
4519 | SolarMutexGuard aGuard; | |||
4520 | const ScRangeList& rRanges = GetRangeList(); | |||
4521 | return rRanges.size(); | |||
4522 | } | |||
4523 | ||||
4524 | uno::Any SAL_CALL ScCellRangesObj::getByIndex( sal_Int32 nIndex ) | |||
4525 | { | |||
4526 | SolarMutexGuard aGuard; | |||
4527 | uno::Reference<table::XCellRange> xRange(GetObjectByIndex_Impl(nIndex)); | |||
4528 | if (!xRange.is()) | |||
4529 | throw lang::IndexOutOfBoundsException(); | |||
4530 | ||||
4531 | return uno::makeAny(xRange); | |||
4532 | ||||
4533 | } | |||
4534 | ||||
4535 | uno::Type SAL_CALL ScCellRangesObj::getElementType() | |||
4536 | { | |||
4537 | SolarMutexGuard aGuard; | |||
4538 | return cppu::UnoType<table::XCellRange>::get(); | |||
4539 | } | |||
4540 | ||||
4541 | sal_Bool SAL_CALL ScCellRangesObj::hasElements() | |||
4542 | { | |||
4543 | SolarMutexGuard aGuard; | |||
4544 | const ScRangeList& rRanges = GetRangeList(); | |||
4545 | return !rRanges.empty(); | |||
4546 | } | |||
4547 | ||||
4548 | // XServiceInfo | |||
4549 | OUString SAL_CALL ScCellRangesObj::getImplementationName() | |||
4550 | { | |||
4551 | return "ScCellRangesObj"; | |||
4552 | } | |||
4553 | ||||
4554 | sal_Bool SAL_CALL ScCellRangesObj::supportsService( const OUString& rServiceName ) | |||
4555 | { | |||
4556 | return cppu::supportsService(this, rServiceName); | |||
4557 | } | |||
4558 | ||||
4559 | uno::Sequence<OUString> SAL_CALL ScCellRangesObj::getSupportedServiceNames() | |||
4560 | { | |||
4561 | return {SCSHEETCELLRANGES_SERVICE"com.sun.star.sheet.SheetCellRanges", | |||
4562 | SCCELLPROPERTIES_SERVICE"com.sun.star.table.CellProperties", | |||
4563 | SCCHARPROPERTIES_SERVICE"com.sun.star.style.CharacterProperties", | |||
4564 | SCPARAPROPERTIES_SERVICE"com.sun.star.style.ParagraphProperties"}; | |||
4565 | } | |||
4566 | ||||
4567 | uno::Reference<table::XCellRange> ScCellRangeObj::CreateRangeFromDoc( const ScDocument& rDoc, const ScRange& rR ) | |||
4568 | { | |||
4569 | SfxObjectShell* pObjSh = rDoc.GetDocumentShell(); | |||
4570 | if ( auto pDocShell = dynamic_cast<ScDocShell*>( pObjSh) ) | |||
4571 | return new ScCellRangeObj( pDocShell, rR ); | |||
4572 | return nullptr; | |||
4573 | } | |||
4574 | ||||
4575 | ScCellRangeObj::ScCellRangeObj(ScDocShell* pDocSh, const ScRange& rR) : | |||
4576 | ScCellRangesBase( pDocSh, rR ), | |||
4577 | pRangePropSet( lcl_GetRangePropertySet() ), | |||
4578 | aRange( rR ) | |||
4579 | { | |||
4580 | aRange.PutInOrder(); // beginning / end correct | |||
4581 | } | |||
4582 | ||||
4583 | ScCellRangeObj::~ScCellRangeObj() | |||
4584 | { | |||
4585 | } | |||
4586 | ||||
4587 | void ScCellRangeObj::RefChanged() | |||
4588 | { | |||
4589 | ScCellRangesBase::RefChanged(); | |||
4590 | ||||
4591 | const ScRangeList& rRanges = GetRangeList(); | |||
4592 | OSL_ENSURE(rRanges.size() == 1, "What ranges ?!?!")do { if (true && (!(rRanges.size() == 1))) { sal_detail_logFormat ((SAL_DETAIL_LOG_LEVEL_WARN), ("legacy.osl"), ("/home/maarten/src/libreoffice/core/sc/source/ui/unoobj/cellsuno.cxx" ":" "4592" ": "), "%s", "What ranges ?!?!"); } } while (false ); | |||
4593 | if ( !rRanges.empty() ) | |||
4594 | { | |||
4595 | const ScRange & rFirst = rRanges[0]; | |||
4596 | aRange = rFirst; | |||
4597 | aRange.PutInOrder(); | |||
4598 | } | |||
4599 | } | |||
4600 | ||||
4601 | uno::Any SAL_CALL ScCellRangeObj::queryInterface( const uno::Type& rType ) | |||
4602 | { | |||
4603 | SC_QUERYINTERFACE( sheet::XCellRangeAddressable )if (rType == cppu::UnoType<sheet::XCellRangeAddressable> ::get()) { return uno::makeAny(uno::Reference<sheet::XCellRangeAddressable >(this)); } | |||
4604 | SC_QUERYINTERFACE( table::XCellRange )if (rType == cppu::UnoType<table::XCellRange>::get()) { return uno::makeAny(uno::Reference<table::XCellRange>( this)); } | |||
4605 | SC_QUERYINTERFACE( sheet::XSheetCellRange )if (rType == cppu::UnoType<sheet::XSheetCellRange>::get ()) { return uno::makeAny(uno::Reference<sheet::XSheetCellRange >(this)); } | |||
4606 | SC_QUERYINTERFACE( sheet::XArrayFormulaRange )if (rType == cppu::UnoType<sheet::XArrayFormulaRange>:: get()) { return uno::makeAny(uno::Reference<sheet::XArrayFormulaRange >(this)); } | |||
4607 | SC_QUERYINTERFACE( sheet::XArrayFormulaTokens )if (rType == cppu::UnoType<sheet::XArrayFormulaTokens>:: get()) { return uno::makeAny(uno::Reference<sheet::XArrayFormulaTokens >(this)); } | |||
4608 | SC_QUERYINTERFACE( sheet::XCellRangeData )if (rType == cppu::UnoType<sheet::XCellRangeData>::get( )) { return uno::makeAny(uno::Reference<sheet::XCellRangeData >(this)); } | |||
4609 | SC_QUERYINTERFACE( sheet::XCellRangeFormula )if (rType == cppu::UnoType<sheet::XCellRangeFormula>::get ()) { return uno::makeAny(uno::Reference<sheet::XCellRangeFormula >(this)); } | |||
4610 | SC_QUERYINTERFACE( sheet::XMultipleOperation )if (rType == cppu::UnoType<sheet::XMultipleOperation>:: get()) { return uno::makeAny(uno::Reference<sheet::XMultipleOperation >(this)); } | |||
4611 | SC_QUERYINTERFACE( util::XMergeable )if (rType == cppu::UnoType<util::XMergeable>::get()) { return uno::makeAny(uno::Reference<util::XMergeable>(this)); } | |||
4612 | SC_QUERYINTERFACE( sheet::XCellSeries )if (rType == cppu::UnoType<sheet::XCellSeries>::get()) { return uno::makeAny(uno::Reference<sheet::XCellSeries> (this)); } | |||
4613 | SC_QUERYINTERFACE( table::XAutoFormattable )if (rType == cppu::UnoType<table::XAutoFormattable>::get ()) { return uno::makeAny(uno::Reference<table::XAutoFormattable >(this)); } | |||
4614 | SC_QUERYINTERFACE( util::XSortable )if (rType == cppu::UnoType<util::XSortable>::get()) { return uno::makeAny(uno::Reference<util::XSortable>(this)); } | |||
4615 | SC_QUERYINTERFACE( sheet::XSheetFilterableEx )if (rType == cppu::UnoType<sheet::XSheetFilterableEx>:: get()) { return uno::makeAny(uno::Reference<sheet::XSheetFilterableEx >(this)); } | |||
4616 | SC_QUERYINTERFACE( sheet::XSheetFilterable )if (rType == cppu::UnoType<sheet::XSheetFilterable>::get ()) { return uno::makeAny(uno::Reference<sheet::XSheetFilterable >(this)); } | |||
4617 | SC_QUERYINTERFACE( sheet::XSubTotalCalculatable )if (rType == cppu::UnoType<sheet::XSubTotalCalculatable> ::get()) { return uno::makeAny(uno::Reference<sheet::XSubTotalCalculatable >(this)); } | |||
4618 | SC_QUERYINTERFACE( table::XColumnRowRange )if (rType == cppu::UnoType<table::XColumnRowRange>::get ()) { return uno::makeAny(uno::Reference<table::XColumnRowRange >(this)); } | |||
4619 | SC_QUERYINTERFACE( util::XImportable )if (rType == cppu::UnoType<util::XImportable>::get()) { return uno::makeAny(uno::Reference<util::XImportable>( this)); } | |||
4620 | SC_QUERYINTERFACE( sheet::XCellFormatRangesSupplier )if (rType == cppu::UnoType<sheet::XCellFormatRangesSupplier >::get()) { return uno::makeAny(uno::Reference<sheet::XCellFormatRangesSupplier >(this)); } | |||
4621 | SC_QUERYINTERFACE( sheet::XUniqueCellFormatRangesSupplier )if (rType == cppu::UnoType<sheet::XUniqueCellFormatRangesSupplier >::get()) { return uno::makeAny(uno::Reference<sheet::XUniqueCellFormatRangesSupplier >(this)); } | |||
4622 | ||||
4623 | return ScCellRangesBase::queryInterface( rType ); | |||
4624 | } | |||
4625 | ||||
4626 | void SAL_CALL ScCellRangeObj::acquire() throw() | |||
4627 | { | |||
4628 | ScCellRangesBase::acquire(); | |||
4629 | } | |||
4630 | ||||
4631 | void SAL_CALL ScCellRangeObj::release() throw() | |||
4632 | { | |||
4633 | ScCellRangesBase::release(); | |||
4634 | } | |||
4635 | ||||
4636 | uno::Sequence<uno::Type> SAL_CALL ScCellRangeObj::getTypes() | |||
4637 | { | |||
4638 | static const uno::Sequence<uno::Type> aTypes = comphelper::concatSequences( | |||
4639 | ScCellRangesBase::getTypes(), | |||
4640 | uno::Sequence<uno::Type> | |||
4641 | { | |||
4642 | cppu::UnoType<sheet::XCellRangeAddressable>::get(), | |||
4643 | cppu::UnoType<sheet::XSheetCellRange>::get(), | |||
4644 | cppu::UnoType<sheet::XArrayFormulaRange>::get(), | |||
4645 | cppu::UnoType<sheet::XArrayFormulaTokens>::get(), | |||
4646 | cppu::UnoType<sheet::XCellRangeData>::get(), | |||
4647 | cppu::UnoType<sheet::XCellRangeFormula>::get(), | |||
4648 | cppu::UnoType<sheet::XMultipleOperation>::get(), | |||
4649 | cppu::UnoType<util::XMergeable>::get(), | |||
4650 | cppu::UnoType<sheet::XCellSeries>::get(), | |||
4651 | cppu::UnoType<table::XAutoFormattable>::get(), | |||
4652 | cppu::UnoType<util::XSortable>::get(), | |||
4653 | cppu::UnoType<sheet::XSheetFilterableEx>::get(), | |||
4654 | cppu::UnoType<sheet::XSubTotalCalculatable>::get(), | |||
4655 | cppu::UnoType<table::XColumnRowRange>::get(), | |||
4656 | cppu::UnoType<util::XImportable>::get(), | |||
4657 | cppu::UnoType<sheet::XCellFormatRangesSupplier>::get(), | |||
4658 | cppu::UnoType<sheet::XUniqueCellFormatRangesSupplier>::get() | |||
4659 | } ); | |||
4660 | return aTypes; | |||
4661 | } | |||
4662 | ||||
4663 | uno::Sequence<sal_Int8> SAL_CALL ScCellRangeObj::getImplementationId() | |||
4664 | { | |||
4665 | return css::uno::Sequence<sal_Int8>(); | |||
4666 | } | |||
4667 | ||||
4668 | // XCellRange | |||
4669 | ||||
4670 | // ColumnCount / RowCount vanished | |||
4671 | //! are used in Writer for tables ??? | |||
4672 | ||||
4673 | uno::Reference<table::XCell> ScCellRangeObj::GetCellByPosition_Impl( | |||
4674 | sal_Int32 nColumn, sal_Int32 nRow ) | |||
4675 | { | |||
4676 | ScDocShell* pDocSh = GetDocShell(); | |||
4677 | if (!pDocSh) | |||
4678 | throw uno::RuntimeException(); | |||
4679 | ||||
4680 | if ( nColumn >= 0 && nRow >= 0 ) | |||
4681 | { | |||
4682 | sal_Int32 nPosX = aRange.aStart.Col() + nColumn; | |||
4683 | sal_Int32 nPosY = aRange.aStart.Row() + nRow; | |||
4684 | ||||
4685 | if ( nPosX <= aRange.aEnd.Col() && nPosY <= aRange.aEnd.Row() ) | |||
4686 | { | |||
4687 | ScAddress aNew( static_cast<SCCOL>(nPosX), static_cast<SCROW>(nPosY), aRange.aStart.Tab() ); | |||
4688 | return new ScCellObj( pDocSh, aNew ); | |||
4689 | } | |||
4690 | } | |||
4691 | ||||
4692 | throw lang::IndexOutOfBoundsException(); | |||
4693 | } | |||
4694 | ||||
4695 | uno::Reference<table::XCell> SAL_CALL ScCellRangeObj::getCellByPosition( | |||
4696 | sal_Int32 nColumn, sal_Int32 nRow ) | |||
4697 | { | |||
4698 | SolarMutexGuard aGuard; | |||
4699 | ||||
4700 | return GetCellByPosition_Impl(nColumn, nRow); | |||
4701 | } | |||
4702 | ||||
4703 | uno::Reference<table::XCellRange> SAL_CALL ScCellRangeObj::getCellRangeByPosition( | |||
4704 | sal_Int32 nLeft, sal_Int32 nTop, sal_Int32 nRight, sal_Int32 nBottom ) | |||
4705 | { | |||
4706 | SolarMutexGuard aGuard; | |||
4707 | ||||
4708 | ScDocShell* pDocSh = GetDocShell(); | |||
4709 | if (!pDocSh) | |||
4710 | throw uno::RuntimeException(); | |||
4711 | ||||
4712 | if ( nLeft >= 0 && nTop >= 0 && nRight >= 0 && nBottom >= 0 ) | |||
4713 | { | |||
4714 | sal_Int32 nStartX = aRange.aStart.Col() + nLeft; | |||
4715 | sal_Int32 nStartY = aRange.aStart.Row() + nTop; | |||
4716 | sal_Int32 nEndX = aRange.aStart.Col() + nRight; | |||
4717 | sal_Int32 nEndY = aRange.aStart.Row() + nBottom; | |||
4718 | ||||
4719 | if ( nStartX <= nEndX && nEndX <= aRange.aEnd.Col() && | |||
4720 | nStartY <= nEndY && nEndY <= aRange.aEnd.Row() ) | |||
4721 | { | |||
4722 | ScRange aNew( static_cast<SCCOL>(nStartX), static_cast<SCROW>(nStartY), aRange.aStart.Tab(), | |||
4723 | static_cast<SCCOL>(nEndX), static_cast<SCROW>(nEndY), aRange.aEnd.Tab() ); | |||
4724 | return new ScCellRangeObj( pDocSh, aNew ); | |||
4725 | } | |||
4726 | } | |||
4727 | ||||
4728 | throw lang::IndexOutOfBoundsException(); | |||
4729 | } | |||
4730 | ||||
4731 | uno::Reference<table::XCellRange> SAL_CALL ScCellRangeObj::getCellRangeByName( | |||
4732 | const OUString& aName ) | |||
4733 | { | |||
4734 | return getCellRangeByName( aName, ScAddress::detailsOOOa1 ); | |||
4735 | } | |||
4736 | ||||
4737 | uno::Reference<table::XCellRange> ScCellRangeObj::getCellRangeByName( | |||
4738 | const OUString& aName, const ScAddress::Details& rDetails ) | |||
4739 | { | |||
4740 | // name refers to the whole document (with the range's table as default), | |||
4741 | // valid only if the range is within this range | |||
4742 | ||||
4743 | SolarMutexGuard aGuard; | |||
4744 | ScDocShell* pDocSh = GetDocShell(); | |||
4745 | if ( pDocSh ) | |||
4746 | { | |||
4747 | ScDocument& rDoc = pDocSh->GetDocument(); | |||
4748 | SCTAB nTab = aRange.aStart.Tab(); | |||
4749 | ||||
4750 | ScRange aCellRange; | |||
4751 | bool bFound = false; | |||
4752 | ScRefFlags nParse = aCellRange.ParseAny( aName, rDoc, rDetails ); | |||
4753 | if ( nParse & ScRefFlags::VALID ) | |||
4754 | { | |||
4755 | if ( !(nParse & ScRefFlags::TAB_3D) ) // no sheet specified -> this sheet | |||
4756 | { | |||
4757 | aCellRange.aStart.SetTab(nTab); | |||
4758 | aCellRange.aEnd.SetTab(nTab); | |||
4759 | } | |||
4760 | bFound = true; | |||
4761 | } | |||
4762 | else | |||
4763 | { | |||
4764 | if ( ScRangeUtil::MakeRangeFromName( aName, rDoc, nTab, aCellRange ) || | |||
4765 | ScRangeUtil::MakeRangeFromName( aName, rDoc, nTab, aCellRange, RUTL_DBASE ) ) | |||
4766 | bFound = true; | |||
4767 | } | |||
4768 | ||||
4769 | if (bFound) // valid only if within this object's range | |||
4770 | { | |||
4771 | if (!aRange.In(aCellRange)) | |||
4772 | bFound = false; | |||
4773 | } | |||
4774 | ||||
4775 | if (bFound) | |||
4776 | { | |||
4777 | if ( aCellRange.aStart == aCellRange.aEnd ) | |||
4778 | return new ScCellObj( pDocSh, aCellRange.aStart ); | |||
4779 | else | |||
4780 | return new ScCellRangeObj( pDocSh, aCellRange ); | |||
4781 | } | |||
4782 | } | |||
4783 | ||||
4784 | throw uno::RuntimeException(); | |||
4785 | } | |||
4786 | ||||
4787 | // XColumnRowRange | |||
4788 | ||||
4789 | uno::Reference<table::XTableColumns> SAL_CALL ScCellRangeObj::getColumns() | |||
4790 | { | |||
4791 | SolarMutexGuard aGuard; | |||
4792 | ScDocShell* pDocSh = GetDocShell(); | |||
4793 | if (pDocSh) | |||
4794 | return new ScTableColumnsObj( pDocSh, aRange.aStart.Tab(), | |||
4795 | aRange.aStart.Col(), aRange.aEnd.Col() ); | |||
4796 | ||||
4797 | OSL_FAIL("Document invalid")do { if (true && (((sal_Bool)1))) { sal_detail_logFormat ((SAL_DETAIL_LOG_LEVEL_WARN), ("legacy.osl"), ("/home/maarten/src/libreoffice/core/sc/source/ui/unoobj/cellsuno.cxx" ":" "4797" ": "), "%s", "Document invalid"); } } while (false ); | |||
4798 | return nullptr; | |||
4799 | } | |||
4800 | ||||
4801 | uno::Reference<table::XTableRows> SAL_CALL ScCellRangeObj::getRows() | |||
4802 | { | |||
4803 | SolarMutexGuard aGuard; | |||
4804 | ScDocShell* pDocSh = GetDocShell(); | |||
4805 | if (pDocSh) | |||
4806 | return new ScTableRowsObj( pDocSh, aRange.aStart.Tab(), | |||
4807 | aRange.aStart.Row(), aRange.aEnd.Row() ); | |||
4808 | ||||
4809 | OSL_FAIL("Document invalid")do { if (true && (((sal_Bool)1))) { sal_detail_logFormat ((SAL_DETAIL_LOG_LEVEL_WARN), ("legacy.osl"), ("/home/maarten/src/libreoffice/core/sc/source/ui/unoobj/cellsuno.cxx" ":" "4809" ": "), "%s", "Document invalid"); } } while (false ); | |||
4810 | return nullptr; | |||
4811 | } | |||
4812 | ||||
4813 | // XAddressableCellRange | |||
4814 | ||||
4815 | table::CellRangeAddress SAL_CALL ScCellRangeObj::getRangeAddress() | |||
4816 | { | |||
4817 | SolarMutexGuard aGuard; | |||
4818 | table::CellRangeAddress aRet; | |||
4819 | ScUnoConversion::FillApiRange( aRet, aRange ); | |||
4820 | return aRet; | |||
4821 | } | |||
4822 | ||||
4823 | // XSheetCellRange | |||
4824 | ||||
4825 | uno::Reference<sheet::XSpreadsheet> SAL_CALL ScCellRangeObj::getSpreadsheet() | |||
4826 | { | |||
4827 | SolarMutexGuard aGuard; | |||
4828 | ScDocShell* pDocSh = GetDocShell(); | |||
4829 | if (pDocSh) | |||
4830 | return new ScTableSheetObj( pDocSh, aRange.aStart.Tab() ); | |||
4831 | ||||
4832 | OSL_FAIL("Document invalid")do { if (true && (((sal_Bool)1))) { sal_detail_logFormat ((SAL_DETAIL_LOG_LEVEL_WARN), ("legacy.osl"), ("/home/maarten/src/libreoffice/core/sc/source/ui/unoobj/cellsuno.cxx" ":" "4832" ": "), "%s", "Document invalid"); } } while (false ); | |||
4833 | return nullptr; | |||
4834 | } | |||
4835 | ||||
4836 | // XArrayFormulaRange | |||
4837 | ||||
4838 | OUString SAL_CALL ScCellRangeObj::getArrayFormula() | |||
4839 | { | |||
4840 | SolarMutexGuard aGuard; | |||
4841 | ||||
4842 | // Matrix formula if clearly part of a matrix (so when start and end of | |||
4843 | // the block belong to the same matrix) else empty string. | |||
4844 | ||||
4845 | ScDocShell* pDocSh = GetDocShell(); | |||
4846 | if (!pDocSh) | |||
4847 | return EMPTY_OUSTRINGScGlobal::GetEmptyOUString(); | |||
4848 | ||||
4849 | OUString aFormula; | |||
4850 | ||||
4851 | ScDocument& rDoc = pDocSh->GetDocument(); | |||
4852 | ScRefCellValue aCell1(rDoc, aRange.aStart); | |||
4853 | ScRefCellValue aCell2(rDoc, aRange.aEnd); | |||
4854 | if (aCell1.meType == CELLTYPE_FORMULA && aCell2.meType == CELLTYPE_FORMULA) | |||
4855 | { | |||
4856 | const ScFormulaCell* pFCell1 = aCell1.mpFormula; | |||
4857 | const ScFormulaCell* pFCell2 = aCell2.mpFormula; | |||
4858 | ScAddress aStart1; | |||
4859 | ScAddress aStart2; | |||
4860 | if (pFCell1->GetMatrixOrigin(rDoc, aStart1) && pFCell2->GetMatrixOrigin(rDoc, aStart2)) | |||
4861 | { | |||
4862 | if (aStart1 == aStart2) // both the same matrix | |||
4863 | pFCell1->GetFormula(aFormula); // it doesn't matter from which cell | |||
4864 | } | |||
4865 | } | |||
4866 | return aFormula; | |||
4867 | } | |||
4868 | ||||
4869 | void ScCellRangeObj::SetArrayFormula_Impl(const OUString& rFormula, | |||
4870 | const formula::FormulaGrammar::Grammar eGrammar) | |||
4871 | { | |||
4872 | ScDocShell* pDocSh = GetDocShell(); | |||
4873 | if (!pDocSh) | |||
4874 | return; | |||
4875 | ||||
4876 | if ( !rFormula.isEmpty() ) | |||
4877 | { | |||
4878 | if ( comphelper::getUnoTunnelImplementation<ScTableSheetObj>( static_cast<cppu::OWeakObject*>(this) ) ) | |||
4879 | { | |||
4880 | // don't set array formula for sheet object | |||
4881 | throw uno::RuntimeException(); | |||
4882 | } | |||
4883 | ||||
4884 | pDocSh->GetDocFunc().EnterMatrix( aRange, nullptr, nullptr, rFormula, true, true, OUString()/*rFormulaNmsp*/, eGrammar ); | |||
4885 | } | |||
4886 | else | |||
4887 | { | |||
4888 | // empty string -> erase array formula | |||
4889 | ScMarkData aMark(GetDocument()->GetSheetLimits()); | |||
4890 | aMark.SetMarkArea( aRange ); | |||
4891 | aMark.SelectTable( aRange.aStart.Tab(), true ); | |||
4892 | pDocSh->GetDocFunc().DeleteContents( aMark, InsertDeleteFlags::CONTENTS, true, true ); | |||
4893 | } | |||
4894 | } | |||
4895 | ||||
4896 | void SAL_CALL ScCellRangeObj::setArrayFormula( const OUString& aFormula ) | |||
4897 | { | |||
4898 | SolarMutexGuard aGuard; | |||
4899 | // GRAM_API for API compatibility. | |||
4900 | SetArrayFormula_Impl( aFormula, formula::FormulaGrammar::GRAM_API); | |||
4901 | } | |||
4902 | ||||
4903 | // XArrayFormulaTokens | |||
4904 | uno::Sequence<sheet::FormulaToken> SAL_CALL ScCellRangeObj::getArrayTokens() | |||
4905 | { | |||
4906 | SolarMutexGuard aGuard; | |||
4907 | ||||
4908 | // same cell logic as in getArrayFormula | |||
4909 | ||||
4910 | uno::Sequence<sheet::FormulaToken> aSequence; | |||
4911 | ScDocShell* pDocSh = GetDocShell(); | |||
4912 | if (!pDocSh) | |||
4913 | return aSequence; | |||
4914 | ||||
4915 | ScDocument& rDoc = pDocSh->GetDocument(); | |||
4916 | ScRefCellValue aCell1(rDoc, aRange.aStart); | |||
4917 | ScRefCellValue aCell2(rDoc, aRange.aEnd); | |||
4918 | if (aCell1.meType == CELLTYPE_FORMULA && aCell2.meType == CELLTYPE_FORMULA) | |||
4919 | { | |||
4920 | const ScFormulaCell* pFCell1 = aCell1.mpFormula; | |||
4921 | const ScFormulaCell* pFCell2 = aCell2.mpFormula; | |||
4922 | ScAddress aStart1; | |||
4923 | ScAddress aStart2; | |||
4924 | if (pFCell1->GetMatrixOrigin(rDoc, aStart1) && pFCell2->GetMatrixOrigin(rDoc, aStart2)) | |||
4925 | { | |||
4926 | if (aStart1 == aStart2) | |||
4927 | { | |||
4928 | const ScTokenArray* pTokenArray = pFCell1->GetCode(); | |||
4929 | if (pTokenArray) | |||
4930 | ScTokenConversion::ConvertToTokenSequence(rDoc, aSequence, *pTokenArray); | |||
4931 | } | |||
4932 | } | |||
4933 | } | |||
4934 | ||||
4935 | return aSequence; | |||
4936 | } | |||
4937 | ||||
4938 | void SAL_CALL ScCellRangeObj::setArrayTokens( const uno::Sequence<sheet::FormulaToken>& rTokens ) | |||
4939 | { | |||
4940 | SolarMutexGuard aGuard; | |||
4941 | ScDocShell* pDocSh = GetDocShell(); | |||
4942 | if ( !pDocSh ) | |||
4943 | return; | |||
4944 | ||||
4945 | if ( rTokens.hasElements() ) | |||
4946 | { | |||
4947 | if ( comphelper::getUnoTunnelImplementation<ScTableSheetObj>( static_cast<cppu::OWeakObject*>(this) ) ) | |||
4948 | { | |||
4949 | throw uno::RuntimeException(); | |||
4950 | } | |||
4951 | ||||
4952 | ScDocument& rDoc = pDocSh->GetDocument(); | |||
4953 | ScTokenArray aTokenArray(rDoc); | |||
4954 | (void)ScTokenConversion::ConvertToTokenArray( rDoc, aTokenArray, rTokens ); | |||
4955 | ||||
4956 | // Actually GRAM_API is a don't-care here because of the token | |||
4957 | // array being set, it fits with other API compatibility grammars | |||
4958 | // though. | |||
4959 | pDocSh->GetDocFunc().EnterMatrix( aRange, nullptr, &aTokenArray, EMPTY_OUSTRINGScGlobal::GetEmptyOUString(), true, true, EMPTY_OUSTRINGScGlobal::GetEmptyOUString(), formula::FormulaGrammar::GRAM_API ); | |||
4960 | } | |||
4961 | else | |||
4962 | { | |||
4963 | // empty sequence -> erase array formula | |||
4964 | ScMarkData aMark(pDocSh->GetDocument().GetSheetLimits()); | |||
4965 | aMark.SetMarkArea( aRange ); | |||
4966 | aMark.SelectTable( aRange.aStart.Tab(), true ); | |||
4967 | pDocSh->GetDocFunc().DeleteContents( aMark, InsertDeleteFlags::CONTENTS, true, true ); | |||
4968 | } | |||
4969 | } | |||
4970 | ||||
4971 | // XCellRangeData | |||
4972 | ||||
4973 | uno::Sequence< uno::Sequence<uno::Any> > SAL_CALL ScCellRangeObj::getDataArray() | |||
4974 | { | |||
4975 | SolarMutexGuard aGuard; | |||
4976 | ||||
4977 | if ( comphelper::getUnoTunnelImplementation<ScTableSheetObj>( static_cast<cppu::OWeakObject*>(this) ) ) | |||
4978 | { | |||
4979 | // don't create a data array for the sheet | |||
4980 | throw uno::RuntimeException(); | |||
4981 | } | |||
4982 | ||||
4983 | ScDocShell* pDocSh = GetDocShell(); | |||
4984 | if (pDocSh) | |||
4985 | { | |||
4986 | uno::Any aAny; | |||
4987 | // bAllowNV = TRUE: errors as void | |||
4988 | if ( ScRangeToSequence::FillMixedArray( aAny, pDocSh->GetDocument(), aRange, true ) ) | |||
4989 | { | |||
4990 | uno::Sequence< uno::Sequence<uno::Any> > aSeq; | |||
4991 | if ( aAny >>= aSeq ) | |||
4992 | return aSeq; // success | |||
4993 | } | |||
4994 | } | |||
4995 | ||||
4996 | throw uno::RuntimeException(); // no other exceptions specified | |||
4997 | } | |||
4998 | ||||
4999 | void SAL_CALL ScCellRangeObj::setDataArray( | |||
5000 | const uno::Sequence< uno::Sequence<uno::Any> >& aArray ) | |||
5001 | { | |||
5002 | SolarMutexGuard aGuard; | |||
5003 | ||||
5004 | bool bDone = false; | |||
5005 | ScDocShell* pDocSh = GetDocShell(); | |||
5006 | if (pDocSh) | |||
5007 | { | |||
5008 | //! move lcl_PutDataArray to docfunc? | |||
5009 | bDone = lcl_PutDataArray( *pDocSh, aRange, aArray ); | |||
5010 | } | |||
5011 | ||||
5012 | if (!bDone) | |||
5013 | throw uno::RuntimeException(); // no other exceptions specified | |||
5014 | } | |||
5015 | ||||
5016 | // XCellRangeFormula | |||
5017 | ||||
5018 | uno::Sequence< uno::Sequence<OUString> > SAL_CALL ScCellRangeObj::getFormulaArray() | |||
5019 | { | |||
5020 | SolarMutexGuard aGuard; | |||
5021 | ||||
5022 | if ( comphelper::getUnoTunnelImplementation<ScTableSheetObj>( static_cast<cppu::OWeakObject*>(this) ) ) | |||
5023 | { | |||
5024 | // don't create a data array for the sheet | |||
5025 | throw uno::RuntimeException(); | |||
5026 | } | |||
5027 | ||||
5028 | ScDocShell* pDocSh = GetDocShell(); | |||
5029 | if (pDocSh) | |||
5030 | { | |||
5031 | SCCOL nStartCol = aRange.aStart.Col(); | |||
5032 | SCROW nStartRow = aRange.aStart.Row(); | |||
5033 | SCCOL nEndCol = aRange.aEnd.Col(); | |||
5034 | SCROW nEndRow = aRange.aEnd.Row(); | |||
5035 | SCCOL nColCount = nEndCol + 1 - nStartCol; | |||
5036 | SCROW nRowCount = nEndRow + 1 - nStartRow; | |||
5037 | SCTAB nTab = aRange.aStart.Tab(); | |||
5038 | ||||
5039 | uno::Sequence< uno::Sequence<OUString> > aRowSeq( nRowCount ); | |||
5040 | uno::Sequence<OUString>* pRowAry = aRowSeq.getArray(); | |||
5041 | for (SCROW nRowIndex = 0; nRowIndex < nRowCount; nRowIndex++) | |||
5042 | { | |||
5043 | uno::Sequence<OUString> aColSeq( nColCount ); | |||
5044 | OUString* pColAry = aColSeq.getArray(); | |||
5045 | for (SCCOL nColIndex = 0; nColIndex < nColCount; nColIndex++) | |||
5046 | pColAry[nColIndex] = lcl_GetInputString( pDocSh->GetDocument(), | |||
5047 | ScAddress( nStartCol+nColIndex, nStartRow+nRowIndex, nTab ), true ); | |||
5048 | ||||
5049 | pRowAry[nRowIndex] = aColSeq; | |||
5050 | } | |||
5051 | ||||
5052 | return aRowSeq; | |||
5053 | } | |||
5054 | ||||
5055 | throw uno::RuntimeException(); // no other exceptions specified | |||
5056 | } | |||
5057 | ||||
5058 | void SAL_CALL ScCellRangeObj::setFormulaArray( | |||
5059 | const uno::Sequence< uno::Sequence<OUString> >& aArray ) | |||
5060 | { | |||
5061 | SolarMutexGuard aGuard; | |||
5062 | ||||
5063 | bool bDone = false; | |||
5064 | ScDocShell* pDocSh = GetDocShell(); | |||
5065 | if (pDocSh) | |||
5066 | { | |||
5067 | ScExternalRefManager::ApiGuard aExtRefGuard(pDocSh->GetDocument()); | |||
5068 | ||||
5069 | // GRAM_API for API compatibility. | |||
5070 | bDone = lcl_PutFormulaArray( *pDocSh, aRange, aArray, formula::FormulaGrammar::GRAM_API ); | |||
5071 | } | |||
5072 | ||||
5073 | if (!bDone) | |||
5074 | throw uno::RuntimeException(); // no other exceptions specified | |||
5075 | } | |||
5076 | ||||
5077 | // XMultipleOperation | |||
5078 | ||||
5079 | void SAL_CALL ScCellRangeObj::setTableOperation( const table::CellRangeAddress& aFormulaRange, | |||
5080 | sheet::TableOperationMode nMode, | |||
5081 | const table::CellAddress& aColumnCell, | |||
5082 | const table::CellAddress& aRowCell ) | |||
5083 | { | |||
5084 | SolarMutexGuard aGuard; | |||
5085 | ScDocShell* pDocSh = GetDocShell(); | |||
5086 | if (!pDocSh) | |||
5087 | return; | |||
5088 | ||||
5089 | bool bError = false; | |||
5090 | ScTabOpParam aParam; | |||
5091 | aParam.aRefFormulaCell = ScRefAddress( static_cast<SCCOL>(aFormulaRange.StartColumn), | |||
5092 | static_cast<SCROW>(aFormulaRange.StartRow), aFormulaRange.Sheet ); | |||
5093 | aParam.aRefFormulaEnd = ScRefAddress( static_cast<SCCOL>(aFormulaRange.EndColumn), | |||
5094 | static_cast<SCROW>(aFormulaRange.EndRow), aFormulaRange.Sheet ); | |||
5095 | aParam.aRefRowCell = ScRefAddress( static_cast<SCCOL>(aRowCell.Column), | |||
5096 | static_cast<SCROW>(aRowCell.Row), aRowCell.Sheet ); | |||
5097 | aParam.aRefColCell = ScRefAddress( static_cast<SCCOL>(aColumnCell.Column), | |||
5098 | static_cast<SCROW>(aColumnCell.Row), aColumnCell.Sheet ); | |||
5099 | ||||
5100 | switch (nMode) | |||
5101 | { | |||
5102 | case sheet::TableOperationMode_COLUMN: | |||
5103 | aParam.meMode = ScTabOpParam::Column; | |||
5104 | break; | |||
5105 | case sheet::TableOperationMode_ROW: | |||
5106 | aParam.meMode = ScTabOpParam::Row; | |||
5107 | break; | |||
5108 | case sheet::TableOperationMode_BOTH: | |||
5109 | aParam.meMode = ScTabOpParam::Both; | |||
5110 | break; | |||
5111 | default: | |||
5112 | bError = true; | |||
5113 | } | |||
5114 | ||||
5115 | if (!bError) | |||
5116 | pDocSh->GetDocFunc().TabOp( aRange, nullptr, aParam, true, true ); | |||
5117 | } | |||
5118 | ||||
5119 | // XMergeable | |||
5120 | ||||
5121 | void SAL_CALL ScCellRangeObj::merge( sal_Bool bMerge ) | |||
5122 | { | |||
5123 | SolarMutexGuard aGuard; | |||
5124 | ScDocShell* pDocSh = GetDocShell(); | |||
5125 | if ( !pDocSh ) | |||
5126 | return; | |||
5127 | ||||
5128 | ScCellMergeOption aMergeOption( | |||
5129 | aRange.aStart.Col(), aRange.aStart.Row(), | |||
5130 | aRange.aEnd.Col(), aRange.aEnd.Row(), false); | |||
5131 | aMergeOption.maTabs.insert(aRange.aStart.Tab()); | |||
5132 | if ( bMerge ) | |||
5133 | pDocSh->GetDocFunc().MergeCells( aMergeOption, false, true, true ); | |||
5134 | else | |||
5135 | pDocSh->GetDocFunc().UnmergeCells( aMergeOption, true, nullptr ); | |||
5136 | ||||
5137 | //! Catch error? | |||
5138 | } | |||
5139 | ||||
5140 | sal_Bool SAL_CALL ScCellRangeObj::getIsMerged() | |||
5141 | { | |||
5142 | SolarMutexGuard aGuard; | |||
5143 | ScDocShell* pDocSh = GetDocShell(); | |||
5144 | return pDocSh && pDocSh->GetDocument().HasAttrib( aRange, HasAttrFlags::Merged ); | |||
5145 | } | |||
5146 | ||||
5147 | // XCellSeries | |||
5148 | ||||
5149 | void SAL_CALL ScCellRangeObj::fillSeries( sheet::FillDirection nFillDirection, | |||
5150 | sheet::FillMode nFillMode, sheet::FillDateMode nFillDateMode, | |||
5151 | double fStep, double fEndValue ) | |||
5152 | { | |||
5153 | SolarMutexGuard aGuard; | |||
5154 | ScDocShell* pDocSh = GetDocShell(); | |||
5155 | if ( !pDocSh ) | |||
5156 | return; | |||
5157 | ||||
5158 | bool bError = false; | |||
5159 | ||||
5160 | FillDir eDir = FILL_TO_BOTTOM; | |||
5161 | switch (nFillDirection) | |||
5162 | { | |||
5163 | case sheet::FillDirection_TO_BOTTOM: | |||
5164 | eDir = FILL_TO_BOTTOM; | |||
5165 | break; | |||
5166 | case sheet::FillDirection_TO_RIGHT: | |||
5167 | eDir = FILL_TO_RIGHT; | |||
5168 | break; | |||
5169 | case sheet::FillDirection_TO_TOP: | |||
5170 | eDir = FILL_TO_TOP; | |||
5171 | break; | |||
5172 | case sheet::FillDirection_TO_LEFT: | |||
5173 | eDir = FILL_TO_LEFT; | |||
5174 | break; | |||
5175 | default: | |||
5176 | bError = true; | |||
5177 | } | |||
5178 | ||||
5179 | FillCmd eCmd = FILL_SIMPLE; | |||
5180 | switch ( nFillMode ) | |||
5181 | { | |||
5182 | case sheet::FillMode_SIMPLE: | |||
5183 | eCmd = FILL_SIMPLE; | |||
5184 | break; | |||
5185 | case sheet::FillMode_LINEAR: | |||
5186 | eCmd = FILL_LINEAR; | |||
5187 | break; | |||
5188 | case sheet::FillMode_GROWTH: | |||
5189 | eCmd = FILL_GROWTH; | |||
5190 | break; | |||
5191 | case sheet::FillMode_DATE: | |||
5192 | eCmd = FILL_DATE; | |||
5193 | break; | |||
5194 | case sheet::FillMode_AUTO: | |||
5195 | eCmd = FILL_AUTO; | |||
5196 | break; | |||
5197 | default: | |||
5198 | bError = true; | |||
5199 | } | |||
5200 | ||||
5201 | FillDateCmd eDateCmd = FILL_DAY; | |||
5202 | switch ( nFillDateMode ) | |||
5203 | { | |||
5204 | case sheet::FillDateMode_FILL_DATE_DAY: | |||
5205 | eDateCmd = FILL_DAY; | |||
5206 | break; | |||
5207 | case sheet::FillDateMode_FILL_DATE_WEEKDAY: | |||
5208 | eDateCmd = FILL_WEEKDAY; | |||
5209 | break; | |||
5210 | case sheet::FillDateMode_FILL_DATE_MONTH: | |||
5211 | eDateCmd = FILL_MONTH; | |||
5212 | break; | |||
5213 | case sheet::FillDateMode_FILL_DATE_YEAR: | |||
5214 | eDateCmd = FILL_YEAR; | |||
5215 | break; | |||
5216 | default: | |||
5217 | bError = true; | |||
5218 | } | |||
5219 | ||||
5220 | if (!bError) | |||
5221 | pDocSh->GetDocFunc().FillSeries( aRange, nullptr, eDir, eCmd, eDateCmd, | |||
5222 | MAXDOUBLE1.7e307, fStep, fEndValue, true ); | |||
5223 | } | |||
5224 | ||||
5225 | void SAL_CALL ScCellRangeObj::fillAuto( sheet::FillDirection nFillDirection, | |||
5226 | sal_Int32 nSourceCount ) | |||
5227 | { | |||
5228 | SolarMutexGuard aGuard; | |||
5229 | ScDocShell* pDocSh = GetDocShell(); | |||
5230 | if ( !(pDocSh && nSourceCount) ) | |||
5231 | return; | |||
5232 | ||||
5233 | ScRange aSourceRange(aRange); | |||
5234 | SCCOLROW nCount = 0; // "Dest-Count" | |||
5235 | FillDir eDir = FILL_TO_BOTTOM; | |||
5236 | bool bError = false; | |||
5237 | switch (nFillDirection) | |||
5238 | { | |||
5239 | case sheet::FillDirection_TO_BOTTOM: | |||
5240 | aSourceRange.aEnd.SetRow( static_cast<SCROW>( aSourceRange.aStart.Row() + nSourceCount - 1 ) ); | |||
5241 | nCount = aRange.aEnd.Row() - aSourceRange.aEnd.Row(); | |||
5242 | eDir = FILL_TO_BOTTOM; | |||
5243 | break; | |||
5244 | case sheet::FillDirection_TO_RIGHT: | |||
5245 | aSourceRange.aEnd.SetCol( static_cast<SCCOL>( aSourceRange.aStart.Col() + nSourceCount - 1 ) ); | |||
5246 | nCount = aRange.aEnd.Col() - aSourceRange.aEnd.Col(); | |||
5247 | eDir = FILL_TO_RIGHT; | |||
5248 | break; | |||
5249 | case sheet::FillDirection_TO_TOP: | |||
5250 | aSourceRange.aStart.SetRow( static_cast<SCROW>( aSourceRange.aEnd.Row() - nSourceCount + 1 ) ); | |||
5251 | nCount = aSourceRange.aStart.Row() - aRange.aStart.Row(); | |||
5252 | eDir = FILL_TO_TOP; | |||
5253 | break; | |||
5254 | case sheet::FillDirection_TO_LEFT: | |||
5255 | aSourceRange.aStart.SetCol( static_cast<SCCOL>( aSourceRange.aEnd.Col() - nSourceCount + 1 ) ); | |||
5256 | nCount = aSourceRange.aStart.Col() - aRange.aStart.Col(); | |||
5257 | eDir = FILL_TO_LEFT; | |||
5258 | break; | |||
5259 | default: | |||
5260 | bError = true; | |||
5261 | } | |||
5262 | const ScDocument& rDoc = pDocSh->GetDocument(); | |||
5263 | if (nCount < 0 || nCount > rDoc.MaxRow()) // overflow | |||
5264 | bError = true; | |||
5265 | ||||
5266 | if (!bError) | |||
5267 | pDocSh->GetDocFunc().FillAuto( aSourceRange, nullptr, eDir, nCount, true ); | |||
5268 | } | |||
5269 | ||||
5270 | // XAutoFormattable | |||
5271 | ||||
5272 | void SAL_CALL ScCellRangeObj::autoFormat( const OUString& aName ) | |||
5273 | { | |||
5274 | SolarMutexGuard aGuard; | |||
5275 | ScDocShell* pDocSh = GetDocShell(); | |||
5276 | if ( pDocSh ) | |||
5277 | { | |||
5278 | ScAutoFormat* pAutoFormat = ScGlobal::GetOrCreateAutoFormat(); | |||
5279 | ScAutoFormat::const_iterator it = pAutoFormat->find(aName); | |||
5280 | if (it == pAutoFormat->end()) | |||
5281 | throw lang::IllegalArgumentException(); | |||
5282 | ||||
5283 | ScAutoFormat::const_iterator itBeg = pAutoFormat->begin(); | |||
5284 | size_t nIndex = std::distance(itBeg, it); | |||
5285 | pDocSh->GetDocFunc().AutoFormat(aRange, nullptr, nIndex, true); | |||
5286 | ||||
5287 | } | |||
5288 | } | |||
5289 | ||||
5290 | // XSortable | |||
5291 | ||||
5292 | uno::Sequence<beans::PropertyValue> SAL_CALL ScCellRangeObj::createSortDescriptor() | |||
5293 | { | |||
5294 | SolarMutexGuard aGuard; | |||
5295 | ScSortParam aParam; | |||
5296 | ScDocShell* pDocSh = GetDocShell(); | |||
5297 | if ( pDocSh ) | |||
5298 | { | |||
5299 | // create DB-Area only during execution; API always the exact area | |||
5300 | ScDBData* pData = pDocSh->GetDBData( aRange, SC_DB_OLD, ScGetDBSelection::ForceMark ); | |||
5301 | if (pData) | |||
5302 | { | |||
5303 | pData->GetSortParam(aParam); | |||
5304 | ||||
5305 | // SortDescriptor contains the counted fields inside the area | |||
5306 | ScRange aDBRange; | |||
5307 | pData->GetArea(aDBRange); | |||
5308 | SCCOLROW nFieldStart = aParam.bByRow ? | |||
5309 | static_cast<SCCOLROW>(aDBRange.aStart.Col()) : | |||
5310 | static_cast<SCCOLROW>(aDBRange.aStart.Row()); | |||
5311 | for (sal_uInt16 i=0; i<aParam.GetSortKeyCount(); i++) | |||
5312 | if ( aParam.maKeyState[i].bDoSort && aParam.maKeyState[i].nField >= nFieldStart ) | |||
5313 | aParam.maKeyState[i].nField -= nFieldStart; | |||
5314 | } | |||
5315 | } | |||
5316 | ||||
5317 | uno::Sequence<beans::PropertyValue> aSeq( ScSortDescriptor::GetPropertyCount() ); | |||
5318 | ScSortDescriptor::FillProperties( aSeq, aParam ); | |||
5319 | return aSeq; | |||
5320 | } | |||
5321 | ||||
5322 | void SAL_CALL ScCellRangeObj::sort( const uno::Sequence<beans::PropertyValue>& aDescriptor ) | |||
5323 | { | |||
5324 | SolarMutexGuard aGuard; | |||
5325 | ScDocShell* pDocSh = GetDocShell(); | |||
5326 | if (!pDocSh) | |||
5327 | return; | |||
5328 | ||||
5329 | sal_uInt16 i; | |||
5330 | ScSortParam aParam; | |||
5331 | ScDBData* pData = pDocSh->GetDBData( aRange, SC_DB_MAKE, ScGetDBSelection::ForceMark ); // if needed create area | |||
5332 | if (pData) | |||
5333 | { | |||
5334 | // get old settings if not everything is set anew | |||
5335 | pData->GetSortParam(aParam); | |||
5336 | SCCOLROW nOldStart = aParam.bByRow ? | |||
5337 | static_cast<SCCOLROW>(aRange.aStart.Col()) : | |||
5338 | static_cast<SCCOLROW>(aRange.aStart.Row()); | |||
5339 | for (i=0; i<aParam.GetSortKeyCount(); i++) | |||
5340 | if ( aParam.maKeyState[i].bDoSort && aParam.maKeyState[i].nField >= nOldStart ) | |||
5341 | aParam.maKeyState[i].nField -= nOldStart; | |||
5342 | } | |||
5343 | ||||
5344 | ScSortDescriptor::FillSortParam( aParam, aDescriptor ); | |||
5345 | ||||
5346 | // SortDescriptor contains the counted fields inside the area | |||
5347 | // ByRow can be changed during execution of FillSortParam | |||
5348 | SCCOLROW nFieldStart = aParam.bByRow ? | |||
5349 | static_cast<SCCOLROW>(aRange.aStart.Col()) : | |||
5350 | static_cast<SCCOLROW>(aRange.aStart.Row()); | |||
5351 | SCCOLROW nFieldEnd = aParam.bByRow ? | |||
5352 | static_cast<SCCOLROW>(aRange.aEnd.Col()) : | |||
5353 | static_cast<SCCOLROW>(aRange.aEnd.Row()); | |||
5354 | for (i=0; i<aParam.GetSortKeyCount(); i++) | |||
5355 | { | |||
5356 | aParam.maKeyState[i].nField += nFieldStart; | |||
5357 | // tdf#103632 - sanity check poorly behaved macros. | |||
5358 | if (aParam.maKeyState[i].nField > nFieldEnd) | |||
5359 | aParam.maKeyState[i].nField = nFieldEnd; | |||
5360 | } | |||
5361 | ||||
5362 | SCTAB nTab = aRange.aStart.Tab(); | |||
5363 | aParam.nCol1 = aRange.aStart.Col(); | |||
5364 | aParam.nRow1 = aRange.aStart.Row(); | |||
5365 | aParam.nCol2 = aRange.aEnd.Col(); | |||
5366 | aParam.nRow2 = aRange.aEnd.Row(); | |||
5367 | ||||
5368 | pDocSh->GetDBData( aRange, SC_DB_MAKE, ScGetDBSelection::ForceMark ); // if needed create area | |||
5369 | ||||
5370 | ScDBDocFunc aFunc(*pDocSh); // area must be created | |||
5371 | (void)aFunc.Sort( nTab, aParam, true, true, true ); | |||
5372 | } | |||
5373 | ||||
5374 | // XFilterable | |||
5375 | ||||
5376 | uno::Reference<sheet::XSheetFilterDescriptor> SAL_CALL ScCellRangeObj::createFilterDescriptor( | |||
5377 | sal_Bool bEmpty ) | |||
5378 | { | |||
5379 | SolarMutexGuard aGuard; | |||
5380 | ScDocShell* pDocSh = GetDocShell(); | |||
5381 | ScFilterDescriptor* pNew = new ScFilterDescriptor(pDocSh); | |||
5382 | if ( !bEmpty && pDocSh ) | |||
5383 | { | |||
5384 | // create DB-Area only during execution; API always the exact area | |||
5385 | ScDBData* pData = pDocSh->GetDBData( aRange, SC_DB_OLD, ScGetDBSelection::ForceMark ); | |||
5386 | if (pData) | |||
5387 | { | |||
5388 | ScQueryParam aParam; | |||
5389 | pData->GetQueryParam(aParam); | |||
5390 | // FilterDescriptor contains the counted fields inside the area | |||
5391 | ScRange aDBRange; | |||
5392 | pData->GetArea(aDBRange); | |||
5393 | SCCOLROW nFieldStart = aParam.bByRow ? | |||
5394 | static_cast<SCCOLROW>(aDBRange.aStart.Col()) : | |||
5395 | static_cast<SCCOLROW>(aDBRange.aStart.Row()); | |||
5396 | SCSIZE nCount = aParam.GetEntryCount(); | |||
5397 | for (SCSIZE i=0; i<nCount; i++) | |||
5398 | { | |||
5399 | ScQueryEntry& rEntry = aParam.GetEntry(i); | |||
5400 | if (rEntry.bDoQuery && rEntry.nField >= nFieldStart) | |||
5401 | rEntry.nField -= nFieldStart; | |||
5402 | } | |||
5403 | pNew->SetParam(aParam); | |||
5404 | } | |||
5405 | } | |||
5406 | return pNew; | |||
5407 | } | |||
5408 | ||||
5409 | void SAL_CALL ScCellRangeObj::filter( const uno::Reference<sheet::XSheetFilterDescriptor>& xDescriptor ) | |||
5410 | { | |||
5411 | SolarMutexGuard aGuard; | |||
5412 | ||||
5413 | if (!xDescriptor.is()) return; | |||
5414 | ||||
5415 | // This could be theoretically an unknown object, so only use the | |||
5416 | // public XSheetFilterDescriptor interface to copy the data into a | |||
5417 | // ScFilterDescriptor object: | |||
5418 | //! if it already a ScFilterDescriptor is, direct via getImplementation? | |||
5419 | ||||
5420 | ScDocShell* pDocSh = GetDocShell(); | |||
5421 | rtl::Reference<ScFilterDescriptor> xImpl(new ScFilterDescriptor(pDocSh)); | |||
5422 | uno::Reference< sheet::XSheetFilterDescriptor2 > xDescriptor2( xDescriptor, uno::UNO_QUERY ); | |||
5423 | if ( xDescriptor2.is() ) | |||
5424 | { | |||
5425 | xImpl->setFilterFields2( xDescriptor2->getFilterFields2() ); | |||
5426 | } | |||
5427 | else | |||
5428 | { | |||
5429 | xImpl->setFilterFields( xDescriptor->getFilterFields() ); | |||
5430 | } | |||
5431 | // the rest are now properties... | |||
5432 | ||||
5433 | uno::Reference<beans::XPropertySet> xPropSet( xDescriptor, uno::UNO_QUERY ); | |||
5434 | if (xPropSet.is()) | |||
5435 | lcl_CopyProperties(*xImpl, *xPropSet); | |||
5436 | ||||
5437 | if (!pDocSh) | |||
5438 | return; | |||
5439 | ||||
5440 | ScQueryParam aParam = xImpl->GetParam(); | |||
5441 | // FilterDescriptor contains the counted fields inside the area | |||
5442 | SCCOLROW nFieldStart = aParam.bByRow ? | |||
5443 | static_cast<SCCOLROW>(aRange.aStart.Col()) : | |||
5444 | static_cast<SCCOLROW>(aRange.aStart.Row()); | |||
5445 | SCSIZE nCount = aParam.GetEntryCount(); | |||
5446 | svl::SharedStringPool& rPool = pDocSh->GetDocument().GetSharedStringPool(); | |||
5447 | for (SCSIZE i=0; i<nCount; i++) | |||
5448 | { | |||
5449 | ScQueryEntry& rEntry = aParam.GetEntry(i); | |||
5450 | if (rEntry.bDoQuery) | |||
5451 | { | |||
5452 | rEntry.nField += nFieldStart; | |||
5453 | // dialog always shows the string -> must match the value | |||
5454 | ScQueryEntry::QueryItemsType& rItems = rEntry.GetQueryItems(); | |||
5455 | rItems.resize(1); | |||
5456 | ScQueryEntry::Item& rItem = rItems.front(); | |||
5457 | if (rItem.meType != ScQueryEntry::ByString) | |||
5458 | { | |||
5459 | OUString aStr; | |||
5460 | pDocSh->GetDocument().GetFormatTable()->GetInputLineString(rItem.mfVal, 0, aStr); | |||
5461 | rItem.maString = rPool.intern(aStr); | |||
5462 | } | |||
5463 | } | |||
5464 | } | |||
5465 | ||||
5466 | SCTAB nTab = aRange.aStart.Tab(); | |||
5467 | aParam.nCol1 = aRange.aStart.Col(); | |||
5468 | aParam.nRow1 = aRange.aStart.Row(); | |||
5469 | aParam.nCol2 = aRange.aEnd.Col(); | |||
5470 | aParam.nRow2 = aRange.aEnd.Row(); | |||
5471 | ||||
5472 | pDocSh->GetDBData( aRange, SC_DB_MAKE, ScGetDBSelection::ForceMark ); // if needed create area | |||
5473 | ||||
5474 | //! keep source range in filter descriptor | |||
5475 | //! if created by createFilterDescriptorByObject ??? | |||
5476 | ||||
5477 | ScDBDocFunc aFunc(*pDocSh); | |||
5478 | aFunc.Query( nTab, aParam, nullptr, true, true ); // area must be created | |||
5479 | } | |||
5480 | ||||
5481 | //! get/setAutoFilter as properties!!! | |||
5482 | ||||
5483 | // XAdvancedFilterSource | |||
5484 | ||||
5485 | uno::Reference<sheet::XSheetFilterDescriptor> SAL_CALL ScCellRangeObj::createFilterDescriptorByObject( | |||
5486 | const uno::Reference<sheet::XSheetFilterable>& xObject ) | |||
5487 | { | |||
5488 | SolarMutexGuard aGuard; | |||
5489 | ||||
5490 | // this here is not the area, which will be filtered, instead the area | |||
5491 | // with the query | |||
5492 | ||||
5493 | uno::Reference<sheet::XCellRangeAddressable> xAddr( xObject, uno::UNO_QUERY ); | |||
5494 | ||||
5495 | ScDocShell* pDocSh = GetDocShell(); | |||
5496 | if ( !pDocSh || !xAddr.is() ) | |||
5497 | { | |||
5498 | OSL_FAIL("no document or no area")do { if (true && (((sal_Bool)1))) { sal_detail_logFormat ((SAL_DETAIL_LOG_LEVEL_WARN), ("legacy.osl"), ("/home/maarten/src/libreoffice/core/sc/source/ui/unoobj/cellsuno.cxx" ":" "5498" ": "), "%s", "no document or no area"); } } while (false); | |||
5499 | return nullptr; | |||
5500 | } | |||
5501 | ||||
5502 | //! check if xObject is in the same document | |||
5503 | ||||
5504 | std::unique_ptr<ScFilterDescriptor> pNew(new ScFilterDescriptor(pDocSh)); //! instead from object? | |||
5505 | ||||
5506 | ScQueryParam aParam = pNew->GetParam(); | |||
5507 | aParam.bHasHeader = true; | |||
5508 | ||||
5509 | table::CellRangeAddress aDataAddress(xAddr->getRangeAddress()); | |||
5510 | aParam.nCol1 = static_cast<SCCOL>(aDataAddress.StartColumn); | |||
5511 | aParam.nRow1 = static_cast<SCROW>(aDataAddress.StartRow); | |||
5512 | aParam.nCol2 = static_cast<SCCOL>(aDataAddress.EndColumn); | |||
5513 | aParam.nRow2 = static_cast<SCROW>(aDataAddress.EndRow); | |||
5514 | aParam.nTab = aDataAddress.Sheet; | |||
5515 | ||||
5516 | ScDocument& rDoc = pDocSh->GetDocument(); | |||
5517 | if (!rDoc.CreateQueryParam(aRange, aParam)) | |||
5518 | return nullptr; | |||
5519 | ||||
5520 | // FilterDescriptor contains the counted fields inside the area | |||
5521 | SCCOLROW nFieldStart = aParam.bByRow ? | |||
5522 | static_cast<SCCOLROW>(aDataAddress.StartColumn) : | |||
5523 | static_cast<SCCOLROW>(aDataAddress.StartRow); | |||
5524 | SCSIZE nCount = aParam.GetEntryCount(); | |||
5525 | for (SCSIZE i=0; i<nCount; i++) | |||
5526 | { | |||
5527 | ScQueryEntry& rEntry = aParam.GetEntry(i); | |||
5528 | if (rEntry.bDoQuery && rEntry.nField >= nFieldStart) | |||
5529 | rEntry.nField -= nFieldStart; | |||
5530 | } | |||
5531 | ||||
5532 | pNew->SetParam( aParam ); | |||
5533 | return pNew.release(); | |||
5534 | } | |||
5535 | ||||
5536 | // XSubTotalSource | |||
5537 | ||||
5538 | uno::Reference<sheet::XSubTotalDescriptor> SAL_CALL ScCellRangeObj::createSubTotalDescriptor( | |||
5539 | sal_Bool bEmpty ) | |||
5540 | { | |||
5541 | SolarMutexGuard aGuard; | |||
5542 | ScSubTotalDescriptor* pNew = new ScSubTotalDescriptor; | |||
5543 | ScDocShell* pDocSh = GetDocShell(); | |||
5544 | if ( !bEmpty && pDocSh ) | |||
5545 | { | |||
5546 | // create DB-Area only during execution; API always the exact area | |||
5547 | ScDBData* pData = pDocSh->GetDBData( aRange, SC_DB_OLD, ScGetDBSelection::ForceMark ); | |||
5548 | if (pData) | |||
5549 | { | |||
5550 | ScSubTotalParam aParam; | |||
5551 | pData->GetSubTotalParam(aParam); | |||
5552 | // SubTotalDescriptor contains the counted fields inside the area | |||
5553 | ScRange aDBRange; | |||
5554 | pData->GetArea(aDBRange); | |||
5555 | SCCOL nFieldStart = aDBRange.aStart.Col(); | |||
5556 | for (sal_uInt16 i=0; i<MAXSUBTOTAL; i++) | |||
5557 | { | |||
5558 | if ( aParam.bGroupActive[i] ) | |||
5559 | { | |||
5560 | if ( aParam.nField[i] >= nFieldStart ) | |||
5561 | aParam.nField[i] = sal::static_int_cast<SCCOL>( aParam.nField[i] - nFieldStart ); | |||
5562 | for (SCCOL j=0; j<aParam.nSubTotals[i]; j++) | |||
5563 | if ( aParam.pSubTotals[i][j] >= nFieldStart ) | |||
5564 | aParam.pSubTotals[i][j] = sal::static_int_cast<SCCOL>( aParam.pSubTotals[i][j] - nFieldStart ); | |||
5565 | } | |||
5566 | } | |||
5567 | pNew->SetParam(aParam); | |||
5568 | } | |||
5569 | } | |||
5570 | return pNew; | |||
5571 | } | |||
5572 | ||||
5573 | void SAL_CALL ScCellRangeObj::applySubTotals( | |||
5574 | const uno::Reference<sheet::XSubTotalDescriptor>& xDescriptor, | |||
5575 | sal_Bool bReplace) | |||
5576 | { | |||
5577 | SolarMutexGuard aGuard; | |||
5578 | ||||
5579 | if (!xDescriptor.is()) return; | |||
5580 | ||||
5581 | ScDocShell* pDocSh = GetDocShell(); | |||
5582 | ScSubTotalDescriptorBase* pImp = | |||
5583 | comphelper::getUnoTunnelImplementation<ScSubTotalDescriptorBase>( xDescriptor ); | |||
5584 | ||||
5585 | if (!(pDocSh && pImp)) | |||
5586 | return; | |||
5587 | ||||
5588 | ScSubTotalParam aParam; | |||
5589 | pImp->GetData(aParam); // virtual method of base class | |||
5590 | ||||
5591 | // SubTotalDescriptor contains the counted fields inside the area | |||
5592 | SCCOL nFieldStart = aRange.aStart.Col(); | |||
5593 | for (sal_uInt16 i=0; i<MAXSUBTOTAL; i++) | |||
5594 | { | |||
5595 | if ( aParam.bGroupActive[i] ) | |||
5596 | { | |||
5597 | aParam.nField[i] = sal::static_int_cast<SCCOL>( aParam.nField[i] + nFieldStart ); | |||
5598 | for (SCCOL j=0; j<aParam.nSubTotals[i]; j++) | |||
5599 | aParam.pSubTotals[i][j] = sal::static_int_cast<SCCOL>( aParam.pSubTotals[i][j] + nFieldStart ); | |||
5600 | } | |||
5601 | } | |||
5602 | ||||
5603 | aParam.bReplace = bReplace; | |||
5604 | ||||
5605 | SCTAB nTab = aRange.aStart.Tab(); | |||
5606 | aParam.nCol1 = aRange.aStart.Col(); | |||
5607 | aParam.nRow1 = aRange.aStart.Row(); | |||
5608 | aParam.nCol2 = aRange.aEnd.Col(); | |||
5609 | aParam.nRow2 = aRange.aEnd.Row(); | |||
5610 | ||||
5611 | pDocSh->GetDBData( aRange, SC_DB_MAKE, ScGetDBSelection::ForceMark ); // if needed create area | |||
5612 | ||||
5613 | ScDBDocFunc aFunc(*pDocSh); | |||
5614 | aFunc.DoSubTotals( nTab, aParam, true, true ); // area must be created | |||
5615 | } | |||
5616 | ||||
5617 | void SAL_CALL ScCellRangeObj::removeSubTotals() | |||
5618 | { | |||
5619 | SolarMutexGuard aGuard; | |||
5620 | ||||
5621 | ScDocShell* pDocSh = GetDocShell(); | |||
5622 | if (!pDocSh) | |||
5623 | return; | |||
5624 | ||||
5625 | ScSubTotalParam aParam; | |||
5626 | ScDBData* pData = pDocSh->GetDBData( aRange, SC_DB_OLD, ScGetDBSelection::ForceMark ); | |||
5627 | if (pData) | |||
5628 | pData->GetSubTotalParam(aParam); // also keep field entries during remove | |||
5629 | ||||
5630 | aParam.bRemoveOnly = true; | |||
5631 | ||||
5632 | SCTAB nTab = aRange.aStart.Tab(); | |||
5633 | aParam.nCol1 = aRange.aStart.Col(); | |||
5634 | aParam.nRow1 = aRange.aStart.Row(); | |||
5635 | aParam.nCol2 = aRange.aEnd.Col(); | |||
5636 | aParam.nRow2 = aRange.aEnd.Row(); | |||
5637 | ||||
5638 | pDocSh->GetDBData( aRange, SC_DB_MAKE, ScGetDBSelection::ForceMark ); // if needed create area | |||
5639 | ||||
5640 | ScDBDocFunc aFunc(*pDocSh); | |||
5641 | aFunc.DoSubTotals( nTab, aParam, true, true ); // are must be created | |||
5642 | } | |||
5643 | ||||
5644 | uno::Sequence<beans::PropertyValue> SAL_CALL ScCellRangeObj::createImportDescriptor( sal_Bool bEmpty ) | |||
5645 | { | |||
5646 | SolarMutexGuard aGuard; | |||
5647 | ScImportParam aParam; | |||
5648 | ScDocShell* pDocSh = GetDocShell(); | |||
5649 | if ( !bEmpty && pDocSh ) | |||
5650 | { | |||
5651 | // create DB-Area only during execution; API always the exact area | |||
5652 | ScDBData* pData = pDocSh->GetDBData( aRange, SC_DB_OLD, ScGetDBSelection::ForceMark ); | |||
5653 | if (pData) | |||
5654 | pData->GetImportParam(aParam); | |||
5655 | } | |||
5656 | ||||
5657 | uno::Sequence<beans::PropertyValue> aSeq( ScImportDescriptor::GetPropertyCount() ); | |||
5658 | ScImportDescriptor::FillProperties( aSeq, aParam ); | |||
5659 | return aSeq; | |||
5660 | } | |||
5661 | ||||
5662 | void SAL_CALL ScCellRangeObj::doImport( const uno::Sequence<beans::PropertyValue>& aDescriptor ) | |||
5663 | { | |||
5664 | SolarMutexGuard aGuard; | |||
5665 | ScDocShell* pDocSh = GetDocShell(); | |||
5666 | if (!pDocSh) | |||
5667 | return; | |||
5668 | ||||
5669 | ScImportParam aParam; | |||
5670 | ScImportDescriptor::FillImportParam( aParam, aDescriptor ); | |||
5671 | ||||
5672 | SCTAB nTab = aRange.aStart.Tab(); | |||
5673 | aParam.nCol1 = aRange.aStart.Col(); | |||
5674 | aParam.nRow1 = aRange.aStart.Row(); | |||
5675 | aParam.nCol2 = aRange.aEnd.Col(); | |||
5676 | aParam.nRow2 = aRange.aEnd.Row(); | |||
5677 | ||||
5678 | //! TODO: could we get passed a valid result set by any means? | |||
5679 | ||||
5680 | pDocSh->GetDBData( aRange, SC_DB_MAKE, ScGetDBSelection::ForceMark ); // if needed create area | |||
5681 | ||||
5682 | ScDBDocFunc aFunc(*pDocSh); // are must be created | |||
5683 | aFunc.DoImport( nTab, aParam, nullptr ); //! Api-Flag as parameter | |||
5684 | } | |||
5685 | ||||
5686 | // XCellFormatRangesSupplier | |||
5687 | ||||
5688 | uno::Reference<container::XIndexAccess> SAL_CALL ScCellRangeObj::getCellFormatRanges() | |||
5689 | { | |||
5690 | SolarMutexGuard aGuard; | |||
5691 | ScDocShell* pDocSh = GetDocShell(); | |||
5692 | if ( pDocSh ) | |||
5693 | return new ScCellFormatsObj( pDocSh, aRange ); | |||
5694 | return nullptr; | |||
5695 | } | |||
5696 | ||||
5697 | // XUniqueCellFormatRangesSupplier | |||
5698 | ||||
5699 | uno::Reference<container::XIndexAccess> SAL_CALL ScCellRangeObj::getUniqueCellFormatRanges() | |||
5700 | { | |||
5701 | SolarMutexGuard aGuard; | |||
5702 | ScDocShell* pDocSh = GetDocShell(); | |||
5703 | if ( pDocSh ) | |||
5704 | return new ScUniqueCellFormatsObj( pDocSh, aRange ); | |||
5705 | return nullptr; | |||
5706 | } | |||
5707 | ||||
5708 | // XPropertySet extended for Range-Properties | |||
5709 | ||||
5710 | uno::Reference<beans::XPropertySetInfo> SAL_CALL ScCellRangeObj::getPropertySetInfo() | |||
5711 | { | |||
5712 | SolarMutexGuard aGuard; | |||
5713 | static uno::Reference<beans::XPropertySetInfo> aRef( | |||
5714 | new SfxItemPropertySetInfo( pRangePropSet->getPropertyMap() )); | |||
5715 | return aRef; | |||
5716 | } | |||
5717 | ||||
5718 | void ScCellRangeObj::SetOnePropertyValue( const SfxItemPropertySimpleEntry* pEntry, const uno::Any& aValue ) | |||
5719 | { | |||
5720 | // Range has only Position and Size in addition to ScCellRangesBase, both are ReadOnly | |||
5721 | // -> nothing to do here | |||
5722 | ||||
5723 | ScCellRangesBase::SetOnePropertyValue( pEntry, aValue ); | |||
5724 | } | |||
5725 | ||||
5726 | void ScCellRangeObj::GetOnePropertyValue( const SfxItemPropertySimpleEntry* pEntry, uno::Any& rAny ) | |||
5727 | { | |||
5728 | if ( !pEntry ) | |||
5729 | return; | |||
5730 | ||||
5731 | if ( pEntry->nWID == SC_WID_UNO_POS( 1200 + 10 ) ) | |||
5732 | { | |||
5733 | ScDocShell* pDocSh = GetDocShell(); | |||
5734 | if (pDocSh) | |||
5735 | { | |||
5736 | // GetMMRect converts using HMM_PER_TWIPS, like the DrawingLayer | |||
5737 | tools::Rectangle aMMRect(pDocSh->GetDocument().GetMMRect( | |||
5738 | aRange.aStart.Col(), aRange.aStart.Row(), | |||
5739 | aRange.aEnd.Col(), aRange.aEnd.Row(), aRange.aStart.Tab() )); | |||
5740 | awt::Point aPos( aMMRect.Left(), aMMRect.Top() ); | |||
5741 | rAny <<= aPos; | |||
5742 | } | |||
5743 | } | |||
5744 | else if ( pEntry->nWID == SC_WID_UNO_SIZE( 1200 + 11 ) ) | |||
5745 | { | |||
5746 | ScDocShell* pDocSh = GetDocShell(); | |||
5747 | if (pDocSh) | |||
5748 | { | |||
5749 | // GetMMRect converts using HMM_PER_TWIPS, like the DrawingLayer | |||
5750 | tools::Rectangle aMMRect = pDocSh->GetDocument().GetMMRect( | |||
5751 | aRange.aStart.Col(), aRange.aStart.Row(), | |||
5752 | aRange.aEnd.Col(), aRange.aEnd.Row(), aRange.aStart.Tab() ); | |||
5753 | Size aSize(aMMRect.GetSize()); | |||
5754 | awt::Size aAwtSize( aSize.Width(), aSize.Height() ); | |||
5755 | rAny <<= aAwtSize; | |||
5756 | } | |||
5757 | } | |||
5758 | else | |||
5759 | ScCellRangesBase::GetOnePropertyValue( pEntry, rAny ); | |||
5760 | } | |||
5761 | ||||
5762 | const SfxItemPropertyMap& ScCellRangeObj::GetItemPropertyMap() | |||
5763 | { | |||
5764 | return pRangePropSet->getPropertyMap(); | |||
5765 | } | |||
5766 | ||||
5767 | // XServiceInfo | |||
5768 | ||||
5769 | OUString SAL_CALL ScCellRangeObj::getImplementationName() | |||
5770 | { | |||
5771 | return "ScCellRangeObj"; | |||
5772 | } | |||
5773 | ||||
5774 | sal_Bool SAL_CALL ScCellRangeObj::supportsService( const OUString& rServiceName ) | |||
5775 | { | |||
5776 | return cppu::supportsService(this, rServiceName); | |||
5777 | } | |||
5778 | ||||
5779 | uno::Sequence<OUString> SAL_CALL ScCellRangeObj::getSupportedServiceNames() | |||
5780 | { | |||
5781 | return {SCSHEETCELLRANGE_SERVICE"com.sun.star.sheet.SheetCellRange", | |||
5782 | SCCELLRANGE_SERVICE"com.sun.star.table.CellRange", | |||
5783 | SCCELLPROPERTIES_SERVICE"com.sun.star.table.CellProperties", | |||
5784 | SCCHARPROPERTIES_SERVICE"com.sun.star.style.CharacterProperties", | |||
5785 | SCPARAPROPERTIES_SERVICE"com.sun.star.style.ParagraphProperties"}; | |||
5786 | } | |||
5787 | ||||
5788 | const SvxItemPropertySet* ScCellObj::GetEditPropertySet() | |||
5789 | { | |||
5790 | return lcl_GetEditPropertySet(); | |||
5791 | } | |||
5792 | ||||
5793 | const SfxItemPropertyMap& ScCellObj::GetCellPropertyMap() | |||
5794 | { | |||
5795 | return lcl_GetCellPropertySet()->getPropertyMap(); | |||
5796 | } | |||
5797 | ||||
5798 | ScCellObj::ScCellObj(ScDocShell* pDocSh, const ScAddress& rP) : | |||
5799 | ScCellRangeObj( pDocSh, ScRange(rP,rP) ), | |||
5800 | pCellPropSet( lcl_GetCellPropertySet() ), | |||
5801 | aCellPos( rP ), | |||
5802 | nActionLockCount( 0 ) | |||
5803 | { | |||
5804 | // pUnoText is allocated on demand (GetUnoText) | |||
5805 | // can't be aggregated because getString/setString is handled here | |||
5806 | } | |||
5807 | ||||
5808 | SvxUnoText& ScCellObj::GetUnoText() | |||
5809 | { | |||
5810 | if (!mxUnoText.is()) | |||
5811 | { | |||
5812 | mxUnoText.set(new ScCellTextObj(GetDocShell(), aCellPos)); | |||
5813 | if (nActionLockCount) | |||
5814 | { | |||
5815 | ScCellEditSource* pEditSource = | |||
5816 | static_cast<ScCellEditSource*> (mxUnoText->GetEditSource()); | |||
5817 | if (pEditSource) | |||
5818 | pEditSource->SetDoUpdateData(false); | |||
5819 | } | |||
5820 | } | |||
5821 | return *mxUnoText; | |||
5822 | } | |||
5823 | ||||
5824 | ScCellObj::~ScCellObj() | |||
5825 | { | |||
5826 | } | |||
5827 | ||||
5828 | void ScCellObj::RefChanged() | |||
5829 | { | |||
5830 | ScCellRangeObj::RefChanged(); | |||
5831 | ||||
5832 | const ScRangeList& rRanges = GetRangeList(); | |||
5833 | OSL_ENSURE(rRanges.size() == 1, "What ranges ?!?!")do { if (true && (!(rRanges.size() == 1))) { sal_detail_logFormat ((SAL_DETAIL_LOG_LEVEL_WARN), ("legacy.osl"), ("/home/maarten/src/libreoffice/core/sc/source/ui/unoobj/cellsuno.cxx" ":" "5833" ": "), "%s", "What ranges ?!?!"); } } while (false ); | |||
5834 | if ( !rRanges.empty() ) | |||
5835 | { | |||
5836 | aCellPos = rRanges[ 0 ].aStart; | |||
5837 | } | |||
5838 | } | |||
5839 | ||||
5840 | uno::Any SAL_CALL ScCellObj::queryInterface( const uno::Type& rType ) | |||
5841 | { | |||
5842 | SC_QUERYINTERFACE( table::XCell )if (rType == cppu::UnoType<table::XCell>::get()) { return uno::makeAny(uno::Reference<table::XCell>(this)); } | |||
5843 | SC_QUERYINTERFACE( table::XCell2 )if (rType == cppu::UnoType<table::XCell2>::get()) { return uno::makeAny(uno::Reference<table::XCell2>(this)); } | |||
5844 | SC_QUERYINTERFACE( sheet::XFormulaTokens )if (rType == cppu::UnoType<sheet::XFormulaTokens>::get( )) { return uno::makeAny(uno::Reference<sheet::XFormulaTokens >(this)); } | |||
5845 | SC_QUERYINTERFACE( sheet::XCellAddressable )if (rType == cppu::UnoType<sheet::XCellAddressable>::get ()) { return uno::makeAny(uno::Reference<sheet::XCellAddressable >(this)); } | |||
5846 | SC_QUERYINTERFACE( text::XText )if (rType == cppu::UnoType<text::XText>::get()) { return uno::makeAny(uno::Reference<text::XText>(this)); } | |||
5847 | SC_QUERYINTERFACE( text::XSimpleText )if (rType == cppu::UnoType<text::XSimpleText>::get()) { return uno::makeAny(uno::Reference<text::XSimpleText>( this)); } | |||
5848 | SC_QUERYINTERFACE( text::XTextRange )if (rType == cppu::UnoType<text::XTextRange>::get()) { return uno::makeAny(uno::Reference<text::XTextRange>(this)); } | |||
5849 | SC_QUERYINTERFACE( container::XEnumerationAccess )if (rType == cppu::UnoType<container::XEnumerationAccess> ::get()) { return uno::makeAny(uno::Reference<container::XEnumerationAccess >(this)); } | |||
5850 | SC_QUERYINTERFACE( container::XElementAccess )if (rType == cppu::UnoType<container::XElementAccess>:: get()) { return uno::makeAny(uno::Reference<container::XElementAccess >(this)); } | |||
5851 | SC_QUERYINTERFACE( sheet::XSheetAnnotationAnchor )if (rType == cppu::UnoType<sheet::XSheetAnnotationAnchor> ::get()) { return uno::makeAny(uno::Reference<sheet::XSheetAnnotationAnchor >(this)); } | |||
5852 | SC_QUERYINTERFACE( text::XTextFieldsSupplier )if (rType == cppu::UnoType<text::XTextFieldsSupplier>:: get()) { return uno::makeAny(uno::Reference<text::XTextFieldsSupplier >(this)); } | |||
5853 | SC_QUERYINTERFACE( document::XActionLockable )if (rType == cppu::UnoType<document::XActionLockable>:: get()) { return uno::makeAny(uno::Reference<document::XActionLockable >(this)); } | |||
5854 | ||||
5855 | return ScCellRangeObj::queryInterface( rType ); | |||
5856 | } | |||
5857 | ||||
5858 | void SAL_CALL ScCellObj::acquire() throw() | |||
5859 | { | |||
5860 | ScCellRangeObj::acquire(); | |||
5861 | } | |||
5862 | ||||
5863 | void SAL_CALL ScCellObj::release() throw() | |||
5864 | { | |||
5865 | ScCellRangeObj::release(); | |||
5866 | } | |||
5867 | ||||
5868 | uno::Sequence<uno::Type> SAL_CALL ScCellObj::getTypes() | |||
5869 | { | |||
5870 | static const uno::Sequence<uno::Type> aTypes = comphelper::concatSequences( | |||
5871 | ScCellRangeObj::getTypes(), | |||
5872 | uno::Sequence<uno::Type> | |||
5873 | { | |||
5874 | cppu::UnoType<table::XCell>::get(), | |||
5875 | cppu::UnoType<sheet::XCellAddressable>::get(), | |||
5876 | cppu::UnoType<text::XText>::get(), | |||
5877 | cppu::UnoType<container::XEnumerationAccess>::get(), | |||
5878 | cppu::UnoType<sheet::XSheetAnnotationAnchor>::get(), | |||
5879 | cppu::UnoType<text::XTextFieldsSupplier>::get(), | |||
5880 | cppu::UnoType<document::XActionLockable>::get(), | |||
5881 | cppu::UnoType<sheet::XFormulaTokens>::get(), | |||
5882 | cppu::UnoType<table::XCell2>::get() | |||
5883 | } ); | |||
5884 | return aTypes; | |||
5885 | } | |||
5886 | ||||
5887 | uno::Sequence<sal_Int8> SAL_CALL ScCellObj::getImplementationId() | |||
5888 | { | |||
5889 | return css::uno::Sequence<sal_Int8>(); | |||
5890 | } | |||
5891 | ||||
5892 | // helper methods | |||
5893 | ||||
5894 | OUString ScCellObj::GetInputString_Impl(bool bEnglish) const // for getFormula / FormulaLocal | |||
5895 | { | |||
5896 | if (GetDocShell()) | |||
5897 | return lcl_GetInputString( GetDocShell()->GetDocument(), aCellPos, bEnglish ); | |||
5898 | return OUString(); | |||
5899 | } | |||
5900 | ||||
5901 | OUString ScCellObj::GetOutputString_Impl() const | |||
5902 | { | |||
5903 | ScDocShell* pDocSh = GetDocShell(); | |||
5904 | OUString aVal; | |||
5905 | if ( pDocSh ) | |||
5906 | { | |||
5907 | ScDocument& rDoc = pDocSh->GetDocument(); | |||
5908 | ScRefCellValue aCell(rDoc, aCellPos); | |||
5909 | ||||
5910 | aVal = ScCellFormat::GetOutputString(rDoc, aCellPos, aCell); | |||
5911 | } | |||
5912 | return aVal; | |||
5913 | } | |||
5914 | ||||
5915 | void ScCellObj::SetString_Impl(const OUString& rString, bool bInterpret, bool bEnglish) | |||
5916 | { | |||
5917 | ScDocShell* pDocSh = GetDocShell(); | |||
5918 | if ( pDocSh ) | |||
5919 | { | |||
5920 | // GRAM_API for API compatibility. | |||
5921 | (void)pDocSh->GetDocFunc().SetCellText( | |||
5922 | aCellPos, rString, bInterpret, bEnglish, true, formula::FormulaGrammar::GRAM_API ); | |||
5923 | } | |||
5924 | } | |||
5925 | ||||
5926 | double ScCellObj::GetValue_Impl() const | |||
5927 | { | |||
5928 | ScDocShell* pDocSh = GetDocShell(); | |||
5929 | if ( pDocSh ) | |||
5930 | return pDocSh->GetDocument().GetValue( aCellPos ); | |||
5931 | ||||
5932 | return 0.0; | |||
5933 | } | |||
5934 | ||||
5935 | void ScCellObj::SetValue_Impl(double fValue) | |||
5936 | { | |||
5937 | ScDocShell* pDocSh = GetDocShell(); | |||
5938 | if ( pDocSh ) | |||
5939 | pDocSh->GetDocFunc().SetValueCell(aCellPos, fValue, false); | |||
5940 | } | |||
5941 | ||||
5942 | // only for XML import | |||
5943 | ||||
5944 | void ScCellObj::InputEnglishString( const OUString& rText ) | |||
5945 | { | |||
5946 | // This is like a mixture of setFormula and property FormulaLocal: | |||
5947 | // The cell's number format is checked for "text", a new cell format may be set, | |||
5948 | // but all parsing is in English. | |||
5949 | ||||
5950 | ScDocShell* pDocSh = GetDocShell(); | |||
5951 | if (!pDocSh) | |||
5952 | return; | |||
5953 | ||||
5954 | ScDocument& rDoc = pDocSh->GetDocument(); | |||
5955 | SvNumberFormatter* pFormatter = rDoc.GetFormatTable(); | |||
5956 | sal_uInt32 nOldFormat = rDoc.GetNumberFormat( aCellPos ); | |||
5957 | if (pFormatter->GetType(nOldFormat) == SvNumFormatType::TEXT) | |||
5958 | { | |||
5959 | SetString_Impl(rText, false, false); // text cell | |||
5960 | return; | |||
5961 | } | |||
5962 | ||||
5963 | ScDocFunc &rFunc = pDocSh->GetDocFunc(); | |||
5964 | ||||
5965 | ScInputStringType aRes = | |||
5966 | ScStringUtil::parseInputString(*pFormatter, rText, LANGUAGE_ENGLISH_USLanguageType(0x0409)); | |||
5967 | ||||
5968 | if (aRes.meType != ScInputStringType::Unknown) | |||
5969 | { | |||
5970 | if ((nOldFormat % SV_COUNTRY_LANGUAGE_OFFSET10000) == 0 && aRes.mnFormatType != SvNumFormatType::ALL) | |||
5971 | { | |||
5972 | // apply a format for the recognized type and the old format's language | |||
5973 | sal_uInt32 nNewFormat = ScGlobal::GetStandardFormat(*pFormatter, nOldFormat, aRes.mnFormatType); | |||
5974 | if (nNewFormat != nOldFormat) | |||
5975 | { | |||
5976 | ScPatternAttr aPattern( rDoc.GetPool() ); | |||
5977 | aPattern.GetItemSet().Put( SfxUInt32Item( ATTR_VALUE_FORMAT, nNewFormat ) ); | |||
5978 | // ATTR_LANGUAGE_FORMAT remains unchanged | |||
5979 | rFunc.ApplyAttributes( *GetMarkData(), aPattern, true ); | |||
5980 | } | |||
5981 | } | |||
5982 | } | |||
5983 | switch (aRes.meType) | |||
5984 | { | |||
5985 | case ScInputStringType::Formula: | |||
5986 | rFunc.SetFormulaCell( | |||
5987 | aCellPos, | |||
5988 | new ScFormulaCell(rDoc, aCellPos, aRes.maText, formula::FormulaGrammar::GRAM_API), | |||
5989 | false); | |||
5990 | break; | |||
5991 | case ScInputStringType::Number: | |||
5992 | rFunc.SetValueCell(aCellPos, aRes.mfValue, false); | |||
5993 | break; | |||
5994 | case ScInputStringType::Text: | |||
5995 | rFunc.SetStringOrEditCell(aCellPos, aRes.maText, false); | |||
5996 | break; | |||
5997 | default: | |||
5998 | SetString_Impl(rText, false, false); // probably empty string | |||
5999 | } | |||
6000 | } | |||
6001 | ||||
6002 | // XText | |||
6003 | ||||
6004 | uno::Reference<text::XTextCursor> SAL_CALL ScCellObj::createTextCursor() | |||
6005 | { | |||
6006 | SolarMutexGuard aGuard; | |||
6007 | return new ScCellTextCursor( *this ); | |||
6008 | } | |||
6009 | ||||
6010 | uno::Reference<text::XTextCursor> SAL_CALL ScCellObj::createTextCursorByRange( | |||
6011 | const uno::Reference<text::XTextRange>& aTextPosition ) | |||
6012 | { | |||
6013 | SolarMutexGuard aGuard; | |||
6014 | SvxUnoTextCursor* pCursor = new ScCellTextCursor( *this ); | |||
6015 | uno::Reference<text::XTextCursor> xCursor(pCursor); | |||
6016 | ||||
6017 | SvxUnoTextRangeBase* pRange = comphelper::getUnoTunnelImplementation<SvxUnoTextRangeBase>( aTextPosition ); | |||
6018 | if(pRange) | |||
6019 | pCursor->SetSelection( pRange->GetSelection() ); | |||
6020 | else | |||
6021 | { | |||
6022 | ScCellTextCursor* pOther = comphelper::getUnoTunnelImplementation<ScCellTextCursor>( aTextPosition ); | |||
6023 | if(!pOther) | |||
6024 | throw uno::RuntimeException(); | |||
6025 | ||||
6026 | pCursor->SetSelection( pOther->GetSelection() ); | |||
6027 | ||||
6028 | } | |||
6029 | ||||
6030 | return xCursor; | |||
6031 | } | |||
6032 | ||||
6033 | OUString SAL_CALL ScCellObj::getString() | |||
6034 | { | |||
6035 | SolarMutexGuard aGuard; | |||
6036 | return GetOutputString_Impl(); | |||
6037 | } | |||
6038 | ||||
6039 | void SAL_CALL ScCellObj::setString( const OUString& aText ) | |||
6040 | { | |||
6041 | SolarMutexGuard aGuard; | |||
6042 | SetString_Impl(aText, false, false); // always text | |||
6043 | ||||
6044 | // don't create pUnoText here if not there | |||
6045 | if (mxUnoText.is()) | |||
6046 | mxUnoText->SetSelection(ESelection( 0,0, 0,aText.getLength() )); | |||
6047 | } | |||
6048 | ||||
6049 | void SAL_CALL ScCellObj::insertString( const uno::Reference<text::XTextRange>& xRange, | |||
6050 | const OUString& aString, sal_Bool bAbsorb ) | |||
6051 | { | |||
6052 | // special handling for ScCellTextCursor is no longer needed, | |||
6053 | // SvxUnoText::insertString checks for SvxUnoTextRangeBase instead of SvxUnoTextRange | |||
6054 | ||||
6055 | SolarMutexGuard aGuard; | |||
6056 | GetUnoText().insertString(xRange, aString, bAbsorb); | |||
6057 | } | |||
6058 | ||||
6059 | void SAL_CALL ScCellObj::insertControlCharacter( const uno::Reference<text::XTextRange>& xRange, | |||
6060 | sal_Int16 nControlCharacter, sal_Bool bAbsorb ) | |||
6061 | { | |||
6062 | SolarMutexGuard aGuard; | |||
6063 | GetUnoText().insertControlCharacter(xRange, nControlCharacter, bAbsorb); | |||
6064 | } | |||
6065 | ||||
6066 | void SAL_CALL ScCellObj::insertTextContent( const uno::Reference<text::XTextRange >& xRange, | |||
6067 | const uno::Reference<text::XTextContent >& xContent, | |||
6068 | sal_Bool bAbsorb ) | |||
6069 | { | |||
6070 | SolarMutexGuard aGuard; | |||
6071 | ScDocShell* pDocSh = GetDocShell(); | |||
6072 | if ( pDocSh && xContent.is() ) | |||
6073 | { | |||
6074 | ScEditFieldObj* pCellField = comphelper::getUnoTunnelImplementation<ScEditFieldObj>(xContent); | |||
6075 | SvxUnoTextRangeBase* pTextRange = comphelper::getUnoTunnelImplementation<ScCellTextCursor>( xRange ); | |||
6076 | ||||
6077 | if ( pCellField && !pCellField->IsInserted() && pTextRange ) | |||
6078 | { | |||
6079 | SvxEditSource* pEditSource = pTextRange->GetEditSource(); | |||
6080 | ESelection aSelection(pTextRange->GetSelection()); | |||
6081 | ||||
6082 | if (!bAbsorb) | |||
6083 | { | |||
6084 | // do not replace -> append | |||
6085 | aSelection.Adjust(); | |||
6086 | aSelection.nStartPara = aSelection.nEndPara; | |||
6087 | aSelection.nStartPos = aSelection.nEndPos; | |||
6088 | } | |||
6089 | ||||
6090 | if (pCellField->GetFieldType() == text::textfield::Type::TABLE) | |||
6091 | pCellField->setPropertyValue(SC_UNONAME_TABLEPOS"TablePosition", uno::makeAny<sal_Int32>(aCellPos.Tab())); | |||
6092 | ||||
6093 | SvxFieldItem aItem = pCellField->CreateFieldItem(); | |||
6094 | SvxTextForwarder* pForwarder = pEditSource->GetTextForwarder(); | |||
6095 | pForwarder->QuickInsertField( aItem, aSelection ); | |||
6096 | pEditSource->UpdateData(); | |||
6097 | ||||
6098 | // new selection: a digit | |||
6099 | aSelection.Adjust(); | |||
6100 | aSelection.nEndPara = aSelection.nStartPara; | |||
6101 | aSelection.nEndPos = aSelection.nStartPos + 1; | |||
6102 | uno::Reference<text::XTextRange> xParent(this); | |||
6103 | pCellField->InitDoc( | |||
6104 | xParent, std::make_unique<ScCellEditSource>(pDocSh, aCellPos), aSelection); | |||
6105 | ||||
6106 | // for bAbsorb=FALSE, the new selection must be behind the inserted content | |||
6107 | // (the xml filter relies on this) | |||
6108 | if (!bAbsorb) | |||
6109 | aSelection.nStartPos = aSelection.nEndPos; | |||
6110 | ||||
6111 | pTextRange->SetSelection( aSelection ); | |||
6112 | ||||
6113 | return; | |||
6114 | } | |||
6115 | } | |||
6116 | GetUnoText().insertTextContent(xRange, xContent, bAbsorb); | |||
6117 | } | |||
6118 | ||||
6119 | void SAL_CALL ScCellObj::removeTextContent( const uno::Reference<text::XTextContent>& xContent ) | |||
6120 | { | |||
6121 | SolarMutexGuard aGuard; | |||
6122 | if ( xContent.is() ) | |||
6123 | { | |||
6124 | ScEditFieldObj* pCellField = comphelper::getUnoTunnelImplementation<ScEditFieldObj>(xContent); | |||
6125 | if ( pCellField && pCellField->IsInserted() ) | |||
6126 | { | |||
6127 | //! Check if field is in this cell | |||
6128 | pCellField->DeleteField(); | |||
6129 | return; | |||
6130 | } | |||
6131 | } | |||
6132 | GetUnoText().removeTextContent(xContent); | |||
6133 | } | |||
6134 | ||||
6135 | uno::Reference<text::XText> SAL_CALL ScCellObj::getText() | |||
6136 | { | |||
6137 | return this; | |||
6138 | } | |||
6139 | ||||
6140 | uno::Reference<text::XTextRange> SAL_CALL ScCellObj::getStart() | |||
6141 | { | |||
6142 | SolarMutexGuard aGuard; | |||
6143 | return GetUnoText().getStart(); | |||
6144 | } | |||
6145 | ||||
6146 | uno::Reference<text::XTextRange> SAL_CALL ScCellObj::getEnd() | |||
6147 | { | |||
6148 | SolarMutexGuard aGuard; | |||
6149 | return GetUnoText().getEnd(); | |||
6150 | } | |||
6151 | ||||
6152 | uno::Reference<container::XEnumeration> SAL_CALL ScCellObj::createEnumeration() | |||
6153 | { | |||
6154 | SolarMutexGuard aGuard; | |||
6155 | return GetUnoText().createEnumeration(); | |||
6156 | } | |||
6157 | ||||
6158 | uno::Type SAL_CALL ScCellObj::getElementType() | |||
6159 | { | |||
6160 | SolarMutexGuard aGuard; | |||
6161 | return GetUnoText().getElementType(); | |||
6162 | } | |||
6163 | ||||
6164 | sal_Bool SAL_CALL ScCellObj::hasElements() | |||
6165 | { | |||
6166 | SolarMutexGuard aGuard; | |||
6167 | return GetUnoText().hasElements(); | |||
6168 | } | |||
6169 | ||||
6170 | // XCell | |||
6171 | ||||
6172 | OUString SAL_CALL ScCellObj::getFormula() | |||
6173 | { | |||
6174 | SolarMutexGuard aGuard; | |||
6175 | return GetInputString_Impl( true /* English */ ); | |||
6176 | } | |||
6177 | ||||
6178 | void SAL_CALL ScCellObj::setFormula( const OUString& aFormula ) | |||
6179 | { | |||
6180 | SolarMutexGuard aGuard; | |||
6181 | SetString_Impl(aFormula, true, true); // Interpret as English | |||
6182 | } | |||
6183 | ||||
6184 | double SAL_CALL ScCellObj::getValue() | |||
6185 | { | |||
6186 | SolarMutexGuard aGuard; | |||
6187 | return GetValue_Impl(); | |||
6188 | } | |||
6189 | ||||
6190 | void SAL_CALL ScCellObj::setValue( double nValue ) | |||
6191 | { | |||
6192 | SolarMutexGuard aGuard; | |||
6193 | SetValue_Impl(nValue); | |||
6194 | } | |||
6195 | ||||
6196 | void SAL_CALL ScCellObj::setFormulaString( const OUString& aFormula) | |||
6197 | { | |||
6198 | SolarMutexGuard aGuard; | |||
6199 | ScDocShell *pDocSh = GetDocShell(); | |||
6200 | if( pDocSh ) | |||
6201 | { | |||
6202 | ScFormulaCell* pCell = new ScFormulaCell( pDocSh->GetDocument(), aCellPos ); | |||
6203 | pCell->SetHybridFormula( aFormula, formula::FormulaGrammar::GRAM_NATIVE ); | |||
6204 | pDocSh->GetDocFunc().SetFormulaCell(aCellPos, pCell, false); | |||
6205 | } | |||
6206 | } | |||
6207 | void SAL_CALL ScCellObj::setFormulaResult( double nValue ) | |||
6208 | { | |||
6209 | SolarMutexGuard aGuard; | |||
6210 | ScDocShell* pDocSh = GetDocShell(); | |||
6211 | if (pDocSh) | |||
6212 | { | |||
6213 | ScRefCellValue aCell(pDocSh->GetDocument(), aCellPos); | |||
6214 | if (aCell.meType == CELLTYPE_FORMULA) | |||
6215 | { | |||
6216 | ScFormulaCell* pCell = aCell.mpFormula; | |||
6217 | pCell->SetHybridDouble( nValue ); | |||
6218 | pCell->ResetDirty(); | |||
6219 | pCell->SetChanged(false); | |||
6220 | } | |||
6221 | } | |||
6222 | } | |||
6223 | ||||
6224 | table::CellContentType SAL_CALL ScCellObj::getType() | |||
6225 | { | |||
6226 | SolarMutexGuard aGuard; | |||
6227 | table::CellContentType eRet = table::CellContentType_EMPTY; | |||
6228 | ScDocShell* pDocSh = GetDocShell(); | |||
6229 | if (pDocSh) | |||
6230 | { | |||
6231 | CellType eCalcType = pDocSh->GetDocument().GetCellType( aCellPos ); | |||
6232 | switch (eCalcType) | |||
6233 | { | |||
6234 | case CELLTYPE_VALUE: | |||
6235 | eRet = table::CellContentType_VALUE; | |||
6236 | break; | |||
6237 | case CELLTYPE_STRING: | |||
6238 | case CELLTYPE_EDIT: | |||
6239 | eRet = table::CellContentType_TEXT; | |||
6240 | break; | |||
6241 | case CELLTYPE_FORMULA: | |||
6242 | eRet = table::CellContentType_FORMULA; | |||
6243 | break; | |||
6244 | default: | |||
6245 | eRet = table::CellContentType_EMPTY; | |||
6246 | } | |||
6247 | } | |||
6248 | else | |||
6249 | { | |||
6250 | OSL_FAIL("no DocShell")do { if (true && (((sal_Bool)1))) { sal_detail_logFormat ((SAL_DETAIL_LOG_LEVEL_WARN), ("legacy.osl"), ("/home/maarten/src/libreoffice/core/sc/source/ui/unoobj/cellsuno.cxx" ":" "6250" ": "), "%s", "no DocShell"); } } while (false); //! Exception or so? | |||
6251 | } | |||
6252 | ||||
6253 | return eRet; | |||
6254 | } | |||
6255 | ||||
6256 | sal_Int32 ScCellObj::GetResultType_Impl() const | |||
6257 | { | |||
6258 | SolarMutexGuard aGuard; | |||
6259 | sal_Int32 eRet = sheet::FormulaResult::STRING; | |||
6260 | ScDocShell* pDocSh = GetDocShell(); | |||
6261 | if (pDocSh) | |||
6262 | { | |||
6263 | if (pDocSh->GetDocument().GetCellType(aCellPos) == CELLTYPE_FORMULA) | |||
6264 | { | |||
6265 | ScFormulaCell* pFCell = pDocSh->GetDocument().GetFormulaCell(aCellPos); | |||
6266 | if (!pFCell) | |||
6267 | { | |||
6268 | // should throw instead of default string? | |||
6269 | } | |||
6270 | else if (pFCell->GetErrCode() != FormulaError::NONE ) | |||
6271 | { | |||
6272 | eRet = sheet::FormulaResult::ERROR; | |||
6273 | } | |||
6274 | else if (pFCell->IsValue()) | |||
6275 | { | |||
6276 | eRet = sheet::FormulaResult::VALUE; | |||
6277 | } | |||
6278 | else | |||
6279 | { | |||
6280 | eRet = sheet::FormulaResult::STRING; | |||
6281 | } | |||
6282 | } | |||
6283 | } | |||
6284 | else | |||
6285 | { | |||
6286 | OSL_FAIL("no DocShell")do { if (true && (((sal_Bool)1))) { sal_detail_logFormat ((SAL_DETAIL_LOG_LEVEL_WARN), ("legacy.osl"), ("/home/maarten/src/libreoffice/core/sc/source/ui/unoobj/cellsuno.cxx" ":" "6286" ": "), "%s", "no DocShell"); } } while (false); | |||
6287 | } | |||
6288 | ||||
6289 | return eRet; | |||
6290 | } | |||
6291 | ||||
6292 | table::CellContentType ScCellObj::GetContentType_Impl() | |||
6293 | { | |||
6294 | ScDocShell* pDocSh = GetDocShell(); | |||
6295 | if ( pDocSh ) | |||
6296 | { | |||
6297 | ScRefCellValue aCell(pDocSh->GetDocument(), aCellPos); | |||
6298 | if (aCell.meType == CELLTYPE_FORMULA) | |||
6299 | { | |||
6300 | bool bValue = aCell.mpFormula->IsValue(); | |||
6301 | return bValue ? table::CellContentType_VALUE : table::CellContentType_TEXT; | |||
6302 | } | |||
6303 | } | |||
6304 | return getType(); | |||
6305 | } | |||
6306 | ||||
6307 | sal_Int32 SAL_CALL ScCellObj::getError() | |||
6308 | { | |||
6309 | SolarMutexGuard aGuard; | |||
6310 | ScDocShell* pDocSh = GetDocShell(); | |||
6311 | if (!pDocSh) | |||
6312 | { | |||
6313 | OSL_FAIL("no DocShell")do { if (true && (((sal_Bool)1))) { sal_detail_logFormat ((SAL_DETAIL_LOG_LEVEL_WARN), ("legacy.osl"), ("/home/maarten/src/libreoffice/core/sc/source/ui/unoobj/cellsuno.cxx" ":" "6313" ": "), "%s", "no DocShell"); } } while (false); //! Exception or so? | |||
6314 | return 0; | |||
6315 | } | |||
6316 | ||||
6317 | FormulaError nError = FormulaError::NONE; | |||
6318 | ScRefCellValue aCell(pDocSh->GetDocument(), aCellPos); | |||
6319 | if (aCell.meType == CELLTYPE_FORMULA) | |||
6320 | nError = aCell.mpFormula->GetErrCode(); | |||
6321 | ||||
6322 | return static_cast<sal_Int32>(nError); | |||
6323 | } | |||
6324 | ||||
6325 | // XFormulaTokens | |||
6326 | ||||
6327 | uno::Sequence<sheet::FormulaToken> SAL_CALL ScCellObj::getTokens() | |||
6328 | { | |||
6329 | SolarMutexGuard aGuard; | |||
6330 | uno::Sequence<sheet::FormulaToken> aSequence; | |||
6331 | ScDocShell* pDocSh = GetDocShell(); | |||
6332 | if (!pDocSh) | |||
6333 | return aSequence; | |||
6334 | ||||
6335 | ScDocument& rDoc = pDocSh->GetDocument(); | |||
6336 | ScRefCellValue aCell(rDoc, aCellPos); | |||
6337 | if (aCell.meType == CELLTYPE_FORMULA) | |||
6338 | { | |||
6339 | ScTokenArray* pTokenArray = aCell.mpFormula->GetCode(); | |||
6340 | if (pTokenArray) | |||
6341 | ScTokenConversion::ConvertToTokenSequence(rDoc, aSequence, *pTokenArray); | |||
6342 | } | |||
6343 | return aSequence; | |||
6344 | } | |||
6345 | ||||
6346 | void SAL_CALL ScCellObj::setTokens( const uno::Sequence<sheet::FormulaToken>& rTokens ) | |||
6347 | { | |||
6348 | SolarMutexGuard aGuard; | |||
6349 | ScDocShell* pDocSh = GetDocShell(); | |||
6350 | if ( pDocSh ) | |||
6351 | { | |||
6352 | ScDocument& rDoc = pDocSh->GetDocument(); | |||
6353 | ScTokenArray aTokenArray(rDoc); | |||
6354 | (void)ScTokenConversion::ConvertToTokenArray( rDoc, aTokenArray, rTokens ); | |||
6355 | ||||
6356 | ScFormulaCell* pNewCell = new ScFormulaCell(rDoc, aCellPos, aTokenArray); | |||
6357 | (void)pDocSh->GetDocFunc().SetFormulaCell(aCellPos, pNewCell, false); | |||
6358 | } | |||
6359 | } | |||
6360 | ||||
6361 | // XCellAddressable | |||
6362 | ||||
6363 | table::CellAddress SAL_CALL ScCellObj::getCellAddress() | |||
6364 | { | |||
6365 | SolarMutexGuard aGuard; | |||
6366 | table::CellAddress aAdr; | |||
6367 | aAdr.Sheet = aCellPos.Tab(); | |||
6368 | aAdr.Column = aCellPos.Col(); | |||
6369 | aAdr.Row = aCellPos.Row(); | |||
6370 | return aAdr; | |||
6371 | } | |||
6372 | ||||
6373 | // XSheetAnnotationAnchor | |||
6374 | ||||
6375 | uno::Reference<sheet::XSheetAnnotation> SAL_CALL ScCellObj::getAnnotation() | |||
6376 | { | |||
6377 | SolarMutexGuard aGuard; | |||
6378 | ScDocShell* pDocSh = GetDocShell(); | |||
6379 | if ( pDocSh ) | |||
6380 | return new ScAnnotationObj( pDocSh, aCellPos ); | |||
6381 | ||||
6382 | OSL_FAIL("getAnnotation without DocShell")do { if (true && (((sal_Bool)1))) { sal_detail_logFormat ((SAL_DETAIL_LOG_LEVEL_WARN), ("legacy.osl"), ("/home/maarten/src/libreoffice/core/sc/source/ui/unoobj/cellsuno.cxx" ":" "6382" ": "), "%s", "getAnnotation without DocShell"); } } while (false); | |||
6383 | return nullptr; | |||
6384 | } | |||
6385 | ||||
6386 | // XFieldTypesSupplier | |||
6387 | ||||
6388 | uno::Reference<container::XEnumerationAccess> SAL_CALL ScCellObj::getTextFields() | |||
6389 | { | |||
6390 | SolarMutexGuard aGuard; | |||
6391 | ScDocShell* pDocSh = GetDocShell(); | |||
6392 | if ( pDocSh ) | |||
6393 | { | |||
6394 | uno::Reference<text::XTextRange> xContent(this); | |||
6395 | return new ScCellFieldsObj(xContent, pDocSh, aCellPos); | |||
6396 | } | |||
6397 | ||||
6398 | return nullptr; | |||
6399 | } | |||
6400 | ||||
6401 | uno::Reference<container::XNameAccess> SAL_CALL ScCellObj::getTextFieldMasters() | |||
6402 | { | |||
6403 | // there is no such thing in Calc (?) | |||
6404 | return nullptr; | |||
6405 | } | |||
6406 | ||||
6407 | // XPropertySet extended for Cell-Properties | |||
6408 | ||||
6409 | uno::Reference<beans::XPropertySetInfo> SAL_CALL ScCellObj::getPropertySetInfo() | |||
6410 | { | |||
6411 | SolarMutexGuard aGuard; | |||
6412 | static uno::Reference<beans::XPropertySetInfo> aRef( | |||
6413 | new SfxItemPropertySetInfo( pCellPropSet->getPropertyMap() )); | |||
6414 | return aRef; | |||
6415 | } | |||
6416 | ||||
6417 | void ScCellObj::SetOnePropertyValue( const SfxItemPropertySimpleEntry* pEntry, const uno::Any& aValue ) | |||
6418 | { | |||
6419 | if ( !pEntry ) | |||
6420 | return; | |||
6421 | ||||
6422 | if ( pEntry->nWID == SC_WID_UNO_FORMLOC( 1200 + 12 ) ) | |||
6423 | { | |||
6424 | OUString aStrVal; | |||
6425 | aValue >>= aStrVal; | |||
6426 | SetString_Impl(aStrVal, true, false); // interpret locally | |||
6427 | } | |||
6428 | else if ( pEntry->nWID == SC_WID_UNO_FORMRT( 1200 + 13 ) || pEntry->nWID == SC_WID_UNO_FORMRT2( 1200 + 46 ) | |||
6429 | || pEntry->nWID == SC_WID_UNO_CELLCONTENTTYPE( 1200 + 47 ) ) | |||
6430 | { | |||
6431 | // Read-Only | |||
6432 | //! Exception or so... | |||
6433 | } | |||
6434 | else | |||
6435 | ScCellRangeObj::SetOnePropertyValue( pEntry, aValue ); | |||
6436 | } | |||
6437 | ||||
6438 | void ScCellObj::GetOnePropertyValue( const SfxItemPropertySimpleEntry* pEntry, uno::Any& rAny ) | |||
6439 | { | |||
6440 | if ( !pEntry ) | |||
6441 | return; | |||
6442 | ||||
6443 | if ( pEntry->nWID == SC_WID_UNO_FORMLOC( 1200 + 12 ) ) | |||
6444 | { | |||
6445 | // sal_False = local | |||
6446 | rAny <<= GetInputString_Impl(false); | |||
6447 | } | |||
6448 | else if ( pEntry->nWID == SC_WID_UNO_FORMRT2( 1200 + 46 ) ) | |||
6449 | { | |||
6450 | sal_Int32 eType = GetResultType_Impl(); | |||
6451 | rAny <<= eType; | |||
6452 | } | |||
6453 | else if ( pEntry->nWID == SC_WID_UNO_CELLCONTENTTYPE( 1200 + 47 ) || pEntry->nWID == SC_WID_UNO_FORMRT( 1200 + 13 ) ) | |||
6454 | { | |||
6455 | table::CellContentType eType = GetContentType_Impl(); | |||
6456 | rAny <<= eType; | |||
6457 | } | |||
6458 | else | |||
6459 | ScCellRangeObj::GetOnePropertyValue(pEntry, rAny); | |||
6460 | } | |||
6461 | ||||
6462 | const SfxItemPropertyMap& ScCellObj::GetItemPropertyMap() | |||
6463 | { | |||
6464 | return pCellPropSet->getPropertyMap(); | |||
6465 | } | |||
6466 | ||||
6467 | // XServiceInfo | |||
6468 | ||||
6469 | OUString SAL_CALL ScCellObj::getImplementationName() | |||
6470 | { | |||
6471 | return "ScCellObj"; | |||
6472 | } | |||
6473 | ||||
6474 | sal_Bool SAL_CALL ScCellObj::supportsService( const OUString& rServiceName ) | |||
6475 | { | |||
6476 | return cppu::supportsService(this, rServiceName); | |||
6477 | } | |||
6478 | ||||
6479 | uno::Sequence<OUString> SAL_CALL ScCellObj::getSupportedServiceNames() | |||
6480 | { | |||
6481 | return {SCSHEETCELL_SERVICE"com.sun.star.sheet.SheetCell", | |||
6482 | SCCELL_SERVICE"com.sun.star.table.Cell", | |||
6483 | SCCELLPROPERTIES_SERVICE"com.sun.star.table.CellProperties", | |||
6484 | SCCHARPROPERTIES_SERVICE"com.sun.star.style.CharacterProperties", | |||
6485 | SCPARAPROPERTIES_SERVICE"com.sun.star.style.ParagraphProperties", | |||
6486 | SCSHEETCELLRANGE_SERVICE"com.sun.star.sheet.SheetCellRange", | |||
6487 | SCCELLRANGE_SERVICE"com.sun.star.table.CellRange"}; | |||
6488 | } | |||
6489 | ||||
6490 | // XActionLockable | |||
6491 | ||||
6492 | sal_Bool SAL_CALL ScCellObj::isActionLocked() | |||
6493 | { | |||
6494 | SolarMutexGuard aGuard; | |||
6495 | return nActionLockCount != 0; | |||
6496 | } | |||
6497 | ||||
6498 | void SAL_CALL ScCellObj::addActionLock() | |||
6499 | { | |||
6500 | SolarMutexGuard aGuard; | |||
6501 | if (!nActionLockCount) | |||
6502 | { | |||
6503 | if (mxUnoText.is()) | |||
6504 | { | |||
6505 | ScCellEditSource* pEditSource = | |||
6506 | static_cast<ScCellEditSource*> (mxUnoText->GetEditSource()); | |||
6507 | if (pEditSource) | |||
6508 | pEditSource->SetDoUpdateData(false); | |||
6509 | } | |||
6510 | } | |||
6511 | nActionLockCount++; | |||
6512 | } | |||
6513 | ||||
6514 | void SAL_CALL ScCellObj::removeActionLock() | |||
6515 | { | |||
6516 | SolarMutexGuard aGuard; | |||
6517 | if (nActionLockCount <= 0) | |||
6518 | return; | |||
6519 | ||||
6520 | nActionLockCount--; | |||
6521 | if (nActionLockCount) | |||
6522 | return; | |||
6523 | ||||
6524 | if (mxUnoText.is()) | |||
6525 | { | |||
6526 | ScCellEditSource* pEditSource = | |||
6527 | static_cast<ScCellEditSource*> (mxUnoText->GetEditSource()); | |||
6528 | if (pEditSource) | |||
6529 | { | |||
6530 | pEditSource->SetDoUpdateData(true); | |||
6531 | if (pEditSource->IsDirty()) | |||
6532 | pEditSource->UpdateData(); | |||
6533 | } | |||
6534 | } | |||
6535 | } | |||
6536 | ||||
6537 | void SAL_CALL ScCellObj::setActionLocks( sal_Int16 nLock ) | |||
6538 | { | |||
6539 | SolarMutexGuard aGuard; | |||
6540 | if (mxUnoText.is()) | |||
6541 | { | |||
6542 | ScCellEditSource* pEditSource = | |||
6543 | static_cast<ScCellEditSource*> (mxUnoText->GetEditSource()); | |||
6544 | if (pEditSource) | |||
6545 | { | |||
6546 | pEditSource->SetDoUpdateData(nLock == 0); | |||
6547 | if ((nActionLockCount > 0) && (nLock == 0) && pEditSource->IsDirty()) | |||
6548 | pEditSource->UpdateData(); | |||
6549 | } | |||
6550 | } | |||
6551 | nActionLockCount = nLock; | |||
6552 | } | |||
6553 | ||||
6554 | sal_Int16 SAL_CALL ScCellObj::resetActionLocks() | |||
6555 | { | |||
6556 | SolarMutexGuard aGuard; | |||
6557 | sal_uInt16 nRet(nActionLockCount); | |||
6558 | if (mxUnoText.is()) | |||
6559 | { | |||
6560 | ScCellEditSource* pEditSource = | |||
6561 | static_cast<ScCellEditSource*> (mxUnoText->GetEditSource()); | |||
6562 | if (pEditSource) | |||
6563 | { | |||
6564 | pEditSource->SetDoUpdateData(true); | |||
6565 | if (pEditSource->IsDirty()) | |||
6566 | pEditSource->UpdateData(); | |||
6567 | } | |||
6568 | } | |||
6569 | nActionLockCount = 0; | |||
6570 | return nRet; | |||
6571 | } | |||
6572 | ||||
6573 | static ScRange MaxDocRange(ScDocShell* pDocSh, SCTAB nTab) | |||
6574 | { | |||
6575 | const SCCOL nMaxcol = pDocSh ? pDocSh->GetDocument().MaxCol() : MAXCOL; | |||
6576 | const SCROW nMaxRow = pDocSh ? pDocSh->GetDocument().MaxRow() : MAXROW; | |||
6577 | return ScRange(0, 0, nTab, nMaxcol, nMaxRow, nTab); | |||
6578 | } | |||
6579 | ||||
6580 | ScTableSheetObj::ScTableSheetObj( ScDocShell* pDocSh, SCTAB nTab ) : | |||
6581 | ScCellRangeObj( pDocSh, MaxDocRange(pDocSh, nTab) ), | |||
6582 | pSheetPropSet(lcl_GetSheetPropertySet()) | |||
6583 | { | |||
6584 | } | |||
6585 | ||||
6586 | ScTableSheetObj::~ScTableSheetObj() | |||
6587 | { | |||
6588 | } | |||
6589 | ||||
6590 | void ScTableSheetObj::InitInsertSheet(ScDocShell* pDocSh, SCTAB nTab) | |||
6591 | { | |||
6592 | ScDocument& rDoc = pDocSh->GetDocument(); | |||
6593 | InitInsertRange( pDocSh, ScRange(0,0,nTab, rDoc.MaxCol(),rDoc.MaxRow(),nTab) ); | |||
6594 | } | |||
6595 | ||||
6596 | uno::Any SAL_CALL ScTableSheetObj::queryInterface( const uno::Type& rType ) | |||
6597 | { | |||
6598 | SC_QUERYINTERFACE( sheet::XSpreadsheet )if (rType == cppu::UnoType<sheet::XSpreadsheet>::get()) { return uno::makeAny(uno::Reference<sheet::XSpreadsheet> (this)); } | |||
6599 | SC_QUERYINTERFACE( container::XNamed )if (rType == cppu::UnoType<container::XNamed>::get()) { return uno::makeAny(uno::Reference<container::XNamed>( this)); } | |||
6600 | SC_QUERYINTERFACE( sheet::XSheetPageBreak )if (rType == cppu::UnoType<sheet::XSheetPageBreak>::get ()) { return uno::makeAny(uno::Reference<sheet::XSheetPageBreak >(this)); } | |||
6601 | SC_QUERYINTERFACE( sheet::XCellRangeMovement )if (rType == cppu::UnoType<sheet::XCellRangeMovement>:: get()) { return uno::makeAny(uno::Reference<sheet::XCellRangeMovement >(this)); } | |||
6602 | SC_QUERYINTERFACE( table::XTableChartsSupplier )if (rType == cppu::UnoType<table::XTableChartsSupplier> ::get()) { return uno::makeAny(uno::Reference<table::XTableChartsSupplier >(this)); } | |||
6603 | SC_QUERYINTERFACE( sheet::XDataPilotTablesSupplier )if (rType == cppu::UnoType<sheet::XDataPilotTablesSupplier >::get()) { return uno::makeAny(uno::Reference<sheet::XDataPilotTablesSupplier >(this)); } | |||
6604 | SC_QUERYINTERFACE( sheet::XScenariosSupplier )if (rType == cppu::UnoType<sheet::XScenariosSupplier>:: get()) { return uno::makeAny(uno::Reference<sheet::XScenariosSupplier >(this)); } | |||
6605 | SC_QUERYINTERFACE( sheet::XSheetAnnotationsSupplier )if (rType == cppu::UnoType<sheet::XSheetAnnotationsSupplier >::get()) { return uno::makeAny(uno::Reference<sheet::XSheetAnnotationsSupplier >(this)); } | |||
6606 | SC_QUERYINTERFACE( drawing::XDrawPageSupplier )if (rType == cppu::UnoType<drawing::XDrawPageSupplier>:: get()) { return uno::makeAny(uno::Reference<drawing::XDrawPageSupplier >(this)); } | |||
6607 | SC_QUERYINTERFACE( sheet::XPrintAreas )if (rType == cppu::UnoType<sheet::XPrintAreas>::get()) { return uno::makeAny(uno::Reference<sheet::XPrintAreas> (this)); } | |||
6608 | SC_QUERYINTERFACE( sheet::XSheetAuditing )if (rType == cppu::UnoType<sheet::XSheetAuditing>::get( )) { return uno::makeAny(uno::Reference<sheet::XSheetAuditing >(this)); } | |||
6609 | SC_QUERYINTERFACE( sheet::XSheetOutline )if (rType == cppu::UnoType<sheet::XSheetOutline>::get() ) { return uno::makeAny(uno::Reference<sheet::XSheetOutline >(this)); } | |||
6610 | SC_QUERYINTERFACE( util::XProtectable )if (rType == cppu::UnoType<util::XProtectable>::get()) { return uno::makeAny(uno::Reference<util::XProtectable> (this)); } | |||
6611 | SC_QUERYINTERFACE( sheet::XScenario )if (rType == cppu::UnoType<sheet::XScenario>::get()) { return uno::makeAny(uno::Reference<sheet::XScenario>(this)); } | |||
6612 | SC_QUERYINTERFACE( sheet::XScenarioEnhanced )if (rType == cppu::UnoType<sheet::XScenarioEnhanced>::get ()) { return uno::makeAny(uno::Reference<sheet::XScenarioEnhanced >(this)); } | |||
6613 | SC_QUERYINTERFACE( sheet::XSheetLinkable )if (rType == cppu::UnoType<sheet::XSheetLinkable>::get( )) { return uno::makeAny(uno::Reference<sheet::XSheetLinkable >(this)); } | |||
6614 | SC_QUERYINTERFACE( sheet::XExternalSheetName )if (rType == cppu::UnoType<sheet::XExternalSheetName>:: get()) { return uno::makeAny(uno::Reference<sheet::XExternalSheetName >(this)); } | |||
6615 | SC_QUERYINTERFACE( document::XEventsSupplier )if (rType == cppu::UnoType<document::XEventsSupplier>:: get()) { return uno::makeAny(uno::Reference<document::XEventsSupplier >(this)); } | |||
6616 | SC_QUERYINTERFACE( table::XTablePivotChartsSupplier )if (rType == cppu::UnoType<table::XTablePivotChartsSupplier >::get()) { return uno::makeAny(uno::Reference<table::XTablePivotChartsSupplier >(this)); } | |||
6617 | ||||
6618 | return ScCellRangeObj::queryInterface( rType ); | |||
6619 | } | |||
6620 | ||||
6621 | void SAL_CALL ScTableSheetObj::acquire() throw() | |||
6622 | { | |||
6623 | ScCellRangeObj::acquire(); | |||
6624 | } | |||
6625 | ||||
6626 | void SAL_CALL ScTableSheetObj::release() throw() | |||
6627 | { | |||
6628 | ScCellRangeObj::release(); | |||
6629 | } | |||
6630 | ||||
6631 | uno::Sequence<uno::Type> SAL_CALL ScTableSheetObj::getTypes() | |||
6632 | { | |||
6633 | static const uno::Sequence<uno::Type> aTypes = comphelper::concatSequences( | |||
6634 | ScCellRangeObj::getTypes(), | |||
6635 | uno::Sequence<uno::Type> | |||
6636 | { | |||
6637 | cppu::UnoType<sheet::XSpreadsheet>::get(), | |||
6638 | cppu::UnoType<container::XNamed>::get(), | |||
6639 | cppu::UnoType<sheet::XSheetPageBreak>::get(), | |||
6640 | cppu::UnoType<sheet::XCellRangeMovement>::get(), | |||
6641 | cppu::UnoType<table::XTableChartsSupplier>::get(), | |||
6642 | cppu::UnoType<sheet::XDataPilotTablesSupplier>::get(), | |||
6643 | cppu::UnoType<sheet::XScenariosSupplier>::get(), | |||
6644 | cppu::UnoType<sheet::XSheetAnnotationsSupplier>::get(), | |||
6645 | cppu::UnoType<drawing::XDrawPageSupplier>::get(), | |||
6646 | cppu::UnoType<sheet::XPrintAreas>::get(), | |||
6647 | cppu::UnoType<sheet::XSheetAuditing>::get(), | |||
6648 | cppu::UnoType<sheet::XSheetOutline>::get(), | |||
6649 | cppu::UnoType<util::XProtectable>::get(), | |||
6650 | cppu::UnoType<sheet::XScenario>::get(), | |||
6651 | cppu::UnoType<sheet::XScenarioEnhanced>::get(), | |||
6652 | cppu::UnoType<sheet::XSheetLinkable>::get(), | |||
6653 | cppu::UnoType<sheet::XExternalSheetName>::get(), | |||
6654 | cppu::UnoType<document::XEventsSupplier>::get(), | |||
6655 | cppu::UnoType<table::XTablePivotChartsSupplier>::get() | |||
6656 | } ); | |||
6657 | return aTypes; | |||
6658 | } | |||
6659 | ||||
6660 | uno::Sequence<sal_Int8> SAL_CALL ScTableSheetObj::getImplementationId() | |||
6661 | { | |||
6662 | return css::uno::Sequence<sal_Int8>(); | |||
6663 | } | |||
6664 | ||||
6665 | // Helper functions | |||
6666 | ||||
6667 | SCTAB ScTableSheetObj::GetTab_Impl() const | |||
6668 | { | |||
6669 | const ScRangeList& rRanges = GetRangeList(); | |||
6670 | OSL_ENSURE(rRanges.size() == 1, "What ranges ?!?!")do { if (true && (!(rRanges.size() == 1))) { sal_detail_logFormat ((SAL_DETAIL_LOG_LEVEL_WARN), ("legacy.osl"), ("/home/maarten/src/libreoffice/core/sc/source/ui/unoobj/cellsuno.cxx" ":" "6670" ": "), "%s", "What ranges ?!?!"); } } while (false ); | |||
6671 | if ( !rRanges.empty() ) | |||
6672 | { | |||
6673 | return rRanges[ 0 ].aStart.Tab(); | |||
6674 | } | |||
6675 | return 0; | |||
6676 | } | |||
6677 | ||||
6678 | // former XSheet | |||
6679 | ||||
6680 | uno::Reference<table::XTableCharts> SAL_CALL ScTableSheetObj::getCharts() | |||
6681 | { | |||
6682 | SolarMutexGuard aGuard; | |||
6683 | ScDocShell* pDocSh = GetDocShell(); | |||
6684 | if ( pDocSh ) | |||
6685 | return new ScChartsObj( pDocSh, GetTab_Impl() ); | |||
6686 | ||||
6687 | OSL_FAIL("no document")do { if (true && (((sal_Bool)1))) { sal_detail_logFormat ((SAL_DETAIL_LOG_LEVEL_WARN), ("legacy.osl"), ("/home/maarten/src/libreoffice/core/sc/source/ui/unoobj/cellsuno.cxx" ":" "6687" ": "), "%s", "no document"); } } while (false); | |||
6688 | return nullptr; | |||
6689 | } | |||
6690 | ||||
6691 | uno::Reference<table::XTablePivotCharts> SAL_CALL ScTableSheetObj::getPivotCharts() | |||
6692 | { | |||
6693 | SolarMutexGuard aGuard; | |||
6694 | ScDocShell* pDocSh = GetDocShell(); | |||
6695 | if (pDocSh) | |||
6696 | return new sc::TablePivotCharts(pDocSh, GetTab_Impl()); | |||
6697 | ||||
6698 | OSL_FAIL("no document")do { if (true && (((sal_Bool)1))) { sal_detail_logFormat ((SAL_DETAIL_LOG_LEVEL_WARN), ("legacy.osl"), ("/home/maarten/src/libreoffice/core/sc/source/ui/unoobj/cellsuno.cxx" ":" "6698" ": "), "%s", "no document"); } } while (false); | |||
6699 | return nullptr; | |||
6700 | } | |||
6701 | ||||
6702 | uno::Reference<sheet::XDataPilotTables> SAL_CALL ScTableSheetObj::getDataPilotTables() | |||
6703 | { | |||
6704 | SolarMutexGuard aGuard; | |||
6705 | ScDocShell* pDocSh = GetDocShell(); | |||
6706 | if ( pDocSh ) | |||
6707 | return new ScDataPilotTablesObj( pDocSh, GetTab_Impl() ); | |||
6708 | ||||
6709 | OSL_FAIL("no document")do { if (true && (((sal_Bool)1))) { sal_detail_logFormat ((SAL_DETAIL_LOG_LEVEL_WARN), ("legacy.osl"), ("/home/maarten/src/libreoffice/core/sc/source/ui/unoobj/cellsuno.cxx" ":" "6709" ": "), "%s", "no document"); } } while (false); | |||
6710 | return nullptr; | |||
6711 | } | |||
6712 | ||||
6713 | uno::Reference<sheet::XScenarios> SAL_CALL ScTableSheetObj::getScenarios() | |||
6714 | { | |||
6715 | SolarMutexGuard aGuard; | |||
6716 | ScDocShell* pDocSh = GetDocShell(); | |||
6717 | ||||
6718 | if ( pDocSh ) | |||
6719 | return new ScScenariosObj( pDocSh, GetTab_Impl() ); | |||
6720 | ||||
6721 | OSL_FAIL("no document")do { if (true && (((sal_Bool)1))) { sal_detail_logFormat ((SAL_DETAIL_LOG_LEVEL_WARN), ("legacy.osl"), ("/home/maarten/src/libreoffice/core/sc/source/ui/unoobj/cellsuno.cxx" ":" "6721" ": "), "%s", "no document"); } } while (false); | |||
6722 | return nullptr; | |||
6723 | } | |||
6724 | ||||
6725 | uno::Reference<sheet::XSheetAnnotations> SAL_CALL ScTableSheetObj::getAnnotations() | |||
6726 | { | |||
6727 | SolarMutexGuard aGuard; | |||
6728 | ScDocShell* pDocSh = GetDocShell(); | |||
6729 | ||||
6730 | if ( pDocSh ) | |||
6731 | return new ScAnnotationsObj( pDocSh, GetTab_Impl() ); | |||
6732 | ||||
6733 | OSL_FAIL("no document")do { if (true && (((sal_Bool)1))) { sal_detail_logFormat ((SAL_DETAIL_LOG_LEVEL_WARN), ("legacy.osl"), ("/home/maarten/src/libreoffice/core/sc/source/ui/unoobj/cellsuno.cxx" ":" "6733" ": "), "%s", "no document"); } } while (false); | |||
6734 | return nullptr; | |||
6735 | } | |||
6736 | ||||
6737 | uno::Reference<table::XCellRange> SAL_CALL ScTableSheetObj::getCellRangeByName( | |||
6738 | const OUString& rRange ) | |||
6739 | { | |||
6740 | SolarMutexGuard aGuard; | |||
6741 | return ScCellRangeObj::getCellRangeByName( rRange ); | |||
6742 | } | |||
6743 | ||||
6744 | uno::Reference<sheet::XSheetCellCursor> SAL_CALL ScTableSheetObj::createCursor() | |||
6745 | { | |||
6746 | SolarMutexGuard aGuard; | |||
6747 | ScDocShell* pDocSh = GetDocShell(); | |||
6748 | if ( pDocSh ) | |||
6749 | { | |||
6750 | //! single cell or whole table?????? | |||
6751 | const ScDocument& rDoc = pDocSh->GetDocument(); | |||
6752 | SCTAB nTab = GetTab_Impl(); | |||
6753 | return new ScCellCursorObj( pDocSh, ScRange( 0,0,nTab, rDoc.MaxCol(),rDoc.MaxRow(),nTab ) ); | |||
6754 | } | |||
6755 | return nullptr; | |||
6756 | } | |||
6757 | ||||
6758 | uno::Reference<sheet::XSheetCellCursor> SAL_CALL ScTableSheetObj::createCursorByRange( | |||
6759 | const uno::Reference<sheet::XSheetCellRange>& xCellRange ) | |||
6760 | { | |||
6761 | SolarMutexGuard aGuard; | |||
6762 | ScDocShell* pDocSh = GetDocShell(); | |||
6763 | if ( pDocSh && xCellRange.is() ) | |||
6764 | { | |||
6765 | ScCellRangesBase* pRangesImp = comphelper::getUnoTunnelImplementation<ScCellRangesBase>( xCellRange ); | |||
6766 | if (pRangesImp) | |||
6767 | { | |||
6768 | const ScRangeList& rRanges = pRangesImp->GetRangeList(); | |||
6769 | OSL_ENSURE( rRanges.size() == 1, "Range? Ranges?" )do { if (true && (!(rRanges.size() == 1))) { sal_detail_logFormat ((SAL_DETAIL_LOG_LEVEL_WARN), ("legacy.osl"), ("/home/maarten/src/libreoffice/core/sc/source/ui/unoobj/cellsuno.cxx" ":" "6769" ": "), "%s", "Range? Ranges?"); } } while (false); | |||
6770 | return new ScCellCursorObj( pDocSh, rRanges[ 0 ] ); | |||
6771 | } | |||
6772 | } | |||
6773 | return nullptr; | |||
6774 | } | |||
6775 | ||||
6776 | // XSheetCellRange | |||
6777 | ||||
6778 | uno::Reference<sheet::XSpreadsheet> SAL_CALL ScTableSheetObj::getSpreadsheet() | |||
6779 | { | |||
6780 | return this; //!??? | |||
6781 | } | |||
6782 | ||||
6783 | // XCellRange | |||
6784 | ||||
6785 | uno::Reference<table::XCell> SAL_CALL ScTableSheetObj::getCellByPosition( | |||
6786 | sal_Int32 nColumn, sal_Int32 nRow ) | |||
6787 | { | |||
6788 | SolarMutexGuard aGuard; | |||
6789 | return ScCellRangeObj::GetCellByPosition_Impl(nColumn, nRow); | |||
6790 | } | |||
6791 | ||||
6792 | uno::Reference<table::XCellRange> SAL_CALL ScTableSheetObj::getCellRangeByPosition( | |||
6793 | sal_Int32 nLeft, sal_Int32 nTop, sal_Int32 nRight, sal_Int32 nBottom ) | |||
6794 | { | |||
6795 | SolarMutexGuard aGuard; | |||
6796 | return ScCellRangeObj::getCellRangeByPosition(nLeft,nTop,nRight,nBottom); | |||
6797 | } | |||
6798 | ||||
6799 | uno::Sequence<sheet::TablePageBreakData> SAL_CALL ScTableSheetObj::getColumnPageBreaks() | |||
6800 | { | |||
6801 | SolarMutexGuard aGuard; | |||
6802 | ScDocShell* pDocSh = GetDocShell(); | |||
6803 | if ( pDocSh ) | |||
6804 | { | |||
6805 | ScDocument& rDoc = pDocSh->GetDocument(); | |||
6806 | SCTAB nTab = GetTab_Impl(); | |||
6807 | ||||
6808 | Size aSize(rDoc.GetPageSize( nTab )); | |||
6809 | if (aSize.Width() && aSize.Height()) // effective size already set? | |||
6810 | rDoc.UpdatePageBreaks( nTab ); | |||
6811 | else | |||
6812 | { | |||
6813 | // update breaks like in ScDocShell::PageStyleModified: | |||
6814 | ScPrintFunc aPrintFunc( pDocSh, pDocSh->GetPrinter(), nTab ); | |||
6815 | aPrintFunc.UpdatePages(); | |||
6816 | } | |||
6817 | ||||
6818 | SCCOL nCount = 0; | |||
6819 | for (SCCOL nCol : rDoc.GetColumnsRange(nTab, 0, rDoc.MaxCol())) | |||
6820 | if (rDoc.HasColBreak(nCol, nTab) != ScBreakType::NONE) | |||
6821 | ++nCount; | |||
6822 | ||||
6823 | sheet::TablePageBreakData aData; | |||
6824 | uno::Sequence<sheet::TablePageBreakData> aSeq(nCount); | |||
6825 | sheet::TablePageBreakData* pAry = aSeq.getArray(); | |||
6826 | sal_uInt16 nPos = 0; | |||
6827 | for (SCCOL nCol : rDoc.GetColumnsRange(nTab, 0, rDoc.MaxCol())) | |||
6828 | { | |||
6829 | ScBreakType nBreak = rDoc.HasColBreak(nCol, nTab); | |||
6830 | if (nBreak != ScBreakType::NONE) | |||
6831 | { | |||
6832 | aData.Position = nCol; | |||
6833 | aData.ManualBreak = bool(nBreak & ScBreakType::Manual); | |||
6834 | pAry[nPos] = aData; | |||
6835 | ++nPos; | |||
6836 | } | |||
6837 | } | |||
6838 | return aSeq; | |||
6839 | } | |||
6840 | return uno::Sequence<sheet::TablePageBreakData>(0); | |||
6841 | } | |||
6842 | ||||
6843 | uno::Sequence<sheet::TablePageBreakData> SAL_CALL ScTableSheetObj::getRowPageBreaks() | |||
6844 | { | |||
6845 | SolarMutexGuard aGuard; | |||
6846 | ScDocShell* pDocSh = GetDocShell(); | |||
6847 | if ( pDocSh ) | |||
6848 | { | |||
6849 | ScDocument& rDoc = pDocSh->GetDocument(); | |||
6850 | SCTAB nTab = GetTab_Impl(); | |||
6851 | ||||
6852 | Size aSize(rDoc.GetPageSize( nTab )); | |||
6853 | if (aSize.Width() && aSize.Height()) // effective size already set? | |||
6854 | rDoc.UpdatePageBreaks( nTab ); | |||
6855 | else | |||
6856 | { | |||
6857 | // update breaks like in ScDocShell::PageStyleModified: | |||
6858 | ScPrintFunc aPrintFunc( pDocSh, pDocSh->GetPrinter(), nTab ); | |||
6859 | aPrintFunc.UpdatePages(); | |||
6860 | } | |||
6861 | return rDoc.GetRowBreakData(nTab); | |||
6862 | } | |||
6863 | return uno::Sequence<sheet::TablePageBreakData>(0); | |||
6864 | } | |||
6865 | ||||
6866 | void SAL_CALL ScTableSheetObj::removeAllManualPageBreaks() | |||
6867 | { | |||
6868 | SolarMutexGuard aGuard; | |||
6869 | ScDocShell* pDocSh = GetDocShell(); | |||
6870 | if ( !pDocSh ) | |||
6871 | return; | |||
6872 | ||||
6873 | //! DocFunc function, also for ScViewFunc::RemoveManualBreaks | |||
6874 | ||||
6875 | ScDocument& rDoc = pDocSh->GetDocument(); | |||
6876 | bool bUndo (rDoc.IsUndoEnabled()); | |||
6877 | SCTAB nTab = GetTab_Impl(); | |||
6878 | ||||
6879 | if (bUndo) | |||
6880 | { | |||
6881 | ScDocumentUniquePtr pUndoDoc(new ScDocument( SCDOCMODE_UNDO )); | |||
6882 | pUndoDoc->InitUndo( rDoc, nTab, nTab, true, true ); | |||
6883 | rDoc.CopyToDocument(0,0,nTab, rDoc.MaxCol(),rDoc.MaxRow(),nTab, InsertDeleteFlags::NONE, false, *pUndoDoc); | |||
6884 | pDocSh->GetUndoManager()->AddUndoAction( | |||
6885 | std::make_unique<ScUndoRemoveBreaks>( pDocSh, nTab, std::move(pUndoDoc) ) ); | |||
6886 | } | |||
6887 | ||||
6888 | rDoc.RemoveManualBreaks(nTab); | |||
6889 | rDoc.UpdatePageBreaks(nTab); | |||
6890 | ||||
6891 | //? UpdatePageBreakData( sal_True ); | |||
6892 | pDocSh->SetDocumentModified(); | |||
6893 | pDocSh->PostPaint(ScRange(0, 0, nTab, rDoc.MaxCol(), rDoc.MaxRow(), nTab), PaintPartFlags::Grid); | |||
6894 | } | |||
6895 | ||||
6896 | // XNamed | |||
6897 | ||||
6898 | OUString SAL_CALL ScTableSheetObj::getName() | |||
6899 | { | |||
6900 | SolarMutexGuard aGuard; | |||
6901 | OUString aName; | |||
6902 | ScDocShell* pDocSh = GetDocShell(); | |||
6903 | if ( pDocSh ) | |||
6904 | pDocSh->GetDocument().GetName( GetTab_Impl(), aName ); | |||
6905 | return aName; | |||
6906 | } | |||
6907 | ||||
6908 | void SAL_CALL ScTableSheetObj::setName( const OUString& aNewName ) | |||
6909 | { | |||
6910 | SolarMutexGuard aGuard; | |||
6911 | ScDocShell* pDocSh = GetDocShell(); | |||
6912 | if ( pDocSh ) | |||
6913 | { | |||
6914 | pDocSh->GetDocFunc().RenameTable( GetTab_Impl(), aNewName, true, true ); | |||
6915 | } | |||
6916 | } | |||
6917 | ||||
6918 | // XDrawPageSupplier | |||
6919 | ||||
6920 | uno::Reference<drawing::XDrawPage> SAL_CALL ScTableSheetObj::getDrawPage() | |||
6921 | { | |||
6922 | SolarMutexGuard aGuard; | |||
6923 | ScDocShell* pDocSh = GetDocShell(); | |||
6924 | if ( pDocSh ) | |||
6925 | { | |||
6926 | ScDrawLayer* pDrawLayer = pDocSh->MakeDrawLayer(); | |||
6927 | OSL_ENSURE(pDrawLayer,"Cannot create Draw-Layer")do { if (true && (!(pDrawLayer))) { sal_detail_logFormat ((SAL_DETAIL_LOG_LEVEL_WARN), ("legacy.osl"), ("/home/maarten/src/libreoffice/core/sc/source/ui/unoobj/cellsuno.cxx" ":" "6927" ": "), "%s", "Cannot create Draw-Layer"); } } while (false); | |||
6928 | ||||
6929 | SCTAB nTab = GetTab_Impl(); | |||
6930 | SdrPage* pPage = pDrawLayer->GetPage(static_cast<sal_uInt16>(nTab)); | |||
6931 | OSL_ENSURE(pPage,"Draw-Page not found")do { if (true && (!(pPage))) { sal_detail_logFormat(( SAL_DETAIL_LOG_LEVEL_WARN), ("legacy.osl"), ("/home/maarten/src/libreoffice/core/sc/source/ui/unoobj/cellsuno.cxx" ":" "6931" ": "), "%s", "Draw-Page not found"); } } while (false ); | |||
6932 | if (pPage) | |||
6933 | return uno::Reference<drawing::XDrawPage> (pPage->getUnoPage(), uno::UNO_QUERY); | |||
6934 | ||||
6935 | // The DrawPage object will register itself as a Listener at SdrModel | |||
6936 | // and should receive all action from there | |||
6937 | } | |||
6938 | return nullptr; | |||
6939 | } | |||
6940 | ||||
6941 | // XCellMovement | |||
6942 | ||||
6943 | void SAL_CALL ScTableSheetObj::insertCells( const table::CellRangeAddress& rRangeAddress, | |||
6944 | sheet::CellInsertMode nMode ) | |||
6945 | { | |||
6946 | SolarMutexGuard aGuard; | |||
6947 | ScDocShell* pDocSh = GetDocShell(); | |||
6948 | if ( !pDocSh ) | |||
6949 | return; | |||
6950 | ||||
6951 | bool bDo = true; | |||
6952 | InsCellCmd eCmd = INS_NONE; | |||
6953 | switch (nMode) | |||
6954 | { | |||
6955 | case sheet::CellInsertMode_NONE: bDo = false; break; | |||
6956 | case sheet::CellInsertMode_DOWN: eCmd = INS_CELLSDOWN; break; | |||
6957 | case sheet::CellInsertMode_RIGHT: eCmd = INS_CELLSRIGHT; break; | |||
6958 | case sheet::CellInsertMode_ROWS: eCmd = INS_INSROWS_BEFORE; break; | |||
6959 | case sheet::CellInsertMode_COLUMNS: eCmd = INS_INSCOLS_BEFORE; break; | |||
6960 | default: | |||
6961 | OSL_FAIL("insertCells: wrong mode")do { if (true && (((sal_Bool)1))) { sal_detail_logFormat ((SAL_DETAIL_LOG_LEVEL_WARN), ("legacy.osl"), ("/home/maarten/src/libreoffice/core/sc/source/ui/unoobj/cellsuno.cxx" ":" "6961" ": "), "%s", "insertCells: wrong mode"); } } while (false); | |||
6962 | bDo = false; | |||
6963 | } | |||
6964 | ||||
6965 | if (bDo) | |||
6966 | { | |||
6967 | OSL_ENSURE( rRangeAddress.Sheet == GetTab_Impl(), "wrong table in CellRangeAddress" )do { if (true && (!(rRangeAddress.Sheet == GetTab_Impl ()))) { sal_detail_logFormat((SAL_DETAIL_LOG_LEVEL_WARN), ("legacy.osl" ), ("/home/maarten/src/libreoffice/core/sc/source/ui/unoobj/cellsuno.cxx" ":" "6967" ": "), "%s", "wrong table in CellRangeAddress"); } } while (false); | |||
6968 | ScRange aScRange; | |||
6969 | ScUnoConversion::FillScRange( aScRange, rRangeAddress ); | |||
6970 | (void)pDocSh->GetDocFunc().InsertCells( aScRange, nullptr, eCmd, true, true ); | |||
6971 | } | |||
6972 | } | |||
6973 | ||||
6974 | void SAL_CALL ScTableSheetObj::removeRange( const table::CellRangeAddress& rRangeAddress, | |||
6975 | sheet::CellDeleteMode nMode ) | |||
6976 | { | |||
6977 | SolarMutexGuard aGuard; | |||
6978 | ScDocShell* pDocSh = GetDocShell(); | |||
6979 | if ( !pDocSh ) | |||
6980 | return; | |||
6981 | ||||
6982 | bool bDo = true; | |||
6983 | DelCellCmd eCmd = DelCellCmd::NONE; | |||
6984 | switch (nMode) | |||
6985 | { | |||
6986 | case sheet::CellDeleteMode_NONE: bDo = false; break; | |||
6987 | case sheet::CellDeleteMode_UP: eCmd = DelCellCmd::CellsUp; break; | |||
6988 | case sheet::CellDeleteMode_LEFT: eCmd = DelCellCmd::CellsLeft; break; | |||
6989 | case sheet::CellDeleteMode_ROWS: eCmd = DelCellCmd::Rows; break; | |||
6990 | case sheet::CellDeleteMode_COLUMNS: eCmd = DelCellCmd::Cols; break; | |||
6991 | default: | |||
6992 | OSL_FAIL("deleteCells: wrong mode")do { if (true && (((sal_Bool)1))) { sal_detail_logFormat ((SAL_DETAIL_LOG_LEVEL_WARN), ("legacy.osl"), ("/home/maarten/src/libreoffice/core/sc/source/ui/unoobj/cellsuno.cxx" ":" "6992" ": "), "%s", "deleteCells: wrong mode"); } } while (false); | |||
6993 | bDo = false; | |||
6994 | } | |||
6995 | ||||
6996 | if (bDo) | |||
6997 | { | |||
6998 | OSL_ENSURE( rRangeAddress.Sheet == GetTab_Impl(), "wrong table in CellRangeAddress" )do { if (true && (!(rRangeAddress.Sheet == GetTab_Impl ()))) { sal_detail_logFormat((SAL_DETAIL_LOG_LEVEL_WARN), ("legacy.osl" ), ("/home/maarten/src/libreoffice/core/sc/source/ui/unoobj/cellsuno.cxx" ":" "6998" ": "), "%s", "wrong table in CellRangeAddress"); } } while (false); | |||
6999 | ScRange aScRange; | |||
7000 | ScUnoConversion::FillScRange( aScRange, rRangeAddress ); | |||
7001 | (void)pDocSh->GetDocFunc().DeleteCells( aScRange, nullptr, eCmd, true ); | |||
7002 | } | |||
7003 | } | |||
7004 | ||||
7005 | void SAL_CALL ScTableSheetObj::moveRange( const table::CellAddress& aDestination, | |||
7006 | const table::CellRangeAddress& aSource ) | |||
7007 | { | |||
7008 | SolarMutexGuard aGuard; | |||
7009 | ScDocShell* pDocSh = GetDocShell(); | |||
7010 | if ( pDocSh ) | |||
7011 | { | |||
7012 | OSL_ENSURE( aSource.Sheet == GetTab_Impl(), "wrong table in CellRangeAddress" )do { if (true && (!(aSource.Sheet == GetTab_Impl()))) { sal_detail_logFormat((SAL_DETAIL_LOG_LEVEL_WARN), ("legacy.osl" ), ("/home/maarten/src/libreoffice/core/sc/source/ui/unoobj/cellsuno.cxx" ":" "7012" ": "), "%s", "wrong table in CellRangeAddress"); } } while (false); | |||
7013 | ScRange aSourceRange; | |||
7014 | ScUnoConversion::FillScRange( aSourceRange, aSource ); | |||
7015 | ScAddress aDestPos( static_cast<SCCOL>(aDestination.Column), static_cast<SCROW>(aDestination.Row), aDestination.Sheet ); | |||
7016 | (void)pDocSh->GetDocFunc().MoveBlock( aSourceRange, aDestPos, true, true, true, true ); | |||
7017 | } | |||
7018 | } | |||
7019 | ||||
7020 | void SAL_CALL ScTableSheetObj::copyRange( const table::CellAddress& aDestination, | |||
7021 | const table::CellRangeAddress& aSource ) | |||
7022 | { | |||
7023 | SolarMutexGuard aGuard; | |||
7024 | ScDocShell* pDocSh = GetDocShell(); | |||
7025 | if ( pDocSh ) | |||
7026 | { | |||
7027 | OSL_ENSURE( aSource.Sheet == GetTab_Impl(), "wrong table in CellRangeAddress" )do { if (true && (!(aSource.Sheet == GetTab_Impl()))) { sal_detail_logFormat((SAL_DETAIL_LOG_LEVEL_WARN), ("legacy.osl" ), ("/home/maarten/src/libreoffice/core/sc/source/ui/unoobj/cellsuno.cxx" ":" "7027" ": "), "%s", "wrong table in CellRangeAddress"); } } while (false); | |||
7028 | ScRange aSourceRange; | |||
7029 | ScUnoConversion::FillScRange( aSourceRange, aSource ); | |||
7030 | ScAddress aDestPos( static_cast<SCCOL>(aDestination.Column), static_cast<SCROW>(aDestination.Row), aDestination.Sheet ); | |||
7031 | (void)pDocSh->GetDocFunc().MoveBlock( aSourceRange, aDestPos, false, true, true, true ); | |||
7032 | } | |||
7033 | } | |||
7034 | ||||
7035 | // XPrintAreas | |||
7036 | ||||
7037 | void ScTableSheetObj::PrintAreaUndo_Impl( std::unique_ptr<ScPrintRangeSaver> pOldRanges ) | |||
7038 | { | |||
7039 | // page break and undo | |||
7040 | ScDocShell* pDocSh = GetDocShell(); | |||
7041 | ||||
7042 | if(!pDocSh) | |||
7043 | return; | |||
7044 | ||||
7045 | ScDocument& rDoc = pDocSh->GetDocument(); | |||
7046 | const bool bUndo(rDoc.IsUndoEnabled()); | |||
7047 | const SCTAB nTab(GetTab_Impl()); | |||
7048 | ||||
7049 | if(bUndo) | |||
7050 | { | |||
7051 | pDocSh->GetUndoManager()->AddUndoAction( | |||
7052 | std::make_unique<ScUndoPrintRange>( | |||
7053 | pDocSh, | |||
7054 | nTab, | |||
7055 | std::move(pOldRanges), | |||
7056 | rDoc.CreatePrintRangeSaver())); // create new ranges | |||
7057 | } | |||
7058 | ||||
7059 | ScPrintFunc(pDocSh, pDocSh->GetPrinter(), nTab).UpdatePages(); | |||
7060 | SfxBindings* pBindings = pDocSh->GetViewBindings(); | |||
7061 | ||||
7062 | if(pBindings) | |||
7063 | { | |||
7064 | pBindings->Invalidate(SID_DELETE_PRINTAREA((((26000 + 521) + 50))+32)); | |||
7065 | } | |||
7066 | ||||
7067 | pDocSh->SetDocumentModified(); | |||
7068 | } | |||
7069 | ||||
7070 | uno::Sequence<table::CellRangeAddress> SAL_CALL ScTableSheetObj::getPrintAreas() | |||
7071 | { | |||
7072 | SolarMutexGuard aGuard; | |||
7073 | ScDocShell* pDocSh = GetDocShell(); | |||
7074 | if ( pDocSh ) | |||
7075 | { | |||
7076 | ScDocument& rDoc = pDocSh->GetDocument(); | |||
7077 | SCTAB nTab = GetTab_Impl(); | |||
7078 | sal_uInt16 nCount = rDoc.GetPrintRangeCount( nTab ); | |||
7079 | ||||
7080 | table::CellRangeAddress aRangeAddress; | |||
7081 | uno::Sequence<table::CellRangeAddress> aSeq(nCount); | |||
7082 | table::CellRangeAddress* pAry = aSeq.getArray(); | |||
7083 | for (sal_uInt16 i=0; i<nCount; i++) | |||
7084 | { | |||
7085 | const ScRange* pRange = rDoc.GetPrintRange( nTab, i ); | |||
7086 | OSL_ENSURE(pRange,"where is the printing area")do { if (true && (!(pRange))) { sal_detail_logFormat( (SAL_DETAIL_LOG_LEVEL_WARN), ("legacy.osl"), ("/home/maarten/src/libreoffice/core/sc/source/ui/unoobj/cellsuno.cxx" ":" "7086" ": "), "%s", "where is the printing area"); } } while (false); | |||
7087 | if (pRange) | |||
7088 | { | |||
7089 | ScUnoConversion::FillApiRange( aRangeAddress, *pRange ); | |||
7090 | aRangeAddress.Sheet = nTab; // core does not care about sheet index | |||
7091 | pAry[i] = aRangeAddress; | |||
7092 | } | |||
7093 | } | |||
7094 | return aSeq; | |||
7095 | } | |||
7096 | return uno::Sequence<table::CellRangeAddress>(); | |||
7097 | } | |||
7098 | ||||
7099 | void SAL_CALL ScTableSheetObj::setPrintAreas( | |||
7100 | const uno::Sequence<table::CellRangeAddress>& aPrintAreas ) | |||
7101 | { | |||
7102 | SolarMutexGuard aGuard; | |||
7103 | ScDocShell* pDocSh = GetDocShell(); | |||
7104 | if ( !pDocSh ) | |||
7105 | return; | |||
7106 | ||||
7107 | std::unique_ptr<ScPrintRangeSaver> pOldRanges; | |||
7108 | ScDocument& rDoc = pDocSh->GetDocument(); | |||
7109 | SCTAB nTab = GetTab_Impl(); | |||
7110 | ||||
7111 | if ( rDoc.IsUndoEnabled() ) | |||
7112 | pOldRanges = rDoc.CreatePrintRangeSaver(); | |||
7113 | ||||
7114 | sal_uInt16 nCount = static_cast<sal_uInt16>(aPrintAreas.getLength()); | |||
7115 | rDoc.ClearPrintRanges( nTab ); | |||
7116 | if (nCount) | |||
7117 | { | |||
7118 | ScRange aPrintRange; | |||
7119 | for (const table::CellRangeAddress& rPrintArea : aPrintAreas) | |||
7120 | { | |||
7121 | ScUnoConversion::FillScRange( aPrintRange, rPrintArea ); | |||
7122 | rDoc.AddPrintRange( nTab, aPrintRange ); | |||
7123 | } | |||
7124 | } | |||
7125 | ||||
7126 | if ( rDoc.IsUndoEnabled() ) | |||
7127 | PrintAreaUndo_Impl( std::move(pOldRanges) ); // Undo, Page Breaks, Modified etc. | |||
7128 | } | |||
7129 | ||||
7130 | sal_Bool SAL_CALL ScTableSheetObj::getPrintTitleColumns() | |||
7131 | { | |||
7132 | SolarMutexGuard aGuard; | |||
7133 | ScDocShell* pDocSh = GetDocShell(); | |||
7134 | if ( pDocSh ) | |||
7135 | { | |||
7136 | ScDocument& rDoc = pDocSh->GetDocument(); | |||
7137 | SCTAB nTab = GetTab_Impl(); | |||
7138 | return ( rDoc.GetRepeatColRange(nTab) != nullptr ); | |||
7139 | } | |||
7140 | return false; | |||
7141 | } | |||
7142 | ||||
7143 | void SAL_CALL ScTableSheetObj::setPrintTitleColumns( sal_Bool bPrintTitleColumns ) | |||
7144 | { | |||
7145 | SolarMutexGuard aGuard; | |||
7146 | ScDocShell* pDocSh = GetDocShell(); | |||
7147 | if ( !pDocSh ) | |||
7148 | return; | |||
7149 | ||||
7150 | ScDocument& rDoc = pDocSh->GetDocument(); | |||
7151 | SCTAB nTab = GetTab_Impl(); | |||
7152 | ||||
7153 | std::unique_ptr<ScPrintRangeSaver> pOldRanges = rDoc.CreatePrintRangeSaver(); | |||
7154 | ||||
7155 | if ( bPrintTitleColumns ) | |||
7156 | { | |||
7157 | if ( !rDoc.GetRepeatColRange( nTab ) ) // do not change existing area | |||
7158 | { | |||
7159 | rDoc.SetRepeatColRange( nTab, std::unique_ptr<ScRange>(new ScRange( 0, 0, nTab, 0, 0, nTab )) ); // enable | |||
7160 | } | |||
7161 | } | |||
7162 | else | |||
7163 | rDoc.SetRepeatColRange( nTab, nullptr ); // disable | |||
7164 | ||||
7165 | PrintAreaUndo_Impl( std::move(pOldRanges) ); // undo, page break, modified etc. | |||
7166 | ||||
7167 | //! save last set area during switch off and recreate during switch on ??? | |||
7168 | } | |||
7169 | ||||
7170 | table::CellRangeAddress SAL_CALL ScTableSheetObj::getTitleColumns() | |||
7171 | { | |||
7172 | SolarMutexGuard aGuard; | |||
7173 | table::CellRangeAddress aRet; | |||
7174 | ScDocShell* pDocSh = GetDocShell(); | |||
7175 | if ( pDocSh ) | |||
7176 | { | |||
7177 | ScDocument& rDoc = pDocSh->GetDocument(); | |||
7178 | SCTAB nTab = GetTab_Impl(); | |||
7179 | const ScRange* pRange = rDoc.GetRepeatColRange(nTab); | |||
7180 | if (pRange) | |||
7181 | { | |||
7182 | ScUnoConversion::FillApiRange( aRet, *pRange ); | |||
7183 | aRet.Sheet = nTab; // core does not care about sheet index | |||
7184 | } | |||
7185 | } | |||
7186 | return aRet; | |||
7187 | } | |||
7188 | ||||
7189 | void SAL_CALL ScTableSheetObj::setTitleColumns( const table::CellRangeAddress& aTitleColumns ) | |||
7190 | { | |||
7191 | SolarMutexGuard aGuard; | |||
7192 | ScDocShell* pDocSh = GetDocShell(); | |||
7193 | if ( !pDocSh ) | |||
7194 | return; | |||
7195 | ||||
7196 | ScDocument& rDoc = pDocSh->GetDocument(); | |||
7197 | SCTAB nTab = GetTab_Impl(); | |||
7198 | ||||
7199 | std::unique_ptr<ScPrintRangeSaver> pOldRanges = rDoc.CreatePrintRangeSaver(); | |||
7200 | ||||
7201 | std::unique_ptr<ScRange> pNew(new ScRange); | |||
7202 | ScUnoConversion::FillScRange( *pNew, aTitleColumns ); | |||
7203 | rDoc.SetRepeatColRange( nTab, std::move(pNew) ); // also always enable | |||
7204 | ||||
7205 | PrintAreaUndo_Impl( std::move(pOldRanges) ); // undo, page breaks, modified etc. | |||
7206 | } | |||
7207 | ||||
7208 | sal_Bool SAL_CALL ScTableSheetObj::getPrintTitleRows() | |||
7209 | { | |||
7210 | SolarMutexGuard aGuard; | |||
7211 | ScDocShell* pDocSh = GetDocShell(); | |||
7212 | if ( pDocSh ) | |||
7213 | { | |||
7214 | ScDocument& rDoc = pDocSh->GetDocument(); | |||
7215 | SCTAB nTab = GetTab_Impl(); | |||
7216 | return ( rDoc.GetRepeatRowRange(nTab) != nullptr ); | |||
7217 | } | |||
7218 | return false; | |||
7219 | } | |||
7220 | ||||
7221 | void SAL_CALL ScTableSheetObj::setPrintTitleRows( sal_Bool bPrintTitleRows ) | |||
7222 | { | |||
7223 | SolarMutexGuard aGuard; | |||
7224 | ScDocShell* pDocSh = GetDocShell(); | |||
7225 | if ( !pDocSh ) | |||
7226 | return; | |||
7227 | ||||
7228 | ScDocument& rDoc = pDocSh->GetDocument(); | |||
7229 | SCTAB nTab = GetTab_Impl(); | |||
7230 | ||||
7231 | std::unique_ptr<ScPrintRangeSaver> pOldRanges = rDoc.CreatePrintRangeSaver(); | |||
7232 | ||||
7233 | if ( bPrintTitleRows ) | |||
7234 | { | |||
7235 | if ( !rDoc.GetRepeatRowRange( nTab ) ) // do not change existing area | |||
7236 | { | |||
7237 | std::unique_ptr<ScRange> pNew( new ScRange(0, 0, nTab, 0, 0, nTab) ); | |||
7238 | rDoc.SetRepeatRowRange( nTab, std::move(pNew) ); // enable | |||
7239 | } | |||
7240 | } | |||
7241 | else | |||
7242 | rDoc.SetRepeatRowRange( nTab, nullptr ); // disable | |||
7243 | ||||
7244 | PrintAreaUndo_Impl( std::move(pOldRanges) ); // undo, page breaks, modified etc. | |||
7245 | ||||
7246 | //! save last set area during switch off and recreate during switch on ??? | |||
7247 | } | |||
7248 | ||||
7249 | table::CellRangeAddress SAL_CALL ScTableSheetObj::getTitleRows() | |||
7250 | { | |||
7251 | SolarMutexGuard aGuard; | |||
7252 | table::CellRangeAddress aRet; | |||
7253 | ScDocShell* pDocSh = GetDocShell(); | |||
7254 | if ( pDocSh ) | |||
7255 | { | |||
7256 | ScDocument& rDoc = pDocSh->GetDocument(); | |||
7257 | SCTAB nTab = GetTab_Impl(); | |||
7258 | const ScRange* pRange = rDoc.GetRepeatRowRange(nTab); | |||
7259 | if (pRange) | |||
7260 | { | |||
7261 | ScUnoConversion::FillApiRange( aRet, *pRange ); | |||
7262 | aRet.Sheet = nTab; // core does not care about sheet index | |||
7263 | } | |||
7264 | } | |||
7265 | return aRet; | |||
7266 | } | |||
7267 | ||||
7268 | void SAL_CALL ScTableSheetObj::setTitleRows( const table::CellRangeAddress& aTitleRows ) | |||
7269 | { | |||
7270 | SolarMutexGuard aGuard; | |||
7271 | ScDocShell* pDocSh = GetDocShell(); | |||
7272 | if ( !pDocSh ) | |||
7273 | return; | |||
7274 | ||||
7275 | ScDocument& rDoc = pDocSh->GetDocument(); | |||
7276 | SCTAB nTab = GetTab_Impl(); | |||
7277 | ||||
7278 | std::unique_ptr<ScPrintRangeSaver> pOldRanges = rDoc.CreatePrintRangeSaver(); | |||
7279 | ||||
7280 | std::unique_ptr<ScRange> pNew(new ScRange); | |||
7281 | ScUnoConversion::FillScRange( *pNew, aTitleRows ); | |||
7282 | rDoc.SetRepeatRowRange( nTab, std::move(pNew) ); // also always enable | |||
7283 | ||||
7284 | PrintAreaUndo_Impl( std::move(pOldRanges) ); // Undo, page breaks, modified etc. | |||
7285 | } | |||
7286 | ||||
7287 | // XSheetLinkable | |||
7288 | ||||
7289 | sheet::SheetLinkMode SAL_CALL ScTableSheetObj::getLinkMode() | |||
7290 | { | |||
7291 | SolarMutexGuard aGuard; | |||
7292 | sheet::SheetLinkMode eRet = sheet::SheetLinkMode_NONE; | |||
7293 | ScDocShell* pDocSh = GetDocShell(); | |||
7294 | if ( pDocSh ) | |||
7295 | { | |||
7296 | ScLinkMode nMode = pDocSh->GetDocument().GetLinkMode( GetTab_Impl() ); | |||
7297 | if ( nMode == ScLinkMode::NORMAL ) | |||
7298 | eRet = sheet::SheetLinkMode_NORMAL; | |||
7299 | else if ( nMode == ScLinkMode::VALUE ) | |||
7300 | eRet = sheet::SheetLinkMode_VALUE; | |||
7301 | } | |||
7302 | return eRet; | |||
7303 | } | |||
7304 | ||||
7305 | void SAL_CALL ScTableSheetObj::setLinkMode( sheet::SheetLinkMode nLinkMode ) | |||
7306 | { | |||
7307 | SolarMutexGuard aGuard; | |||
7308 | ||||
7309 | //! search for filter and options in old link | |||
7310 | ||||
7311 | OUString aUrl(getLinkUrl()); | |||
7312 | OUString aSheet(getLinkSheetName()); | |||
7313 | ||||
7314 | link( aUrl, aSheet, "", "", nLinkMode ); | |||
7315 | } | |||
7316 | ||||
7317 | OUString SAL_CALL ScTableSheetObj::getLinkUrl() | |||
7318 | { | |||
7319 | SolarMutexGuard aGuard; | |||
7320 | OUString aFile; | |||
7321 | ScDocShell* pDocSh = GetDocShell(); | |||
7322 | if ( pDocSh ) | |||
7323 | aFile = pDocSh->GetDocument().GetLinkDoc( GetTab_Impl() ); | |||
7324 | return aFile; | |||
7325 | } | |||
7326 | ||||
7327 | void SAL_CALL ScTableSheetObj::setLinkUrl( const OUString& aLinkUrl ) | |||
7328 | { | |||
7329 | SolarMutexGuard aGuard; | |||
7330 | ||||
7331 | //! search for filter and options in old link | |||
7332 | ||||
7333 | sheet::SheetLinkMode eMode = getLinkMode(); | |||
7334 | OUString aSheet(getLinkSheetName()); | |||
7335 | ||||
7336 | link( aLinkUrl, aSheet, "", "", eMode ); | |||
7337 | } | |||
7338 | ||||
7339 | OUString SAL_CALL ScTableSheetObj::getLinkSheetName() | |||
7340 | { | |||
7341 | SolarMutexGuard aGuard; | |||
7342 | OUString aSheet; | |||
7343 | ScDocShell* pDocSh = GetDocShell(); | |||
7344 | if ( pDocSh ) | |||
7345 | aSheet = pDocSh->GetDocument().GetLinkTab( GetTab_Impl() ); | |||
7346 | return aSheet; | |||
7347 | } | |||
7348 | ||||
7349 | void SAL_CALL ScTableSheetObj::setLinkSheetName( const OUString& aLinkSheetName ) | |||
7350 | { | |||
7351 | SolarMutexGuard aGuard; | |||
7352 | ||||
7353 | //! search for filter and options in old link | |||
7354 | ||||
7355 | sheet::SheetLinkMode eMode = getLinkMode(); | |||
7356 | OUString aUrl(getLinkUrl()); | |||
7357 | ||||
7358 | link( aUrl, aLinkSheetName, "", "", eMode ); | |||
7359 | } | |||
7360 | ||||
7361 | void SAL_CALL ScTableSheetObj::link( const OUString& aUrl, const OUString& aSheetName, | |||
7362 | const OUString& aFilterName, const OUString& aFilterOptions, | |||
7363 | sheet::SheetLinkMode nMode ) | |||
7364 | { | |||
7365 | SolarMutexGuard aGuard; | |||
7366 | ScDocShell* pDocSh = GetDocShell(); | |||
7367 | if ( !pDocSh ) | |||
7368 | return; | |||
7369 | ||||
7370 | ScDocument& rDoc = pDocSh->GetDocument(); | |||
7371 | SCTAB nTab = GetTab_Impl(); | |||
7372 | ||||
7373 | OUString aFileString = aUrl; | |||
7374 | OUString aFilterString = aFilterName; | |||
7375 | OUString aOptString = aFilterOptions; | |||
7376 | ||||
7377 | aFileString = ScGlobal::GetAbsDocName( aFileString, pDocSh ); | |||
7378 | if (aFilterString.isEmpty()) | |||
7379 | ScDocumentLoader::GetFilterName( aFileString, aFilterString, aOptString, true, false ); | |||
7380 | ||||
7381 | // remove application prefix from filter name here, so the filter options | |||
7382 | // aren't reset when the filter name is changed in ScTableLink::DataChanged | |||
7383 | ScDocumentLoader::RemoveAppPrefix( aFilterString ); | |||
7384 | ||||
7385 | ScLinkMode nLinkMode = ScLinkMode::NONE; | |||
7386 | if ( nMode == sheet::SheetLinkMode_NORMAL ) | |||
7387 | nLinkMode = ScLinkMode::NORMAL; | |||
7388 | else if ( nMode == sheet::SheetLinkMode_VALUE ) | |||
7389 | nLinkMode = ScLinkMode::VALUE; | |||
7390 | ||||
7391 | rDoc.SetLink( nTab, nLinkMode, aFileString, aFilterString, aOptString, aSheetName, 0/*nRefresh*/ ); | |||
7392 | ||||
7393 | pDocSh->UpdateLinks(); // if needed add or delete link | |||
7394 | SfxBindings* pBindings = pDocSh->GetViewBindings(); | |||
7395 | if (pBindings) | |||
7396 | pBindings->Invalidate(SID_LINKS((26000) + 60)); | |||
7397 | ||||
7398 | //! undo of link data on the table | |||
7399 | ||||
7400 | if ( !(nLinkMode != ScLinkMode::NONE && rDoc.IsExecuteLinkEnabled()) ) // update link | |||
7401 | return; | |||
7402 | ||||
7403 | // Always update link also if already exists | |||
7404 | //! update only on the affected table??? | |||
7405 | ||||
7406 | sfx2::LinkManager* pLinkManager = rDoc.GetLinkManager(); | |||
7407 | sal_uInt16 nCount = pLinkManager->GetLinks().size(); | |||
7408 | for ( sal_uInt16 i=0; i<nCount; i++ ) | |||
7409 | { | |||
7410 | ::sfx2::SvBaseLink* pBase = pLinkManager->GetLinks()[i].get(); | |||
7411 | if (dynamic_cast<const ScTableLink*>( pBase) != nullptr) | |||
7412 | { | |||
7413 | ScTableLink* pTabLink = static_cast<ScTableLink*>(pBase); | |||
7414 | if ( aFileString == pTabLink->GetFileName() ) | |||
7415 | pTabLink->Update(); // include Paint&Undo | |||
7416 | ||||
7417 | //! The file name should only exists once (?) | |||
7418 | } | |||
7419 | } | |||
7420 | ||||
7421 | //! notify ScSheetLinkObj objects!!! | |||
7422 | } | |||
7423 | ||||
7424 | // XSheetAuditing | |||
7425 | ||||
7426 | sal_Bool SAL_CALL ScTableSheetObj::hideDependents( const table::CellAddress& aPosition ) | |||
7427 | { | |||
7428 | SolarMutexGuard aGuard; | |||
7429 | ScDocShell* pDocSh = GetDocShell(); | |||
7430 | if ( pDocSh ) | |||
7431 | { | |||
7432 | SCTAB nTab = GetTab_Impl(); | |||
7433 | OSL_ENSURE( aPosition.Sheet == nTab, "wrong table in CellAddress" )do { if (true && (!(aPosition.Sheet == nTab))) { sal_detail_logFormat ((SAL_DETAIL_LOG_LEVEL_WARN), ("legacy.osl"), ("/home/maarten/src/libreoffice/core/sc/source/ui/unoobj/cellsuno.cxx" ":" "7433" ": "), "%s", "wrong table in CellAddress"); } } while (false); | |||
7434 | ScAddress aPos( static_cast<SCCOL>(aPosition.Column), static_cast<SCROW>(aPosition.Row), nTab ); | |||
7435 | return pDocSh->GetDocFunc().DetectiveDelSucc( aPos ); | |||
7436 | } | |||
7437 | return false; | |||
7438 | } | |||
7439 | ||||
7440 | sal_Bool SAL_CALL ScTableSheetObj::hidePrecedents( const table::CellAddress& aPosition ) | |||
7441 | { | |||
7442 | SolarMutexGuard aGuard; | |||
7443 | ScDocShell* pDocSh = GetDocShell(); | |||
7444 | if ( pDocSh ) | |||
7445 | { | |||
7446 | SCTAB nTab = GetTab_Impl(); | |||
7447 | OSL_ENSURE( aPosition.Sheet == nTab, "wrong table in CellAddress" )do { if (true && (!(aPosition.Sheet == nTab))) { sal_detail_logFormat ((SAL_DETAIL_LOG_LEVEL_WARN), ("legacy.osl"), ("/home/maarten/src/libreoffice/core/sc/source/ui/unoobj/cellsuno.cxx" ":" "7447" ": "), "%s", "wrong table in CellAddress"); } } while (false); | |||
7448 | ScAddress aPos( static_cast<SCCOL>(aPosition.Column), static_cast<SCROW>(aPosition.Row), nTab ); | |||
7449 | return pDocSh->GetDocFunc().DetectiveDelPred( aPos ); | |||
7450 | } | |||
7451 | return false; | |||
7452 | } | |||
7453 | ||||
7454 | sal_Bool SAL_CALL ScTableSheetObj::showDependents( const table::CellAddress& aPosition ) | |||
7455 | { | |||
7456 | SolarMutexGuard aGuard; | |||
7457 | ScDocShell* pDocSh = GetDocShell(); | |||
7458 | if ( pDocSh ) | |||
7459 | { | |||
7460 | SCTAB nTab = GetTab_Impl(); | |||
7461 | OSL_ENSURE( aPosition.Sheet == nTab, "wrong table in CellAddress" )do { if (true && (!(aPosition.Sheet == nTab))) { sal_detail_logFormat ((SAL_DETAIL_LOG_LEVEL_WARN), ("legacy.osl"), ("/home/maarten/src/libreoffice/core/sc/source/ui/unoobj/cellsuno.cxx" ":" "7461" ": "), "%s", "wrong table in CellAddress"); } } while (false); | |||
7462 | ScAddress aPos( static_cast<SCCOL>(aPosition.Column), static_cast<SCROW>(aPosition.Row), nTab ); | |||
7463 | return pDocSh->GetDocFunc().DetectiveAddSucc( aPos ); | |||
7464 | } | |||
7465 | return false; | |||
7466 | } | |||
7467 | ||||
7468 | sal_Bool SAL_CALL ScTableSheetObj::showPrecedents( const table::CellAddress& aPosition ) | |||
7469 | { | |||
7470 | SolarMutexGuard aGuard; | |||
7471 | ScDocShell* pDocSh = GetDocShell(); | |||
7472 | if ( pDocSh ) | |||
7473 | { | |||
7474 | SCTAB nTab = GetTab_Impl(); | |||
7475 | OSL_ENSURE( aPosition.Sheet == nTab, "wrong table in CellAddress" )do { if (true && (!(aPosition.Sheet == nTab))) { sal_detail_logFormat ((SAL_DETAIL_LOG_LEVEL_WARN), ("legacy.osl"), ("/home/maarten/src/libreoffice/core/sc/source/ui/unoobj/cellsuno.cxx" ":" "7475" ": "), "%s", "wrong table in CellAddress"); } } while (false); | |||
7476 | ScAddress aPos( static_cast<SCCOL>(aPosition.Column), static_cast<SCROW>(aPosition.Row), nTab ); | |||
7477 | return pDocSh->GetDocFunc().DetectiveAddPred( aPos ); | |||
7478 | } | |||
7479 | return false; | |||
7480 | } | |||
7481 | ||||
7482 | sal_Bool SAL_CALL ScTableSheetObj::showErrors( const table::CellAddress& aPosition ) | |||
7483 | { | |||
7484 | SolarMutexGuard aGuard; | |||
7485 | ScDocShell* pDocSh = GetDocShell(); | |||
7486 | if ( pDocSh ) | |||
7487 | { | |||
7488 | SCTAB nTab = GetTab_Impl(); | |||
7489 | OSL_ENSURE( aPosition.Sheet == nTab, "wrong table in CellAddress" )do { if (true && (!(aPosition.Sheet == nTab))) { sal_detail_logFormat ((SAL_DETAIL_LOG_LEVEL_WARN), ("legacy.osl"), ("/home/maarten/src/libreoffice/core/sc/source/ui/unoobj/cellsuno.cxx" ":" "7489" ": "), "%s", "wrong table in CellAddress"); } } while (false); | |||
7490 | ScAddress aPos( static_cast<SCCOL>(aPosition.Column), static_cast<SCROW>(aPosition.Row), nTab ); | |||
7491 | return pDocSh->GetDocFunc().DetectiveAddError( aPos ); | |||
7492 | } | |||
7493 | return false; | |||
7494 | } | |||
7495 | ||||
7496 | sal_Bool SAL_CALL ScTableSheetObj::showInvalid() | |||
7497 | { | |||
7498 | SolarMutexGuard aGuard; | |||
7499 | ScDocShell* pDocSh = GetDocShell(); | |||
7500 | if ( pDocSh ) | |||
7501 | return pDocSh->GetDocFunc().DetectiveMarkInvalid( GetTab_Impl() ); | |||
7502 | return false; | |||
7503 | } | |||
7504 | ||||
7505 | void SAL_CALL ScTableSheetObj::clearArrows() | |||
7506 | { | |||
7507 | SolarMutexGuard aGuard; | |||
7508 | ScDocShell* pDocSh = GetDocShell(); | |||
7509 | if ( pDocSh ) | |||
7510 | pDocSh->GetDocFunc().DetectiveDelAll( GetTab_Impl() ); | |||
7511 | } | |||
7512 | ||||
7513 | // XSheetOutline | |||
7514 | ||||
7515 | void SAL_CALL ScTableSheetObj::group( const table::CellRangeAddress& rGroupRange, | |||
7516 | table::TableOrientation nOrientation ) | |||
7517 | { | |||
7518 | SolarMutexGuard aGuard; | |||
7519 | ScDocShell* pDocSh = GetDocShell(); | |||
7520 | if ( pDocSh ) | |||
7521 | { | |||
7522 | bool bColumns = ( nOrientation == table::TableOrientation_COLUMNS ); | |||
7523 | ScRange aGroupRange; | |||
7524 | ScUnoConversion::FillScRange( aGroupRange, rGroupRange ); | |||
7525 | ScOutlineDocFunc aFunc(*pDocSh); | |||
7526 | aFunc.MakeOutline( aGroupRange, bColumns, true, true ); | |||
7527 | } | |||
7528 | } | |||
7529 | ||||
7530 | void SAL_CALL ScTableSheetObj::ungroup( const table::CellRangeAddress& rGroupRange, | |||
7531 | table::TableOrientation nOrientation ) | |||
7532 | { | |||
7533 | SolarMutexGuard aGuard; | |||
7534 | ScDocShell* pDocSh = GetDocShell(); | |||
7535 | if ( pDocSh ) | |||
7536 | { | |||
7537 | bool bColumns = ( nOrientation == table::TableOrientation_COLUMNS ); | |||
7538 | ScRange aGroupRange; | |||
7539 | ScUnoConversion::FillScRange( aGroupRange, rGroupRange ); | |||
7540 | ScOutlineDocFunc aFunc(*pDocSh); | |||
7541 | aFunc.RemoveOutline( aGroupRange, bColumns, true, true ); | |||
7542 | } | |||
7543 | } | |||
7544 | ||||
7545 | void SAL_CALL ScTableSheetObj::autoOutline( const table::CellRangeAddress& rCellRange ) | |||
7546 | { | |||
7547 | SolarMutexGuard aGuard; | |||
7548 | ScDocShell* pDocSh = GetDocShell(); | |||
7549 | if ( pDocSh ) | |||
7550 | { | |||
7551 | ScRange aFormulaRange; | |||
7552 | ScUnoConversion::FillScRange( aFormulaRange, rCellRange ); | |||
7553 | ScOutlineDocFunc aFunc(*pDocSh); | |||
7554 | aFunc.AutoOutline( aFormulaRange, true ); | |||
7555 | } | |||
7556 | } | |||
7557 | ||||
7558 | void SAL_CALL ScTableSheetObj::clearOutline() | |||
7559 | { | |||
7560 | SolarMutexGuard aGuard; | |||
7561 | ScDocShell* pDocSh = GetDocShell(); | |||
7562 | if ( pDocSh ) | |||
7563 | { | |||
7564 | SCTAB nTab = GetTab_Impl(); | |||
7565 | ScOutlineDocFunc aFunc(*pDocSh); | |||
7566 | aFunc.RemoveAllOutlines( nTab, true ); | |||
7567 | } | |||
7568 | } | |||
7569 | ||||
7570 | void SAL_CALL ScTableSheetObj::hideDetail( const table::CellRangeAddress& rCellRange ) | |||
7571 | { | |||
7572 | SolarMutexGuard aGuard; | |||
7573 | ScDocShell* pDocSh = GetDocShell(); | |||
7574 | if ( pDocSh ) | |||
7575 | { | |||
7576 | ScRange aMarkRange; | |||
7577 | ScUnoConversion::FillScRange( aMarkRange, rCellRange ); | |||
7578 | ScOutlineDocFunc aFunc(*pDocSh); | |||
7579 | aFunc.HideMarkedOutlines( aMarkRange, true ); | |||
7580 | } | |||
7581 | } | |||
7582 | ||||
7583 | void SAL_CALL ScTableSheetObj::showDetail( const table::CellRangeAddress& rCellRange ) | |||
7584 | { | |||
7585 | SolarMutexGuard aGuard; | |||
7586 | ScDocShell* pDocSh = GetDocShell(); | |||
7587 | if ( pDocSh ) | |||
7588 | { | |||
7589 | ScRange aMarkRange; | |||
7590 | ScUnoConversion::FillScRange( aMarkRange, rCellRange ); | |||
7591 | ScOutlineDocFunc aFunc(*pDocSh); | |||
7592 | aFunc.ShowMarkedOutlines( aMarkRange, true ); | |||
7593 | } | |||
7594 | } | |||
7595 | ||||
7596 | void SAL_CALL ScTableSheetObj::showLevel( sal_Int16 nLevel, table::TableOrientation nOrientation ) | |||
7597 | { | |||
7598 | SolarMutexGuard aGuard; | |||
7599 | ScDocShell* pDocSh = GetDocShell(); | |||
7600 | if ( pDocSh ) | |||
7601 | { | |||
7602 | bool bColumns = ( nOrientation == table::TableOrientation_COLUMNS ); | |||
7603 | SCTAB nTab = GetTab_Impl(); | |||
7604 | ScOutlineDocFunc aFunc(*pDocSh); | |||
7605 | aFunc.SelectLevel( nTab, bColumns, nLevel, true, true ); | |||
7606 | } | |||
7607 | } | |||
7608 | ||||
7609 | // XProtectable | |||
7610 | ||||
7611 | void SAL_CALL ScTableSheetObj::protect( const OUString& aPassword ) | |||
7612 | { | |||
7613 | SolarMutexGuard aGuard; | |||
7614 | ScDocShell* pDocSh = GetDocShell(); | |||
7615 | // #i108245# if already protected, don't change anything | |||
7616 | if ( pDocSh && !pDocSh->GetDocument().IsTabProtected( GetTab_Impl() ) ) | |||
7617 | { | |||
7618 | pDocSh->GetDocFunc().Protect( GetTab_Impl(), aPassword ); | |||
7619 | } | |||
7620 | } | |||
7621 | ||||
7622 | void SAL_CALL ScTableSheetObj::unprotect( const OUString& aPassword ) | |||
7623 | { | |||
7624 | SolarMutexGuard aGuard; | |||
7625 | ScDocShell* pDocSh = GetDocShell(); | |||
7626 | if ( pDocSh ) | |||
7627 | { | |||
7628 | bool bDone = pDocSh->GetDocFunc().Unprotect( GetTab_Impl(), aPassword, true ); | |||
7629 | if (!bDone) | |||
7630 | throw lang::IllegalArgumentException(); | |||
7631 | } | |||
7632 | } | |||
7633 | ||||
7634 | sal_Bool SAL_CALL ScTableSheetObj::isProtected() | |||
7635 | { | |||
7636 | SolarMutexGuard aGuard; | |||
7637 | ScDocShell* pDocSh = GetDocShell(); | |||
7638 | if ( pDocSh ) | |||
7639 | return pDocSh->GetDocument().IsTabProtected( GetTab_Impl() ); | |||
7640 | ||||
7641 | OSL_FAIL("no DocShell")do { if (true && (((sal_Bool)1))) { sal_detail_logFormat ((SAL_DETAIL_LOG_LEVEL_WARN), ("legacy.osl"), ("/home/maarten/src/libreoffice/core/sc/source/ui/unoobj/cellsuno.cxx" ":" "7641" ": "), "%s", "no DocShell"); } } while (false); //! Exception or so? | |||
7642 | return false; | |||
7643 | } | |||
7644 | ||||
7645 | // XScenario | |||
7646 | ||||
7647 | sal_Bool SAL_CALL ScTableSheetObj::getIsScenario() | |||
7648 | { | |||
7649 | SolarMutexGuard aGuard; | |||
7650 | ScDocShell* pDocSh = GetDocShell(); | |||
7651 | if ( pDocSh ) | |||
7652 | return pDocSh->GetDocument().IsScenario( GetTab_Impl() ); | |||
7653 | ||||
7654 | return false; | |||
7655 | } | |||
7656 | ||||
7657 | OUString SAL_CALL ScTableSheetObj::getScenarioComment() | |||
7658 | { | |||
7659 | SolarMutexGuard aGuard; | |||
7660 | ScDocShell* pDocSh = GetDocShell(); | |||
7661 | if ( pDocSh ) | |||
7662 | { | |||
7663 | OUString aComment; | |||
7664 | Color aColor; | |||
7665 | ScScenarioFlags nFlags; | |||
7666 | pDocSh->GetDocument().GetScenarioData( GetTab_Impl(), aComment, aColor, nFlags ); | |||
7667 | return aComment; | |||
7668 | } | |||
7669 | return OUString(); | |||
7670 | } | |||
7671 | ||||
7672 | void SAL_CALL ScTableSheetObj::setScenarioComment( const OUString& aScenarioComment ) | |||
7673 | { | |||
7674 | SolarMutexGuard aGuard; | |||
7675 | ScDocShell* pDocSh = GetDocShell(); | |||
7676 | if ( !pDocSh ) | |||
7677 | return; | |||
7678 | ||||
7679 | ScDocument& rDoc = pDocSh->GetDocument(); | |||
7680 | SCTAB nTab = GetTab_Impl(); | |||
7681 | ||||
7682 | OUString aName; | |||
7683 | OUString aComment; | |||
7684 | Color aColor; | |||
7685 | ScScenarioFlags nFlags; | |||
7686 | rDoc.GetName( nTab, aName ); | |||
7687 | rDoc.GetScenarioData( nTab, aComment, aColor, nFlags ); | |||
7688 | ||||
7689 | aComment = aScenarioComment; | |||
7690 | ||||
7691 | pDocSh->ModifyScenario( nTab, aName, aComment, aColor, nFlags ); | |||
7692 | } | |||
7693 | ||||
7694 | void SAL_CALL ScTableSheetObj::addRanges( const uno::Sequence<table::CellRangeAddress>& rScenRanges ) | |||
7695 | { | |||
7696 | SolarMutexGuard aGuard; | |||
7697 | ScDocShell* pDocSh = GetDocShell(); | |||
7698 | if ( !pDocSh ) | |||
7699 | return; | |||
7700 | ||||
7701 | ScDocument& rDoc = pDocSh->GetDocument(); | |||
7702 | SCTAB nTab = GetTab_Impl(); | |||
7703 | ||||
7704 | if (!rDoc.IsScenario(nTab)) | |||
7705 | return; | |||
7706 | ||||
7707 | ScMarkData aMarkData(rDoc.GetSheetLimits()); | |||
7708 | aMarkData.SelectTable( nTab, true ); | |||
7709 | ||||
7710 | for (const table::CellRangeAddress& rRange : rScenRanges) | |||
7711 | { | |||
7712 | OSL_ENSURE( rRange.Sheet == nTab, "addRanges with wrong Tab" )do { if (true && (!(rRange.Sheet == nTab))) { sal_detail_logFormat ((SAL_DETAIL_LOG_LEVEL_WARN), ("legacy.osl"), ("/home/maarten/src/libreoffice/core/sc/source/ui/unoobj/cellsuno.cxx" ":" "7712" ": "), "%s", "addRanges with wrong Tab"); } } while (false); | |||
7713 | ScRange aOneRange( static_cast<SCCOL>(rRange.StartColumn), static_cast<SCROW>(rRange.StartRow), nTab, | |||
7714 | static_cast<SCCOL>(rRange.EndColumn), static_cast<SCROW>(rRange.EndRow), nTab ); | |||
7715 | ||||
7716 | aMarkData.SetMultiMarkArea( aOneRange ); | |||
7717 | } | |||
7718 | ||||
7719 | // Scenario ranges are tagged with attribute | |||
7720 | ScPatternAttr aPattern( rDoc.GetPool() ); | |||
7721 | aPattern.GetItemSet().Put( ScMergeFlagAttr( ScMF::Scenario ) ); | |||
7722 | aPattern.GetItemSet().Put( ScProtectionAttr( true ) ); | |||
7723 | pDocSh->GetDocFunc().ApplyAttributes( aMarkData, aPattern, true ); | |||
7724 | } | |||
7725 | ||||
7726 | void SAL_CALL ScTableSheetObj::apply() | |||
7727 | { | |||
7728 | SolarMutexGuard aGuard; | |||
7729 | ScDocShell* pDocSh = GetDocShell(); | |||
7730 | if ( !pDocSh ) | |||
7731 | return; | |||
7732 | ||||
7733 | ScDocument& rDoc = pDocSh->GetDocument(); | |||
7734 | SCTAB nTab = GetTab_Impl(); | |||
7735 | OUString aName; | |||
7736 | rDoc.GetName( nTab, aName ); // scenario name | |||
7737 | ||||
7738 | SCTAB nDestTab = nTab; | |||
7739 | while ( nDestTab > 0 && rDoc.IsScenario(nDestTab) ) | |||
7740 | --nDestTab; | |||
7741 | ||||
7742 | if ( !rDoc.IsScenario(nDestTab) ) | |||
7743 | pDocSh->UseScenario( nDestTab, aName ); | |||
7744 | ||||
7745 | //! otherwise error or so | |||
7746 | } | |||
7747 | ||||
7748 | // XScenarioEnhanced | |||
7749 | ||||
7750 | uno::Sequence< table::CellRangeAddress > SAL_CALL ScTableSheetObj::getRanges( ) | |||
7751 | { | |||
7752 | SolarMutexGuard aGuard; | |||
7753 | ScDocShell* pDocSh = GetDocShell(); | |||
7754 | if ( pDocSh ) | |||
7755 | { | |||
7756 | ScDocument& rDoc = pDocSh->GetDocument(); | |||
7757 | SCTAB nTab = GetTab_Impl(); | |||
7758 | const ScRangeList* pRangeList = rDoc.GetScenarioRanges(nTab); | |||
7759 | if (pRangeList) | |||
7760 | { | |||
7761 | size_t nCount = pRangeList->size(); | |||
7762 | uno::Sequence< table::CellRangeAddress > aRetRanges( nCount ); | |||
7763 | table::CellRangeAddress* pAry = aRetRanges.getArray(); | |||
7764 | for( size_t nIndex = 0; nIndex < nCount; nIndex++ ) | |||
7765 | { | |||
7766 | const ScRange & rRange = (*pRangeList)[nIndex]; | |||
7767 | pAry->StartColumn = rRange.aStart.Col(); | |||
7768 | pAry->StartRow = rRange.aStart.Row(); | |||
7769 | pAry->EndColumn = rRange.aEnd.Col(); | |||
7770 | pAry->EndRow = rRange.aEnd.Row(); | |||
7771 | pAry->Sheet = rRange.aStart.Tab(); | |||
7772 | ++pAry; | |||
7773 | } | |||
7774 | return aRetRanges; | |||
7775 | } | |||
7776 | } | |||
7777 | return uno::Sequence< table::CellRangeAddress > (); | |||
7778 | } | |||
7779 | ||||
7780 | // XExternalSheetName | |||
7781 | ||||
7782 | void ScTableSheetObj::setExternalName( const OUString& aUrl, const OUString& aSheetName ) | |||
7783 | { | |||
7784 | SolarMutexGuard aGuard; | |||
7785 | ScDocShell* pDocSh = GetDocShell(); | |||
7786 | if ( pDocSh ) | |||
7787 | { | |||
7788 | ScDocument& rDoc = pDocSh->GetDocument(); | |||
7789 | const SCTAB nTab = GetTab_Impl(); | |||
7790 | const OUString aAbsDocName( ScGlobal::GetAbsDocName( aUrl, pDocSh ) ); | |||
7791 | const OUString aDocTabName( ScGlobal::GetDocTabName( aAbsDocName, aSheetName ) ); | |||
7792 | if ( !rDoc.RenameTab( nTab, aDocTabName, true /*bExternalDocument*/ ) ) | |||
7793 | { | |||
7794 | throw container::ElementExistException( OUString(), *this ); | |||
7795 | } | |||
7796 | } | |||
7797 | } | |||
7798 | ||||
7799 | // XEventsSupplier | |||
7800 | ||||
7801 | uno::Reference<container::XNameReplace> SAL_CALL ScTableSheetObj::getEvents() | |||
7802 | { | |||
7803 | SolarMutexGuard aGuard; | |||
7804 | ScDocShell* pDocSh = GetDocShell(); | |||
7805 | if ( pDocSh ) | |||
7806 | return new ScSheetEventsObj( pDocSh, GetTab_Impl() ); | |||
7807 | ||||
7808 | return nullptr; | |||
7809 | } | |||
7810 | ||||
7811 | // XPropertySet extended for Sheet-Properties | |||
7812 | ||||
7813 | uno::Reference<beans::XPropertySetInfo> SAL_CALL ScTableSheetObj::getPropertySetInfo() | |||
7814 | { | |||
7815 | SolarMutexGuard aGuard; | |||
7816 | static uno::Reference<beans::XPropertySetInfo> aRef( | |||
7817 | new SfxItemPropertySetInfo( pSheetPropSet->getPropertyMap() )); | |||
7818 | return aRef; | |||
7819 | } | |||
7820 | ||||
7821 | void ScTableSheetObj::SetOnePropertyValue( const SfxItemPropertySimpleEntry* pEntry, const uno::Any& aValue ) | |||
7822 | { | |||
7823 | if ( !pEntry ) | |||
7824 | return; | |||
7825 | ||||
7826 | if ( IsScItemWid( pEntry->nWID ) ) | |||
7827 | { | |||
7828 | // for Item WIDs, call ScCellRangesBase directly | |||
7829 | ScCellRangesBase::SetOnePropertyValue(pEntry, aValue); | |||
7830 | return; | |||
7831 | } | |||
7832 | ||||
7833 | // own properties | |||
7834 | ||||
7835 | ScDocShell* pDocSh = GetDocShell(); | |||
7836 | if (!pDocSh) | |||
7837 | return; //! Exception or so? | |||
7838 | ScDocument& rDoc = pDocSh->GetDocument(); | |||
7839 | SCTAB nTab = GetTab_Impl(); | |||
7840 | ScDocFunc &rFunc = pDocSh->GetDocFunc(); | |||
7841 | ||||
7842 | if ( pEntry->nWID == SC_WID_UNO_PAGESTL( 1200 + 14 ) ) | |||
7843 | { | |||
7844 | OUString aStrVal; | |||
7845 | aValue >>= aStrVal; | |||
7846 | OUString aNewStr(ScStyleNameConversion::ProgrammaticToDisplayName( | |||
7847 | aStrVal, SfxStyleFamily::Page )); | |||
7848 | ||||
7849 | //! Undo? (also if SID_STYLE_APPLY on View) | |||
7850 | ||||
7851 | if ( rDoc.GetPageStyle( nTab ) != aNewStr ) | |||
7852 | { | |||
7853 | rDoc.SetPageStyle( nTab, aNewStr ); | |||
7854 | if (!rDoc.IsImportingXML()) | |||
7855 | { | |||
7856 | ScPrintFunc( pDocSh, pDocSh->GetPrinter(), nTab ).UpdatePages(); | |||
7857 | ||||
7858 | SfxBindings* pBindings = pDocSh->GetViewBindings(); | |||
7859 | if (pBindings) | |||
7860 | { | |||
7861 | pBindings->Invalidate( SID_STYLE_FAMILY4((5000 + 541) + 3) ); | |||
7862 | pBindings->Invalidate( SID_STATUS_PAGESTYLE((26000 + 100) + 15) ); | |||
7863 | pBindings->Invalidate( FID_RESET_PRINTZOOM((((26000 + 521) + 50))+82) ); | |||
7864 | pBindings->Invalidate( SID_ATTR_PARA_LEFT_TO_RIGHT( 10000 + 950 ) ); | |||
7865 | pBindings->Invalidate( SID_ATTR_PARA_RIGHT_TO_LEFT( 10000 + 951 ) ); | |||
7866 | } | |||
7867 | } | |||
7868 | pDocSh->SetDocumentModified(); | |||
7869 | } | |||
7870 | } | |||
7871 | else if ( pEntry->nWID == SC_WID_UNO_CELLVIS( 1200 + 15 ) ) | |||
7872 | { | |||
7873 | bool bVis = ScUnoHelpFunctions::GetBoolFromAny( aValue ); | |||
7874 | rFunc.SetTableVisible( nTab, bVis, true ); | |||
7875 | } | |||
7876 | else if ( pEntry->nWID == SC_WID_UNO_ISACTIVE( 1200 + 29 ) ) | |||
7877 | { | |||
7878 | if (rDoc.IsScenario(nTab)) | |||
7879 | rDoc.SetActiveScenario( nTab, ScUnoHelpFunctions::GetBoolFromAny( aValue ) ); | |||
7880 | } | |||
7881 | else if ( pEntry->nWID == SC_WID_UNO_BORDCOL( 1200 + 30 ) ) | |||
7882 | { | |||
7883 | if (rDoc.IsScenario(nTab)) | |||
7884 | { | |||
7885 | sal_Int32 nNewColor = 0; | |||
7886 | if (aValue >>= nNewColor) | |||
7887 | { | |||
7888 | OUString aName; | |||
7889 | OUString aComment; | |||
7890 | Color aColor; | |||
7891 | ScScenarioFlags nFlags; | |||
7892 | rDoc.GetName( nTab, aName ); | |||
7893 | rDoc.GetScenarioData( nTab, aComment, aColor, nFlags ); | |||
7894 | ||||
7895 | aColor = Color(static_cast<sal_uInt32>(nNewColor)); | |||
7896 | ||||
7897 | pDocSh->ModifyScenario( nTab, aName, aComment, aColor, nFlags ); | |||
7898 | } | |||
7899 | } | |||
7900 | } | |||
7901 | else if ( pEntry->nWID == SC_WID_UNO_PROTECT( 1200 + 31 ) ) | |||
7902 | { | |||
7903 | if (rDoc.IsScenario(nTab)) | |||
7904 | { | |||
7905 | OUString aName; | |||
7906 | OUString aComment; | |||
7907 | Color aColor; | |||
7908 | ScScenarioFlags nFlags; | |||
7909 | rDoc.GetName( nTab, aName ); | |||
7910 | rDoc.GetScenarioData( nTab, aComment, aColor, nFlags ); | |||
7911 | bool bModify(false); | |||
7912 | ||||
7913 | if (ScUnoHelpFunctions::GetBoolFromAny( aValue )) | |||
7914 | { | |||
7915 | if (!(nFlags & ScScenarioFlags::Protected)) | |||
7916 | { | |||
7917 | nFlags |= ScScenarioFlags::Protected; | |||
7918 | bModify = true; | |||
7919 | } | |||
7920 | } | |||
7921 | else | |||
7922 | { | |||
7923 | if (nFlags & ScScenarioFlags::Protected) | |||
7924 | { | |||
7925 | nFlags &= ~ScScenarioFlags::Protected; | |||
7926 | bModify = true; | |||
7927 | } | |||
7928 | } | |||
7929 | ||||
7930 | if (bModify) | |||
7931 | pDocSh->ModifyScenario( nTab, aName, aComment, aColor, nFlags ); | |||
7932 | } | |||
7933 | } | |||
7934 | else if ( pEntry->nWID == SC_WID_UNO_SHOWBORD( 1200 + 32 ) ) | |||
7935 | { | |||
7936 | if (rDoc.IsScenario(nTab)) | |||
7937 | { | |||
7938 | OUString aName; | |||
7939 | OUString aComment; | |||
7940 | Color aColor; | |||
7941 | ScScenarioFlags nFlags; | |||
7942 | rDoc.GetName( nTab, aName ); | |||
7943 | rDoc.GetScenarioData( nTab, aComment, aColor, nFlags ); | |||
7944 | bool bModify(false); | |||
7945 | ||||
7946 | if (ScUnoHelpFunctions::GetBoolFromAny( aValue )) | |||
7947 | { | |||
7948 | if (!(nFlags & ScScenarioFlags::ShowFrame)) | |||
7949 | { | |||
7950 | nFlags |= ScScenarioFlags::ShowFrame; | |||
7951 | bModify = true; | |||
7952 | } | |||
7953 | } | |||
7954 | else | |||
7955 | { | |||
7956 | if (nFlags & ScScenarioFlags::ShowFrame) | |||
7957 | { | |||
7958 | nFlags &= ~ScScenarioFlags::ShowFrame; | |||
7959 | bModify = true; | |||
7960 | } | |||
7961 | } | |||
7962 | ||||
7963 | if (bModify) | |||
7964 | pDocSh->ModifyScenario( nTab, aName, aComment, aColor, nFlags ); | |||
7965 | } | |||
7966 | } | |||
7967 | else if ( pEntry->nWID == SC_WID_UNO_PRINTBORD( 1200 + 33 ) ) | |||
7968 | { | |||
7969 | if (rDoc.IsScenario(nTab)) | |||
7970 | { | |||
7971 | OUString aName; | |||
7972 | OUString aComment; | |||
7973 | Color aColor; | |||
7974 | ScScenarioFlags nFlags; | |||
7975 | rDoc.GetName( nTab, aName ); | |||
7976 | rDoc.GetScenarioData( nTab, aComment, aColor, nFlags ); | |||
7977 | bool bModify(false); | |||
7978 | ||||
7979 | if (ScUnoHelpFunctions::GetBoolFromAny( aValue )) | |||
7980 | { | |||
7981 | if (!(nFlags & ScScenarioFlags::PrintFrame)) | |||
7982 | { | |||
7983 | nFlags |= ScScenarioFlags::PrintFrame; | |||
7984 | bModify = true; | |||
7985 | } | |||
7986 | } | |||
7987 | else | |||
7988 | { | |||
7989 | if (nFlags & ScScenarioFlags::PrintFrame) | |||
7990 | { | |||
7991 | nFlags &= ~ScScenarioFlags::PrintFrame; | |||
7992 | bModify = true; | |||
7993 | } | |||
7994 | } | |||
7995 | ||||
7996 | if (bModify) | |||
7997 | pDocSh->ModifyScenario( nTab, aName, aComment, aColor, nFlags ); | |||
7998 | } | |||
7999 | } | |||
8000 | else if ( pEntry->nWID == SC_WID_UNO_COPYBACK( 1200 + 34 ) ) | |||
8001 | { | |||
8002 | if (rDoc.IsScenario(nTab)) | |||
8003 | { | |||
8004 | OUString aName; | |||
8005 | OUString aComment; | |||
8006 | Color aColor; | |||
8007 | ScScenarioFlags nFlags; | |||
8008 | rDoc.GetName( nTab, aName ); | |||
8009 | rDoc.GetScenarioData( nTab, aComment, aColor, nFlags ); | |||
8010 | bool bModify(false); | |||
8011 | ||||
8012 | if (ScUnoHelpFunctions::GetBoolFromAny( aValue )) | |||
8013 | { | |||
8014 | if (!(nFlags & ScScenarioFlags::TwoWay)) | |||
8015 | { | |||
8016 | nFlags |= ScScenarioFlags::TwoWay; | |||
8017 | bModify = true; | |||
8018 | } | |||
8019 | } | |||
8020 | else | |||
8021 | { | |||
8022 | if (nFlags & ScScenarioFlags::TwoWay) | |||
8023 | { | |||
8024 | nFlags &= ~ScScenarioFlags::TwoWay; | |||
8025 | bModify = true; | |||
8026 | } | |||
8027 | } | |||
8028 | ||||
8029 | if (bModify) | |||
8030 | pDocSh->ModifyScenario( nTab, aName, aComment, aColor, nFlags ); | |||
8031 | } | |||
8032 | } | |||
8033 | else if ( pEntry->nWID == SC_WID_UNO_COPYSTYL( 1200 + 35 ) ) | |||
8034 | { | |||
8035 | if (rDoc.IsScenario(nTab)) | |||
8036 | { | |||
8037 | OUString aName; | |||
8038 | OUString aComment; | |||
8039 | Color aColor; | |||
8040 | ScScenarioFlags nFlags; | |||
8041 | rDoc.GetName( nTab, aName ); | |||
8042 | rDoc.GetScenarioData( nTab, aComment, aColor, nFlags ); | |||
8043 | bool bModify(false); | |||
8044 | ||||
8045 | if (ScUnoHelpFunctions::GetBoolFromAny( aValue )) | |||
8046 | { | |||
8047 | if (!(nFlags & ScScenarioFlags::Attrib)) | |||
8048 | { | |||
8049 | nFlags |= ScScenarioFlags::Attrib; | |||
8050 | bModify = true; | |||
8051 | } | |||
8052 | } | |||
8053 | else | |||
8054 | { | |||
8055 | if (nFlags & ScScenarioFlags::Attrib) | |||
8056 | { | |||
8057 | nFlags &= ~ScScenarioFlags::Attrib; | |||
8058 | bModify = true; | |||
8059 | } | |||
8060 | } | |||
8061 | ||||
8062 | if (bModify) | |||
8063 | pDocSh->ModifyScenario( nTab, aName, aComment, aColor, nFlags ); | |||
8064 | } | |||
8065 | } | |||
8066 | else if ( pEntry->nWID == SC_WID_UNO_COPYFORM( 1200 + 36 ) ) | |||
8067 | { | |||
8068 | if (rDoc.IsScenario(nTab)) | |||
8069 | { | |||
8070 | OUString aName; | |||
8071 | OUString aComment; | |||
8072 | Color aColor; | |||
8073 | ScScenarioFlags nFlags; | |||
8074 | rDoc.GetName( nTab, aName ); | |||
8075 | rDoc.GetScenarioData( nTab, aComment, aColor, nFlags ); | |||
8076 | bool bModify(false); | |||
8077 | ||||
8078 | if (ScUnoHelpFunctions::GetBoolFromAny( aValue )) | |||
8079 | { | |||
8080 | if (nFlags & ScScenarioFlags::Value) | |||
8081 | { | |||
8082 | nFlags &= ~ScScenarioFlags::Value; | |||
8083 | bModify = true; | |||
8084 | } | |||
8085 | } | |||
8086 | else | |||
8087 | { | |||
8088 | if (!(nFlags & ScScenarioFlags::Value)) | |||
8089 | { | |||
8090 | nFlags |= ScScenarioFlags::Value; | |||
8091 | bModify = true; | |||
8092 | } | |||
8093 | } | |||
8094 | ||||
8095 | if (bModify) | |||
8096 | pDocSh->ModifyScenario( nTab, aName, aComment, aColor, nFlags ); | |||
8097 | } | |||
8098 | } | |||
8099 | else if ( pEntry->nWID == SC_WID_UNO_TABLAYOUT( 1200 + 37 ) ) | |||
8100 | { | |||
8101 | sal_Int16 nValue = 0; | |||
8102 | if (aValue >>= nValue) | |||
8103 | { | |||
8104 | if (nValue == css::text::WritingMode2::RL_TB) | |||
8105 | rFunc.SetLayoutRTL(nTab, true); | |||
8106 | else | |||
8107 | rFunc.SetLayoutRTL(nTab, false); | |||
8108 | } | |||
8109 | } | |||
8110 | else if ( pEntry->nWID == SC_WID_UNO_AUTOPRINT( 1200 + 38 ) ) | |||
8111 | { | |||
8112 | bool bAutoPrint = ScUnoHelpFunctions::GetBoolFromAny( aValue ); | |||
8113 | if (bAutoPrint) | |||
8114 | rDoc.SetPrintEntireSheet( nTab ); // clears all print ranges | |||
8115 | else | |||
8116 | { | |||
8117 | if (rDoc.IsPrintEntireSheet( nTab )) | |||
8118 | rDoc.ClearPrintRanges( nTab ); // if this flag is true, there are no PrintRanges, so Clear clears only the flag. | |||
8119 | } | |||
8120 | } | |||
8121 | else if ( pEntry->nWID == SC_WID_UNO_TABCOLOR( 1200 + 41 ) ) | |||
8122 | { | |||
8123 | Color aColor = COL_AUTO; | |||
8124 | if ( aValue >>= aColor ) | |||
8125 | { | |||
8126 | if ( rDoc.GetTabBgColor( nTab ) != aColor ) | |||
8127 | rFunc.SetTabBgColor( nTab, aColor, true, true ); | |||
8128 | } | |||
8129 | } | |||
8130 | else if ( pEntry->nWID == SC_WID_UNO_CODENAME( 1200 + 40 ) ) | |||
8131 | { | |||
8132 | OUString aCodeName; | |||
8133 | if (aValue >>= aCodeName) | |||
8134 | { | |||
8135 | pDocSh->GetDocument().SetCodeName( GetTab_Impl(), aCodeName ); | |||
8136 | } | |||
8137 | } | |||
8138 | else if (pEntry->nWID == SC_WID_UNO_CONDFORMAT( 1200 + 44 )) | |||
8139 | { | |||
8140 | uno::Reference<sheet::XConditionalFormats> xCondFormat; | |||
8141 | if (aValue >>= xCondFormat) | |||
8142 | { | |||
8143 | // how to set the format correctly | |||
8144 | } | |||
8145 | } | |||
8146 | else | |||
8147 | ScCellRangeObj::SetOnePropertyValue(pEntry, aValue); // base class, no Item WID | |||
8148 | } | |||
8149 | ||||
8150 | void ScTableSheetObj::GetOnePropertyValue( const SfxItemPropertySimpleEntry* pEntry, | |||
8151 | uno::Any& rAny ) | |||
8152 | { | |||
8153 | if ( !pEntry ) | |||
8154 | return; | |||
8155 | ||||
8156 | ScDocShell* pDocSh = GetDocShell(); | |||
8157 | if (!pDocSh) | |||
8158 | throw uno::RuntimeException(); | |||
8159 | ScDocument& rDoc = pDocSh->GetDocument(); | |||
8160 | SCTAB nTab = GetTab_Impl(); | |||
8161 | ||||
8162 | if ( pEntry->nWID == SC_WID_UNO_NAMES( 1200 + 42 ) ) | |||
8163 | { | |||
8164 | rAny <<= uno::Reference<sheet::XNamedRanges>(new ScLocalNamedRangesObj(pDocSh, this)); | |||
8165 | } | |||
8166 | else if ( pEntry->nWID == SC_WID_UNO_PAGESTL( 1200 + 14 ) ) | |||
8167 | { | |||
8168 | rAny <<= ScStyleNameConversion::DisplayToProgrammaticName( | |||
8169 | rDoc.GetPageStyle( nTab ), SfxStyleFamily::Page ); | |||
8170 | } | |||
8171 | else if ( pEntry->nWID == SC_WID_UNO_CELLVIS( 1200 + 15 ) ) | |||
8172 | { | |||
8173 | bool bVis = rDoc.IsVisible( nTab ); | |||
8174 | rAny <<= bVis; | |||
8175 | } | |||
8176 | else if ( pEntry->nWID == SC_WID_UNO_LINKDISPBIT( 1200 + 16 ) ) | |||
8177 | { | |||
8178 | // no target bitmaps for individual entries (would be all equal) | |||
8179 | // ScLinkTargetTypeObj::SetLinkTargetBitmap( aAny, SC_LINKTARGETTYPE_SHEET ); | |||
8180 | } | |||
8181 | else if ( pEntry->nWID == SC_WID_UNO_LINKDISPNAME( 1200 + 17 ) ) | |||
8182 | { | |||
8183 | // LinkDisplayName for hyperlink dialog | |||
8184 | rAny <<= getName(); // sheet name | |||
8185 | } | |||
8186 | else if ( pEntry->nWID == SC_WID_UNO_ISACTIVE( 1200 + 29 ) ) | |||
8187 | { | |||
8188 | if (rDoc.IsScenario(nTab)) | |||
8189 | rAny <<= rDoc.IsActiveScenario( nTab ); | |||
8190 | } | |||
8191 | else if ( pEntry->nWID == SC_WID_UNO_BORDCOL( 1200 + 30 ) ) | |||
8192 | { | |||
8193 | if (rDoc.IsScenario(nTab)) | |||
8194 | { | |||
8195 | OUString aComment; | |||
8196 | Color aColor; | |||
8197 | ScScenarioFlags nFlags; | |||
8198 | rDoc.GetScenarioData( nTab, aComment, aColor, nFlags ); | |||
8199 | ||||
8200 | rAny <<= aColor; | |||
8201 | } | |||
8202 | } | |||
8203 | else if ( pEntry->nWID == SC_WID_UNO_PROTECT( 1200 + 31 ) ) | |||
8204 | { | |||
8205 | if (rDoc.IsScenario(nTab)) | |||
8206 | { | |||
8207 | ScScenarioFlags nFlags; | |||
8208 | rDoc.GetScenarioFlags(nTab, nFlags); | |||
8209 | ||||
8210 | rAny <<= ((nFlags & ScScenarioFlags::Protected) != ScScenarioFlags::NONE); | |||
8211 | } | |||
8212 | } | |||
8213 | else if ( pEntry->nWID == SC_WID_UNO_SHOWBORD( 1200 + 32 ) ) | |||
8214 | { | |||
8215 | if (rDoc.IsScenario(nTab)) | |||
8216 | { | |||
8217 | ScScenarioFlags nFlags; | |||
8218 | rDoc.GetScenarioFlags(nTab, nFlags); | |||
8219 | ||||
8220 | rAny <<= ((nFlags & ScScenarioFlags::ShowFrame) != ScScenarioFlags::NONE); | |||
8221 | } | |||
8222 | } | |||
8223 | else if ( pEntry->nWID == SC_WID_UNO_PRINTBORD( 1200 + 33 ) ) | |||
8224 | { | |||
8225 | if (rDoc.IsScenario(nTab)) | |||
8226 | { | |||
8227 | ScScenarioFlags nFlags; | |||
8228 | rDoc.GetScenarioFlags(nTab, nFlags); | |||
8229 | ||||
8230 | rAny <<= ((nFlags & ScScenarioFlags::PrintFrame) != ScScenarioFlags::NONE); | |||
8231 | } | |||
8232 | } | |||
8233 | else if ( pEntry->nWID == SC_WID_UNO_COPYBACK( 1200 + 34 ) ) | |||
8234 | { | |||
8235 | if (rDoc.IsScenario(nTab)) | |||
8236 | { | |||
8237 | ScScenarioFlags nFlags; | |||
8238 | rDoc.GetScenarioFlags(nTab, nFlags); | |||
8239 | ||||
8240 | rAny <<= ((nFlags & ScScenarioFlags::TwoWay) != ScScenarioFlags::NONE); | |||
8241 | } | |||
8242 | } | |||
8243 | else if ( pEntry->nWID == SC_WID_UNO_COPYSTYL( 1200 + 35 ) ) | |||
8244 | { | |||
8245 | if (rDoc.IsScenario(nTab)) | |||
8246 | { | |||
8247 | ScScenarioFlags nFlags; | |||
8248 | rDoc.GetScenarioFlags(nTab, nFlags); | |||
8249 | ||||
8250 | rAny <<= ((nFlags & ScScenarioFlags::Attrib) != ScScenarioFlags::NONE); | |||
8251 | } | |||
8252 | } | |||
8253 | else if ( pEntry->nWID == SC_WID_UNO_COPYFORM( 1200 + 36 ) ) | |||
8254 | { | |||
8255 | if (rDoc.IsScenario(nTab)) | |||
8256 | { | |||
8257 | ScScenarioFlags nFlags; | |||
8258 | rDoc.GetScenarioFlags(nTab, nFlags); | |||
8259 | ||||
8260 | rAny <<= !(nFlags & ScScenarioFlags::Value); | |||
8261 | } | |||
8262 | } | |||
8263 | else if ( pEntry->nWID == SC_WID_UNO_TABLAYOUT( 1200 + 37 ) ) | |||
8264 | { | |||
8265 | if (rDoc.IsLayoutRTL(nTab)) | |||
8266 | rAny <<= sal_Int16(css::text::WritingMode2::RL_TB); | |||
8267 | else | |||
8268 | rAny <<= sal_Int16(css::text::WritingMode2::LR_TB); | |||
8269 | } | |||
8270 | else if ( pEntry->nWID == SC_WID_UNO_AUTOPRINT( 1200 + 38 ) ) | |||
8271 | { | |||
8272 | bool bAutoPrint = rDoc.IsPrintEntireSheet( nTab ); | |||
8273 | rAny <<= bAutoPrint; | |||
8274 | } | |||
8275 | else if ( pEntry->nWID == SC_WID_UNO_TABCOLOR( 1200 + 41 ) ) | |||
8276 | { | |||
8277 | rAny <<= rDoc.GetTabBgColor(nTab); | |||
8278 | } | |||
8279 | else if ( pEntry->nWID == SC_WID_UNO_CODENAME( 1200 + 40 ) ) | |||
8280 | { | |||
8281 | OUString aCodeName; | |||
8282 | pDocSh->GetDocument().GetCodeName(GetTab_Impl(), aCodeName); | |||
8283 | rAny <<= aCodeName; | |||
8284 | } | |||
8285 | else if (pEntry->nWID == SC_WID_UNO_CONDFORMAT( 1200 + 44 )) | |||
8286 | { | |||
8287 | rAny <<= uno::Reference<sheet::XConditionalFormats>(new ScCondFormatsObj(pDocSh, nTab)); | |||
8288 | } | |||
8289 | else | |||
8290 | ScCellRangeObj::GetOnePropertyValue(pEntry, rAny); | |||
8291 | } | |||
8292 | ||||
8293 | const SfxItemPropertyMap& ScTableSheetObj::GetItemPropertyMap() | |||
8294 | { | |||
8295 | return pSheetPropSet->getPropertyMap(); | |||
8296 | } | |||
8297 | ||||
8298 | // XServiceInfo | |||
8299 | ||||
8300 | OUString SAL_CALL ScTableSheetObj::getImplementationName() | |||
8301 | { | |||
8302 | return "ScTableSheetObj"; | |||
8303 | } | |||
8304 | ||||
8305 | sal_Bool SAL_CALL ScTableSheetObj::supportsService( const OUString& rServiceName ) | |||
8306 | { | |||
8307 | return cppu::supportsService(this, rServiceName); | |||
8308 | } | |||
8309 | ||||
8310 | uno::Sequence<OUString> SAL_CALL ScTableSheetObj::getSupportedServiceNames() | |||
8311 | { | |||
8312 | return {SCSPREADSHEET_SERVICE"com.sun.star.sheet.Spreadsheet", | |||
8313 | SCSHEETCELLRANGE_SERVICE"com.sun.star.sheet.SheetCellRange", | |||
8314 | SCCELLRANGE_SERVICE"com.sun.star.table.CellRange", | |||
8315 | SCCELLPROPERTIES_SERVICE"com.sun.star.table.CellProperties", | |||
8316 | SCCHARPROPERTIES_SERVICE"com.sun.star.style.CharacterProperties", | |||
8317 | SCPARAPROPERTIES_SERVICE"com.sun.star.style.ParagraphProperties", | |||
8318 | SCLINKTARGET_SERVICE"com.sun.star.document.LinkTarget"}; | |||
8319 | } | |||
8320 | ||||
8321 | // XUnoTunnel | |||
8322 | ||||
8323 | UNO3_GETIMPLEMENTATION2_IMPL(ScTableSheetObj, ScCellRangeObj)namespace { class theScTableSheetObjUnoTunnelId : public rtl:: Static< UnoTunnelIdInit, theScTableSheetObjUnoTunnelId> {}; } const css::uno::Sequence< sal_Int8 > & ScTableSheetObj ::getUnoTunnelId() throw() { return theScTableSheetObjUnoTunnelId ::get().getSeq(); }sal_Int64 ScTableSheetObj::getSomething( const css::uno::Sequence< sal_Int8 >& rId ) { if( isUnoTunnelId <ScTableSheetObj>(rId) ) { return sal::static_int_cast< sal_Int64>(reinterpret_cast<sal_IntPtr>(this)); } else { return ScCellRangeObj::getSomething( rId ); } }; | |||
8324 | ||||
8325 | ScTableColumnObj::ScTableColumnObj( ScDocShell* pDocSh, SCCOL nCol, SCTAB nTab ) : | |||
8326 | ScCellRangeObj( pDocSh, ScRange(nCol,0,nTab, nCol, pDocSh->GetDocument().MaxRow(),nTab) ), | |||
8327 | pColPropSet(lcl_GetColumnPropertySet()) | |||
8328 | { | |||
8329 | } | |||
8330 | ||||
8331 | ScTableColumnObj::~ScTableColumnObj() | |||
8332 | { | |||
8333 | } | |||
8334 | ||||
8335 | uno::Any SAL_CALL ScTableColumnObj::queryInterface( const uno::Type& rType ) | |||
8336 | { | |||
8337 | SC_QUERYINTERFACE( container::XNamed )if (rType == cppu::UnoType<container::XNamed>::get()) { return uno::makeAny(uno::Reference<container::XNamed>( this)); } | |||
8338 | ||||
8339 | return ScCellRangeObj::queryInterface( rType ); | |||
8340 | } | |||
8341 | ||||
8342 | void SAL_CALL ScTableColumnObj::acquire() throw() | |||
8343 | { | |||
8344 | ScCellRangeObj::acquire(); | |||
8345 | } | |||
8346 | ||||
8347 | void SAL_CALL ScTableColumnObj::release() throw() | |||
8348 | { | |||
8349 | ScCellRangeObj::release(); | |||
8350 | } | |||
8351 | ||||
8352 | uno::Sequence<uno::Type> SAL_CALL ScTableColumnObj::getTypes() | |||
8353 | { | |||
8354 | return comphelper::concatSequences( | |||
8355 | ScCellRangeObj::getTypes(), | |||
8356 | uno::Sequence<uno::Type> { cppu::UnoType<container::XNamed>::get() } ); | |||
8357 | } | |||
8358 | ||||
8359 | uno::Sequence<sal_Int8> SAL_CALL ScTableColumnObj::getImplementationId() | |||
8360 | { | |||
8361 | return css::uno::Sequence<sal_Int8>(); | |||
8362 | } | |||
8363 | ||||
8364 | // XNamed | |||
8365 | ||||
8366 | OUString SAL_CALL ScTableColumnObj::getName() | |||
8367 | { | |||
8368 | SolarMutexGuard aGuard; | |||
8369 | ||||
8370 | const ScRange& rRange = GetRange(); | |||
8371 | OSL_ENSURE(rRange.aStart.Col() == rRange.aEnd.Col(), "too many columns")do { if (true && (!(rRange.aStart.Col() == rRange.aEnd .Col()))) { sal_detail_logFormat((SAL_DETAIL_LOG_LEVEL_WARN), ("legacy.osl"), ("/home/maarten/src/libreoffice/core/sc/source/ui/unoobj/cellsuno.cxx" ":" "8371" ": "), "%s", "too many columns"); } } while (false ); | |||
8372 | SCCOL nCol = rRange.aStart.Col(); | |||
8373 | ||||
8374 | return ScColToAlpha( nCol ); // from global.hxx | |||
8375 | } | |||
8376 | ||||
8377 | void SAL_CALL ScTableColumnObj::setName( const OUString& /* aNewName */ ) | |||
8378 | { | |||
8379 | SolarMutexGuard aGuard; | |||
8380 | throw uno::RuntimeException(); // read-only | |||
8381 | } | |||
8382 | ||||
8383 | // XPropertySet extended for Column-Properties | |||
8384 | ||||
8385 | uno::Reference<beans::XPropertySetInfo> SAL_CALL ScTableColumnObj::getPropertySetInfo() | |||
8386 | { | |||
8387 | SolarMutexGuard aGuard; | |||
8388 | static uno::Reference<beans::XPropertySetInfo> aRef( | |||
8389 | new SfxItemPropertySetInfo( pColPropSet->getPropertyMap() )); | |||
8390 | return aRef; | |||
8391 | } | |||
8392 | ||||
8393 | void ScTableColumnObj::SetOnePropertyValue(const SfxItemPropertySimpleEntry* pEntry, const uno::Any& aValue) | |||
8394 | { | |||
8395 | if ( !pEntry ) | |||
8396 | return; | |||
8397 | ||||
8398 | if ( IsScItemWid( pEntry->nWID ) ) | |||
8399 | { | |||
8400 | // for Item WIDs, call ScCellRangesBase directly | |||
8401 | ScCellRangesBase::SetOnePropertyValue(pEntry, aValue); | |||
8402 | return; | |||
8403 | } | |||
8404 | ||||
8405 | // own properties | |||
8406 | ||||
8407 | ScDocShell* pDocSh = GetDocShell(); | |||
8408 | if (!pDocSh) | |||
8409 | return; //! Exception or so? | |||
8410 | const ScRange& rRange = GetRange(); | |||
8411 | OSL_ENSURE(rRange.aStart.Col() == rRange.aEnd.Col(), "Too many columns")do { if (true && (!(rRange.aStart.Col() == rRange.aEnd .Col()))) { sal_detail_logFormat((SAL_DETAIL_LOG_LEVEL_WARN), ("legacy.osl"), ("/home/maarten/src/libreoffice/core/sc/source/ui/unoobj/cellsuno.cxx" ":" "8411" ": "), "%s", "Too many columns"); } } while (false ); | |||
8412 | SCCOL nCol = rRange.aStart.Col(); | |||
8413 | SCTAB nTab = rRange.aStart.Tab(); | |||
8414 | ScDocFunc &rFunc = pDocSh->GetDocFunc(); | |||
8415 | ||||
8416 | std::vector<sc::ColRowSpan> aColArr(1, sc::ColRowSpan(nCol,nCol)); | |||
8417 | ||||
8418 | if ( pEntry->nWID == SC_WID_UNO_CELLWID( 1200 + 18 ) ) | |||
8419 | { | |||
8420 | sal_Int32 nNewWidth = 0; | |||
8421 | if ( aValue >>= nNewWidth ) | |||
8422 | { | |||
8423 | // property is 1/100mm, column width is twips | |||
8424 | nNewWidth = HMMToTwips(nNewWidth); | |||
8425 | rFunc.SetWidthOrHeight( | |||
8426 | true, aColArr, nTab, SC_SIZE_ORIGINAL, static_cast<sal_uInt16>(nNewWidth), true, true); | |||
8427 | } | |||
8428 | } | |||
8429 | else if ( pEntry->nWID == SC_WID_UNO_CELLVIS( 1200 + 15 ) ) | |||
8430 | { | |||
8431 | bool bVis = ScUnoHelpFunctions::GetBoolFromAny( aValue ); | |||
8432 | ScSizeMode eMode = bVis ? SC_SIZE_SHOW : SC_SIZE_DIRECT; | |||
8433 | rFunc.SetWidthOrHeight(true, aColArr, nTab, eMode, 0, true, true); | |||
8434 | // SC_SIZE_DIRECT with size 0 will hide | |||
8435 | } | |||
8436 | else if ( pEntry->nWID == SC_WID_UNO_OWIDTH( 1200 + 19 ) ) | |||
8437 | { | |||
8438 | bool bOpt = ScUnoHelpFunctions::GetBoolFromAny( aValue ); | |||
8439 | if (bOpt) | |||
8440 | rFunc.SetWidthOrHeight( | |||
8441 | true, aColArr, nTab, SC_SIZE_OPTIMAL, STD_EXTRA_WIDTH113, true, true); | |||
8442 | // sal_False on columns currently without effect | |||
8443 | } | |||
8444 | else if ( pEntry->nWID == SC_WID_UNO_NEWPAGE( 1200 + 20 ) || pEntry->nWID == SC_WID_UNO_MANPAGE( 1200 + 21 ) ) | |||
8445 | { | |||
8446 | bool bSet = ScUnoHelpFunctions::GetBoolFromAny( aValue ); | |||
8447 | if (bSet) | |||
8448 | rFunc.InsertPageBreak( true, rRange.aStart, true, true ); | |||
8449 | else | |||
8450 | rFunc.RemovePageBreak( true, rRange.aStart, true, true ); | |||
8451 | } | |||
8452 | else | |||
8453 | ScCellRangeObj::SetOnePropertyValue(pEntry, aValue); // base class, no Item WID | |||
8454 | } | |||
8455 | ||||
8456 | void ScTableColumnObj::GetOnePropertyValue( const SfxItemPropertySimpleEntry* pEntry, uno::Any& rAny ) | |||
8457 | { | |||
8458 | if ( !pEntry ) | |||
8459 | return; | |||
8460 | ||||
8461 | ScDocShell* pDocSh = GetDocShell(); | |||
8462 | if (!pDocSh) | |||
8463 | throw uno::RuntimeException(); | |||
8464 | ||||
8465 | ScDocument& rDoc = pDocSh->GetDocument(); | |||
8466 | const ScRange& rRange = GetRange(); | |||
8467 | OSL_ENSURE(rRange.aStart.Col() == rRange.aEnd.Col(), "too many columns")do { if (true && (!(rRange.aStart.Col() == rRange.aEnd .Col()))) { sal_detail_logFormat((SAL_DETAIL_LOG_LEVEL_WARN), ("legacy.osl"), ("/home/maarten/src/libreoffice/core/sc/source/ui/unoobj/cellsuno.cxx" ":" "8467" ": "), "%s", "too many columns"); } } while (false ); | |||
8468 | SCCOL nCol = rRange.aStart.Col(); | |||
8469 | SCTAB nTab = rRange.aStart.Tab(); | |||
8470 | ||||
8471 | if ( pEntry->nWID == SC_WID_UNO_CELLWID( 1200 + 18 ) ) | |||
8472 | { | |||
8473 | // for hidden column, return original height | |||
8474 | sal_uInt16 nWidth = rDoc.GetOriginalWidth( nCol, nTab ); | |||
8475 | // property is 1/100mm, column width is twips | |||
8476 | nWidth = static_cast<sal_uInt16>(TwipsToHMM(nWidth)); | |||
8477 | rAny <<= static_cast<sal_Int32>(nWidth); | |||
8478 | } | |||
8479 | else if ( pEntry->nWID == SC_WID_UNO_CELLVIS( 1200 + 15 ) ) | |||
8480 | { | |||
8481 | bool bHidden = rDoc.ColHidden(nCol, nTab); | |||
8482 | rAny <<= !bHidden; | |||
8483 | } | |||
8484 | else if ( pEntry->nWID == SC_WID_UNO_OWIDTH( 1200 + 19 ) ) | |||
8485 | { | |||
8486 | //! at the moment always set ??!?! | |||
8487 | bool bOpt = !(rDoc.GetColFlags( nCol, nTab ) & CRFlags::ManualSize); | |||
8488 | rAny <<= bOpt; | |||
8489 | } | |||
8490 | else if ( pEntry->nWID == SC_WID_UNO_NEWPAGE( 1200 + 20 ) ) | |||
8491 | { | |||
8492 | ScBreakType nBreak = rDoc.HasColBreak(nCol, nTab); | |||
8493 | rAny <<= nBreak != ScBreakType::NONE; | |||
8494 | } | |||
8495 | else if ( pEntry->nWID == SC_WID_UNO_MANPAGE( 1200 + 21 ) ) | |||
8496 | { | |||
8497 | ScBreakType nBreak = rDoc.HasColBreak(nCol, nTab); | |||
8498 | rAny <<= bool(nBreak & ScBreakType::Manual); | |||
8499 | } | |||
8500 | else | |||
8501 | ScCellRangeObj::GetOnePropertyValue(pEntry, rAny); | |||
8502 | } | |||
8503 | ||||
8504 | const SfxItemPropertyMap& ScTableColumnObj::GetItemPropertyMap() | |||
8505 | { | |||
8506 | return pColPropSet->getPropertyMap(); | |||
8507 | } | |||
8508 | ||||
8509 | ScTableRowObj::ScTableRowObj(ScDocShell* pDocSh, SCROW nRow, SCTAB nTab) : | |||
8510 | ScCellRangeObj( pDocSh, ScRange(0,nRow,nTab, pDocSh->GetDocument().MaxCol(),nRow,nTab) ), | |||
8511 | pRowPropSet(lcl_GetRowPropertySet()) | |||
8512 | { | |||
8513 | } | |||
8514 | ||||
8515 | ScTableRowObj::~ScTableRowObj() | |||
8516 | { | |||
8517 | } | |||
8518 | ||||
8519 | // XPropertySet extended for Row-Properties | |||
8520 | ||||
8521 | uno::Reference<beans::XPropertySetInfo> SAL_CALL ScTableRowObj::getPropertySetInfo() | |||
8522 | { | |||
8523 | SolarMutexGuard aGuard; | |||
8524 | static uno::Reference<beans::XPropertySetInfo> aRef( | |||
8525 | new SfxItemPropertySetInfo( pRowPropSet->getPropertyMap() )); | |||
8526 | return aRef; | |||
8527 | } | |||
8528 | ||||
8529 | void ScTableRowObj::SetOnePropertyValue( const SfxItemPropertySimpleEntry* pEntry, const uno::Any& aValue ) | |||
8530 | { | |||
8531 | if ( !pEntry ) | |||
8532 | return; | |||
8533 | ||||
8534 | if ( IsScItemWid( pEntry->nWID ) ) | |||
8535 | { | |||
8536 | // for Item WIDs, call ScCellRangesBase directly | |||
8537 | ScCellRangesBase::SetOnePropertyValue(pEntry, aValue); | |||
8538 | return; | |||
8539 | } | |||
8540 | ||||
8541 | // own properties | |||
8542 | ||||
8543 | ScDocShell* pDocSh = GetDocShell(); | |||
8544 | if (!pDocSh) | |||
8545 | return; //! Exception or so? | |||
8546 | ScDocument& rDoc = pDocSh->GetDocument(); | |||
8547 | const ScRange& rRange = GetRange(); | |||
8548 | OSL_ENSURE(rRange.aStart.Row() == rRange.aEnd.Row(), "too many rows")do { if (true && (!(rRange.aStart.Row() == rRange.aEnd .Row()))) { sal_detail_logFormat((SAL_DETAIL_LOG_LEVEL_WARN), ("legacy.osl"), ("/home/maarten/src/libreoffice/core/sc/source/ui/unoobj/cellsuno.cxx" ":" "8548" ": "), "%s", "too many rows"); } } while (false); | |||
8549 | SCROW nRow = rRange.aStart.Row(); | |||
8550 | SCTAB nTab = rRange.aStart.Tab(); | |||
8551 | ScDocFunc &rFunc = pDocSh->GetDocFunc(); | |||
8552 | ||||
8553 | std::vector<sc::ColRowSpan> aRowArr(1, sc::ColRowSpan(nRow,nRow)); | |||
8554 | ||||
8555 | if ( pEntry->nWID == SC_WID_UNO_CELLHGT( 1200 + 22 ) ) | |||
8556 | { | |||
8557 | sal_Int32 nNewHeight = 0; | |||
8558 | if ( aValue >>= nNewHeight ) | |||
8559 | { | |||
8560 | // property is 1/100mm, row height is twips | |||
8561 | nNewHeight = HMMToTwips(nNewHeight); | |||
8562 | rFunc.SetWidthOrHeight( | |||
8563 | false, aRowArr, nTab, SC_SIZE_ORIGINAL, static_cast<sal_uInt16>(nNewHeight), true, true); | |||
8564 | } | |||
8565 | } | |||
8566 | else if ( pEntry->nWID == SC_WID_UNO_CELLVIS( 1200 + 15 ) ) | |||
8567 | { | |||
8568 | bool bVis = ScUnoHelpFunctions::GetBoolFromAny( aValue ); | |||
8569 | ScSizeMode eMode = bVis ? SC_SIZE_SHOW : SC_SIZE_DIRECT; | |||
8570 | rFunc.SetWidthOrHeight(false, aRowArr, nTab, eMode, 0, true, true); | |||
8571 | // SC_SIZE_DIRECT with size zero will hide | |||
8572 | } | |||
8573 | else if ( pEntry->nWID == SC_WID_UNO_CELLFILT( 1200 + 23 ) ) | |||
8574 | { | |||
8575 | bool bFil = ScUnoHelpFunctions::GetBoolFromAny( aValue ); | |||
8576 | // SC_SIZE_DIRECT with size zero will hide | |||
8577 | rDoc.SetRowFiltered(nRow, nRow, nTab, bFil); | |||
8578 | } | |||
8579 | else if ( pEntry->nWID == SC_WID_UNO_OHEIGHT( 1200 + 24 ) ) | |||
8580 | { | |||
8581 | bool bOpt = ScUnoHelpFunctions::GetBoolFromAny( aValue ); | |||
8582 | if (bOpt) | |||
8583 | rFunc.SetWidthOrHeight(false, aRowArr, nTab, SC_SIZE_OPTIMAL, 0, true, true); | |||
8584 | else | |||
8585 | { | |||
8586 | // set current height again manually | |||
8587 | sal_uInt16 nHeight = rDoc.GetOriginalHeight( nRow, nTab ); | |||
8588 | rFunc.SetWidthOrHeight(false, aRowArr, nTab, SC_SIZE_ORIGINAL, nHeight, true, true); | |||
8589 | } | |||
8590 | } | |||
8591 | else if ( pEntry->nWID == SC_WID_UNO_NEWPAGE( 1200 + 20 ) || pEntry->nWID == SC_WID_UNO_MANPAGE( 1200 + 21 ) ) | |||
8592 | { | |||
8593 | bool bSet = ScUnoHelpFunctions::GetBoolFromAny( aValue ); | |||
8594 | if (bSet) | |||
8595 | rFunc.InsertPageBreak( false, rRange.aStart, true, true ); | |||
8596 | else | |||
8597 | rFunc.RemovePageBreak( false, rRange.aStart, true, true ); | |||
8598 | } | |||
8599 | else | |||
8600 | ScCellRangeObj::SetOnePropertyValue(pEntry, aValue); // base class, no Item WID | |||
8601 | } | |||
8602 | ||||
8603 | void ScTableRowObj::GetOnePropertyValue( const SfxItemPropertySimpleEntry* pEntry, uno::Any& rAny ) | |||
8604 | { | |||
8605 | if ( !pEntry ) | |||
8606 | return; | |||
8607 | ||||
8608 | ScDocShell* pDocSh = GetDocShell(); | |||
8609 | if (!pDocSh) | |||
8610 | throw uno::RuntimeException(); | |||
8611 | ScDocument& rDoc = pDocSh->GetDocument(); | |||
8612 | const ScRange& rRange = GetRange(); | |||
8613 | OSL_ENSURE(rRange.aStart.Row() == rRange.aEnd.Row(), "too many rows")do { if (true && (!(rRange.aStart.Row() == rRange.aEnd .Row()))) { sal_detail_logFormat((SAL_DETAIL_LOG_LEVEL_WARN), ("legacy.osl"), ("/home/maarten/src/libreoffice/core/sc/source/ui/unoobj/cellsuno.cxx" ":" "8613" ": "), "%s", "too many rows"); } } while (false); | |||
8614 | SCROW nRow = rRange.aStart.Row(); | |||
8615 | SCTAB nTab = rRange.aStart.Tab(); | |||
8616 | ||||
8617 | if ( pEntry->nWID == SC_WID_UNO_CELLHGT( 1200 + 22 ) ) | |||
8618 | { | |||
8619 | // for hidden row, return original height | |||
8620 | sal_uInt16 nHeight = rDoc.GetOriginalHeight( nRow, nTab ); | |||
8621 | // property is 1/100mm, row height is twips | |||
8622 | nHeight = static_cast<sal_uInt16>(TwipsToHMM(nHeight)); | |||
8623 | rAny <<= static_cast<sal_Int32>(nHeight); | |||
8624 | } | |||
8625 | else if ( pEntry->nWID == SC_WID_UNO_CELLVIS( 1200 + 15 ) ) | |||
8626 | { | |||
8627 | bool bHidden = rDoc.RowHidden(nRow, nTab); | |||
8628 | rAny <<= !bHidden; | |||
8629 | } | |||
8630 | else if ( pEntry->nWID == SC_WID_UNO_CELLFILT( 1200 + 23 ) ) | |||
8631 | { | |||
8632 | bool bVis = rDoc.RowFiltered(nRow, nTab); | |||
8633 | rAny <<= bVis; | |||
8634 | } | |||
8635 | else if ( pEntry->nWID == SC_WID_UNO_OHEIGHT( 1200 + 24 ) ) | |||
8636 | { | |||
8637 | bool bOpt = !(rDoc.GetRowFlags( nRow, nTab ) & CRFlags::ManualSize); | |||
8638 | rAny <<= bOpt; | |||
8639 | } | |||
8640 | else if ( pEntry->nWID == SC_WID_UNO_NEWPAGE( 1200 + 20 ) ) | |||
8641 | { | |||
8642 | ScBreakType nBreak = rDoc.HasRowBreak(nRow, nTab); | |||
8643 | rAny <<= (nBreak != ScBreakType::NONE); | |||
8644 | } | |||
8645 | else if ( pEntry->nWID == SC_WID_UNO_MANPAGE( 1200 + 21 ) ) | |||
8646 | { | |||
8647 | bool bBreak(rDoc.HasRowBreak(nRow, nTab) & ScBreakType::Manual); | |||
8648 | rAny <<= bBreak; | |||
8649 | } | |||
8650 | else | |||
8651 | ScCellRangeObj::GetOnePropertyValue(pEntry, rAny); | |||
8652 | } | |||
8653 | ||||
8654 | const SfxItemPropertyMap& ScTableRowObj::GetItemPropertyMap() | |||
8655 | { | |||
8656 | return pRowPropSet->getPropertyMap(); | |||
8657 | } | |||
8658 | ||||
8659 | ScCellsObj::ScCellsObj(ScDocShell* pDocSh, const ScRangeList& rR) : | |||
8660 | pDocShell( pDocSh ), | |||
8661 | aRanges( rR ) | |||
8662 | { | |||
8663 | pDocShell->GetDocument().AddUnoObject(*this); | |||
8664 | } | |||
8665 | ||||
8666 | ScCellsObj::~ScCellsObj() | |||
8667 | { | |||
8668 | SolarMutexGuard g; | |||
8669 | ||||
8670 | if (pDocShell) | |||
8671 | pDocShell->GetDocument().RemoveUnoObject(*this); | |||
8672 | } | |||
8673 | ||||
8674 | void ScCellsObj::Notify( SfxBroadcaster&, const SfxHint& rHint ) | |||
8675 | { | |||
8676 | if ( dynamic_cast<const ScUpdateRefHint*>(&rHint) ) | |||
8677 | { | |||
8678 | const ScUpdateRefHint& rRef = static_cast<const ScUpdateRefHint&>(rHint); | |||
8679 | aRanges.UpdateReference( rRef.GetMode(), &pDocShell->GetDocument(), rRef.GetRange(), | |||
8680 | rRef.GetDx(), rRef.GetDy(), rRef.GetDz() ); | |||
8681 | } | |||
8682 | else if ( rHint.GetId() == SfxHintId::Dying ) | |||
8683 | { | |||
8684 | pDocShell = nullptr; | |||
8685 | } | |||
8686 | } | |||
8687 | ||||
8688 | // XEnumerationAccess | |||
8689 | ||||
8690 | uno::Reference<container::XEnumeration> SAL_CALL ScCellsObj::createEnumeration() | |||
8691 | { | |||
8692 | SolarMutexGuard aGuard; | |||
8693 | if (pDocShell) | |||
8694 | return new ScCellsEnumeration( pDocShell, aRanges ); | |||
8695 | return nullptr; | |||
8696 | } | |||
8697 | ||||
8698 | uno::Type SAL_CALL ScCellsObj::getElementType() | |||
8699 | { | |||
8700 | SolarMutexGuard aGuard; | |||
8701 | return cppu::UnoType<table::XCell>::get(); | |||
8702 | } | |||
8703 | ||||
8704 | sal_Bool SAL_CALL ScCellsObj::hasElements() | |||
8705 | { | |||
8706 | SolarMutexGuard aGuard; | |||
8707 | bool bHas = false; | |||
8708 | if ( pDocShell ) | |||
8709 | { | |||
8710 | //! faster if test ourself? | |||
8711 | ||||
8712 | uno::Reference<container::XEnumeration> xEnum(new ScCellsEnumeration( pDocShell, aRanges )); | |||
8713 | bHas = xEnum->hasMoreElements(); | |||
8714 | } | |||
8715 | return bHas; | |||
8716 | } | |||
8717 | ||||
8718 | ScCellsEnumeration::ScCellsEnumeration(ScDocShell* pDocSh, const ScRangeList& rR) : | |||
8719 | pDocShell( pDocSh ), | |||
8720 | aRanges( rR ), | |||
8721 | bAtEnd( false ) | |||
8722 | { | |||
8723 | ScDocument& rDoc = pDocShell->GetDocument(); | |||
8724 | rDoc.AddUnoObject(*this); | |||
8725 | ||||
8726 | if ( aRanges.empty() ) | |||
8727 | bAtEnd = true; | |||
8728 | else | |||
8729 | { | |||
8730 | SCTAB nTab = aRanges[ 0 ].aStart.Tab(); | |||
8731 | aPos = ScAddress(0,0,nTab); | |||
8732 | CheckPos_Impl(); // set aPos on first matching cell | |||
8733 | } | |||
8734 | } | |||
8735 | ||||
8736 | void ScCellsEnumeration::CheckPos_Impl() | |||
8737 | { | |||
8738 | if (!pDocShell) | |||
8739 | return; | |||
8740 | ||||
8741 | bool bFound = false; | |||
8742 | ScDocument& rDoc = pDocShell->GetDocument(); | |||
8743 | ScRefCellValue aCell(rDoc, aPos); | |||
8744 | if (!aCell.isEmpty()) | |||
8745 | { | |||
8746 | if (!pMark) | |||
8747 | { | |||
8748 | pMark.reset( new ScMarkData(rDoc.GetSheetLimits()) ); | |||
8749 | pMark->MarkFromRangeList(aRanges, false); | |||
8750 | pMark->MarkToMulti(); // needed for GetNextMarkedCell | |||
8751 | } | |||
8752 | bFound = pMark->IsCellMarked(aPos.Col(), aPos.Row()); | |||
8753 | } | |||
8754 | if (!bFound) | |||
8755 | Advance_Impl(); | |||
8756 | } | |||
8757 | ||||
8758 | ScCellsEnumeration::~ScCellsEnumeration() | |||
8759 | { | |||
8760 | SolarMutexGuard g; | |||
8761 | ||||
8762 | if (pDocShell) | |||
8763 | pDocShell->GetDocument().RemoveUnoObject(*this); | |||
8764 | pMark.reset(); | |||
8765 | } | |||
8766 | ||||
8767 | void ScCellsEnumeration::Advance_Impl() | |||
8768 | { | |||
8769 | OSL_ENSURE(!bAtEnd,"too much Advance_Impl")do { if (true && (!(!bAtEnd))) { sal_detail_logFormat ((SAL_DETAIL_LOG_LEVEL_WARN), ("legacy.osl"), ("/home/maarten/src/libreoffice/core/sc/source/ui/unoobj/cellsuno.cxx" ":" "8769" ": "), "%s", "too much Advance_Impl"); } } while ( false); | |||
8770 | if (!pMark) | |||
8771 | { | |||
8772 | pMark.reset( new ScMarkData(pDocShell->GetDocument().GetSheetLimits()) ); | |||
8773 | pMark->MarkFromRangeList( aRanges, false ); | |||
8774 | pMark->MarkToMulti(); // needed for GetNextMarkedCell | |||
8775 | } | |||
8776 | ||||
8777 | SCCOL nCol = aPos.Col(); | |||
8778 | SCROW nRow = aPos.Row(); | |||
8779 | SCTAB nTab = aPos.Tab(); | |||
8780 | bool bFound = pDocShell->GetDocument().GetNextMarkedCell( nCol, nRow, nTab, *pMark ); | |||
8781 | if (bFound) | |||
8782 | aPos.Set( nCol, nRow, nTab ); | |||
8783 | else | |||
8784 | bAtEnd = true; // nothing will follow | |||
8785 | } | |||
8786 | ||||
8787 | void ScCellsEnumeration::Notify( SfxBroadcaster&, const SfxHint& rHint ) | |||
8788 | { | |||
8789 | const ScUpdateRefHint* pRefHint = dynamic_cast<const ScUpdateRefHint*>(&rHint); | |||
8790 | if ( pRefHint ) | |||
8791 | { | |||
8792 | if (pDocShell) | |||
8793 | { | |||
8794 | aRanges.UpdateReference( pRefHint->GetMode(), &pDocShell->GetDocument(), pRefHint->GetRange(), | |||
8795 | pRefHint->GetDx(), pRefHint->GetDy(), pRefHint->GetDz() ); | |||
8796 | ||||
8797 | pMark.reset(); // recreate from moved area | |||
8798 | ||||
8799 | if (!bAtEnd) // adjust aPos | |||
8800 | { | |||
8801 | ScRangeList aNew { ScRange(aPos) }; | |||
8802 | aNew.UpdateReference( pRefHint->GetMode(), &pDocShell->GetDocument(), pRefHint->GetRange(), | |||
8803 | pRefHint->GetDx(), pRefHint->GetDy(), pRefHint->GetDz() ); | |||
8804 | if (aNew.size()==1) | |||
8805 | { | |||
8806 | aPos = aNew[ 0 ].aStart; | |||
8807 | CheckPos_Impl(); | |||
8808 | } | |||
8809 | } | |||
8810 | } | |||
8811 | } | |||
8812 | else if ( rHint.GetId() == SfxHintId::Dying ) | |||
8813 | { | |||
8814 | pDocShell = nullptr; | |||
8815 | } | |||
8816 | } | |||
8817 | ||||
8818 | // XEnumeration | |||
8819 | ||||
8820 | sal_Bool SAL_CALL ScCellsEnumeration::hasMoreElements() | |||
8821 | { | |||
8822 | SolarMutexGuard aGuard; | |||
8823 | return !bAtEnd; | |||
8824 | } | |||
8825 | ||||
8826 | uno::Any SAL_CALL ScCellsEnumeration::nextElement() | |||
8827 | { | |||
8828 | SolarMutexGuard aGuard; | |||
8829 | if (pDocShell && !bAtEnd) | |||
8830 | { | |||
8831 | // interface must match ScCellsObj::getElementType | |||
8832 | ||||
8833 | ScAddress aTempPos(aPos); | |||
8834 | Advance_Impl(); | |||
8835 | return uno::makeAny(uno::Reference<table::XCell>(new ScCellObj( pDocShell, aTempPos ))); | |||
8836 | } | |||
8837 | ||||
8838 | throw container::NoSuchElementException(); // no more elements | |||
8839 | } | |||
8840 | ||||
8841 | ScCellFormatsObj::ScCellFormatsObj(ScDocShell* pDocSh, const ScRange& rRange) : | |||
8842 | pDocShell( pDocSh ), | |||
8843 | aTotalRange( rRange ) | |||
8844 | { | |||
8845 | ScDocument& rDoc = pDocShell->GetDocument(); | |||
8846 | rDoc.AddUnoObject(*this); | |||
8847 | ||||
8848 | OSL_ENSURE( aTotalRange.aStart.Tab() == aTotalRange.aEnd.Tab(), "different tables" )do { if (true && (!(aTotalRange.aStart.Tab() == aTotalRange .aEnd.Tab()))) { sal_detail_logFormat((SAL_DETAIL_LOG_LEVEL_WARN ), ("legacy.osl"), ("/home/maarten/src/libreoffice/core/sc/source/ui/unoobj/cellsuno.cxx" ":" "8848" ": "), "%s", "different tables"); } } while (false ); | |||
8849 | } | |||
8850 | ||||
8851 | ScCellFormatsObj::~ScCellFormatsObj() | |||
8852 | { | |||
8853 | SolarMutexGuard g; | |||
8854 | ||||
8855 | if (pDocShell) | |||
8856 | pDocShell->GetDocument().RemoveUnoObject(*this); | |||
8857 | } | |||
8858 | ||||
8859 | void ScCellFormatsObj::Notify( SfxBroadcaster&, const SfxHint& rHint ) | |||
8860 | { | |||
8861 | if ( dynamic_cast<const ScUpdateRefHint*>(&rHint) ) | |||
8862 | { | |||
8863 | //! aTotalRange... | |||
8864 | } | |||
8865 | else if ( rHint.GetId() == SfxHintId::Dying ) | |||
8866 | { | |||
8867 | pDocShell = nullptr; | |||
8868 | } | |||
8869 | } | |||
8870 | ||||
8871 | ScCellRangeObj* ScCellFormatsObj::GetObjectByIndex_Impl(long nIndex) const | |||
8872 | { | |||
8873 | //! access the AttrArrays directly !!!! | |||
8874 | ||||
8875 | ScCellRangeObj* pRet = nullptr; | |||
8876 | if (pDocShell) | |||
8877 | { | |||
8878 | ScDocument& rDoc = pDocShell->GetDocument(); | |||
8879 | long nPos = 0; | |||
8880 | ScAttrRectIterator aIter( rDoc, aTotalRange.aStart.Tab(), | |||
8881 | aTotalRange.aStart.Col(), aTotalRange.aStart.Row(), | |||
8882 | aTotalRange.aEnd.Col(), aTotalRange.aEnd.Row() ); | |||
8883 | SCCOL nCol1, nCol2; | |||
8884 | SCROW nRow1, nRow2; | |||
8885 | while ( aIter.GetNext( nCol1, nCol2, nRow1, nRow2 ) ) | |||
8886 | { | |||
8887 | if ( nPos == nIndex ) | |||
8888 | { | |||
8889 | SCTAB nTab = aTotalRange.aStart.Tab(); | |||
8890 | ScRange aNext( nCol1, nRow1, nTab, nCol2, nRow2, nTab ); | |||
8891 | ||||
8892 | if ( aNext.aStart == aNext.aEnd ) | |||
8893 | pRet = new ScCellObj( pDocShell, aNext.aStart ); | |||
8894 | else | |||
8895 | pRet = new ScCellRangeObj( pDocShell, aNext ); | |||
8896 | } | |||
8897 | ++nPos; | |||
8898 | } | |||
8899 | } | |||
8900 | return pRet; | |||
8901 | } | |||
8902 | ||||
8903 | // XIndexAccess | |||
8904 | ||||
8905 | sal_Int32 SAL_CALL ScCellFormatsObj::getCount() | |||
8906 | { | |||
8907 | SolarMutexGuard aGuard; | |||
8908 | ||||
8909 | //! access the AttrArrays directly !!!! | |||
8910 | ||||
8911 | long nCount = 0; | |||
8912 | if (pDocShell) | |||
8913 | { | |||
8914 | ScDocument& rDoc = pDocShell->GetDocument(); | |||
8915 | ScAttrRectIterator aIter( rDoc, aTotalRange.aStart.Tab(), | |||
8916 | aTotalRange.aStart.Col(), aTotalRange.aStart.Row(), | |||
8917 | aTotalRange.aEnd.Col(), aTotalRange.aEnd.Row() ); | |||
8918 | SCCOL nCol1, nCol2; | |||
8919 | SCROW nRow1, nRow2; | |||
8920 | while ( aIter.GetNext( nCol1, nCol2, nRow1, nRow2 ) ) | |||
8921 | ++nCount; | |||
8922 | } | |||
8923 | return nCount; | |||
8924 | } | |||
8925 | ||||
8926 | uno::Any SAL_CALL ScCellFormatsObj::getByIndex( sal_Int32 nIndex ) | |||
8927 | { | |||
8928 | SolarMutexGuard aGuard; | |||
8929 | ||||
8930 | uno::Reference<table::XCellRange> xRange(GetObjectByIndex_Impl(nIndex)); | |||
8931 | if (!xRange.is()) | |||
8932 | throw lang::IndexOutOfBoundsException(); | |||
8933 | ||||
8934 | return uno::makeAny(xRange); | |||
8935 | ||||
8936 | } | |||
8937 | ||||
8938 | uno::Type SAL_CALL ScCellFormatsObj::getElementType() | |||
8939 | { | |||
8940 | SolarMutexGuard aGuard; | |||
8941 | return cppu::UnoType<table::XCellRange>::get(); | |||
8942 | } | |||
8943 | ||||
8944 | sal_Bool SAL_CALL ScCellFormatsObj::hasElements() | |||
8945 | { | |||
8946 | SolarMutexGuard aGuard; | |||
8947 | return ( getCount() != 0 ); //! always greater then zero ?? | |||
8948 | } | |||
8949 | ||||
8950 | // XEnumerationAccess | |||
8951 | ||||
8952 | uno::Reference<container::XEnumeration> SAL_CALL ScCellFormatsObj::createEnumeration() | |||
8953 | { | |||
8954 | SolarMutexGuard aGuard; | |||
8955 | if (pDocShell) | |||
8956 | return new ScCellFormatsEnumeration( pDocShell, aTotalRange ); | |||
8957 | return nullptr; | |||
8958 | } | |||
8959 | ||||
8960 | ScCellFormatsEnumeration::ScCellFormatsEnumeration(ScDocShell* pDocSh, const ScRange& rRange) : | |||
8961 | pDocShell( pDocSh ), | |||
8962 | nTab( rRange.aStart.Tab() ), | |||
8963 | bAtEnd( false ), | |||
8964 | bDirty( false ) | |||
8965 | { | |||
8966 | ScDocument& rDoc = pDocShell->GetDocument(); | |||
8967 | rDoc.AddUnoObject(*this); | |||
8968 | ||||
8969 | OSL_ENSURE( rRange.aStart.Tab() == rRange.aEnd.Tab(),do { if (true && (!(rRange.aStart.Tab() == rRange.aEnd .Tab()))) { sal_detail_logFormat((SAL_DETAIL_LOG_LEVEL_WARN), ("legacy.osl"), ("/home/maarten/src/libreoffice/core/sc/source/ui/unoobj/cellsuno.cxx" ":" "8970" ": "), "%s", "CellFormatsEnumeration: different tables" ); } } while (false) | |||
8970 | "CellFormatsEnumeration: different tables" )do { if (true && (!(rRange.aStart.Tab() == rRange.aEnd .Tab()))) { sal_detail_logFormat((SAL_DETAIL_LOG_LEVEL_WARN), ("legacy.osl"), ("/home/maarten/src/libreoffice/core/sc/source/ui/unoobj/cellsuno.cxx" ":" "8970" ": "), "%s", "CellFormatsEnumeration: different tables" ); } } while (false); | |||
8971 | ||||
8972 | pIter.reset( new ScAttrRectIterator( rDoc, nTab, | |||
8973 | rRange.aStart.Col(), rRange.aStart.Row(), | |||
8974 | rRange.aEnd.Col(), rRange.aEnd.Row() ) ); | |||
8975 | Advance_Impl(); | |||
8976 | } | |||
8977 | ||||
8978 | ScCellFormatsEnumeration::~ScCellFormatsEnumeration() | |||
8979 | { | |||
8980 | SolarMutexGuard g; | |||
8981 | ||||
8982 | if (pDocShell) | |||
8983 | pDocShell->GetDocument().RemoveUnoObject(*this); | |||
8984 | } | |||
8985 | ||||
8986 | void ScCellFormatsEnumeration::Advance_Impl() | |||
8987 | { | |||
8988 | OSL_ENSURE(!bAtEnd,"too many Advance_Impl")do { if (true && (!(!bAtEnd))) { sal_detail_logFormat ((SAL_DETAIL_LOG_LEVEL_WARN), ("legacy.osl"), ("/home/maarten/src/libreoffice/core/sc/source/ui/unoobj/cellsuno.cxx" ":" "8988" ": "), "%s", "too many Advance_Impl"); } } while ( false); | |||
8989 | ||||
8990 | if ( pIter ) | |||
8991 | { | |||
8992 | if ( bDirty ) | |||
8993 | { | |||
8994 | pIter->DataChanged(); // new search for AttrArray-Index | |||
8995 | bDirty = false; | |||
8996 | } | |||
8997 | ||||
8998 | SCCOL nCol1, nCol2; | |||
8999 | SCROW nRow1, nRow2; | |||
9000 | if ( pIter->GetNext( nCol1, nCol2, nRow1, nRow2 ) ) | |||
9001 | aNext = ScRange( nCol1, nRow1, nTab, nCol2, nRow2, nTab ); | |||
9002 | else | |||
9003 | bAtEnd = true; | |||
9004 | } | |||
9005 | else | |||
9006 | bAtEnd = true; // document vanished or so | |||
9007 | } | |||
9008 | ||||
9009 | ScCellRangeObj* ScCellFormatsEnumeration::NextObject_Impl() | |||
9010 | { | |||
9011 | ScCellRangeObj* pRet = nullptr; | |||
9012 | if (pDocShell && !bAtEnd) | |||
9013 | { | |||
9014 | if ( aNext.aStart == aNext.aEnd ) | |||
9015 | pRet = new ScCellObj( pDocShell, aNext.aStart ); | |||
9016 | else | |||
9017 | pRet = new ScCellRangeObj( pDocShell, aNext ); | |||
9018 | Advance_Impl(); | |||
9019 | } | |||
9020 | return pRet; | |||
9021 | } | |||
9022 | ||||
9023 | void ScCellFormatsEnumeration::Notify( SfxBroadcaster&, const SfxHint& rHint ) | |||
9024 | { | |||
9025 | if ( dynamic_cast<const ScUpdateRefHint*>(&rHint) ) | |||
9026 | { | |||
9027 | //! and now??? | |||
9028 | } | |||
9029 | else | |||
9030 | { | |||
9031 | const SfxHintId nId = rHint.GetId(); | |||
9032 | if ( nId == SfxHintId::Dying ) | |||
9033 | { | |||
9034 | pDocShell = nullptr; | |||
9035 | pIter.reset(); | |||
9036 | } | |||
9037 | else if ( nId == SfxHintId::DataChanged ) | |||
9038 | { | |||
9039 | bDirty = true; // AttrArray-Index possibly invalid | |||
9040 | } | |||
9041 | } | |||
9042 | } | |||
9043 | ||||
9044 | // XEnumeration | |||
9045 | ||||
9046 | sal_Bool SAL_CALL ScCellFormatsEnumeration::hasMoreElements() | |||
9047 | { | |||
9048 | SolarMutexGuard aGuard; | |||
9049 | return !bAtEnd; | |||
9050 | } | |||
9051 | ||||
9052 | uno::Any SAL_CALL ScCellFormatsEnumeration::nextElement() | |||
9053 | { | |||
9054 | SolarMutexGuard aGuard; | |||
9055 | ||||
9056 | if ( bAtEnd || !pDocShell ) | |||
9057 | throw container::NoSuchElementException(); // no more elements | |||
9058 | ||||
9059 | // interface must match ScCellFormatsObj::getElementType | |||
9060 | ||||
9061 | return uno::makeAny(uno::Reference<table::XCellRange> (NextObject_Impl())); | |||
9062 | } | |||
9063 | ||||
9064 | ScUniqueCellFormatsObj::~ScUniqueCellFormatsObj() | |||
9065 | { | |||
9066 | SolarMutexGuard g; | |||
9067 | ||||
9068 | if (pDocShell) | |||
9069 | pDocShell->GetDocument().RemoveUnoObject(*this); | |||
9070 | } | |||
9071 | ||||
9072 | void ScUniqueCellFormatsObj::Notify( SfxBroadcaster&, const SfxHint& rHint ) | |||
9073 | { | |||
9074 | if ( dynamic_cast<const ScUpdateRefHint*>(&rHint) ) | |||
9075 | { | |||
9076 | //! aTotalRange... | |||
9077 | } | |||
9078 | else | |||
9079 | { | |||
9080 | if ( rHint.GetId() == SfxHintId::Dying ) | |||
9081 | pDocShell = nullptr; | |||
9082 | } | |||
9083 | } | |||
9084 | ||||
9085 | // Fill the list of formats from the document | |||
9086 | ||||
9087 | namespace { | |||
9088 | ||||
9089 | // hash code to access the range lists by ScPatternAttr pointer | |||
9090 | struct ScPatternHashCode | |||
9091 | { | |||
9092 | size_t operator()( const ScPatternAttr* pPattern ) const | |||
9093 | { | |||
9094 | return reinterpret_cast<size_t>(pPattern); | |||
9095 | } | |||
9096 | }; | |||
9097 | ||||
9098 | } | |||
9099 | ||||
9100 | // Hash map to find a range by its start row | |||
9101 | typedef std::unordered_map< SCROW, ScRange > ScRowRangeHashMap; | |||
9102 | ||||
9103 | namespace { | |||
9104 | ||||
9105 | // Hash map entry. | |||
9106 | // The Join method depends on the column-wise order of ScAttrRectIterator | |||
9107 | class ScUniqueFormatsEntry | |||
9108 | { | |||
9109 | enum EntryState { STATE_EMPTY, STATE_SINGLE, STATE_COMPLEX }; | |||
9110 | ||||
9111 | EntryState eState; | |||
9112 | ScRange aSingleRange; | |||
9113 | ScRowRangeHashMap aJoinedRanges; // "active" ranges to be merged | |||
9114 | std::vector<ScRange> aCompletedRanges; // ranges that will no longer be touched | |||
9115 | ScRangeListRef aReturnRanges; // result as ScRangeList for further use | |||
9116 | ||||
9117 | public: | |||
9118 | ScUniqueFormatsEntry() : eState( STATE_EMPTY ) {} | |||
9119 | ||||
9120 | void Join( const ScRange& rNewRange ); | |||
9121 | const ScRangeList& GetRanges(); | |||
9122 | void Clear() { aReturnRanges.clear(); } // aJoinedRanges and aCompletedRanges are cleared in GetRanges | |||
9123 | }; | |||
9124 | ||||
9125 | } | |||
9126 | ||||
9127 | void ScUniqueFormatsEntry::Join( const ScRange& rNewRange ) | |||
9128 | { | |||
9129 | // Special-case handling for single range | |||
9130 | ||||
9131 | if ( eState == STATE_EMPTY ) | |||
9132 | { | |||
9133 | aSingleRange = rNewRange; | |||
9134 | eState = STATE_SINGLE; | |||
9135 | return; | |||
9136 | } | |||
9137 | if ( eState == STATE_SINGLE ) | |||
9138 | { | |||
9139 | if ( aSingleRange.aStart.Row() == rNewRange.aStart.Row() && | |||
9140 | aSingleRange.aEnd.Row() == rNewRange.aEnd.Row() && | |||
9141 | aSingleRange.aEnd.Col() + 1 == rNewRange.aStart.Col() ) | |||
9142 | { | |||
9143 | aSingleRange.aEnd.SetCol( rNewRange.aEnd.Col() ); | |||
9144 | return; // still a single range | |||
9145 | } | |||
9146 | ||||
9147 | SCROW nSingleRow = aSingleRange.aStart.Row(); | |||
9148 | aJoinedRanges.emplace( nSingleRow, aSingleRange ); | |||
9149 | eState = STATE_COMPLEX; | |||
9150 | // continue normally | |||
9151 | } | |||
9152 | ||||
9153 | // This is called in the order of ScAttrRectIterator results. | |||
9154 | // rNewRange can only be joined with an existing entry if it's the same rows, starting in the next column. | |||
9155 | // If the old entry for the start row extends to a different end row, or ends in a different column, it | |||
9156 | // can be moved to aCompletedRanges because it can't be joined with following iterator results. | |||
9157 | // Everything happens within one sheet, so Tab can be ignored. | |||
9158 | ||||
9159 | SCROW nStartRow = rNewRange.aStart.Row(); | |||
9160 | ScRowRangeHashMap::iterator aIter( aJoinedRanges.find( nStartRow ) ); // find the active entry for the start row | |||
9161 | if ( aIter != aJoinedRanges.end() ) | |||
9162 | { | |||
9163 | ScRange& rOldRange = aIter->second; | |||
9164 | if ( rOldRange.aEnd.Row() == rNewRange.aEnd.Row() && | |||
9165 | rOldRange.aEnd.Col() + 1 == rNewRange.aStart.Col() ) | |||
9166 | { | |||
9167 | // extend existing range | |||
9168 | rOldRange.aEnd.SetCol( rNewRange.aEnd.Col() ); | |||
9169 | } | |||
9170 | else | |||
9171 | { | |||
9172 | // move old range to aCompletedRanges, keep rNewRange for joining | |||
9173 | aCompletedRanges.push_back( rOldRange ); | |||
9174 | rOldRange = rNewRange; // replace in hash map | |||
9175 | } | |||
9176 | } | |||
9177 | else | |||
9178 | { | |||
9179 | // keep rNewRange for joining | |||
9180 | aJoinedRanges.emplace( nStartRow, rNewRange ); | |||
9181 | } | |||
9182 | } | |||
9183 | ||||
9184 | const ScRangeList& ScUniqueFormatsEntry::GetRanges() | |||
9185 | { | |||
9186 | if ( eState == STATE_SINGLE ) | |||
9187 | { | |||
9188 | aReturnRanges = new ScRangeList( aSingleRange ); | |||
9189 | return *aReturnRanges; | |||
9190 | } | |||
9191 | ||||
9192 | // move remaining entries from aJoinedRanges to aCompletedRanges | |||
9193 | ||||
9194 | for ( const auto& rEntry : aJoinedRanges ) | |||
9195 | aCompletedRanges.push_back( rEntry.second ); | |||
9196 | aJoinedRanges.clear(); | |||
9197 | ||||
9198 | // sort all ranges for a predictable API result | |||
9199 | ||||
9200 | std::sort( aCompletedRanges.begin(), aCompletedRanges.end() ); | |||
9201 | ||||
9202 | // fill and return ScRangeList | |||
9203 | ||||
9204 | aReturnRanges = new ScRangeList; | |||
9205 | for ( const auto& rCompletedRange : aCompletedRanges ) | |||
9206 | aReturnRanges->push_back( rCompletedRange ); | |||
9207 | aCompletedRanges.clear(); | |||
9208 | ||||
9209 | return *aReturnRanges; | |||
9210 | } | |||
9211 | ||||
9212 | typedef std::unordered_map< const ScPatternAttr*, ScUniqueFormatsEntry, ScPatternHashCode > ScUniqueFormatsHashMap; | |||
9213 | ||||
9214 | namespace { | |||
9215 | ||||
9216 | // function object to sort the range lists by start of first range | |||
9217 | struct ScUniqueFormatsOrder | |||
9218 | { | |||
9219 | bool operator()( const ScRangeList& rList1, const ScRangeList& rList2 ) const | |||
9220 | { | |||
9221 | // all range lists have at least one entry | |||
9222 | OSL_ENSURE( !rList1.empty() && !rList2.empty(), "ScUniqueFormatsOrder: empty list" )do { if (true && (!(!rList1.empty() && !rList2 .empty()))) { sal_detail_logFormat((SAL_DETAIL_LOG_LEVEL_WARN ), ("legacy.osl"), ("/home/maarten/src/libreoffice/core/sc/source/ui/unoobj/cellsuno.cxx" ":" "9222" ": "), "%s", "ScUniqueFormatsOrder: empty list"); } } while (false); | |||
9223 | ||||
9224 | // compare start positions using ScAddress comparison operator | |||
9225 | return ( rList1[ 0 ].aStart < rList2[ 0 ].aStart ); | |||
9226 | } | |||
9227 | }; | |||
9228 | ||||
9229 | } | |||
9230 | ||||
9231 | ScUniqueCellFormatsObj::ScUniqueCellFormatsObj(ScDocShell* pDocSh, const ScRange& rTotalRange) : | |||
9232 | pDocShell( pDocSh ), | |||
9233 | aRangeLists() | |||
9234 | { | |||
9235 | pDocShell->GetDocument().AddUnoObject(*this); | |||
9236 | ||||
9237 | OSL_ENSURE( rTotalRange.aStart.Tab() == rTotalRange.aEnd.Tab(), "different tables" )do { if (true && (!(rTotalRange.aStart.Tab() == rTotalRange .aEnd.Tab()))) { sal_detail_logFormat((SAL_DETAIL_LOG_LEVEL_WARN ), ("legacy.osl"), ("/home/maarten/src/libreoffice/core/sc/source/ui/unoobj/cellsuno.cxx" ":" "9237" ": "), "%s", "different tables"); } } while (false ); | |||
9238 | ||||
9239 | ScDocument& rDoc = pDocShell->GetDocument(); | |||
9240 | SCTAB nTab = rTotalRange.aStart.Tab(); | |||
9241 | ScAttrRectIterator aIter( rDoc, nTab, | |||
9242 | rTotalRange.aStart.Col(), rTotalRange.aStart.Row(), | |||
9243 | rTotalRange.aEnd.Col(), rTotalRange.aEnd.Row() ); | |||
9244 | SCCOL nCol1, nCol2; | |||
9245 | SCROW nRow1, nRow2; | |||
9246 | ||||
9247 | // Collect the ranges for each format in a hash map, to avoid nested loops | |||
9248 | ||||
9249 | ScUniqueFormatsHashMap aHashMap; | |||
9250 | while (aIter.GetNext( nCol1, nCol2, nRow1, nRow2 ) ) | |||
9251 | { | |||
9252 | ScRange aRange( nCol1, nRow1, nTab, nCol2, nRow2, nTab ); | |||
9253 | const ScPatternAttr* pPattern = rDoc.GetPattern(nCol1, nRow1, nTab); | |||
9254 | aHashMap[pPattern].Join( aRange ); | |||
9255 | } | |||
9256 | ||||
9257 | // Fill the vector aRangeLists with the range lists from the hash map | |||
9258 | ||||
9259 | aRangeLists.reserve( aHashMap.size() ); | |||
9260 | for ( auto& rMapEntry : aHashMap ) | |||
9261 | { | |||
9262 | ScUniqueFormatsEntry& rEntry = rMapEntry.second; | |||
9263 | const ScRangeList& rRanges = rEntry.GetRanges(); | |||
9264 | aRangeLists.push_back( rRanges ); // copy ScRangeList | |||
9265 | rEntry.Clear(); // free memory, don't hold both copies of all ranges | |||
9266 | } | |||
9267 | ||||
9268 | // Sort the vector by first range's start position, to avoid random shuffling | |||
9269 | // due to using the ScPatterAttr pointers | |||
9270 | ||||
9271 | ::std::sort( aRangeLists.begin(), aRangeLists.end(), ScUniqueFormatsOrder() ); | |||
9272 | } | |||
9273 | ||||
9274 | ||||
9275 | // XIndexAccess | |||
9276 | ||||
9277 | sal_Int32 SAL_CALL ScUniqueCellFormatsObj::getCount() | |||
9278 | { | |||
9279 | SolarMutexGuard aGuard; | |||
9280 | ||||
9281 | return aRangeLists.size(); | |||
9282 | } | |||
9283 | ||||
9284 | uno::Any SAL_CALL ScUniqueCellFormatsObj::getByIndex( sal_Int32 nIndex ) | |||
9285 | { | |||
9286 | SolarMutexGuard aGuard; | |||
9287 | ||||
9288 | if(o3tl::make_unsigned(nIndex) >= aRangeLists.size()) | |||
| ||||
9289 | throw lang::IndexOutOfBoundsException(); | |||
9290 | ||||
9291 | return uno::makeAny(uno::Reference<sheet::XSheetCellRangeContainer>(new ScCellRangesObj(pDocShell, aRangeLists[nIndex]))); | |||
9292 | ||||
9293 | } | |||
9294 | ||||
9295 | uno::Type SAL_CALL ScUniqueCellFormatsObj::getElementType() | |||
9296 | { | |||
9297 | SolarMutexGuard aGuard; | |||
9298 | return cppu::UnoType<sheet::XSheetCellRangeContainer>::get(); | |||
9299 | } | |||
9300 | ||||
9301 | sal_Bool SAL_CALL ScUniqueCellFormatsObj::hasElements() | |||
9302 | { | |||
9303 | SolarMutexGuard aGuard; | |||
9304 | return ( !aRangeLists.empty() ); | |||
9305 | } | |||
9306 | ||||
9307 | // XEnumerationAccess | |||
9308 | ||||
9309 | uno::Reference<container::XEnumeration> SAL_CALL ScUniqueCellFormatsObj::createEnumeration() | |||
9310 | { | |||
9311 | SolarMutexGuard aGuard; | |||
9312 | if (pDocShell) | |||
9313 | return new ScUniqueCellFormatsEnumeration( pDocShell, aRangeLists ); | |||
9314 | return nullptr; | |||
9315 | } | |||
9316 | ||||
9317 | ScUniqueCellFormatsEnumeration::ScUniqueCellFormatsEnumeration(ScDocShell* pDocSh, const std::vector<ScRangeList>& rRangeLists) : | |||
9318 | aRangeLists(rRangeLists), | |||
9319 | pDocShell( pDocSh ), | |||
9320 | nCurrentPosition(0) | |||
9321 | { | |||
9322 | pDocShell->GetDocument().AddUnoObject(*this); | |||
9323 | } | |||
9324 | ||||
9325 | ScUniqueCellFormatsEnumeration::~ScUniqueCellFormatsEnumeration() | |||
9326 | { | |||
9327 | SolarMutexGuard g; | |||
9328 | ||||
9329 | if (pDocShell) | |||
9330 | pDocShell->GetDocument().RemoveUnoObject(*this); | |||
9331 | } | |||
9332 | ||||
9333 | void ScUniqueCellFormatsEnumeration::Notify( SfxBroadcaster&, const SfxHint& rHint ) | |||
9334 | { | |||
9335 | if ( dynamic_cast<const ScUpdateRefHint*>(&rHint) ) | |||
9336 | { | |||
9337 | //! and now ??? | |||
9338 | } | |||
9339 | else | |||
9340 | { | |||
9341 | if ( rHint.GetId() == SfxHintId::Dying ) | |||
9342 | pDocShell = nullptr; | |||
9343 | } | |||
9344 | } | |||
9345 | ||||
9346 | // XEnumeration | |||
9347 | ||||
9348 | sal_Bool SAL_CALL ScUniqueCellFormatsEnumeration::hasMoreElements() | |||
9349 | { | |||
9350 | SolarMutexGuard aGuard; | |||
9351 | return o3tl::make_unsigned(nCurrentPosition) < aRangeLists.size(); | |||
9352 | } | |||
9353 | ||||
9354 | uno::Any SAL_CALL ScUniqueCellFormatsEnumeration::nextElement() | |||
9355 | { | |||
9356 | SolarMutexGuard aGuard; | |||
9357 | ||||
9358 | if ( !hasMoreElements() || !pDocShell ) | |||
9359 | throw container::NoSuchElementException(); // no more elements | |||
9360 | ||||
9361 | // interface type must match ScCellFormatsObj::getElementType | |||
9362 | ||||
9363 | return uno::makeAny(uno::Reference<sheet::XSheetCellRangeContainer>(new ScCellRangesObj(pDocShell, aRangeLists[nCurrentPosition++]))); | |||
9364 | } | |||
9365 | ||||
9366 | /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ |