xref: /trunk/main/sc/source/ui/unoobj/styleuno.cxx (revision 91144cd0085a7583d2099b982122deb2184ab956)
1 /**************************************************************
2  *
3  * Licensed to the Apache Software Foundation (ASF) under one
4  * or more contributor license agreements.  See the NOTICE file
5  * distributed with this work for additional information
6  * regarding copyright ownership.  The ASF licenses this file
7  * to you under the Apache License, Version 2.0 (the
8  * "License"); you may not use this file except in compliance
9  * with the License.  You may obtain a copy of the License at
10  *
11  *   http://www.apache.org/licenses/LICENSE-2.0
12  *
13  * Unless required by applicable law or agreed to in writing,
14  * software distributed under the License is distributed on an
15  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16  * KIND, either express or implied.  See the License for the
17  * specific language governing permissions and limitations
18  * under the License.
19  *
20  *************************************************************/
21 
22 
23 
24 // MARKER(update_precomp.py): autogen include statement, do not remove
25 #include "precompiled_sc.hxx"
26 
27 
28 
29 #include "scitems.hxx"
30 #include <editeng/memberids.hrc>
31 #include <svx/algitem.hxx>
32 #include <editeng/boxitem.hxx>
33 #include <editeng/langitem.hxx>
34 #include <editeng/numitem.hxx>
35 #include <svx/pageitem.hxx>
36 #include <editeng/pbinitem.hxx>
37 #include <svx/unomid.hxx>
38 #include <editeng/unonrule.hxx>
39 #include <sfx2/bindings.hxx>
40 #include <sfx2/printer.hxx>
41 #include <vcl/virdev.hxx>
42 #include <svl/itempool.hxx>
43 #include <svl/itemset.hxx>
44 #include <svl/intitem.hxx>
45 #include <svl/zformat.hxx>
46 #include <rtl/uuid.h>
47 
48 #include <com/sun/star/table/BorderLine.hpp>
49 #include <com/sun/star/table/CellVertJustify.hpp>
50 #include <com/sun/star/table/TableBorder.hpp>
51 #include <com/sun/star/table/ShadowFormat.hpp>
52 #include <com/sun/star/table/CellHoriJustify.hpp>
53 #include <com/sun/star/table/CellOrientation.hpp>
54 #include <com/sun/star/style/PageStyleLayout.hpp>
55 #include <com/sun/star/style/GraphicLocation.hpp>
56 #include <com/sun/star/sheet/XHeaderFooterContent.hpp>
57 #include <com/sun/star/util/CellProtection.hpp>
58 #include <com/sun/star/awt/FontSlant.hpp>
59 #include <com/sun/star/awt/Size.hpp>
60 #include <com/sun/star/lang/Locale.hpp>
61 #include <com/sun/star/beans/PropertyAttribute.hpp>
62 
63 #include "styleuno.hxx"
64 #include "docsh.hxx"
65 #include "attrib.hxx"
66 #include "stlpool.hxx"
67 #include "docpool.hxx"
68 #include "unoguard.hxx"
69 #include "miscuno.hxx"
70 #include "convuno.hxx"
71 #include "tablink.hxx"
72 #include "unonames.hxx"
73 #include "unowids.hxx"
74 #include "globstr.hrc"
75 #include "cellsuno.hxx"
76 
77 using namespace ::com::sun::star;
78 
79 //------------------------------------------------------------------------
80 
lcl_GetCellStyleSet()81 const SfxItemPropertySet* lcl_GetCellStyleSet()
82 {
83     static SfxItemPropertyMapEntry aCellStyleMap_Impl[] =
84     {
85         {MAP_CHAR_LEN(SC_UNONAME_ASIANVERT),ATTR_VERTICAL_ASIAN,&getBooleanCppuType(),                  0, 0 },
86         {MAP_CHAR_LEN(SC_UNONAME_BOTTBORDER),ATTR_BORDER,       &::getCppuType((const table::BorderLine*)0),        0, BOTTOM_BORDER | CONVERT_TWIPS },
87         {MAP_CHAR_LEN(SC_UNONAME_CELLBACK), ATTR_BACKGROUND,    &::getCppuType((const sal_Int32*)0),            0, MID_BACK_COLOR },
88         {MAP_CHAR_LEN(SC_UNONAME_CELLPRO),  ATTR_PROTECTION,    &::getCppuType((const util::CellProtection*)0), 0, 0 },
89         {MAP_CHAR_LEN(SC_UNONAME_CCOLOR),   ATTR_FONT_COLOR,    &::getCppuType((const sal_Int32*)0),            0, 0 },
90         {MAP_CHAR_LEN(SC_UNONAME_COUTL),    ATTR_FONT_CONTOUR,  &::getBooleanCppuType(),            0, 0 },
91         {MAP_CHAR_LEN(SC_UNONAME_CCROSS),   ATTR_FONT_CROSSEDOUT,&::getBooleanCppuType(),           0, MID_CROSSED_OUT },
92         {MAP_CHAR_LEN(SC_UNONAME_CEMPHAS),  ATTR_FONT_EMPHASISMARK,&getCppuType((sal_Int16*)0),         0, MID_EMPHASIS },
93         {MAP_CHAR_LEN(SC_UNONAME_CFONT),    ATTR_FONT,          &::getCppuType((const sal_Int16*)0),            0, MID_FONT_FAMILY },
94         {MAP_CHAR_LEN(SC_UNONAME_CFCHARS),  ATTR_FONT,          &getCppuType((sal_Int16*)0),            0, MID_FONT_CHAR_SET },
95         {MAP_CHAR_LEN(SC_UNO_CJK_CFCHARS),  ATTR_CJK_FONT,      &getCppuType((sal_Int16*)0),            0, MID_FONT_CHAR_SET },
96         {MAP_CHAR_LEN(SC_UNO_CTL_CFCHARS),  ATTR_CTL_FONT,      &getCppuType((sal_Int16*)0),            0, MID_FONT_CHAR_SET },
97         {MAP_CHAR_LEN(SC_UNONAME_CFFAMIL),  ATTR_FONT,          &getCppuType((sal_Int16*)0),            0, MID_FONT_FAMILY },
98         {MAP_CHAR_LEN(SC_UNO_CJK_CFFAMIL),  ATTR_CJK_FONT,      &getCppuType((sal_Int16*)0),            0, MID_FONT_FAMILY },
99         {MAP_CHAR_LEN(SC_UNO_CTL_CFFAMIL),  ATTR_CTL_FONT,      &getCppuType((sal_Int16*)0),            0, MID_FONT_FAMILY },
100         {MAP_CHAR_LEN(SC_UNONAME_CFNAME),   ATTR_FONT,          &getCppuType((rtl::OUString*)0),        0, MID_FONT_FAMILY_NAME },
101         {MAP_CHAR_LEN(SC_UNO_CJK_CFNAME),   ATTR_CJK_FONT,      &getCppuType((rtl::OUString*)0),        0, MID_FONT_FAMILY_NAME },
102         {MAP_CHAR_LEN(SC_UNO_CTL_CFNAME),   ATTR_CTL_FONT,      &getCppuType((rtl::OUString*)0),        0, MID_FONT_FAMILY_NAME },
103         {MAP_CHAR_LEN(SC_UNONAME_CFPITCH),  ATTR_FONT,          &getCppuType((sal_Int16*)0),            0, MID_FONT_PITCH },
104         {MAP_CHAR_LEN(SC_UNO_CJK_CFPITCH),  ATTR_CJK_FONT,      &getCppuType((sal_Int16*)0),            0, MID_FONT_PITCH },
105         {MAP_CHAR_LEN(SC_UNO_CTL_CFPITCH),  ATTR_CTL_FONT,      &getCppuType((sal_Int16*)0),            0, MID_FONT_PITCH },
106         {MAP_CHAR_LEN(SC_UNONAME_CFSTYLE),  ATTR_FONT,          &getCppuType((rtl::OUString*)0),        0, MID_FONT_STYLE_NAME },
107         {MAP_CHAR_LEN(SC_UNO_CJK_CFSTYLE),  ATTR_CJK_FONT,      &getCppuType((rtl::OUString*)0),        0, MID_FONT_STYLE_NAME },
108         {MAP_CHAR_LEN(SC_UNO_CTL_CFSTYLE),  ATTR_CTL_FONT,      &getCppuType((rtl::OUString*)0),        0, MID_FONT_STYLE_NAME },
109         {MAP_CHAR_LEN(SC_UNONAME_CHEIGHT),  ATTR_FONT_HEIGHT,   &::getCppuType((const float*)0),            0, MID_FONTHEIGHT | CONVERT_TWIPS },
110         {MAP_CHAR_LEN(SC_UNO_CJK_CHEIGHT),  ATTR_CJK_FONT_HEIGHT,&::getCppuType((const float*)0),           0, MID_FONTHEIGHT | CONVERT_TWIPS },
111         {MAP_CHAR_LEN(SC_UNO_CTL_CHEIGHT),  ATTR_CTL_FONT_HEIGHT,&::getCppuType((const float*)0),           0, MID_FONTHEIGHT | CONVERT_TWIPS },
112         {MAP_CHAR_LEN(SC_UNONAME_CLOCAL),   ATTR_FONT_LANGUAGE, &::getCppuType((const lang::Locale*)0),         0, MID_LANG_LOCALE },
113         {MAP_CHAR_LEN(SC_UNO_CJK_CLOCAL),   ATTR_CJK_FONT_LANGUAGE,&::getCppuType((const lang::Locale*)0),          0, MID_LANG_LOCALE },
114         {MAP_CHAR_LEN(SC_UNO_CTL_CLOCAL),   ATTR_CTL_FONT_LANGUAGE,&::getCppuType((const lang::Locale*)0),          0, MID_LANG_LOCALE },
115         {MAP_CHAR_LEN(SC_UNONAME_COVER),    ATTR_FONT_OVERLINE, &::getCppuType((const sal_Int16*)0),    0, MID_TL_STYLE },
116         {MAP_CHAR_LEN(SC_UNONAME_COVRLCOL), ATTR_FONT_OVERLINE, &getCppuType((sal_Int32*)0),            0, MID_TL_COLOR },
117         {MAP_CHAR_LEN(SC_UNONAME_COVRLHAS), ATTR_FONT_OVERLINE, &getBooleanCppuType(),                  0, MID_TL_HASCOLOR },
118         {MAP_CHAR_LEN(SC_UNONAME_CPOST),    ATTR_FONT_POSTURE,  &::getCppuType((const awt::FontSlant*)0),       0, MID_POSTURE },
119         {MAP_CHAR_LEN(SC_UNO_CJK_CPOST),    ATTR_CJK_FONT_POSTURE,&::getCppuType((const awt::FontSlant*)0),     0, MID_POSTURE },
120         {MAP_CHAR_LEN(SC_UNO_CTL_CPOST),    ATTR_CTL_FONT_POSTURE,&::getCppuType((const awt::FontSlant*)0),     0, MID_POSTURE },
121         {MAP_CHAR_LEN(SC_UNONAME_CRELIEF),  ATTR_FONT_RELIEF,   &getCppuType((sal_Int16*)0),            0, MID_RELIEF },
122         {MAP_CHAR_LEN(SC_UNONAME_CSHADD),   ATTR_FONT_SHADOWED, &::getBooleanCppuType(),            0, 0 },
123         {MAP_CHAR_LEN(SC_UNONAME_CSTRIKE),  ATTR_FONT_CROSSEDOUT,&getCppuType((sal_Int16*)0),           0, MID_CROSS_OUT },
124         {MAP_CHAR_LEN(SC_UNONAME_CUNDER),   ATTR_FONT_UNDERLINE,&::getCppuType((const sal_Int16*)0),    0, MID_TL_STYLE },
125         {MAP_CHAR_LEN(SC_UNONAME_CUNDLCOL), ATTR_FONT_UNDERLINE,&getCppuType((sal_Int32*)0),            0, MID_TL_COLOR },
126         {MAP_CHAR_LEN(SC_UNONAME_CUNDLHAS), ATTR_FONT_UNDERLINE,&getBooleanCppuType(),                  0, MID_TL_HASCOLOR },
127         {MAP_CHAR_LEN(SC_UNONAME_CWEIGHT),  ATTR_FONT_WEIGHT,   &::getCppuType((const float*)0),            0, MID_WEIGHT },
128         {MAP_CHAR_LEN(SC_UNO_CJK_CWEIGHT),  ATTR_CJK_FONT_WEIGHT,&::getCppuType((const float*)0),           0, MID_WEIGHT },
129         {MAP_CHAR_LEN(SC_UNO_CTL_CWEIGHT),  ATTR_CTL_FONT_WEIGHT,&::getCppuType((const float*)0),           0, MID_WEIGHT },
130         {MAP_CHAR_LEN(SC_UNONAME_CWORDMOD), ATTR_FONT_WORDLINE, &getBooleanCppuType(),                  0, 0 },
131         {MAP_CHAR_LEN(SC_UNONAME_DIAGONAL_BLTR), ATTR_BORDER_BLTR, &::getCppuType((const table::BorderLine*)0), 0, 0 | CONVERT_TWIPS },
132         {MAP_CHAR_LEN(SC_UNONAME_DIAGONAL_TLBR), ATTR_BORDER_TLBR, &::getCppuType((const table::BorderLine*)0), 0, 0 | CONVERT_TWIPS },
133         {MAP_CHAR_LEN(SC_UNONAME_DISPNAME), SC_WID_UNO_DISPNAME,&::getCppuType((rtl::OUString*)0),  beans::PropertyAttribute::READONLY, 0 },
134         {MAP_CHAR_LEN(SC_UNONAME_CELLHJUS), ATTR_HOR_JUSTIFY,   &::getCppuType((const table::CellHoriJustify*)0),   0, MID_HORJUST_HORJUST },
135         {MAP_CHAR_LEN(SC_UNONAME_CELLTRAN), ATTR_BACKGROUND,    &::getBooleanCppuType(),            0, MID_GRAPHIC_TRANSPARENT },
136         {MAP_CHAR_LEN(SC_UNONAME_WRAP),     ATTR_LINEBREAK,     &::getBooleanCppuType(),            0, 0 },
137         {MAP_CHAR_LEN(SC_UNONAME_LEFTBORDER),ATTR_BORDER,       &::getCppuType((const table::BorderLine*)0),        0, LEFT_BORDER | CONVERT_TWIPS },
138         {MAP_CHAR_LEN(SC_UNONAME_NUMFMT),   ATTR_VALUE_FORMAT,  &::getCppuType((const sal_Int32*)0),            0, 0 },
139 //      {MAP_CHAR_LEN(SC_UNONAME_NUMRULES), SC_WID_UNO_NUMRULES,&getCppuType((const uno::Reference<container::XIndexReplace>*)0), 0, 0 },
140         {MAP_CHAR_LEN(SC_UNONAME_CELLORI),  ATTR_STACKED,       &::getCppuType((const table::CellOrientation*)0),   0, 0 },
141         {MAP_CHAR_LEN(SC_UNONAME_PADJUST),  ATTR_HOR_JUSTIFY,   &::getCppuType((const sal_Int16*)0),    0, MID_HORJUST_ADJUST },
142         {MAP_CHAR_LEN(SC_UNONAME_PBMARGIN), ATTR_MARGIN,        &::getCppuType((const sal_Int32*)0),            0, MID_MARGIN_LO_MARGIN | CONVERT_TWIPS },
143         {MAP_CHAR_LEN(SC_UNONAME_PINDENT),  ATTR_INDENT,        &::getCppuType((const sal_Int16*)0),            0, 0 }, //! CONVERT_TWIPS
144         {MAP_CHAR_LEN(SC_UNONAME_PISCHDIST),ATTR_SCRIPTSPACE,   &::getBooleanCppuType(),                    0, 0 },
145         {MAP_CHAR_LEN(SC_UNONAME_PISFORBID),ATTR_FORBIDDEN_RULES,&::getBooleanCppuType(),                   0, 0 },
146         {MAP_CHAR_LEN(SC_UNONAME_PISHANG),  ATTR_HANGPUNCTUATION,&::getBooleanCppuType(),                   0, 0 },
147         {MAP_CHAR_LEN(SC_UNONAME_PISHYPHEN),ATTR_HYPHENATE,     &getBooleanCppuType(),                  0, 0 },
148         {MAP_CHAR_LEN(SC_UNONAME_PLASTADJ), ATTR_HOR_JUSTIFY,   &::getCppuType((const sal_Int16*)0),    0, MID_HORJUST_ADJUST },
149         {MAP_CHAR_LEN(SC_UNONAME_PLMARGIN), ATTR_MARGIN,        &::getCppuType((const sal_Int32*)0),            0, MID_MARGIN_L_MARGIN  | CONVERT_TWIPS },
150         {MAP_CHAR_LEN(SC_UNONAME_PRMARGIN), ATTR_MARGIN,        &::getCppuType((const sal_Int32*)0),            0, MID_MARGIN_R_MARGIN  | CONVERT_TWIPS },
151         {MAP_CHAR_LEN(SC_UNONAME_PTMARGIN), ATTR_MARGIN,        &::getCppuType((const sal_Int32*)0),            0, MID_MARGIN_UP_MARGIN | CONVERT_TWIPS },
152         {MAP_CHAR_LEN(SC_UNONAME_RIGHTBORDER),ATTR_BORDER,      &::getCppuType((const table::BorderLine*)0),        0, RIGHT_BORDER | CONVERT_TWIPS },
153         {MAP_CHAR_LEN(SC_UNONAME_ROTANG),   ATTR_ROTATE_VALUE,  &::getCppuType((const sal_Int32*)0),            0, 0 },
154         {MAP_CHAR_LEN(SC_UNONAME_ROTREF),   ATTR_ROTATE_MODE,   &::getCppuType((const table::CellVertJustify*)0),   0, 0 },
155         {MAP_CHAR_LEN(SC_UNONAME_SHADOW),   ATTR_SHADOW,        &::getCppuType((const table::ShadowFormat*)0),  0, 0 | CONVERT_TWIPS },
156         {MAP_CHAR_LEN(SC_UNONAME_SHRINK_TO_FIT), ATTR_SHRINKTOFIT, &getBooleanCppuType(),               0, 0 },
157         {MAP_CHAR_LEN(SC_UNONAME_TBLBORD),  SC_WID_UNO_TBLBORD, &::getCppuType((const table::TableBorder*)0),       0, 0 | CONVERT_TWIPS },
158         {MAP_CHAR_LEN(SC_UNONAME_TOPBORDER),ATTR_BORDER,        &::getCppuType((const table::BorderLine*)0),        0, TOP_BORDER | CONVERT_TWIPS },
159         {MAP_CHAR_LEN(SC_UNONAME_USERDEF),  ATTR_USERDEF,       &getCppuType((uno::Reference<container::XNameContainer>*)0), 0, 0 },
160         {MAP_CHAR_LEN(SC_UNONAME_CELLVJUS), ATTR_VER_JUSTIFY,   &::getCppuType((const table::CellVertJustify*)0),   0, 0 },
161         {MAP_CHAR_LEN(SC_UNONAME_WRITING),  ATTR_WRITINGDIR,    &getCppuType((sal_Int16*)0),            0, 0 },
162         {0,0,0,0,0,0}
163     };
164     static SfxItemPropertySet aCellStyleSet_Impl( aCellStyleMap_Impl );
165     return &aCellStyleSet_Impl;
166 }
167 
168 //  Map mit allen Seitenattributen, incl. Kopf-/Fusszeilenattribute
169 
lcl_GetPageStyleSet()170 const SfxItemPropertySet * lcl_GetPageStyleSet()
171 {
172     static SfxItemPropertyMapEntry aPageStyleMap_Impl[] =
173     {
174         {MAP_CHAR_LEN(SC_UNO_PAGE_BACKCOLOR),   ATTR_BACKGROUND,    &::getCppuType((const sal_Int32*)0),            0, MID_BACK_COLOR },
175         {MAP_CHAR_LEN(SC_UNO_PAGE_GRAPHICFILT), ATTR_BACKGROUND,    &::getCppuType((const ::rtl::OUString*)0),          0, MID_GRAPHIC_FILTER },
176         {MAP_CHAR_LEN(SC_UNO_PAGE_GRAPHICLOC),  ATTR_BACKGROUND,    &::getCppuType((const style::GraphicLocation*)0),   0, MID_GRAPHIC_POSITION },
177         {MAP_CHAR_LEN(SC_UNO_PAGE_GRAPHICURL),  ATTR_BACKGROUND,    &::getCppuType((const ::rtl::OUString*)0),          0, MID_GRAPHIC_URL },
178         {MAP_CHAR_LEN(SC_UNO_PAGE_BACKTRANS),   ATTR_BACKGROUND,    &::getBooleanCppuType(),            0, MID_GRAPHIC_TRANSPARENT },
179         {MAP_CHAR_LEN(OLD_UNO_PAGE_BACKCOLOR),  ATTR_BACKGROUND,    &::getCppuType((const sal_Int32*)0),            0, MID_BACK_COLOR },
180         {MAP_CHAR_LEN(SC_UNO_PAGE_BORDERDIST),  ATTR_BORDER,        &::getCppuType((const sal_Int32*)0),    0, BORDER_DISTANCE | CONVERT_TWIPS },
181         {MAP_CHAR_LEN(SC_UNO_PAGE_BOTTBORDER),  ATTR_BORDER,        &::getCppuType((const table::BorderLine*)0),        0, BOTTOM_BORDER | CONVERT_TWIPS },
182         {MAP_CHAR_LEN(SC_UNO_PAGE_BOTTBRDDIST), ATTR_BORDER,        &::getCppuType((const sal_Int32*)0),    0, BOTTOM_BORDER_DISTANCE | CONVERT_TWIPS },
183         {MAP_CHAR_LEN(SC_UNO_PAGE_BOTTMARGIN),  ATTR_ULSPACE,       &::getCppuType((const sal_Int32*)0),            0, MID_LO_MARGIN | CONVERT_TWIPS },
184         {MAP_CHAR_LEN(SC_UNO_PAGE_CENTERHOR),   ATTR_PAGE_HORCENTER,&::getBooleanCppuType(),            0, 0 },
185         {MAP_CHAR_LEN(SC_UNO_PAGE_CENTERVER),   ATTR_PAGE_VERCENTER,&::getBooleanCppuType(),            0, 0 },
186         {MAP_CHAR_LEN(SC_UNONAME_DISPNAME),     SC_WID_UNO_DISPNAME,&::getCppuType((rtl::OUString*)0),  beans::PropertyAttribute::READONLY, 0 },
187         {MAP_CHAR_LEN(SC_UNO_PAGE_FIRSTPAGE),   ATTR_PAGE_FIRSTPAGENO,&::getCppuType((const sal_Int16*)0),      0, 0 },
188 //
189         {MAP_CHAR_LEN(SC_UNO_PAGE_FTRBACKCOL),  SC_WID_UNO_FOOTERSET,&::getCppuType((const sal_Int32*)0),           0, 0 },
190         {MAP_CHAR_LEN(SC_UNO_PAGE_FTRGRFFILT),  SC_WID_UNO_FOOTERSET,&::getCppuType((const ::rtl::OUString*)0),     0, 0 },
191         {MAP_CHAR_LEN(SC_UNO_PAGE_FTRGRFLOC),   SC_WID_UNO_FOOTERSET,&::getCppuType((const style::GraphicLocation*)0), 0, 0 },
192         {MAP_CHAR_LEN(SC_UNO_PAGE_FTRGRFURL),   SC_WID_UNO_FOOTERSET,&::getCppuType((const ::rtl::OUString*)0),     0, 0 },
193         {MAP_CHAR_LEN(SC_UNO_PAGE_FTRBACKTRAN), SC_WID_UNO_FOOTERSET,&::getBooleanCppuType(),                       0, 0 },
194         {MAP_CHAR_LEN(OLD_UNO_PAGE_FTRBACKCOL), SC_WID_UNO_FOOTERSET,&::getCppuType((const sal_Int32*)0),           0, 0 },
195         {MAP_CHAR_LEN(SC_UNO_PAGE_FTRBODYDIST), SC_WID_UNO_FOOTERSET,&::getCppuType((const sal_Int32*)0),           0, 0 },
196         {MAP_CHAR_LEN(SC_UNO_PAGE_FTRBRDDIST),  SC_WID_UNO_FOOTERSET,&::getCppuType((const sal_Int32*)0),           0, 0 },
197         {MAP_CHAR_LEN(SC_UNO_PAGE_FTRBOTTBOR),  SC_WID_UNO_FOOTERSET,&::getCppuType((const table::BorderLine*)0),   0, 0 },
198         {MAP_CHAR_LEN(SC_UNO_PAGE_FTRBOTTBDIS), SC_WID_UNO_FOOTERSET,&::getCppuType((const sal_Int32*)0),           0, 0 },
199         {MAP_CHAR_LEN(OLD_UNO_PAGE_FTRDYNAMIC), SC_WID_UNO_FOOTERSET,&::getBooleanCppuType(),                       0, 0 },
200         {MAP_CHAR_LEN(SC_UNO_PAGE_FTRHEIGHT),   SC_WID_UNO_FOOTERSET,&::getCppuType((const sal_Int32*)0),           0, 0 },
201         {MAP_CHAR_LEN(SC_UNO_PAGE_FTRDYNAMIC),  SC_WID_UNO_FOOTERSET,&::getBooleanCppuType(),                       0, 0 },
202         {MAP_CHAR_LEN(SC_UNO_PAGE_FTRON),       SC_WID_UNO_FOOTERSET,&::getBooleanCppuType(),                       0, 0 },
203         {MAP_CHAR_LEN(SC_UNO_PAGE_FTRSHARED),   SC_WID_UNO_FOOTERSET,&::getBooleanCppuType(),                       0, 0 },
204         {MAP_CHAR_LEN(SC_UNO_PAGE_FTRLEFTBOR),  SC_WID_UNO_FOOTERSET,&::getCppuType((const table::BorderLine*)0),   0, 0 },
205         {MAP_CHAR_LEN(SC_UNO_PAGE_FTRLEFTBDIS), SC_WID_UNO_FOOTERSET,&::getCppuType((const sal_Int32*)0),           0, 0 },
206         {MAP_CHAR_LEN(SC_UNO_PAGE_FTRLEFTMAR),  SC_WID_UNO_FOOTERSET,&::getCppuType((const sal_Int32*)0),           0, 0 },
207         {MAP_CHAR_LEN(OLD_UNO_PAGE_FTRON),      SC_WID_UNO_FOOTERSET,&::getBooleanCppuType(),                       0, 0 },
208         {MAP_CHAR_LEN(SC_UNO_PAGE_FTRRIGHTBOR), SC_WID_UNO_FOOTERSET,&::getCppuType((const table::BorderLine*)0),   0, 0 },
209         {MAP_CHAR_LEN(SC_UNO_PAGE_FTRRIGHTBDIS),SC_WID_UNO_FOOTERSET,&::getCppuType((const sal_Int32*)0),           0, 0 },
210         {MAP_CHAR_LEN(SC_UNO_PAGE_FTRRIGHTMAR), SC_WID_UNO_FOOTERSET,&::getCppuType((const sal_Int32*)0),           0, 0 },
211         {MAP_CHAR_LEN(SC_UNO_PAGE_FTRSHADOW),   SC_WID_UNO_FOOTERSET,&::getCppuType((const table::ShadowFormat*)0), 0, 0 },
212         {MAP_CHAR_LEN(OLD_UNO_PAGE_FTRSHARED),  SC_WID_UNO_FOOTERSET,&::getBooleanCppuType(),                       0, 0 },
213         {MAP_CHAR_LEN(SC_UNO_PAGE_FTRTOPBOR),   SC_WID_UNO_FOOTERSET,&::getCppuType((const table::BorderLine*)0),   0, 0 },
214         {MAP_CHAR_LEN(SC_UNO_PAGE_FTRTOPBDIS),  SC_WID_UNO_FOOTERSET,&::getCppuType((const sal_Int32*)0),           0, 0 },
215 //
216         {MAP_CHAR_LEN(SC_UNO_PAGE_HDRBACKCOL),  SC_WID_UNO_HEADERSET,&::getCppuType((const sal_Int32*)0),           0, 0 },
217         {MAP_CHAR_LEN(SC_UNO_PAGE_HDRGRFFILT),  SC_WID_UNO_HEADERSET,&::getCppuType((const ::rtl::OUString*)0),     0, 0 },
218         {MAP_CHAR_LEN(SC_UNO_PAGE_HDRGRFLOC),   SC_WID_UNO_HEADERSET,&::getCppuType((const style::GraphicLocation*)0), 0, 0 },
219         {MAP_CHAR_LEN(SC_UNO_PAGE_HDRGRFURL),   SC_WID_UNO_HEADERSET,&::getCppuType((const ::rtl::OUString*)0),     0, 0 },
220         {MAP_CHAR_LEN(SC_UNO_PAGE_HDRBACKTRAN), SC_WID_UNO_HEADERSET,&::getBooleanCppuType(),                       0, 0 },
221         {MAP_CHAR_LEN(OLD_UNO_PAGE_HDRBACKCOL), SC_WID_UNO_HEADERSET,&::getCppuType((const sal_Int32*)0),           0, 0 },
222         {MAP_CHAR_LEN(SC_UNO_PAGE_HDRBODYDIST), SC_WID_UNO_HEADERSET,&::getCppuType((const sal_Int32*)0),           0, 0 },
223         {MAP_CHAR_LEN(SC_UNO_PAGE_HDRBRDDIST),  SC_WID_UNO_HEADERSET,&::getCppuType((const sal_Int32*)0),           0, 0 },
224         {MAP_CHAR_LEN(SC_UNO_PAGE_HDRBOTTBOR),  SC_WID_UNO_HEADERSET,&::getCppuType((const table::BorderLine*)0),   0, 0 },
225         {MAP_CHAR_LEN(SC_UNO_PAGE_HDRBOTTBDIS), SC_WID_UNO_HEADERSET,&::getCppuType((const sal_Int32*)0),           0, 0 },
226         {MAP_CHAR_LEN(OLD_UNO_PAGE_HDRDYNAMIC), SC_WID_UNO_HEADERSET,&::getBooleanCppuType(),                       0, 0 },
227         {MAP_CHAR_LEN(SC_UNO_PAGE_HDRHEIGHT),   SC_WID_UNO_HEADERSET,&::getCppuType((const sal_Int32*)0),           0, 0 },
228         {MAP_CHAR_LEN(SC_UNO_PAGE_HDRDYNAMIC),  SC_WID_UNO_HEADERSET,&::getBooleanCppuType(),                       0, 0 },
229         {MAP_CHAR_LEN(SC_UNO_PAGE_HDRON),       SC_WID_UNO_HEADERSET,&::getBooleanCppuType(),                       0, 0 },
230         {MAP_CHAR_LEN(SC_UNO_PAGE_HDRSHARED),   SC_WID_UNO_HEADERSET,&::getBooleanCppuType(),                       0, 0 },
231         {MAP_CHAR_LEN(SC_UNO_PAGE_HDRLEFTBOR),  SC_WID_UNO_HEADERSET,&::getCppuType((const table::BorderLine*)0),   0, 0 },
232         {MAP_CHAR_LEN(SC_UNO_PAGE_HDRLEFTBDIS), SC_WID_UNO_HEADERSET,&::getCppuType((const sal_Int32*)0),           0, 0 },
233         {MAP_CHAR_LEN(SC_UNO_PAGE_HDRLEFTMAR),  SC_WID_UNO_HEADERSET,&::getCppuType((const sal_Int32*)0),           0, 0 },
234         {MAP_CHAR_LEN(OLD_UNO_PAGE_HDRON),      SC_WID_UNO_HEADERSET,&::getBooleanCppuType(),                       0, 0 },
235         {MAP_CHAR_LEN(SC_UNO_PAGE_HDRRIGHTBOR), SC_WID_UNO_HEADERSET,&::getCppuType((const table::BorderLine*)0),   0, 0 },
236         {MAP_CHAR_LEN(SC_UNO_PAGE_HDRRIGHTBDIS),SC_WID_UNO_HEADERSET,&::getCppuType((const sal_Int32*)0),           0, 0 },
237         {MAP_CHAR_LEN(SC_UNO_PAGE_HDRRIGHTMAR), SC_WID_UNO_HEADERSET,&::getCppuType((const sal_Int32*)0),           0, 0 },
238         {MAP_CHAR_LEN(SC_UNO_PAGE_HDRSHADOW),   SC_WID_UNO_HEADERSET,&::getCppuType((const table::ShadowFormat*)0), 0, 0 },
239         {MAP_CHAR_LEN(OLD_UNO_PAGE_HDRSHARED),  SC_WID_UNO_HEADERSET,&::getBooleanCppuType(),                       0, 0 },
240         {MAP_CHAR_LEN(SC_UNO_PAGE_HDRTOPBOR),   SC_WID_UNO_HEADERSET,&::getCppuType((const table::BorderLine*)0),   0, 0 },
241         {MAP_CHAR_LEN(SC_UNO_PAGE_HDRTOPBDIS),  SC_WID_UNO_HEADERSET,&::getCppuType((const sal_Int32*)0),           0, 0 },
242 //
243         {MAP_CHAR_LEN(SC_UNO_PAGE_HEIGHT),      ATTR_PAGE_SIZE,     &::getCppuType((const sal_Int32*)0),            0, MID_SIZE_HEIGHT | CONVERT_TWIPS },
244         {MAP_CHAR_LEN(OLD_UNO_PAGE_BACKTRANS),  ATTR_BACKGROUND,    &::getBooleanCppuType(),            0, MID_GRAPHIC_TRANSPARENT },
245         {MAP_CHAR_LEN(SC_UNO_PAGE_LANDSCAPE),   ATTR_PAGE,          &::getBooleanCppuType(),            0, MID_PAGE_ORIENTATION },
246         {MAP_CHAR_LEN(SC_UNO_PAGE_LEFTBORDER),  ATTR_BORDER,        &::getCppuType((const table::BorderLine*)0),        0, LEFT_BORDER | CONVERT_TWIPS },
247         {MAP_CHAR_LEN(SC_UNO_PAGE_LEFTBRDDIST), ATTR_BORDER,        &::getCppuType((const sal_Int32*)0),    0, LEFT_BORDER_DISTANCE | CONVERT_TWIPS },
248         {MAP_CHAR_LEN(SC_UNO_PAGE_LEFTMARGIN),  ATTR_LRSPACE,       &::getCppuType((const sal_Int32*)0),            0, MID_L_MARGIN | CONVERT_TWIPS },
249         {MAP_CHAR_LEN(SC_UNO_PAGE_LEFTFTRCONT), ATTR_PAGE_FOOTERLEFT,&::getCppuType((const uno::Reference< sheet::XHeaderFooterContent >*)0), 0, 0 },
250         {MAP_CHAR_LEN(SC_UNO_PAGE_LEFTHDRCONT), ATTR_PAGE_HEADERLEFT,&::getCppuType((const uno::Reference< sheet::XHeaderFooterContent >*)0), 0, 0 },
251         {MAP_CHAR_LEN(SC_UNO_PAGE_NUMBERTYPE),  ATTR_PAGE,          &::getCppuType((const sal_Int16*)0),            0, MID_PAGE_NUMTYPE },
252         {MAP_CHAR_LEN(SC_UNO_PAGE_SCALEVAL),    ATTR_PAGE_SCALE,    &::getCppuType((const sal_Int16*)0),            0, 0 },
253         {MAP_CHAR_LEN(SC_UNO_PAGE_SYTLELAYOUT), ATTR_PAGE,          &::getCppuType((const style::PageStyleLayout*)0),   0, MID_PAGE_LAYOUT },
254         {MAP_CHAR_LEN(SC_UNO_PAGE_PRINTANNOT),  ATTR_PAGE_NOTES,    &::getBooleanCppuType(),            0, 0 },
255         {MAP_CHAR_LEN(SC_UNO_PAGE_PRINTCHARTS), ATTR_PAGE_CHARTS,   &::getBooleanCppuType(),            0, 0 },
256         {MAP_CHAR_LEN(SC_UNO_PAGE_PRINTDOWN),   ATTR_PAGE_TOPDOWN,  &::getBooleanCppuType(),            0, 0 },
257         {MAP_CHAR_LEN(SC_UNO_PAGE_PRINTDRAW),   ATTR_PAGE_DRAWINGS, &::getBooleanCppuType(),            0, 0 },
258         {MAP_CHAR_LEN(SC_UNO_PAGE_PRINTFORMUL), ATTR_PAGE_FORMULAS, &::getBooleanCppuType(),            0, 0 },
259         {MAP_CHAR_LEN(SC_UNO_PAGE_PRINTGRID),   ATTR_PAGE_GRID,     &::getBooleanCppuType(),            0, 0 },
260         {MAP_CHAR_LEN(SC_UNO_PAGE_PRINTHEADER), ATTR_PAGE_HEADERS,  &::getBooleanCppuType(),            0, 0 },
261         {MAP_CHAR_LEN(SC_UNO_PAGE_PRINTOBJS),   ATTR_PAGE_OBJECTS,  &::getBooleanCppuType(),            0, 0 },
262         {MAP_CHAR_LEN(SC_UNO_PAGE_PRINTZERO),   ATTR_PAGE_NULLVALS, &::getBooleanCppuType(),            0, 0 },
263         {MAP_CHAR_LEN(SC_UNO_PAGE_PAPERTRAY),   ATTR_PAGE_PAPERBIN, &::getCppuType((const ::rtl::OUString*)0),      0, 0 },
264         {MAP_CHAR_LEN(SC_UNO_PAGE_RIGHTBORDER), ATTR_BORDER,        &::getCppuType((const table::BorderLine*)0),        0, RIGHT_BORDER | CONVERT_TWIPS },
265         {MAP_CHAR_LEN(SC_UNO_PAGE_RIGHTBRDDIST),ATTR_BORDER,        &::getCppuType((const sal_Int32*)0),    0, RIGHT_BORDER_DISTANCE | CONVERT_TWIPS },
266         {MAP_CHAR_LEN(SC_UNO_PAGE_RIGHTMARGIN), ATTR_LRSPACE,       &::getCppuType((const sal_Int32*)0),            0, MID_R_MARGIN | CONVERT_TWIPS },
267         {MAP_CHAR_LEN(SC_UNO_PAGE_RIGHTFTRCON), ATTR_PAGE_FOOTERRIGHT,&::getCppuType((const uno::Reference< sheet::XHeaderFooterContent >*)0), 0, 0 },
268         {MAP_CHAR_LEN(SC_UNO_PAGE_RIGHTHDRCON), ATTR_PAGE_HEADERRIGHT,&::getCppuType((const uno::Reference< sheet::XHeaderFooterContent >*)0), 0, 0 },
269         {MAP_CHAR_LEN(SC_UNO_PAGE_SCALETOPAG),  ATTR_PAGE_SCALETOPAGES,&::getCppuType((const sal_Int16*)0),     0, 0 },
270         {MAP_CHAR_LEN(SC_UNO_PAGE_SCALETOX),    ATTR_PAGE_SCALETO,  &::getCppuType((const sal_Int16*)0),        0, 0 },
271         {MAP_CHAR_LEN(SC_UNO_PAGE_SCALETOY),    ATTR_PAGE_SCALETO,  &::getCppuType((const sal_Int16*)0),        0, 0 },
272         {MAP_CHAR_LEN(SC_UNO_PAGE_SHADOWFORM),  ATTR_SHADOW,        &::getCppuType((const table::ShadowFormat*)0),  0, 0 | CONVERT_TWIPS },
273         {MAP_CHAR_LEN(SC_UNO_PAGE_SIZE),        ATTR_PAGE_SIZE,     &::getCppuType((const awt::Size*)0),            0, MID_SIZE_SIZE | CONVERT_TWIPS },
274         {MAP_CHAR_LEN(SC_UNO_PAGE_TOPBORDER),   ATTR_BORDER,        &::getCppuType((const table::BorderLine*)0),        0, TOP_BORDER | CONVERT_TWIPS },
275         {MAP_CHAR_LEN(SC_UNO_PAGE_TOPBRDDIST),  ATTR_BORDER,        &::getCppuType((const sal_Int32*)0),    0, TOP_BORDER_DISTANCE | CONVERT_TWIPS },
276         {MAP_CHAR_LEN(SC_UNO_PAGE_TOPMARGIN),   ATTR_ULSPACE,       &::getCppuType((const sal_Int32*)0),            0, MID_UP_MARGIN | CONVERT_TWIPS },
277         {MAP_CHAR_LEN(OLD_UNO_PAGE_FTRBACKTRAN),SC_WID_UNO_FOOTERSET,&::getBooleanCppuType(),                       0, 0 },
278         {MAP_CHAR_LEN(OLD_UNO_PAGE_HDRBACKTRAN),SC_WID_UNO_HEADERSET,&::getBooleanCppuType(),                       0, 0 },
279         {MAP_CHAR_LEN(SC_UNONAME_USERDEF),      ATTR_USERDEF,       &getCppuType((uno::Reference<container::XNameContainer>*)0), 0, 0 },
280         {MAP_CHAR_LEN(SC_UNO_PAGE_WIDTH),       ATTR_PAGE_SIZE,     &::getCppuType((const sal_Int32*)0),            0, MID_SIZE_WIDTH | CONVERT_TWIPS },
281         {MAP_CHAR_LEN(SC_UNONAME_WRITING),      ATTR_WRITINGDIR,    &getCppuType((sal_Int16*)0),            0, 0 },
282         {0,0,0,0,0,0}
283     };
284     static SfxItemPropertySet aPageStyleSet_Impl( aPageStyleMap_Impl );
285     return &aPageStyleSet_Impl;
286 }
287 
288 //  Map mit Inhalten des Header-Item-Sets
289 
lcl_GetHeaderStyleMap()290 const SfxItemPropertyMap* lcl_GetHeaderStyleMap()
291 {
292     static SfxItemPropertyMapEntry aHeaderStyleMap_Impl[] =
293     {
294         {MAP_CHAR_LEN(SC_UNO_PAGE_HDRBACKCOL),  ATTR_BACKGROUND,    &::getCppuType((const sal_Int32*)0),            0, MID_BACK_COLOR },
295         {MAP_CHAR_LEN(SC_UNO_PAGE_HDRGRFFILT),  ATTR_BACKGROUND,    &::getCppuType((const ::rtl::OUString*)0),          0, MID_GRAPHIC_FILTER },
296         {MAP_CHAR_LEN(SC_UNO_PAGE_HDRGRFLOC),   ATTR_BACKGROUND,    &::getCppuType((const style::GraphicLocation*)0),   0, MID_GRAPHIC_POSITION },
297         {MAP_CHAR_LEN(SC_UNO_PAGE_HDRGRFURL),   ATTR_BACKGROUND,    &::getCppuType((const ::rtl::OUString*)0),          0, MID_GRAPHIC_URL },
298         {MAP_CHAR_LEN(SC_UNO_PAGE_HDRBACKTRAN), ATTR_BACKGROUND,    &::getBooleanCppuType(),            0, MID_GRAPHIC_TRANSPARENT },
299         {MAP_CHAR_LEN(OLD_UNO_PAGE_HDRBACKCOL), ATTR_BACKGROUND,    &::getCppuType((const sal_Int32*)0),            0, MID_BACK_COLOR },
300         {MAP_CHAR_LEN(SC_UNO_PAGE_HDRBODYDIST), ATTR_ULSPACE,       &::getCppuType((const sal_Int32*)0),            0, MID_LO_MARGIN | CONVERT_TWIPS },
301         {MAP_CHAR_LEN(SC_UNO_PAGE_HDRBRDDIST),  ATTR_BORDER,        &::getCppuType((const sal_Int32*)0),    0, BORDER_DISTANCE | CONVERT_TWIPS },
302         {MAP_CHAR_LEN(SC_UNO_PAGE_HDRBOTTBOR),  ATTR_BORDER,        &::getCppuType((const table::BorderLine*)0),        0, BOTTOM_BORDER | CONVERT_TWIPS },
303         {MAP_CHAR_LEN(SC_UNO_PAGE_HDRBOTTBDIS), ATTR_BORDER,        &::getCppuType((const sal_Int32*)0),    0, BOTTOM_BORDER_DISTANCE | CONVERT_TWIPS },
304         {MAP_CHAR_LEN(OLD_UNO_PAGE_HDRDYNAMIC), ATTR_PAGE_DYNAMIC,  &::getBooleanCppuType(),            0, 0 },
305         {MAP_CHAR_LEN(SC_UNO_PAGE_HDRHEIGHT),   ATTR_PAGE_SIZE,     &::getCppuType((const sal_Int32*)0),            0, MID_SIZE_HEIGHT | CONVERT_TWIPS },
306         {MAP_CHAR_LEN(SC_UNO_PAGE_HDRDYNAMIC),  ATTR_PAGE_DYNAMIC,  &::getBooleanCppuType(),            0, 0 },
307         {MAP_CHAR_LEN(SC_UNO_PAGE_HDRON),       ATTR_PAGE_ON,       &::getBooleanCppuType(),            0, 0 },
308         {MAP_CHAR_LEN(SC_UNO_PAGE_HDRSHARED),   ATTR_PAGE_SHARED,   &::getBooleanCppuType(),            0, 0 },
309         {MAP_CHAR_LEN(SC_UNO_PAGE_HDRLEFTBOR),  ATTR_BORDER,        &::getCppuType((const table::BorderLine*)0),        0, LEFT_BORDER | CONVERT_TWIPS },
310         {MAP_CHAR_LEN(SC_UNO_PAGE_HDRLEFTBDIS), ATTR_BORDER,        &::getCppuType((const sal_Int32*)0),    0, LEFT_BORDER_DISTANCE | CONVERT_TWIPS },
311         {MAP_CHAR_LEN(SC_UNO_PAGE_HDRLEFTMAR),  ATTR_LRSPACE,       &::getCppuType((const sal_Int32*)0),            0, MID_L_MARGIN | CONVERT_TWIPS },
312         {MAP_CHAR_LEN(OLD_UNO_PAGE_HDRON),      ATTR_PAGE_ON,       &::getBooleanCppuType(),            0, 0 },
313         {MAP_CHAR_LEN(SC_UNO_PAGE_HDRRIGHTBOR), ATTR_BORDER,        &::getCppuType((const table::BorderLine*)0),        0, RIGHT_BORDER | CONVERT_TWIPS },
314         {MAP_CHAR_LEN(SC_UNO_PAGE_HDRRIGHTBDIS),ATTR_BORDER,        &::getCppuType((const sal_Int32*)0),    0, RIGHT_BORDER_DISTANCE | CONVERT_TWIPS },
315         {MAP_CHAR_LEN(SC_UNO_PAGE_HDRRIGHTMAR), ATTR_LRSPACE,       &::getCppuType((const sal_Int32*)0),            0, MID_R_MARGIN | CONVERT_TWIPS },
316         {MAP_CHAR_LEN(SC_UNO_PAGE_HDRSHADOW),   ATTR_SHADOW,        &::getCppuType((const table::ShadowFormat*)0),  0, 0 | CONVERT_TWIPS },
317         {MAP_CHAR_LEN(OLD_UNO_PAGE_HDRSHARED),  ATTR_PAGE_SHARED,   &::getBooleanCppuType(),            0, 0 },
318         {MAP_CHAR_LEN(SC_UNO_PAGE_HDRTOPBOR),   ATTR_BORDER,        &::getCppuType((const table::BorderLine*)0),        0, TOP_BORDER | CONVERT_TWIPS },
319         {MAP_CHAR_LEN(SC_UNO_PAGE_HDRTOPBDIS),  ATTR_BORDER,        &::getCppuType((const sal_Int32*)0),    0, TOP_BORDER_DISTANCE | CONVERT_TWIPS },
320         {MAP_CHAR_LEN(OLD_UNO_PAGE_HDRBACKTRAN),ATTR_BACKGROUND,    &::getBooleanCppuType(),            0, MID_GRAPHIC_TRANSPARENT },
321         {0,0,0,0,0,0}
322     };
323     static SfxItemPropertyMap aHeaderStyleMap( aHeaderStyleMap_Impl );
324     return &aHeaderStyleMap;
325 }
326 
327 //  Map mit Inhalten des Footer-Item-Sets
328 
lcl_GetFooterStyleMap()329 const SfxItemPropertyMap* lcl_GetFooterStyleMap()
330 {
331     static SfxItemPropertyMapEntry aFooterStyleMap_Impl[] =
332     {
333         {MAP_CHAR_LEN(SC_UNO_PAGE_FTRBACKCOL),  ATTR_BACKGROUND,    &::getCppuType((const sal_Int32*)0),            0, MID_BACK_COLOR },
334         {MAP_CHAR_LEN(SC_UNO_PAGE_FTRGRFFILT),  ATTR_BACKGROUND,    &::getCppuType((const ::rtl::OUString*)0),          0, MID_GRAPHIC_FILTER },
335         {MAP_CHAR_LEN(SC_UNO_PAGE_FTRGRFLOC),   ATTR_BACKGROUND,    &::getCppuType((const style::GraphicLocation*)0),   0, MID_GRAPHIC_POSITION },
336         {MAP_CHAR_LEN(SC_UNO_PAGE_FTRGRFURL),   ATTR_BACKGROUND,    &::getCppuType((const ::rtl::OUString*)0),          0, MID_GRAPHIC_URL },
337         {MAP_CHAR_LEN(SC_UNO_PAGE_FTRBACKTRAN), ATTR_BACKGROUND,    &::getBooleanCppuType(),            0, MID_GRAPHIC_TRANSPARENT },
338         {MAP_CHAR_LEN(OLD_UNO_PAGE_FTRBACKCOL), ATTR_BACKGROUND,    &::getCppuType((const sal_Int32*)0),            0, MID_BACK_COLOR },
339         {MAP_CHAR_LEN(SC_UNO_PAGE_FTRBODYDIST), ATTR_ULSPACE,       &::getCppuType((const sal_Int32*)0),            0, MID_UP_MARGIN | CONVERT_TWIPS },
340         {MAP_CHAR_LEN(SC_UNO_PAGE_FTRBRDDIST),  ATTR_BORDER,        &::getCppuType((const sal_Int32*)0),    0, BORDER_DISTANCE | CONVERT_TWIPS },
341         {MAP_CHAR_LEN(SC_UNO_PAGE_FTRBOTTBOR),  ATTR_BORDER,        &::getCppuType((const table::BorderLine*)0),        0, BOTTOM_BORDER | CONVERT_TWIPS },
342         {MAP_CHAR_LEN(SC_UNO_PAGE_FTRBOTTBDIS), ATTR_BORDER,        &::getCppuType((const sal_Int32*)0),    0, BOTTOM_BORDER_DISTANCE | CONVERT_TWIPS },
343         {MAP_CHAR_LEN(OLD_UNO_PAGE_FTRDYNAMIC), ATTR_PAGE_DYNAMIC,  &::getBooleanCppuType(),            0, 0 },
344         {MAP_CHAR_LEN(SC_UNO_PAGE_FTRHEIGHT),   ATTR_PAGE_SIZE,     &::getCppuType((const sal_Int32*)0),            0, MID_SIZE_HEIGHT | CONVERT_TWIPS },
345         {MAP_CHAR_LEN(SC_UNO_PAGE_FTRDYNAMIC),  ATTR_PAGE_DYNAMIC,  &::getBooleanCppuType(),            0, 0 },
346         {MAP_CHAR_LEN(SC_UNO_PAGE_FTRON),       ATTR_PAGE_ON,       &::getBooleanCppuType(),            0, 0 },
347         {MAP_CHAR_LEN(SC_UNO_PAGE_FTRSHARED),   ATTR_PAGE_SHARED,   &::getBooleanCppuType(),            0, 0 },
348         {MAP_CHAR_LEN(SC_UNO_PAGE_FTRLEFTBOR),  ATTR_BORDER,        &::getCppuType((const table::BorderLine*)0),        0, LEFT_BORDER | CONVERT_TWIPS },
349         {MAP_CHAR_LEN(SC_UNO_PAGE_FTRLEFTBDIS), ATTR_BORDER,        &::getCppuType((const sal_Int32*)0),    0, LEFT_BORDER_DISTANCE | CONVERT_TWIPS },
350         {MAP_CHAR_LEN(SC_UNO_PAGE_FTRLEFTMAR),  ATTR_LRSPACE,       &::getCppuType((const sal_Int32*)0),            0, MID_L_MARGIN | CONVERT_TWIPS },
351         {MAP_CHAR_LEN(OLD_UNO_PAGE_FTRON),      ATTR_PAGE_ON,       &::getBooleanCppuType(),            0, 0 },
352         {MAP_CHAR_LEN(SC_UNO_PAGE_FTRRIGHTBOR), ATTR_BORDER,        &::getCppuType((const table::BorderLine*)0),        0, RIGHT_BORDER | CONVERT_TWIPS },
353         {MAP_CHAR_LEN(SC_UNO_PAGE_FTRRIGHTBDIS),ATTR_BORDER,        &::getCppuType((const sal_Int32*)0),    0, RIGHT_BORDER_DISTANCE | CONVERT_TWIPS },
354         {MAP_CHAR_LEN(SC_UNO_PAGE_FTRRIGHTMAR), ATTR_LRSPACE,       &::getCppuType((const sal_Int32*)0),            0, MID_R_MARGIN | CONVERT_TWIPS },
355         {MAP_CHAR_LEN(SC_UNO_PAGE_FTRSHADOW),   ATTR_SHADOW,        &::getCppuType((const table::ShadowFormat*)0),  0, 0 | CONVERT_TWIPS },
356         {MAP_CHAR_LEN(OLD_UNO_PAGE_FTRSHARED),  ATTR_PAGE_SHARED,   &::getBooleanCppuType(),            0, 0 },
357         {MAP_CHAR_LEN(SC_UNO_PAGE_FTRTOPBOR),   ATTR_BORDER,        &::getCppuType((const table::BorderLine*)0),        0, TOP_BORDER | CONVERT_TWIPS },
358         {MAP_CHAR_LEN(SC_UNO_PAGE_FTRTOPBDIS),  ATTR_BORDER,        &::getCppuType((const sal_Int32*)0),    0, TOP_BORDER_DISTANCE | CONVERT_TWIPS },
359         {MAP_CHAR_LEN(OLD_UNO_PAGE_FTRBACKTRAN),ATTR_BACKGROUND,    &::getBooleanCppuType(),            0, MID_GRAPHIC_TRANSPARENT },
360         {0,0,0,0,0,0}
361     };
362     static SfxItemPropertyMap aFooterStyleMap( aFooterStyleMap_Impl );
363     return &aFooterStyleMap;
364 }
365 
366 
367 //------------------------------------------------------------------------
368 
369 //  Index-Access auf die Style-Typen: 0 = Cell, 1 = Page
370 
371 #define SC_STYLE_FAMILY_COUNT 2
372 
373 #define SC_FAMILYNAME_CELL  "CellStyles"
374 #define SC_FAMILYNAME_PAGE  "PageStyles"
375 
376 static sal_uInt16 aStyleFamilyTypes[SC_STYLE_FAMILY_COUNT] = { SFX_STYLE_FAMILY_PARA, SFX_STYLE_FAMILY_PAGE };
377 
378 //------------------------------------------------------------------------
379 
380 //! diese Funktionen in einen allgemeinen Header verschieben
TwipsToHMM(long nTwips)381 inline long TwipsToHMM(long nTwips) { return (nTwips * 127 + 36) / 72; }
HMMToTwips(long nHMM)382 inline long HMMToTwips(long nHMM)   { return (nHMM * 72 + 63) / 127; }
383 
384 //------------------------------------------------------------------------
385 
386 #define SCSTYLE_SERVICE         "com.sun.star.style.Style"
387 #define SCCELLSTYLE_SERVICE     "com.sun.star.style.CellStyle"
388 #define SCPAGESTYLE_SERVICE     "com.sun.star.style.PageStyle"
389 
390 SC_SIMPLE_SERVICE_INFO( ScStyleFamiliesObj, "ScStyleFamiliesObj", "com.sun.star.style.StyleFamilies" )
391 SC_SIMPLE_SERVICE_INFO( ScStyleFamilyObj, "ScStyleFamilyObj", "com.sun.star.style.StyleFamily" )
392 
393 //------------------------------------------------------------------------
394 
395 #define SC_PAPERBIN_DEFAULTNAME     "[From printer settings]"
396 
397 //------------------------------------------------------------------------
398 
399 //  conversion programmatic <-> display (visible) name
400 //  currently, the core always has the visible names
401 //  the api is required to use programmatic names for default styles
402 //  these programmatic names must never change!
403 
404 #define SC_STYLE_PROG_STANDARD      "Default"
405 #define SC_STYLE_PROG_RESULT        "Result"
406 #define SC_STYLE_PROG_RESULT1       "Result2"
407 #define SC_STYLE_PROG_HEADLINE      "Heading"
408 #define SC_STYLE_PROG_HEADLINE1     "Heading1"
409 #define SC_STYLE_PROG_REPORT        "Report"
410 
411 struct ScDisplayNameMap
412 {
413     String  aDispName;
414     String  aProgName;
415 };
416 
lcl_GetStyleNameMap(sal_uInt16 nType)417 const ScDisplayNameMap* lcl_GetStyleNameMap( sal_uInt16 nType )
418 {
419     if ( nType == SFX_STYLE_FAMILY_PARA )
420     {
421         static sal_Bool bCellMapFilled = sal_False;
422         static ScDisplayNameMap aCellMap[6];
423         if ( !bCellMapFilled )
424         {
425             aCellMap[0].aDispName = ScGlobal::GetRscString( STR_STYLENAME_STANDARD );
426             aCellMap[0].aProgName = String::CreateFromAscii( SC_STYLE_PROG_STANDARD );
427 
428             aCellMap[1].aDispName = ScGlobal::GetRscString( STR_STYLENAME_RESULT );
429             aCellMap[1].aProgName = String::CreateFromAscii( SC_STYLE_PROG_RESULT );
430 
431             aCellMap[2].aDispName = ScGlobal::GetRscString( STR_STYLENAME_RESULT1 );
432             aCellMap[2].aProgName = String::CreateFromAscii( SC_STYLE_PROG_RESULT1 );
433 
434             aCellMap[3].aDispName = ScGlobal::GetRscString( STR_STYLENAME_HEADLINE );
435             aCellMap[3].aProgName = String::CreateFromAscii( SC_STYLE_PROG_HEADLINE );
436 
437             aCellMap[4].aDispName = ScGlobal::GetRscString( STR_STYLENAME_HEADLINE1 );
438             aCellMap[4].aProgName = String::CreateFromAscii( SC_STYLE_PROG_HEADLINE1 );
439 
440             //  last entry remains empty
441 
442             bCellMapFilled = sal_True;
443         }
444         return aCellMap;
445     }
446     else if ( nType == SFX_STYLE_FAMILY_PAGE )
447     {
448         static sal_Bool bPageMapFilled = sal_False;
449         static ScDisplayNameMap aPageMap[3];
450         if ( !bPageMapFilled )
451         {
452             aPageMap[0].aDispName = ScGlobal::GetRscString( STR_STYLENAME_STANDARD );
453             aPageMap[0].aProgName = String::CreateFromAscii( SC_STYLE_PROG_STANDARD );
454 
455             aPageMap[1].aDispName = ScGlobal::GetRscString( STR_STYLENAME_REPORT );
456             aPageMap[1].aProgName = String::CreateFromAscii( SC_STYLE_PROG_REPORT );
457 
458             //  last entry remains empty
459 
460             bPageMapFilled = sal_True;
461         }
462         return aPageMap;
463     }
464     DBG_ERROR("invalid family");
465     return NULL;
466 }
467 
468 //  programmatic name suffix for display names that match other programmatic names
469 //  is " (user)" including a space
470 
471 #define SC_SUFFIX_USER      " (user)"
472 #define SC_SUFFIX_USER_LEN  7
473 
lcl_EndsWithUser(const String & rString)474 sal_Bool lcl_EndsWithUser( const String& rString )
475 {
476     const sal_Unicode *pChar = rString.GetBuffer();
477     xub_StrLen nLen = rString.Len();
478     return nLen >= SC_SUFFIX_USER_LEN &&
479            pChar[nLen-7] == ' ' &&
480            pChar[nLen-6] == '(' &&
481            pChar[nLen-5] == 'u' &&
482            pChar[nLen-4] == 's' &&
483            pChar[nLen-3] == 'e' &&
484            pChar[nLen-2] == 'r' &&
485            pChar[nLen-1] == ')';
486 }
487 
488 // static
DisplayToProgrammaticName(const String & rDispName,sal_uInt16 nType)489 String ScStyleNameConversion::DisplayToProgrammaticName( const String& rDispName, sal_uInt16 nType )
490 {
491     sal_Bool bDisplayIsProgrammatic = sal_False;
492 
493     const ScDisplayNameMap* pNames = lcl_GetStyleNameMap( nType );
494     if (pNames)
495     {
496         do
497         {
498             if (pNames->aDispName == rDispName)
499                 return pNames->aProgName;
500             else if (pNames->aProgName == rDispName)
501                 bDisplayIsProgrammatic = sal_True;          // display name matches any programmatic name
502         }
503         while( (++pNames)->aDispName.Len() );
504     }
505 
506     if ( bDisplayIsProgrammatic || lcl_EndsWithUser( rDispName ) )
507     {
508         //  add the (user) suffix if the display name matches any style's programmatic name
509         //  or if it already contains the suffix
510 
511         String aRet(rDispName);
512         aRet.AppendAscii( RTL_CONSTASCII_STRINGPARAM( SC_SUFFIX_USER ) );
513         return aRet;
514     }
515 
516     return rDispName;
517 }
518 
519 // static
ProgrammaticToDisplayName(const String & rProgName,sal_uInt16 nType)520 String ScStyleNameConversion::ProgrammaticToDisplayName( const String& rProgName, sal_uInt16 nType )
521 {
522     if ( lcl_EndsWithUser( rProgName ) )
523     {
524         //  remove the (user) suffix, don't compare to map entries
525         return rProgName.Copy( 0, rProgName.Len() - SC_SUFFIX_USER_LEN );
526     }
527 
528     const ScDisplayNameMap* pNames = lcl_GetStyleNameMap( nType );
529     if (pNames)
530     {
531         do
532         {
533             if (pNames->aProgName == rProgName)
534                 return pNames->aDispName;
535         }
536         while( (++pNames)->aDispName.Len() );
537     }
538     return rProgName;
539 }
540 
541 //------------------------------------------------------------------------
542 
lcl_AnyTabProtected(ScDocument & rDoc)543 sal_Bool lcl_AnyTabProtected( ScDocument& rDoc )
544 {
545     SCTAB nTabCount = rDoc.GetTableCount();
546     for (SCTAB i=0; i<nTabCount; i++)
547         if (rDoc.IsTabProtected(i))
548             return sal_True;
549     return sal_False;
550 }
551 
552 //------------------------------------------------------------------------
553 
ScStyleFamiliesObj(ScDocShell * pDocSh)554 ScStyleFamiliesObj::ScStyleFamiliesObj(ScDocShell* pDocSh) :
555     pDocShell( pDocSh )
556 {
557     pDocShell->GetDocument()->AddUnoObject(*this);
558 }
559 
~ScStyleFamiliesObj()560 ScStyleFamiliesObj::~ScStyleFamiliesObj()
561 {
562     if (pDocShell)
563         pDocShell->GetDocument()->RemoveUnoObject(*this);
564 }
565 
Notify(SfxBroadcaster &,const SfxHint & rHint)566 void ScStyleFamiliesObj::Notify( SfxBroadcaster&, const SfxHint& rHint )
567 {
568     //  Referenz-Update interessiert hier nicht
569 
570     if ( rHint.ISA( SfxSimpleHint ) &&
571             ((const SfxSimpleHint&)rHint).GetId() == SFX_HINT_DYING )
572     {
573         pDocShell = NULL;       // ungueltig geworden
574     }
575 }
576 
577 // XStyleFamilies
578 
GetObjectByType_Impl(sal_uInt16 nType) const579 ScStyleFamilyObj*ScStyleFamiliesObj::GetObjectByType_Impl(sal_uInt16 nType) const
580 {
581     if ( pDocShell )
582     {
583         if ( nType == SFX_STYLE_FAMILY_PARA )
584             return new ScStyleFamilyObj( pDocShell, SFX_STYLE_FAMILY_PARA );
585         else if ( nType == SFX_STYLE_FAMILY_PAGE )
586             return new ScStyleFamilyObj( pDocShell, SFX_STYLE_FAMILY_PAGE );
587     }
588     DBG_ERROR("getStyleFamilyByType: keine DocShell oder falscher Typ");
589     return NULL;
590 }
591 
GetObjectByIndex_Impl(sal_uInt32 nIndex) const592 ScStyleFamilyObj* ScStyleFamiliesObj::GetObjectByIndex_Impl(sal_uInt32 nIndex) const
593 {
594     if ( nIndex < SC_STYLE_FAMILY_COUNT )
595         return GetObjectByType_Impl(aStyleFamilyTypes[nIndex]);
596 
597     return NULL;    // ungueltiger Index
598 }
599 
GetObjectByName_Impl(const rtl::OUString & aName) const600 ScStyleFamilyObj* ScStyleFamiliesObj::GetObjectByName_Impl(const rtl::OUString& aName) const
601 {
602     if ( pDocShell )
603     {
604         String aNameStr( aName );
605         if ( aNameStr.EqualsAscii( SC_FAMILYNAME_CELL ) )
606             return new ScStyleFamilyObj( pDocShell, SFX_STYLE_FAMILY_PARA );
607         else if ( aNameStr.EqualsAscii( SC_FAMILYNAME_PAGE ) )
608             return new ScStyleFamilyObj( pDocShell, SFX_STYLE_FAMILY_PAGE );
609     }
610     // no assertion - called directly from getByName
611     return NULL;
612 }
613 
614 // container::XIndexAccess
615 
getCount()616 sal_Int32 SAL_CALL ScStyleFamiliesObj::getCount()
617 {
618     return SC_STYLE_FAMILY_COUNT;
619 }
620 
getByIndex(sal_Int32 nIndex)621 uno::Any SAL_CALL ScStyleFamiliesObj::getByIndex( sal_Int32 nIndex )
622 {
623     ScUnoGuard aGuard;
624     uno::Reference< container::XNameContainer >  xFamily(GetObjectByIndex_Impl(nIndex));
625     if (xFamily.is())
626         return uno::makeAny(xFamily);
627     else
628         throw lang::IndexOutOfBoundsException();
629 //    return uno::Any();
630 }
631 
getElementType()632 uno::Type SAL_CALL ScStyleFamiliesObj::getElementType()
633 {
634     ScUnoGuard aGuard;
635     return ::getCppuType((const uno::Reference< container::XNameContainer >*)0);    // muss zu getByIndex passen
636 }
637 
hasElements()638 sal_Bool SAL_CALL ScStyleFamiliesObj::hasElements()
639 {
640     ScUnoGuard aGuard;
641     return ( getCount() != 0 );
642 }
643 
644 // container::XNameAccess
645 
getByName(const rtl::OUString & aName)646 uno::Any SAL_CALL ScStyleFamiliesObj::getByName( const rtl::OUString& aName )
647 {
648     ScUnoGuard aGuard;
649     uno::Reference< container::XNameContainer >  xFamily(GetObjectByName_Impl(aName));
650     if (xFamily.is())
651         return uno::makeAny(xFamily);
652     else
653         throw container::NoSuchElementException();
654 //    return uno::Any();
655 }
656 
getElementNames()657 uno::Sequence<rtl::OUString> SAL_CALL ScStyleFamiliesObj::getElementNames()
658 {
659     ScUnoGuard aGuard;
660     uno::Sequence<rtl::OUString> aNames(SC_STYLE_FAMILY_COUNT);
661     rtl::OUString* pNames = aNames.getArray();
662     pNames[0] = rtl::OUString::createFromAscii( SC_FAMILYNAME_CELL );
663     pNames[1] = rtl::OUString::createFromAscii( SC_FAMILYNAME_PAGE );
664     return aNames;
665 }
666 
hasByName(const rtl::OUString & aName)667 sal_Bool SAL_CALL ScStyleFamiliesObj::hasByName( const rtl::OUString& aName )
668 {
669     ScUnoGuard aGuard;
670     String aNameStr( aName );
671     return ( aNameStr.EqualsAscii( SC_FAMILYNAME_CELL ) || aNameStr.EqualsAscii( SC_FAMILYNAME_PAGE ) );
672 }
673 
674 // style::XStyleLoader
675 
loadStylesFromURL(const rtl::OUString & aURL,const uno::Sequence<beans::PropertyValue> & aOptions)676 void SAL_CALL ScStyleFamiliesObj::loadStylesFromURL( const rtl::OUString& aURL,
677                         const uno::Sequence<beans::PropertyValue>& aOptions )
678 {
679     //! use aOptions (like Writer)
680     //! set flag to disable filter option dialogs when importing
681 
682     String aFilter;     // empty - detect
683     String aFiltOpt;
684     ScDocumentLoader aLoader( aURL, aFilter, aFiltOpt );
685 
686     ScDocShell* pSource = aLoader.GetDocShell();
687     if ( pSource && pDocShell )
688     {
689         //  collect options
690 
691         sal_Bool bLoadReplace = sal_True;           // defaults
692         sal_Bool bLoadCellStyles = sal_True;
693         sal_Bool bLoadPageStyles = sal_True;
694 
695         const beans::PropertyValue* pPropArray = aOptions.getConstArray();
696         long nPropCount = aOptions.getLength();
697         for (long i = 0; i < nPropCount; i++)
698         {
699             const beans::PropertyValue& rProp = pPropArray[i];
700             String aPropName(rProp.Name);
701 
702             if (aPropName.EqualsAscii( SC_UNONAME_OVERWSTL ))
703                 bLoadReplace = ScUnoHelpFunctions::GetBoolFromAny( rProp.Value );
704             else if (aPropName.EqualsAscii( SC_UNONAME_LOADCELL ))
705                 bLoadCellStyles = ScUnoHelpFunctions::GetBoolFromAny( rProp.Value );
706             else if (aPropName.EqualsAscii( SC_UNONAME_LOADPAGE ))
707                 bLoadPageStyles = ScUnoHelpFunctions::GetBoolFromAny( rProp.Value );
708         }
709 
710         pDocShell->LoadStylesArgs( *pSource, bLoadReplace, bLoadCellStyles, bLoadPageStyles );
711         pDocShell->SetDocumentModified();   // paint is inside LoadStyles
712     }
713 }
714 
getStyleLoaderOptions()715 uno::Sequence<beans::PropertyValue> SAL_CALL ScStyleFamiliesObj::getStyleLoaderOptions()
716 {
717     //  return defaults for options (?)
718 
719     uno::Sequence<beans::PropertyValue> aSequence(3);
720     beans::PropertyValue* pArray = aSequence.getArray();
721 
722     pArray[0].Name = rtl::OUString::createFromAscii( SC_UNONAME_OVERWSTL );
723     ScUnoHelpFunctions::SetBoolInAny( pArray[0].Value, sal_True );
724 
725     pArray[1].Name = rtl::OUString::createFromAscii( SC_UNONAME_LOADCELL );
726     ScUnoHelpFunctions::SetBoolInAny( pArray[1].Value, sal_True );
727 
728     pArray[2].Name = rtl::OUString::createFromAscii( SC_UNONAME_LOADPAGE );
729     ScUnoHelpFunctions::SetBoolInAny( pArray[2].Value, sal_True );
730 
731     return aSequence;
732 }
733 
734 //------------------------------------------------------------------------
735 
ScStyleFamilyObj(ScDocShell * pDocSh,SfxStyleFamily eFam)736 ScStyleFamilyObj::ScStyleFamilyObj(ScDocShell* pDocSh, SfxStyleFamily eFam) :
737     pDocShell( pDocSh ),
738     eFamily( eFam )
739 {
740     pDocShell->GetDocument()->AddUnoObject(*this);
741 }
742 
~ScStyleFamilyObj()743 ScStyleFamilyObj::~ScStyleFamilyObj()
744 {
745     if (pDocShell)
746         pDocShell->GetDocument()->RemoveUnoObject(*this);
747 }
748 
Notify(SfxBroadcaster &,const SfxHint & rHint)749 void ScStyleFamilyObj::Notify( SfxBroadcaster&, const SfxHint& rHint )
750 {
751     //  Referenz-Update interessiert hier nicht
752 
753     if ( rHint.ISA( SfxSimpleHint ) &&
754             ((const SfxSimpleHint&)rHint).GetId() == SFX_HINT_DYING )
755     {
756         pDocShell = NULL;       // ungueltig geworden
757     }
758 }
759 
760 // XStyleFamily
761 
GetObjectByIndex_Impl(sal_uInt32 nIndex)762 ScStyleObj* ScStyleFamilyObj::GetObjectByIndex_Impl(sal_uInt32 nIndex)
763 {
764     if ( pDocShell )
765     {
766         ScDocument* pDoc = pDocShell->GetDocument();
767         ScStyleSheetPool* pStylePool = pDoc->GetStyleSheetPool();
768 
769         SfxStyleSheetIterator aIter( pStylePool, eFamily );
770         if ( nIndex < aIter.Count() )
771         {
772             SfxStyleSheetBase* pStyle = aIter[(sal_uInt16)nIndex];
773             if ( pStyle )
774             {
775                 return new ScStyleObj( pDocShell, eFamily, String (pStyle->GetName()) );
776             }
777         }
778     }
779     return NULL;
780 }
781 
GetObjectByName_Impl(const rtl::OUString & aName)782 ScStyleObj* ScStyleFamilyObj::GetObjectByName_Impl(const rtl::OUString& aName)
783 {
784     if ( pDocShell )
785     {
786         String aString(aName);
787 
788         ScDocument* pDoc = pDocShell->GetDocument();
789         ScStyleSheetPool* pStylePool = pDoc->GetStyleSheetPool();
790         if ( pStylePool->Find( aString, eFamily ) )
791             return new ScStyleObj( pDocShell, eFamily, aString );
792     }
793     return NULL;
794 }
795 
insertByName(const rtl::OUString & aName,const uno::Any & aElement)796 void SAL_CALL ScStyleFamilyObj::insertByName( const rtl::OUString& aName, const uno::Any& aElement )
797 {
798     ScUnoGuard aGuard;
799     sal_Bool bDone = sal_False;
800     //  Reflection muss nicht uno::XInterface sein, kann auch irgendein Interface sein...
801     uno::Reference< uno::XInterface > xInterface(aElement, uno::UNO_QUERY);
802     if ( xInterface.is() )
803     {
804         ScStyleObj* pStyleObj = ScStyleObj::getImplementation( xInterface );
805         if ( pStyleObj && pStyleObj->GetFamily() == eFamily &&
806                 !pStyleObj->IsInserted() )  // noch nicht eingefuegt?
807         {
808             String aNameStr(ScStyleNameConversion::ProgrammaticToDisplayName( aName, sal::static_int_cast<sal_uInt16>(eFamily) ));
809 
810             ScDocument* pDoc = pDocShell->GetDocument();
811             ScStyleSheetPool* pStylePool = pDoc->GetStyleSheetPool();
812 
813             //! DocFunc-Funktion??
814             //! Undo ?????????????
815 
816             if ( !pStylePool->Find( aNameStr, eFamily ) )   // noch nicht vorhanden
817             {
818                 (void)pStylePool->Make( aNameStr, eFamily, SFXSTYLEBIT_USERDEF );
819 
820                 if ( eFamily == SFX_STYLE_FAMILY_PARA && !pDoc->IsImportingXML() )
821                     pDoc->GetPool()->CellStyleCreated( aNameStr );
822 
823                 pStyleObj->InitDoc( pDocShell, aNameStr );  // Objekt kann benutzt werden
824 
825                 pDocShell->SetDocumentModified();   // verwendet wird der neue Style noch nicht
826                 bDone = sal_True;
827             }
828             else
829                 throw container::ElementExistException();
830         }
831     }
832 
833     if (!bDone)
834     {
835         //  other errors are handled above
836         throw lang::IllegalArgumentException();
837     }
838 }
839 
replaceByName(const rtl::OUString & aName,const uno::Any & aElement)840 void SAL_CALL ScStyleFamilyObj::replaceByName( const rtl::OUString& aName, const uno::Any& aElement )
841 {
842     ScUnoGuard aGuard;
843     //! zusammenfassen?
844     removeByName( aName );
845     insertByName( aName, aElement );
846 }
847 
removeByName(const rtl::OUString & aName)848 void SAL_CALL ScStyleFamilyObj::removeByName( const rtl::OUString& aName )
849 {
850     ScUnoGuard aGuard;
851     sal_Bool bFound = sal_False;
852     if ( pDocShell )
853     {
854         String aString(ScStyleNameConversion::ProgrammaticToDisplayName( aName, sal::static_int_cast<sal_uInt16>(eFamily) ));
855 
856         ScDocument* pDoc = pDocShell->GetDocument();
857         ScStyleSheetPool* pStylePool = pDoc->GetStyleSheetPool();
858 
859         //! DocFunc-Funktion??
860         //! Undo ?????????????
861 
862         SfxStyleSheetBase* pStyle = pStylePool->Find( aString, eFamily );
863         if (pStyle)
864         {
865             bFound = sal_True;
866             if ( eFamily == SFX_STYLE_FAMILY_PARA )
867             {
868                 // wie ScViewFunc::RemoveStyleSheetInUse
869                 VirtualDevice aVDev;
870                 Point aLogic = aVDev.LogicToPixel( Point(1000,1000), MAP_TWIP );
871                 double nPPTX = aLogic.X() / 1000.0;
872                 double nPPTY = aLogic.Y() / 1000.0;
873                 Fraction aZoom(1,1);
874                 pDoc->StyleSheetChanged( pStyle, sal_False, &aVDev, nPPTX, nPPTY, aZoom, aZoom );
875                 pDocShell->PostPaint( 0,0,0, MAXCOL,MAXROW,MAXTAB, PAINT_GRID|PAINT_LEFT );
876                 pDocShell->SetDocumentModified();
877 
878                 pStylePool->Remove( pStyle );
879 
880                 //! InvalidateAttribs();        // Bindings-Invalidate
881             }
882             else
883             {
884                 if ( pDoc->RemovePageStyleInUse( aString ) )
885                     pDocShell->PageStyleModified( ScGlobal::GetRscString(STR_STYLENAME_STANDARD), sal_True );
886 
887                 pStylePool->Remove( pStyle );
888 
889                 SfxBindings* pBindings = pDocShell->GetViewBindings();
890                 if (pBindings)
891                     pBindings->Invalidate( SID_STYLE_FAMILY4 );
892                 pDocShell->SetDocumentModified();
893             }
894         }
895     }
896 
897     if (!bFound)
898         throw container::NoSuchElementException();
899 }
900 
901 // container::XIndexAccess
902 
getCount()903 sal_Int32 SAL_CALL ScStyleFamilyObj::getCount()
904 {
905     ScUnoGuard aGuard;
906     if ( pDocShell )
907     {
908         ScDocument* pDoc = pDocShell->GetDocument();
909         ScStyleSheetPool* pStylePool = pDoc->GetStyleSheetPool();
910 
911         SfxStyleSheetIterator aIter( pStylePool, eFamily );
912         return aIter.Count();
913     }
914     return 0;
915 }
916 
getByIndex(sal_Int32 nIndex)917 uno::Any SAL_CALL ScStyleFamilyObj::getByIndex( sal_Int32 nIndex )
918 {
919     ScUnoGuard aGuard;
920     uno::Reference< style::XStyle >  xObj(GetObjectByIndex_Impl(nIndex));
921     if (xObj.is())
922         return uno::makeAny(xObj);
923     else
924         throw lang::IndexOutOfBoundsException();
925 //    return uno::Any();
926 }
927 
getElementType()928 uno::Type SAL_CALL ScStyleFamilyObj::getElementType()
929 {
930     ScUnoGuard aGuard;
931     return ::getCppuType((const uno::Reference< style::XStyle >*)0);    // muss zu getByIndex passen
932 }
933 
hasElements()934 sal_Bool SAL_CALL ScStyleFamilyObj::hasElements()
935 {
936     ScUnoGuard aGuard;
937     return ( getCount() != 0 );
938 }
939 
940 // container::XNameAccess
941 
getByName(const rtl::OUString & aName)942 uno::Any SAL_CALL ScStyleFamilyObj::getByName( const rtl::OUString& aName )
943 {
944     ScUnoGuard aGuard;
945     uno::Reference< style::XStyle > xObj(
946         GetObjectByName_Impl( ScStyleNameConversion::ProgrammaticToDisplayName( aName, sal::static_int_cast<sal_uInt16>(eFamily) ) ));
947     if (xObj.is())
948         return uno::makeAny(xObj);
949     else
950         throw container::NoSuchElementException();
951 //    return uno::Any();
952 }
953 
getElementNames()954 uno::Sequence<rtl::OUString> SAL_CALL ScStyleFamilyObj::getElementNames()
955 {
956     ScUnoGuard aGuard;
957     if ( pDocShell )
958     {
959         ScDocument* pDoc = pDocShell->GetDocument();
960         ScStyleSheetPool* pStylePool = pDoc->GetStyleSheetPool();
961 
962         SfxStyleSheetIterator aIter( pStylePool, eFamily );
963         sal_uInt16 nCount = aIter.Count();
964 
965         String aName;
966         uno::Sequence<rtl::OUString> aSeq(nCount);
967         rtl::OUString* pAry = aSeq.getArray();
968         SfxStyleSheetBase* pStyle = aIter.First();
969         sal_uInt16 nPos = 0;
970         while (pStyle)
971         {
972             DBG_ASSERT( nPos<nCount, "Anzahl durcheinandergekommen" );
973             if (nPos<nCount)
974                 pAry[nPos++] = ScStyleNameConversion::DisplayToProgrammaticName(
975                                     pStyle->GetName(), sal::static_int_cast<sal_uInt16>(eFamily) );
976             pStyle = aIter.Next();
977         }
978         return aSeq;
979     }
980     return uno::Sequence<rtl::OUString>();
981 }
982 
hasByName(const rtl::OUString & aName)983 sal_Bool SAL_CALL ScStyleFamilyObj::hasByName( const rtl::OUString& aName )
984 {
985     ScUnoGuard aGuard;
986     if ( pDocShell )
987     {
988         String aString(ScStyleNameConversion::ProgrammaticToDisplayName( aName, sal::static_int_cast<sal_uInt16>(eFamily) ));
989 
990         ScDocument* pDoc = pDocShell->GetDocument();
991         ScStyleSheetPool* pStylePool = pDoc->GetStyleSheetPool();
992         if ( pStylePool->Find( aString, eFamily ) )
993             return sal_True;
994     }
995     return sal_False;
996 }
997 
998 // XPropertySet
999 
getPropertySetInfo()1000 uno::Reference< beans::XPropertySetInfo > SAL_CALL ScStyleFamilyObj::getPropertySetInfo(  )
1001 {
1002     OSL_ENSURE( 0, "###unexpected!" );
1003     return uno::Reference< beans::XPropertySetInfo >();
1004 }
1005 
setPropertyValue(const::rtl::OUString &,const uno::Any &)1006 void SAL_CALL ScStyleFamilyObj::setPropertyValue( const ::rtl::OUString&, const uno::Any& )
1007 {
1008     OSL_ENSURE( 0, "###unexpected!" );
1009 }
1010 
getPropertyValue(const::rtl::OUString & sPropertyName)1011 uno::Any SAL_CALL ScStyleFamilyObj::getPropertyValue( const ::rtl::OUString& sPropertyName )
1012 {
1013     uno::Any aRet;
1014 
1015     if ( sPropertyName.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("DisplayName") ) )
1016     {
1017         ScUnoGuard aGuard;
1018         sal_uInt32 nResId = 0;
1019         switch ( eFamily )
1020         {
1021             case SFX_STYLE_FAMILY_PARA:
1022                 nResId = STR_STYLE_FAMILY_CELL; break;
1023             case SFX_STYLE_FAMILY_PAGE:
1024                 nResId = STR_STYLE_FAMILY_PAGE; break;
1025             default:
1026                 OSL_ENSURE( 0, "ScStyleFamilyObj::getPropertyValue(): invalid family" );
1027         }
1028         if ( nResId > 0 )
1029         {
1030             ::rtl::OUString sDisplayName( ScGlobal::GetRscString( static_cast< sal_uInt16 >( nResId ) ) );
1031             aRet = uno::makeAny( sDisplayName );
1032         }
1033     }
1034     else
1035     {
1036         throw beans::UnknownPropertyException( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("unknown property: ") ) + sPropertyName, static_cast<OWeakObject *>(this) );
1037     }
1038 
1039     return aRet;
1040 }
1041 
addPropertyChangeListener(const::rtl::OUString &,const uno::Reference<beans::XPropertyChangeListener> &)1042 void SAL_CALL ScStyleFamilyObj::addPropertyChangeListener( const ::rtl::OUString&, const uno::Reference< beans::XPropertyChangeListener >& )
1043 {
1044     OSL_ENSURE( 0, "###unexpected!" );
1045 }
1046 
removePropertyChangeListener(const::rtl::OUString &,const uno::Reference<beans::XPropertyChangeListener> &)1047 void SAL_CALL ScStyleFamilyObj::removePropertyChangeListener( const ::rtl::OUString&, const uno::Reference< beans::XPropertyChangeListener >& )
1048 {
1049     OSL_ENSURE( 0, "###unexpected!" );
1050 }
1051 
addVetoableChangeListener(const::rtl::OUString &,const uno::Reference<beans::XVetoableChangeListener> &)1052 void SAL_CALL ScStyleFamilyObj::addVetoableChangeListener( const ::rtl::OUString&, const uno::Reference< beans::XVetoableChangeListener >& )
1053 {
1054     OSL_ENSURE( 0, "###unexpected!" );
1055 }
1056 
removeVetoableChangeListener(const::rtl::OUString &,const uno::Reference<beans::XVetoableChangeListener> &)1057 void SAL_CALL ScStyleFamilyObj::removeVetoableChangeListener( const ::rtl::OUString&, const uno::Reference< beans::XVetoableChangeListener >& )
1058 {
1059     OSL_ENSURE( 0, "###unexpected!" );
1060 }
1061 
1062 //------------------------------------------------------------------------
1063 
1064 //  Default-ctor wird fuer die Reflection gebraucht
1065 
1066 //UNUSED2008-05  ScStyleObj::ScStyleObj() :
1067 //UNUSED2008-05  aPropSet( lcl_GetCellStyleMap() ),
1068 //UNUSED2008-05  pDocShell( NULL ),
1069 //UNUSED2008-05  eFamily( SFX_STYLE_FAMILY_PARA )
1070 //UNUSED2008-05  {
1071 //UNUSED2008-05  }
1072 
ScStyleObj(ScDocShell * pDocSh,SfxStyleFamily eFam,const String & rName)1073 ScStyleObj::ScStyleObj(ScDocShell* pDocSh, SfxStyleFamily eFam, const String& rName) :
1074     pPropSet( (eFam == SFX_STYLE_FAMILY_PARA) ? lcl_GetCellStyleSet() : lcl_GetPageStyleSet() ),
1075     pDocShell( pDocSh ),
1076     eFamily( eFam ),
1077     aStyleName( rName )
1078 {
1079     //  pDocShell ist Null, wenn per ServiceProvider erzeugt
1080 
1081     if (pDocShell)
1082         pDocShell->GetDocument()->AddUnoObject(*this);
1083 }
1084 
InitDoc(ScDocShell * pNewDocSh,const String & rNewName)1085 void ScStyleObj::InitDoc( ScDocShell* pNewDocSh, const String& rNewName )
1086 {
1087     if ( pNewDocSh && !pDocShell )
1088     {
1089         aStyleName = rNewName;
1090         pDocShell = pNewDocSh;
1091         pDocShell->GetDocument()->AddUnoObject(*this);
1092     }
1093 }
1094 
~ScStyleObj()1095 ScStyleObj::~ScStyleObj()
1096 {
1097     if (pDocShell)
1098         pDocShell->GetDocument()->RemoveUnoObject(*this);
1099 }
1100 
1101 // XUnoTunnel
1102 
getSomething(const uno::Sequence<sal_Int8> & rId)1103 sal_Int64 SAL_CALL ScStyleObj::getSomething(
1104                 const uno::Sequence<sal_Int8 >& rId )
1105 {
1106     if ( rId.getLength() == 16 &&
1107           0 == rtl_compareMemory( getUnoTunnelId().getConstArray(),
1108                                     rId.getConstArray(), 16 ) )
1109     {
1110         return sal::static_int_cast<sal_Int64>(reinterpret_cast<sal_IntPtr>(this));
1111     }
1112     return 0;
1113 }
1114 
1115 // static
getUnoTunnelId()1116 const uno::Sequence<sal_Int8>& ScStyleObj::getUnoTunnelId()
1117 {
1118     static uno::Sequence<sal_Int8> * pSeq = 0;
1119     if( !pSeq )
1120     {
1121         osl::Guard< osl::Mutex > aGuard( osl::Mutex::getGlobalMutex() );
1122         if( !pSeq )
1123         {
1124             static uno::Sequence< sal_Int8 > aSeq( 16 );
1125             rtl_createUuid( (sal_uInt8*)aSeq.getArray(), 0, sal_True );
1126             pSeq = &aSeq;
1127         }
1128     }
1129     return *pSeq;
1130 }
1131 
1132 // static
getImplementation(const uno::Reference<uno::XInterface> xObj)1133 ScStyleObj* ScStyleObj::getImplementation(
1134                         const uno::Reference<uno::XInterface> xObj )
1135 {
1136     ScStyleObj* pRet = NULL;
1137     uno::Reference<lang::XUnoTunnel> xUT( xObj, uno::UNO_QUERY );
1138     if (xUT.is())
1139         pRet = reinterpret_cast<ScStyleObj*>(sal::static_int_cast<sal_IntPtr>(xUT->getSomething(getUnoTunnelId())));
1140     return pRet;
1141 }
1142 
Notify(SfxBroadcaster &,const SfxHint & rHint)1143 void ScStyleObj::Notify( SfxBroadcaster&, const SfxHint& rHint )
1144 {
1145     //  Referenz-Update interessiert hier nicht
1146 
1147     if ( rHint.ISA( SfxSimpleHint ) &&
1148             ((const SfxSimpleHint&)rHint).GetId() == SFX_HINT_DYING )
1149     {
1150         pDocShell = NULL;       // ungueltig geworden
1151     }
1152 }
1153 
GetStyle_Impl()1154 SfxStyleSheetBase* ScStyleObj::GetStyle_Impl()
1155 {
1156     if ( pDocShell )
1157     {
1158         ScDocument* pDoc = pDocShell->GetDocument();
1159         ScStyleSheetPool* pStylePool = pDoc->GetStyleSheetPool();
1160         return pStylePool->Find( aStyleName, eFamily );
1161     }
1162     return NULL;
1163 }
1164 
1165 // style::XStyle
1166 
isUserDefined()1167 sal_Bool SAL_CALL ScStyleObj::isUserDefined()
1168 {
1169     ScUnoGuard aGuard;
1170     SfxStyleSheetBase* pStyle = GetStyle_Impl();
1171     if (pStyle)
1172         return pStyle->IsUserDefined();
1173     return sal_False;
1174 }
1175 
isInUse()1176 sal_Bool SAL_CALL ScStyleObj::isInUse()
1177 {
1178     ScUnoGuard aGuard;
1179     SfxStyleSheetBase* pStyle = GetStyle_Impl();
1180     if (pStyle)
1181         return pStyle->IsUsed();
1182     return sal_False;
1183 }
1184 
getParentStyle()1185 rtl::OUString SAL_CALL ScStyleObj::getParentStyle()
1186 {
1187     ScUnoGuard aGuard;
1188     SfxStyleSheetBase* pStyle = GetStyle_Impl();
1189     if (pStyle)
1190         return ScStyleNameConversion::DisplayToProgrammaticName( pStyle->GetParent(), sal::static_int_cast<sal_uInt16>(eFamily) );
1191     return rtl::OUString();
1192 }
1193 
setParentStyle(const rtl::OUString & rParentStyle)1194 void SAL_CALL ScStyleObj::setParentStyle( const rtl::OUString& rParentStyle )
1195 {
1196     ScUnoGuard aGuard;
1197     SfxStyleSheetBase* pStyle = GetStyle_Impl();
1198     if (pStyle)
1199     {
1200         //  #70909# cell styles cannot be modified if any sheet is protected
1201         if ( eFamily == SFX_STYLE_FAMILY_PARA && lcl_AnyTabProtected( *pDocShell->GetDocument() ) )
1202             return;         //! exception?
1203 
1204         //! DocFunc-Funktion??
1205         //! Undo ?????????????
1206 
1207         String aString(ScStyleNameConversion::ProgrammaticToDisplayName( rParentStyle, sal::static_int_cast<sal_uInt16>(eFamily) ));
1208         sal_Bool bOk = pStyle->SetParent( aString );
1209         if (bOk)
1210         {
1211             //  wie bei setPropertyValue
1212 
1213             ScDocument* pDoc = pDocShell->GetDocument();
1214             if ( eFamily == SFX_STYLE_FAMILY_PARA )
1215             {
1216                 //  Zeilenhoehen anpassen...
1217 
1218                 VirtualDevice aVDev;
1219                 Point aLogic = aVDev.LogicToPixel( Point(1000,1000), MAP_TWIP );
1220                 double nPPTX = aLogic.X() / 1000.0;
1221                 double nPPTY = aLogic.Y() / 1000.0;
1222                 Fraction aZoom(1,1);
1223                 pDoc->StyleSheetChanged( pStyle, sal_False, &aVDev, nPPTX, nPPTY, aZoom, aZoom );
1224 
1225                 pDocShell->PostPaint( 0,0,0, MAXCOL,MAXROW,MAXTAB, PAINT_GRID|PAINT_LEFT );
1226                 pDocShell->SetDocumentModified();
1227             }
1228             else
1229             {
1230                 //! ModifyStyleSheet am Dokument (alte Werte merken)
1231 
1232                 pDocShell->PageStyleModified( aStyleName, sal_True );
1233             }
1234         }
1235     }
1236 }
1237 
1238 // container::XNamed
1239 
getName()1240 rtl::OUString SAL_CALL ScStyleObj::getName()
1241 {
1242     ScUnoGuard aGuard;
1243     SfxStyleSheetBase* pStyle = GetStyle_Impl();
1244     if (pStyle)
1245         return ScStyleNameConversion::DisplayToProgrammaticName( pStyle->GetName(), sal::static_int_cast<sal_uInt16>(eFamily) );
1246     return rtl::OUString();
1247 }
1248 
setName(const rtl::OUString & aNewName)1249 void SAL_CALL ScStyleObj::setName( const rtl::OUString& aNewName )
1250 {
1251     ScUnoGuard aGuard;
1252     SfxStyleSheetBase* pStyle = GetStyle_Impl();
1253     if (pStyle)
1254     {
1255         //  #71225# cell styles cannot be renamed if any sheet is protected
1256         if ( eFamily == SFX_STYLE_FAMILY_PARA && lcl_AnyTabProtected( *pDocShell->GetDocument() ) )
1257             return;         //! exception?
1258 
1259         //! DocFunc-Funktion??
1260         //! Undo ?????????????
1261 
1262         String aString(aNewName);
1263         sal_Bool bOk = pStyle->SetName( aString );
1264         if (bOk)
1265         {
1266             aStyleName = aString;       //! notify other objects for this style?
1267 
1268             ScDocument* pDoc = pDocShell->GetDocument();
1269             if ( eFamily == SFX_STYLE_FAMILY_PARA && !pDoc->IsImportingXML() )
1270                 pDoc->GetPool()->CellStyleCreated( aString );
1271 
1272             //  Zellvorlagen = 2, Seitenvorlagen = 4
1273             sal_uInt16 nId = ( eFamily == SFX_STYLE_FAMILY_PARA ) ?
1274                             SID_STYLE_FAMILY2 : SID_STYLE_FAMILY4;
1275             SfxBindings* pBindings = pDocShell->GetViewBindings();
1276             if (pBindings)
1277             {
1278                 pBindings->Invalidate( nId );
1279                 pBindings->Invalidate( SID_STYLE_APPLY );
1280             }
1281         }
1282     }
1283 }
1284 
1285 // static
CreateEmptyNumberingRules()1286 uno::Reference<container::XIndexReplace> ScStyleObj::CreateEmptyNumberingRules()
1287 {
1288     SvxNumRule aRule( 0, 0, sal_True );         // nothing supported
1289     return SvxCreateNumRule( &aRule );
1290 }
1291 
1292 // beans::XPropertyState
1293 
GetStyleItemSet_Impl(const::rtl::OUString & rPropName,const SfxItemPropertySimpleEntry * & rpResultEntry)1294 const SfxItemSet* ScStyleObj::GetStyleItemSet_Impl( const ::rtl::OUString& rPropName,
1295                                         const SfxItemPropertySimpleEntry*& rpResultEntry )
1296 {
1297     //! OUString as argument?
1298 
1299     SfxStyleSheetBase* pStyle = GetStyle_Impl();
1300     if (pStyle)
1301     {
1302         const SfxItemPropertySimpleEntry* pEntry = NULL;
1303         if ( eFamily == SFX_STYLE_FAMILY_PAGE )
1304         {
1305             pEntry = lcl_GetHeaderStyleMap()->getByName( rPropName );
1306             if ( pEntry )     // only item-wids in header/footer map
1307             {
1308                 rpResultEntry = pEntry;
1309                 return &((const SvxSetItem&)pStyle->GetItemSet().Get(ATTR_PAGE_HEADERSET)).GetItemSet();
1310             }
1311             pEntry = lcl_GetFooterStyleMap()->getByName( rPropName );
1312             if ( pEntry )      // only item-wids in header/footer map
1313             {
1314                 rpResultEntry = pEntry;
1315                 return &((const SvxSetItem&)pStyle->GetItemSet().Get(ATTR_PAGE_FOOTERSET)).GetItemSet();
1316             }
1317         }
1318         pEntry = pPropSet->getPropertyMap()->getByName( rPropName );
1319         if ( pEntry )
1320         {
1321             rpResultEntry = pEntry;
1322             return &pStyle->GetItemSet();
1323         }
1324     }
1325 
1326     rpResultEntry = NULL;
1327     return NULL;
1328 }
1329 
getPropertyState(const rtl::OUString & aPropertyName)1330 beans::PropertyState SAL_CALL ScStyleObj::getPropertyState( const rtl::OUString& aPropertyName )
1331 {
1332     ScUnoGuard aGuard;
1333     beans::PropertyState eRet = beans::PropertyState_DIRECT_VALUE;
1334 
1335     const SfxItemPropertySimpleEntry* pResultEntry = NULL;
1336     const SfxItemSet* pItemSet = GetStyleItemSet_Impl( aPropertyName, pResultEntry );
1337 
1338     if ( pItemSet && pResultEntry )
1339     {
1340         sal_uInt16 nWhich = pResultEntry->nWID;
1341         if ( nWhich == SC_WID_UNO_TBLBORD )
1342         {
1343             nWhich = ATTR_BORDER;
1344         }
1345         if ( IsScItemWid( nWhich ) )
1346         {
1347             SfxItemState eState = pItemSet->GetItemState( nWhich, sal_False );
1348 
1349 //           //  if no rotate value is set, look at orientation
1350 //           //! also for a fixed value of 0 (in case orientation is ambiguous)?
1351 //           if ( nWhich == ATTR_ROTATE_VALUE && eState == SFX_ITEM_DEFAULT )
1352 //               eState = pItemSet->GetItemState( ATTR_ORIENTATION, sal_False );
1353 
1354             if ( eState == SFX_ITEM_SET )
1355                 eRet = beans::PropertyState_DIRECT_VALUE;
1356             else if ( eState == SFX_ITEM_DEFAULT )
1357                 eRet = beans::PropertyState_DEFAULT_VALUE;
1358             else if ( eState == SFX_ITEM_DONTCARE )
1359                 eRet = beans::PropertyState_AMBIGUOUS_VALUE;    // kann eigentlich nicht sein...
1360             else
1361             {
1362                 DBG_ERROR("unbekannter ItemState");
1363             }
1364         }
1365     }
1366     return eRet;
1367 }
1368 
getPropertyStates(const uno::Sequence<rtl::OUString> & aPropertyNames)1369 uno::Sequence<beans::PropertyState> SAL_CALL ScStyleObj::getPropertyStates(
1370                             const uno::Sequence<rtl::OUString>& aPropertyNames )
1371 {
1372     //  duemmliche Default-Implementierung: alles einzeln per getPropertyState holen
1373     //! sollte optimiert werden!
1374 
1375     ScUnoGuard aGuard;
1376     const rtl::OUString* pNames = aPropertyNames.getConstArray();
1377     uno::Sequence<beans::PropertyState> aRet(aPropertyNames.getLength());
1378     beans::PropertyState* pStates = aRet.getArray();
1379     for(sal_Int32 i = 0; i < aPropertyNames.getLength(); i++)
1380         pStates[i] = getPropertyState(pNames[i]);
1381     return aRet;
1382 }
1383 
setPropertyToDefault(const rtl::OUString & aPropertyName)1384 void SAL_CALL ScStyleObj::setPropertyToDefault( const rtl::OUString& aPropertyName )
1385 {
1386     ScUnoGuard aGuard;
1387 
1388     const SfxItemPropertyMap* pMap = pPropSet->getPropertyMap();
1389     const SfxItemPropertySimpleEntry* pEntry = pMap->getByName( aPropertyName );
1390     if ( !pEntry )
1391         throw beans::UnknownPropertyException();
1392 
1393     SetOnePropertyValue( aPropertyName, pEntry, NULL );
1394 }
1395 
getPropertyDefault(const rtl::OUString & aPropertyName)1396 uno::Any SAL_CALL ScStyleObj::getPropertyDefault( const rtl::OUString& aPropertyName )
1397 {
1398     ScUnoGuard aGuard;
1399     uno::Any aAny;
1400 
1401     const SfxItemPropertySimpleEntry* pResultEntry = NULL;
1402     const SfxItemSet* pStyleSet = GetStyleItemSet_Impl( aPropertyName, pResultEntry );
1403 
1404     if ( pStyleSet && pResultEntry )
1405     {
1406         sal_uInt16 nWhich = pResultEntry->nWID;
1407 
1408         if ( IsScItemWid( nWhich ) )
1409         {
1410             //  Default ist Default vom ItemPool, nicht vom Standard-Style,
1411             //  damit es zu setPropertyToDefault passt
1412             SfxItemSet aEmptySet( *pStyleSet->GetPool(), pStyleSet->GetRanges() );
1413             //  #65253# Default-Items mit falscher Slot-ID funktionieren im SfxItemPropertySet3 nicht
1414             //! Slot-IDs aendern...
1415             if ( aEmptySet.GetPool()->GetSlotId(nWhich) == nWhich &&
1416                  aEmptySet.GetItemState(nWhich, sal_False) == SFX_ITEM_DEFAULT )
1417             {
1418                 aEmptySet.Put( aEmptySet.Get( nWhich ) );
1419             }
1420             const SfxItemSet* pItemSet = &aEmptySet;
1421 
1422             switch ( nWhich )       // fuer Item-Spezial-Behandlungen
1423             {
1424                 case ATTR_VALUE_FORMAT:
1425                     //  default has no language set
1426                     aAny <<= sal_Int32( ((const SfxUInt32Item&)pItemSet->Get(nWhich)).GetValue() );
1427                     break;
1428                 case ATTR_INDENT:
1429                     aAny <<= sal_Int16( TwipsToHMM(((const SfxUInt16Item&)
1430                                     pItemSet->Get(nWhich)).GetValue()) );
1431                     break;
1432                 case ATTR_PAGE_SCALE:
1433                 case ATTR_PAGE_SCALETOPAGES:
1434                 case ATTR_PAGE_FIRSTPAGENO:
1435                     aAny <<= sal_Int16( ((const SfxUInt16Item&)pItemSet->Get(nWhich)).GetValue() );
1436                     break;
1437                 case ATTR_PAGE_CHARTS:
1438                 case ATTR_PAGE_OBJECTS:
1439                 case ATTR_PAGE_DRAWINGS:
1440                     //! sal_Bool-MID fuer ScViewObjectModeItem definieren?
1441                     aAny <<= sal_Bool( ((const ScViewObjectModeItem&)pItemSet->Get(nWhich)).
1442                                     GetValue() == VOBJ_MODE_SHOW );
1443                     break;
1444                 case ATTR_PAGE_SCALETO:
1445                     {
1446                         const ScPageScaleToItem aItem((const ScPageScaleToItem&)pItemSet->Get(nWhich));
1447                         if (aPropertyName.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM ( SC_UNO_PAGE_SCALETOX )))
1448                             aAny = uno::makeAny(static_cast<sal_Int16>(aItem.GetWidth()));
1449                         else
1450                             aAny = uno::makeAny(static_cast<sal_Int16>(aItem.GetHeight()));
1451                     }
1452                     break;
1453                 default:
1454                     pPropSet->getPropertyValue( *pResultEntry, *pItemSet, aAny );
1455             }
1456         }
1457         else if ( IsScUnoWid( nWhich ) )
1458         {
1459             SfxItemSet aEmptySet( *pStyleSet->GetPool(), pStyleSet->GetRanges() );
1460             const SfxItemSet* pItemSet = &aEmptySet;
1461             switch ( nWhich )
1462             {
1463                 case SC_WID_UNO_TBLBORD:
1464                     {
1465                         const SfxPoolItem* pItem = &pItemSet->Get( ATTR_BORDER );
1466                         if ( pItem )
1467                         {
1468                             SvxBoxItem aOuter( *( static_cast<const SvxBoxItem*>( pItem ) ) );
1469                             SvxBoxInfoItem aInner( ATTR_BORDER_INNER );
1470                             table::TableBorder aBorder;
1471                             ScHelperFunctions::FillTableBorder( aBorder, aOuter, aInner );
1472                             aBorder.IsHorizontalLineValid = sal_False;
1473                             aBorder.IsVerticalLineValid = sal_False;
1474                             aBorder.IsDistanceValid = sal_False;
1475                             aAny <<= aBorder;
1476                         }
1477                     }
1478                     break;
1479             }
1480         }
1481     }
1482     return aAny;
1483 }
1484 
1485 // XMultiPropertySet
1486 
setPropertyValues(const uno::Sequence<rtl::OUString> & aPropertyNames,const uno::Sequence<uno::Any> & aValues)1487 void SAL_CALL ScStyleObj::setPropertyValues( const uno::Sequence< rtl::OUString >& aPropertyNames,
1488                                                 const uno::Sequence< uno::Any >& aValues )
1489 {
1490     ScUnoGuard aGuard;
1491 
1492     sal_Int32 nCount = aPropertyNames.getLength();
1493     if ( aValues.getLength() != nCount )
1494         throw lang::IllegalArgumentException();
1495 
1496     if ( nCount )
1497     {
1498         const rtl::OUString* pNames = aPropertyNames.getConstArray();
1499         const uno::Any* pValues = aValues.getConstArray();
1500 
1501         const SfxItemPropertyMap* pPropertyMap = pPropSet->getPropertyMap();
1502         for (sal_Int32 i = 0; i < nCount; i++)
1503         {
1504             const SfxItemPropertySimpleEntry*  pEntry = pPropertyMap->getByName( pNames[i] );
1505 
1506             // enhance ODS load performance
1507             SetOnePropertyValueWithoutUpdate( pNames[i], pEntry, &pValues[i] );
1508         }
1509 
1510         // enhance ODS load performance
1511         StyleSheetChangedUpdate();
1512     }
1513 }
1514 
getPropertyValues(const uno::Sequence<rtl::OUString> & aPropertyNames)1515 uno::Sequence<uno::Any> SAL_CALL ScStyleObj::getPropertyValues(
1516                                     const uno::Sequence< rtl::OUString >& aPropertyNames )
1517 {
1518     ScUnoGuard aGuard;
1519 
1520     //! optimize
1521 
1522     sal_Int32 nCount = aPropertyNames.getLength();
1523     uno::Sequence<uno::Any> aSequence( nCount );
1524     if ( nCount )
1525     {
1526         uno::Any* pValues = aSequence.getArray();
1527         for (sal_Int32 i=0; i<nCount; i++)
1528             pValues[i] = getPropertyValue( aPropertyNames[i] );
1529     }
1530     return aSequence;
1531 }
1532 
addPropertiesChangeListener(const uno::Sequence<rtl::OUString> &,const uno::Reference<beans::XPropertiesChangeListener> &)1533 void SAL_CALL ScStyleObj::addPropertiesChangeListener( const uno::Sequence<rtl::OUString>& /* aPropertyNames */,
1534                                     const uno::Reference<beans::XPropertiesChangeListener>& /* xListener */ )
1535 {
1536     // no bound properties
1537 }
1538 
removePropertiesChangeListener(const uno::Reference<beans::XPropertiesChangeListener> &)1539 void SAL_CALL ScStyleObj::removePropertiesChangeListener(
1540                                     const uno::Reference<beans::XPropertiesChangeListener>& /* xListener */ )
1541 {
1542     // no bound properties
1543 }
1544 
firePropertiesChangeEvent(const uno::Sequence<rtl::OUString> &,const uno::Reference<beans::XPropertiesChangeListener> &)1545 void SAL_CALL ScStyleObj::firePropertiesChangeEvent( const uno::Sequence<rtl::OUString>& /* aPropertyNames */,
1546                                     const uno::Reference<beans::XPropertiesChangeListener>& /* xListener */ )
1547 {
1548     // no bound properties
1549 }
1550 
1551 // XMultiPropertyStates
1552 // getPropertyStates already defined for XPropertyState
1553 
setAllPropertiesToDefault()1554 void SAL_CALL ScStyleObj::setAllPropertiesToDefault()
1555 {
1556     ScUnoGuard aGuard;
1557 
1558     SfxStyleSheetBase* pStyle = GetStyle_Impl();
1559     if ( pStyle )
1560     {
1561         //  #70909# cell styles cannot be modified if any sheet is protected
1562         if ( eFamily == SFX_STYLE_FAMILY_PARA && lcl_AnyTabProtected( *pDocShell->GetDocument() ) )
1563             throw uno::RuntimeException();
1564 
1565         SfxItemSet& rSet = pStyle->GetItemSet();
1566         rSet.ClearItem();                               // set all items to default
1567 
1568         //! merge with SetOneProperty
1569 
1570         ScDocument* pDoc = pDocShell->GetDocument();
1571         if ( eFamily == SFX_STYLE_FAMILY_PARA )
1572         {
1573             //  row heights
1574 
1575             VirtualDevice aVDev;
1576             Point aLogic = aVDev.LogicToPixel( Point(1000,1000), MAP_TWIP );
1577             double nPPTX = aLogic.X() / 1000.0;
1578             double nPPTY = aLogic.Y() / 1000.0;
1579             Fraction aZoom(1,1);
1580             pDoc->StyleSheetChanged( pStyle, sal_False, &aVDev, nPPTX, nPPTY, aZoom, aZoom );
1581 
1582             pDocShell->PostPaint( 0,0,0, MAXCOL,MAXROW,MAXTAB, PAINT_GRID|PAINT_LEFT );
1583             pDocShell->SetDocumentModified();
1584         }
1585         else
1586         {
1587             // #i22448# apply the default BoxInfoItem for page styles again
1588             // (same content as in ScStyleSheet::GetItemSet, to control the dialog)
1589             SvxBoxInfoItem aBoxInfoItem( ATTR_BORDER_INNER );
1590             aBoxInfoItem.SetTable( sal_False );
1591             aBoxInfoItem.SetDist( sal_True );
1592             aBoxInfoItem.SetValid( VALID_DISTANCE, sal_True );
1593             rSet.Put( aBoxInfoItem );
1594 
1595             pDocShell->PageStyleModified( aStyleName, sal_True );
1596         }
1597     }
1598 }
1599 
setPropertiesToDefault(const uno::Sequence<rtl::OUString> & aPropertyNames)1600 void SAL_CALL ScStyleObj::setPropertiesToDefault( const uno::Sequence<rtl::OUString>& aPropertyNames )
1601 {
1602     ScUnoGuard aGuard;
1603 
1604     sal_Int32 nCount = aPropertyNames.getLength();
1605     if ( nCount )
1606     {
1607         const rtl::OUString* pNames = aPropertyNames.getConstArray();
1608 
1609         const SfxItemPropertyMap* pPropertyMap = pPropSet->getPropertyMap();
1610         for (sal_Int32 i = 0; i < nCount; i++)
1611         {
1612             const SfxItemPropertySimpleEntry*  pEntry = pPropertyMap->getByName( pNames[i] );
1613             SetOnePropertyValue( pNames[i], pEntry, NULL );
1614         }
1615     }
1616 }
1617 
getPropertyDefaults(const uno::Sequence<rtl::OUString> & aPropertyNames)1618 uno::Sequence<uno::Any> SAL_CALL ScStyleObj::getPropertyDefaults(
1619                                 const uno::Sequence<rtl::OUString>& aPropertyNames )
1620 {
1621     ScUnoGuard aGuard;
1622 
1623     //! optimize
1624 
1625     sal_Int32 nCount = aPropertyNames.getLength();
1626     uno::Sequence<uno::Any> aSequence( nCount );
1627     if ( nCount )
1628     {
1629         uno::Any* pValues = aSequence.getArray();
1630         for (sal_Int32 i=0; i<nCount; i++)
1631             pValues[i] = getPropertyDefault( aPropertyNames[i] );
1632     }
1633     return aSequence;
1634 }
1635 
1636 // beans::XPropertySet
1637 
getPropertySetInfo()1638 uno::Reference<beans::XPropertySetInfo> SAL_CALL ScStyleObj::getPropertySetInfo()
1639 {
1640     ScUnoGuard aGuard;
1641     return pPropSet->getPropertySetInfo();
1642 }
1643 
setPropertyValue(const rtl::OUString & aPropertyName,const uno::Any & aValue)1644 void SAL_CALL ScStyleObj::setPropertyValue(
1645                         const rtl::OUString& aPropertyName, const uno::Any& aValue )
1646 {
1647     ScUnoGuard aGuard;
1648 
1649     const SfxItemPropertySimpleEntry*  pEntry = pPropSet->getPropertyMap()->getByName( aPropertyName );
1650     if ( !pEntry )
1651         throw beans::UnknownPropertyException();
1652 
1653     SetOnePropertyValue( aPropertyName, pEntry, &aValue );
1654 }
1655 
SetOnePropertyValue(const::rtl::OUString & rPropertyName,const SfxItemPropertySimpleEntry * pEntry,const uno::Any * pValue)1656 void ScStyleObj::SetOnePropertyValue( const ::rtl::OUString& rPropertyName, const SfxItemPropertySimpleEntry* pEntry, const uno::Any* pValue )
1657 {
1658     SetOnePropertyValueWithoutUpdate(rPropertyName, pEntry, pValue);
1659     StyleSheetChangedUpdate();
1660 }
1661 
SetOnePropertyValueWithoutUpdate(const::rtl::OUString & rPropertyName,const SfxItemPropertySimpleEntry * pEntry,const uno::Any * pValue)1662 void ScStyleObj::SetOnePropertyValueWithoutUpdate( const ::rtl::OUString& rPropertyName, const SfxItemPropertySimpleEntry* pEntry, const uno::Any* pValue )
1663 {
1664     SfxStyleSheetBase* pStyle = GetStyle_Impl();
1665     if ( pStyle && pEntry )
1666     {
1667         //  #70909# cell styles cannot be modified if any sheet is protected
1668         if ( eFamily == SFX_STYLE_FAMILY_PARA && lcl_AnyTabProtected( *pDocShell->GetDocument() ) )
1669             throw uno::RuntimeException();
1670 
1671         SfxItemSet& rSet = pStyle->GetItemSet();    // direkt im lebenden Style aendern...
1672         sal_Bool bDone = sal_False;
1673         if ( eFamily == SFX_STYLE_FAMILY_PAGE )
1674         {
1675             if(pEntry->nWID == SC_WID_UNO_HEADERSET)
1676             {
1677                 const SfxItemPropertySimpleEntry* pHeaderEntry = lcl_GetHeaderStyleMap()->getByName( rPropertyName );
1678                 if ( pHeaderEntry ) // only item-wids in header/footer map
1679                 {
1680                     SvxSetItem aNewHeader( (const SvxSetItem&)rSet.Get(ATTR_PAGE_HEADERSET) );
1681                     if (pValue)
1682                         pPropSet->setPropertyValue( *pHeaderEntry, *pValue, aNewHeader.GetItemSet() );
1683                     else
1684                         aNewHeader.GetItemSet().ClearItem( pHeaderEntry->nWID );
1685                     rSet.Put( aNewHeader );
1686                     bDone = sal_True;
1687                 }
1688             }
1689             else if(pEntry->nWID == SC_WID_UNO_FOOTERSET)
1690             {
1691                 const SfxItemPropertySimpleEntry* pFooterEntry = lcl_GetFooterStyleMap()->getByName( rPropertyName );
1692                 if ( pFooterEntry ) // only item-wids in header/footer map
1693                 {
1694                     SvxSetItem aNewFooter( (const SvxSetItem&)rSet.Get(ATTR_PAGE_FOOTERSET) );
1695                     if (pValue)
1696                         pPropSet->setPropertyValue( *pFooterEntry, *pValue, aNewFooter.GetItemSet() );
1697                     else
1698                         aNewFooter.GetItemSet().ClearItem( pFooterEntry->nWID );
1699                     rSet.Put( aNewFooter );
1700                     bDone = sal_True;
1701                 }
1702             }
1703         }
1704         if (!bDone)
1705         {
1706             if ( pEntry )
1707             {
1708                 if ( IsScItemWid( pEntry->nWID ) )
1709                 {
1710                     if (pValue)
1711                     {
1712                         switch ( pEntry->nWID )     // fuer Item-Spezial-Behandlungen
1713                         {
1714                             case ATTR_VALUE_FORMAT:
1715                                 {
1716                                     // #67847# language for number formats
1717                                     SvNumberFormatter* pFormatter =
1718                                             pDocShell->GetDocument()->GetFormatTable();
1719                                     sal_uInt32 nOldFormat = ((const SfxUInt32Item&)
1720                                             rSet.Get( ATTR_VALUE_FORMAT )).GetValue();
1721                                     LanguageType eOldLang = ((const SvxLanguageItem&)
1722                                             rSet.Get( ATTR_LANGUAGE_FORMAT )).GetLanguage();
1723                                     nOldFormat = pFormatter->
1724                                             GetFormatForLanguageIfBuiltIn( nOldFormat, eOldLang );
1725 
1726                                     sal_uInt32 nNewFormat = 0;
1727                                     *pValue >>= nNewFormat;
1728                                     rSet.Put( SfxUInt32Item( ATTR_VALUE_FORMAT, nNewFormat ) );
1729 
1730                                     const SvNumberformat* pNewEntry = pFormatter->GetEntry( nNewFormat );
1731                                     LanguageType eNewLang =
1732                                         pNewEntry ? pNewEntry->GetLanguage() : LANGUAGE_DONTKNOW;
1733                                     if ( eNewLang != eOldLang && eNewLang != LANGUAGE_DONTKNOW )
1734                                         rSet.Put( SvxLanguageItem( eNewLang, ATTR_LANGUAGE_FORMAT ) );
1735 
1736                                     //! keep default state of number format if only language changed?
1737                                 }
1738                                 break;
1739                             case ATTR_INDENT:
1740                                 {
1741                                     sal_Int16 nVal = 0;
1742                                     *pValue >>= nVal;
1743                                     rSet.Put( SfxUInt16Item( pEntry->nWID, (sal_uInt16)HMMToTwips(nVal) ) );
1744                                 }
1745                                 break;
1746                             case ATTR_ROTATE_VALUE:
1747                                 {
1748                                     sal_Int32 nRotVal = 0;
1749                                     if ( *pValue >>= nRotVal )
1750                                     {
1751                                         //  stored value is always between 0 and 360 deg.
1752                                         nRotVal %= 36000;
1753                                         if ( nRotVal < 0 )
1754                                             nRotVal += 36000;
1755                                         rSet.Put( SfxInt32Item( ATTR_ROTATE_VALUE, nRotVal ) );
1756                                     }
1757                                 }
1758                                 break;
1759                             case ATTR_STACKED:
1760                                 {
1761                                     table::CellOrientation eOrient;
1762                                     if( *pValue >>= eOrient )
1763                                     {
1764                                         switch( eOrient )
1765                                         {
1766                                             case table::CellOrientation_STANDARD:
1767                                                 rSet.Put( SfxBoolItem( ATTR_STACKED, sal_False ) );
1768                                             break;
1769                                             case table::CellOrientation_TOPBOTTOM:
1770                                                 rSet.Put( SfxBoolItem( ATTR_STACKED, sal_False ) );
1771                                                 rSet.Put( SfxInt32Item( ATTR_ROTATE_VALUE, 27000 ) );
1772                                             break;
1773                                             case table::CellOrientation_BOTTOMTOP:
1774                                                 rSet.Put( SfxBoolItem( ATTR_STACKED, sal_False ) );
1775                                                 rSet.Put( SfxInt32Item( ATTR_ROTATE_VALUE, 9000 ) );
1776                                             break;
1777                                             case table::CellOrientation_STACKED:
1778                                                 rSet.Put( SfxBoolItem( ATTR_STACKED, sal_True ) );
1779                                             break;
1780                                             default:
1781                                             {
1782                                                 // added to avoid warnings
1783                                             }
1784                                         }
1785                                     }
1786                                 }
1787                                 break;
1788                             case ATTR_PAGE_SCALE:
1789                             case ATTR_PAGE_SCALETOPAGES:
1790                                 {
1791                                     rSet.ClearItem(ATTR_PAGE_SCALETOPAGES);
1792                                     rSet.ClearItem(ATTR_PAGE_SCALE);
1793                                     rSet.ClearItem(ATTR_PAGE_SCALETO);
1794                                     sal_Int16 nVal = 0;
1795                                     *pValue >>= nVal;
1796                                     rSet.Put( SfxUInt16Item( pEntry->nWID, nVal ) );
1797                                 }
1798                                 break;
1799                             case ATTR_PAGE_FIRSTPAGENO:
1800                                 {
1801                                     sal_Int16 nVal = 0;
1802                                     *pValue >>= nVal;
1803                                     rSet.Put( SfxUInt16Item( ATTR_PAGE_FIRSTPAGENO, nVal ) );
1804                                 }
1805                                 break;
1806                             case ATTR_PAGE_CHARTS:
1807                             case ATTR_PAGE_OBJECTS:
1808                             case ATTR_PAGE_DRAWINGS:
1809                                 {
1810                                     sal_Bool bBool = sal_False;
1811                                     *pValue >>= bBool;
1812                                     //! sal_Bool-MID fuer ScViewObjectModeItem definieren?
1813                                     rSet.Put( ScViewObjectModeItem( pEntry->nWID,
1814                                         bBool ? VOBJ_MODE_SHOW : VOBJ_MODE_HIDE ) );
1815                                 }
1816                                 break;
1817                             case ATTR_PAGE_PAPERBIN:
1818                                 {
1819                                     sal_uInt8 nTray = PAPERBIN_PRINTER_SETTINGS;
1820                                     sal_Bool bFound = sal_False;
1821 
1822                                     rtl::OUString aName;
1823                                     if ( *pValue >>= aName )
1824                                     {
1825                                         if ( aName.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( SC_PAPERBIN_DEFAULTNAME ) ) )
1826                                             bFound = sal_True;
1827                                         else
1828                                         {
1829                                             Printer* pPrinter = pDocShell->GetPrinter();
1830                                             if (pPrinter)
1831                                             {
1832                                                 String aNameStr = aName;
1833                                                 sal_uInt16 nCount = pPrinter->GetPaperBinCount();
1834                                                 for (sal_uInt16 i=0; i<nCount; i++)
1835                                                     if ( aNameStr == pPrinter->GetPaperBinName(i) )
1836                                                     {
1837                                                         nTray = (sal_uInt8) i;
1838                                                         bFound = sal_True;
1839                                                         break;
1840                                                     }
1841                                             }
1842                                         }
1843                                     }
1844                                     if ( bFound )
1845                                         rSet.Put( SvxPaperBinItem( ATTR_PAGE_PAPERBIN, nTray ) );
1846                                     else
1847                                         throw lang::IllegalArgumentException();
1848                                 }
1849                                 break;
1850                             case ATTR_PAGE_SCALETO:
1851                                 {
1852                                     sal_Int16 nPages = 0;
1853                                     if (*pValue >>= nPages)
1854                                     {
1855                                         ScPageScaleToItem aItem = ((const ScPageScaleToItem&)rSet.Get(ATTR_PAGE_SCALETO));
1856                                         if ( rPropertyName.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM ( SC_UNO_PAGE_SCALETOX)))
1857                                             aItem.SetWidth(static_cast<sal_uInt16>(nPages));
1858                                         else
1859                                             aItem.SetHeight(static_cast<sal_uInt16>(nPages));
1860                                         rSet.Put( aItem );
1861                                         rSet.ClearItem(ATTR_PAGE_SCALETOPAGES);
1862                                         rSet.ClearItem(ATTR_PAGE_SCALE);
1863                                     }
1864                                 }
1865                                 break;
1866                             default:
1867                                 //  #65253# Default-Items mit falscher Slot-ID
1868                                 //  funktionieren im SfxItemPropertySet3 nicht
1869                                 //! Slot-IDs aendern...
1870                                 if ( rSet.GetPool()->GetSlotId(pEntry->nWID) == pEntry->nWID &&
1871                                      rSet.GetItemState(pEntry->nWID, sal_False) == SFX_ITEM_DEFAULT )
1872                                 {
1873                                     rSet.Put( rSet.Get(pEntry->nWID) );
1874                                 }
1875                                 pPropSet->setPropertyValue( *pEntry, *pValue, rSet );
1876                         }
1877                     }
1878                     else
1879                     {
1880                         rSet.ClearItem( pEntry->nWID );
1881                         // #67847# language for number formats
1882                         if ( pEntry->nWID == ATTR_VALUE_FORMAT )
1883                             rSet.ClearItem( ATTR_LANGUAGE_FORMAT );
1884 
1885                         //! for ATTR_ROTATE_VALUE, also reset ATTR_ORIENTATION?
1886                     }
1887                 }
1888                 else if ( IsScUnoWid( pEntry->nWID ) )
1889                 {
1890                     switch ( pEntry->nWID )
1891                     {
1892                         case SC_WID_UNO_TBLBORD:
1893                             {
1894                                 if (pValue)
1895                                 {
1896                                     table::TableBorder aBorder;
1897                                     if ( *pValue >>= aBorder )
1898                                     {
1899                                         SvxBoxItem aOuter( ATTR_BORDER );
1900                                         SvxBoxInfoItem aInner( ATTR_BORDER_INNER );
1901                                         ScHelperFunctions::FillBoxItems( aOuter, aInner, aBorder );
1902                                         rSet.Put( aOuter );
1903                                     }
1904                                 }
1905                                 else
1906                                 {
1907                                     rSet.ClearItem( ATTR_BORDER );
1908                                 }
1909                             }
1910                             break;
1911                     }
1912                 }
1913             }
1914         }
1915 
1916         if(SFX_STYLE_FAMILY_PARA != eFamily)
1917         {
1918             //! ModifyStyleSheet am Dokument (alte Werte merken)
1919 
1920             pDocShell->PageStyleModified( aStyleName, sal_True );
1921         }
1922     }
1923 }
1924 
StyleSheetChangedUpdate()1925 bool ScStyleObj::StyleSheetChangedUpdate()
1926 {
1927     SfxStyleSheetBase* pStyle = GetStyle_Impl();
1928 
1929     if(pStyle)
1930     {
1931         //! DocFunc-Funktion??
1932         //! Undo ?????????????
1933 
1934         if(SFX_STYLE_FAMILY_PARA == eFamily)
1935         {
1936             // adapt line heights
1937             VirtualDevice aVDev;
1938             const Point aLogic(aVDev.LogicToPixel(Point(1000,1000), MAP_TWIP));
1939             const double nPPTX(aLogic.X() / 1000.0);
1940             const double nPPTY(aLogic.Y() / 1000.0);
1941             const Fraction aZoom(1,1);
1942             ScDocument* pDoc = pDocShell->GetDocument();
1943 
1944             pDoc->StyleSheetChanged(pStyle, sal_False, &aVDev, nPPTX, nPPTY, aZoom, aZoom);
1945             pDocShell->PostPaint(0,0,0, MAXCOL,MAXROW,MAXTAB, PAINT_GRID|PAINT_LEFT);
1946             pDocShell->SetDocumentModified();
1947         }
1948 
1949         return true;
1950     }
1951 
1952     return false;
1953 }
1954 
getPropertyValue(const rtl::OUString & aPropertyName)1955 uno::Any SAL_CALL ScStyleObj::getPropertyValue( const rtl::OUString& aPropertyName )
1956 {
1957     ScUnoGuard aGuard;
1958     uno::Any aAny;
1959 
1960     if ( aPropertyName.equalsAscii( SC_UNONAME_DISPNAME ) )      // read-only
1961     {
1962         //  core always has the display name
1963         SfxStyleSheetBase* pStyle = GetStyle_Impl();
1964         if (pStyle)
1965             aAny <<= rtl::OUString( pStyle->GetName() );
1966     }
1967     else
1968     {
1969         const SfxItemPropertySimpleEntry* pResultEntry = NULL;
1970         const SfxItemSet* pItemSet = GetStyleItemSet_Impl( aPropertyName, pResultEntry );
1971 
1972         if ( pItemSet && pResultEntry )
1973         {
1974             sal_uInt16 nWhich = pResultEntry->nWID;
1975 
1976             if ( IsScItemWid( nWhich ) )
1977             {
1978                 switch ( nWhich )       // fuer Item-Spezial-Behandlungen
1979                 {
1980                     case ATTR_VALUE_FORMAT:
1981                         if ( pDocShell )
1982                         {
1983                             sal_uInt32 nOldFormat = ((const SfxUInt32Item&)
1984                                     pItemSet->Get( ATTR_VALUE_FORMAT )).GetValue();
1985                             LanguageType eOldLang = ((const SvxLanguageItem&)
1986                                     pItemSet->Get( ATTR_LANGUAGE_FORMAT )).GetLanguage();
1987                             nOldFormat = pDocShell->GetDocument()->GetFormatTable()->
1988                                     GetFormatForLanguageIfBuiltIn( nOldFormat, eOldLang );
1989                             aAny <<= nOldFormat;
1990                         }
1991                         break;
1992                     case ATTR_INDENT:
1993                         aAny <<= sal_Int16( TwipsToHMM(((const SfxUInt16Item&)
1994                                         pItemSet->Get(nWhich)).GetValue()) );
1995                         break;
1996                     case ATTR_STACKED:
1997                         {
1998                             sal_Int32 nRot = ((const SfxInt32Item&)pItemSet->Get(ATTR_ROTATE_VALUE)).GetValue();
1999                             sal_Bool bStacked = ((const SfxBoolItem&)pItemSet->Get(nWhich)).GetValue();
2000                             SvxOrientationItem( nRot, bStacked, 0 ).QueryValue( aAny );
2001                         }
2002                         break;
2003                     case ATTR_PAGE_SCALE:
2004                     case ATTR_PAGE_SCALETOPAGES:
2005                     case ATTR_PAGE_FIRSTPAGENO:
2006                         aAny <<= sal_Int16( ((const SfxUInt16Item&)pItemSet->Get(nWhich)).GetValue() );
2007                         break;
2008                     case ATTR_PAGE_CHARTS:
2009                     case ATTR_PAGE_OBJECTS:
2010                     case ATTR_PAGE_DRAWINGS:
2011                         //! sal_Bool-MID fuer ScViewObjectModeItem definieren?
2012                         aAny <<= sal_Bool( ((const ScViewObjectModeItem&)pItemSet->
2013                                         Get(nWhich)).GetValue() == VOBJ_MODE_SHOW );
2014                         break;
2015                     case ATTR_PAGE_PAPERBIN:
2016                         {
2017                             // property PrinterPaperTray is the name of the tray
2018 
2019                             sal_uInt8 nValue = ((const SvxPaperBinItem&)pItemSet->Get(nWhich)).GetValue();
2020                             rtl::OUString aName;
2021                             if ( nValue == PAPERBIN_PRINTER_SETTINGS )
2022                                 aName = rtl::OUString::createFromAscii( SC_PAPERBIN_DEFAULTNAME );
2023                             else
2024                             {
2025                                 Printer* pPrinter = pDocShell->GetPrinter();
2026                                 if (pPrinter)
2027                                     aName = pPrinter->GetPaperBinName( nValue );
2028                             }
2029                             aAny <<= aName;
2030                         }
2031                         break;
2032                     case ATTR_PAGE_SCALETO:
2033                         {
2034                             ScPageScaleToItem aItem((const ScPageScaleToItem&)pItemSet->Get(ATTR_PAGE_SCALETO));
2035                             if (aPropertyName.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM ( SC_UNO_PAGE_SCALETOX)))
2036                                 aAny = uno::makeAny(static_cast<sal_Int16>(aItem.GetWidth()));
2037                             else
2038                                 aAny = uno::makeAny(static_cast<sal_Int16>(aItem.GetHeight()));
2039                         }
2040                         break;
2041                     default:
2042                         //  #65253# Default-Items mit falscher Slot-ID
2043                         //  funktionieren im SfxItemPropertySet3 nicht
2044                         //! Slot-IDs aendern...
2045                         if ( pItemSet->GetPool()->GetSlotId(nWhich) == nWhich &&
2046                              pItemSet->GetItemState(nWhich, sal_False) == SFX_ITEM_DEFAULT )
2047                         {
2048                             SfxItemSet aNoEmptySet( *pItemSet );
2049                             aNoEmptySet.Put( aNoEmptySet.Get( nWhich ) );
2050                             pPropSet->getPropertyValue( *pResultEntry, aNoEmptySet, aAny );
2051                         }
2052                         else
2053                             pPropSet->getPropertyValue( *pResultEntry, *pItemSet, aAny );
2054                 }
2055             }
2056             else if ( IsScUnoWid( nWhich ) )
2057             {
2058                 switch ( nWhich )
2059                 {
2060                     case SC_WID_UNO_TBLBORD:
2061                         {
2062                             const SfxPoolItem* pItem = &pItemSet->Get( ATTR_BORDER );
2063                             if ( pItem )
2064                             {
2065                                 SvxBoxItem aOuter( *( static_cast<const SvxBoxItem*>( pItem ) ) );
2066                                 SvxBoxInfoItem aInner( ATTR_BORDER_INNER );
2067                                 table::TableBorder aBorder;
2068                                 ScHelperFunctions::FillTableBorder( aBorder, aOuter, aInner );
2069                                 aBorder.IsHorizontalLineValid = sal_False;
2070                                 aBorder.IsVerticalLineValid = sal_False;
2071                                 aBorder.IsDistanceValid = sal_False;
2072                                 aAny <<= aBorder;
2073                             }
2074                         }
2075                         break;
2076                 }
2077             }
2078         }
2079     }
2080 
2081     return aAny;
2082 }
2083 
SC_IMPL_DUMMY_PROPERTY_LISTENER(ScStyleObj)2084 SC_IMPL_DUMMY_PROPERTY_LISTENER( ScStyleObj )
2085 
2086 // lang::XServiceInfo
2087 
2088 rtl::OUString SAL_CALL ScStyleObj::getImplementationName()
2089 {
2090     return rtl::OUString::createFromAscii( "ScStyleObj" );
2091 }
2092 
supportsService(const rtl::OUString & rServiceName)2093 sal_Bool SAL_CALL ScStyleObj::supportsService( const rtl::OUString& rServiceName )
2094 {
2095     sal_Bool bPage = ( eFamily == SFX_STYLE_FAMILY_PAGE );
2096     return rServiceName.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM ( SCSTYLE_SERVICE ) )||
2097            rServiceName.equalsAsciiL(
2098             RTL_CONSTASCII_STRINGPARAM ( bPage ? SCPAGESTYLE_SERVICE : SCCELLSTYLE_SERVICE ));
2099 }
2100 
getSupportedServiceNames()2101 uno::Sequence<rtl::OUString> SAL_CALL ScStyleObj::getSupportedServiceNames()
2102 {
2103     sal_Bool bPage = ( eFamily == SFX_STYLE_FAMILY_PAGE );
2104     uno::Sequence<rtl::OUString> aRet(2);
2105     rtl::OUString* pArray = aRet.getArray();
2106     pArray[0] = rtl::OUString::createFromAscii( SCSTYLE_SERVICE );
2107     pArray[1] = rtl::OUString::createFromAscii( bPage ? SCPAGESTYLE_SERVICE
2108                                                       : SCCELLSTYLE_SERVICE );
2109     return aRet;
2110 }
2111 
2112 //------------------------------------------------------------------------
2113