xref: /AOO41X/main/sc/source/ui/unoobj/styleuno.cxx (revision caf44ce1e4f3f1fdb78689037f2ae93dda60bade)
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() throw(uno::RuntimeException)
617 {
618     return SC_STYLE_FAMILY_COUNT;
619 }
620 
getByIndex(sal_Int32 nIndex)621 uno::Any SAL_CALL ScStyleFamiliesObj::getByIndex( sal_Int32 nIndex )
622                             throw(lang::IndexOutOfBoundsException,
623                                     lang::WrappedTargetException, uno::RuntimeException)
624 {
625     ScUnoGuard aGuard;
626     uno::Reference< container::XNameContainer >  xFamily(GetObjectByIndex_Impl(nIndex));
627     if (xFamily.is())
628         return uno::makeAny(xFamily);
629     else
630         throw lang::IndexOutOfBoundsException();
631 //    return uno::Any();
632 }
633 
getElementType()634 uno::Type SAL_CALL ScStyleFamiliesObj::getElementType() throw(uno::RuntimeException)
635 {
636     ScUnoGuard aGuard;
637     return ::getCppuType((const uno::Reference< container::XNameContainer >*)0);    // muss zu getByIndex passen
638 }
639 
hasElements()640 sal_Bool SAL_CALL ScStyleFamiliesObj::hasElements() throw(uno::RuntimeException)
641 {
642     ScUnoGuard aGuard;
643     return ( getCount() != 0 );
644 }
645 
646 // container::XNameAccess
647 
getByName(const rtl::OUString & aName)648 uno::Any SAL_CALL ScStyleFamiliesObj::getByName( const rtl::OUString& aName )
649                     throw(container::NoSuchElementException,
650                         lang::WrappedTargetException, uno::RuntimeException)
651 {
652     ScUnoGuard aGuard;
653     uno::Reference< container::XNameContainer >  xFamily(GetObjectByName_Impl(aName));
654     if (xFamily.is())
655         return uno::makeAny(xFamily);
656     else
657         throw container::NoSuchElementException();
658 //    return uno::Any();
659 }
660 
getElementNames()661 uno::Sequence<rtl::OUString> SAL_CALL ScStyleFamiliesObj::getElementNames()
662                                                 throw(uno::RuntimeException)
663 {
664     ScUnoGuard aGuard;
665     uno::Sequence<rtl::OUString> aNames(SC_STYLE_FAMILY_COUNT);
666     rtl::OUString* pNames = aNames.getArray();
667     pNames[0] = rtl::OUString::createFromAscii( SC_FAMILYNAME_CELL );
668     pNames[1] = rtl::OUString::createFromAscii( SC_FAMILYNAME_PAGE );
669     return aNames;
670 }
671 
hasByName(const rtl::OUString & aName)672 sal_Bool SAL_CALL ScStyleFamiliesObj::hasByName( const rtl::OUString& aName )
673                                         throw(uno::RuntimeException)
674 {
675     ScUnoGuard aGuard;
676     String aNameStr( aName );
677     return ( aNameStr.EqualsAscii( SC_FAMILYNAME_CELL ) || aNameStr.EqualsAscii( SC_FAMILYNAME_PAGE ) );
678 }
679 
680 // style::XStyleLoader
681 
loadStylesFromURL(const rtl::OUString & aURL,const uno::Sequence<beans::PropertyValue> & aOptions)682 void SAL_CALL ScStyleFamiliesObj::loadStylesFromURL( const rtl::OUString& aURL,
683                         const uno::Sequence<beans::PropertyValue>& aOptions )
684                                 throw(io::IOException, uno::RuntimeException)
685 {
686     //! use aOptions (like Writer)
687     //! set flag to disable filter option dialogs when importing
688 
689     String aFilter;     // empty - detect
690     String aFiltOpt;
691     ScDocumentLoader aLoader( aURL, aFilter, aFiltOpt );
692 
693     ScDocShell* pSource = aLoader.GetDocShell();
694     if ( pSource && pDocShell )
695     {
696         //  collect options
697 
698         sal_Bool bLoadReplace = sal_True;           // defaults
699         sal_Bool bLoadCellStyles = sal_True;
700         sal_Bool bLoadPageStyles = sal_True;
701 
702         const beans::PropertyValue* pPropArray = aOptions.getConstArray();
703         long nPropCount = aOptions.getLength();
704         for (long i = 0; i < nPropCount; i++)
705         {
706             const beans::PropertyValue& rProp = pPropArray[i];
707             String aPropName(rProp.Name);
708 
709             if (aPropName.EqualsAscii( SC_UNONAME_OVERWSTL ))
710                 bLoadReplace = ScUnoHelpFunctions::GetBoolFromAny( rProp.Value );
711             else if (aPropName.EqualsAscii( SC_UNONAME_LOADCELL ))
712                 bLoadCellStyles = ScUnoHelpFunctions::GetBoolFromAny( rProp.Value );
713             else if (aPropName.EqualsAscii( SC_UNONAME_LOADPAGE ))
714                 bLoadPageStyles = ScUnoHelpFunctions::GetBoolFromAny( rProp.Value );
715         }
716 
717         pDocShell->LoadStylesArgs( *pSource, bLoadReplace, bLoadCellStyles, bLoadPageStyles );
718         pDocShell->SetDocumentModified();   // paint is inside LoadStyles
719     }
720 }
721 
getStyleLoaderOptions()722 uno::Sequence<beans::PropertyValue> SAL_CALL ScStyleFamiliesObj::getStyleLoaderOptions()
723                                                 throw(uno::RuntimeException)
724 {
725     //  return defaults for options (?)
726 
727     uno::Sequence<beans::PropertyValue> aSequence(3);
728     beans::PropertyValue* pArray = aSequence.getArray();
729 
730     pArray[0].Name = rtl::OUString::createFromAscii( SC_UNONAME_OVERWSTL );
731     ScUnoHelpFunctions::SetBoolInAny( pArray[0].Value, sal_True );
732 
733     pArray[1].Name = rtl::OUString::createFromAscii( SC_UNONAME_LOADCELL );
734     ScUnoHelpFunctions::SetBoolInAny( pArray[1].Value, sal_True );
735 
736     pArray[2].Name = rtl::OUString::createFromAscii( SC_UNONAME_LOADPAGE );
737     ScUnoHelpFunctions::SetBoolInAny( pArray[2].Value, sal_True );
738 
739     return aSequence;
740 }
741 
742 //------------------------------------------------------------------------
743 
ScStyleFamilyObj(ScDocShell * pDocSh,SfxStyleFamily eFam)744 ScStyleFamilyObj::ScStyleFamilyObj(ScDocShell* pDocSh, SfxStyleFamily eFam) :
745     pDocShell( pDocSh ),
746     eFamily( eFam )
747 {
748     pDocShell->GetDocument()->AddUnoObject(*this);
749 }
750 
~ScStyleFamilyObj()751 ScStyleFamilyObj::~ScStyleFamilyObj()
752 {
753     if (pDocShell)
754         pDocShell->GetDocument()->RemoveUnoObject(*this);
755 }
756 
Notify(SfxBroadcaster &,const SfxHint & rHint)757 void ScStyleFamilyObj::Notify( SfxBroadcaster&, const SfxHint& rHint )
758 {
759     //  Referenz-Update interessiert hier nicht
760 
761     if ( rHint.ISA( SfxSimpleHint ) &&
762             ((const SfxSimpleHint&)rHint).GetId() == SFX_HINT_DYING )
763     {
764         pDocShell = NULL;       // ungueltig geworden
765     }
766 }
767 
768 // XStyleFamily
769 
GetObjectByIndex_Impl(sal_uInt32 nIndex)770 ScStyleObj* ScStyleFamilyObj::GetObjectByIndex_Impl(sal_uInt32 nIndex)
771 {
772     if ( pDocShell )
773     {
774         ScDocument* pDoc = pDocShell->GetDocument();
775         ScStyleSheetPool* pStylePool = pDoc->GetStyleSheetPool();
776 
777         SfxStyleSheetIterator aIter( pStylePool, eFamily );
778         if ( nIndex < aIter.Count() )
779         {
780             SfxStyleSheetBase* pStyle = aIter[(sal_uInt16)nIndex];
781             if ( pStyle )
782             {
783                 return new ScStyleObj( pDocShell, eFamily, String (pStyle->GetName()) );
784             }
785         }
786     }
787     return NULL;
788 }
789 
GetObjectByName_Impl(const rtl::OUString & aName)790 ScStyleObj* ScStyleFamilyObj::GetObjectByName_Impl(const rtl::OUString& aName)
791 {
792     if ( pDocShell )
793     {
794         String aString(aName);
795 
796         ScDocument* pDoc = pDocShell->GetDocument();
797         ScStyleSheetPool* pStylePool = pDoc->GetStyleSheetPool();
798         if ( pStylePool->Find( aString, eFamily ) )
799             return new ScStyleObj( pDocShell, eFamily, aString );
800     }
801     return NULL;
802 }
803 
insertByName(const rtl::OUString & aName,const uno::Any & aElement)804 void SAL_CALL ScStyleFamilyObj::insertByName( const rtl::OUString& aName, const uno::Any& aElement )
805                             throw(lang::IllegalArgumentException, container::ElementExistException,
806                                     lang::WrappedTargetException, uno::RuntimeException)
807 {
808     ScUnoGuard aGuard;
809     sal_Bool bDone = sal_False;
810     //  Reflection muss nicht uno::XInterface sein, kann auch irgendein Interface sein...
811     uno::Reference< uno::XInterface > xInterface(aElement, uno::UNO_QUERY);
812     if ( xInterface.is() )
813     {
814         ScStyleObj* pStyleObj = ScStyleObj::getImplementation( xInterface );
815         if ( pStyleObj && pStyleObj->GetFamily() == eFamily &&
816                 !pStyleObj->IsInserted() )  // noch nicht eingefuegt?
817         {
818             String aNameStr(ScStyleNameConversion::ProgrammaticToDisplayName( aName, sal::static_int_cast<sal_uInt16>(eFamily) ));
819 
820             ScDocument* pDoc = pDocShell->GetDocument();
821             ScStyleSheetPool* pStylePool = pDoc->GetStyleSheetPool();
822 
823             //! DocFunc-Funktion??
824             //! Undo ?????????????
825 
826             if ( !pStylePool->Find( aNameStr, eFamily ) )   // noch nicht vorhanden
827             {
828                 (void)pStylePool->Make( aNameStr, eFamily, SFXSTYLEBIT_USERDEF );
829 
830                 if ( eFamily == SFX_STYLE_FAMILY_PARA && !pDoc->IsImportingXML() )
831                     pDoc->GetPool()->CellStyleCreated( aNameStr );
832 
833                 pStyleObj->InitDoc( pDocShell, aNameStr );  // Objekt kann benutzt werden
834 
835                 pDocShell->SetDocumentModified();   // verwendet wird der neue Style noch nicht
836                 bDone = sal_True;
837             }
838             else
839                 throw container::ElementExistException();
840         }
841     }
842 
843     if (!bDone)
844     {
845         //  other errors are handled above
846         throw lang::IllegalArgumentException();
847     }
848 }
849 
replaceByName(const rtl::OUString & aName,const uno::Any & aElement)850 void SAL_CALL ScStyleFamilyObj::replaceByName( const rtl::OUString& aName, const uno::Any& aElement )
851                             throw(lang::IllegalArgumentException, container::NoSuchElementException,
852                                     lang::WrappedTargetException, uno::RuntimeException)
853 {
854     ScUnoGuard aGuard;
855     //! zusammenfassen?
856     removeByName( aName );
857     insertByName( aName, aElement );
858 }
859 
removeByName(const rtl::OUString & aName)860 void SAL_CALL ScStyleFamilyObj::removeByName( const rtl::OUString& aName )
861                                 throw(container::NoSuchElementException,
862                                     lang::WrappedTargetException, uno::RuntimeException)
863 {
864     ScUnoGuard aGuard;
865     sal_Bool bFound = sal_False;
866     if ( pDocShell )
867     {
868         String aString(ScStyleNameConversion::ProgrammaticToDisplayName( aName, sal::static_int_cast<sal_uInt16>(eFamily) ));
869 
870         ScDocument* pDoc = pDocShell->GetDocument();
871         ScStyleSheetPool* pStylePool = pDoc->GetStyleSheetPool();
872 
873         //! DocFunc-Funktion??
874         //! Undo ?????????????
875 
876         SfxStyleSheetBase* pStyle = pStylePool->Find( aString, eFamily );
877         if (pStyle)
878         {
879             bFound = sal_True;
880             if ( eFamily == SFX_STYLE_FAMILY_PARA )
881             {
882                 // wie ScViewFunc::RemoveStyleSheetInUse
883                 VirtualDevice aVDev;
884                 Point aLogic = aVDev.LogicToPixel( Point(1000,1000), MAP_TWIP );
885                 double nPPTX = aLogic.X() / 1000.0;
886                 double nPPTY = aLogic.Y() / 1000.0;
887                 Fraction aZoom(1,1);
888                 pDoc->StyleSheetChanged( pStyle, sal_False, &aVDev, nPPTX, nPPTY, aZoom, aZoom );
889                 pDocShell->PostPaint( 0,0,0, MAXCOL,MAXROW,MAXTAB, PAINT_GRID|PAINT_LEFT );
890                 pDocShell->SetDocumentModified();
891 
892                 pStylePool->Remove( pStyle );
893 
894                 //! InvalidateAttribs();        // Bindings-Invalidate
895             }
896             else
897             {
898                 if ( pDoc->RemovePageStyleInUse( aString ) )
899                     pDocShell->PageStyleModified( ScGlobal::GetRscString(STR_STYLENAME_STANDARD), sal_True );
900 
901                 pStylePool->Remove( pStyle );
902 
903                 SfxBindings* pBindings = pDocShell->GetViewBindings();
904                 if (pBindings)
905                     pBindings->Invalidate( SID_STYLE_FAMILY4 );
906                 pDocShell->SetDocumentModified();
907             }
908         }
909     }
910 
911     if (!bFound)
912         throw container::NoSuchElementException();
913 }
914 
915 // container::XIndexAccess
916 
getCount()917 sal_Int32 SAL_CALL ScStyleFamilyObj::getCount() throw(uno::RuntimeException)
918 {
919     ScUnoGuard aGuard;
920     if ( pDocShell )
921     {
922         ScDocument* pDoc = pDocShell->GetDocument();
923         ScStyleSheetPool* pStylePool = pDoc->GetStyleSheetPool();
924 
925         SfxStyleSheetIterator aIter( pStylePool, eFamily );
926         return aIter.Count();
927     }
928     return 0;
929 }
930 
getByIndex(sal_Int32 nIndex)931 uno::Any SAL_CALL ScStyleFamilyObj::getByIndex( sal_Int32 nIndex )
932                             throw(lang::IndexOutOfBoundsException,
933                                     lang::WrappedTargetException, uno::RuntimeException)
934 {
935     ScUnoGuard aGuard;
936     uno::Reference< style::XStyle >  xObj(GetObjectByIndex_Impl(nIndex));
937     if (xObj.is())
938         return uno::makeAny(xObj);
939     else
940         throw lang::IndexOutOfBoundsException();
941 //    return uno::Any();
942 }
943 
getElementType()944 uno::Type SAL_CALL ScStyleFamilyObj::getElementType() throw(uno::RuntimeException)
945 {
946     ScUnoGuard aGuard;
947     return ::getCppuType((const uno::Reference< style::XStyle >*)0);    // muss zu getByIndex passen
948 }
949 
hasElements()950 sal_Bool SAL_CALL ScStyleFamilyObj::hasElements() throw(uno::RuntimeException)
951 {
952     ScUnoGuard aGuard;
953     return ( getCount() != 0 );
954 }
955 
956 // container::XNameAccess
957 
getByName(const rtl::OUString & aName)958 uno::Any SAL_CALL ScStyleFamilyObj::getByName( const rtl::OUString& aName )
959             throw(container::NoSuchElementException,
960                     lang::WrappedTargetException, uno::RuntimeException)
961 {
962     ScUnoGuard aGuard;
963     uno::Reference< style::XStyle > xObj(
964         GetObjectByName_Impl( ScStyleNameConversion::ProgrammaticToDisplayName( aName, sal::static_int_cast<sal_uInt16>(eFamily) ) ));
965     if (xObj.is())
966         return uno::makeAny(xObj);
967     else
968         throw container::NoSuchElementException();
969 //    return uno::Any();
970 }
971 
getElementNames()972 uno::Sequence<rtl::OUString> SAL_CALL ScStyleFamilyObj::getElementNames()
973                                                 throw(uno::RuntimeException)
974 {
975     ScUnoGuard aGuard;
976     if ( pDocShell )
977     {
978         ScDocument* pDoc = pDocShell->GetDocument();
979         ScStyleSheetPool* pStylePool = pDoc->GetStyleSheetPool();
980 
981         SfxStyleSheetIterator aIter( pStylePool, eFamily );
982         sal_uInt16 nCount = aIter.Count();
983 
984         String aName;
985         uno::Sequence<rtl::OUString> aSeq(nCount);
986         rtl::OUString* pAry = aSeq.getArray();
987         SfxStyleSheetBase* pStyle = aIter.First();
988         sal_uInt16 nPos = 0;
989         while (pStyle)
990         {
991             DBG_ASSERT( nPos<nCount, "Anzahl durcheinandergekommen" );
992             if (nPos<nCount)
993                 pAry[nPos++] = ScStyleNameConversion::DisplayToProgrammaticName(
994                                     pStyle->GetName(), sal::static_int_cast<sal_uInt16>(eFamily) );
995             pStyle = aIter.Next();
996         }
997         return aSeq;
998     }
999     return uno::Sequence<rtl::OUString>();
1000 }
1001 
hasByName(const rtl::OUString & aName)1002 sal_Bool SAL_CALL ScStyleFamilyObj::hasByName( const rtl::OUString& aName )
1003                                         throw(uno::RuntimeException)
1004 {
1005     ScUnoGuard aGuard;
1006     if ( pDocShell )
1007     {
1008         String aString(ScStyleNameConversion::ProgrammaticToDisplayName( aName, sal::static_int_cast<sal_uInt16>(eFamily) ));
1009 
1010         ScDocument* pDoc = pDocShell->GetDocument();
1011         ScStyleSheetPool* pStylePool = pDoc->GetStyleSheetPool();
1012         if ( pStylePool->Find( aString, eFamily ) )
1013             return sal_True;
1014     }
1015     return sal_False;
1016 }
1017 
1018 // XPropertySet
1019 
getPropertySetInfo()1020 uno::Reference< beans::XPropertySetInfo > SAL_CALL ScStyleFamilyObj::getPropertySetInfo(  ) throw (uno::RuntimeException)
1021 {
1022     OSL_ENSURE( 0, "###unexpected!" );
1023     return uno::Reference< beans::XPropertySetInfo >();
1024 }
1025 
setPropertyValue(const::rtl::OUString &,const uno::Any &)1026 void SAL_CALL ScStyleFamilyObj::setPropertyValue( const ::rtl::OUString&, const uno::Any& ) throw (beans::UnknownPropertyException, beans::PropertyVetoException, lang::IllegalArgumentException, lang::WrappedTargetException, uno::RuntimeException)
1027 {
1028     OSL_ENSURE( 0, "###unexpected!" );
1029 }
1030 
getPropertyValue(const::rtl::OUString & sPropertyName)1031 uno::Any SAL_CALL ScStyleFamilyObj::getPropertyValue( const ::rtl::OUString& sPropertyName ) throw (beans::UnknownPropertyException, lang::WrappedTargetException, uno::RuntimeException)
1032 {
1033     uno::Any aRet;
1034 
1035     if ( sPropertyName.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("DisplayName") ) )
1036     {
1037         ScUnoGuard aGuard;
1038         sal_uInt32 nResId = 0;
1039         switch ( eFamily )
1040         {
1041             case SFX_STYLE_FAMILY_PARA:
1042                 nResId = STR_STYLE_FAMILY_CELL; break;
1043             case SFX_STYLE_FAMILY_PAGE:
1044                 nResId = STR_STYLE_FAMILY_PAGE; break;
1045             default:
1046                 OSL_ENSURE( 0, "ScStyleFamilyObj::getPropertyValue(): invalid family" );
1047         }
1048         if ( nResId > 0 )
1049         {
1050             ::rtl::OUString sDisplayName( ScGlobal::GetRscString( static_cast< sal_uInt16 >( nResId ) ) );
1051             aRet = uno::makeAny( sDisplayName );
1052         }
1053     }
1054     else
1055     {
1056         throw beans::UnknownPropertyException( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("unknown property: ") ) + sPropertyName, static_cast<OWeakObject *>(this) );
1057     }
1058 
1059     return aRet;
1060 }
1061 
addPropertyChangeListener(const::rtl::OUString &,const uno::Reference<beans::XPropertyChangeListener> &)1062 void SAL_CALL ScStyleFamilyObj::addPropertyChangeListener( const ::rtl::OUString&, const uno::Reference< beans::XPropertyChangeListener >& ) throw (beans::UnknownPropertyException, lang::WrappedTargetException, uno::RuntimeException)
1063 {
1064     OSL_ENSURE( 0, "###unexpected!" );
1065 }
1066 
removePropertyChangeListener(const::rtl::OUString &,const uno::Reference<beans::XPropertyChangeListener> &)1067 void SAL_CALL ScStyleFamilyObj::removePropertyChangeListener( const ::rtl::OUString&, const uno::Reference< beans::XPropertyChangeListener >& ) throw (beans::UnknownPropertyException, lang::WrappedTargetException, uno::RuntimeException)
1068 {
1069     OSL_ENSURE( 0, "###unexpected!" );
1070 }
1071 
addVetoableChangeListener(const::rtl::OUString &,const uno::Reference<beans::XVetoableChangeListener> &)1072 void SAL_CALL ScStyleFamilyObj::addVetoableChangeListener( const ::rtl::OUString&, const uno::Reference< beans::XVetoableChangeListener >& ) throw (beans::UnknownPropertyException, lang::WrappedTargetException, uno::RuntimeException)
1073 {
1074     OSL_ENSURE( 0, "###unexpected!" );
1075 }
1076 
removeVetoableChangeListener(const::rtl::OUString &,const uno::Reference<beans::XVetoableChangeListener> &)1077 void SAL_CALL ScStyleFamilyObj::removeVetoableChangeListener( const ::rtl::OUString&, const uno::Reference< beans::XVetoableChangeListener >& ) throw (beans::UnknownPropertyException, lang::WrappedTargetException, uno::RuntimeException)
1078 {
1079     OSL_ENSURE( 0, "###unexpected!" );
1080 }
1081 
1082 //------------------------------------------------------------------------
1083 
1084 //  Default-ctor wird fuer die Reflection gebraucht
1085 
1086 //UNUSED2008-05  ScStyleObj::ScStyleObj() :
1087 //UNUSED2008-05  aPropSet( lcl_GetCellStyleMap() ),
1088 //UNUSED2008-05  pDocShell( NULL ),
1089 //UNUSED2008-05  eFamily( SFX_STYLE_FAMILY_PARA )
1090 //UNUSED2008-05  {
1091 //UNUSED2008-05  }
1092 
ScStyleObj(ScDocShell * pDocSh,SfxStyleFamily eFam,const String & rName)1093 ScStyleObj::ScStyleObj(ScDocShell* pDocSh, SfxStyleFamily eFam, const String& rName) :
1094     pPropSet( (eFam == SFX_STYLE_FAMILY_PARA) ? lcl_GetCellStyleSet() : lcl_GetPageStyleSet() ),
1095     pDocShell( pDocSh ),
1096     eFamily( eFam ),
1097     aStyleName( rName )
1098 {
1099     //  pDocShell ist Null, wenn per ServiceProvider erzeugt
1100 
1101     if (pDocShell)
1102         pDocShell->GetDocument()->AddUnoObject(*this);
1103 }
1104 
InitDoc(ScDocShell * pNewDocSh,const String & rNewName)1105 void ScStyleObj::InitDoc( ScDocShell* pNewDocSh, const String& rNewName )
1106 {
1107     if ( pNewDocSh && !pDocShell )
1108     {
1109         aStyleName = rNewName;
1110         pDocShell = pNewDocSh;
1111         pDocShell->GetDocument()->AddUnoObject(*this);
1112     }
1113 }
1114 
~ScStyleObj()1115 ScStyleObj::~ScStyleObj()
1116 {
1117     if (pDocShell)
1118         pDocShell->GetDocument()->RemoveUnoObject(*this);
1119 }
1120 
1121 // XUnoTunnel
1122 
getSomething(const uno::Sequence<sal_Int8> & rId)1123 sal_Int64 SAL_CALL ScStyleObj::getSomething(
1124                 const uno::Sequence<sal_Int8 >& rId ) throw(uno::RuntimeException)
1125 {
1126     if ( rId.getLength() == 16 &&
1127           0 == rtl_compareMemory( getUnoTunnelId().getConstArray(),
1128                                     rId.getConstArray(), 16 ) )
1129     {
1130         return sal::static_int_cast<sal_Int64>(reinterpret_cast<sal_IntPtr>(this));
1131     }
1132     return 0;
1133 }
1134 
1135 // static
getUnoTunnelId()1136 const uno::Sequence<sal_Int8>& ScStyleObj::getUnoTunnelId()
1137 {
1138     static uno::Sequence<sal_Int8> * pSeq = 0;
1139     if( !pSeq )
1140     {
1141         osl::Guard< osl::Mutex > aGuard( osl::Mutex::getGlobalMutex() );
1142         if( !pSeq )
1143         {
1144             static uno::Sequence< sal_Int8 > aSeq( 16 );
1145             rtl_createUuid( (sal_uInt8*)aSeq.getArray(), 0, sal_True );
1146             pSeq = &aSeq;
1147         }
1148     }
1149     return *pSeq;
1150 }
1151 
1152 // static
getImplementation(const uno::Reference<uno::XInterface> xObj)1153 ScStyleObj* ScStyleObj::getImplementation(
1154                         const uno::Reference<uno::XInterface> xObj )
1155 {
1156     ScStyleObj* pRet = NULL;
1157     uno::Reference<lang::XUnoTunnel> xUT( xObj, uno::UNO_QUERY );
1158     if (xUT.is())
1159         pRet = reinterpret_cast<ScStyleObj*>(sal::static_int_cast<sal_IntPtr>(xUT->getSomething(getUnoTunnelId())));
1160     return pRet;
1161 }
1162 
Notify(SfxBroadcaster &,const SfxHint & rHint)1163 void ScStyleObj::Notify( SfxBroadcaster&, const SfxHint& rHint )
1164 {
1165     //  Referenz-Update interessiert hier nicht
1166 
1167     if ( rHint.ISA( SfxSimpleHint ) &&
1168             ((const SfxSimpleHint&)rHint).GetId() == SFX_HINT_DYING )
1169     {
1170         pDocShell = NULL;       // ungueltig geworden
1171     }
1172 }
1173 
GetStyle_Impl()1174 SfxStyleSheetBase* ScStyleObj::GetStyle_Impl()
1175 {
1176     if ( pDocShell )
1177     {
1178         ScDocument* pDoc = pDocShell->GetDocument();
1179         ScStyleSheetPool* pStylePool = pDoc->GetStyleSheetPool();
1180         return pStylePool->Find( aStyleName, eFamily );
1181     }
1182     return NULL;
1183 }
1184 
1185 // style::XStyle
1186 
isUserDefined()1187 sal_Bool SAL_CALL ScStyleObj::isUserDefined() throw(uno::RuntimeException)
1188 {
1189     ScUnoGuard aGuard;
1190     SfxStyleSheetBase* pStyle = GetStyle_Impl();
1191     if (pStyle)
1192         return pStyle->IsUserDefined();
1193     return sal_False;
1194 }
1195 
isInUse()1196 sal_Bool SAL_CALL ScStyleObj::isInUse() throw(uno::RuntimeException)
1197 {
1198     ScUnoGuard aGuard;
1199     SfxStyleSheetBase* pStyle = GetStyle_Impl();
1200     if (pStyle)
1201         return pStyle->IsUsed();
1202     return sal_False;
1203 }
1204 
getParentStyle()1205 rtl::OUString SAL_CALL ScStyleObj::getParentStyle() throw(uno::RuntimeException)
1206 {
1207     ScUnoGuard aGuard;
1208     SfxStyleSheetBase* pStyle = GetStyle_Impl();
1209     if (pStyle)
1210         return ScStyleNameConversion::DisplayToProgrammaticName( pStyle->GetParent(), sal::static_int_cast<sal_uInt16>(eFamily) );
1211     return rtl::OUString();
1212 }
1213 
setParentStyle(const rtl::OUString & rParentStyle)1214 void SAL_CALL ScStyleObj::setParentStyle( const rtl::OUString& rParentStyle )
1215                 throw(container::NoSuchElementException, uno::RuntimeException)
1216 {
1217     ScUnoGuard aGuard;
1218     SfxStyleSheetBase* pStyle = GetStyle_Impl();
1219     if (pStyle)
1220     {
1221         //  #70909# cell styles cannot be modified if any sheet is protected
1222         if ( eFamily == SFX_STYLE_FAMILY_PARA && lcl_AnyTabProtected( *pDocShell->GetDocument() ) )
1223             return;         //! exception?
1224 
1225         //! DocFunc-Funktion??
1226         //! Undo ?????????????
1227 
1228         String aString(ScStyleNameConversion::ProgrammaticToDisplayName( rParentStyle, sal::static_int_cast<sal_uInt16>(eFamily) ));
1229         sal_Bool bOk = pStyle->SetParent( aString );
1230         if (bOk)
1231         {
1232             //  wie bei setPropertyValue
1233 
1234             ScDocument* pDoc = pDocShell->GetDocument();
1235             if ( eFamily == SFX_STYLE_FAMILY_PARA )
1236             {
1237                 //  Zeilenhoehen anpassen...
1238 
1239                 VirtualDevice aVDev;
1240                 Point aLogic = aVDev.LogicToPixel( Point(1000,1000), MAP_TWIP );
1241                 double nPPTX = aLogic.X() / 1000.0;
1242                 double nPPTY = aLogic.Y() / 1000.0;
1243                 Fraction aZoom(1,1);
1244                 pDoc->StyleSheetChanged( pStyle, sal_False, &aVDev, nPPTX, nPPTY, aZoom, aZoom );
1245 
1246                 pDocShell->PostPaint( 0,0,0, MAXCOL,MAXROW,MAXTAB, PAINT_GRID|PAINT_LEFT );
1247                 pDocShell->SetDocumentModified();
1248             }
1249             else
1250             {
1251                 //! ModifyStyleSheet am Dokument (alte Werte merken)
1252 
1253                 pDocShell->PageStyleModified( aStyleName, sal_True );
1254             }
1255         }
1256     }
1257 }
1258 
1259 // container::XNamed
1260 
getName()1261 rtl::OUString SAL_CALL ScStyleObj::getName() throw(uno::RuntimeException)
1262 {
1263     ScUnoGuard aGuard;
1264     SfxStyleSheetBase* pStyle = GetStyle_Impl();
1265     if (pStyle)
1266         return ScStyleNameConversion::DisplayToProgrammaticName( pStyle->GetName(), sal::static_int_cast<sal_uInt16>(eFamily) );
1267     return rtl::OUString();
1268 }
1269 
setName(const rtl::OUString & aNewName)1270 void SAL_CALL ScStyleObj::setName( const rtl::OUString& aNewName )
1271                                                 throw(uno::RuntimeException)
1272 {
1273     ScUnoGuard aGuard;
1274     SfxStyleSheetBase* pStyle = GetStyle_Impl();
1275     if (pStyle)
1276     {
1277         //  #71225# cell styles cannot be renamed if any sheet is protected
1278         if ( eFamily == SFX_STYLE_FAMILY_PARA && lcl_AnyTabProtected( *pDocShell->GetDocument() ) )
1279             return;         //! exception?
1280 
1281         //! DocFunc-Funktion??
1282         //! Undo ?????????????
1283 
1284         String aString(aNewName);
1285         sal_Bool bOk = pStyle->SetName( aString );
1286         if (bOk)
1287         {
1288             aStyleName = aString;       //! notify other objects for this style?
1289 
1290             ScDocument* pDoc = pDocShell->GetDocument();
1291             if ( eFamily == SFX_STYLE_FAMILY_PARA && !pDoc->IsImportingXML() )
1292                 pDoc->GetPool()->CellStyleCreated( aString );
1293 
1294             //  Zellvorlagen = 2, Seitenvorlagen = 4
1295             sal_uInt16 nId = ( eFamily == SFX_STYLE_FAMILY_PARA ) ?
1296                             SID_STYLE_FAMILY2 : SID_STYLE_FAMILY4;
1297             SfxBindings* pBindings = pDocShell->GetViewBindings();
1298             if (pBindings)
1299             {
1300                 pBindings->Invalidate( nId );
1301                 pBindings->Invalidate( SID_STYLE_APPLY );
1302             }
1303         }
1304     }
1305 }
1306 
1307 // static
CreateEmptyNumberingRules()1308 uno::Reference<container::XIndexReplace> ScStyleObj::CreateEmptyNumberingRules()
1309 {
1310     SvxNumRule aRule( 0, 0, sal_True );         // nothing supported
1311     return SvxCreateNumRule( &aRule );
1312 }
1313 
1314 // beans::XPropertyState
1315 
GetStyleItemSet_Impl(const::rtl::OUString & rPropName,const SfxItemPropertySimpleEntry * & rpResultEntry)1316 const SfxItemSet* ScStyleObj::GetStyleItemSet_Impl( const ::rtl::OUString& rPropName,
1317                                         const SfxItemPropertySimpleEntry*& rpResultEntry )
1318 {
1319     //! OUString as argument?
1320 
1321     SfxStyleSheetBase* pStyle = GetStyle_Impl();
1322     if (pStyle)
1323     {
1324         const SfxItemPropertySimpleEntry* pEntry = NULL;
1325         if ( eFamily == SFX_STYLE_FAMILY_PAGE )
1326         {
1327             pEntry = lcl_GetHeaderStyleMap()->getByName( rPropName );
1328             if ( pEntry )     // only item-wids in header/footer map
1329             {
1330                 rpResultEntry = pEntry;
1331                 return &((const SvxSetItem&)pStyle->GetItemSet().Get(ATTR_PAGE_HEADERSET)).GetItemSet();
1332             }
1333             pEntry = lcl_GetFooterStyleMap()->getByName( rPropName );
1334             if ( pEntry )      // only item-wids in header/footer map
1335             {
1336                 rpResultEntry = pEntry;
1337                 return &((const SvxSetItem&)pStyle->GetItemSet().Get(ATTR_PAGE_FOOTERSET)).GetItemSet();
1338             }
1339         }
1340         pEntry = pPropSet->getPropertyMap()->getByName( rPropName );
1341         if ( pEntry )
1342         {
1343             rpResultEntry = pEntry;
1344             return &pStyle->GetItemSet();
1345         }
1346     }
1347 
1348     rpResultEntry = NULL;
1349     return NULL;
1350 }
1351 
getPropertyState(const rtl::OUString & aPropertyName)1352 beans::PropertyState SAL_CALL ScStyleObj::getPropertyState( const rtl::OUString& aPropertyName )
1353                                 throw(beans::UnknownPropertyException, uno::RuntimeException)
1354 {
1355     ScUnoGuard aGuard;
1356     beans::PropertyState eRet = beans::PropertyState_DIRECT_VALUE;
1357 
1358     const SfxItemPropertySimpleEntry* pResultEntry = NULL;
1359     const SfxItemSet* pItemSet = GetStyleItemSet_Impl( aPropertyName, pResultEntry );
1360 
1361     if ( pItemSet && pResultEntry )
1362     {
1363         sal_uInt16 nWhich = pResultEntry->nWID;
1364         if ( nWhich == SC_WID_UNO_TBLBORD )
1365         {
1366             nWhich = ATTR_BORDER;
1367         }
1368         if ( IsScItemWid( nWhich ) )
1369         {
1370             SfxItemState eState = pItemSet->GetItemState( nWhich, sal_False );
1371 
1372 //           //  if no rotate value is set, look at orientation
1373 //           //! also for a fixed value of 0 (in case orientation is ambiguous)?
1374 //           if ( nWhich == ATTR_ROTATE_VALUE && eState == SFX_ITEM_DEFAULT )
1375 //               eState = pItemSet->GetItemState( ATTR_ORIENTATION, sal_False );
1376 
1377             if ( eState == SFX_ITEM_SET )
1378                 eRet = beans::PropertyState_DIRECT_VALUE;
1379             else if ( eState == SFX_ITEM_DEFAULT )
1380                 eRet = beans::PropertyState_DEFAULT_VALUE;
1381             else if ( eState == SFX_ITEM_DONTCARE )
1382                 eRet = beans::PropertyState_AMBIGUOUS_VALUE;    // kann eigentlich nicht sein...
1383             else
1384             {
1385                 DBG_ERROR("unbekannter ItemState");
1386             }
1387         }
1388     }
1389     return eRet;
1390 }
1391 
getPropertyStates(const uno::Sequence<rtl::OUString> & aPropertyNames)1392 uno::Sequence<beans::PropertyState> SAL_CALL ScStyleObj::getPropertyStates(
1393                             const uno::Sequence<rtl::OUString>& aPropertyNames )
1394                     throw(beans::UnknownPropertyException, uno::RuntimeException)
1395 {
1396     //  duemmliche Default-Implementierung: alles einzeln per getPropertyState holen
1397     //! sollte optimiert werden!
1398 
1399     ScUnoGuard aGuard;
1400     const rtl::OUString* pNames = aPropertyNames.getConstArray();
1401     uno::Sequence<beans::PropertyState> aRet(aPropertyNames.getLength());
1402     beans::PropertyState* pStates = aRet.getArray();
1403     for(sal_Int32 i = 0; i < aPropertyNames.getLength(); i++)
1404         pStates[i] = getPropertyState(pNames[i]);
1405     return aRet;
1406 }
1407 
setPropertyToDefault(const rtl::OUString & aPropertyName)1408 void SAL_CALL ScStyleObj::setPropertyToDefault( const rtl::OUString& aPropertyName )
1409                             throw(beans::UnknownPropertyException, uno::RuntimeException)
1410 {
1411     ScUnoGuard aGuard;
1412 
1413     const SfxItemPropertyMap* pMap = pPropSet->getPropertyMap();
1414     const SfxItemPropertySimpleEntry* pEntry = pMap->getByName( aPropertyName );
1415     if ( !pEntry )
1416         throw beans::UnknownPropertyException();
1417 
1418     SetOnePropertyValue( aPropertyName, pEntry, NULL );
1419 }
1420 
getPropertyDefault(const rtl::OUString & aPropertyName)1421 uno::Any SAL_CALL ScStyleObj::getPropertyDefault( const rtl::OUString& aPropertyName )
1422                             throw(beans::UnknownPropertyException, lang::WrappedTargetException,
1423                                     uno::RuntimeException)
1424 {
1425     ScUnoGuard aGuard;
1426     uno::Any aAny;
1427 
1428     const SfxItemPropertySimpleEntry* pResultEntry = NULL;
1429     const SfxItemSet* pStyleSet = GetStyleItemSet_Impl( aPropertyName, pResultEntry );
1430 
1431     if ( pStyleSet && pResultEntry )
1432     {
1433         sal_uInt16 nWhich = pResultEntry->nWID;
1434 
1435         if ( IsScItemWid( nWhich ) )
1436         {
1437             //  Default ist Default vom ItemPool, nicht vom Standard-Style,
1438             //  damit es zu setPropertyToDefault passt
1439             SfxItemSet aEmptySet( *pStyleSet->GetPool(), pStyleSet->GetRanges() );
1440             //  #65253# Default-Items mit falscher Slot-ID funktionieren im SfxItemPropertySet3 nicht
1441             //! Slot-IDs aendern...
1442             if ( aEmptySet.GetPool()->GetSlotId(nWhich) == nWhich &&
1443                  aEmptySet.GetItemState(nWhich, sal_False) == SFX_ITEM_DEFAULT )
1444             {
1445                 aEmptySet.Put( aEmptySet.Get( nWhich ) );
1446             }
1447             const SfxItemSet* pItemSet = &aEmptySet;
1448 
1449             switch ( nWhich )       // fuer Item-Spezial-Behandlungen
1450             {
1451                 case ATTR_VALUE_FORMAT:
1452                     //  default has no language set
1453                     aAny <<= sal_Int32( ((const SfxUInt32Item&)pItemSet->Get(nWhich)).GetValue() );
1454                     break;
1455                 case ATTR_INDENT:
1456                     aAny <<= sal_Int16( TwipsToHMM(((const SfxUInt16Item&)
1457                                     pItemSet->Get(nWhich)).GetValue()) );
1458                     break;
1459                 case ATTR_PAGE_SCALE:
1460                 case ATTR_PAGE_SCALETOPAGES:
1461                 case ATTR_PAGE_FIRSTPAGENO:
1462                     aAny <<= sal_Int16( ((const SfxUInt16Item&)pItemSet->Get(nWhich)).GetValue() );
1463                     break;
1464                 case ATTR_PAGE_CHARTS:
1465                 case ATTR_PAGE_OBJECTS:
1466                 case ATTR_PAGE_DRAWINGS:
1467                     //! sal_Bool-MID fuer ScViewObjectModeItem definieren?
1468                     aAny <<= sal_Bool( ((const ScViewObjectModeItem&)pItemSet->Get(nWhich)).
1469                                     GetValue() == VOBJ_MODE_SHOW );
1470                     break;
1471                 case ATTR_PAGE_SCALETO:
1472                     {
1473                         const ScPageScaleToItem aItem((const ScPageScaleToItem&)pItemSet->Get(nWhich));
1474                         if (aPropertyName.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM ( SC_UNO_PAGE_SCALETOX )))
1475                             aAny = uno::makeAny(static_cast<sal_Int16>(aItem.GetWidth()));
1476                         else
1477                             aAny = uno::makeAny(static_cast<sal_Int16>(aItem.GetHeight()));
1478                     }
1479                     break;
1480                 default:
1481                     pPropSet->getPropertyValue( *pResultEntry, *pItemSet, aAny );
1482             }
1483         }
1484         else if ( IsScUnoWid( nWhich ) )
1485         {
1486             SfxItemSet aEmptySet( *pStyleSet->GetPool(), pStyleSet->GetRanges() );
1487             const SfxItemSet* pItemSet = &aEmptySet;
1488             switch ( nWhich )
1489             {
1490                 case SC_WID_UNO_TBLBORD:
1491                     {
1492                         const SfxPoolItem* pItem = &pItemSet->Get( ATTR_BORDER );
1493                         if ( pItem )
1494                         {
1495                             SvxBoxItem aOuter( *( static_cast<const SvxBoxItem*>( pItem ) ) );
1496                             SvxBoxInfoItem aInner( ATTR_BORDER_INNER );
1497                             table::TableBorder aBorder;
1498                             ScHelperFunctions::FillTableBorder( aBorder, aOuter, aInner );
1499                             aBorder.IsHorizontalLineValid = sal_False;
1500                             aBorder.IsVerticalLineValid = sal_False;
1501                             aBorder.IsDistanceValid = sal_False;
1502                             aAny <<= aBorder;
1503                         }
1504                     }
1505                     break;
1506             }
1507         }
1508     }
1509     return aAny;
1510 }
1511 
1512 // XMultiPropertySet
1513 
setPropertyValues(const uno::Sequence<rtl::OUString> & aPropertyNames,const uno::Sequence<uno::Any> & aValues)1514 void SAL_CALL ScStyleObj::setPropertyValues( const uno::Sequence< rtl::OUString >& aPropertyNames,
1515                                                 const uno::Sequence< uno::Any >& aValues )
1516                                 throw (beans::PropertyVetoException, lang::IllegalArgumentException,
1517                                         lang::WrappedTargetException, uno::RuntimeException)
1518 {
1519     ScUnoGuard aGuard;
1520 
1521     sal_Int32 nCount = aPropertyNames.getLength();
1522     if ( aValues.getLength() != nCount )
1523         throw lang::IllegalArgumentException();
1524 
1525     if ( nCount )
1526     {
1527         const rtl::OUString* pNames = aPropertyNames.getConstArray();
1528         const uno::Any* pValues = aValues.getConstArray();
1529 
1530         const SfxItemPropertyMap* pPropertyMap = pPropSet->getPropertyMap();
1531         for (sal_Int32 i = 0; i < nCount; i++)
1532         {
1533             const SfxItemPropertySimpleEntry*  pEntry = pPropertyMap->getByName( pNames[i] );
1534 
1535             // enhance ODS load performance
1536             SetOnePropertyValueWithoutUpdate( pNames[i], pEntry, &pValues[i] );
1537         }
1538 
1539         // enhance ODS load performance
1540         StyleSheetChangedUpdate();
1541     }
1542 }
1543 
getPropertyValues(const uno::Sequence<rtl::OUString> & aPropertyNames)1544 uno::Sequence<uno::Any> SAL_CALL ScStyleObj::getPropertyValues(
1545                                     const uno::Sequence< rtl::OUString >& aPropertyNames )
1546                                 throw (uno::RuntimeException)
1547 {
1548     ScUnoGuard aGuard;
1549 
1550     //! optimize
1551 
1552     sal_Int32 nCount = aPropertyNames.getLength();
1553     uno::Sequence<uno::Any> aSequence( nCount );
1554     if ( nCount )
1555     {
1556         uno::Any* pValues = aSequence.getArray();
1557         for (sal_Int32 i=0; i<nCount; i++)
1558             pValues[i] = getPropertyValue( aPropertyNames[i] );
1559     }
1560     return aSequence;
1561 }
1562 
addPropertiesChangeListener(const uno::Sequence<rtl::OUString> &,const uno::Reference<beans::XPropertiesChangeListener> &)1563 void SAL_CALL ScStyleObj::addPropertiesChangeListener( const uno::Sequence<rtl::OUString>& /* aPropertyNames */,
1564                                     const uno::Reference<beans::XPropertiesChangeListener>& /* xListener */ )
1565                                 throw (uno::RuntimeException)
1566 {
1567     // no bound properties
1568 }
1569 
removePropertiesChangeListener(const uno::Reference<beans::XPropertiesChangeListener> &)1570 void SAL_CALL ScStyleObj::removePropertiesChangeListener(
1571                                     const uno::Reference<beans::XPropertiesChangeListener>& /* xListener */ )
1572                                 throw (uno::RuntimeException)
1573 {
1574     // no bound properties
1575 }
1576 
firePropertiesChangeEvent(const uno::Sequence<rtl::OUString> &,const uno::Reference<beans::XPropertiesChangeListener> &)1577 void SAL_CALL ScStyleObj::firePropertiesChangeEvent( const uno::Sequence<rtl::OUString>& /* aPropertyNames */,
1578                                     const uno::Reference<beans::XPropertiesChangeListener>& /* xListener */ )
1579                                 throw (uno::RuntimeException)
1580 {
1581     // no bound properties
1582 }
1583 
1584 // XMultiPropertyStates
1585 // getPropertyStates already defined for XPropertyState
1586 
setAllPropertiesToDefault()1587 void SAL_CALL ScStyleObj::setAllPropertiesToDefault() throw (uno::RuntimeException)
1588 {
1589     ScUnoGuard aGuard;
1590 
1591     SfxStyleSheetBase* pStyle = GetStyle_Impl();
1592     if ( pStyle )
1593     {
1594         //  #70909# cell styles cannot be modified if any sheet is protected
1595         if ( eFamily == SFX_STYLE_FAMILY_PARA && lcl_AnyTabProtected( *pDocShell->GetDocument() ) )
1596             throw uno::RuntimeException();
1597 
1598         SfxItemSet& rSet = pStyle->GetItemSet();
1599         rSet.ClearItem();                               // set all items to default
1600 
1601         //! merge with SetOneProperty
1602 
1603         ScDocument* pDoc = pDocShell->GetDocument();
1604         if ( eFamily == SFX_STYLE_FAMILY_PARA )
1605         {
1606             //  row heights
1607 
1608             VirtualDevice aVDev;
1609             Point aLogic = aVDev.LogicToPixel( Point(1000,1000), MAP_TWIP );
1610             double nPPTX = aLogic.X() / 1000.0;
1611             double nPPTY = aLogic.Y() / 1000.0;
1612             Fraction aZoom(1,1);
1613             pDoc->StyleSheetChanged( pStyle, sal_False, &aVDev, nPPTX, nPPTY, aZoom, aZoom );
1614 
1615             pDocShell->PostPaint( 0,0,0, MAXCOL,MAXROW,MAXTAB, PAINT_GRID|PAINT_LEFT );
1616             pDocShell->SetDocumentModified();
1617         }
1618         else
1619         {
1620             // #i22448# apply the default BoxInfoItem for page styles again
1621             // (same content as in ScStyleSheet::GetItemSet, to control the dialog)
1622             SvxBoxInfoItem aBoxInfoItem( ATTR_BORDER_INNER );
1623             aBoxInfoItem.SetTable( sal_False );
1624             aBoxInfoItem.SetDist( sal_True );
1625             aBoxInfoItem.SetValid( VALID_DISTANCE, sal_True );
1626             rSet.Put( aBoxInfoItem );
1627 
1628             pDocShell->PageStyleModified( aStyleName, sal_True );
1629         }
1630     }
1631 }
1632 
setPropertiesToDefault(const uno::Sequence<rtl::OUString> & aPropertyNames)1633 void SAL_CALL ScStyleObj::setPropertiesToDefault( const uno::Sequence<rtl::OUString>& aPropertyNames )
1634                                 throw (beans::UnknownPropertyException, uno::RuntimeException)
1635 {
1636     ScUnoGuard aGuard;
1637 
1638     sal_Int32 nCount = aPropertyNames.getLength();
1639     if ( nCount )
1640     {
1641         const rtl::OUString* pNames = aPropertyNames.getConstArray();
1642 
1643         const SfxItemPropertyMap* pPropertyMap = pPropSet->getPropertyMap();
1644         for (sal_Int32 i = 0; i < nCount; i++)
1645         {
1646             const SfxItemPropertySimpleEntry*  pEntry = pPropertyMap->getByName( pNames[i] );
1647             SetOnePropertyValue( pNames[i], pEntry, NULL );
1648         }
1649     }
1650 }
1651 
getPropertyDefaults(const uno::Sequence<rtl::OUString> & aPropertyNames)1652 uno::Sequence<uno::Any> SAL_CALL ScStyleObj::getPropertyDefaults(
1653                                 const uno::Sequence<rtl::OUString>& aPropertyNames )
1654                         throw (beans::UnknownPropertyException, lang::WrappedTargetException,
1655                                 uno::RuntimeException)
1656 {
1657     ScUnoGuard aGuard;
1658 
1659     //! optimize
1660 
1661     sal_Int32 nCount = aPropertyNames.getLength();
1662     uno::Sequence<uno::Any> aSequence( nCount );
1663     if ( nCount )
1664     {
1665         uno::Any* pValues = aSequence.getArray();
1666         for (sal_Int32 i=0; i<nCount; i++)
1667             pValues[i] = getPropertyDefault( aPropertyNames[i] );
1668     }
1669     return aSequence;
1670 }
1671 
1672 // beans::XPropertySet
1673 
getPropertySetInfo()1674 uno::Reference<beans::XPropertySetInfo> SAL_CALL ScStyleObj::getPropertySetInfo()
1675                                                         throw(uno::RuntimeException)
1676 {
1677     ScUnoGuard aGuard;
1678     return pPropSet->getPropertySetInfo();
1679 }
1680 
setPropertyValue(const rtl::OUString & aPropertyName,const uno::Any & aValue)1681 void SAL_CALL ScStyleObj::setPropertyValue(
1682                         const rtl::OUString& aPropertyName, const uno::Any& aValue )
1683                 throw(beans::UnknownPropertyException, beans::PropertyVetoException,
1684                         lang::IllegalArgumentException, lang::WrappedTargetException,
1685                         uno::RuntimeException)
1686 {
1687     ScUnoGuard aGuard;
1688 
1689     const SfxItemPropertySimpleEntry*  pEntry = pPropSet->getPropertyMap()->getByName( aPropertyName );
1690     if ( !pEntry )
1691         throw beans::UnknownPropertyException();
1692 
1693     SetOnePropertyValue( aPropertyName, pEntry, &aValue );
1694 }
1695 
SetOnePropertyValue(const::rtl::OUString & rPropertyName,const SfxItemPropertySimpleEntry * pEntry,const uno::Any * pValue)1696 void ScStyleObj::SetOnePropertyValue( const ::rtl::OUString& rPropertyName, const SfxItemPropertySimpleEntry* pEntry, const uno::Any* pValue )
1697                                 throw(lang::IllegalArgumentException, uno::RuntimeException)
1698 {
1699     SetOnePropertyValueWithoutUpdate(rPropertyName, pEntry, pValue);
1700     StyleSheetChangedUpdate();
1701 }
1702 
SetOnePropertyValueWithoutUpdate(const::rtl::OUString & rPropertyName,const SfxItemPropertySimpleEntry * pEntry,const uno::Any * pValue)1703 void ScStyleObj::SetOnePropertyValueWithoutUpdate( const ::rtl::OUString& rPropertyName, const SfxItemPropertySimpleEntry* pEntry, const uno::Any* pValue )
1704                                 throw(lang::IllegalArgumentException, uno::RuntimeException)
1705 {
1706     SfxStyleSheetBase* pStyle = GetStyle_Impl();
1707     if ( pStyle && pEntry )
1708     {
1709         //  #70909# cell styles cannot be modified if any sheet is protected
1710         if ( eFamily == SFX_STYLE_FAMILY_PARA && lcl_AnyTabProtected( *pDocShell->GetDocument() ) )
1711             throw uno::RuntimeException();
1712 
1713         SfxItemSet& rSet = pStyle->GetItemSet();    // direkt im lebenden Style aendern...
1714         sal_Bool bDone = sal_False;
1715         if ( eFamily == SFX_STYLE_FAMILY_PAGE )
1716         {
1717             if(pEntry->nWID == SC_WID_UNO_HEADERSET)
1718             {
1719                 const SfxItemPropertySimpleEntry* pHeaderEntry = lcl_GetHeaderStyleMap()->getByName( rPropertyName );
1720                 if ( pHeaderEntry ) // only item-wids in header/footer map
1721                 {
1722                     SvxSetItem aNewHeader( (const SvxSetItem&)rSet.Get(ATTR_PAGE_HEADERSET) );
1723                     if (pValue)
1724                         pPropSet->setPropertyValue( *pHeaderEntry, *pValue, aNewHeader.GetItemSet() );
1725                     else
1726                         aNewHeader.GetItemSet().ClearItem( pHeaderEntry->nWID );
1727                     rSet.Put( aNewHeader );
1728                     bDone = sal_True;
1729                 }
1730             }
1731             else if(pEntry->nWID == SC_WID_UNO_FOOTERSET)
1732             {
1733                 const SfxItemPropertySimpleEntry* pFooterEntry = lcl_GetFooterStyleMap()->getByName( rPropertyName );
1734                 if ( pFooterEntry ) // only item-wids in header/footer map
1735                 {
1736                     SvxSetItem aNewFooter( (const SvxSetItem&)rSet.Get(ATTR_PAGE_FOOTERSET) );
1737                     if (pValue)
1738                         pPropSet->setPropertyValue( *pFooterEntry, *pValue, aNewFooter.GetItemSet() );
1739                     else
1740                         aNewFooter.GetItemSet().ClearItem( pFooterEntry->nWID );
1741                     rSet.Put( aNewFooter );
1742                     bDone = sal_True;
1743                 }
1744             }
1745         }
1746         if (!bDone)
1747         {
1748             if ( pEntry )
1749             {
1750                 if ( IsScItemWid( pEntry->nWID ) )
1751                 {
1752                     if (pValue)
1753                     {
1754                         switch ( pEntry->nWID )     // fuer Item-Spezial-Behandlungen
1755                         {
1756                             case ATTR_VALUE_FORMAT:
1757                                 {
1758                                     // #67847# language for number formats
1759                                     SvNumberFormatter* pFormatter =
1760                                             pDocShell->GetDocument()->GetFormatTable();
1761                                     sal_uInt32 nOldFormat = ((const SfxUInt32Item&)
1762                                             rSet.Get( ATTR_VALUE_FORMAT )).GetValue();
1763                                     LanguageType eOldLang = ((const SvxLanguageItem&)
1764                                             rSet.Get( ATTR_LANGUAGE_FORMAT )).GetLanguage();
1765                                     nOldFormat = pFormatter->
1766                                             GetFormatForLanguageIfBuiltIn( nOldFormat, eOldLang );
1767 
1768                                     sal_uInt32 nNewFormat = 0;
1769                                     *pValue >>= nNewFormat;
1770                                     rSet.Put( SfxUInt32Item( ATTR_VALUE_FORMAT, nNewFormat ) );
1771 
1772                                     const SvNumberformat* pNewEntry = pFormatter->GetEntry( nNewFormat );
1773                                     LanguageType eNewLang =
1774                                         pNewEntry ? pNewEntry->GetLanguage() : LANGUAGE_DONTKNOW;
1775                                     if ( eNewLang != eOldLang && eNewLang != LANGUAGE_DONTKNOW )
1776                                         rSet.Put( SvxLanguageItem( eNewLang, ATTR_LANGUAGE_FORMAT ) );
1777 
1778                                     //! keep default state of number format if only language changed?
1779                                 }
1780                                 break;
1781                             case ATTR_INDENT:
1782                                 {
1783                                     sal_Int16 nVal = 0;
1784                                     *pValue >>= nVal;
1785                                     rSet.Put( SfxUInt16Item( pEntry->nWID, (sal_uInt16)HMMToTwips(nVal) ) );
1786                                 }
1787                                 break;
1788                             case ATTR_ROTATE_VALUE:
1789                                 {
1790                                     sal_Int32 nRotVal = 0;
1791                                     if ( *pValue >>= nRotVal )
1792                                     {
1793                                         //  stored value is always between 0 and 360 deg.
1794                                         nRotVal %= 36000;
1795                                         if ( nRotVal < 0 )
1796                                             nRotVal += 36000;
1797                                         rSet.Put( SfxInt32Item( ATTR_ROTATE_VALUE, nRotVal ) );
1798                                     }
1799                                 }
1800                                 break;
1801                             case ATTR_STACKED:
1802                                 {
1803                                     table::CellOrientation eOrient;
1804                                     if( *pValue >>= eOrient )
1805                                     {
1806                                         switch( eOrient )
1807                                         {
1808                                             case table::CellOrientation_STANDARD:
1809                                                 rSet.Put( SfxBoolItem( ATTR_STACKED, sal_False ) );
1810                                             break;
1811                                             case table::CellOrientation_TOPBOTTOM:
1812                                                 rSet.Put( SfxBoolItem( ATTR_STACKED, sal_False ) );
1813                                                 rSet.Put( SfxInt32Item( ATTR_ROTATE_VALUE, 27000 ) );
1814                                             break;
1815                                             case table::CellOrientation_BOTTOMTOP:
1816                                                 rSet.Put( SfxBoolItem( ATTR_STACKED, sal_False ) );
1817                                                 rSet.Put( SfxInt32Item( ATTR_ROTATE_VALUE, 9000 ) );
1818                                             break;
1819                                             case table::CellOrientation_STACKED:
1820                                                 rSet.Put( SfxBoolItem( ATTR_STACKED, sal_True ) );
1821                                             break;
1822                                             default:
1823                                             {
1824                                                 // added to avoid warnings
1825                                             }
1826                                         }
1827                                     }
1828                                 }
1829                                 break;
1830                             case ATTR_PAGE_SCALE:
1831                             case ATTR_PAGE_SCALETOPAGES:
1832                                 {
1833                                     rSet.ClearItem(ATTR_PAGE_SCALETOPAGES);
1834                                     rSet.ClearItem(ATTR_PAGE_SCALE);
1835                                     rSet.ClearItem(ATTR_PAGE_SCALETO);
1836                                     sal_Int16 nVal = 0;
1837                                     *pValue >>= nVal;
1838                                     rSet.Put( SfxUInt16Item( pEntry->nWID, nVal ) );
1839                                 }
1840                                 break;
1841                             case ATTR_PAGE_FIRSTPAGENO:
1842                                 {
1843                                     sal_Int16 nVal = 0;
1844                                     *pValue >>= nVal;
1845                                     rSet.Put( SfxUInt16Item( ATTR_PAGE_FIRSTPAGENO, nVal ) );
1846                                 }
1847                                 break;
1848                             case ATTR_PAGE_CHARTS:
1849                             case ATTR_PAGE_OBJECTS:
1850                             case ATTR_PAGE_DRAWINGS:
1851                                 {
1852                                     sal_Bool bBool = sal_False;
1853                                     *pValue >>= bBool;
1854                                     //! sal_Bool-MID fuer ScViewObjectModeItem definieren?
1855                                     rSet.Put( ScViewObjectModeItem( pEntry->nWID,
1856                                         bBool ? VOBJ_MODE_SHOW : VOBJ_MODE_HIDE ) );
1857                                 }
1858                                 break;
1859                             case ATTR_PAGE_PAPERBIN:
1860                                 {
1861                                     sal_uInt8 nTray = PAPERBIN_PRINTER_SETTINGS;
1862                                     sal_Bool bFound = sal_False;
1863 
1864                                     rtl::OUString aName;
1865                                     if ( *pValue >>= aName )
1866                                     {
1867                                         if ( aName.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( SC_PAPERBIN_DEFAULTNAME ) ) )
1868                                             bFound = sal_True;
1869                                         else
1870                                         {
1871                                             Printer* pPrinter = pDocShell->GetPrinter();
1872                                             if (pPrinter)
1873                                             {
1874                                                 String aNameStr = aName;
1875                                                 sal_uInt16 nCount = pPrinter->GetPaperBinCount();
1876                                                 for (sal_uInt16 i=0; i<nCount; i++)
1877                                                     if ( aNameStr == pPrinter->GetPaperBinName(i) )
1878                                                     {
1879                                                         nTray = (sal_uInt8) i;
1880                                                         bFound = sal_True;
1881                                                         break;
1882                                                     }
1883                                             }
1884                                         }
1885                                     }
1886                                     if ( bFound )
1887                                         rSet.Put( SvxPaperBinItem( ATTR_PAGE_PAPERBIN, nTray ) );
1888                                     else
1889                                         throw lang::IllegalArgumentException();
1890                                 }
1891                                 break;
1892                             case ATTR_PAGE_SCALETO:
1893                                 {
1894                                     sal_Int16 nPages = 0;
1895                                     if (*pValue >>= nPages)
1896                                     {
1897                                         ScPageScaleToItem aItem = ((const ScPageScaleToItem&)rSet.Get(ATTR_PAGE_SCALETO));
1898                                         if ( rPropertyName.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM ( SC_UNO_PAGE_SCALETOX)))
1899                                             aItem.SetWidth(static_cast<sal_uInt16>(nPages));
1900                                         else
1901                                             aItem.SetHeight(static_cast<sal_uInt16>(nPages));
1902                                         rSet.Put( aItem );
1903                                         rSet.ClearItem(ATTR_PAGE_SCALETOPAGES);
1904                                         rSet.ClearItem(ATTR_PAGE_SCALE);
1905                                     }
1906                                 }
1907                                 break;
1908                             default:
1909                                 //  #65253# Default-Items mit falscher Slot-ID
1910                                 //  funktionieren im SfxItemPropertySet3 nicht
1911                                 //! Slot-IDs aendern...
1912                                 if ( rSet.GetPool()->GetSlotId(pEntry->nWID) == pEntry->nWID &&
1913                                      rSet.GetItemState(pEntry->nWID, sal_False) == SFX_ITEM_DEFAULT )
1914                                 {
1915                                     rSet.Put( rSet.Get(pEntry->nWID) );
1916                                 }
1917                                 pPropSet->setPropertyValue( *pEntry, *pValue, rSet );
1918                         }
1919                     }
1920                     else
1921                     {
1922                         rSet.ClearItem( pEntry->nWID );
1923                         // #67847# language for number formats
1924                         if ( pEntry->nWID == ATTR_VALUE_FORMAT )
1925                             rSet.ClearItem( ATTR_LANGUAGE_FORMAT );
1926 
1927                         //! for ATTR_ROTATE_VALUE, also reset ATTR_ORIENTATION?
1928                     }
1929                 }
1930                 else if ( IsScUnoWid( pEntry->nWID ) )
1931                 {
1932                     switch ( pEntry->nWID )
1933                     {
1934                         case SC_WID_UNO_TBLBORD:
1935                             {
1936                                 if (pValue)
1937                                 {
1938                                     table::TableBorder aBorder;
1939                                     if ( *pValue >>= aBorder )
1940                                     {
1941                                         SvxBoxItem aOuter( ATTR_BORDER );
1942                                         SvxBoxInfoItem aInner( ATTR_BORDER_INNER );
1943                                         ScHelperFunctions::FillBoxItems( aOuter, aInner, aBorder );
1944                                         rSet.Put( aOuter );
1945                                     }
1946                                 }
1947                                 else
1948                                 {
1949                                     rSet.ClearItem( ATTR_BORDER );
1950                                 }
1951                             }
1952                             break;
1953                     }
1954                 }
1955             }
1956         }
1957 
1958         if(SFX_STYLE_FAMILY_PARA != eFamily)
1959         {
1960             //! ModifyStyleSheet am Dokument (alte Werte merken)
1961 
1962             pDocShell->PageStyleModified( aStyleName, sal_True );
1963         }
1964     }
1965 }
1966 
StyleSheetChangedUpdate()1967 bool ScStyleObj::StyleSheetChangedUpdate()
1968 {
1969     SfxStyleSheetBase* pStyle = GetStyle_Impl();
1970 
1971     if(pStyle)
1972     {
1973         //! DocFunc-Funktion??
1974         //! Undo ?????????????
1975 
1976         if(SFX_STYLE_FAMILY_PARA == eFamily)
1977         {
1978             // adapt line heights
1979             VirtualDevice aVDev;
1980             const Point aLogic(aVDev.LogicToPixel(Point(1000,1000), MAP_TWIP));
1981             const double nPPTX(aLogic.X() / 1000.0);
1982             const double nPPTY(aLogic.Y() / 1000.0);
1983             const Fraction aZoom(1,1);
1984             ScDocument* pDoc = pDocShell->GetDocument();
1985 
1986             pDoc->StyleSheetChanged(pStyle, sal_False, &aVDev, nPPTX, nPPTY, aZoom, aZoom);
1987             pDocShell->PostPaint(0,0,0, MAXCOL,MAXROW,MAXTAB, PAINT_GRID|PAINT_LEFT);
1988             pDocShell->SetDocumentModified();
1989         }
1990 
1991         return true;
1992     }
1993 
1994     return false;
1995 }
1996 
getPropertyValue(const rtl::OUString & aPropertyName)1997 uno::Any SAL_CALL ScStyleObj::getPropertyValue( const rtl::OUString& aPropertyName )
1998                 throw(beans::UnknownPropertyException, lang::WrappedTargetException,
1999                         uno::RuntimeException)
2000 {
2001     ScUnoGuard aGuard;
2002     uno::Any aAny;
2003 
2004     if ( aPropertyName.equalsAscii( SC_UNONAME_DISPNAME ) )      // read-only
2005     {
2006         //  core always has the display name
2007         SfxStyleSheetBase* pStyle = GetStyle_Impl();
2008         if (pStyle)
2009             aAny <<= rtl::OUString( pStyle->GetName() );
2010     }
2011     else
2012     {
2013         const SfxItemPropertySimpleEntry* pResultEntry = NULL;
2014         const SfxItemSet* pItemSet = GetStyleItemSet_Impl( aPropertyName, pResultEntry );
2015 
2016         if ( pItemSet && pResultEntry )
2017         {
2018             sal_uInt16 nWhich = pResultEntry->nWID;
2019 
2020             if ( IsScItemWid( nWhich ) )
2021             {
2022                 switch ( nWhich )       // fuer Item-Spezial-Behandlungen
2023                 {
2024                     case ATTR_VALUE_FORMAT:
2025                         if ( pDocShell )
2026                         {
2027                             sal_uInt32 nOldFormat = ((const SfxUInt32Item&)
2028                                     pItemSet->Get( ATTR_VALUE_FORMAT )).GetValue();
2029                             LanguageType eOldLang = ((const SvxLanguageItem&)
2030                                     pItemSet->Get( ATTR_LANGUAGE_FORMAT )).GetLanguage();
2031                             nOldFormat = pDocShell->GetDocument()->GetFormatTable()->
2032                                     GetFormatForLanguageIfBuiltIn( nOldFormat, eOldLang );
2033                             aAny <<= nOldFormat;
2034                         }
2035                         break;
2036                     case ATTR_INDENT:
2037                         aAny <<= sal_Int16( TwipsToHMM(((const SfxUInt16Item&)
2038                                         pItemSet->Get(nWhich)).GetValue()) );
2039                         break;
2040                     case ATTR_STACKED:
2041                         {
2042                             sal_Int32 nRot = ((const SfxInt32Item&)pItemSet->Get(ATTR_ROTATE_VALUE)).GetValue();
2043                             sal_Bool bStacked = ((const SfxBoolItem&)pItemSet->Get(nWhich)).GetValue();
2044                             SvxOrientationItem( nRot, bStacked, 0 ).QueryValue( aAny );
2045                         }
2046                         break;
2047                     case ATTR_PAGE_SCALE:
2048                     case ATTR_PAGE_SCALETOPAGES:
2049                     case ATTR_PAGE_FIRSTPAGENO:
2050                         aAny <<= sal_Int16( ((const SfxUInt16Item&)pItemSet->Get(nWhich)).GetValue() );
2051                         break;
2052                     case ATTR_PAGE_CHARTS:
2053                     case ATTR_PAGE_OBJECTS:
2054                     case ATTR_PAGE_DRAWINGS:
2055                         //! sal_Bool-MID fuer ScViewObjectModeItem definieren?
2056                         aAny <<= sal_Bool( ((const ScViewObjectModeItem&)pItemSet->
2057                                         Get(nWhich)).GetValue() == VOBJ_MODE_SHOW );
2058                         break;
2059                     case ATTR_PAGE_PAPERBIN:
2060                         {
2061                             // property PrinterPaperTray is the name of the tray
2062 
2063                             sal_uInt8 nValue = ((const SvxPaperBinItem&)pItemSet->Get(nWhich)).GetValue();
2064                             rtl::OUString aName;
2065                             if ( nValue == PAPERBIN_PRINTER_SETTINGS )
2066                                 aName = rtl::OUString::createFromAscii( SC_PAPERBIN_DEFAULTNAME );
2067                             else
2068                             {
2069                                 Printer* pPrinter = pDocShell->GetPrinter();
2070                                 if (pPrinter)
2071                                     aName = pPrinter->GetPaperBinName( nValue );
2072                             }
2073                             aAny <<= aName;
2074                         }
2075                         break;
2076                     case ATTR_PAGE_SCALETO:
2077                         {
2078                             ScPageScaleToItem aItem((const ScPageScaleToItem&)pItemSet->Get(ATTR_PAGE_SCALETO));
2079                             if (aPropertyName.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM ( SC_UNO_PAGE_SCALETOX)))
2080                                 aAny = uno::makeAny(static_cast<sal_Int16>(aItem.GetWidth()));
2081                             else
2082                                 aAny = uno::makeAny(static_cast<sal_Int16>(aItem.GetHeight()));
2083                         }
2084                         break;
2085                     default:
2086                         //  #65253# Default-Items mit falscher Slot-ID
2087                         //  funktionieren im SfxItemPropertySet3 nicht
2088                         //! Slot-IDs aendern...
2089                         if ( pItemSet->GetPool()->GetSlotId(nWhich) == nWhich &&
2090                              pItemSet->GetItemState(nWhich, sal_False) == SFX_ITEM_DEFAULT )
2091                         {
2092                             SfxItemSet aNoEmptySet( *pItemSet );
2093                             aNoEmptySet.Put( aNoEmptySet.Get( nWhich ) );
2094                             pPropSet->getPropertyValue( *pResultEntry, aNoEmptySet, aAny );
2095                         }
2096                         else
2097                             pPropSet->getPropertyValue( *pResultEntry, *pItemSet, aAny );
2098                 }
2099             }
2100             else if ( IsScUnoWid( nWhich ) )
2101             {
2102                 switch ( nWhich )
2103                 {
2104                     case SC_WID_UNO_TBLBORD:
2105                         {
2106                             const SfxPoolItem* pItem = &pItemSet->Get( ATTR_BORDER );
2107                             if ( pItem )
2108                             {
2109                                 SvxBoxItem aOuter( *( static_cast<const SvxBoxItem*>( pItem ) ) );
2110                                 SvxBoxInfoItem aInner( ATTR_BORDER_INNER );
2111                                 table::TableBorder aBorder;
2112                                 ScHelperFunctions::FillTableBorder( aBorder, aOuter, aInner );
2113                                 aBorder.IsHorizontalLineValid = sal_False;
2114                                 aBorder.IsVerticalLineValid = sal_False;
2115                                 aBorder.IsDistanceValid = sal_False;
2116                                 aAny <<= aBorder;
2117                             }
2118                         }
2119                         break;
2120                 }
2121             }
2122         }
2123     }
2124 
2125     return aAny;
2126 }
2127 
SC_IMPL_DUMMY_PROPERTY_LISTENER(ScStyleObj)2128 SC_IMPL_DUMMY_PROPERTY_LISTENER( ScStyleObj )
2129 
2130 // lang::XServiceInfo
2131 
2132 rtl::OUString SAL_CALL ScStyleObj::getImplementationName() throw(uno::RuntimeException)
2133 {
2134     return rtl::OUString::createFromAscii( "ScStyleObj" );
2135 }
2136 
supportsService(const rtl::OUString & rServiceName)2137 sal_Bool SAL_CALL ScStyleObj::supportsService( const rtl::OUString& rServiceName )
2138                                                     throw(uno::RuntimeException)
2139 {
2140     sal_Bool bPage = ( eFamily == SFX_STYLE_FAMILY_PAGE );
2141     return rServiceName.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM ( SCSTYLE_SERVICE ) )||
2142            rServiceName.equalsAsciiL(
2143             RTL_CONSTASCII_STRINGPARAM ( bPage ? SCPAGESTYLE_SERVICE : SCCELLSTYLE_SERVICE ));
2144 }
2145 
getSupportedServiceNames()2146 uno::Sequence<rtl::OUString> SAL_CALL ScStyleObj::getSupportedServiceNames()
2147                                                     throw(uno::RuntimeException)
2148 {
2149     sal_Bool bPage = ( eFamily == SFX_STYLE_FAMILY_PAGE );
2150     uno::Sequence<rtl::OUString> aRet(2);
2151     rtl::OUString* pArray = aRet.getArray();
2152     pArray[0] = rtl::OUString::createFromAscii( SCSTYLE_SERVICE );
2153     pArray[1] = rtl::OUString::createFromAscii( bPage ? SCPAGESTYLE_SERVICE
2154                                                       : SCCELLSTYLE_SERVICE );
2155     return aRet;
2156 }
2157 
2158 //------------------------------------------------------------------------
2159 
2160 
2161