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
{ namespace sun
{ namespace star
{ namespace 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;
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(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
);
259 // Default > Object no fill no line
261 aName
= SdResId(STR_POOLSHEET_OBJNOLINENOFILL
);
262 pSheet
= &(pSSPool
->Make(aName
, SfxStyleFamily::Para
, nMask
));
263 pSheet
->SetParent(aStdName
);
264 pSheet
->SetHelpId( aHelpFile
, HID_POOLSHEET_OBJNOLINENOFILL
);
265 pISet
= &pSheet
->GetItemSet();
267 pISet
->Put(XFillStyleItem(drawing::FillStyle_NONE
));
268 pISet
->Put(XLineStyleItem(drawing::LineStyle_NONE
));
276 aTextName
= SdResId(STR_POOLSHEET_TEXT
);
277 pSheet
= &(pSSPool
->Make(aTextName
, SfxStyleFamily::Para
, nMask
));
278 pSheet
->SetHelpId( aHelpFile
, HID_POOLSHEET_TEXT
);
279 pISet
= &pSheet
->GetItemSet();
280 aSvxFontItem
.SetFamilyName("Noto Sans");
281 pISet
->Put( aSvxFontItem
); // Noto Sans
282 pISet
->Put(XFillStyleItem(drawing::FillStyle_SOLID
)); // solid fill
283 pISet
->Put(XFillColorItem(OUString(), Color(0xeeeeee))); // light gray 5
284 pISet
->Put(XLineStyleItem(drawing::LineStyle_SOLID
)); // solid fill
285 pISet
->Put(XLineColorItem(OUString(), Color(0xcccccc))); // light gray 3
290 aA4Name
= SdResId(STR_POOLSHEET_A4
);
291 pSheet
= &(pSSPool
->Make(aA4Name
, SfxStyleFamily::Para
, nMask
));
292 pSheet
->SetParent( aTextName
);
293 pSheet
->SetHelpId( aHelpFile
, HID_POOLSHEET_A4
);
294 pISet
= &pSheet
->GetItemSet();
295 pISet
->Put(SvxFontHeightItem(635, 100, EE_CHAR_FONTHEIGHT
)); // 18 pt
296 pISet
->Put(XFillStyleItem(drawing::FillStyle_NONE
)); // no filling
301 aName
= SdResId(STR_POOLSHEET_A4_TITLE
);
302 pSheet
= &(pSSPool
->Make(aName
, SfxStyleFamily::Para
, nMask
));
303 pSheet
->SetParent( aA4Name
);
304 pSheet
->SetHelpId( aHelpFile
, HID_POOLSHEET_A4_TITLE
);
305 pISet
= &pSheet
->GetItemSet();
306 pISet
->Put(SvxFontHeightItem(1551, 100, EE_CHAR_FONTHEIGHT
)); // 44 pt
307 pISet
->Put(XLineStyleItem(drawing::LineStyle_NONE
)); // no border
309 // Text > A4 > Headline
311 aName
= SdResId(STR_POOLSHEET_A4_HEADLINE
);
312 pSheet
= &(pSSPool
->Make(aName
, SfxStyleFamily::Para
, nMask
));
313 pSheet
->SetParent( aA4Name
);
314 pSheet
->SetHelpId( aHelpFile
, HID_POOLSHEET_A4_HEADLINE
);
315 pISet
= &pSheet
->GetItemSet();
316 pISet
->Put(SvxFontHeightItem(847, 100, EE_CHAR_FONTHEIGHT
)); // 24 pt
317 pISet
->Put(XLineStyleItem(drawing::LineStyle_NONE
)); // no border
321 aName
= SdResId(STR_POOLSHEET_A4_TEXT
);
322 pSheet
= &(pSSPool
->Make(aName
, SfxStyleFamily::Para
, nMask
));
323 pSheet
->SetParent(aA4Name
);
324 pSheet
->SetHelpId( aHelpFile
, HID_POOLSHEET_A4_TEXT
);
325 pISet
= &pSheet
->GetItemSet();
326 pISet
->Put(XLineStyleItem(drawing::LineStyle_NONE
)); // no border
331 aA0Name
= SdResId(STR_POOLSHEET_A0
);
332 pSheet
= &(pSSPool
->Make(aA0Name
, SfxStyleFamily::Para
, nMask
));
333 pSheet
->SetParent(aTextName
);
334 pSheet
->SetHelpId( aHelpFile
, HID_POOLSHEET_A0
);
335 pISet
= &pSheet
->GetItemSet();
336 pISet
->Put(SvxFontHeightItem(1692, 100, EE_CHAR_FONTHEIGHT
)); // 48 pt
337 pISet
->Put(XFillStyleItem(drawing::FillStyle_NONE
)); // no filling
341 aName
= SdResId(STR_POOLSHEET_A0_TITLE
);
342 pSheet
= &(pSSPool
->Make(aName
, SfxStyleFamily::Para
, nMask
));
343 pSheet
->SetParent(aA0Name
);
344 pSheet
->SetHelpId( aHelpFile
, HID_POOLSHEET_A0_TITLE
);
345 pISet
= &pSheet
->GetItemSet();
346 pISet
->Put(SvxFontHeightItem(3385, 100, EE_CHAR_FONTHEIGHT
)); // 96 pt
347 pISet
->Put(XLineStyleItem(drawing::LineStyle_NONE
)); // no border
349 // Text > A0 > Headline
351 aName
= SdResId(STR_POOLSHEET_A0_HEADLINE
);
352 pSheet
= &(pSSPool
->Make(aName
, SfxStyleFamily::Para
, nMask
));
353 pSheet
->SetParent(aA0Name
);
354 pSheet
->SetHelpId( aHelpFile
, HID_POOLSHEET_A0_HEADLINE
);
355 pISet
= &pSheet
->GetItemSet();
356 pISet
->Put(SvxFontHeightItem(2538, 100, EE_CHAR_FONTHEIGHT
)); // 72 pt
357 pISet
->Put(XLineStyleItem(drawing::LineStyle_NONE
)); // no border
361 aName
= SdResId(STR_POOLSHEET_A0_TEXT
);
362 pSheet
= &(pSSPool
->Make(aName
, SfxStyleFamily::Para
, nMask
));
363 pSheet
->SetParent(aA0Name
);
364 pSheet
->SetHelpId( aHelpFile
, HID_POOLSHEET_A0_TEXT
);
365 pISet
= &pSheet
->GetItemSet();
366 pISet
->Put(XLineStyleItem(drawing::LineStyle_NONE
)); // no border
370 OUString aGraphicName
;
371 XFillGradientItem aFillGradient
;
375 aGraphicName
= SdResId(STR_POOLSHEET_GRAPHIC
);
376 pSheet
= &(pSSPool
->Make(aGraphicName
, SfxStyleFamily::Para
, nMask
));
377 pSheet
->SetHelpId( aHelpFile
, HID_POOLSHEET_GRAPHIC
);
378 pISet
= &pSheet
->GetItemSet();
379 aSvxFontItem
.SetFamilyName("Liberation Sans"); // Liberation Sans
380 pISet
->Put( aSvxFontItem
);
381 pISet
->Put( SvxFontHeightItem(635, 100, EE_CHAR_FONTHEIGHT
) ); // 18 pt
382 pISet
->Put( XFillStyleItem(drawing::FillStyle_SOLID
) ); // solid fill
383 pISet
->Put( XFillColorItem(OUString(), COL_WHITE
) ); // filled white
387 OUString aShapesName
;
389 aShapesName
= SdResId(STR_POOLSHEET_SHAPES
);
390 pSheet
= &(pSSPool
->Make(aShapesName
, SfxStyleFamily::Para
, nMask
));
391 pSheet
->SetParent( aGraphicName
);
392 pSheet
->SetHelpId( aHelpFile
, HID_POOLSHEET_SHAPES
);
393 pISet
= &pSheet
->GetItemSet();
394 pISet
->Put(XFillStyleItem(drawing::FillStyle_GRADIENT
)); // fill with gradient
395 aGradient
.SetGradientStyle( ::awt::GradientStyle_RECT
); // square type
396 aGradient
.SetAngle( 0 ); // 0° angle
397 aGradient
.SetStartColor( Color(0xcccccc) ); // white
398 aGradient
.SetEndColor( COL_WHITE
); // light gray 3
399 aFillGradient
.SetName( aShapesName
);
400 aFillGradient
.SetGradientValue(aGradient
);
401 pISet
->Put( aFillGradient
);
402 pISet
->Put( XLineStyleItem(drawing::LineStyle_NONE
) ); // no border
403 pISet
->Put( SvxFontHeightItem(494, 100, EE_CHAR_FONTHEIGHT
) ); // 14 pt
404 pISet
->Put( SvxWeightItem(WEIGHT_BOLD
, EE_CHAR_WEIGHT
) ); // bold
406 // Graphic > Shapes > Filled
407 OUString
aFilledName(SdResId(STR_POOLSHEET_FILLED
));
410 pSheet
= &(pSSPool
->Make(aName
, SfxStyleFamily::Para
, nMask
));
411 pSheet
->SetHelpId( aHelpFile
, HID_POOLSHEET_FILLED
);
412 pSheet
->SetParent( aShapesName
);
413 pISet
= &pSheet
->GetItemSet();
415 aGradient
.SetGradientStyle( ::awt::GradientStyle_LINEAR
);
416 aGradient
.SetAngle( 300 );
417 aGradient
.SetStartColor( COL_WHITE
); // white
418 aGradient
.SetEndColor( Color(0xcccccc) ); // light gray 3
419 aFillGradient
.SetName( aName
);
420 aFillGradient
.SetGradientValue(aGradient
);
421 pISet
->Put( XFillStyleItem(drawing::FillStyle_GRADIENT
) );
422 pISet
->Put( aFillGradient
);
424 // Graphic > Shapes > Filled > Blue
426 aName
=SdResId(STR_POOLSHEET_FILLED_BLUE
);
427 pSheet
= &(pSSPool
->Make(aName
, SfxStyleFamily::Para
, nMask
));
428 pSheet
->SetParent(aFilledName
);
429 pSheet
->SetHelpId( aHelpFile
, HID_POOLSHEET_FILLED_BLUE
);
430 pISet
= &pSheet
->GetItemSet();
432 aGradient
.SetStartColor( Color(0x00729fcf) ); // light blue 2
433 aGradient
.SetEndColor( Color(0x00355269) ); // dark blue 2
434 aFillGradient
.SetName( aName
);
435 aFillGradient
.SetGradientValue(aGradient
);
436 pISet
->Put( aFillGradient
);
437 pISet
->Put( SvxColorItem(COL_WHITE
, EE_CHAR_COLOR
)); // font white
439 // Graphic > Shapes > Filled > Green
441 aName
=SdResId(STR_POOLSHEET_FILLED_GREEN
);
442 pSheet
= &(pSSPool
->Make(aName
, SfxStyleFamily::Para
, nMask
));
443 pSheet
->SetParent(aFilledName
);
444 pSheet
->SetHelpId( aHelpFile
, HID_POOLSHEET_FILLED_GREEN
);
445 pISet
= &pSheet
->GetItemSet();
447 aGradient
.SetStartColor( Color(0x0077bc65) ); // light green 2
448 aGradient
.SetEndColor( Color(0x00127622) ); // dark green 2
449 aFillGradient
.SetName( aName
);
450 aFillGradient
.SetGradientValue(aGradient
);
451 pISet
->Put( aFillGradient
);
452 pISet
->Put( aSvxFontItem
); // font name
453 pISet
->Put( SvxColorItem(COL_WHITE
, EE_CHAR_COLOR
)); // font white
455 // Graphic > Shapes > Filled > Red
457 aName
=SdResId(STR_POOLSHEET_FILLED_RED
);
458 pSheet
= &(pSSPool
->Make(aName
, SfxStyleFamily::Para
, nMask
));
459 pSheet
->SetParent(aFilledName
);
460 pSheet
->SetHelpId( aHelpFile
, HID_POOLSHEET_FILLED_RED
);
461 pISet
= &pSheet
->GetItemSet();
463 aGradient
.SetStartColor( Color(0x00ff6d6d) ); // light red 2
464 aGradient
.SetEndColor( Color(0x00c9211e) ); // dark red 2
465 aFillGradient
.SetName( aName
);
466 aFillGradient
.SetGradientValue(aGradient
);
467 pISet
->Put( aFillGradient
);
468 pISet
->Put( SvxColorItem(COL_WHITE
, EE_CHAR_COLOR
)); // font white
470 // Graphic > Shapes > Filled > Yellow
472 aName
=SdResId(STR_POOLSHEET_FILLED_YELLOW
);
473 pSheet
= &(pSSPool
->Make(aName
, SfxStyleFamily::Para
, nMask
));
474 pSheet
->SetParent(aFilledName
);
475 pSheet
->SetHelpId( aHelpFile
, HID_POOLSHEET_FILLED_YELLOW
);
476 pISet
= &pSheet
->GetItemSet();
478 aGradient
.SetStartColor( Color(0x00ffde59) ); // light gold 2
479 aGradient
.SetEndColor( Color(0x00b47804) ); // dark gold 2
480 aFillGradient
.SetName( aName
);
481 aFillGradient
.SetGradientValue(aGradient
);
482 pISet
->Put( aFillGradient
);
483 pISet
->Put( SvxColorItem(COL_WHITE
, EE_CHAR_COLOR
)); // font white
485 // Graphic > Shapes > Outlines
486 OUString
aOutlineName(SdResId(STR_POOLSHEET_OUTLINE
));
488 aName
= aOutlineName
;
489 pSheet
= &(pSSPool
->Make(aName
, SfxStyleFamily::Para
, nMask
));
490 pSheet
->SetHelpId( aHelpFile
, HID_POOLSHEET_OUTLINE
);
491 pSheet
->SetParent( aShapesName
);
492 pISet
= &pSheet
->GetItemSet();
493 pISet
->Put( XFillStyleItem(drawing::FillStyle_NONE
) ); // clear
494 pISet
->Put( XLineStyleItem(drawing::LineStyle_SOLID
) ); // solide line
495 pISet
->Put( XLineWidthItem(81) ); // 2.3 pt
496 pISet
->Put( XLineColorItem(OUString(), COL_BLACK
) ); // b/w
498 // Graphic > Shapes > Outlines > Blue
500 aName
=SdResId(STR_POOLSHEET_OUTLINE_BLUE
);
501 pSheet
= &(pSSPool
->Make(aName
, SfxStyleFamily::Para
, nMask
));
502 pSheet
->SetParent(aOutlineName
);
503 pSheet
->SetHelpId( aHelpFile
, HID_POOLSHEET_OUTLINE_BLUE
);
504 pISet
= &pSheet
->GetItemSet();
505 pISet
->Put( XLineColorItem(OUString(), Color(0x00355269)) ); // dark blue 2
506 pISet
->Put( SvxColorItem(Color(0x00355269), EE_CHAR_COLOR
)); // font color
508 // Graphic > Shapes > Outlines > Green
510 aName
=SdResId(STR_POOLSHEET_OUTLINE_GREEN
);
511 pSheet
= &(pSSPool
->Make(aName
, SfxStyleFamily::Para
, nMask
));
512 pSheet
->SetParent(aOutlineName
);
513 pSheet
->SetHelpId( aHelpFile
, HID_POOLSHEET_OUTLINE_GREEN
);
514 pISet
= &pSheet
->GetItemSet();
515 pISet
->Put( XLineColorItem(OUString(), Color(0x00127622)) ); // dark green 2
516 pISet
->Put( SvxColorItem(Color(0x00127622), EE_CHAR_COLOR
)); // font color
518 // Graphic > Shapes > Outlines > Red
520 aName
=SdResId(STR_POOLSHEET_OUTLINE_RED
);
521 pSheet
= &(pSSPool
->Make(aName
, SfxStyleFamily::Para
, nMask
));
522 pSheet
->SetParent(aOutlineName
);
523 pSheet
->SetHelpId( aHelpFile
, HID_POOLSHEET_OUTLINE_RED
);
524 pISet
= &pSheet
->GetItemSet();
525 pISet
->Put( XLineColorItem(OUString(), Color(0x00c9211e)) ); // dark red 2
526 pISet
->Put( SvxColorItem(Color(0x00c9211e), EE_CHAR_COLOR
)); // font color
528 // Graphic > Shapes > Outlines > Yellow
530 aName
=SdResId(STR_POOLSHEET_OUTLINE_YELLOW
);
531 pSheet
= &(pSSPool
->Make(aName
, SfxStyleFamily::Para
, nMask
));
532 pSheet
->SetParent(aOutlineName
);
533 pSheet
->SetHelpId( aHelpFile
, HID_POOLSHEET_OUTLINE_YELLOW
);
534 pISet
= &pSheet
->GetItemSet();
535 pISet
->Put( XLineStyleItem(drawing::LineStyle_SOLID
));
536 pISet
->Put( XLineColorItem(OUString(), Color(0x00b47804)) ); // dark gold 2
537 pISet
->Put( SvxColorItem(Color(0x00b47804), EE_CHAR_COLOR
)); // font color
542 aLinesName
= SdResId(STR_POOLSHEET_LINES
);
543 pSheet
= &(pSSPool
->Make(aLinesName
, SfxStyleFamily::Para
, nMask
));
544 pSheet
->SetParent( aGraphicName
);
545 pSheet
->SetHelpId( aHelpFile
, HID_POOLSHEET_LINES
);
546 pISet
= &pSheet
->GetItemSet();
547 pISet
->Put( XFillStyleItem(drawing::FillStyle_NONE
) ); // clear
548 pISet
->Put( XLineStyleItem(drawing::LineStyle_SOLID
) ); // solide line
549 pISet
->Put( XLineColorItem(OUString(), COL_BLACK
) ); // b/w
551 // Graphic > Lines > Measurements
553 aName
= SdResId(STR_POOLSHEET_MEASURE
);
554 pSheet
= &(pSSPool
->Make(aName
, SfxStyleFamily::Para
, nMask
));
555 pSheet
->SetParent(aLinesName
);
556 pSheet
->SetHelpId( aHelpFile
, HID_POOLSHEET_MEASURE
);
557 pISet
= &pSheet
->GetItemSet();
559 ::basegfx::B2DPolygon aArrow
; // arrows
560 aArrow
.append(::basegfx::B2DPoint(10.0, 0.0));
561 aArrow
.append(::basegfx::B2DPoint(0.0, 30.0));
562 aArrow
.append(::basegfx::B2DPoint(20.0, 30.0));
563 aArrow
.setClosed(true);
565 pISet
->Put(XLineStartItem(SvxResId(RID_SVXSTR_ARROW
),::basegfx::B2DPolyPolygon(aArrow
)));
566 pISet
->Put(XLineStartWidthItem(200));
567 pISet
->Put(XLineEndItem(SvxResId(RID_SVXSTR_ARROW
),::basegfx::B2DPolyPolygon(aArrow
)));
568 pISet
->Put(XLineEndWidthItem(200));
569 pISet
->Put(SdrYesNoItem(SDRATTR_MEASURESHOWUNIT
, true));
571 // Graphic > Lines > Dashed
573 aName
= SdResId(STR_POOLSHEET_LINES_DASHED
);
574 pSheet
= &(pSSPool
->Make(aName
, SfxStyleFamily::Para
, nMask
));
575 pSheet
->SetParent(aLinesName
);
576 pSheet
->SetHelpId( aHelpFile
, HID_POOLSHEET_LINES_DASHED
);
577 pISet
= &pSheet
->GetItemSet();
578 pISet
->Put( XLineStyleItem(drawing::LineStyle_DASH
) ); // dashed line
581 // Generate presentation templates for default layout.
582 OUString aPrefix
= SdResId(STR_LAYOUT_DEFAULT_NAME
);
583 pSSPool
->CreateLayoutStyleSheets(aPrefix
);
586 static Any
implMakeSolidCellStyle( SdStyleSheetPool
* pSSPool
, const OUString
& rName
, const OUString
& rParent
, const Color
& rColor
)
588 SfxStyleSheetBase
* pSheet
= &(pSSPool
->Make(rName
, SfxStyleFamily::Frame
, SfxStyleSearchBits::Auto
));
589 pSheet
->SetParent(rParent
);
590 SfxItemSet
* pISet
= &pSheet
->GetItemSet();
591 pISet
->Put(XFillStyleItem(drawing::FillStyle_SOLID
));
592 pISet
->Put(XFillColorItem(OUString(), rColor
));
594 return Any( Reference
< XStyle
>( static_cast< XWeak
* >( pSheet
), UNO_QUERY
) );
597 static void implCreateTableTemplate( const Reference
< XNameContainer
>& xTableFamily
, const OUString
& rName
, const Any
& rBody
, const Any
& rHeading
, const Any
& rBanding
)
599 if( !xTableFamily
.is() )
604 if( !xTableFamily
->hasByName( rName
) )
606 Reference
< XSingleServiceFactory
> xFactory( xTableFamily
, UNO_QUERY_THROW
);
607 Reference
< XNameReplace
> xDefaultTableStyle( xFactory
->createInstance(), UNO_QUERY_THROW
);
608 xTableFamily
->insertByName( rName
, Any( xDefaultTableStyle
) );
610 xDefaultTableStyle
->replaceByName( "body", rBody
);
611 xDefaultTableStyle
->replaceByName( "odd-rows" , rBanding
);
612 xDefaultTableStyle
->replaceByName( "odd-columns" , rBanding
);
613 xDefaultTableStyle
->replaceByName( "first-row" , rHeading
);
614 xDefaultTableStyle
->replaceByName( "first-column" , rHeading
);
615 xDefaultTableStyle
->replaceByName( "last-row" , rHeading
);
616 xDefaultTableStyle
->replaceByName( "last-column" , rHeading
);
621 OSL_FAIL("sd::implCreateTableTemplate(), exception caught!");
625 void SdDrawDocument::CreateDefaultCellStyles()
627 SdStyleSheetPool
* pSSPool
= static_cast< SdStyleSheetPool
* >(GetStyleSheetPool());
628 SfxStyleSheetBase
* pSheet
= nullptr;
630 Reference
< XNameContainer
> xTableFamily( pSSPool
->getByName( "table" ), UNO_QUERY
);
632 // ---- Default -----------------------------------------------
634 OUString
aDefaultCellStyleName( "default" );
636 pSheet
= &(pSSPool
->Make(aDefaultCellStyleName
, SfxStyleFamily::Frame
, SfxStyleSearchBits::Auto
));
637 pSheet
->SetHelpId( OUString(), HID_SD_CELL_STYLE_DEFAULT
);
638 SfxItemSet
& rISet
= pSheet
->GetItemSet();
640 rISet
.Put(XFillStyleItem(drawing::FillStyle_SOLID
));
641 rISet
.Put(XFillColorItem(OUString(), Color(0x00ccccff)));
643 vcl::Font aLatinFont
, aCJKFont
, aCTLFont
;
645 getDefaultFonts( aLatinFont
, aCJKFont
, aCTLFont
);
647 SvxFontItem
aSvxFontItem( aLatinFont
.GetFamilyType(), aLatinFont
.GetFamilyName(), aLatinFont
.GetStyleName(), aLatinFont
.GetPitch(),
648 aLatinFont
.GetCharSet(), EE_CHAR_FONTINFO
);
650 SvxFontItem
aSvxFontItemCJK( aCJKFont
.GetFamilyType(), aCJKFont
.GetFamilyName(), aCJKFont
.GetStyleName(), aCJKFont
.GetPitch(),
651 aCJKFont
.GetCharSet(), EE_CHAR_FONTINFO_CJK
);
653 SvxFontItem
aSvxFontItemCTL( aCTLFont
.GetFamilyType(), aCTLFont
.GetFamilyName(), aCTLFont
.GetStyleName(), aCTLFont
.GetPitch(),
654 aCTLFont
.GetCharSet(), EE_CHAR_FONTINFO_CTL
);
656 rISet
.Put( aSvxFontItem
);
657 rISet
.Put( aSvxFontItemCJK
);
658 rISet
.Put( aSvxFontItemCTL
);
660 rISet
.Put( SvxFontHeightItem( 635, 100, EE_CHAR_FONTHEIGHT
) ); // sj: (i33745) changed default from 24 to 18 pt
661 rISet
.Put( SvxFontHeightItem( 635, 100, EE_CHAR_FONTHEIGHT_CJK
) ); // 18 pt
662 rISet
.Put( SvxFontHeightItem( convertFontHeightToCTL( 635 ), 100, EE_CHAR_FONTHEIGHT_CTL
) ); // 18 pt
664 rISet
.Put(SvxColorItem(COL_AUTO
, EE_CHAR_COLOR
));
666 // Paragraph attributes (Edit Engine)
667 rISet
.Put(SvxLRSpaceItem(EE_PARA_LRSPACE
));
668 rISet
.Put(SvxULSpaceItem(EE_PARA_ULSPACE
));
670 rISet
.Put( makeSdrTextLeftDistItem( 250 ) );
671 rISet
.Put( makeSdrTextRightDistItem( 250 ) );
672 rISet
.Put( makeSdrTextUpperDistItem( 130 ) );
673 rISet
.Put( makeSdrTextLowerDistItem( 130 ) );
675 rISet
.Put( SvxLineSpacingItem( LINE_SPACE_DEFAULT_HEIGHT
, EE_PARA_SBL
) );
676 rISet
.Put( SvxAutoKernItem( true, EE_CHAR_PAIRKERNING
) );
677 rISet
.Put( SdrTextVertAdjustItem(SDRTEXTVERTADJUST_TOP
) );
678 rISet
.Put( SdrTextHorzAdjustItem(SDRTEXTHORZADJUST_LEFT
) );
680 Color
aWhite( COL_WHITE
);
681 ::editeng::SvxBorderLine
aBorderLine(
682 &aWhite
, 1, SvxBorderLineStyle::SOLID
);
684 SvxBoxItem
aBoxItem( SDRATTR_TABLE_BORDER
);
685 aBoxItem
.SetLine( &aBorderLine
, SvxBoxItemLine::TOP
);
686 aBoxItem
.SetLine( &aBorderLine
, SvxBoxItemLine::BOTTOM
);
687 aBoxItem
.SetLine( &aBorderLine
, SvxBoxItemLine::LEFT
);
688 aBoxItem
.SetLine( &aBorderLine
, SvxBoxItemLine::RIGHT
);
690 rISet
.Put( aBoxItem
);
692 // ---- default --------------------------------------------------
694 Any
aGray1( implMakeSolidCellStyle( pSSPool
, "gray1" , aDefaultCellStyleName
, Color(230,230,230)));
695 Any
aGray2( implMakeSolidCellStyle( pSSPool
, "gray2" , aDefaultCellStyleName
, Color(204,204,204)));
696 Any
aGray3( implMakeSolidCellStyle( pSSPool
, "gray3" , aDefaultCellStyleName
, Color(179,179,179)));
698 implCreateTableTemplate( xTableFamily
, "default" , aGray1
, aGray3
, aGray2
);
700 // ---- BW ------------------------------------------------
702 Any
aBW1( implMakeSolidCellStyle( pSSPool
, "bw1" , aDefaultCellStyleName
, Color(255,255,255)));
703 Any
aBW2( implMakeSolidCellStyle( pSSPool
, "bw2" , aDefaultCellStyleName
, Color(230,230,230)));
704 Any
aBW3( implMakeSolidCellStyle( pSSPool
, "bw3" , aDefaultCellStyleName
, Color(0,0,0)));
706 implCreateTableTemplate( xTableFamily
, "bw" , aBW1
, aBW3
, aBW2
);
708 // ---- Orange --------------------------------------------------
710 Any
aOrange1( implMakeSolidCellStyle( pSSPool
, "orange1" , aDefaultCellStyleName
, Color(255,204,153)));
711 Any
aOrange2( implMakeSolidCellStyle( pSSPool
, "orange2" , aDefaultCellStyleName
, Color(255,153,102)));
712 Any
aOrange3( implMakeSolidCellStyle( pSSPool
, "orange3" , aDefaultCellStyleName
, Color(255,102,51)));
714 implCreateTableTemplate( xTableFamily
, "orange" , aOrange1
, aOrange3
, aOrange2
);
716 // ---- Turquoise --------------------------------------------------
718 Any
aTurquoise1( implMakeSolidCellStyle( pSSPool
, "turquoise1" , aDefaultCellStyleName
, Color(71,184,184)));
719 Any
aTurquoise2( implMakeSolidCellStyle( pSSPool
, "turquoise2" , aDefaultCellStyleName
, Color(51,163,163)));
720 Any
aTurquoise3( implMakeSolidCellStyle( pSSPool
, "turquoise3" , aDefaultCellStyleName
, Color(25,138,138)));
722 implCreateTableTemplate( xTableFamily
, "turquoise" , aTurquoise1
, aTurquoise3
, aTurquoise2
);
724 // ---- Gray ------------------------------------------------
726 Any
aBlue1( implMakeSolidCellStyle( pSSPool
, "blue1" , aDefaultCellStyleName
, Color(153,204,255)));
727 Any
aBlue2( implMakeSolidCellStyle( pSSPool
, "blue2" , aDefaultCellStyleName
, Color(0,153,255)));
728 Any
aBlue3( implMakeSolidCellStyle( pSSPool
, "blue3" , aDefaultCellStyleName
, Color(0,102,204)));
730 implCreateTableTemplate( xTableFamily
, "blue" , aBlue1
, aBlue3
, aBlue2
);
732 // ---- Sun ------------------------------------------------
734 Any
aSun1( implMakeSolidCellStyle( pSSPool
, "sun1" , aDefaultCellStyleName
, Color(230,230,255)));
735 Any
aSun2( implMakeSolidCellStyle( pSSPool
, "sun2" , aDefaultCellStyleName
, Color(204,204,255)));
736 Any
aSun3( implMakeSolidCellStyle( pSSPool
, "sun3" , aDefaultCellStyleName
, Color(153,153,255)));
738 implCreateTableTemplate( xTableFamily
, "sun" , aSun1
, aSun3
, aSun2
);
740 // ---- Earth ----------------------------------------------
742 Any
aEarth1( implMakeSolidCellStyle( pSSPool
, "earth1" , aDefaultCellStyleName
, Color(255,255,204)));
743 Any
aEarth2( implMakeSolidCellStyle( pSSPool
, "earth2" , aDefaultCellStyleName
, Color(255,204,153)));
744 Any
aEarth3( implMakeSolidCellStyle( pSSPool
, "earth3" , aDefaultCellStyleName
, Color(204,102,51)));
746 implCreateTableTemplate( xTableFamily
, "earth" , aEarth1
, aEarth3
, aEarth2
);
748 // ---- Green ----------------------------------------------
750 Any
aGreen1( implMakeSolidCellStyle( pSSPool
, "green1" , aDefaultCellStyleName
, Color(255,255,204)));
751 Any
aGreen2( implMakeSolidCellStyle( pSSPool
, "green2" , aDefaultCellStyleName
, Color(148,189,94)));
752 Any
aGreen3( implMakeSolidCellStyle( pSSPool
, "green3" , aDefaultCellStyleName
, Color(92,133,38)));
754 implCreateTableTemplate( xTableFamily
, "green" , aGreen1
, aGreen3
, aGreen2
);
756 // ---- Seaweed ----------------------------------------------
758 Any
aSeetang1( implMakeSolidCellStyle( pSSPool
, "seetang1" , aDefaultCellStyleName
, Color(204,255,255)));
759 Any
aSeetang2( implMakeSolidCellStyle( pSSPool
, "seetang2" , aDefaultCellStyleName
, Color(71,184,184)));
760 Any
aSeetang3( implMakeSolidCellStyle( pSSPool
, "seetang3" , aDefaultCellStyleName
, Color(51,163,163)));
762 implCreateTableTemplate( xTableFamily
, "seetang" , aSeetang1
, aSeetang3
, aSeetang2
);
764 // ---- LightBlue ----------------------------------------------
766 Any
aLightBlue1( implMakeSolidCellStyle( pSSPool
, "lightblue1" , aDefaultCellStyleName
, Color(255,255,255)));
767 Any
aLightBlue2( implMakeSolidCellStyle( pSSPool
, "lightblue2" , aDefaultCellStyleName
, Color(230,230,255)));
768 Any
aLightBlue3( implMakeSolidCellStyle( pSSPool
, "lightblue3" , aDefaultCellStyleName
, Color(153,153,204)));
770 implCreateTableTemplate( xTableFamily
, "lightblue" , aLightBlue1
, aLightBlue3
, aLightBlue2
);
772 // ---- Yellow ----------------------------------------------
774 Any
aYellow1( implMakeSolidCellStyle( pSSPool
, "yellow1" , aDefaultCellStyleName
, Color(255,255,204)));
775 Any
aYellow2( implMakeSolidCellStyle( pSSPool
, "yellow2" , aDefaultCellStyleName
, Color(255,255,153)));
776 Any
aYellow3( implMakeSolidCellStyle( pSSPool
, "yellow3" , aDefaultCellStyleName
, Color(255,204,153)));
778 implCreateTableTemplate( xTableFamily
, "yellow" , aYellow1
, aYellow3
, aYellow2
);
781 // Number of pages that reference a master page
782 sal_uInt16
SdDrawDocument::GetMasterPageUserCount(SdrPage
const * pMaster
) const
784 sal_uInt16 nResult
= 0;
786 sal_uInt16 nPageCount
= GetPageCount();
788 for (nPage
= 0; nPage
< nPageCount
; nPage
++)
790 const SdrPage
* pPage
= GetPage(nPage
);
792 if(pPage
->TRG_HasMasterPage())
794 if(&(pPage
->TRG_GetMasterPage()) == pMaster
)
803 // Finish OnlineSpelling in the background
805 void SdDrawDocument::StopOnlineSpelling()
807 if (mpOnlineSpellingIdle
&& mpOnlineSpellingIdle
->IsActive())
809 mpOnlineSpellingIdle
->Stop();
812 mpOnlineSpellingIdle
.reset();
813 mpOnlineSpellingList
.reset();
816 // Start OnlineSpelling in the background
817 void SdDrawDocument::StartOnlineSpelling(bool bForceSpelling
)
819 if (!(mbOnlineSpell
&& (bForceSpelling
|| mbInitialOnlineSpellingEnabled
) &&
820 mpDocSh
&& !mpDocSh
->IsReadOnly()) )
823 StopOnlineSpelling();
825 SdOutliner
* pOutl
= GetInternalOutliner();
827 Reference
< XSpellChecker1
> xSpellChecker( LinguMgr::GetSpellChecker() );
828 if ( xSpellChecker
.is() )
829 pOutl
->SetSpeller( xSpellChecker
);
831 Reference
< XHyphenator
> xHyphenator( LinguMgr::GetHyphenator() );
832 if( xHyphenator
.is() )
833 pOutl
->SetHyphenator( xHyphenator
);
835 pOutl
->SetDefaultLanguage( meLanguage
);
837 mpOnlineSpellingList
.reset(new ShapeList
);
840 for ( nPage
= 0; nPage
< GetPageCount(); nPage
++ )
842 // Search in all pages
843 FillOnlineSpellingList(static_cast<SdPage
*>(GetPage(nPage
)));
846 for (nPage
= 0; nPage
< GetMasterPageCount(); nPage
++)
848 // Search all master pages
849 FillOnlineSpellingList(static_cast<SdPage
*>( GetMasterPage(nPage
) ));
852 mpOnlineSpellingList
->seekShape(0);
853 mpOnlineSpellingIdle
.reset(new Idle("OnlineSpelling"));
854 mpOnlineSpellingIdle
->SetInvokeHandler( LINK(this, SdDrawDocument
, OnlineSpellingHdl
) );
855 mpOnlineSpellingIdle
->SetPriority(TaskPriority::LOWEST
);
856 mpOnlineSpellingIdle
->Start();
859 // Fill OnlineSpelling list
860 void SdDrawDocument::FillOnlineSpellingList(SdPage
const * pPage
)
862 SdrObjListIter
aIter(pPage
, SdrIterMode::Flat
);
864 while (aIter
.IsMore())
866 SdrObject
* pObj
= aIter
.Next();
871 if (pObj
->GetOutlinerParaObject())
873 // Found a text object
874 mpOnlineSpellingList
->addShape(*pObj
);
876 else if (pObj
->GetObjIdentifier() == OBJ_GRUP
)
878 // Found a group object
879 SdrObjListIter
aGroupIter(static_cast< SdrObjGroup
* >(pObj
)->GetSubList(), SdrIterMode::DeepNoGroups
);
881 bool bSubTextObjFound
= false;
883 while (aGroupIter
.IsMore() && !bSubTextObjFound
)
885 if (aGroupIter
.Next()->GetOutlinerParaObject())
887 // Found a text object in a group object
888 bSubTextObjFound
= true;
892 if (bSubTextObjFound
)
894 mpOnlineSpellingList
->addShape(*pObj
);
900 // OnlineSpelling in the background
901 IMPL_LINK_NOARG(SdDrawDocument
, OnlineSpellingHdl
, Timer
*, void)
903 if (mpOnlineSpellingList
!=nullptr
904 && ( !mbOnlineSpell
|| mpOnlineSpellingList
->hasMore()))
907 SdrObject
* pObj
= mpOnlineSpellingList
->getNextShape();
911 if (pObj
->GetOutlinerParaObject() && dynamic_cast< const SdrTextObj
*>( pObj
) != nullptr)
914 SpellObject(static_cast<SdrTextObj
*>(pObj
));
916 else if (pObj
->GetObjIdentifier() == OBJ_GRUP
)
918 // Found a group object
919 SdrObjListIter
aGroupIter(static_cast< SdrObjGroup
* >(pObj
)->GetSubList(), SdrIterMode::DeepNoGroups
);
922 while (aGroupIter
.IsMore())
924 SdrObject
* pSubObj
= aGroupIter
.Next();
926 if (pSubObj
->GetOutlinerParaObject() && dynamic_cast< SdrTextObj
*>( pSubObj
) != nullptr)
928 // Found a text object in a group object
929 SpellObject(static_cast<SdrTextObj
*>(pSubObj
));
936 mpOnlineSpellingIdle
->Start();
940 // Initial spelling has finished
941 mbInitialOnlineSpellingEnabled
= false;
944 StopOnlineSpelling();
946 mpOnlineSearchItem
.reset();
950 // Spell object (for OnlineSpelling)
951 void SdDrawDocument::SpellObject(SdrTextObj
* pObj
)
953 if (!(pObj
&& pObj
->GetOutlinerParaObject()) /* && pObj != pView->GetTextEditObject() */)
956 mbHasOnlineSpellErrors
= false;
957 SdOutliner
* pOutl
= GetInternalOutliner();
958 pOutl
->SetUpdateMode(true);
959 Link
<EditStatus
&,void> aEvtHdl
= pOutl
->GetStatusEventHdl();
960 pOutl
->SetStatusEventHdl(LINK(this, SdDrawDocument
, OnlineSpellEventHdl
));
962 OutlinerMode nOldOutlMode
= pOutl
->GetMode();
963 OutlinerMode nOutlMode
= OutlinerMode::TextObject
;
964 if (pObj
->GetObjInventor() == SdrInventor::Default
&&
965 pObj
->GetObjIdentifier() == OBJ_OUTLINETEXT
)
967 nOutlMode
= OutlinerMode::OutlineObject
;
969 pOutl
->Init( nOutlMode
);
971 // Put text into the outliner
972 pOutl
->SetText(*pObj
->GetOutlinerParaObject());
974 if (!mpOnlineSearchItem
|| pOutl
->HasText(*mpOnlineSearchItem
))
977 pOutl
->CompleteOnlineSpelling();
979 if (mbHasOnlineSpellErrors
)
981 std::unique_ptr
<OutlinerParaObject
> pOPO
= pOutl
->CreateParaObject();
984 if (!( *pOPO
== *pObj
->GetOutlinerParaObject() ) ||
985 !pObj
->GetOutlinerParaObject()->isWrongListEqual( *pOPO
))
987 sd::ModifyGuard
aGuard( this );
989 // taking text from the outliner
990 // use non-broadcasting version to avoid O(n^2)
991 pObj
->NbcSetOutlinerParaObject( std::move(pOPO
) );
997 pOutl
->SetStatusEventHdl(aEvtHdl
);
998 pOutl
->SetUpdateMode(false);
999 pOutl
->Init( nOldOutlMode
);
1000 mbHasOnlineSpellErrors
= false;
1003 // Object was inserted into model
1004 void SdDrawDocument::InsertObject(SdrObject
* pObj
)
1006 if(mpOnlineSpellingList
&& pObj
)
1008 if (pObj
->GetOutlinerParaObject() || (pObj
->GetObjIdentifier() == OBJ_GRUP
))
1010 // Add object to OnlineSpelling list
1011 mpOnlineSpellingList
->addShape(*pObj
);
1016 // Object removed from model
1017 void SdDrawDocument::RemoveObject(SdrObject
* pObj
)
1019 if(mpOnlineSpellingList
&& pObj
)
1021 if (pObj
->GetOutlinerParaObject() || (pObj
->GetObjIdentifier() == OBJ_GRUP
))
1023 // Replace object in OnlineSpelling list by 0 pointer
1024 mpOnlineSpellingList
->removeShape(*pObj
);
1029 // Callback for ExecuteSpellPopup()
1030 IMPL_LINK(SdDrawDocument
, OnlineSpellEventHdl
, EditStatus
&, rEditStat
, void)
1032 EditStatusFlags nStat
= rEditStat
.GetStatusWord();
1033 mbHasOnlineSpellErrors
= bool(nStat
& EditStatusFlags::WRONGWORDCHANGED
);
1036 // Callback for ExecuteSpellPopup()
1038 // removed link and replaced with Imp method
1039 void SdDrawDocument::ImpOnlineSpellCallback(SpellCallbackInfo
const * pInfo
, SdrObject
* pObj
, SdrOutliner
const * pOutl
)
1041 mpOnlineSearchItem
.reset();
1043 SpellCallbackCommand nCommand
= pInfo
->nCommand
;
1045 if (nCommand
== SpellCallbackCommand::IGNOREWORD
1046 // restart when add to dictionary takes place, too.
1047 || nCommand
== SpellCallbackCommand::ADDTODICTIONARY
)
1049 if(pOutl
&& dynamic_cast< const SdrTextObj
*>( pObj
))
1051 bool bModified(IsChanged());
1052 static_cast<SdrTextObj
*>(pObj
)->SetOutlinerParaObject(pOutl
->CreateParaObject());
1053 SetChanged(bModified
);
1054 pObj
->BroadcastObjectChange();
1057 mpOnlineSearchItem
.reset(new SvxSearchItem( SID_SEARCH_ITEM
) );
1058 mpOnlineSearchItem
->SetSearchString(pInfo
->aWord
);
1059 StartOnlineSpelling();
1061 else if (nCommand
== SpellCallbackCommand::STARTSPELLDLG
)
1062 SfxViewFrame::Current()->GetDispatcher()->Execute( SID_SPELL_DIALOG
, SfxCallMode::ASYNCHRON
);
1063 else if (nCommand
== SpellCallbackCommand::AUTOCORRECT_OPTIONS
)
1064 SfxViewFrame::Current()->GetDispatcher()->Execute( SID_AUTO_CORRECT_DLG
, SfxCallMode::ASYNCHRON
);
1067 // Return formatted page number (1, I, i, a, etc.)
1068 OUString
SdDrawDocument::CreatePageNumValue(sal_uInt16 nNum
) const
1070 OUString aPageNumValue
;
1071 bool bUpper
= false;
1073 switch (mePageNumType
)
1075 case css::style::NumberingType::CHARS_UPPER_LETTER
:
1076 aPageNumValue
+= OUStringChar( sal_Unicode((nNum
- 1) % 26 + 'A') );
1078 case css::style::NumberingType::CHARS_LOWER_LETTER
:
1079 aPageNumValue
+= OUStringChar( sal_Unicode((nNum
- 1) % 26 + 'a') );
1081 case css::style::NumberingType::ROMAN_UPPER
:
1084 case css::style::NumberingType::ROMAN_LOWER
:
1085 aPageNumValue
+= SvxNumberFormat::CreateRomanString(nNum
, bUpper
);
1087 case css::style::NumberingType::NUMBER_NONE
:
1088 aPageNumValue
= " ";
1091 aPageNumValue
+= OUString::number(nNum
);
1094 return aPageNumValue
;
1097 // Rename layout template
1098 // Keep in mind that rOldLayoutName contains the _complete_ name of the layout
1099 // (including ~LT~). This is unlike rNewName.
1100 void SdDrawDocument::RenameLayoutTemplate(const OUString
& rOldLayoutName
, const OUString
& rNewName
)
1102 OUString
aSep(SD_LT_SEPARATOR
);
1103 OUString
aOldName(rOldLayoutName
);
1104 sal_Int32 nPos
= aOldName
.indexOf( aSep
);
1106 // erase everything after '~LT~'
1108 aOldName
= aOldName
.copy(0, nPos
+ aSep
.getLength());
1110 std::vector
<StyleReplaceData
> aReplList
;
1111 SfxStyleSheetIterator
aIter(mxStyleSheetPool
.get(), SfxStyleFamily::Page
);
1112 SfxStyleSheetBase
* pSheet
= aIter
.First();
1116 OUString aSheetName
= pSheet
->GetName();
1118 // if the sheetname starts with aOldName + "~LT~"
1119 if (aSheetName
.startsWith(aOldName
))
1121 aSheetName
= aSheetName
.replaceAt(0, aOldName
.getLength() - aSep
.getLength(), rNewName
);
1123 StyleReplaceData aReplData
;
1124 aReplData
.nFamily
= pSheet
->GetFamily();
1125 aReplData
.nNewFamily
= pSheet
->GetFamily();
1126 aReplData
.aName
= pSheet
->GetName();
1127 aReplData
.aNewName
= aSheetName
;
1128 aReplList
.push_back(aReplData
);
1130 pSheet
->SetName(aSheetName
);
1133 pSheet
= aIter
.Next();
1136 // Now set the layout name of the drawing and the notes page, as well as
1137 // their master pages.
1138 OUString aPageLayoutName
= rNewName
+ aSep
+ STR_LAYOUT_OUTLINE
;
1140 // Inform all text objects on pages that use the renamed layout and set the
1143 for (nPage
= 0; nPage
< GetPageCount(); nPage
++)
1145 SdPage
* pPage
= static_cast<SdPage
*>(GetPage(nPage
));
1146 OUString
aTemp(pPage
->GetLayoutName());
1148 if (aTemp
== rOldLayoutName
)
1150 pPage
->SetLayoutName(aPageLayoutName
);
1152 for (size_t nObj
= 0; nObj
< pPage
->GetObjCount(); ++nObj
)
1154 SdrObject
* pObj
= pPage
->GetObj(nObj
);
1156 if (pObj
->GetObjInventor() == SdrInventor::Default
)
1158 switch( pObj
->GetObjIdentifier() )
1161 case OBJ_OUTLINETEXT
:
1164 OutlinerParaObject
* pOPO
= static_cast<SdrTextObj
*>(pObj
)->GetOutlinerParaObject();
1168 for (const auto& rRepl
: aReplList
)
1169 pOPO
->ChangeStyleSheets( rRepl
.aName
, rRepl
.nFamily
, rRepl
.aNewName
, rRepl
.nNewFamily
);
1182 // Now do this again for all master pages.
1183 // The affected master pages get the name of the layout as their page name.
1184 for (nPage
= 0; nPage
< GetMasterPageCount(); nPage
++)
1186 SdPage
* pPage
= static_cast<SdPage
*>( GetMasterPage(nPage
) );
1187 OUString
aTemp(pPage
->GetLayoutName());
1189 if (aTemp
== rOldLayoutName
)
1191 pPage
->SetLayoutName(aPageLayoutName
);
1192 pPage
->SetName(rNewName
);
1194 for (size_t nObj
= 0; nObj
< pPage
->GetObjCount(); ++nObj
)
1196 SdrObject
* pObj
= pPage
->GetObj(nObj
);
1198 if (pObj
->GetObjInventor() == SdrInventor::Default
)
1200 switch(pObj
->GetObjIdentifier())
1203 case OBJ_OUTLINETEXT
:
1206 OutlinerParaObject
* pOPO
= static_cast<SdrTextObj
*>(pObj
)->GetOutlinerParaObject();
1210 for (const auto& rRepl
: aReplList
)
1211 pOPO
->ChangeStyleSheets( rRepl
.aName
, rRepl
.nFamily
, rRepl
.aNewName
, rRepl
.nNewFamily
);
1225 // Set outliner defaults (pool defaults)
1226 void SdDrawDocument::SetTextDefaults() const
1228 // BulletItem and BulletFont for Title and Outline
1229 SvxBulletItem
aBulletItem(EE_PARA_BULLET
);
1230 vcl::Font
aBulletFont( SdStyleSheetPool::GetBulletFont() );
1231 aBulletFont
.SetFontSize(Size(0,846)); // 24 pt
1232 aBulletItem
.SetFont(aBulletFont
);
1233 aBulletItem
.SetStyle(SvxBulletStyle::BULLET
);
1234 aBulletItem
.SetStart(1);
1235 aBulletItem
.SetScale(45); // In percent
1236 aBulletItem
.SetSymbol( 0x25CF ); // In points
1237 m_pItemPool
->SetPoolDefaultItem( aBulletItem
);
1240 SvxNumberFormat
aNumberFormat(SVX_NUM_CHAR_SPECIAL
);
1241 aNumberFormat
.SetBulletFont(&aBulletFont
);
1242 aNumberFormat
.SetBulletChar( 0x25CF ); // StarBats: 0xF000 + 34
1243 aNumberFormat
.SetBulletRelSize(45);
1244 aNumberFormat
.SetBulletColor(COL_AUTO
);
1245 aNumberFormat
.SetStart(1);
1246 aNumberFormat
.SetNumAdjust(SvxAdjust::Left
);
1248 SvxNumRule
aNumRule( SvxNumRuleFlags::BULLET_REL_SIZE
| SvxNumRuleFlags::BULLET_COLOR
, SVX_MAX_NUM
, false);
1250 //aNumberFormat.SetAbsLSpace( 0 );
1251 //aNumberFormat.SetFirstLineOffset( 0 );
1252 //aNumRule.SetLevel( 0, aNumberFormat );
1254 for( sal_uInt16 i
= 0; i
< aNumRule
.GetLevelCount(); i
++ )
1256 const auto nLSpace
= (i
+ 1) * 600;
1257 aNumberFormat
.SetAbsLSpace(nLSpace
);
1258 aNumberFormat
.SetFirstLineOffset(-600);
1259 aNumRule
.SetLevel( i
, aNumberFormat
);
1262 SvxNumBulletItem
aNumBulletItem( aNumRule
, EE_PARA_NUMBULLET
);
1263 m_pItemPool
->SetPoolDefaultItem( aNumBulletItem
);
1266 css::text::WritingMode
SdDrawDocument::GetDefaultWritingMode() const
1268 const SfxPoolItem
* pItem
= ( m_pItemPool
? m_pItemPool
->GetPoolDefaultItem( EE_PARA_WRITINGDIR
) : nullptr );
1269 css::text::WritingMode eRet
= css::text::WritingMode_LR_TB
;
1273 switch( static_cast<const SvxFrameDirectionItem
&>( *pItem
).GetValue() )
1275 case SvxFrameDirection::Horizontal_LR_TB
: eRet
= css::text::WritingMode_LR_TB
; break;
1276 case SvxFrameDirection::Horizontal_RL_TB
: eRet
= css::text::WritingMode_RL_TB
; break;
1277 case SvxFrameDirection::Vertical_RL_TB
: eRet
= css::text::WritingMode_TB_RL
; break;
1280 OSL_FAIL( "Frame direction not supported yet" );
1288 void SdDrawDocument::SetDefaultWritingMode(css::text::WritingMode eMode
)
1293 SvxFrameDirection nVal
;
1296 case css::text::WritingMode_LR_TB
: nVal
= SvxFrameDirection::Horizontal_LR_TB
; break;
1297 case css::text::WritingMode_RL_TB
: nVal
= SvxFrameDirection::Horizontal_RL_TB
; break;
1298 case css::text::WritingMode_TB_RL
: nVal
= SvxFrameDirection::Vertical_RL_TB
; break;
1300 OSL_FAIL( "Frame direction not supported yet" );
1304 SvxFrameDirectionItem
aModeItem( nVal
, EE_PARA_WRITINGDIR
);
1305 m_pItemPool
->SetPoolDefaultItem( aModeItem
);
1307 SvxAdjustItem
aAdjust( SvxAdjust::Left
, EE_PARA_JUST
);
1309 if( eMode
== css::text::WritingMode_RL_TB
)
1310 aAdjust
.SetAdjust( SvxAdjust::Right
);
1312 m_pItemPool
->SetPoolDefaultItem( aAdjust
);
1315 void SdDrawDocument::getDefaultFonts( vcl::Font
& rLatinFont
, vcl::Font
& rCJKFont
, vcl::Font
& rCTLFont
)
1317 LanguageType eLatin
= GetLanguage( EE_CHAR_LANGUAGE
);
1319 // If the UI language is Korean, the default Latin font has to
1320 // be queried for Korean, too (the Latin language from the document can't be Korean).
1321 // This is the same logic as in SwDocShell::InitNew.
1322 LanguageType eUiLanguage
= Application::GetSettings().GetUILanguageTag().getLanguageType();
1323 if (MsLangId::isKorean(eUiLanguage
))
1324 eLatin
= eUiLanguage
;
1326 rLatinFont
= OutputDevice::GetDefaultFont( DefaultFontType::LATIN_PRESENTATION
, eLatin
, GetDefaultFontFlags::OnlyOne
);
1327 rCJKFont
= OutputDevice::GetDefaultFont( DefaultFontType::CJK_PRESENTATION
, GetLanguage( EE_CHAR_LANGUAGE_CJK
), GetDefaultFontFlags::OnlyOne
);
1328 rCTLFont
= OutputDevice::GetDefaultFont( DefaultFontType::CTL_PRESENTATION
, GetLanguage( EE_CHAR_LANGUAGE_CTL
), GetDefaultFontFlags::OnlyOne
) ;
1331 /* converts the given western font height to a corresponding ctl font height, depending on the system language */
1332 sal_uInt32
SdDrawDocument::convertFontHeightToCTL( sal_uInt32 nWesternFontHeight
)
1334 LanguageType eRealCTLLanguage
= Application::GetSettings().GetLanguageTag().getLanguageType();
1335 if( LANGUAGE_THAI
== eRealCTLLanguage
)
1337 // http://specs.openoffice.org/g11n/font_sizes/42775_42725_Individual_configurable_font_size_for_default_fonts.odt
1338 double fTemp
= double(nWesternFontHeight
) * 1.333;
1339 nWesternFontHeight
= static_cast<sal_uInt32
>(fTemp
);
1340 // make some nice values for UI that displays PT instead of 1/100th mm
1341 nWesternFontHeight
= ((nWesternFontHeight
* 72) + 1270) / 2540L;
1342 nWesternFontHeight
= ((nWesternFontHeight
* 2540L) + 36) / 72;
1344 return nWesternFontHeight
;
1347 SdStyleSheetPool
* SdDrawDocument::GetSdStyleSheetPool() const
1349 return dynamic_cast< SdStyleSheetPool
* >( GetStyleSheetPool() );
1352 ModifyGuard::ModifyGuard( SdDrawDocument
* pDoc
)
1353 : mpDocShell( nullptr ), mpDoc( pDoc
)
1358 void ModifyGuard::init()
1362 mpDoc
= mpDocShell
->GetDoc();
1366 mpDocShell
= mpDoc
->GetDocSh();
1369 mbIsEnableSetModified
= mpDocShell
&& mpDocShell
->IsEnableSetModified();
1370 mbIsDocumentChanged
= mpDoc
&& mpDoc
->IsChanged();
1372 if( mbIsEnableSetModified
)
1373 mpDocShell
->EnableSetModified( false );
1376 ModifyGuard::~ModifyGuard()
1378 if( mbIsEnableSetModified
)
1379 mpDocShell
->EnableSetModified();
1381 if( mpDoc
&& (mpDoc
->IsChanged() != mbIsDocumentChanged
) )
1382 mpDoc
->SetChanged(mbIsDocumentChanged
);
1385 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */