1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
3 * This file is part of the LibreOffice project.
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
9 * This file incorporates work covered by the following license notice:
11 * Licensed to the Apache Software Foundation (ASF) under one or more
12 * contributor license agreements. See the NOTICE file distributed
13 * with this work for additional information regarding copyright
14 * ownership. The ASF licenses this file to you under the Apache
15 * License, Version 2.0 (the "License"); you may not use this file
16 * except in compliance with the License. You may obtain a copy of
17 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
20 #include <sal/config.h>
22 #include <com/sun/star/style/XStyle.hpp>
23 #include <com/sun/star/drawing/LineStyle.hpp>
24 #include <i18nlangtag/languagetag.hxx>
25 #include <i18nlangtag/mslangid.hxx>
26 #include <sfx2/dispatch.hxx>
27 #include <Outliner.hxx>
28 #include <editeng/outliner.hxx>
30 #include <DrawDocShell.hxx>
31 #include <editeng/eeitem.hxx>
33 #include <vcl/idle.hxx>
34 #include <vcl/settings.hxx>
35 #include <vcl/svapp.hxx>
37 #include <editeng/autokernitem.hxx>
39 #include <svx/svxids.hrc>
40 #include <svl/srchitem.hxx>
41 #include <editeng/lrspitem.hxx>
42 #include <editeng/ulspitem.hxx>
43 #include <editeng/lspcitem.hxx>
44 #include <editeng/adjustitem.hxx>
45 #include <editeng/numdef.hxx>
46 #include <svx/strings.hrc>
47 #include <svx/dialmgr.hxx>
48 #include <editeng/bulletitem.hxx>
49 #include <editeng/borderline.hxx>
50 #include <editeng/boxitem.hxx>
51 #include <svx/xlineit0.hxx>
52 #include <svx/sdshitm.hxx>
53 #include <svx/svdotext.hxx>
54 #include <svx/xfillit0.hxx>
55 #include <svx/sdshcitm.hxx>
56 #include <editeng/editstat.hxx>
57 #include <editeng/colritem.hxx>
58 #include <editeng/fhgtitem.hxx>
59 #include <editeng/wghtitem.hxx>
60 #include <editeng/postitem.hxx>
61 #include <editeng/crossedoutitem.hxx>
62 #include <editeng/udlnitem.hxx>
63 #include <editeng/contouritem.hxx>
64 #include <editeng/emphasismarkitem.hxx>
65 #include <editeng/fontitem.hxx>
66 #include <editeng/shdditem.hxx>
67 #include <editeng/cmapitem.hxx>
68 #include <svx/xbtmpit.hxx>
69 #include <svx/xflhtit.hxx>
70 #include <svx/xflgrit.hxx>
71 #include <svx/xflclit.hxx>
72 #include <svx/xlnedcit.hxx>
73 #include <svx/xlnstcit.hxx>
74 #include <svx/xlnedwit.hxx>
75 #include <svx/xlnstwit.hxx>
76 #include <svx/xlnedit.hxx>
77 #include <editeng/charreliefitem.hxx>
78 #include <svx/xlnstit.hxx>
79 #include <svx/xlndsit.hxx>
80 #include <svx/xlnwtit.hxx>
81 #include <svx/xlnclit.hxx>
82 #include <svx/svditer.hxx>
83 #include <svx/svdogrp.hxx>
84 #include <svx/sdsxyitm.hxx>
85 #include <svx/sdtditm.hxx>
86 #include <svx/sdtaitm.hxx>
87 #include <svx/sdynitm.hxx>
88 #include <editeng/numitem.hxx>
89 #include <editeng/unolingu.hxx>
90 #include <svl/itempool.hxx>
91 #include <editeng/outlobj.hxx>
92 #include <sfx2/viewfrm.hxx>
93 #include <editeng/frmdiritem.hxx>
95 #include <sdresid.hxx>
96 #include <drawdoc.hxx>
98 #include <strings.hrc>
100 #include <stlpool.hxx>
101 #include <shapelist.hxx>
102 #include <basegfx/point/b2dpoint.hxx>
103 #include <basegfx/polygon/b2dpolygon.hxx>
104 #include <svl/itemset.hxx>
106 #include <strings.hxx>
108 namespace com::sun::star::linguistic2
{ class XHyphenator
; }
110 using namespace ::com::sun::star
;
111 using namespace ::com::sun::star::uno
;
112 using namespace ::com::sun::star::lang
;
113 using namespace ::com::sun::star::style
;
114 using namespace ::com::sun::star::container
;
115 using namespace ::com::sun::star::linguistic2
;
116 using namespace ::sd
;
118 // CreateLayoutTemplates
119 // At the moment (31.03.1995), the StyleSheetPool only saves styleheets that
120 // have an ItemSet. To save all stylesheets, we force the creation of an ItemSet
121 // with a GetItemSet call.
122 // We can remove this behavior once the pool saves styleheets even without an ItemSet
123 void SdDrawDocument::CreateLayoutTemplates()
125 SdStyleSheetPool
* pSSPool
= static_cast<SdStyleSheetPool
*>(GetStyleSheetPool());
126 SfxStyleSheetBase
* pSheet
= nullptr;
127 const OUString aHelpFile
;
128 OUString
aStdName(SdResId(STR_STANDARD_STYLESHEET_NAME
));
132 SfxStyleSearchBits nMask
= SfxStyleSearchBits::Auto
;
134 OUString
aName(aStdName
);
135 pSheet
= &(pSSPool
->Make(aName
, SfxStyleFamily::Para
, nMask
));
136 pSheet
->SetHelpId( aHelpFile
, HID_STANDARD_STYLESHEET_NAME
);
137 SfxItemSet
& rISet
= pSheet
->GetItemSet();
139 ::basegfx::B2DPolyPolygon aNullPolyPolygon
;
140 Color
aNullCol(COL_DEFAULT_SHAPE_STROKE
);
143 XGradient
aNullGrad(aNullCol
,COL_WHITE
);
144 aNullGrad
.SetStartIntens( 100 );
145 aNullGrad
.SetEndIntens( 100 );
146 XHatch
aNullHatch(aNullCol
);
148 // Line attributes (Extended OutputDevice)
149 rISet
.Put(XLineStyleItem(drawing::LineStyle_SOLID
));
150 rISet
.Put(XLineColorItem(OUString(), COL_DEFAULT_SHAPE_STROKE
));
151 rISet
.Put(XLineWidthItem(0));
152 rISet
.Put(XLineDashItem(aNullDash
));
153 rISet
.Put(XLineStartItem(aNullPolyPolygon
));
154 rISet
.Put(XLineEndItem(aNullPolyPolygon
));
155 rISet
.Put(XLineStartWidthItem(200));
156 rISet
.Put(XLineEndWidthItem(200));
157 rISet
.Put(XLineStartCenterItem());
158 rISet
.Put(XLineEndCenterItem());
159 rISet
.Put(SdrTextHorzAdjustItem(SDRTEXTHORZADJUST_BLOCK
));
161 // Fill attributes (Extended OutputDevice)
162 rISet
.Put(XFillStyleItem(drawing::FillStyle_SOLID
));
163 rISet
.Put(XFillColorItem(OUString(), COL_DEFAULT_SHAPE_FILLING
));
165 rISet
.Put( XFillGradientItem( aNullGrad
) );
166 rISet
.Put(XFillHatchItem(aNullHatch
));
167 Size
aNullSize( 32, 32 );
168 Bitmap
aNullBmp( aNullSize
, 8 );
169 aNullBmp
.Erase( COL_WHITE
);
170 rISet
.Put(XFillBitmapItem(Graphic(BitmapEx(aNullBmp
))));
172 // Shadow attributes (Drawing Engine)
173 rISet
.Put(makeSdrShadowItem(false));
174 rISet
.Put(makeSdrShadowColorItem(COL_GRAY
));
175 rISet
.Put(makeSdrShadowXDistItem(200)); // 3 mm Shadow distance
176 rISet
.Put(makeSdrShadowYDistItem(200));
178 vcl::Font aLatinFont
, aCJKFont
, aCTLFont
;
180 getDefaultFonts( aLatinFont
, aCJKFont
, aCTLFont
);
182 SvxFontItem
aSvxFontItem( aLatinFont
.GetFamilyType(), aLatinFont
.GetFamilyName(), aLatinFont
.GetStyleName(), aLatinFont
.GetPitch(),
183 aLatinFont
.GetCharSet(), EE_CHAR_FONTINFO
);
185 SvxFontItem
aSvxFontItemCJK( aCJKFont
.GetFamilyType(), aCJKFont
.GetFamilyName(), aCJKFont
.GetStyleName(), aCJKFont
.GetPitch(),
186 aCJKFont
.GetCharSet(), EE_CHAR_FONTINFO_CJK
);
188 SvxFontItem
aSvxFontItemCTL( aCTLFont
.GetFamilyType(), aCTLFont
.GetFamilyName(), aCTLFont
.GetStyleName(), aCTLFont
.GetPitch(),
189 aCTLFont
.GetCharSet(), EE_CHAR_FONTINFO_CTL
);
191 rISet
.Put( aSvxFontItem
);
192 rISet
.Put( aSvxFontItemCJK
);
193 rISet
.Put( aSvxFontItemCTL
);
195 rISet
.Put( SvxFontHeightItem( 635, 100, EE_CHAR_FONTHEIGHT
) ); // sj: (i33745) changed default from 24 to 18 pt
196 rISet
.Put( SvxFontHeightItem( 635, 100, EE_CHAR_FONTHEIGHT_CJK
) ); // 18 pt
197 rISet
.Put( SvxFontHeightItem( convertFontHeightToCTL( 635 ), 100, EE_CHAR_FONTHEIGHT_CTL
) ); // 18 pt
199 rISet
.Put( SvxWeightItem( WEIGHT_NORMAL
, EE_CHAR_WEIGHT
) );
200 rISet
.Put( SvxWeightItem( WEIGHT_NORMAL
, EE_CHAR_WEIGHT_CJK
) );
201 rISet
.Put( SvxWeightItem( WEIGHT_NORMAL
, EE_CHAR_WEIGHT_CTL
) );
203 rISet
.Put( SvxPostureItem( ITALIC_NONE
, EE_CHAR_ITALIC
) );
204 rISet
.Put( SvxPostureItem( ITALIC_NONE
, EE_CHAR_ITALIC_CJK
) );
205 rISet
.Put( SvxPostureItem( ITALIC_NONE
, EE_CHAR_ITALIC_CTL
) );
207 rISet
.Put(SvxContourItem(false, EE_CHAR_OUTLINE
));
208 rISet
.Put(SvxShadowedItem(false, EE_CHAR_SHADOW
));
209 rISet
.Put(SvxUnderlineItem(LINESTYLE_NONE
, EE_CHAR_UNDERLINE
));
210 rISet
.Put(SvxOverlineItem(LINESTYLE_NONE
, EE_CHAR_OVERLINE
));
211 rISet
.Put(SvxCrossedOutItem(STRIKEOUT_NONE
, EE_CHAR_STRIKEOUT
));
212 rISet
.Put(SvxCaseMapItem(SvxCaseMap::NotMapped
, EE_CHAR_CASEMAP
));
213 rISet
.Put(SvxEmphasisMarkItem(FontEmphasisMark::NONE
, EE_CHAR_EMPHASISMARK
));
214 rISet
.Put(SvxCharReliefItem(FontRelief::NONE
, EE_CHAR_RELIEF
));
215 rISet
.Put(SvxColorItem(COL_AUTO
, EE_CHAR_COLOR
));
217 // Paragraph attributes (Edit Engine)
218 rISet
.Put(SvxLRSpaceItem(EE_PARA_LRSPACE
));
219 rISet
.Put(SvxULSpaceItem(EE_PARA_ULSPACE
));
221 rISet
.Put( makeSdrTextLeftDistItem( 250 ) ); // sj: (i33745) using text frame distances seems to be a better default
222 rISet
.Put( makeSdrTextRightDistItem( 250 ) );
223 rISet
.Put( makeSdrTextUpperDistItem( 125 ) );
224 rISet
.Put( makeSdrTextLowerDistItem( 125 ) );
226 rISet
.Put( SvxLineSpacingItem( LINE_SPACE_DEFAULT_HEIGHT
, EE_PARA_SBL
) );
228 // #i16874# enable kerning by default but only for new documents
229 rISet
.Put( SvxAutoKernItem( true, EE_CHAR_PAIRKERNING
) );
232 // BulletItem and BulletFont for title and outline
233 SvxBulletItem
aBulletItem(EE_PARA_BULLET
);
234 // Identical in all layers
235 aBulletItem
.SetStyle(SvxBulletStyle::BULLET
);
236 aBulletItem
.SetStart(1);
237 aBulletItem
.SetScale(45); // In percent
239 vcl::Font
aBulletFont( SdStyleSheetPool::GetBulletFont() );
241 aBulletFont
.SetFontSize(Size(0,635)); // sj: (i33745) changed default from 24 to 18 pt
243 aBulletItem
.SetFont(aBulletFont
);
244 aBulletItem
.SetSymbol( 0x25CF ); // In points
245 rISet
.Put(aBulletItem
);
248 SdStyleSheetPool::PutNumBulletItem( pSheet
, aBulletFont
);
250 SfxItemSet
* pISet
= nullptr;
252 // Default > Object without filling
254 aName
= SdResId(STR_POOLSHEET_OBJWITHOUTFILL
);
255 pSheet
= &(pSSPool
->Make(aName
, SfxStyleFamily::Para
, nMask
));
256 pSheet
->SetParent(aStdName
);
257 pSheet
->SetHelpId( aHelpFile
, HID_POOLSHEET_OBJWITHOUTFILL
);
258 pISet
= &pSheet
->GetItemSet();
260 pISet
->Put(XFillStyleItem(drawing::FillStyle_NONE
));
262 // Default > Object no fill no line
264 aName
= SdResId(STR_POOLSHEET_OBJNOLINENOFILL
);
265 pSheet
= &(pSSPool
->Make(aName
, SfxStyleFamily::Para
, nMask
));
266 pSheet
->SetParent(aStdName
);
267 pSheet
->SetHelpId( aHelpFile
, HID_POOLSHEET_OBJNOLINENOFILL
);
268 pISet
= &pSheet
->GetItemSet();
270 pISet
->Put(XFillStyleItem(drawing::FillStyle_NONE
));
271 pISet
->Put(XLineStyleItem(drawing::LineStyle_NONE
));
279 aTextName
= SdResId(STR_POOLSHEET_TEXT
);
280 pSheet
= &(pSSPool
->Make(aTextName
, SfxStyleFamily::Para
, nMask
));
281 pSheet
->SetHelpId( aHelpFile
, HID_POOLSHEET_TEXT
);
282 pISet
= &pSheet
->GetItemSet();
283 aSvxFontItem
.SetFamilyName("Noto Sans");
284 pISet
->Put( aSvxFontItem
); // Noto Sans
285 pISet
->Put(XFillStyleItem(drawing::FillStyle_SOLID
)); // solid fill
286 pISet
->Put(XFillColorItem(OUString(), Color(0xeeeeee))); // light gray 5
287 pISet
->Put(XLineStyleItem(drawing::LineStyle_SOLID
)); // solid fill
288 pISet
->Put(XLineColorItem(OUString(), Color(0xcccccc))); // light gray 3
293 aA4Name
= SdResId(STR_POOLSHEET_A4
);
294 pSheet
= &(pSSPool
->Make(aA4Name
, SfxStyleFamily::Para
, nMask
));
295 pSheet
->SetParent( aTextName
);
296 pSheet
->SetHelpId( aHelpFile
, HID_POOLSHEET_A4
);
297 pISet
= &pSheet
->GetItemSet();
298 pISet
->Put(SvxFontHeightItem(635, 100, EE_CHAR_FONTHEIGHT
)); // 18 pt
299 pISet
->Put(XFillStyleItem(drawing::FillStyle_NONE
)); // no filling
304 aName
= SdResId(STR_POOLSHEET_A4_TITLE
);
305 pSheet
= &(pSSPool
->Make(aName
, SfxStyleFamily::Para
, nMask
));
306 pSheet
->SetParent( aA4Name
);
307 pSheet
->SetHelpId( aHelpFile
, HID_POOLSHEET_A4_TITLE
);
308 pISet
= &pSheet
->GetItemSet();
309 pISet
->Put(SvxFontHeightItem(1551, 100, EE_CHAR_FONTHEIGHT
)); // 44 pt
310 pISet
->Put(XLineStyleItem(drawing::LineStyle_NONE
)); // no border
312 // Text > A4 > Headline
314 aName
= SdResId(STR_POOLSHEET_A4_HEADLINE
);
315 pSheet
= &(pSSPool
->Make(aName
, SfxStyleFamily::Para
, nMask
));
316 pSheet
->SetParent( aA4Name
);
317 pSheet
->SetHelpId( aHelpFile
, HID_POOLSHEET_A4_HEADLINE
);
318 pISet
= &pSheet
->GetItemSet();
319 pISet
->Put(SvxFontHeightItem(847, 100, EE_CHAR_FONTHEIGHT
)); // 24 pt
320 pISet
->Put(XLineStyleItem(drawing::LineStyle_NONE
)); // no border
324 aName
= SdResId(STR_POOLSHEET_A4_TEXT
);
325 pSheet
= &(pSSPool
->Make(aName
, SfxStyleFamily::Para
, nMask
));
326 pSheet
->SetParent(aA4Name
);
327 pSheet
->SetHelpId( aHelpFile
, HID_POOLSHEET_A4_TEXT
);
328 pISet
= &pSheet
->GetItemSet();
329 pISet
->Put(XLineStyleItem(drawing::LineStyle_NONE
)); // no border
334 aA0Name
= SdResId(STR_POOLSHEET_A0
);
335 pSheet
= &(pSSPool
->Make(aA0Name
, SfxStyleFamily::Para
, nMask
));
336 pSheet
->SetParent(aTextName
);
337 pSheet
->SetHelpId( aHelpFile
, HID_POOLSHEET_A0
);
338 pISet
= &pSheet
->GetItemSet();
339 pISet
->Put(SvxFontHeightItem(1692, 100, EE_CHAR_FONTHEIGHT
)); // 48 pt
340 pISet
->Put(XFillStyleItem(drawing::FillStyle_NONE
)); // no filling
344 aName
= SdResId(STR_POOLSHEET_A0_TITLE
);
345 pSheet
= &(pSSPool
->Make(aName
, SfxStyleFamily::Para
, nMask
));
346 pSheet
->SetParent(aA0Name
);
347 pSheet
->SetHelpId( aHelpFile
, HID_POOLSHEET_A0_TITLE
);
348 pISet
= &pSheet
->GetItemSet();
349 pISet
->Put(SvxFontHeightItem(3385, 100, EE_CHAR_FONTHEIGHT
)); // 96 pt
350 pISet
->Put(XLineStyleItem(drawing::LineStyle_NONE
)); // no border
352 // Text > A0 > Headline
354 aName
= SdResId(STR_POOLSHEET_A0_HEADLINE
);
355 pSheet
= &(pSSPool
->Make(aName
, SfxStyleFamily::Para
, nMask
));
356 pSheet
->SetParent(aA0Name
);
357 pSheet
->SetHelpId( aHelpFile
, HID_POOLSHEET_A0_HEADLINE
);
358 pISet
= &pSheet
->GetItemSet();
359 pISet
->Put(SvxFontHeightItem(2538, 100, EE_CHAR_FONTHEIGHT
)); // 72 pt
360 pISet
->Put(XLineStyleItem(drawing::LineStyle_NONE
)); // no border
364 aName
= SdResId(STR_POOLSHEET_A0_TEXT
);
365 pSheet
= &(pSSPool
->Make(aName
, SfxStyleFamily::Para
, nMask
));
366 pSheet
->SetParent(aA0Name
);
367 pSheet
->SetHelpId( aHelpFile
, HID_POOLSHEET_A0_TEXT
);
368 pISet
= &pSheet
->GetItemSet();
369 pISet
->Put(XLineStyleItem(drawing::LineStyle_NONE
)); // no border
373 OUString aGraphicName
;
374 XFillGradientItem aFillGradient
;
378 aGraphicName
= SdResId(STR_POOLSHEET_GRAPHIC
);
379 pSheet
= &(pSSPool
->Make(aGraphicName
, SfxStyleFamily::Para
, nMask
));
380 pSheet
->SetHelpId( aHelpFile
, HID_POOLSHEET_GRAPHIC
);
381 pISet
= &pSheet
->GetItemSet();
382 aSvxFontItem
.SetFamilyName("Liberation Sans"); // Liberation Sans
383 pISet
->Put( aSvxFontItem
);
384 pISet
->Put( SvxFontHeightItem(635, 100, EE_CHAR_FONTHEIGHT
) ); // 18 pt
385 pISet
->Put( XFillStyleItem(drawing::FillStyle_SOLID
) ); // solid fill
386 pISet
->Put( XFillColorItem(OUString(), COL_WHITE
) ); // filled white
390 OUString aShapesName
;
392 aShapesName
= SdResId(STR_POOLSHEET_SHAPES
);
393 pSheet
= &(pSSPool
->Make(aShapesName
, SfxStyleFamily::Para
, nMask
));
394 pSheet
->SetParent( aGraphicName
);
395 pSheet
->SetHelpId( aHelpFile
, HID_POOLSHEET_SHAPES
);
396 pISet
= &pSheet
->GetItemSet();
397 pISet
->Put(XFillStyleItem(drawing::FillStyle_GRADIENT
)); // fill with gradient
398 aGradient
.SetGradientStyle( ::awt::GradientStyle_RECT
); // square type
399 aGradient
.SetAngle( Degree10(0) ); // 0° angle
400 aGradient
.SetStartColor( Color(0xcccccc) ); // white
401 aGradient
.SetEndColor( COL_WHITE
); // light gray 3
402 aFillGradient
.SetName( aShapesName
);
403 aFillGradient
.SetGradientValue(aGradient
);
404 pISet
->Put( aFillGradient
);
405 pISet
->Put( XLineStyleItem(drawing::LineStyle_NONE
) ); // no border
406 pISet
->Put( SvxFontHeightItem(494, 100, EE_CHAR_FONTHEIGHT
) ); // 14 pt
407 pISet
->Put( SvxWeightItem(WEIGHT_BOLD
, EE_CHAR_WEIGHT
) ); // bold
409 // Graphic > Shapes > Filled
410 OUString
aFilledName(SdResId(STR_POOLSHEET_FILLED
));
413 pSheet
= &(pSSPool
->Make(aName
, SfxStyleFamily::Para
, nMask
));
414 pSheet
->SetHelpId( aHelpFile
, HID_POOLSHEET_FILLED
);
415 pSheet
->SetParent( aShapesName
);
416 pISet
= &pSheet
->GetItemSet();
418 aGradient
.SetGradientStyle( ::awt::GradientStyle_LINEAR
);
419 aGradient
.SetAngle( Degree10(300) );
420 aGradient
.SetStartColor( COL_WHITE
); // white
421 aGradient
.SetEndColor( Color(0xcccccc) ); // light gray 3
422 aFillGradient
.SetName( aName
);
423 aFillGradient
.SetGradientValue(aGradient
);
424 pISet
->Put( XFillStyleItem(drawing::FillStyle_GRADIENT
) );
425 pISet
->Put( aFillGradient
);
427 // Graphic > Shapes > Filled > Blue
429 aName
=SdResId(STR_POOLSHEET_FILLED_BLUE
);
430 pSheet
= &(pSSPool
->Make(aName
, SfxStyleFamily::Para
, nMask
));
431 pSheet
->SetParent(aFilledName
);
432 pSheet
->SetHelpId( aHelpFile
, HID_POOLSHEET_FILLED_BLUE
);
433 pISet
= &pSheet
->GetItemSet();
435 aGradient
.SetStartColor( Color(0x00729fcf) ); // light blue 2
436 aGradient
.SetEndColor( Color(0x00355269) ); // dark blue 2
437 aFillGradient
.SetName( aName
);
438 aFillGradient
.SetGradientValue(aGradient
);
439 pISet
->Put( aFillGradient
);
440 pISet
->Put( SvxColorItem(COL_WHITE
, EE_CHAR_COLOR
)); // font white
442 // Graphic > Shapes > Filled > Green
444 aName
=SdResId(STR_POOLSHEET_FILLED_GREEN
);
445 pSheet
= &(pSSPool
->Make(aName
, SfxStyleFamily::Para
, nMask
));
446 pSheet
->SetParent(aFilledName
);
447 pSheet
->SetHelpId( aHelpFile
, HID_POOLSHEET_FILLED_GREEN
);
448 pISet
= &pSheet
->GetItemSet();
450 aGradient
.SetStartColor( Color(0x0077bc65) ); // light green 2
451 aGradient
.SetEndColor( Color(0x00127622) ); // dark green 2
452 aFillGradient
.SetName( aName
);
453 aFillGradient
.SetGradientValue(aGradient
);
454 pISet
->Put( aFillGradient
);
455 pISet
->Put( aSvxFontItem
); // font name
456 pISet
->Put( SvxColorItem(COL_WHITE
, EE_CHAR_COLOR
)); // font white
458 // Graphic > Shapes > Filled > Red
460 aName
=SdResId(STR_POOLSHEET_FILLED_RED
);
461 pSheet
= &(pSSPool
->Make(aName
, SfxStyleFamily::Para
, nMask
));
462 pSheet
->SetParent(aFilledName
);
463 pSheet
->SetHelpId( aHelpFile
, HID_POOLSHEET_FILLED_RED
);
464 pISet
= &pSheet
->GetItemSet();
466 aGradient
.SetStartColor( Color(0x00ff6d6d) ); // light red 2
467 aGradient
.SetEndColor( Color(0x00c9211e) ); // dark red 2
468 aFillGradient
.SetName( aName
);
469 aFillGradient
.SetGradientValue(aGradient
);
470 pISet
->Put( aFillGradient
);
471 pISet
->Put( SvxColorItem(COL_WHITE
, EE_CHAR_COLOR
)); // font white
473 // Graphic > Shapes > Filled > Yellow
475 aName
=SdResId(STR_POOLSHEET_FILLED_YELLOW
);
476 pSheet
= &(pSSPool
->Make(aName
, SfxStyleFamily::Para
, nMask
));
477 pSheet
->SetParent(aFilledName
);
478 pSheet
->SetHelpId( aHelpFile
, HID_POOLSHEET_FILLED_YELLOW
);
479 pISet
= &pSheet
->GetItemSet();
481 aGradient
.SetStartColor( Color(0x00ffde59) ); // light gold 2
482 aGradient
.SetEndColor( Color(0x00b47804) ); // dark gold 2
483 aFillGradient
.SetName( aName
);
484 aFillGradient
.SetGradientValue(aGradient
);
485 pISet
->Put( aFillGradient
);
486 pISet
->Put( SvxColorItem(COL_WHITE
, EE_CHAR_COLOR
)); // font white
488 // Graphic > Shapes > Outlines
489 OUString
aOutlineName(SdResId(STR_POOLSHEET_OUTLINE
));
491 aName
= aOutlineName
;
492 pSheet
= &(pSSPool
->Make(aName
, SfxStyleFamily::Para
, nMask
));
493 pSheet
->SetHelpId( aHelpFile
, HID_POOLSHEET_OUTLINE
);
494 pSheet
->SetParent( aShapesName
);
495 pISet
= &pSheet
->GetItemSet();
496 pISet
->Put( XFillStyleItem(drawing::FillStyle_NONE
) ); // clear
497 pISet
->Put( XLineStyleItem(drawing::LineStyle_SOLID
) ); // solide line
498 pISet
->Put( XLineWidthItem(81) ); // 2.3 pt
499 pISet
->Put( XLineColorItem(OUString(), COL_BLACK
) ); // b/w
501 // Graphic > Shapes > Outlines > Blue
503 aName
=SdResId(STR_POOLSHEET_OUTLINE_BLUE
);
504 pSheet
= &(pSSPool
->Make(aName
, SfxStyleFamily::Para
, nMask
));
505 pSheet
->SetParent(aOutlineName
);
506 pSheet
->SetHelpId( aHelpFile
, HID_POOLSHEET_OUTLINE_BLUE
);
507 pISet
= &pSheet
->GetItemSet();
508 pISet
->Put( XLineColorItem(OUString(), Color(0x00355269)) ); // dark blue 2
509 pISet
->Put( SvxColorItem(Color(0x00355269), EE_CHAR_COLOR
)); // font color
511 // Graphic > Shapes > Outlines > Green
513 aName
=SdResId(STR_POOLSHEET_OUTLINE_GREEN
);
514 pSheet
= &(pSSPool
->Make(aName
, SfxStyleFamily::Para
, nMask
));
515 pSheet
->SetParent(aOutlineName
);
516 pSheet
->SetHelpId( aHelpFile
, HID_POOLSHEET_OUTLINE_GREEN
);
517 pISet
= &pSheet
->GetItemSet();
518 pISet
->Put( XLineColorItem(OUString(), Color(0x00127622)) ); // dark green 2
519 pISet
->Put( SvxColorItem(Color(0x00127622), EE_CHAR_COLOR
)); // font color
521 // Graphic > Shapes > Outlines > Red
523 aName
=SdResId(STR_POOLSHEET_OUTLINE_RED
);
524 pSheet
= &(pSSPool
->Make(aName
, SfxStyleFamily::Para
, nMask
));
525 pSheet
->SetParent(aOutlineName
);
526 pSheet
->SetHelpId( aHelpFile
, HID_POOLSHEET_OUTLINE_RED
);
527 pISet
= &pSheet
->GetItemSet();
528 pISet
->Put( XLineColorItem(OUString(), Color(0x00c9211e)) ); // dark red 2
529 pISet
->Put( SvxColorItem(Color(0x00c9211e), EE_CHAR_COLOR
)); // font color
531 // Graphic > Shapes > Outlines > Yellow
533 aName
=SdResId(STR_POOLSHEET_OUTLINE_YELLOW
);
534 pSheet
= &(pSSPool
->Make(aName
, SfxStyleFamily::Para
, nMask
));
535 pSheet
->SetParent(aOutlineName
);
536 pSheet
->SetHelpId( aHelpFile
, HID_POOLSHEET_OUTLINE_YELLOW
);
537 pISet
= &pSheet
->GetItemSet();
538 pISet
->Put( XLineStyleItem(drawing::LineStyle_SOLID
));
539 pISet
->Put( XLineColorItem(OUString(), Color(0x00b47804)) ); // dark gold 2
540 pISet
->Put( SvxColorItem(Color(0x00b47804), EE_CHAR_COLOR
)); // font color
545 aLinesName
= SdResId(STR_POOLSHEET_LINES
);
546 pSheet
= &(pSSPool
->Make(aLinesName
, SfxStyleFamily::Para
, nMask
));
547 pSheet
->SetParent( aGraphicName
);
548 pSheet
->SetHelpId( aHelpFile
, HID_POOLSHEET_LINES
);
549 pISet
= &pSheet
->GetItemSet();
550 pISet
->Put( XFillStyleItem(drawing::FillStyle_NONE
) ); // clear
551 pISet
->Put( XLineStyleItem(drawing::LineStyle_SOLID
) ); // solide line
552 pISet
->Put( XLineColorItem(OUString(), COL_BLACK
) ); // b/w
554 // Graphic > Lines > Measurements
556 aName
= SdResId(STR_POOLSHEET_MEASURE
);
557 pSheet
= &(pSSPool
->Make(aName
, SfxStyleFamily::Para
, nMask
));
558 pSheet
->SetParent(aLinesName
);
559 pSheet
->SetHelpId( aHelpFile
, HID_POOLSHEET_MEASURE
);
560 pISet
= &pSheet
->GetItemSet();
562 ::basegfx::B2DPolygon aArrow
; // arrows
563 aArrow
.append(::basegfx::B2DPoint(10.0, 0.0));
564 aArrow
.append(::basegfx::B2DPoint(0.0, 30.0));
565 aArrow
.append(::basegfx::B2DPoint(20.0, 30.0));
566 aArrow
.setClosed(true);
568 pISet
->Put(XLineStartItem(SvxResId(RID_SVXSTR_ARROW
),::basegfx::B2DPolyPolygon(aArrow
)));
569 pISet
->Put(XLineStartWidthItem(200));
570 pISet
->Put(XLineEndItem(SvxResId(RID_SVXSTR_ARROW
),::basegfx::B2DPolyPolygon(aArrow
)));
571 pISet
->Put(XLineEndWidthItem(200));
572 pISet
->Put(SdrYesNoItem(SDRATTR_MEASURESHOWUNIT
, true));
574 // Graphic > Lines > Dashed
576 aName
= SdResId(STR_POOLSHEET_LINES_DASHED
);
577 pSheet
= &(pSSPool
->Make(aName
, SfxStyleFamily::Para
, nMask
));
578 pSheet
->SetParent(aLinesName
);
579 pSheet
->SetHelpId( aHelpFile
, HID_POOLSHEET_LINES_DASHED
);
580 pISet
= &pSheet
->GetItemSet();
581 pISet
->Put( XLineStyleItem(drawing::LineStyle_DASH
) ); // dashed line
584 // Generate presentation templates for default layout.
585 OUString aPrefix
= SdResId(STR_LAYOUT_DEFAULT_NAME
);
586 pSSPool
->CreateLayoutStyleSheets(aPrefix
);
589 static Any
implMakeSolidCellStyle( SdStyleSheetPool
* pSSPool
, const OUString
& rName
, const OUString
& rParent
, const Color
& rColor
)
591 SfxStyleSheetBase
* pSheet
= &(pSSPool
->Make(rName
, SfxStyleFamily::Frame
, SfxStyleSearchBits::Auto
));
592 pSheet
->SetParent(rParent
);
593 SfxItemSet
* pISet
= &pSheet
->GetItemSet();
594 pISet
->Put(XFillStyleItem(drawing::FillStyle_SOLID
));
595 pISet
->Put(XFillColorItem(OUString(), rColor
));
597 return Any( Reference
< XStyle
>( static_cast< XWeak
* >( pSheet
), UNO_QUERY
) );
600 static void implCreateTableTemplate( const Reference
< XNameContainer
>& xTableFamily
, const OUString
& rName
, const Any
& rBody
, const Any
& rHeading
, const Any
& rBanding
)
602 if( !xTableFamily
.is() )
607 if( !xTableFamily
->hasByName( rName
) )
609 Reference
< XSingleServiceFactory
> xFactory( xTableFamily
, UNO_QUERY_THROW
);
610 Reference
< XNameReplace
> xDefaultTableStyle( xFactory
->createInstance(), UNO_QUERY_THROW
);
611 xTableFamily
->insertByName( rName
, Any( xDefaultTableStyle
) );
613 xDefaultTableStyle
->replaceByName( "body", rBody
);
614 xDefaultTableStyle
->replaceByName( "odd-rows" , rBanding
);
615 xDefaultTableStyle
->replaceByName( "odd-columns" , rBanding
);
616 xDefaultTableStyle
->replaceByName( "first-row" , rHeading
);
617 xDefaultTableStyle
->replaceByName( "first-column" , rHeading
);
618 xDefaultTableStyle
->replaceByName( "last-row" , rHeading
);
619 xDefaultTableStyle
->replaceByName( "last-column" , rHeading
);
624 OSL_FAIL("sd::implCreateTableTemplate(), exception caught!");
628 void SdDrawDocument::CreateDefaultCellStyles()
630 SdStyleSheetPool
* pSSPool
= static_cast< SdStyleSheetPool
* >(GetStyleSheetPool());
631 SfxStyleSheetBase
* pSheet
= nullptr;
633 Reference
< XNameContainer
> xTableFamily( pSSPool
->getByName( "table" ), UNO_QUERY
);
635 // ---- Default -----------------------------------------------
637 OUString
aDefaultCellStyleName( "default" );
639 pSheet
= &(pSSPool
->Make(aDefaultCellStyleName
, SfxStyleFamily::Frame
, SfxStyleSearchBits::Auto
));
640 pSheet
->SetHelpId( OUString(), HID_SD_CELL_STYLE_DEFAULT
);
641 SfxItemSet
& rISet
= pSheet
->GetItemSet();
643 rISet
.Put(XFillStyleItem(drawing::FillStyle_SOLID
));
644 rISet
.Put(XFillColorItem(OUString(), Color(0x00ccccff)));
646 vcl::Font aLatinFont
, aCJKFont
, aCTLFont
;
648 getDefaultFonts( aLatinFont
, aCJKFont
, aCTLFont
);
650 SvxFontItem
aSvxFontItem( aLatinFont
.GetFamilyType(), aLatinFont
.GetFamilyName(), aLatinFont
.GetStyleName(), aLatinFont
.GetPitch(),
651 aLatinFont
.GetCharSet(), EE_CHAR_FONTINFO
);
653 SvxFontItem
aSvxFontItemCJK( aCJKFont
.GetFamilyType(), aCJKFont
.GetFamilyName(), aCJKFont
.GetStyleName(), aCJKFont
.GetPitch(),
654 aCJKFont
.GetCharSet(), EE_CHAR_FONTINFO_CJK
);
656 SvxFontItem
aSvxFontItemCTL( aCTLFont
.GetFamilyType(), aCTLFont
.GetFamilyName(), aCTLFont
.GetStyleName(), aCTLFont
.GetPitch(),
657 aCTLFont
.GetCharSet(), EE_CHAR_FONTINFO_CTL
);
659 rISet
.Put( aSvxFontItem
);
660 rISet
.Put( aSvxFontItemCJK
);
661 rISet
.Put( aSvxFontItemCTL
);
663 rISet
.Put( SvxFontHeightItem( 635, 100, EE_CHAR_FONTHEIGHT
) ); // sj: (i33745) changed default from 24 to 18 pt
664 rISet
.Put( SvxFontHeightItem( 635, 100, EE_CHAR_FONTHEIGHT_CJK
) ); // 18 pt
665 rISet
.Put( SvxFontHeightItem( convertFontHeightToCTL( 635 ), 100, EE_CHAR_FONTHEIGHT_CTL
) ); // 18 pt
667 rISet
.Put(SvxColorItem(COL_AUTO
, EE_CHAR_COLOR
));
669 // Paragraph attributes (Edit Engine)
670 rISet
.Put(SvxLRSpaceItem(EE_PARA_LRSPACE
));
671 rISet
.Put(SvxULSpaceItem(EE_PARA_ULSPACE
));
673 rISet
.Put( makeSdrTextLeftDistItem( 250 ) );
674 rISet
.Put( makeSdrTextRightDistItem( 250 ) );
675 rISet
.Put( makeSdrTextUpperDistItem( 130 ) );
676 rISet
.Put( makeSdrTextLowerDistItem( 130 ) );
678 rISet
.Put( SvxLineSpacingItem( LINE_SPACE_DEFAULT_HEIGHT
, EE_PARA_SBL
) );
679 rISet
.Put( SvxAutoKernItem( true, EE_CHAR_PAIRKERNING
) );
680 rISet
.Put( SdrTextVertAdjustItem(SDRTEXTVERTADJUST_TOP
) );
681 rISet
.Put( SdrTextHorzAdjustItem(SDRTEXTHORZADJUST_LEFT
) );
683 Color
aWhite( COL_WHITE
);
684 ::editeng::SvxBorderLine
aBorderLine(
685 &aWhite
, 1, SvxBorderLineStyle::SOLID
);
687 SvxBoxItem
aBoxItem( SDRATTR_TABLE_BORDER
);
688 aBoxItem
.SetLine( &aBorderLine
, SvxBoxItemLine::TOP
);
689 aBoxItem
.SetLine( &aBorderLine
, SvxBoxItemLine::BOTTOM
);
690 aBoxItem
.SetLine( &aBorderLine
, SvxBoxItemLine::LEFT
);
691 aBoxItem
.SetLine( &aBorderLine
, SvxBoxItemLine::RIGHT
);
693 rISet
.Put( aBoxItem
);
695 // ---- default --------------------------------------------------
697 Any
aGray1( implMakeSolidCellStyle( pSSPool
, "gray1" , aDefaultCellStyleName
, Color(230,230,230)));
698 Any
aGray2( implMakeSolidCellStyle( pSSPool
, "gray2" , aDefaultCellStyleName
, Color(204,204,204)));
699 Any
aGray3( implMakeSolidCellStyle( pSSPool
, "gray3" , aDefaultCellStyleName
, Color(179,179,179)));
701 implCreateTableTemplate( xTableFamily
, "default" , aGray1
, aGray3
, aGray2
);
703 // ---- BW ------------------------------------------------
705 Any
aBW1( implMakeSolidCellStyle( pSSPool
, "bw1" , aDefaultCellStyleName
, Color(255,255,255)));
706 Any
aBW2( implMakeSolidCellStyle( pSSPool
, "bw2" , aDefaultCellStyleName
, Color(230,230,230)));
707 Any
aBW3( implMakeSolidCellStyle( pSSPool
, "bw3" , aDefaultCellStyleName
, Color(0,0,0)));
709 implCreateTableTemplate( xTableFamily
, "bw" , aBW1
, aBW3
, aBW2
);
711 // ---- Orange --------------------------------------------------
713 Any
aOrange1( implMakeSolidCellStyle( pSSPool
, "orange1" , aDefaultCellStyleName
, Color(255,204,153)));
714 Any
aOrange2( implMakeSolidCellStyle( pSSPool
, "orange2" , aDefaultCellStyleName
, Color(255,153,102)));
715 Any
aOrange3( implMakeSolidCellStyle( pSSPool
, "orange3" , aDefaultCellStyleName
, Color(255,102,51)));
717 implCreateTableTemplate( xTableFamily
, "orange" , aOrange1
, aOrange3
, aOrange2
);
719 // ---- Turquoise --------------------------------------------------
721 Any
aTurquoise1( implMakeSolidCellStyle( pSSPool
, "turquoise1" , aDefaultCellStyleName
, Color(71,184,184)));
722 Any
aTurquoise2( implMakeSolidCellStyle( pSSPool
, "turquoise2" , aDefaultCellStyleName
, Color(51,163,163)));
723 Any
aTurquoise3( implMakeSolidCellStyle( pSSPool
, "turquoise3" , aDefaultCellStyleName
, Color(25,138,138)));
725 implCreateTableTemplate( xTableFamily
, "turquoise" , aTurquoise1
, aTurquoise3
, aTurquoise2
);
727 // ---- Gray ------------------------------------------------
729 Any
aBlue1( implMakeSolidCellStyle( pSSPool
, "blue1" , aDefaultCellStyleName
, Color(153,204,255)));
730 Any
aBlue2( implMakeSolidCellStyle( pSSPool
, "blue2" , aDefaultCellStyleName
, Color(0,153,255)));
731 Any
aBlue3( implMakeSolidCellStyle( pSSPool
, "blue3" , aDefaultCellStyleName
, Color(0,102,204)));
733 implCreateTableTemplate( xTableFamily
, "blue" , aBlue1
, aBlue3
, aBlue2
);
735 // ---- Sun ------------------------------------------------
737 Any
aSun1( implMakeSolidCellStyle( pSSPool
, "sun1" , aDefaultCellStyleName
, Color(230,230,255)));
738 Any
aSun2( implMakeSolidCellStyle( pSSPool
, "sun2" , aDefaultCellStyleName
, Color(204,204,255)));
739 Any
aSun3( implMakeSolidCellStyle( pSSPool
, "sun3" , aDefaultCellStyleName
, Color(153,153,255)));
741 implCreateTableTemplate( xTableFamily
, "sun" , aSun1
, aSun3
, aSun2
);
743 // ---- Earth ----------------------------------------------
745 Any
aEarth1( implMakeSolidCellStyle( pSSPool
, "earth1" , aDefaultCellStyleName
, Color(255,255,204)));
746 Any
aEarth2( implMakeSolidCellStyle( pSSPool
, "earth2" , aDefaultCellStyleName
, Color(255,204,153)));
747 Any
aEarth3( implMakeSolidCellStyle( pSSPool
, "earth3" , aDefaultCellStyleName
, Color(204,102,51)));
749 implCreateTableTemplate( xTableFamily
, "earth" , aEarth1
, aEarth3
, aEarth2
);
751 // ---- Green ----------------------------------------------
753 Any
aGreen1( implMakeSolidCellStyle( pSSPool
, "green1" , aDefaultCellStyleName
, Color(255,255,204)));
754 Any
aGreen2( implMakeSolidCellStyle( pSSPool
, "green2" , aDefaultCellStyleName
, Color(148,189,94)));
755 Any
aGreen3( implMakeSolidCellStyle( pSSPool
, "green3" , aDefaultCellStyleName
, Color(92,133,38)));
757 implCreateTableTemplate( xTableFamily
, "green" , aGreen1
, aGreen3
, aGreen2
);
759 // ---- Seaweed ----------------------------------------------
761 Any
aSeetang1( implMakeSolidCellStyle( pSSPool
, "seetang1" , aDefaultCellStyleName
, Color(204,255,255)));
762 Any
aSeetang2( implMakeSolidCellStyle( pSSPool
, "seetang2" , aDefaultCellStyleName
, Color(71,184,184)));
763 Any
aSeetang3( implMakeSolidCellStyle( pSSPool
, "seetang3" , aDefaultCellStyleName
, Color(51,163,163)));
765 implCreateTableTemplate( xTableFamily
, "seetang" , aSeetang1
, aSeetang3
, aSeetang2
);
767 // ---- LightBlue ----------------------------------------------
769 Any
aLightBlue1( implMakeSolidCellStyle( pSSPool
, "lightblue1" , aDefaultCellStyleName
, Color(255,255,255)));
770 Any
aLightBlue2( implMakeSolidCellStyle( pSSPool
, "lightblue2" , aDefaultCellStyleName
, Color(230,230,255)));
771 Any
aLightBlue3( implMakeSolidCellStyle( pSSPool
, "lightblue3" , aDefaultCellStyleName
, Color(153,153,204)));
773 implCreateTableTemplate( xTableFamily
, "lightblue" , aLightBlue1
, aLightBlue3
, aLightBlue2
);
775 // ---- Yellow ----------------------------------------------
777 Any
aYellow1( implMakeSolidCellStyle( pSSPool
, "yellow1" , aDefaultCellStyleName
, Color(255,255,204)));
778 Any
aYellow2( implMakeSolidCellStyle( pSSPool
, "yellow2" , aDefaultCellStyleName
, Color(255,255,153)));
779 Any
aYellow3( implMakeSolidCellStyle( pSSPool
, "yellow3" , aDefaultCellStyleName
, Color(255,204,153)));
781 implCreateTableTemplate( xTableFamily
, "yellow" , aYellow1
, aYellow3
, aYellow2
);
784 // Number of pages that reference a master page
785 sal_uInt16
SdDrawDocument::GetMasterPageUserCount(SdrPage
const * pMaster
) const
787 sal_uInt16 nResult
= 0;
789 sal_uInt16 nPageCount
= GetPageCount();
791 for (nPage
= 0; nPage
< nPageCount
; nPage
++)
793 const SdrPage
* pPage
= GetPage(nPage
);
795 if(pPage
->TRG_HasMasterPage())
797 if(&(pPage
->TRG_GetMasterPage()) == pMaster
)
806 // Finish OnlineSpelling in the background
808 void SdDrawDocument::StopOnlineSpelling()
810 if (mpOnlineSpellingIdle
&& mpOnlineSpellingIdle
->IsActive())
812 mpOnlineSpellingIdle
->Stop();
815 mpOnlineSpellingIdle
.reset();
816 mpOnlineSpellingList
.reset();
819 // Start OnlineSpelling in the background
820 void SdDrawDocument::StartOnlineSpelling(bool bForceSpelling
)
822 if ( !mbOnlineSpell
|| !(bForceSpelling
|| mbInitialOnlineSpellingEnabled
) ||
823 !mpDocSh
|| mpDocSh
->IsReadOnly() )
826 StopOnlineSpelling();
828 SdOutliner
* pOutl
= GetInternalOutliner();
830 Reference
< XSpellChecker1
> xSpellChecker( LinguMgr::GetSpellChecker() );
831 if ( xSpellChecker
.is() )
832 pOutl
->SetSpeller( xSpellChecker
);
834 Reference
< XHyphenator
> xHyphenator( LinguMgr::GetHyphenator() );
835 if( xHyphenator
.is() )
836 pOutl
->SetHyphenator( xHyphenator
);
838 pOutl
->SetDefaultLanguage( meLanguage
);
840 mpOnlineSpellingList
.reset(new ShapeList
);
843 for ( nPage
= 0; nPage
< GetPageCount(); nPage
++ )
845 // Search in all pages
846 FillOnlineSpellingList(static_cast<SdPage
*>(GetPage(nPage
)));
849 for (nPage
= 0; nPage
< GetMasterPageCount(); nPage
++)
851 // Search all master pages
852 FillOnlineSpellingList(static_cast<SdPage
*>( GetMasterPage(nPage
) ));
855 mpOnlineSpellingList
->seekShape(0);
856 mpOnlineSpellingIdle
.reset(new Idle("OnlineSpelling"));
857 mpOnlineSpellingIdle
->SetInvokeHandler( LINK(this, SdDrawDocument
, OnlineSpellingHdl
) );
858 mpOnlineSpellingIdle
->SetPriority(TaskPriority::LOWEST
);
859 mpOnlineSpellingIdle
->Start();
862 // Fill OnlineSpelling list
863 void SdDrawDocument::FillOnlineSpellingList(SdPage
const * pPage
)
865 SdrObjListIter
aIter(pPage
, SdrIterMode::Flat
);
867 while (aIter
.IsMore())
869 SdrObject
* pObj
= aIter
.Next();
874 if (pObj
->GetOutlinerParaObject())
876 // Found a text object
877 mpOnlineSpellingList
->addShape(*pObj
);
879 else if (pObj
->GetObjIdentifier() == OBJ_GRUP
)
881 // Found a group object
882 SdrObjListIter
aGroupIter(static_cast< SdrObjGroup
* >(pObj
)->GetSubList(), SdrIterMode::DeepNoGroups
);
884 bool bSubTextObjFound
= false;
886 while (aGroupIter
.IsMore() && !bSubTextObjFound
)
888 if (aGroupIter
.Next()->GetOutlinerParaObject())
890 // Found a text object in a group object
891 bSubTextObjFound
= true;
895 if (bSubTextObjFound
)
897 mpOnlineSpellingList
->addShape(*pObj
);
903 // OnlineSpelling in the background
904 IMPL_LINK_NOARG(SdDrawDocument
, OnlineSpellingHdl
, Timer
*, void)
906 if (mpOnlineSpellingList
!=nullptr
907 && ( !mbOnlineSpell
|| mpOnlineSpellingList
->hasMore()))
910 SdrObject
* pObj
= mpOnlineSpellingList
->getNextShape();
914 if (pObj
->GetOutlinerParaObject() && dynamic_cast< const SdrTextObj
*>( pObj
) != nullptr)
917 SpellObject(static_cast<SdrTextObj
*>(pObj
));
919 else if (pObj
->GetObjIdentifier() == OBJ_GRUP
)
921 // Found a group object
922 SdrObjListIter
aGroupIter(static_cast< SdrObjGroup
* >(pObj
)->GetSubList(), SdrIterMode::DeepNoGroups
);
925 while (aGroupIter
.IsMore())
927 SdrObject
* pSubObj
= aGroupIter
.Next();
929 if (pSubObj
->GetOutlinerParaObject() && dynamic_cast< SdrTextObj
*>( pSubObj
) != nullptr)
931 // Found a text object in a group object
932 SpellObject(static_cast<SdrTextObj
*>(pSubObj
));
939 mpOnlineSpellingIdle
->Start();
943 // Initial spelling has finished
944 mbInitialOnlineSpellingEnabled
= false;
947 StopOnlineSpelling();
949 mpOnlineSearchItem
.reset();
953 // Spell object (for OnlineSpelling)
954 void SdDrawDocument::SpellObject(SdrTextObj
* pObj
)
956 if (!(pObj
&& pObj
->GetOutlinerParaObject()) /* && pObj != pView->GetTextEditObject() */)
959 mbHasOnlineSpellErrors
= false;
960 SdOutliner
* pOutl
= GetInternalOutliner();
961 pOutl
->SetUpdateMode(true);
962 Link
<EditStatus
&,void> aEvtHdl
= pOutl
->GetStatusEventHdl();
963 pOutl
->SetStatusEventHdl(LINK(this, SdDrawDocument
, OnlineSpellEventHdl
));
965 OutlinerMode nOldOutlMode
= pOutl
->GetMode();
966 OutlinerMode nOutlMode
= OutlinerMode::TextObject
;
967 if (pObj
->GetObjInventor() == SdrInventor::Default
&&
968 pObj
->GetObjIdentifier() == OBJ_OUTLINETEXT
)
970 nOutlMode
= OutlinerMode::OutlineObject
;
972 pOutl
->Init( nOutlMode
);
974 // Put text into the outliner
975 pOutl
->SetText(*pObj
->GetOutlinerParaObject());
977 if (!mpOnlineSearchItem
|| pOutl
->HasText(*mpOnlineSearchItem
))
980 pOutl
->CompleteOnlineSpelling();
982 if (mbHasOnlineSpellErrors
)
984 std::unique_ptr
<OutlinerParaObject
> pOPO
= pOutl
->CreateParaObject();
987 if (!( *pOPO
== *pObj
->GetOutlinerParaObject() ) ||
988 !pObj
->GetOutlinerParaObject()->isWrongListEqual( *pOPO
))
990 sd::ModifyGuard
aGuard( this );
992 // taking text from the outliner
993 // use non-broadcasting version to avoid O(n^2)
994 pObj
->NbcSetOutlinerParaObject( std::move(pOPO
) );
1000 pOutl
->SetStatusEventHdl(aEvtHdl
);
1001 pOutl
->SetUpdateMode(false);
1002 pOutl
->Init( nOldOutlMode
);
1003 mbHasOnlineSpellErrors
= false;
1006 // Object was inserted into model
1007 void SdDrawDocument::InsertObject(SdrObject
* pObj
)
1009 if(mpOnlineSpellingList
&& pObj
)
1011 if (pObj
->GetOutlinerParaObject() || (pObj
->GetObjIdentifier() == OBJ_GRUP
))
1013 // Add object to OnlineSpelling list
1014 mpOnlineSpellingList
->addShape(*pObj
);
1019 // Object removed from model
1020 void SdDrawDocument::RemoveObject(SdrObject
* pObj
)
1022 if(mpOnlineSpellingList
&& pObj
)
1024 if (pObj
->GetOutlinerParaObject() || (pObj
->GetObjIdentifier() == OBJ_GRUP
))
1026 // Replace object in OnlineSpelling list by 0 pointer
1027 mpOnlineSpellingList
->removeShape(*pObj
);
1032 // Callback for ExecuteSpellPopup()
1033 IMPL_LINK(SdDrawDocument
, OnlineSpellEventHdl
, EditStatus
&, rEditStat
, void)
1035 EditStatusFlags nStat
= rEditStat
.GetStatusWord();
1036 mbHasOnlineSpellErrors
= bool(nStat
& EditStatusFlags::WRONGWORDCHANGED
);
1039 // Callback for ExecuteSpellPopup()
1041 // removed link and replaced with Imp method
1042 void SdDrawDocument::ImpOnlineSpellCallback(SpellCallbackInfo
const * pInfo
, SdrObject
* pObj
, SdrOutliner
const * pOutl
)
1044 mpOnlineSearchItem
.reset();
1046 SpellCallbackCommand nCommand
= pInfo
->nCommand
;
1048 if (nCommand
== SpellCallbackCommand::IGNOREWORD
1049 // restart when add to dictionary takes place, too.
1050 || nCommand
== SpellCallbackCommand::ADDTODICTIONARY
)
1052 if(pOutl
&& dynamic_cast< const SdrTextObj
*>( pObj
))
1054 bool bModified(IsChanged());
1055 static_cast<SdrTextObj
*>(pObj
)->SetOutlinerParaObject(pOutl
->CreateParaObject());
1056 SetChanged(bModified
);
1057 pObj
->BroadcastObjectChange();
1060 mpOnlineSearchItem
.reset(new SvxSearchItem( SID_SEARCH_ITEM
) );
1061 mpOnlineSearchItem
->SetSearchString(pInfo
->aWord
);
1062 StartOnlineSpelling();
1064 else if (nCommand
== SpellCallbackCommand::STARTSPELLDLG
)
1065 SfxViewFrame::Current()->GetDispatcher()->Execute( SID_SPELL_DIALOG
, SfxCallMode::ASYNCHRON
);
1066 else if (nCommand
== SpellCallbackCommand::AUTOCORRECT_OPTIONS
)
1067 SfxViewFrame::Current()->GetDispatcher()->Execute( SID_AUTO_CORRECT_DLG
, SfxCallMode::ASYNCHRON
);
1070 // Return formatted page number (1, I, i, a, etc.)
1071 OUString
SdDrawDocument::CreatePageNumValue(sal_uInt16 nNum
) const
1073 OUString aPageNumValue
;
1074 bool bUpper
= false;
1076 switch (mePageNumType
)
1078 case css::style::NumberingType::CHARS_UPPER_LETTER
:
1079 aPageNumValue
+= OUStringChar( sal_Unicode((nNum
- 1) % 26 + 'A') );
1081 case css::style::NumberingType::CHARS_LOWER_LETTER
:
1082 aPageNumValue
+= OUStringChar( sal_Unicode((nNum
- 1) % 26 + 'a') );
1084 case css::style::NumberingType::ROMAN_UPPER
:
1087 case css::style::NumberingType::ROMAN_LOWER
:
1088 aPageNumValue
+= SvxNumberFormat::CreateRomanString(nNum
, bUpper
);
1090 case css::style::NumberingType::NUMBER_NONE
:
1091 aPageNumValue
= " ";
1094 aPageNumValue
+= OUString::number(nNum
);
1097 return aPageNumValue
;
1100 // Rename layout template
1101 // Keep in mind that rOldLayoutName contains the _complete_ name of the layout
1102 // (including ~LT~). This is unlike rNewName.
1103 void SdDrawDocument::RenameLayoutTemplate(const OUString
& rOldLayoutName
, const OUString
& rNewName
)
1105 OUString
aSep(SD_LT_SEPARATOR
);
1106 OUString
aOldName(rOldLayoutName
);
1107 sal_Int32 nPos
= aOldName
.indexOf( aSep
);
1109 // erase everything after '~LT~'
1111 aOldName
= aOldName
.copy(0, nPos
+ aSep
.getLength());
1113 std::vector
<StyleReplaceData
> aReplList
;
1114 SfxStyleSheetIterator
aIter(mxStyleSheetPool
.get(), SfxStyleFamily::Page
);
1115 SfxStyleSheetBase
* pSheet
= aIter
.First();
1119 OUString aSheetName
= pSheet
->GetName();
1121 // if the sheetname starts with aOldName + "~LT~"
1122 if (aSheetName
.startsWith(aOldName
))
1124 aSheetName
= aSheetName
.replaceAt(0, aOldName
.getLength() - aSep
.getLength(), rNewName
);
1126 StyleReplaceData aReplData
;
1127 aReplData
.nFamily
= pSheet
->GetFamily();
1128 aReplData
.nNewFamily
= pSheet
->GetFamily();
1129 aReplData
.aName
= pSheet
->GetName();
1130 aReplData
.aNewName
= aSheetName
;
1131 aReplList
.push_back(aReplData
);
1133 pSheet
->SetName(aSheetName
);
1136 pSheet
= aIter
.Next();
1139 // Now set the layout name of the drawing and the notes page, as well as
1140 // their master pages.
1141 OUString aPageLayoutName
= rNewName
+ aSep
+ STR_LAYOUT_OUTLINE
;
1143 // Inform all text objects on pages that use the renamed layout and set the
1146 for (nPage
= 0; nPage
< GetPageCount(); nPage
++)
1148 SdPage
* pPage
= static_cast<SdPage
*>(GetPage(nPage
));
1149 OUString
aTemp(pPage
->GetLayoutName());
1151 if (aTemp
== rOldLayoutName
)
1153 pPage
->SetLayoutName(aPageLayoutName
);
1155 for (size_t nObj
= 0; nObj
< pPage
->GetObjCount(); ++nObj
)
1157 SdrObject
* pObj
= pPage
->GetObj(nObj
);
1159 if (pObj
->GetObjInventor() == SdrInventor::Default
)
1161 switch( pObj
->GetObjIdentifier() )
1164 case OBJ_OUTLINETEXT
:
1167 OutlinerParaObject
* pOPO
= static_cast<SdrTextObj
*>(pObj
)->GetOutlinerParaObject();
1171 for (const auto& rRepl
: aReplList
)
1172 pOPO
->ChangeStyleSheets( rRepl
.aName
, rRepl
.nFamily
, rRepl
.aNewName
, rRepl
.nNewFamily
);
1185 // Now do this again for all master pages.
1186 // The affected master pages get the name of the layout as their page name.
1187 for (nPage
= 0; nPage
< GetMasterPageCount(); nPage
++)
1189 SdPage
* pPage
= static_cast<SdPage
*>( GetMasterPage(nPage
) );
1190 OUString
aTemp(pPage
->GetLayoutName());
1192 if (aTemp
== rOldLayoutName
)
1194 pPage
->SetLayoutName(aPageLayoutName
);
1195 pPage
->SetName(rNewName
);
1197 for (size_t nObj
= 0; nObj
< pPage
->GetObjCount(); ++nObj
)
1199 SdrObject
* pObj
= pPage
->GetObj(nObj
);
1201 if (pObj
->GetObjInventor() == SdrInventor::Default
)
1203 switch(pObj
->GetObjIdentifier())
1206 case OBJ_OUTLINETEXT
:
1209 OutlinerParaObject
* pOPO
= static_cast<SdrTextObj
*>(pObj
)->GetOutlinerParaObject();
1213 for (const auto& rRepl
: aReplList
)
1214 pOPO
->ChangeStyleSheets( rRepl
.aName
, rRepl
.nFamily
, rRepl
.aNewName
, rRepl
.nNewFamily
);
1228 // Set outliner defaults (pool defaults)
1229 void SdDrawDocument::SetTextDefaults() const
1231 // BulletItem and BulletFont for Title and Outline
1232 SvxBulletItem
aBulletItem(EE_PARA_BULLET
);
1233 vcl::Font
aBulletFont( SdStyleSheetPool::GetBulletFont() );
1234 aBulletFont
.SetFontSize(Size(0,846)); // 24 pt
1235 aBulletItem
.SetFont(aBulletFont
);
1236 aBulletItem
.SetStyle(SvxBulletStyle::BULLET
);
1237 aBulletItem
.SetStart(1);
1238 aBulletItem
.SetScale(45); // In percent
1239 aBulletItem
.SetSymbol( 0x25CF ); // In points
1240 m_pItemPool
->SetPoolDefaultItem( aBulletItem
);
1243 SvxNumberFormat
aNumberFormat(SVX_NUM_CHAR_SPECIAL
);
1244 aNumberFormat
.SetBulletFont(&aBulletFont
);
1245 aNumberFormat
.SetBulletChar( 0x25CF ); // StarBats: 0xF000 + 34
1246 aNumberFormat
.SetBulletRelSize(45);
1247 aNumberFormat
.SetBulletColor(COL_AUTO
);
1248 aNumberFormat
.SetStart(1);
1249 aNumberFormat
.SetNumAdjust(SvxAdjust::Left
);
1251 SvxNumRule
aNumRule( SvxNumRuleFlags::BULLET_REL_SIZE
| SvxNumRuleFlags::BULLET_COLOR
, SVX_MAX_NUM
, false);
1253 //aNumberFormat.SetAbsLSpace( 0 );
1254 //aNumberFormat.SetFirstLineOffset( 0 );
1255 //aNumRule.SetLevel( 0, aNumberFormat );
1257 for( sal_uInt16 i
= 0; i
< aNumRule
.GetLevelCount(); i
++ )
1259 const auto nLSpace
= (i
+ 1) * 600;
1260 aNumberFormat
.SetAbsLSpace(nLSpace
);
1261 aNumberFormat
.SetFirstLineOffset(-600);
1262 aNumRule
.SetLevel( i
, aNumberFormat
);
1265 SvxNumBulletItem
aNumBulletItem( aNumRule
, EE_PARA_NUMBULLET
);
1266 m_pItemPool
->SetPoolDefaultItem( aNumBulletItem
);
1269 css::text::WritingMode
SdDrawDocument::GetDefaultWritingMode() const
1271 const SfxPoolItem
* pItem
= ( m_pItemPool
? m_pItemPool
->GetPoolDefaultItem( EE_PARA_WRITINGDIR
) : nullptr );
1272 css::text::WritingMode eRet
= css::text::WritingMode_LR_TB
;
1276 switch( static_cast<const SvxFrameDirectionItem
&>( *pItem
).GetValue() )
1278 case SvxFrameDirection::Horizontal_LR_TB
: eRet
= css::text::WritingMode_LR_TB
; break;
1279 case SvxFrameDirection::Horizontal_RL_TB
: eRet
= css::text::WritingMode_RL_TB
; break;
1280 case SvxFrameDirection::Vertical_RL_TB
: eRet
= css::text::WritingMode_TB_RL
; break;
1283 OSL_FAIL( "Frame direction not supported yet" );
1291 void SdDrawDocument::SetDefaultWritingMode(css::text::WritingMode eMode
)
1296 SvxFrameDirection nVal
;
1299 case css::text::WritingMode_LR_TB
: nVal
= SvxFrameDirection::Horizontal_LR_TB
; break;
1300 case css::text::WritingMode_RL_TB
: nVal
= SvxFrameDirection::Horizontal_RL_TB
; break;
1301 case css::text::WritingMode_TB_RL
: nVal
= SvxFrameDirection::Vertical_RL_TB
; break;
1303 OSL_FAIL( "Frame direction not supported yet" );
1307 SvxFrameDirectionItem
aModeItem( nVal
, EE_PARA_WRITINGDIR
);
1308 m_pItemPool
->SetPoolDefaultItem( aModeItem
);
1310 SvxAdjustItem
aAdjust( SvxAdjust::Left
, EE_PARA_JUST
);
1312 if( eMode
== css::text::WritingMode_RL_TB
)
1313 aAdjust
.SetAdjust( SvxAdjust::Right
);
1315 m_pItemPool
->SetPoolDefaultItem( aAdjust
);
1318 void SdDrawDocument::getDefaultFonts( vcl::Font
& rLatinFont
, vcl::Font
& rCJKFont
, vcl::Font
& rCTLFont
)
1320 LanguageType eLatin
= GetLanguage( EE_CHAR_LANGUAGE
);
1322 // If the UI language is Korean, the default Latin font has to
1323 // be queried for Korean, too (the Latin language from the document can't be Korean).
1324 // This is the same logic as in SwDocShell::InitNew.
1325 LanguageType eUiLanguage
= Application::GetSettings().GetUILanguageTag().getLanguageType();
1326 if (MsLangId::isKorean(eUiLanguage
))
1327 eLatin
= eUiLanguage
;
1329 rLatinFont
= OutputDevice::GetDefaultFont( DefaultFontType::LATIN_PRESENTATION
, eLatin
, GetDefaultFontFlags::OnlyOne
);
1330 rCJKFont
= OutputDevice::GetDefaultFont( DefaultFontType::CJK_PRESENTATION
, GetLanguage( EE_CHAR_LANGUAGE_CJK
), GetDefaultFontFlags::OnlyOne
);
1331 rCTLFont
= OutputDevice::GetDefaultFont( DefaultFontType::CTL_PRESENTATION
, GetLanguage( EE_CHAR_LANGUAGE_CTL
), GetDefaultFontFlags::OnlyOne
) ;
1334 /* converts the given western font height to a corresponding ctl font height, depending on the system language */
1335 sal_uInt32
SdDrawDocument::convertFontHeightToCTL( sal_uInt32 nWesternFontHeight
)
1337 LanguageType eRealCTLLanguage
= Application::GetSettings().GetLanguageTag().getLanguageType();
1338 if( LANGUAGE_THAI
== eRealCTLLanguage
)
1340 // http://specs.openoffice.org/g11n/font_sizes/42775_42725_Individual_configurable_font_size_for_default_fonts.odt
1341 double fTemp
= double(nWesternFontHeight
) * 1.333;
1342 nWesternFontHeight
= static_cast<sal_uInt32
>(fTemp
);
1343 // make some nice values for UI that displays PT instead of 1/100th mm
1344 nWesternFontHeight
= ((nWesternFontHeight
* 72) + 1270) / 2540L;
1345 nWesternFontHeight
= ((nWesternFontHeight
* 2540L) + 36) / 72;
1347 return nWesternFontHeight
;
1350 SdStyleSheetPool
* SdDrawDocument::GetSdStyleSheetPool() const
1352 return dynamic_cast< SdStyleSheetPool
* >( GetStyleSheetPool() );
1355 ModifyGuard::ModifyGuard( SdDrawDocument
* pDoc
)
1356 : mpDocShell( nullptr ), mpDoc( pDoc
)
1361 void ModifyGuard::init()
1365 mpDoc
= mpDocShell
->GetDoc();
1369 mpDocShell
= mpDoc
->GetDocSh();
1372 mbIsEnableSetModified
= mpDocShell
&& mpDocShell
->IsEnableSetModified();
1373 mbIsDocumentChanged
= mpDoc
&& mpDoc
->IsChanged();
1375 if( mbIsEnableSetModified
)
1376 mpDocShell
->EnableSetModified( false );
1379 ModifyGuard::~ModifyGuard()
1381 if( mbIsEnableSetModified
)
1382 mpDocShell
->EnableSetModified();
1384 if( mpDoc
&& (mpDoc
->IsChanged() != mbIsDocumentChanged
) )
1385 mpDoc
->SetChanged(mbIsDocumentChanged
);
1388 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */