calc: on editing invalidation of view with different zoom is wrong
[LibreOffice.git] / sc / source / ui / unoobj / styleuno.cxx
blobe840d2237c4e62959b7422285de2cf1faab542c4
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3 * This file is part of the LibreOffice project.
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
9 * This file incorporates work covered by the following license notice:
11 * Licensed to the Apache Software Foundation (ASF) under one or more
12 * contributor license agreements. See the NOTICE file distributed
13 * with this work for additional information regarding copyright
14 * ownership. The ASF licenses this file to you under the Apache
15 * License, Version 2.0 (the "License"); you may not use this file
16 * except in compliance with the License. You may obtain a copy of
17 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
20 #include <scitems.hxx>
21 #include <editeng/memberids.h>
22 #include <svx/algitem.hxx>
23 #include <editeng/boxitem.hxx>
24 #include <editeng/langitem.hxx>
25 #include <editeng/numitem.hxx>
26 #include <svx/pageitem.hxx>
27 #include <editeng/pbinitem.hxx>
28 #include <svx/unomid.hxx>
29 #include <editeng/unonrule.hxx>
30 #include <sfx2/bindings.hxx>
31 #include <sfx2/printer.hxx>
32 #include <sfx2/sfxsids.hrc>
33 #include <utility>
34 #include <vcl/virdev.hxx>
35 #include <vcl/svapp.hxx>
36 #include <svl/itempool.hxx>
37 #include <svl/itemset.hxx>
38 #include <svl/numformat.hxx>
39 #include <svl/intitem.hxx>
40 #include <svl/zformat.hxx>
41 #include <tools/fract.hxx>
42 #include <tools/UnitConversion.hxx>
43 #include <osl/diagnose.h>
45 #include <com/sun/star/table/BorderLine.hpp>
46 #include <com/sun/star/table/TableBorder.hpp>
47 #include <com/sun/star/table/TableBorder2.hpp>
48 #include <com/sun/star/table/ShadowFormat.hpp>
49 #include <com/sun/star/table/CellHoriJustify.hpp>
50 #include <com/sun/star/table/CellOrientation.hpp>
51 #include <com/sun/star/style/PageStyleLayout.hpp>
52 #include <com/sun/star/style/GraphicLocation.hpp>
53 #include <com/sun/star/sheet/XHeaderFooterContent.hpp>
54 #include <com/sun/star/util/XComplexColor.hpp>
55 #include <com/sun/star/util/CellProtection.hpp>
56 #include <com/sun/star/util/XComplexColor.hpp>
57 #include <com/sun/star/awt/FontSlant.hpp>
58 #include <com/sun/star/awt/Size.hpp>
59 #include <com/sun/star/lang/IndexOutOfBoundsException.hpp>
60 #include <com/sun/star/lang/Locale.hpp>
61 #include <com/sun/star/beans/PropertyAttribute.hpp>
62 #include <com/sun/star/graphic/XGraphic.hpp>
63 #include <comphelper/propertysequence.hxx>
64 #include <cppuhelper/supportsservice.hxx>
66 #include <CommonProperties.hxx>
67 #include <styleuno.hxx>
68 #include <docsh.hxx>
69 #include <attrib.hxx>
70 #include <stlpool.hxx>
71 #include <docpool.hxx>
72 #include <miscuno.hxx>
73 #include <tablink.hxx>
74 #include <unonames.hxx>
75 #include <unowids.hxx>
76 #include <globstr.hrc>
77 #include <scresid.hxx>
78 #include <cellsuno.hxx>
79 #include <stylehelper.hxx>
81 using namespace ::com::sun::star;
83 static const SfxItemPropertySet* lcl_GetCellStyleSet()
85 static const SfxItemPropertyMapEntry aCellStyleMap_Impl[] =
87 {SC_UNONAME_ASIANVERT,ATTR_VERTICAL_ASIAN,cppu::UnoType<bool>::get(), 0, 0 },
88 CELL_BORDER_PROPERTIES
89 CELL_BACKGROUND_COLOR_PROPERTIES
90 {SC_UNONAME_CELLPRO, ATTR_PROTECTION, ::cppu::UnoType<util::CellProtection>::get(), 0, 0 },
91 CHAR_COLOR_PROPERTIES
92 {SC_UNONAME_COUTL, ATTR_FONT_CONTOUR, cppu::UnoType<bool>::get(), 0, 0 },
93 {SC_UNONAME_CCROSS, ATTR_FONT_CROSSEDOUT,cppu::UnoType<bool>::get(), 0, MID_CROSSED_OUT },
94 {SC_UNONAME_CEMPHAS, ATTR_FONT_EMPHASISMARK,cppu::UnoType<sal_Int16>::get(), 0, MID_EMPHASIS },
95 {SC_UNONAME_CFONT, ATTR_FONT, ::cppu::UnoType<sal_Int16>::get(), 0, MID_FONT_FAMILY },
96 {SC_UNONAME_CFCHARS, ATTR_FONT, cppu::UnoType<sal_Int16>::get(), 0, MID_FONT_CHAR_SET },
97 {SC_UNO_CJK_CFCHARS, ATTR_CJK_FONT, cppu::UnoType<sal_Int16>::get(), 0, MID_FONT_CHAR_SET },
98 {SC_UNO_CTL_CFCHARS, ATTR_CTL_FONT, cppu::UnoType<sal_Int16>::get(), 0, MID_FONT_CHAR_SET },
99 {SC_UNONAME_CFFAMIL, ATTR_FONT, cppu::UnoType<sal_Int16>::get(), 0, MID_FONT_FAMILY },
100 {SC_UNO_CJK_CFFAMIL, ATTR_CJK_FONT, cppu::UnoType<sal_Int16>::get(), 0, MID_FONT_FAMILY },
101 {SC_UNO_CTL_CFFAMIL, ATTR_CTL_FONT, cppu::UnoType<sal_Int16>::get(), 0, MID_FONT_FAMILY },
102 {SC_UNONAME_CFNAME, ATTR_FONT, cppu::UnoType<OUString>::get(), 0, MID_FONT_FAMILY_NAME },
103 {SC_UNO_CJK_CFNAME, ATTR_CJK_FONT, cppu::UnoType<OUString>::get(), 0, MID_FONT_FAMILY_NAME },
104 {SC_UNO_CTL_CFNAME, ATTR_CTL_FONT, cppu::UnoType<OUString>::get(), 0, MID_FONT_FAMILY_NAME },
105 {SC_UNONAME_CFPITCH, ATTR_FONT, cppu::UnoType<sal_Int16>::get(), 0, MID_FONT_PITCH },
106 {SC_UNO_CJK_CFPITCH, ATTR_CJK_FONT, cppu::UnoType<sal_Int16>::get(), 0, MID_FONT_PITCH },
107 {SC_UNO_CTL_CFPITCH, ATTR_CTL_FONT, cppu::UnoType<sal_Int16>::get(), 0, MID_FONT_PITCH },
108 {SC_UNONAME_CFSTYLE, ATTR_FONT, cppu::UnoType<OUString>::get(), 0, MID_FONT_STYLE_NAME },
109 {SC_UNO_CJK_CFSTYLE, ATTR_CJK_FONT, cppu::UnoType<OUString>::get(), 0, MID_FONT_STYLE_NAME },
110 {SC_UNO_CTL_CFSTYLE, ATTR_CTL_FONT, cppu::UnoType<OUString>::get(), 0, MID_FONT_STYLE_NAME },
111 {SC_UNONAME_CHEIGHT, ATTR_FONT_HEIGHT, ::cppu::UnoType<float>::get(), 0, MID_FONTHEIGHT | CONVERT_TWIPS },
112 {SC_UNO_CJK_CHEIGHT, ATTR_CJK_FONT_HEIGHT,::cppu::UnoType<float>::get(), 0, MID_FONTHEIGHT | CONVERT_TWIPS },
113 {SC_UNO_CTL_CHEIGHT, ATTR_CTL_FONT_HEIGHT,::cppu::UnoType<float>::get(), 0, MID_FONTHEIGHT | CONVERT_TWIPS },
114 {SC_UNONAME_CLOCAL, ATTR_FONT_LANGUAGE, ::cppu::UnoType<lang::Locale>::get(), 0, MID_LANG_LOCALE },
115 {SC_UNO_CJK_CLOCAL, ATTR_CJK_FONT_LANGUAGE,::cppu::UnoType<lang::Locale>::get(), 0, MID_LANG_LOCALE },
116 {SC_UNO_CTL_CLOCAL, ATTR_CTL_FONT_LANGUAGE,::cppu::UnoType<lang::Locale>::get(), 0, MID_LANG_LOCALE },
117 {SC_UNONAME_COVER, ATTR_FONT_OVERLINE, ::cppu::UnoType<sal_Int16>::get(), 0, MID_TL_STYLE },
118 {SC_UNONAME_COVRLCOL, ATTR_FONT_OVERLINE, cppu::UnoType<sal_Int32>::get(), 0, MID_TL_COLOR },
119 {SC_UNONAME_COVRLHAS, ATTR_FONT_OVERLINE, cppu::UnoType<bool>::get(), 0, MID_TL_HASCOLOR },
120 {SC_UNONAME_CPOST, ATTR_FONT_POSTURE, ::cppu::UnoType<awt::FontSlant>::get(), 0, MID_POSTURE },
121 {SC_UNO_CJK_CPOST, ATTR_CJK_FONT_POSTURE,::cppu::UnoType<awt::FontSlant>::get(), 0, MID_POSTURE },
122 {SC_UNO_CTL_CPOST, ATTR_CTL_FONT_POSTURE,::cppu::UnoType<awt::FontSlant>::get(), 0, MID_POSTURE },
123 {SC_UNONAME_CRELIEF, ATTR_FONT_RELIEF, cppu::UnoType<sal_Int16>::get(), 0, MID_RELIEF },
124 {SC_UNONAME_CSHADD, ATTR_FONT_SHADOWED, cppu::UnoType<bool>::get(), 0, 0 },
125 {SC_UNONAME_CSTRIKE, ATTR_FONT_CROSSEDOUT,cppu::UnoType<sal_Int16>::get(), 0, MID_CROSS_OUT },
126 {SC_UNONAME_CUNDER, ATTR_FONT_UNDERLINE,::cppu::UnoType<sal_Int16>::get(), 0, MID_TL_STYLE },
127 {SC_UNONAME_CUNDLCOL, ATTR_FONT_UNDERLINE,cppu::UnoType<sal_Int32>::get(), 0, MID_TL_COLOR },
128 {SC_UNONAME_CUNDLHAS, ATTR_FONT_UNDERLINE,cppu::UnoType<bool>::get(), 0, MID_TL_HASCOLOR },
129 {SC_UNONAME_CWEIGHT, ATTR_FONT_WEIGHT, ::cppu::UnoType<float>::get(), 0, MID_WEIGHT },
130 {SC_UNO_CJK_CWEIGHT, ATTR_CJK_FONT_WEIGHT,::cppu::UnoType<float>::get(), 0, MID_WEIGHT },
131 {SC_UNO_CTL_CWEIGHT, ATTR_CTL_FONT_WEIGHT,::cppu::UnoType<float>::get(), 0, MID_WEIGHT },
132 {SC_UNONAME_CWORDMOD, ATTR_FONT_WORDLINE, cppu::UnoType<bool>::get(), 0, 0 },
133 {SC_UNONAME_DIAGONAL_BLTR, ATTR_BORDER_BLTR, ::cppu::UnoType<table::BorderLine>::get(), 0, 0 | CONVERT_TWIPS },
134 {SC_UNONAME_DIAGONAL_BLTR2, ATTR_BORDER_BLTR, ::cppu::UnoType<table::BorderLine2>::get(), 0, 0 | CONVERT_TWIPS },
135 {SC_UNONAME_DIAGONAL_TLBR, ATTR_BORDER_TLBR, ::cppu::UnoType<table::BorderLine>::get(), 0, 0 | CONVERT_TWIPS },
136 {SC_UNONAME_DIAGONAL_TLBR2, ATTR_BORDER_TLBR, ::cppu::UnoType<table::BorderLine2>::get(), 0, 0 | CONVERT_TWIPS },
137 {SC_UNONAME_DISPNAME, SC_WID_UNO_DISPNAME,::cppu::UnoType<OUString>::get(), beans::PropertyAttribute::READONLY, 0 },
138 {SC_UNONAME_CELLHJUS, ATTR_HOR_JUSTIFY, ::cppu::UnoType<table::CellHoriJustify>::get(), 0, MID_HORJUST_HORJUST },
139 {SC_UNONAME_CELLHJUS_METHOD, ATTR_HOR_JUSTIFY_METHOD, ::cppu::UnoType<sal_Int32>::get(), 0, 0 },
140 {SC_UNONAME_CELLTRAN, ATTR_BACKGROUND, cppu::UnoType<bool>::get(), 0, MID_GRAPHIC_TRANSPARENT },
141 {SC_UNONAME_WRAP, ATTR_LINEBREAK, cppu::UnoType<bool>::get(), 0, 0 },
142 {SC_UNONAME_NUMFMT, ATTR_VALUE_FORMAT, ::cppu::UnoType<sal_Int32>::get(), 0, 0 },
143 // {SC_UNONAME_NUMRULES, SC_WID_UNO_NUMRULES,cppu::UnoType<container::XIndexReplace>::get(), 0, 0 },
144 {SC_UNONAME_CELLORI, ATTR_STACKED, ::cppu::UnoType<table::CellOrientation>::get(), 0, 0 },
145 {SC_UNONAME_PADJUST, ATTR_HOR_JUSTIFY, ::cppu::UnoType<sal_Int16>::get(), 0, MID_HORJUST_ADJUST },
146 {SC_UNONAME_PBMARGIN, ATTR_MARGIN, ::cppu::UnoType<sal_Int32>::get(), 0, MID_MARGIN_LO_MARGIN | CONVERT_TWIPS },
147 {SC_UNONAME_PINDENT, ATTR_INDENT, ::cppu::UnoType<sal_Int16>::get(), 0, 0 }, //! CONVERT_TWIPS
148 {SC_UNONAME_PISCHDIST,ATTR_SCRIPTSPACE, cppu::UnoType<bool>::get(), 0, 0 },
149 {SC_UNONAME_PISFORBID,ATTR_FORBIDDEN_RULES,cppu::UnoType<bool>::get(), 0, 0 },
150 {SC_UNONAME_PISHANG, ATTR_HANGPUNCTUATION,cppu::UnoType<bool>::get(), 0, 0 },
151 {SC_UNONAME_PISHYPHEN,ATTR_HYPHENATE, cppu::UnoType<bool>::get(), 0, 0 },
152 {SC_UNONAME_PLASTADJ, ATTR_HOR_JUSTIFY, ::cppu::UnoType<sal_Int16>::get(), 0, MID_HORJUST_ADJUST },
153 {SC_UNONAME_PLMARGIN, ATTR_MARGIN, ::cppu::UnoType<sal_Int32>::get(), 0, MID_MARGIN_L_MARGIN | CONVERT_TWIPS },
154 {SC_UNONAME_PRMARGIN, ATTR_MARGIN, ::cppu::UnoType<sal_Int32>::get(), 0, MID_MARGIN_R_MARGIN | CONVERT_TWIPS },
155 {SC_UNONAME_PTMARGIN, ATTR_MARGIN, ::cppu::UnoType<sal_Int32>::get(), 0, MID_MARGIN_UP_MARGIN | CONVERT_TWIPS },
156 {SC_UNONAME_ROTANG, ATTR_ROTATE_VALUE, ::cppu::UnoType<sal_Int32>::get(), 0, 0 },
157 {SC_UNONAME_ROTREF, ATTR_ROTATE_MODE, ::cppu::UnoType<sal_Int32>::get(), 0, 0 },
158 {SC_UNONAME_SHADOW, ATTR_SHADOW, ::cppu::UnoType<table::ShadowFormat>::get(), 0, 0 | CONVERT_TWIPS },
159 {SC_UNONAME_SHRINK_TO_FIT, ATTR_SHRINKTOFIT, cppu::UnoType<bool>::get(), 0, 0 },
160 {SC_UNONAME_TBLBORD, SC_WID_UNO_TBLBORD, ::cppu::UnoType<table::TableBorder>::get(), 0, 0 | CONVERT_TWIPS },
161 {SC_UNONAME_TBLBORD, SC_WID_UNO_TBLBORD2, ::cppu::UnoType<table::TableBorder2>::get(), 0, 0 | CONVERT_TWIPS },
162 {SC_UNONAME_USERDEF, ATTR_USERDEF, cppu::UnoType<container::XNameContainer>::get(), 0, 0 },
163 {SC_UNONAME_CELLVJUS, ATTR_VER_JUSTIFY, ::cppu::UnoType<sal_Int32>::get(), 0, 0 },
164 {SC_UNONAME_CELLVJUS_METHOD, ATTR_VER_JUSTIFY_METHOD, ::cppu::UnoType<sal_Int32>::get(), 0, 0 },
165 {SC_UNONAME_WRITING, ATTR_WRITINGDIR, cppu::UnoType<sal_Int16>::get(), 0, 0 },
166 {SC_UNONAME_HIDDEN, ATTR_HIDDEN, cppu::UnoType<sal_Bool>::get(), 0, 0 },
167 {SC_UNONAME_HYPERLINK, ATTR_HYPERLINK, cppu::UnoType<OUString>::get(), 0, 0 },
169 static SfxItemPropertySet aCellStyleSet_Impl( aCellStyleMap_Impl );
170 return &aCellStyleSet_Impl;
173 // map with all site attributes including header and footer attributes
175 static const SfxItemPropertySet * lcl_GetPageStyleSet()
177 static const SfxItemPropertyMapEntry aPageStyleMap_Impl[] =
179 {SC_UNO_PAGE_BACKCOLOR, ATTR_BACKGROUND, ::cppu::UnoType<sal_Int32>::get(), 0, MID_BACK_COLOR },
180 {SC_UNO_PAGE_GRAPHICFILT, ATTR_BACKGROUND, ::cppu::UnoType<OUString>::get(), 0, MID_GRAPHIC_FILTER },
181 {SC_UNO_PAGE_GRAPHICLOC, ATTR_BACKGROUND, ::cppu::UnoType<style::GraphicLocation>::get(), 0, MID_GRAPHIC_POSITION },
182 {SC_UNO_PAGE_GRAPHICURL, ATTR_BACKGROUND, ::cppu::UnoType<OUString>::get(), 0, MID_GRAPHIC_URL },
183 {SC_UNO_PAGE_GRAPHIC, ATTR_BACKGROUND, ::cppu::UnoType<graphic::XGraphic>::get(), 0, MID_GRAPHIC },
184 {SC_UNO_PAGE_BACKTRANS, ATTR_BACKGROUND, cppu::UnoType<bool>::get(), 0, MID_GRAPHIC_TRANSPARENT },
185 {OLD_UNO_PAGE_BACKCOLOR, ATTR_BACKGROUND, ::cppu::UnoType<sal_Int32>::get(), 0, MID_BACK_COLOR },
186 {SC_UNO_PAGE_BORDERDIST, ATTR_BORDER, ::cppu::UnoType<sal_Int32>::get(), 0, BORDER_DISTANCE | CONVERT_TWIPS },
187 {SC_UNO_PAGE_BOTTBORDER, ATTR_BORDER, ::cppu::UnoType<table::BorderLine>::get(), 0, BOTTOM_BORDER | CONVERT_TWIPS },
188 {SC_UNO_PAGE_BOTTBRDDIST, ATTR_BORDER, ::cppu::UnoType<sal_Int32>::get(), 0, BOTTOM_BORDER_DISTANCE | CONVERT_TWIPS },
189 {SC_UNO_PAGE_BOTTMARGIN, ATTR_ULSPACE, ::cppu::UnoType<sal_Int32>::get(), 0, MID_LO_MARGIN | CONVERT_TWIPS },
190 {SC_UNO_PAGE_CENTERHOR, ATTR_PAGE_HORCENTER,cppu::UnoType<bool>::get(), 0, 0 },
191 {SC_UNO_PAGE_CENTERVER, ATTR_PAGE_VERCENTER,cppu::UnoType<bool>::get(), 0, 0 },
192 {SC_UNONAME_DISPNAME, SC_WID_UNO_DISPNAME,::cppu::UnoType<OUString>::get(), beans::PropertyAttribute::READONLY, 0 },
193 {SC_UNO_PAGE_FIRSTPAGE, ATTR_PAGE_FIRSTPAGENO,::cppu::UnoType<sal_Int16>::get(), 0, 0 },
194 {SC_UNO_PAGE_FIRSTFTRSHARED, SC_WID_UNO_FOOTERSET,cppu::UnoType<bool>::get(), 0, 0 },
195 {SC_UNO_PAGE_FIRSTHDRSHARED, SC_WID_UNO_HEADERSET,cppu::UnoType<bool>::get(), 0, 0 },
196 {SC_UNO_PAGE_FIRSTFTRCONT, ATTR_PAGE_FOOTERFIRST,cppu::UnoType<sheet::XHeaderFooterContent>::get(), 0, 0 },
197 {SC_UNO_PAGE_FIRSTHDRCONT, ATTR_PAGE_HEADERFIRST,cppu::UnoType<sheet::XHeaderFooterContent>::get(), 0, 0 },
199 {SC_UNO_PAGE_FTRBACKCOL, SC_WID_UNO_FOOTERSET,::cppu::UnoType<sal_Int32>::get(), 0, 0 },
200 {SC_UNO_PAGE_FTRGRFFILT, SC_WID_UNO_FOOTERSET,::cppu::UnoType<OUString>::get(), 0, 0 },
201 {SC_UNO_PAGE_FTRGRFLOC, SC_WID_UNO_FOOTERSET,::cppu::UnoType<style::GraphicLocation>::get(), 0, 0 },
202 {SC_UNO_PAGE_FTRGRFURL, SC_WID_UNO_FOOTERSET,::cppu::UnoType<OUString>::get(), 0, 0 },
203 {SC_UNO_PAGE_FTRGRF, SC_WID_UNO_FOOTERSET,::cppu::UnoType<graphic::XGraphic>::get(), 0, 0 },
204 {SC_UNO_PAGE_FTRBACKTRAN, SC_WID_UNO_FOOTERSET,cppu::UnoType<bool>::get(), 0, 0 },
205 {OLD_UNO_PAGE_FTRBACKCOL, SC_WID_UNO_FOOTERSET,::cppu::UnoType<sal_Int32>::get(), 0, 0 },
206 {SC_UNO_PAGE_FTRBODYDIST, SC_WID_UNO_FOOTERSET,::cppu::UnoType<sal_Int32>::get(), 0, 0 },
207 {SC_UNO_PAGE_FTRBRDDIST, SC_WID_UNO_FOOTERSET,::cppu::UnoType<sal_Int32>::get(), 0, 0 },
208 {SC_UNO_PAGE_FTRBOTTBOR, SC_WID_UNO_FOOTERSET,::cppu::UnoType<table::BorderLine>::get(), 0, 0 },
209 {SC_UNO_PAGE_FTRBOTTBDIS, SC_WID_UNO_FOOTERSET,::cppu::UnoType<sal_Int32>::get(), 0, 0 },
210 {OLD_UNO_PAGE_FTRDYNAMIC, SC_WID_UNO_FOOTERSET,cppu::UnoType<bool>::get(), 0, 0 },
211 {SC_UNO_PAGE_FTRHEIGHT, SC_WID_UNO_FOOTERSET,::cppu::UnoType<sal_Int32>::get(), 0, 0 },
212 {SC_UNO_PAGE_FTRDYNAMIC, SC_WID_UNO_FOOTERSET,cppu::UnoType<bool>::get(), 0, 0 },
213 {SC_UNO_PAGE_FTRON, SC_WID_UNO_FOOTERSET,cppu::UnoType<bool>::get(), 0, 0 },
214 {SC_UNO_PAGE_FTRSHARED, SC_WID_UNO_FOOTERSET,cppu::UnoType<bool>::get(), 0, 0 },
215 {SC_UNO_PAGE_FTRLEFTBOR, SC_WID_UNO_FOOTERSET,::cppu::UnoType<table::BorderLine>::get(), 0, 0 },
216 {SC_UNO_PAGE_FTRLEFTBDIS, SC_WID_UNO_FOOTERSET,::cppu::UnoType<sal_Int32>::get(), 0, 0 },
217 {SC_UNO_PAGE_FTRLEFTMAR, SC_WID_UNO_FOOTERSET,::cppu::UnoType<sal_Int32>::get(), 0, 0 },
218 {OLD_UNO_PAGE_FTRON, SC_WID_UNO_FOOTERSET,cppu::UnoType<bool>::get(), 0, 0 },
219 {SC_UNO_PAGE_FTRRIGHTBOR, SC_WID_UNO_FOOTERSET,::cppu::UnoType<table::BorderLine>::get(), 0, 0 },
220 {SC_UNO_PAGE_FTRRIGHTBDIS,SC_WID_UNO_FOOTERSET,::cppu::UnoType<sal_Int32>::get(), 0, 0 },
221 {SC_UNO_PAGE_FTRRIGHTMAR, SC_WID_UNO_FOOTERSET,::cppu::UnoType<sal_Int32>::get(), 0, 0 },
222 {SC_UNO_PAGE_FTRSHADOW, SC_WID_UNO_FOOTERSET,::cppu::UnoType<table::ShadowFormat>::get(), 0, 0 },
223 {OLD_UNO_PAGE_FTRSHARED, SC_WID_UNO_FOOTERSET,cppu::UnoType<bool>::get(), 0, 0 },
224 {SC_UNO_PAGE_FTRTOPBOR, SC_WID_UNO_FOOTERSET,::cppu::UnoType<table::BorderLine>::get(), 0, 0 },
225 {SC_UNO_PAGE_FTRTOPBDIS, SC_WID_UNO_FOOTERSET,::cppu::UnoType<sal_Int32>::get(), 0, 0 },
227 {SC_UNO_PAGE_HDRBACKCOL, SC_WID_UNO_HEADERSET,::cppu::UnoType<sal_Int32>::get(), 0, 0 },
228 {SC_UNO_PAGE_HDRGRFFILT, SC_WID_UNO_HEADERSET,::cppu::UnoType<OUString>::get(), 0, 0 },
229 {SC_UNO_PAGE_HDRGRFLOC, SC_WID_UNO_HEADERSET,::cppu::UnoType<style::GraphicLocation>::get(), 0, 0 },
230 {SC_UNO_PAGE_HDRGRFURL, SC_WID_UNO_HEADERSET,::cppu::UnoType<OUString>::get(), 0, 0 },
231 {SC_UNO_PAGE_HDRGRF, SC_WID_UNO_HEADERSET,::cppu::UnoType<graphic::XGraphic>::get(), 0, 0 },
232 {SC_UNO_PAGE_HDRBACKTRAN, SC_WID_UNO_HEADERSET,cppu::UnoType<bool>::get(), 0, 0 },
233 {OLD_UNO_PAGE_HDRBACKCOL, SC_WID_UNO_HEADERSET,::cppu::UnoType<sal_Int32>::get(), 0, 0 },
234 {SC_UNO_PAGE_HDRBODYDIST, SC_WID_UNO_HEADERSET,::cppu::UnoType<sal_Int32>::get(), 0, 0 },
235 {SC_UNO_PAGE_HDRBRDDIST, SC_WID_UNO_HEADERSET,::cppu::UnoType<sal_Int32>::get(), 0, 0 },
236 {SC_UNO_PAGE_HDRBOTTBOR, SC_WID_UNO_HEADERSET,::cppu::UnoType<table::BorderLine>::get(), 0, 0 },
237 {SC_UNO_PAGE_HDRBOTTBDIS, SC_WID_UNO_HEADERSET,::cppu::UnoType<sal_Int32>::get(), 0, 0 },
238 {OLD_UNO_PAGE_HDRDYNAMIC, SC_WID_UNO_HEADERSET,cppu::UnoType<bool>::get(), 0, 0 },
239 {SC_UNO_PAGE_HDRHEIGHT, SC_WID_UNO_HEADERSET,::cppu::UnoType<sal_Int32>::get(), 0, 0 },
240 {SC_UNO_PAGE_HDRDYNAMIC, SC_WID_UNO_HEADERSET,cppu::UnoType<bool>::get(), 0, 0 },
241 {SC_UNO_PAGE_HDRON, SC_WID_UNO_HEADERSET,cppu::UnoType<bool>::get(), 0, 0 },
242 {SC_UNO_PAGE_HDRSHARED, SC_WID_UNO_HEADERSET,cppu::UnoType<bool>::get(), 0, 0 },
243 {SC_UNO_PAGE_HDRLEFTBOR, SC_WID_UNO_HEADERSET,::cppu::UnoType<table::BorderLine>::get(), 0, 0 },
244 {SC_UNO_PAGE_HDRLEFTBDIS, SC_WID_UNO_HEADERSET,::cppu::UnoType<sal_Int32>::get(), 0, 0 },
245 {SC_UNO_PAGE_HDRLEFTMAR, SC_WID_UNO_HEADERSET,::cppu::UnoType<sal_Int32>::get(), 0, 0 },
246 {OLD_UNO_PAGE_HDRON, SC_WID_UNO_HEADERSET,cppu::UnoType<bool>::get(), 0, 0 },
247 {SC_UNO_PAGE_HDRRIGHTBOR, SC_WID_UNO_HEADERSET,::cppu::UnoType<table::BorderLine>::get(), 0, 0 },
248 {SC_UNO_PAGE_HDRRIGHTBDIS,SC_WID_UNO_HEADERSET,::cppu::UnoType<sal_Int32>::get(), 0, 0 },
249 {SC_UNO_PAGE_HDRRIGHTMAR, SC_WID_UNO_HEADERSET,::cppu::UnoType<sal_Int32>::get(), 0, 0 },
250 {SC_UNO_PAGE_HDRSHADOW, SC_WID_UNO_HEADERSET,::cppu::UnoType<table::ShadowFormat>::get(), 0, 0 },
251 {OLD_UNO_PAGE_HDRSHARED, SC_WID_UNO_HEADERSET,cppu::UnoType<bool>::get(), 0, 0 },
252 {SC_UNO_PAGE_HDRTOPBOR, SC_WID_UNO_HEADERSET,::cppu::UnoType<table::BorderLine>::get(), 0, 0 },
253 {SC_UNO_PAGE_HDRTOPBDIS, SC_WID_UNO_HEADERSET,::cppu::UnoType<sal_Int32>::get(), 0, 0 },
255 {SC_UNO_PAGE_HEIGHT, ATTR_PAGE_SIZE, ::cppu::UnoType<sal_Int32>::get(), 0, MID_SIZE_HEIGHT | CONVERT_TWIPS },
256 {OLD_UNO_PAGE_BACKTRANS, ATTR_BACKGROUND, cppu::UnoType<bool>::get(), 0, MID_GRAPHIC_TRANSPARENT },
257 {SC_UNO_PAGE_LANDSCAPE, ATTR_PAGE, cppu::UnoType<bool>::get(), 0, MID_PAGE_ORIENTATION },
258 {SC_UNO_PAGE_LEFTBORDER, ATTR_BORDER, ::cppu::UnoType<table::BorderLine>::get(), 0, LEFT_BORDER | CONVERT_TWIPS },
259 {SC_UNO_PAGE_LEFTBRDDIST, ATTR_BORDER, ::cppu::UnoType<sal_Int32>::get(), 0, LEFT_BORDER_DISTANCE | CONVERT_TWIPS },
260 {SC_UNO_PAGE_LEFTMARGIN, ATTR_LRSPACE, ::cppu::UnoType<sal_Int32>::get(), 0, MID_L_MARGIN | CONVERT_TWIPS },
261 {SC_UNO_PAGE_LEFTFTRCONT, ATTR_PAGE_FOOTERLEFT,cppu::UnoType<sheet::XHeaderFooterContent>::get(), 0, 0 },
262 {SC_UNO_PAGE_LEFTHDRCONT, ATTR_PAGE_HEADERLEFT,cppu::UnoType<sheet::XHeaderFooterContent>::get(), 0, 0 },
263 {SC_UNO_PAGE_NUMBERTYPE, ATTR_PAGE, ::cppu::UnoType<sal_Int16>::get(), 0, MID_PAGE_NUMTYPE },
264 {SC_UNO_PAGE_SCALEVAL, ATTR_PAGE_SCALE, ::cppu::UnoType<sal_Int16>::get(), 0, 0 },
265 {SC_UNO_PAGE_SYTLELAYOUT, ATTR_PAGE, ::cppu::UnoType<style::PageStyleLayout>::get(), 0, MID_PAGE_LAYOUT },
266 {SC_UNO_PAGE_PRINTANNOT, ATTR_PAGE_NOTES, cppu::UnoType<bool>::get(), 0, 0 },
267 {SC_UNO_PAGE_PRINTCHARTS, ATTR_PAGE_CHARTS, cppu::UnoType<bool>::get(), 0, 0 },
268 {SC_UNO_PAGE_PRINTDOWN, ATTR_PAGE_TOPDOWN, cppu::UnoType<bool>::get(), 0, 0 },
269 {SC_UNO_PAGE_PRINTDRAW, ATTR_PAGE_DRAWINGS, cppu::UnoType<bool>::get(), 0, 0 },
270 {SC_UNO_PAGE_PRINTFORMUL, ATTR_PAGE_FORMULAS, cppu::UnoType<bool>::get(), 0, 0 },
271 {SC_UNO_PAGE_PRINTGRID, ATTR_PAGE_GRID, cppu::UnoType<bool>::get(), 0, 0 },
272 {SC_UNO_PAGE_PRINTHEADER, ATTR_PAGE_HEADERS, cppu::UnoType<bool>::get(), 0, 0 },
273 {SC_UNO_PAGE_PRINTOBJS, ATTR_PAGE_OBJECTS, cppu::UnoType<bool>::get(), 0, 0 },
274 {SC_UNO_PAGE_PRINTZERO, ATTR_PAGE_NULLVALS, cppu::UnoType<bool>::get(), 0, 0 },
275 {SC_UNO_PAGE_PAPERTRAY, ATTR_PAGE_PAPERBIN, ::cppu::UnoType<OUString>::get(), 0, 0 },
276 {SC_UNO_PAGE_RIGHTBORDER, ATTR_BORDER, ::cppu::UnoType<table::BorderLine>::get(), 0, RIGHT_BORDER | CONVERT_TWIPS },
277 {SC_UNO_PAGE_RIGHTBRDDIST,ATTR_BORDER, ::cppu::UnoType<sal_Int32>::get(), 0, RIGHT_BORDER_DISTANCE | CONVERT_TWIPS },
278 {SC_UNO_PAGE_RIGHTMARGIN, ATTR_LRSPACE, ::cppu::UnoType<sal_Int32>::get(), 0, MID_R_MARGIN | CONVERT_TWIPS },
279 {SC_UNO_PAGE_RIGHTFTRCON, ATTR_PAGE_FOOTERRIGHT,cppu::UnoType<sheet::XHeaderFooterContent>::get(), 0, 0 },
280 {SC_UNO_PAGE_RIGHTHDRCON, ATTR_PAGE_HEADERRIGHT,cppu::UnoType<sheet::XHeaderFooterContent>::get(), 0, 0 },
281 {SC_UNO_PAGE_SCALETOPAG, ATTR_PAGE_SCALETOPAGES,::cppu::UnoType<sal_Int16>::get(), 0, 0 },
282 {SC_UNO_PAGE_SCALETOX, ATTR_PAGE_SCALETO, ::cppu::UnoType<sal_Int16>::get(), 0, 0 },
283 {SC_UNO_PAGE_SCALETOY, ATTR_PAGE_SCALETO, ::cppu::UnoType<sal_Int16>::get(), 0, 0 },
284 {SC_UNO_PAGE_SHADOWFORM, ATTR_SHADOW, ::cppu::UnoType<table::ShadowFormat>::get(), 0, 0 | CONVERT_TWIPS },
285 {SC_UNO_PAGE_SIZE, ATTR_PAGE_SIZE, ::cppu::UnoType<awt::Size>::get(), 0, MID_SIZE_SIZE | CONVERT_TWIPS },
286 {SC_UNO_PAGE_TOPBORDER, ATTR_BORDER, ::cppu::UnoType<table::BorderLine>::get(), 0, TOP_BORDER | CONVERT_TWIPS },
287 {SC_UNO_PAGE_TOPBRDDIST, ATTR_BORDER, ::cppu::UnoType<sal_Int32>::get(), 0, TOP_BORDER_DISTANCE | CONVERT_TWIPS },
288 {SC_UNO_PAGE_TOPMARGIN, ATTR_ULSPACE, ::cppu::UnoType<sal_Int32>::get(), 0, MID_UP_MARGIN | CONVERT_TWIPS },
289 {OLD_UNO_PAGE_FTRBACKTRAN,SC_WID_UNO_FOOTERSET,cppu::UnoType<bool>::get(), 0, 0 },
290 {OLD_UNO_PAGE_HDRBACKTRAN,SC_WID_UNO_HEADERSET,cppu::UnoType<bool>::get(), 0, 0 },
291 {SC_UNONAME_USERDEF, ATTR_USERDEF, cppu::UnoType<container::XNameContainer>::get(), 0, 0 },
292 {SC_UNO_PAGE_WIDTH, ATTR_PAGE_SIZE, ::cppu::UnoType<sal_Int32>::get(), 0, MID_SIZE_WIDTH | CONVERT_TWIPS },
293 {SC_UNONAME_WRITING, ATTR_WRITINGDIR, cppu::UnoType<sal_Int16>::get(), 0, 0 },
294 {SC_UNONAME_HIDDEN, ATTR_HIDDEN, cppu::UnoType<sal_Bool>::get(), 0, 0 },
296 static SfxItemPropertySet aPageStyleSet_Impl( aPageStyleMap_Impl );
297 return &aPageStyleSet_Impl;
300 // map with content of the Header-Item-Sets
302 static const SfxItemPropertyMap* lcl_GetHeaderStyleMap()
304 static const SfxItemPropertyMapEntry aHeaderStyleMap_Impl[] =
306 {SC_UNO_PAGE_HDRBACKCOL, ATTR_BACKGROUND, ::cppu::UnoType<sal_Int32>::get(), 0, MID_BACK_COLOR },
307 {SC_UNO_PAGE_HDRGRFFILT, ATTR_BACKGROUND, ::cppu::UnoType<OUString>::get(), 0, MID_GRAPHIC_FILTER },
308 {SC_UNO_PAGE_HDRGRFLOC, ATTR_BACKGROUND, ::cppu::UnoType<style::GraphicLocation>::get(), 0, MID_GRAPHIC_POSITION },
309 {SC_UNO_PAGE_HDRGRFURL, ATTR_BACKGROUND, ::cppu::UnoType<OUString>::get(), 0, MID_GRAPHIC_URL },
310 {SC_UNO_PAGE_HDRGRF, ATTR_BACKGROUND, ::cppu::UnoType<graphic::XGraphic>::get(), 0, MID_GRAPHIC },
311 {SC_UNO_PAGE_HDRBACKTRAN, ATTR_BACKGROUND, cppu::UnoType<bool>::get(), 0, MID_GRAPHIC_TRANSPARENT },
312 {OLD_UNO_PAGE_HDRBACKCOL, ATTR_BACKGROUND, ::cppu::UnoType<sal_Int32>::get(), 0, MID_BACK_COLOR },
313 {SC_UNO_PAGE_HDRBODYDIST, ATTR_ULSPACE, ::cppu::UnoType<sal_Int32>::get(), 0, MID_LO_MARGIN | CONVERT_TWIPS },
314 {SC_UNO_PAGE_HDRBRDDIST, ATTR_BORDER, ::cppu::UnoType<sal_Int32>::get(), 0, BORDER_DISTANCE | CONVERT_TWIPS },
315 {SC_UNO_PAGE_HDRBOTTBOR, ATTR_BORDER, ::cppu::UnoType<table::BorderLine>::get(), 0, BOTTOM_BORDER | CONVERT_TWIPS },
316 {SC_UNO_PAGE_HDRBOTTBDIS, ATTR_BORDER, ::cppu::UnoType<sal_Int32>::get(), 0, BOTTOM_BORDER_DISTANCE | CONVERT_TWIPS },
317 {OLD_UNO_PAGE_HDRDYNAMIC, ATTR_PAGE_DYNAMIC, cppu::UnoType<bool>::get(), 0, 0 },
318 {SC_UNO_PAGE_HDRHEIGHT, ATTR_PAGE_SIZE, ::cppu::UnoType<sal_Int32>::get(), 0, MID_SIZE_HEIGHT | CONVERT_TWIPS },
319 {SC_UNO_PAGE_HDRDYNAMIC, ATTR_PAGE_DYNAMIC, cppu::UnoType<bool>::get(), 0, 0 },
320 {SC_UNO_PAGE_HDRON, ATTR_PAGE_ON, cppu::UnoType<bool>::get(), 0, 0 },
321 {SC_UNO_PAGE_HDRSHARED, ATTR_PAGE_SHARED, cppu::UnoType<bool>::get(), 0, 0 },
322 {SC_UNO_PAGE_FIRSTHDRSHARED, ATTR_PAGE_SHARED_FIRST, cppu::UnoType<bool>::get(), 0, 0 },
323 {SC_UNO_PAGE_HDRLEFTBOR, ATTR_BORDER, ::cppu::UnoType<table::BorderLine>::get(), 0, LEFT_BORDER | CONVERT_TWIPS },
324 {SC_UNO_PAGE_HDRLEFTBDIS, ATTR_BORDER, ::cppu::UnoType<sal_Int32>::get(), 0, LEFT_BORDER_DISTANCE | CONVERT_TWIPS },
325 {SC_UNO_PAGE_HDRLEFTMAR, ATTR_LRSPACE, ::cppu::UnoType<sal_Int32>::get(), 0, MID_L_MARGIN | CONVERT_TWIPS },
326 {OLD_UNO_PAGE_HDRON, ATTR_PAGE_ON, cppu::UnoType<bool>::get(), 0, 0 },
327 {SC_UNO_PAGE_HDRRIGHTBOR, ATTR_BORDER, ::cppu::UnoType<table::BorderLine>::get(), 0, RIGHT_BORDER | CONVERT_TWIPS },
328 {SC_UNO_PAGE_HDRRIGHTBDIS,ATTR_BORDER, ::cppu::UnoType<sal_Int32>::get(), 0, RIGHT_BORDER_DISTANCE | CONVERT_TWIPS },
329 {SC_UNO_PAGE_HDRRIGHTMAR, ATTR_LRSPACE, ::cppu::UnoType<sal_Int32>::get(), 0, MID_R_MARGIN | CONVERT_TWIPS },
330 {SC_UNO_PAGE_HDRSHADOW, ATTR_SHADOW, ::cppu::UnoType<table::ShadowFormat>::get(), 0, 0 | CONVERT_TWIPS },
331 {OLD_UNO_PAGE_HDRSHARED, ATTR_PAGE_SHARED, cppu::UnoType<bool>::get(), 0, 0 },
332 {SC_UNO_PAGE_HDRTOPBOR, ATTR_BORDER, ::cppu::UnoType<table::BorderLine>::get(), 0, TOP_BORDER | CONVERT_TWIPS },
333 {SC_UNO_PAGE_HDRTOPBDIS, ATTR_BORDER, ::cppu::UnoType<sal_Int32>::get(), 0, TOP_BORDER_DISTANCE | CONVERT_TWIPS },
334 {OLD_UNO_PAGE_HDRBACKTRAN,ATTR_BACKGROUND, cppu::UnoType<bool>::get(), 0, MID_GRAPHIC_TRANSPARENT },
336 static SfxItemPropertyMap aHeaderStyleMap( aHeaderStyleMap_Impl );
337 return &aHeaderStyleMap;
340 // map with content of the Footer-Item-Sets
342 static const SfxItemPropertyMap* lcl_GetFooterStyleMap()
344 static const SfxItemPropertyMapEntry aFooterStyleMap_Impl[] =
346 {SC_UNO_PAGE_FTRBACKCOL, ATTR_BACKGROUND, ::cppu::UnoType<sal_Int32>::get(), 0, MID_BACK_COLOR },
347 {SC_UNO_PAGE_FTRGRFFILT, ATTR_BACKGROUND, ::cppu::UnoType<OUString>::get(), 0, MID_GRAPHIC_FILTER },
348 {SC_UNO_PAGE_FTRGRFLOC, ATTR_BACKGROUND, ::cppu::UnoType<style::GraphicLocation>::get(), 0, MID_GRAPHIC_POSITION },
349 {SC_UNO_PAGE_FTRGRFURL, ATTR_BACKGROUND, ::cppu::UnoType<OUString>::get(), 0, MID_GRAPHIC_URL },
350 {SC_UNO_PAGE_FTRGRF, ATTR_BACKGROUND, ::cppu::UnoType<graphic::XGraphic>::get(), 0, MID_GRAPHIC },
351 {SC_UNO_PAGE_FTRBACKTRAN, ATTR_BACKGROUND, cppu::UnoType<bool>::get(), 0, MID_GRAPHIC_TRANSPARENT },
352 {OLD_UNO_PAGE_FTRBACKCOL, ATTR_BACKGROUND, ::cppu::UnoType<sal_Int32>::get(), 0, MID_BACK_COLOR },
353 {SC_UNO_PAGE_FTRBODYDIST, ATTR_ULSPACE, ::cppu::UnoType<sal_Int32>::get(), 0, MID_UP_MARGIN | CONVERT_TWIPS },
354 {SC_UNO_PAGE_FTRBRDDIST, ATTR_BORDER, ::cppu::UnoType<sal_Int32>::get(), 0, BORDER_DISTANCE | CONVERT_TWIPS },
355 {SC_UNO_PAGE_FTRBOTTBOR, ATTR_BORDER, ::cppu::UnoType<table::BorderLine>::get(), 0, BOTTOM_BORDER | CONVERT_TWIPS },
356 {SC_UNO_PAGE_FTRBOTTBDIS, ATTR_BORDER, ::cppu::UnoType<sal_Int32>::get(), 0, BOTTOM_BORDER_DISTANCE | CONVERT_TWIPS },
357 {OLD_UNO_PAGE_FTRDYNAMIC, ATTR_PAGE_DYNAMIC, cppu::UnoType<bool>::get(), 0, 0 },
358 {SC_UNO_PAGE_FTRHEIGHT, ATTR_PAGE_SIZE, ::cppu::UnoType<sal_Int32>::get(), 0, MID_SIZE_HEIGHT | CONVERT_TWIPS },
359 {SC_UNO_PAGE_FTRDYNAMIC, ATTR_PAGE_DYNAMIC, cppu::UnoType<bool>::get(), 0, 0 },
360 {SC_UNO_PAGE_FTRON, ATTR_PAGE_ON, cppu::UnoType<bool>::get(), 0, 0 },
361 {SC_UNO_PAGE_FTRSHARED, ATTR_PAGE_SHARED, cppu::UnoType<bool>::get(), 0, 0 },
362 {SC_UNO_PAGE_FIRSTFTRSHARED, ATTR_PAGE_SHARED_FIRST, cppu::UnoType<bool>::get(), 0, 0 },
363 {SC_UNO_PAGE_FTRLEFTBOR, ATTR_BORDER, ::cppu::UnoType<table::BorderLine>::get(), 0, LEFT_BORDER | CONVERT_TWIPS },
364 {SC_UNO_PAGE_FTRLEFTBDIS, ATTR_BORDER, ::cppu::UnoType<sal_Int32>::get(), 0, LEFT_BORDER_DISTANCE | CONVERT_TWIPS },
365 {SC_UNO_PAGE_FTRLEFTMAR, ATTR_LRSPACE, ::cppu::UnoType<sal_Int32>::get(), 0, MID_L_MARGIN | CONVERT_TWIPS },
366 {OLD_UNO_PAGE_FTRON, ATTR_PAGE_ON, cppu::UnoType<bool>::get(), 0, 0 },
367 {SC_UNO_PAGE_FTRRIGHTBOR, ATTR_BORDER, ::cppu::UnoType<table::BorderLine>::get(), 0, RIGHT_BORDER | CONVERT_TWIPS },
368 {SC_UNO_PAGE_FTRRIGHTBDIS,ATTR_BORDER, ::cppu::UnoType<sal_Int32>::get(), 0, RIGHT_BORDER_DISTANCE | CONVERT_TWIPS },
369 {SC_UNO_PAGE_FTRRIGHTMAR, ATTR_LRSPACE, ::cppu::UnoType<sal_Int32>::get(), 0, MID_R_MARGIN | CONVERT_TWIPS },
370 {SC_UNO_PAGE_FTRSHADOW, ATTR_SHADOW, ::cppu::UnoType<table::ShadowFormat>::get(), 0, 0 | CONVERT_TWIPS },
371 {OLD_UNO_PAGE_FTRSHARED, ATTR_PAGE_SHARED, cppu::UnoType<bool>::get(), 0, 0 },
372 {SC_UNO_PAGE_FTRTOPBOR, ATTR_BORDER, ::cppu::UnoType<table::BorderLine>::get(), 0, TOP_BORDER | CONVERT_TWIPS },
373 {SC_UNO_PAGE_FTRTOPBDIS, ATTR_BORDER, ::cppu::UnoType<sal_Int32>::get(), 0, TOP_BORDER_DISTANCE | CONVERT_TWIPS },
374 {OLD_UNO_PAGE_FTRBACKTRAN,ATTR_BACKGROUND, cppu::UnoType<bool>::get(), 0, MID_GRAPHIC_TRANSPARENT },
376 static SfxItemPropertyMap aFooterStyleMap( aFooterStyleMap_Impl );
377 return &aFooterStyleMap;
380 // access index on the style types: 0 = Cell, 1 = Page
382 #define SC_STYLE_FAMILY_COUNT 2
384 constexpr OUStringLiteral SC_FAMILYNAME_CELL = u"CellStyles";
385 constexpr OUStringLiteral SC_FAMILYNAME_PAGE = u"PageStyles";
387 const SfxStyleFamily aStyleFamilyTypes[SC_STYLE_FAMILY_COUNT] = { SfxStyleFamily::Para, SfxStyleFamily::Page };
389 constexpr OUStringLiteral SCSTYLE_SERVICE = u"com.sun.star.style.Style";
390 constexpr OUStringLiteral SCCELLSTYLE_SERVICE = u"com.sun.star.style.CellStyle";
391 constexpr OUStringLiteral SCPAGESTYLE_SERVICE = u"com.sun.star.style.PageStyle";
393 SC_SIMPLE_SERVICE_INFO( ScStyleFamiliesObj, "ScStyleFamiliesObj", "com.sun.star.style.StyleFamilies" )
394 SC_SIMPLE_SERVICE_INFO( ScStyleFamilyObj, "ScStyleFamilyObj", "com.sun.star.style.StyleFamily" )
396 constexpr OUStringLiteral SC_PAPERBIN_DEFAULTNAME = u"[From printer settings]";
398 static bool lcl_AnyTabProtected( const ScDocument& rDoc )
400 SCTAB nTabCount = rDoc.GetTableCount();
401 for (SCTAB i=0; i<nTabCount; i++)
402 if (rDoc.IsTabProtected(i))
403 return true;
404 return false;
407 ScStyleFamiliesObj::ScStyleFamiliesObj(ScDocShell* pDocSh) :
408 pDocShell( pDocSh )
410 pDocShell->GetDocument().AddUnoObject(*this);
413 ScStyleFamiliesObj::~ScStyleFamiliesObj()
415 SolarMutexGuard g;
417 if (pDocShell)
418 pDocShell->GetDocument().RemoveUnoObject(*this);
421 void ScStyleFamiliesObj::Notify( SfxBroadcaster&, const SfxHint& rHint )
423 // reference update does not matter here
425 if ( rHint.GetId() == SfxHintId::Dying )
427 pDocShell = nullptr;
431 // XStyleFamilies
433 rtl::Reference<ScStyleFamilyObj> ScStyleFamiliesObj::GetObjectByType_Impl(SfxStyleFamily nType) const
435 if ( pDocShell )
437 if ( nType == SfxStyleFamily::Para )
438 return new ScStyleFamilyObj( pDocShell, SfxStyleFamily::Para );
439 else if ( nType == SfxStyleFamily::Page )
440 return new ScStyleFamilyObj( pDocShell, SfxStyleFamily::Page );
442 OSL_FAIL("getStyleFamilyByType: no DocShell or wrong SfxStyleFamily");
443 return nullptr;
446 rtl::Reference<ScStyleFamilyObj> ScStyleFamiliesObj::GetObjectByIndex_Impl(sal_uInt32 nIndex) const
448 if ( nIndex < SC_STYLE_FAMILY_COUNT )
449 return GetObjectByType_Impl(aStyleFamilyTypes[nIndex]);
451 return nullptr; // invalid index
454 rtl::Reference<ScStyleFamilyObj> ScStyleFamiliesObj::GetObjectByName_Impl(std::u16string_view aName) const
456 if ( pDocShell )
458 if ( aName == SC_FAMILYNAME_CELL )
459 return new ScStyleFamilyObj( pDocShell, SfxStyleFamily::Para );
460 else if ( aName == SC_FAMILYNAME_PAGE )
461 return new ScStyleFamilyObj( pDocShell, SfxStyleFamily::Page );
463 // no assertion - called directly from getByName
464 return nullptr;
467 // container::XIndexAccess
469 sal_Int32 SAL_CALL ScStyleFamiliesObj::getCount()
471 return SC_STYLE_FAMILY_COUNT;
474 uno::Any SAL_CALL ScStyleFamiliesObj::getByIndex( sal_Int32 nIndex )
476 SolarMutexGuard aGuard;
477 uno::Reference< container::XNameContainer > xFamily(GetObjectByIndex_Impl(nIndex));
478 if (!xFamily.is())
479 throw lang::IndexOutOfBoundsException();
481 return uno::Any(xFamily);
484 uno::Type SAL_CALL ScStyleFamiliesObj::getElementType()
486 return cppu::UnoType<container::XNameContainer>::get(); // has to fit to getByIndex
489 sal_Bool SAL_CALL ScStyleFamiliesObj::hasElements()
491 SolarMutexGuard aGuard;
492 return ( getCount() != 0 );
495 // container::XNameAccess
497 uno::Any SAL_CALL ScStyleFamiliesObj::getByName( const OUString& aName )
499 SolarMutexGuard aGuard;
500 uno::Reference< container::XNameContainer > xFamily(GetObjectByName_Impl(aName));
501 if (!xFamily.is())
502 throw container::NoSuchElementException();
504 return uno::Any(xFamily);
507 uno::Sequence<OUString> SAL_CALL ScStyleFamiliesObj::getElementNames()
509 return {SC_FAMILYNAME_CELL, SC_FAMILYNAME_PAGE};
512 sal_Bool SAL_CALL ScStyleFamiliesObj::hasByName( const OUString& aName )
514 return aName == SC_FAMILYNAME_CELL || aName == SC_FAMILYNAME_PAGE;
517 // style::XStyleLoader
519 void SAL_CALL ScStyleFamiliesObj::loadStylesFromURL( const OUString& aURL,
520 const uno::Sequence<beans::PropertyValue>& aOptions )
522 //! use aOptions (like Writer)
523 //! set flag to disable filter option dialogs when importing
525 OUString aFilter; // empty - detect
526 OUString aFiltOpt;
527 uno::Reference<io::XInputStream> xInputStream;
528 if (aURL == "private:stream")
530 for (const auto& rProp : aOptions)
532 if (rProp.Name == "InputStream")
534 rProp.Value >>= xInputStream;
535 if (!xInputStream.is())
537 throw lang::IllegalArgumentException(
538 "Parameter 'InputStream' could not be converted "
539 "to type 'com::sun::star::io::XInputStream'",
540 nullptr, 0);
542 break;
547 ScDocumentLoader aLoader( aURL, aFilter, aFiltOpt, 0, nullptr, xInputStream );
549 ScDocShell* pSource = aLoader.GetDocShell();
551 loadStylesFromDocShell(pSource, aOptions);
554 uno::Sequence<beans::PropertyValue> SAL_CALL ScStyleFamiliesObj::getStyleLoaderOptions()
556 // return defaults for options (?)
557 return comphelper::InitPropertySequence({
558 { SC_UNONAME_OVERWSTL, uno::Any(true) },
559 { SC_UNONAME_LOADCELL, uno::Any(true) },
560 { SC_UNONAME_LOADPAGE, uno::Any(true) }
564 // style::XStyleLoader2
566 void SAL_CALL ScStyleFamiliesObj::loadStylesFromDocument( const uno::Reference < lang::XComponent > & aSourceComponent,
567 const uno::Sequence<beans::PropertyValue>& aOptions )
569 // Source document docShell
570 if ( !aSourceComponent.is() )
571 throw uno::RuntimeException();
573 ScDocShell* pDocShellSrc = dynamic_cast<ScDocShell*> (SfxObjectShell::GetShellFromComponent(aSourceComponent));
575 loadStylesFromDocShell(pDocShellSrc, aOptions);
578 // private
580 void ScStyleFamiliesObj::loadStylesFromDocShell( ScDocShell* pSource,
581 const uno::Sequence<beans::PropertyValue>& aOptions )
584 if ( !(pSource && pDocShell) )
585 return;
587 // collect options
589 bool bLoadReplace = true; // defaults
590 bool bLoadCellStyles = true;
591 bool bLoadPageStyles = true;
593 for (const beans::PropertyValue& rProp : aOptions)
595 OUString aPropName(rProp.Name);
597 if (aPropName == SC_UNONAME_OVERWSTL)
598 bLoadReplace = ScUnoHelpFunctions::GetBoolFromAny( rProp.Value );
599 else if (aPropName == SC_UNONAME_LOADCELL)
600 bLoadCellStyles = ScUnoHelpFunctions::GetBoolFromAny( rProp.Value );
601 else if (aPropName == SC_UNONAME_LOADPAGE)
602 bLoadPageStyles = ScUnoHelpFunctions::GetBoolFromAny( rProp.Value );
605 pDocShell->LoadStylesArgs( *pSource, bLoadReplace, bLoadCellStyles, bLoadPageStyles );
606 pDocShell->SetDocumentModified(); // paint is inside LoadStyles
609 ScStyleFamilyObj::ScStyleFamilyObj(ScDocShell* pDocSh, SfxStyleFamily eFam) :
610 pDocShell( pDocSh ),
611 eFamily( eFam )
613 pDocShell->GetDocument().AddUnoObject(*this);
616 ScStyleFamilyObj::~ScStyleFamilyObj()
618 SolarMutexGuard g;
620 if (pDocShell)
621 pDocShell->GetDocument().RemoveUnoObject(*this);
624 void ScStyleFamilyObj::Notify( SfxBroadcaster&, const SfxHint& rHint )
626 // reference update does not matter here
628 if ( rHint.GetId() == SfxHintId::Dying )
630 pDocShell = nullptr; // has become invalid
634 // XStyleFamily
636 rtl::Reference<ScStyleObj> ScStyleFamilyObj::GetObjectByIndex_Impl(sal_Int32 nIndex)
638 if ( pDocShell )
640 ScDocument& rDoc = pDocShell->GetDocument();
641 ScStyleSheetPool* pStylePool = rDoc.GetStyleSheetPool();
643 SfxStyleSheetIterator aIter( pStylePool, eFamily );
644 if ( nIndex < aIter.Count() )
646 SfxStyleSheetBase* pStyle = aIter[nIndex];
647 if ( pStyle )
649 return new ScStyleObj( pDocShell, eFamily, pStyle->GetName() );
653 return nullptr;
656 rtl::Reference<ScStyleObj> ScStyleFamilyObj::GetObjectByName_Impl(const OUString& aName)
658 if ( pDocShell )
660 ScDocument& rDoc = pDocShell->GetDocument();
661 ScStyleSheetPool* pStylePool = rDoc.GetStyleSheetPool();
662 if ( pStylePool->Find( aName, eFamily ) )
663 return new ScStyleObj( pDocShell, eFamily, aName );
665 return nullptr;
668 void SAL_CALL ScStyleFamilyObj::insertByName( const OUString& aName, const uno::Any& aElement )
670 SolarMutexGuard aGuard;
671 bool bDone = false;
672 // reflection does not need to be uno::XInterface, can be any interface...
673 uno::Reference< uno::XInterface > xInterface(aElement, uno::UNO_QUERY);
674 if ( xInterface.is() )
676 ScStyleObj* pStyleObj = comphelper::getFromUnoTunnel<ScStyleObj>( xInterface );
677 if ( pStyleObj && pStyleObj->GetFamily() == eFamily &&
678 !pStyleObj->IsInserted() ) // not yet inserted?
680 OUString aNameStr(ScStyleNameConversion::ProgrammaticToDisplayName( aName, eFamily ));
682 ScDocument& rDoc = pDocShell->GetDocument();
683 ScStyleSheetPool* pStylePool = rDoc.GetStyleSheetPool();
685 //! DocFunc function ???
686 //! Undo ?????????????
688 if ( pStylePool->Find( aNameStr, eFamily ) ) // not available yet
689 throw container::ElementExistException();
691 (void)pStylePool->Make( aNameStr, eFamily, SfxStyleSearchBits::UserDefined );
693 if ( eFamily == SfxStyleFamily::Para && !rDoc.IsImportingXML() )
694 rDoc.GetPool()->CellStyleCreated( aNameStr, rDoc );
696 pStyleObj->InitDoc( pDocShell, aNameStr ); // object can be used
698 if (!rDoc.IsImportingXML())
699 pDocShell->SetDocumentModified(); // new style not used yet
700 bDone = true;
705 if (!bDone)
707 // other errors are handled above
708 throw lang::IllegalArgumentException();
712 void SAL_CALL ScStyleFamilyObj::replaceByName( const OUString& aName, const uno::Any& aElement )
714 SolarMutexGuard aGuard;
715 //! combine?
716 removeByName( aName );
717 insertByName( aName, aElement );
720 void SAL_CALL ScStyleFamilyObj::removeByName( const OUString& aName )
722 SolarMutexGuard aGuard;
723 bool bFound = false;
724 if ( pDocShell )
726 OUString aString(ScStyleNameConversion::ProgrammaticToDisplayName( aName, eFamily ));
728 ScDocument& rDoc = pDocShell->GetDocument();
729 ScStyleSheetPool* pStylePool = rDoc.GetStyleSheetPool();
731 //! DocFunc function??
732 //! Undo ?????????????
734 SfxStyleSheetBase* pStyle = pStylePool->Find( aString, eFamily );
735 if (pStyle)
737 bFound = true;
738 if ( eFamily == SfxStyleFamily::Para )
740 // like ScViewFunc::RemoveStyleSheetInUse
741 ScopedVclPtrInstance< VirtualDevice > pVDev;
742 Point aLogic = pVDev->LogicToPixel(Point(1000,1000), MapMode(MapUnit::MapTwip));
743 double nPPTX = aLogic.X() / 1000.0;
744 double nPPTY = aLogic.Y() / 1000.0;
745 Fraction aZoom(1,1);
746 rDoc.StyleSheetChanged( pStyle, false, pVDev, nPPTX, nPPTY, aZoom, aZoom );
747 pDocShell->PostPaint( 0,0,0, rDoc.MaxCol(),rDoc.MaxRow(),MAXTAB, PaintPartFlags::Grid|PaintPartFlags::Left );
748 pDocShell->SetDocumentModified();
750 pStylePool->Remove( pStyle );
752 //! InvalidateAttribs(); // Bindings-Invalidate
754 else
756 if ( rDoc.RemovePageStyleInUse( aString ) )
757 pDocShell->PageStyleModified( ScResId(STR_STYLENAME_STANDARD), true );
759 pStylePool->Remove( pStyle );
761 SfxBindings* pBindings = pDocShell->GetViewBindings();
762 if (pBindings)
763 pBindings->Invalidate( SID_STYLE_FAMILY4 );
764 pDocShell->SetDocumentModified();
769 if (!bFound)
770 throw container::NoSuchElementException();
773 // container::XIndexAccess
775 sal_Int32 SAL_CALL ScStyleFamilyObj::getCount()
777 SolarMutexGuard aGuard;
778 if ( pDocShell )
780 ScDocument& rDoc = pDocShell->GetDocument();
781 ScStyleSheetPool* pStylePool = rDoc.GetStyleSheetPool();
783 SfxStyleSheetIterator aIter( pStylePool, eFamily );
784 return aIter.Count();
786 return 0;
789 uno::Any SAL_CALL ScStyleFamilyObj::getByIndex( sal_Int32 nIndex )
791 SolarMutexGuard aGuard;
792 uno::Reference< style::XStyle > xObj(GetObjectByIndex_Impl(nIndex));
793 if (!xObj.is())
794 throw lang::IndexOutOfBoundsException();
796 return uno::Any(xObj);
799 uno::Type SAL_CALL ScStyleFamilyObj::getElementType()
801 return cppu::UnoType<style::XStyle>::get(); // has to fit to getByIndex
804 sal_Bool SAL_CALL ScStyleFamilyObj::hasElements()
806 SolarMutexGuard aGuard;
807 return ( getCount() != 0 );
810 // container::XNameAccess
812 uno::Any SAL_CALL ScStyleFamilyObj::getByName( const OUString& aName )
814 SolarMutexGuard aGuard;
815 uno::Reference< style::XStyle > xObj(
816 GetObjectByName_Impl( ScStyleNameConversion::ProgrammaticToDisplayName( aName, eFamily ) ));
817 if (!xObj.is())
818 throw container::NoSuchElementException();
820 return uno::Any(xObj);
823 uno::Sequence<OUString> SAL_CALL ScStyleFamilyObj::getElementNames()
825 SolarMutexGuard aGuard;
826 if ( pDocShell )
828 ScDocument& rDoc = pDocShell->GetDocument();
829 ScStyleSheetPool* pStylePool = rDoc.GetStyleSheetPool();
831 SfxStyleSheetIterator aIter( pStylePool, eFamily );
832 sal_uInt16 nCount = aIter.Count();
834 uno::Sequence<OUString> aSeq(nCount);
835 OUString* pAry = aSeq.getArray();
836 SfxStyleSheetBase* pStyle = aIter.First();
837 sal_uInt16 nPos = 0;
838 while (pStyle)
840 OSL_ENSURE( nPos < nCount, "Count is wrong" );
841 if (nPos < nCount)
842 pAry[nPos++] = ScStyleNameConversion::DisplayToProgrammaticName(
843 pStyle->GetName(), eFamily );
844 pStyle = aIter.Next();
846 return aSeq;
848 return uno::Sequence<OUString>();
851 sal_Bool SAL_CALL ScStyleFamilyObj::hasByName( const OUString& aName )
853 SolarMutexGuard aGuard;
854 if ( pDocShell )
856 OUString aString(ScStyleNameConversion::ProgrammaticToDisplayName( aName, eFamily ));
858 ScDocument& rDoc = pDocShell->GetDocument();
859 ScStyleSheetPool* pStylePool = rDoc.GetStyleSheetPool();
860 if ( pStylePool->Find( aString, eFamily ) )
861 return true;
863 return false;
866 // XPropertySet
868 uno::Reference< beans::XPropertySetInfo > SAL_CALL ScStyleFamilyObj::getPropertySetInfo( )
870 OSL_FAIL( "###unexpected!" );
871 return uno::Reference< beans::XPropertySetInfo >();
874 void SAL_CALL ScStyleFamilyObj::setPropertyValue( const OUString&, const uno::Any& )
876 OSL_FAIL( "###unexpected!" );
879 uno::Any SAL_CALL ScStyleFamilyObj::getPropertyValue( const OUString& sPropertyName )
881 uno::Any aRet;
883 if ( sPropertyName != "DisplayName" )
885 throw beans::UnknownPropertyException( "unknown property: " + sPropertyName, static_cast<OWeakObject *>(this) );
888 SolarMutexGuard aGuard;
889 TranslateId pResId;
890 switch ( eFamily )
892 case SfxStyleFamily::Para:
893 pResId = STR_STYLE_FAMILY_CELL; break;
894 case SfxStyleFamily::Page:
895 pResId = STR_STYLE_FAMILY_PAGE; break;
896 default:
897 OSL_FAIL( "ScStyleFamilyObj::getPropertyValue(): invalid family" );
899 if (pResId)
901 OUString sDisplayName(ScResId(pResId));
902 aRet <<= sDisplayName;
905 return aRet;
908 void SAL_CALL ScStyleFamilyObj::addPropertyChangeListener( const OUString&, const uno::Reference< beans::XPropertyChangeListener >& )
910 OSL_FAIL( "###unexpected!" );
913 void SAL_CALL ScStyleFamilyObj::removePropertyChangeListener( const OUString&, const uno::Reference< beans::XPropertyChangeListener >& )
915 OSL_FAIL( "###unexpected!" );
918 void SAL_CALL ScStyleFamilyObj::addVetoableChangeListener( const OUString&, const uno::Reference< beans::XVetoableChangeListener >& )
920 OSL_FAIL( "###unexpected!" );
923 void SAL_CALL ScStyleFamilyObj::removeVetoableChangeListener( const OUString&, const uno::Reference< beans::XVetoableChangeListener >& )
925 OSL_FAIL( "###unexpected!" );
928 // default ctor is needed for reflection
930 ScStyleObj::ScStyleObj(ScDocShell* pDocSh, SfxStyleFamily eFam, OUString aName)
931 : pPropSet( (eFam == SfxStyleFamily::Para) ? lcl_GetCellStyleSet() : lcl_GetPageStyleSet() )
932 , pDocShell(pDocSh)
933 , eFamily(eFam)
934 , aStyleName(std::move(aName))
935 , pStyle_cached(nullptr)
937 // if create by ServiceProvider then pDocShell is NULL
939 if (pDocShell)
940 pDocShell->GetDocument().AddUnoObject(*this);
943 void ScStyleObj::InitDoc( ScDocShell* pNewDocSh, const OUString& rNewName )
945 if ( pNewDocSh && !pDocShell )
947 aStyleName = rNewName;
948 pDocShell = pNewDocSh;
949 pDocShell->GetDocument().AddUnoObject(*this);
953 ScStyleObj::~ScStyleObj()
955 SolarMutexGuard g;
957 if (pDocShell)
958 pDocShell->GetDocument().RemoveUnoObject(*this);
961 // XUnoTunnel
963 UNO3_GETIMPLEMENTATION_IMPL(ScStyleObj);
965 void ScStyleObj::Notify( SfxBroadcaster&, const SfxHint& rHint )
967 // reference update does not matter here
969 if ( rHint.GetId() == SfxHintId::Dying )
971 pDocShell = nullptr; // has become invalid
975 SfxStyleSheetBase* ScStyleObj::GetStyle_Impl( bool bUseCachedValue )
977 if ( bUseCachedValue )
978 return pStyle_cached;
980 pStyle_cached = nullptr;
981 if ( pDocShell )
983 ScDocument& rDoc = pDocShell->GetDocument();
984 ScStyleSheetPool* pStylePool = rDoc.GetStyleSheetPool();
985 pStyle_cached = pStylePool->Find( aStyleName, eFamily );
987 return pStyle_cached;
990 // style::XStyle
992 sal_Bool SAL_CALL ScStyleObj::isUserDefined()
994 SolarMutexGuard aGuard;
995 SfxStyleSheetBase* pStyle = GetStyle_Impl();
996 if (pStyle)
997 return pStyle->IsUserDefined();
998 return false;
1001 sal_Bool SAL_CALL ScStyleObj::isInUse()
1003 SolarMutexGuard aGuard;
1004 SfxStyleSheetBase* pStyle = GetStyle_Impl();
1005 if (pStyle)
1006 return pStyle->IsUsed();
1007 return false;
1010 OUString SAL_CALL ScStyleObj::getParentStyle()
1012 SolarMutexGuard aGuard;
1013 SfxStyleSheetBase* pStyle = GetStyle_Impl();
1014 if (pStyle)
1015 return ScStyleNameConversion::DisplayToProgrammaticName( pStyle->GetParent(), eFamily );
1016 return OUString();
1019 void SAL_CALL ScStyleObj::setParentStyle( const OUString& rParentStyle )
1021 SolarMutexGuard aGuard;
1022 SfxStyleSheetBase* pStyle = GetStyle_Impl();
1023 if (!pStyle)
1024 return;
1026 // cell styles cannot be modified if any sheet is protected
1027 if ( eFamily == SfxStyleFamily::Para && lcl_AnyTabProtected( pDocShell->GetDocument() ) )
1028 return; //! exception?
1030 //! DocFunc function??
1031 //! Undo ?????????????
1033 OUString aString(ScStyleNameConversion::ProgrammaticToDisplayName( rParentStyle, eFamily ));
1034 bool bOk = pStyle->SetParent( aString );
1035 if (!bOk)
1036 return;
1038 // as by setPropertyValue
1040 ScDocument& rDoc = pDocShell->GetDocument();
1041 if ( eFamily == SfxStyleFamily::Para )
1043 // update line height
1045 ScopedVclPtrInstance< VirtualDevice > pVDev;
1046 Point aLogic = pVDev->LogicToPixel( Point(1000,1000), MapMode(MapUnit::MapTwip));
1047 double nPPTX = aLogic.X() / 1000.0;
1048 double nPPTY = aLogic.Y() / 1000.0;
1049 Fraction aZoom(1,1);
1050 rDoc.StyleSheetChanged( pStyle, false, pVDev, nPPTX, nPPTY, aZoom, aZoom );
1052 if (!rDoc.IsImportingXML())
1054 pDocShell->PostPaint( 0,0,0, rDoc.MaxCol(),rDoc.MaxRow(),MAXTAB, PaintPartFlags::Grid|PaintPartFlags::Left );
1055 pDocShell->SetDocumentModified();
1058 else
1060 //! ModifyStyleSheet on document (save old values)
1062 pDocShell->PageStyleModified( aStyleName, true );
1066 // container::XNamed
1068 OUString SAL_CALL ScStyleObj::getName()
1070 SolarMutexGuard aGuard;
1071 SfxStyleSheetBase* pStyle = GetStyle_Impl();
1072 if (pStyle)
1073 return ScStyleNameConversion::DisplayToProgrammaticName( pStyle->GetName(), eFamily );
1074 return OUString();
1077 void SAL_CALL ScStyleObj::setName( const OUString& aNewName )
1079 SolarMutexGuard aGuard;
1080 SfxStyleSheetBase* pStyle = GetStyle_Impl();
1081 if (!pStyle)
1082 return;
1084 // cell styles cannot be renamed if any sheet is protected
1085 if ( eFamily == SfxStyleFamily::Para && lcl_AnyTabProtected( pDocShell->GetDocument() ) )
1086 return; //! exception?
1088 //! DocFunc function??
1089 //! Undo ?????????????
1091 bool bOk = pStyle->SetName( aNewName );
1092 if (!bOk)
1093 return;
1095 aStyleName = aNewName; //! notify other objects for this style?
1097 ScDocument& rDoc = pDocShell->GetDocument();
1098 if ( eFamily == SfxStyleFamily::Para && !rDoc.IsImportingXML() )
1099 rDoc.GetPool()->CellStyleCreated( aNewName, rDoc );
1101 // cell styles = 2, page styles = 4
1102 sal_uInt16 nId = ( eFamily == SfxStyleFamily::Para ) ?
1103 SID_STYLE_FAMILY2 : SID_STYLE_FAMILY4;
1104 SfxBindings* pBindings = pDocShell->GetViewBindings();
1105 if (pBindings)
1107 pBindings->Invalidate( nId );
1108 pBindings->Invalidate( SID_STYLE_APPLY );
1112 uno::Reference<container::XIndexReplace> ScStyleObj::CreateEmptyNumberingRules()
1114 SvxNumRule aRule( SvxNumRuleFlags::NONE, 0, true ); // nothing supported
1115 return SvxCreateNumRule( aRule );
1118 // beans::XPropertyState
1120 const SfxItemSet* ScStyleObj::GetStyleItemSet_Impl( std::u16string_view rPropName,
1121 const SfxItemPropertyMapEntry*& rpResultEntry )
1123 SfxStyleSheetBase* pStyle = GetStyle_Impl( true );
1124 if ( pStyle )
1126 const SfxItemPropertyMapEntry* pEntry = nullptr;
1127 if ( eFamily == SfxStyleFamily::Page )
1129 pEntry = lcl_GetHeaderStyleMap()->getByName( rPropName );
1130 if ( pEntry ) // only item-WIDs in header/footer map
1132 rpResultEntry = pEntry;
1133 return &pStyle->GetItemSet().Get(ATTR_PAGE_HEADERSET).GetItemSet();
1135 pEntry = lcl_GetFooterStyleMap()->getByName( rPropName );
1136 if ( pEntry ) // only item-WIDs in header/footer map
1138 rpResultEntry = pEntry;
1139 return &pStyle->GetItemSet().Get(ATTR_PAGE_FOOTERSET).GetItemSet();
1142 pEntry = pPropSet->getPropertyMap().getByName( rPropName );
1143 if ( pEntry )
1145 rpResultEntry = pEntry;
1146 return &pStyle->GetItemSet();
1150 rpResultEntry = nullptr;
1151 return nullptr;
1154 beans::PropertyState ScStyleObj::getPropertyState_Impl( std::u16string_view aPropertyName )
1156 beans::PropertyState eRet = beans::PropertyState_DIRECT_VALUE;
1158 const SfxItemPropertyMapEntry* pResultEntry = nullptr;
1159 const SfxItemSet* pItemSet = GetStyleItemSet_Impl( aPropertyName, pResultEntry );
1161 if ( pItemSet && pResultEntry )
1163 sal_uInt16 nWhich = pResultEntry->nWID;
1164 if ( nWhich == SC_WID_UNO_TBLBORD || nWhich == SC_WID_UNO_TBLBORD2 )
1166 nWhich = ATTR_BORDER;
1168 if ( IsScItemWid( nWhich ) )
1170 SfxItemState eState = pItemSet->GetItemState( nWhich, false );
1172 // // if no rotate value is set, look at orientation
1173 // //! also for a fixed value of 0 (in case orientation is ambiguous)?
1174 // if ( nWhich == ATTR_ROTATE_VALUE && eState == SfxItemState::DEFAULT )
1175 // eState = pItemSet->GetItemState( ATTR_ORIENTATION, sal_False );
1177 if ( eState == SfxItemState::SET )
1178 eRet = beans::PropertyState_DIRECT_VALUE;
1179 else if ( eState == SfxItemState::DEFAULT )
1180 eRet = beans::PropertyState_DEFAULT_VALUE;
1181 else if ( eState == SfxItemState::DONTCARE )
1182 eRet = beans::PropertyState_AMBIGUOUS_VALUE; // should not happen
1183 else
1185 OSL_FAIL("unknown ItemState");
1189 return eRet;
1192 beans::PropertyState SAL_CALL ScStyleObj::getPropertyState( const OUString& aPropertyName )
1194 SolarMutexGuard aGuard;
1195 GetStyle_Impl();
1197 return getPropertyState_Impl( aPropertyName );
1200 uno::Sequence<beans::PropertyState> SAL_CALL ScStyleObj::getPropertyStates( const uno::Sequence<OUString>& aPropertyNames )
1202 SolarMutexGuard aGuard;
1203 GetStyle_Impl();
1205 uno::Sequence<beans::PropertyState> aRet( aPropertyNames.getLength() );
1206 std::transform(aPropertyNames.begin(), aPropertyNames.end(), aRet.getArray(),
1207 [this](const OUString& rName) -> beans::PropertyState { return getPropertyState_Impl(rName); });
1208 return aRet;
1211 void SAL_CALL ScStyleObj::setPropertyToDefault( const OUString& aPropertyName )
1213 SolarMutexGuard aGuard;
1214 GetStyle_Impl();
1216 const SfxItemPropertyMapEntry* pEntry = pPropSet->getPropertyMap().getByName( aPropertyName );
1217 if ( !pEntry )
1218 throw beans::UnknownPropertyException(aPropertyName);
1220 setPropertyValue_Impl( aPropertyName, pEntry, nullptr );
1223 uno::Any ScStyleObj::getPropertyDefault_Impl( std::u16string_view aPropertyName )
1225 uno::Any aAny;
1227 const SfxItemPropertyMapEntry* pResultEntry = nullptr;
1228 const SfxItemSet* pStyleSet = GetStyleItemSet_Impl( aPropertyName, pResultEntry );
1230 if ( pStyleSet && pResultEntry )
1232 sal_uInt16 nWhich = pResultEntry->nWID;
1234 if ( IsScItemWid( nWhich ) )
1236 // Default is default from ItemPool, not from Standard-Style,
1237 // so it is the same as in setPropertyToDefault
1238 SfxItemSet aEmptySet( *pStyleSet->GetPool(), pStyleSet->GetRanges() );
1239 // default items with wrong Slot-ID are not functional in SfxItemPropertySet3
1240 //! change Slot-IDs...
1241 if ( aEmptySet.GetPool()->GetSlotId(nWhich) == nWhich &&
1242 aEmptySet.GetItemState(nWhich, false) == SfxItemState::DEFAULT )
1244 aEmptySet.Put( aEmptySet.Get( nWhich ) );
1246 const SfxItemSet* pItemSet = &aEmptySet;
1248 switch ( nWhich ) // special item handling
1250 case ATTR_VALUE_FORMAT:
1251 // default has no language set
1252 aAny <<= sal_Int32( static_cast<const SfxUInt32Item&>(pItemSet->Get(nWhich)).GetValue() );
1253 break;
1254 case ATTR_INDENT:
1255 aAny <<= sal_Int16( convertTwipToMm100(static_cast<const ScIndentItem&>(
1256 pItemSet->Get(nWhich)).GetValue()) );
1257 break;
1258 case ATTR_PAGE_SCALE:
1259 case ATTR_PAGE_SCALETOPAGES:
1260 case ATTR_PAGE_FIRSTPAGENO:
1261 aAny <<= sal_Int16( static_cast<const SfxUInt16Item&>(pItemSet->Get(nWhich)).GetValue() );
1262 break;
1263 case ATTR_PAGE_CHARTS:
1264 case ATTR_PAGE_OBJECTS:
1265 case ATTR_PAGE_DRAWINGS:
1266 //! define sal_Bool-MID for ScViewObjectModeItem?
1267 aAny <<= static_cast<const ScViewObjectModeItem&>(pItemSet->Get(nWhich)).GetValue() == VOBJ_MODE_SHOW;
1268 break;
1269 case ATTR_PAGE_SCALETO:
1271 const ScPageScaleToItem aItem(static_cast<const ScPageScaleToItem&>(pItemSet->Get(nWhich)));
1272 if ( aPropertyName == SC_UNO_PAGE_SCALETOX )
1273 aAny <<= static_cast<sal_Int16>(aItem.GetWidth());
1274 else
1275 aAny <<= static_cast<sal_Int16>(aItem.GetHeight());
1277 break;
1278 default:
1279 pPropSet->getPropertyValue( *pResultEntry, *pItemSet, aAny );
1282 else if ( IsScUnoWid( nWhich ) )
1284 SfxItemSet aEmptySet( *pStyleSet->GetPool(), pStyleSet->GetRanges() );
1285 const SfxItemSet* pItemSet = &aEmptySet;
1286 switch ( nWhich )
1288 case SC_WID_UNO_TBLBORD:
1289 case SC_WID_UNO_TBLBORD2:
1291 const SfxPoolItem& rItem = pItemSet->Get(ATTR_BORDER);
1292 SvxBoxItem aOuter(static_cast<const SvxBoxItem&>(rItem));
1293 SvxBoxInfoItem aInner(ATTR_BORDER_INNER);
1294 if (nWhich == SC_WID_UNO_TBLBORD2)
1295 ScHelperFunctions::AssignTableBorder2ToAny(aAny, aOuter, aInner, true);
1296 else
1297 ScHelperFunctions::AssignTableBorderToAny(aAny, aOuter, aInner, true);
1299 break;
1303 return aAny;
1306 uno::Any SAL_CALL ScStyleObj::getPropertyDefault( const OUString& aPropertyName )
1308 SolarMutexGuard aGuard;
1309 GetStyle_Impl();
1311 return getPropertyDefault_Impl( aPropertyName );
1314 uno::Sequence<uno::Any> SAL_CALL ScStyleObj::getPropertyDefaults( const uno::Sequence<OUString>& aPropertyNames )
1316 SolarMutexGuard aGuard;
1317 GetStyle_Impl();
1319 uno::Sequence<uno::Any> aSequence( aPropertyNames.getLength() );
1320 std::transform(aPropertyNames.begin(), aPropertyNames.end(), aSequence.getArray(),
1321 [this](const OUString& rName) -> uno::Any { return getPropertyDefault_Impl(rName); });
1322 return aSequence;
1325 // XMultiPropertySet
1327 void SAL_CALL ScStyleObj::setPropertyValues( const uno::Sequence< OUString >& aPropertyNames,
1328 const uno::Sequence< uno::Any >& aValues )
1330 SolarMutexGuard aGuard;
1331 GetStyle_Impl();
1333 if ( aValues.getLength() != aPropertyNames.getLength() )
1334 throw lang::IllegalArgumentException();
1336 const OUString* pNames = aPropertyNames.getConstArray();
1337 const uno::Any* pValues = aValues.getConstArray();
1338 const SfxItemPropertyMap& rPropertyMap = pPropSet->getPropertyMap();
1339 for ( sal_Int32 i = 0; i < aPropertyNames.getLength(); i++ )
1341 const SfxItemPropertyMapEntry* pEntry = rPropertyMap.getByName( pNames[i] );
1342 setPropertyValue_Impl( pNames[i], pEntry, &pValues[i] );
1346 uno::Sequence<uno::Any> SAL_CALL ScStyleObj::getPropertyValues( const uno::Sequence< OUString >& aPropertyNames )
1348 SolarMutexGuard aGuard;
1349 GetStyle_Impl();
1351 uno::Sequence<uno::Any> aSequence( aPropertyNames.getLength() );
1352 std::transform(aPropertyNames.begin(), aPropertyNames.end(), aSequence.getArray(),
1353 [this](const OUString& rName) -> uno::Any { return getPropertyValue_Impl(rName); });
1354 return aSequence;
1357 void SAL_CALL ScStyleObj::addPropertiesChangeListener( const uno::Sequence<OUString>& /* aPropertyNames */,
1358 const uno::Reference<beans::XPropertiesChangeListener>& /* xListener */ )
1360 // no bound properties
1363 void SAL_CALL ScStyleObj::removePropertiesChangeListener(
1364 const uno::Reference<beans::XPropertiesChangeListener>& /* xListener */ )
1366 // no bound properties
1369 void SAL_CALL ScStyleObj::firePropertiesChangeEvent( const uno::Sequence<OUString>& /* aPropertyNames */,
1370 const uno::Reference<beans::XPropertiesChangeListener>& /* xListener */ )
1372 // no bound properties
1375 // XMultiPropertyStates
1376 // getPropertyStates already defined for XPropertyState
1378 void SAL_CALL ScStyleObj::setAllPropertiesToDefault()
1380 SolarMutexGuard aGuard;
1382 SfxStyleSheetBase* pStyle = GetStyle_Impl();
1383 if ( !pStyle )
1384 return;
1386 // cell styles cannot be modified if any sheet is protected
1387 if ( eFamily == SfxStyleFamily::Para && lcl_AnyTabProtected( pDocShell->GetDocument() ) )
1388 throw uno::RuntimeException();
1390 SfxItemSet& rSet = pStyle->GetItemSet();
1391 rSet.ClearItem(); // set all items to default
1393 //! merge with SetOneProperty
1395 ScDocument& rDoc = pDocShell->GetDocument();
1396 if ( eFamily == SfxStyleFamily::Para )
1398 // row heights
1400 ScopedVclPtrInstance< VirtualDevice > pVDev;
1401 Point aLogic = pVDev->LogicToPixel(Point(1000,1000), MapMode(MapUnit::MapTwip));
1402 double nPPTX = aLogic.X() / 1000.0;
1403 double nPPTY = aLogic.Y() / 1000.0;
1404 Fraction aZoom(1,1);
1405 rDoc.StyleSheetChanged( pStyle, false, pVDev, nPPTX, nPPTY, aZoom, aZoom );
1407 if (!rDoc.IsImportingXML())
1409 pDocShell->PostPaint( 0,0,0, rDoc.MaxCol(),rDoc.MaxRow(),MAXTAB, PaintPartFlags::Grid|PaintPartFlags::Left );
1410 pDocShell->SetDocumentModified();
1413 else
1415 // #i22448# apply the default BoxInfoItem for page styles again
1416 // (same content as in ScStyleSheet::GetItemSet, to control the dialog)
1417 SvxBoxInfoItem aBoxInfoItem( ATTR_BORDER_INNER );
1418 aBoxInfoItem.SetTable( false );
1419 aBoxInfoItem.SetDist( true );
1420 aBoxInfoItem.SetValid( SvxBoxInfoItemValidFlags::DISTANCE );
1421 rSet.Put( aBoxInfoItem );
1423 pDocShell->PageStyleModified( aStyleName, true );
1427 void SAL_CALL ScStyleObj::setPropertiesToDefault( const uno::Sequence<OUString>& aPropertyNames )
1429 SolarMutexGuard aGuard;
1430 GetStyle_Impl();
1432 const SfxItemPropertyMap& rPropertyMap = pPropSet->getPropertyMap();
1433 for ( const OUString& rName : aPropertyNames )
1435 const SfxItemPropertyMapEntry* pEntry = rPropertyMap.getByName( rName );
1436 setPropertyValue_Impl( rName, pEntry, nullptr );
1440 // beans::XPropertySet
1442 uno::Reference<beans::XPropertySetInfo> SAL_CALL ScStyleObj::getPropertySetInfo()
1444 SolarMutexGuard aGuard;
1445 return pPropSet->getPropertySetInfo();
1448 void SAL_CALL ScStyleObj::setPropertyValue( const OUString& aPropertyName, const uno::Any& aValue )
1450 SolarMutexGuard aGuard;
1451 GetStyle_Impl();
1453 const SfxItemPropertyMapEntry* pEntry = pPropSet->getPropertyMap().getByName( aPropertyName );
1454 if ( !pEntry )
1455 throw beans::UnknownPropertyException(aPropertyName);
1457 setPropertyValue_Impl( aPropertyName, pEntry, &aValue );
1460 void ScStyleObj::setPropertyValue_Impl( std::u16string_view rPropertyName, const SfxItemPropertyMapEntry* pEntry, const uno::Any* pValue )
1462 SfxStyleSheetBase* pStyle = GetStyle_Impl( true );
1463 if ( !(pStyle && pEntry) )
1464 return;
1466 // cell styles cannot be modified if any sheet is protected
1467 if ( eFamily == SfxStyleFamily::Para && lcl_AnyTabProtected( pDocShell->GetDocument() ) )
1468 throw uno::RuntimeException();
1470 SfxItemSet& rSet = pStyle->GetItemSet(); // change directly in active Style
1471 bool bDone = false;
1472 if ( eFamily == SfxStyleFamily::Page )
1474 if(pEntry->nWID == SC_WID_UNO_HEADERSET)
1476 const SfxItemPropertyMapEntry* pHeaderEntry = lcl_GetHeaderStyleMap()->getByName( rPropertyName );
1477 if ( pHeaderEntry ) // only item-WIDs in header/footer map
1479 SvxSetItem aNewHeader( rSet.Get(ATTR_PAGE_HEADERSET) );
1480 if (pValue)
1481 pPropSet->setPropertyValue( *pHeaderEntry, *pValue, aNewHeader.GetItemSet() );
1482 else
1483 aNewHeader.GetItemSet().ClearItem( pHeaderEntry->nWID );
1484 rSet.Put( aNewHeader );
1485 bDone = true;
1488 else if(pEntry->nWID == SC_WID_UNO_FOOTERSET)
1490 const SfxItemPropertyMapEntry* pFooterEntry = lcl_GetFooterStyleMap()->getByName( rPropertyName );
1491 if ( pFooterEntry ) // only item-WIDs in header/footer map
1493 SvxSetItem aNewFooter( rSet.Get(ATTR_PAGE_FOOTERSET) );
1494 if (pValue)
1495 pPropSet->setPropertyValue( *pFooterEntry, *pValue, aNewFooter.GetItemSet() );
1496 else
1497 aNewFooter.GetItemSet().ClearItem( pFooterEntry->nWID );
1498 rSet.Put( aNewFooter );
1499 bDone = true;
1503 if (!bDone)
1505 if (IsScItemWid(pEntry->nWID))
1507 if (pValue)
1509 switch (pEntry->nWID) // special item handling
1511 case ATTR_VALUE_FORMAT:
1513 // language for number formats
1514 SvNumberFormatter* pFormatter
1515 = pDocShell->GetDocument().GetFormatTable();
1516 sal_uInt32 nOldFormat = rSet.Get(ATTR_VALUE_FORMAT).GetValue();
1517 LanguageType eOldLang
1518 = rSet.Get(ATTR_LANGUAGE_FORMAT).GetLanguage();
1519 pFormatter->GetFormatForLanguageIfBuiltIn(nOldFormat, eOldLang);
1521 sal_uInt32 nNewFormat = 0;
1522 *pValue >>= nNewFormat;
1523 rSet.Put(SfxUInt32Item(ATTR_VALUE_FORMAT, nNewFormat));
1525 const SvNumberformat* pNewEntry = pFormatter->GetEntry(nNewFormat);
1526 LanguageType eNewLang
1527 = pNewEntry ? pNewEntry->GetLanguage() : LANGUAGE_DONTKNOW;
1528 if (eNewLang != eOldLang && eNewLang != LANGUAGE_DONTKNOW)
1529 rSet.Put(SvxLanguageItem(eNewLang, ATTR_LANGUAGE_FORMAT));
1531 //! keep default state of number format if only language changed?
1533 break;
1534 case ATTR_INDENT:
1536 sal_Int16 nVal = 0;
1537 *pValue >>= nVal;
1538 rSet.Put(ScIndentItem(o3tl::toTwips(nVal, o3tl::Length::mm100)));
1540 break;
1541 case ATTR_ROTATE_VALUE:
1543 sal_Int32 nRotVal = 0;
1544 if (*pValue >>= nRotVal)
1546 // stored value is always between 0 and 360 deg.
1547 nRotVal %= 36000;
1548 if (nRotVal < 0)
1549 nRotVal += 36000;
1550 rSet.Put(ScRotateValueItem(Degree100(nRotVal)));
1553 break;
1554 case ATTR_STACKED:
1556 table::CellOrientation eOrient;
1557 if (*pValue >>= eOrient)
1559 switch (eOrient)
1561 case table::CellOrientation_STANDARD:
1562 rSet.Put(ScVerticalStackCell(false));
1563 break;
1564 case table::CellOrientation_TOPBOTTOM:
1565 rSet.Put(ScVerticalStackCell(false));
1566 rSet.Put(ScRotateValueItem(27000_deg100));
1567 break;
1568 case table::CellOrientation_BOTTOMTOP:
1569 rSet.Put(ScVerticalStackCell(false));
1570 rSet.Put(ScRotateValueItem(9000_deg100));
1571 break;
1572 case table::CellOrientation_STACKED:
1573 rSet.Put(ScVerticalStackCell(true));
1574 break;
1575 default:
1577 // added to avoid warnings
1582 break;
1583 case ATTR_PAGE_SCALE:
1584 case ATTR_PAGE_SCALETOPAGES:
1586 rSet.ClearItem(ATTR_PAGE_SCALETOPAGES);
1587 rSet.ClearItem(ATTR_PAGE_SCALE);
1588 rSet.ClearItem(ATTR_PAGE_SCALETO);
1589 sal_Int16 nVal = 0;
1590 *pValue >>= nVal;
1591 rSet.Put(SfxUInt16Item(pEntry->nWID, nVal));
1593 break;
1594 case ATTR_PAGE_FIRSTPAGENO:
1596 sal_Int16 nVal = 0;
1597 *pValue >>= nVal;
1598 rSet.Put(SfxUInt16Item(ATTR_PAGE_FIRSTPAGENO, nVal));
1600 break;
1601 case ATTR_PAGE_CHARTS:
1602 case ATTR_PAGE_OBJECTS:
1603 case ATTR_PAGE_DRAWINGS:
1605 bool bBool = false;
1606 *pValue >>= bBool;
1607 //! need to define sal_Bool-MID for ScViewObjectModeItem?
1608 rSet.Put(ScViewObjectModeItem(
1609 pEntry->nWID, bBool ? VOBJ_MODE_SHOW : VOBJ_MODE_HIDE));
1611 break;
1612 case ATTR_PAGE_PAPERBIN:
1614 sal_uInt8 nTray = PAPERBIN_PRINTER_SETTINGS;
1615 bool bFound = false;
1617 OUString aName;
1618 if (*pValue >>= aName)
1620 if (aName == SC_PAPERBIN_DEFAULTNAME)
1621 bFound = true;
1622 else
1624 Printer* pPrinter = pDocShell->GetPrinter();
1625 if (pPrinter)
1627 const sal_uInt16 nCount = pPrinter->GetPaperBinCount();
1628 for (sal_uInt16 i = 0; i < nCount; i++)
1629 if (aName == pPrinter->GetPaperBinName(i))
1631 nTray = static_cast<sal_uInt8>(i);
1632 bFound = true;
1633 break;
1638 if (!bFound)
1639 throw lang::IllegalArgumentException();
1641 rSet.Put(SvxPaperBinItem(ATTR_PAGE_PAPERBIN, nTray));
1644 break;
1645 case ATTR_PAGE_SCALETO:
1647 sal_Int16 nPages = 0;
1648 if (*pValue >>= nPages)
1650 ScPageScaleToItem aItem = rSet.Get(ATTR_PAGE_SCALETO);
1651 if (rPropertyName == SC_UNO_PAGE_SCALETOX)
1652 aItem.SetWidth(static_cast<sal_uInt16>(nPages));
1653 else
1654 aItem.SetHeight(static_cast<sal_uInt16>(nPages));
1655 rSet.Put(aItem);
1656 rSet.ClearItem(ATTR_PAGE_SCALETOPAGES);
1657 rSet.ClearItem(ATTR_PAGE_SCALE);
1660 break;
1661 case ATTR_HIDDEN:
1663 bool bHidden = false;
1664 if (*pValue >>= bHidden)
1665 pStyle->SetHidden(bHidden);
1667 break;
1668 default:
1669 // default items with wrong Slot-ID are not working in SfxItemPropertySet3
1670 //! change Slot-IDs...
1671 if (rSet.GetPool()->GetSlotId(pEntry->nWID) == pEntry->nWID
1672 && rSet.GetItemState(pEntry->nWID, false) == SfxItemState::DEFAULT)
1674 rSet.Put(rSet.Get(pEntry->nWID));
1676 pPropSet->setPropertyValue(*pEntry, *pValue, rSet);
1679 else
1681 rSet.ClearItem(pEntry->nWID);
1682 // language for number formats
1683 if (pEntry->nWID == ATTR_VALUE_FORMAT)
1684 rSet.ClearItem(ATTR_LANGUAGE_FORMAT);
1686 //! for ATTR_ROTATE_VALUE, also reset ATTR_ORIENTATION?
1689 else if (IsScUnoWid(pEntry->nWID))
1691 switch (pEntry->nWID)
1693 case SC_WID_UNO_TBLBORD:
1695 if (pValue)
1697 table::TableBorder aBorder;
1698 if (*pValue >>= aBorder)
1700 SvxBoxItem aOuter(ATTR_BORDER);
1701 SvxBoxInfoItem aInner(ATTR_BORDER_INNER);
1702 ScHelperFunctions::FillBoxItems(aOuter, aInner, aBorder);
1703 rSet.Put(aOuter);
1706 else
1708 rSet.ClearItem(ATTR_BORDER);
1711 break;
1712 case SC_WID_UNO_TBLBORD2:
1714 if (pValue)
1716 table::TableBorder2 aBorder2;
1717 if (*pValue >>= aBorder2)
1719 SvxBoxItem aOuter(ATTR_BORDER);
1720 SvxBoxInfoItem aInner(ATTR_BORDER_INNER);
1721 ScHelperFunctions::FillBoxItems(aOuter, aInner, aBorder2);
1722 rSet.Put(aOuter);
1725 else
1727 rSet.ClearItem(ATTR_BORDER);
1730 break;
1735 //! DocFunc-??
1736 //! Undo ??
1738 if ( eFamily == SfxStyleFamily::Para )
1740 // If we are loading, we can delay line height calculation, because we are going to re-calc all of those
1741 // after load.
1742 if (pDocShell && !pDocShell->IsLoading())
1744 // update line height
1745 ScopedVclPtrInstance< VirtualDevice > pVDev;
1746 Point aLogic = pVDev->LogicToPixel(Point(1000,1000), MapMode(MapUnit::MapTwip));
1747 double nPPTX = aLogic.X() / 1000.0;
1748 double nPPTY = aLogic.Y() / 1000.0;
1749 Fraction aZoom(1,1);
1750 ScDocument& rDoc = pDocShell->GetDocument();
1751 rDoc.StyleSheetChanged( pStyle, false, pVDev, nPPTX, nPPTY, aZoom, aZoom );
1753 if (!rDoc.IsImportingXML())
1755 pDocShell->PostPaint( 0,0,0, rDoc.MaxCol(),rDoc.MaxRow(),MAXTAB, PaintPartFlags::Grid|PaintPartFlags::Left );
1756 pDocShell->SetDocumentModified();
1760 else
1762 //! ModifyStyleSheet on document (save old values)
1764 pDocShell->PageStyleModified( aStyleName, true );
1768 uno::Any ScStyleObj::getPropertyValue_Impl( std::u16string_view aPropertyName )
1770 uno::Any aAny;
1771 SfxStyleSheetBase* pStyle = GetStyle_Impl( true );
1773 if ( aPropertyName == SC_UNONAME_DISPNAME ) // read-only
1775 // core always has the display name
1776 if ( pStyle )
1777 aAny <<= pStyle->GetName();
1779 else
1781 const SfxItemPropertyMapEntry* pResultEntry = nullptr;
1782 const SfxItemSet* pItemSet = GetStyleItemSet_Impl( aPropertyName, pResultEntry );
1784 if ( pItemSet && pResultEntry )
1786 sal_uInt16 nWhich = pResultEntry->nWID;
1788 if ( IsScItemWid( nWhich ) )
1790 switch ( nWhich ) // for special item handling
1792 case ATTR_VALUE_FORMAT:
1793 if ( pDocShell )
1795 sal_uInt32 nOldFormat =
1796 pItemSet->Get( ATTR_VALUE_FORMAT ).GetValue();
1797 LanguageType eOldLang =
1798 pItemSet->Get( ATTR_LANGUAGE_FORMAT ).GetLanguage();
1799 nOldFormat = pDocShell->GetDocument().GetFormatTable()->
1800 GetFormatForLanguageIfBuiltIn( nOldFormat, eOldLang );
1801 aAny <<= nOldFormat;
1803 break;
1804 case ATTR_INDENT:
1805 aAny <<= sal_Int16( convertTwipToMm100(static_cast<const ScIndentItem&>(
1806 pItemSet->Get(nWhich)).GetValue()) );
1807 break;
1808 case ATTR_STACKED:
1810 Degree100 nRot = pItemSet->Get(ATTR_ROTATE_VALUE).GetValue();
1811 bool bStacked = static_cast<const ScVerticalStackCell&>(pItemSet->Get(nWhich)).GetValue();
1812 SvxOrientationItem( nRot, bStacked, TypedWhichId<SvxOrientationItem>(0) ).QueryValue( aAny );
1814 break;
1815 case ATTR_PAGE_SCALE:
1816 case ATTR_PAGE_SCALETOPAGES:
1817 case ATTR_PAGE_FIRSTPAGENO:
1818 aAny <<= sal_Int16( static_cast<const SfxUInt16Item&>(pItemSet->Get(nWhich)).GetValue() );
1819 break;
1820 case ATTR_PAGE_CHARTS:
1821 case ATTR_PAGE_OBJECTS:
1822 case ATTR_PAGE_DRAWINGS:
1823 //! define sal_Bool-MID for ScViewObjectModeItem?
1824 aAny <<= static_cast<const ScViewObjectModeItem&>(pItemSet->Get(nWhich)).GetValue() == VOBJ_MODE_SHOW;
1825 break;
1826 case ATTR_PAGE_PAPERBIN:
1828 // property PrinterPaperTray is the name of the tray
1830 sal_uInt8 nValue = static_cast<const SvxPaperBinItem&>(pItemSet->Get(nWhich)).GetValue();
1831 OUString aName;
1832 if ( nValue == PAPERBIN_PRINTER_SETTINGS )
1833 aName = SC_PAPERBIN_DEFAULTNAME;
1834 else
1836 Printer* pPrinter = pDocShell->GetPrinter();
1837 if (pPrinter)
1838 aName = pPrinter->GetPaperBinName( nValue );
1840 aAny <<= aName;
1842 break;
1843 case ATTR_PAGE_SCALETO:
1845 const ScPageScaleToItem& aItem(pItemSet->Get(ATTR_PAGE_SCALETO));
1846 if ( aPropertyName == SC_UNO_PAGE_SCALETOX )
1847 aAny <<= static_cast<sal_Int16>(aItem.GetWidth());
1848 else
1849 aAny <<= static_cast<sal_Int16>(aItem.GetHeight());
1851 break;
1852 case ATTR_HIDDEN:
1854 bool bHidden = pStyle && pStyle->IsHidden();
1855 aAny <<= bHidden;
1857 break;
1858 default:
1859 // Default-Items with wrong Slot-ID don't work in SfxItemPropertySet3
1860 //! change Slot-IDs...
1861 if ( pItemSet->GetPool()->GetSlotId(nWhich) == nWhich &&
1862 pItemSet->GetItemState(nWhich, false) == SfxItemState::DEFAULT )
1864 SfxItemSet aNoEmptySet( *pItemSet );
1865 aNoEmptySet.Put( aNoEmptySet.Get( nWhich ) );
1866 pPropSet->getPropertyValue( *pResultEntry, aNoEmptySet, aAny );
1868 else
1869 pPropSet->getPropertyValue( *pResultEntry, *pItemSet, aAny );
1872 else if ( IsScUnoWid( nWhich ) )
1874 switch ( nWhich )
1876 case SC_WID_UNO_TBLBORD:
1877 case SC_WID_UNO_TBLBORD2:
1879 const SfxPoolItem& rItem = pItemSet->Get(ATTR_BORDER);
1880 SvxBoxItem aOuter(static_cast<const SvxBoxItem&>(rItem));
1881 SvxBoxInfoItem aInner(ATTR_BORDER_INNER);
1882 if (nWhich == SC_WID_UNO_TBLBORD2)
1883 ScHelperFunctions::AssignTableBorder2ToAny(aAny, aOuter, aInner,
1884 true);
1885 else
1886 ScHelperFunctions::AssignTableBorderToAny(aAny, aOuter, aInner,
1887 true);
1889 break;
1895 return aAny;
1898 uno::Any SAL_CALL ScStyleObj::getPropertyValue( const OUString& aPropertyName )
1900 SolarMutexGuard aGuard;
1901 GetStyle_Impl();
1903 return getPropertyValue_Impl( aPropertyName );
1906 SC_IMPL_DUMMY_PROPERTY_LISTENER( ScStyleObj )
1908 // lang::XServiceInfo
1910 OUString SAL_CALL ScStyleObj::getImplementationName()
1912 return "ScStyleObj";
1915 sal_Bool SAL_CALL ScStyleObj::supportsService( const OUString& rServiceName )
1917 return cppu::supportsService(this, rServiceName);
1920 uno::Sequence<OUString> SAL_CALL ScStyleObj::getSupportedServiceNames()
1922 const bool bPage = ( eFamily == SfxStyleFamily::Page );
1924 return {SCSTYLE_SERVICE,
1925 (bPage ? OUString(SCPAGESTYLE_SERVICE)
1926 : OUString(SCCELLSTYLE_SERVICE))};
1929 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */