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>
21 #include <config_folders.h>
23 #include <com/sun/star/style/XStyle.hpp>
24 #include <com/sun/star/drawing/LineStyle.hpp>
25 #include <com/sun/star/form/XReset.hpp>
26 #include <com/sun/star/document/XImporter.hpp>
27 #include <com/sun/star/uno/XComponentContext.hpp>
28 #include <com/sun/star/xml/sax/XFastParser.hpp>
29 #include <i18nlangtag/languagetag.hxx>
30 #include <i18nlangtag/mslangid.hxx>
31 #include <sfx2/dispatch.hxx>
32 #include <Outliner.hxx>
33 #include <editeng/outliner.hxx>
35 #include <DrawDocShell.hxx>
36 #include <editeng/eeitem.hxx>
37 #include <comphelper/diagnose_ex.hxx>
38 #include <comphelper/processfactory.hxx>
39 #include <comphelper/propertyvalue.hxx>
40 #include <rtl/bootstrap.hxx>
41 #include <comphelper/configuration.hxx>
42 #include <unotools/streamwrap.hxx>
43 #include <tools/stream.hxx>
44 #include <tools/UnitConversion.hxx>
46 #include <vcl/idle.hxx>
47 #include <vcl/settings.hxx>
48 #include <vcl/svapp.hxx>
50 #include <editeng/autokernitem.hxx>
52 #include <svx/svxids.hrc>
53 #include <svl/srchitem.hxx>
54 #include <editeng/lrspitem.hxx>
55 #include <editeng/ulspitem.hxx>
56 #include <editeng/lspcitem.hxx>
57 #include <editeng/adjustitem.hxx>
58 #include <editeng/numdef.hxx>
59 #include <svx/strings.hrc>
60 #include <svx/dialmgr.hxx>
61 #include <editeng/bulletitem.hxx>
62 #include <editeng/borderline.hxx>
63 #include <editeng/boxitem.hxx>
64 #include <svx/xlineit0.hxx>
65 #include <svx/sdshitm.hxx>
66 #include <svx/svdotext.hxx>
67 #include <svx/xfillit0.hxx>
68 #include <svx/sdshcitm.hxx>
69 #include <editeng/editstat.hxx>
70 #include <editeng/colritem.hxx>
71 #include <editeng/fhgtitem.hxx>
72 #include <editeng/wghtitem.hxx>
73 #include <editeng/postitem.hxx>
74 #include <editeng/crossedoutitem.hxx>
75 #include <editeng/udlnitem.hxx>
76 #include <editeng/contouritem.hxx>
77 #include <editeng/emphasismarkitem.hxx>
78 #include <editeng/fontitem.hxx>
79 #include <editeng/shdditem.hxx>
80 #include <editeng/cmapitem.hxx>
81 #include <svx/xbtmpit.hxx>
82 #include <svx/xflhtit.hxx>
83 #include <svx/xflgrit.hxx>
84 #include <svx/xflclit.hxx>
85 #include <svx/xlnedcit.hxx>
86 #include <svx/xlnstcit.hxx>
87 #include <svx/xlnedwit.hxx>
88 #include <svx/xlnstwit.hxx>
89 #include <svx/xlnedit.hxx>
90 #include <editeng/charreliefitem.hxx>
91 #include <svx/xlnstit.hxx>
92 #include <svx/xlndsit.hxx>
93 #include <svx/xlnwtit.hxx>
94 #include <svx/xlnclit.hxx>
95 #include <svx/svditer.hxx>
96 #include <svx/svdogrp.hxx>
97 #include <svx/sdsxyitm.hxx>
98 #include <svx/sdtditm.hxx>
99 #include <svx/sdtaitm.hxx>
100 #include <svx/sdynitm.hxx>
101 #include <editeng/numitem.hxx>
102 #include <editeng/unolingu.hxx>
103 #include <svl/itempool.hxx>
104 #include <editeng/outlobj.hxx>
105 #include <sfx2/viewfrm.hxx>
106 #include <editeng/frmdiritem.hxx>
107 #include <svx/sdasitm.hxx>
109 #include <sdresid.hxx>
110 #include <drawdoc.hxx>
111 #include <sdpage.hxx>
112 #include <strings.hrc>
114 #include <stlpool.hxx>
115 #include <shapelist.hxx>
116 #include <basegfx/point/b2dpoint.hxx>
117 #include <basegfx/polygon/b2dpolygon.hxx>
118 #include <svl/itemset.hxx>
120 #include <strings.hxx>
122 namespace com::sun::star::linguistic2
{ class XHyphenator
; }
124 using namespace ::com::sun::star
;
125 using namespace ::com::sun::star::uno
;
126 using namespace ::com::sun::star::lang
;
127 using namespace ::com::sun::star::style
;
128 using namespace ::com::sun::star::linguistic2
;
129 using namespace ::sd
;
131 // CreateLayoutTemplates
132 // At the moment (31.03.1995), the StyleSheetPool only saves styleheets that
133 // have an ItemSet. To save all stylesheets, we force the creation of an ItemSet
134 // with a GetItemSet call.
135 // We can remove this behavior once the pool saves styleheets even without an ItemSet
136 void SdDrawDocument::CreateLayoutTemplates()
138 SdStyleSheetPool
* pSSPool
= static_cast<SdStyleSheetPool
*>(GetStyleSheetPool());
139 SfxStyleSheetBase
* pSheet
= nullptr;
140 const OUString aHelpFile
;
141 OUString
aStdName(SdResId(STR_STANDARD_STYLESHEET_NAME
));
145 SfxStyleSearchBits nMask
= SfxStyleSearchBits::Auto
;
147 OUString
aName(aStdName
);
148 pSheet
= &(pSSPool
->Make(aName
, SfxStyleFamily::Para
, nMask
));
149 pSheet
->SetHelpId( aHelpFile
, HID_STANDARD_STYLESHEET_NAME
);
150 SfxItemSet
& rISet
= pSheet
->GetItemSet();
152 Color
aNullCol(COL_DEFAULT_SHAPE_STROKE
);
155 basegfx::BGradient
aNullGrad(
156 basegfx::BColorStops(
157 aNullCol
.getBColor(),
158 COL_WHITE
.getBColor()));
159 aNullGrad
.SetStartIntens( 100 );
160 aNullGrad
.SetEndIntens( 100 );
161 XHatch
aNullHatch(aNullCol
);
163 // Line attributes (Extended OutputDevice)
164 rISet
.Put(XLineStyleItem(drawing::LineStyle_SOLID
));
165 rISet
.Put(XLineColorItem(OUString(), COL_DEFAULT_SHAPE_STROKE
));
166 rISet
.Put(XLineWidthItem(0));
167 rISet
.Put(XLineDashItem(aNullDash
));
168 rISet
.Put(XLineStartItem(basegfx::B2DPolyPolygon()));
169 rISet
.Put(XLineEndItem(basegfx::B2DPolyPolygon()));
170 rISet
.Put(XLineStartWidthItem(200));
171 rISet
.Put(XLineEndWidthItem(200));
172 rISet
.Put(XLineStartCenterItem());
173 rISet
.Put(XLineEndCenterItem());
174 rISet
.Put(SdrTextHorzAdjustItem(SDRTEXTHORZADJUST_BLOCK
));
176 // Fill attributes (Extended OutputDevice)
177 rISet
.Put(XFillStyleItem(drawing::FillStyle_SOLID
));
178 rISet
.Put(XFillColorItem(OUString(), COL_DEFAULT_SHAPE_FILLING
));
180 rISet
.Put( XFillGradientItem( aNullGrad
) );
181 rISet
.Put(XFillHatchItem(aNullHatch
));
182 Size
aNullSize( 32, 32 );
183 Bitmap
aNullBmp(aNullSize
, vcl::PixelFormat::N8_BPP
);
184 aNullBmp
.Erase( COL_WHITE
);
185 rISet
.Put(XFillBitmapItem(Graphic(BitmapEx(aNullBmp
))));
187 // Shadow attributes (Drawing Engine)
188 rISet
.Put(makeSdrShadowItem(false));
189 rISet
.Put(makeSdrShadowColorItem(COL_GRAY
));
190 rISet
.Put(makeSdrShadowXDistItem(200)); // 3 mm Shadow distance
191 rISet
.Put(makeSdrShadowYDistItem(200));
193 vcl::Font aLatinFont
, aCJKFont
, aCTLFont
;
195 getDefaultFonts( aLatinFont
, aCJKFont
, aCTLFont
);
197 SvxFontItem
aSvxFontItem( aLatinFont
.GetFamilyType(), aLatinFont
.GetFamilyName(), aLatinFont
.GetStyleName(), aLatinFont
.GetPitch(),
198 aLatinFont
.GetCharSet(), EE_CHAR_FONTINFO
);
200 SvxFontItem
aSvxFontItemCJK( aCJKFont
.GetFamilyType(), aCJKFont
.GetFamilyName(), aCJKFont
.GetStyleName(), aCJKFont
.GetPitch(),
201 aCJKFont
.GetCharSet(), EE_CHAR_FONTINFO_CJK
);
203 SvxFontItem
aSvxFontItemCTL( aCTLFont
.GetFamilyType(), aCTLFont
.GetFamilyName(), aCTLFont
.GetStyleName(), aCTLFont
.GetPitch(),
204 aCTLFont
.GetCharSet(), EE_CHAR_FONTINFO_CTL
);
206 rISet
.Put( aSvxFontItem
);
207 rISet
.Put( aSvxFontItemCJK
);
208 rISet
.Put( aSvxFontItemCTL
);
210 rISet
.Put( SvxFontHeightItem( 635, 100, EE_CHAR_FONTHEIGHT
) ); // sj: (i33745) changed default from 24 to 18 pt
211 rISet
.Put( SvxFontHeightItem( 635, 100, EE_CHAR_FONTHEIGHT_CJK
) ); // 18 pt
212 rISet
.Put( SvxFontHeightItem( convertFontHeightToCTL( 635 ), 100, EE_CHAR_FONTHEIGHT_CTL
) ); // 18 pt
214 rISet
.Put( SvxWeightItem( WEIGHT_NORMAL
, EE_CHAR_WEIGHT
) );
215 rISet
.Put( SvxWeightItem( WEIGHT_NORMAL
, EE_CHAR_WEIGHT_CJK
) );
216 rISet
.Put( SvxWeightItem( WEIGHT_NORMAL
, EE_CHAR_WEIGHT_CTL
) );
218 rISet
.Put( SvxPostureItem( ITALIC_NONE
, EE_CHAR_ITALIC
) );
219 rISet
.Put( SvxPostureItem( ITALIC_NONE
, EE_CHAR_ITALIC_CJK
) );
220 rISet
.Put( SvxPostureItem( ITALIC_NONE
, EE_CHAR_ITALIC_CTL
) );
222 rISet
.Put(SvxContourItem(false, EE_CHAR_OUTLINE
));
223 rISet
.Put(SvxShadowedItem(false, EE_CHAR_SHADOW
));
224 rISet
.Put(SvxUnderlineItem(LINESTYLE_NONE
, EE_CHAR_UNDERLINE
));
225 rISet
.Put(SvxOverlineItem(LINESTYLE_NONE
, EE_CHAR_OVERLINE
));
226 rISet
.Put(SvxCrossedOutItem(STRIKEOUT_NONE
, EE_CHAR_STRIKEOUT
));
227 rISet
.Put(SvxCaseMapItem(SvxCaseMap::NotMapped
, EE_CHAR_CASEMAP
));
228 rISet
.Put(SvxEmphasisMarkItem(FontEmphasisMark::NONE
, EE_CHAR_EMPHASISMARK
));
229 rISet
.Put(SvxCharReliefItem(FontRelief::NONE
, EE_CHAR_RELIEF
));
230 rISet
.Put(SvxColorItem(COL_AUTO
, EE_CHAR_COLOR
));
232 // Paragraph attributes (Edit Engine)
233 rISet
.Put(SvxLRSpaceItem(EE_PARA_LRSPACE
));
234 rISet
.Put(SvxULSpaceItem(EE_PARA_ULSPACE
));
236 rISet
.Put( makeSdrTextLeftDistItem( 250 ) ); // sj: (i33745) using text frame distances seems to be a better default
237 rISet
.Put( makeSdrTextRightDistItem( 250 ) );
238 rISet
.Put( makeSdrTextUpperDistItem( 125 ) );
239 rISet
.Put( makeSdrTextLowerDistItem( 125 ) );
241 // Set Word-wrap to true by default
242 rISet
.Put( makeSdrTextWordWrapItem(true) );
244 rISet
.Put( SvxLineSpacingItem( LINE_SPACE_DEFAULT_HEIGHT
, EE_PARA_SBL
) );
246 // #i16874# enable kerning by default but only for new documents
247 rISet
.Put( SvxAutoKernItem( true, EE_CHAR_PAIRKERNING
) );
250 // BulletItem and BulletFont for title and outline
251 SvxBulletItem
aBulletItem(EE_PARA_BULLET
);
252 // Identical in all layers
253 aBulletItem
.SetStyle(SvxBulletStyle::BULLET
);
254 aBulletItem
.SetStart(1);
255 aBulletItem
.SetScale(45); // In percent
257 vcl::Font
aBulletFont( SdStyleSheetPool::GetBulletFont() );
259 aBulletFont
.SetFontSize(Size(0,635)); // sj: (i33745) changed default from 24 to 18 pt
261 aBulletItem
.SetFont(aBulletFont
);
262 aBulletItem
.SetSymbol( 0x25CF ); // In points
263 rISet
.Put(aBulletItem
);
266 SdStyleSheetPool::PutNumBulletItem( pSheet
, aBulletFont
);
268 SfxItemSet
* pISet
= nullptr;
270 // Default > Object without filling
272 aName
= SdResId(STR_POOLSHEET_OBJWITHOUTFILL
);
273 pSheet
= &(pSSPool
->Make(aName
, SfxStyleFamily::Para
, nMask
));
274 pSheet
->SetParent(aStdName
);
275 pSheet
->SetHelpId( aHelpFile
, HID_POOLSHEET_OBJWITHOUTFILL
);
276 pISet
= &pSheet
->GetItemSet();
278 pISet
->Put(XFillStyleItem(drawing::FillStyle_NONE
));
280 // Default > Object no fill no line
282 aName
= SdResId(STR_POOLSHEET_OBJNOLINENOFILL
);
283 pSheet
= &(pSSPool
->Make(aName
, SfxStyleFamily::Para
, nMask
));
284 pSheet
->SetParent(aStdName
);
285 pSheet
->SetHelpId( aHelpFile
, HID_POOLSHEET_OBJNOLINENOFILL
);
286 pISet
= &pSheet
->GetItemSet();
288 pISet
->Put(XFillStyleItem(drawing::FillStyle_NONE
));
289 pISet
->Put(XLineStyleItem(drawing::LineStyle_NONE
));
297 aTextName
= SdResId(STR_POOLSHEET_TEXT
);
298 pSheet
= &(pSSPool
->Make(aTextName
, SfxStyleFamily::Para
, nMask
));
299 pSheet
->SetHelpId( aHelpFile
, HID_POOLSHEET_TEXT
);
300 pISet
= &pSheet
->GetItemSet();
301 aSvxFontItem
.SetFamilyName(u
"Noto Sans"_ustr
);
302 pISet
->Put( aSvxFontItem
); // Noto Sans
303 pISet
->Put(XFillStyleItem(drawing::FillStyle_SOLID
)); // solid fill
304 pISet
->Put(XFillColorItem(OUString(), Color(0xeeeeee))); // light gray 5
305 pISet
->Put(XLineStyleItem(drawing::LineStyle_SOLID
)); // solid fill
306 pISet
->Put(XLineColorItem(OUString(), Color(0xcccccc))); // light gray 3
311 aA4Name
= SdResId(STR_POOLSHEET_A4
);
312 pSheet
= &(pSSPool
->Make(aA4Name
, SfxStyleFamily::Para
, nMask
));
313 pSheet
->SetParent( aTextName
);
314 pSheet
->SetHelpId( aHelpFile
, HID_POOLSHEET_A4
);
315 pISet
= &pSheet
->GetItemSet();
316 pISet
->Put(SvxFontHeightItem(635, 100, EE_CHAR_FONTHEIGHT
)); // 18 pt
317 pISet
->Put(XFillStyleItem(drawing::FillStyle_NONE
)); // no filling
322 aName
= SdResId(STR_POOLSHEET_A4_TITLE
);
323 pSheet
= &(pSSPool
->Make(aName
, SfxStyleFamily::Para
, nMask
));
324 pSheet
->SetParent( aA4Name
);
325 pSheet
->SetHelpId( aHelpFile
, HID_POOLSHEET_A4_TITLE
);
326 pISet
= &pSheet
->GetItemSet();
327 pISet
->Put(SvxFontHeightItem(1551, 100, EE_CHAR_FONTHEIGHT
)); // 44 pt
328 pISet
->Put(XLineStyleItem(drawing::LineStyle_NONE
)); // no border
330 // Text > A4 > Headline
332 aName
= SdResId(STR_POOLSHEET_A4_HEADLINE
);
333 pSheet
= &(pSSPool
->Make(aName
, SfxStyleFamily::Para
, nMask
));
334 pSheet
->SetParent( aA4Name
);
335 pSheet
->SetHelpId( aHelpFile
, HID_POOLSHEET_A4_HEADLINE
);
336 pISet
= &pSheet
->GetItemSet();
337 pISet
->Put(SvxFontHeightItem(847, 100, EE_CHAR_FONTHEIGHT
)); // 24 pt
338 pISet
->Put(XLineStyleItem(drawing::LineStyle_NONE
)); // no border
342 aName
= SdResId(STR_POOLSHEET_A4_TEXT
);
343 pSheet
= &(pSSPool
->Make(aName
, SfxStyleFamily::Para
, nMask
));
344 pSheet
->SetParent(aA4Name
);
345 pSheet
->SetHelpId( aHelpFile
, HID_POOLSHEET_A4_TEXT
);
346 pISet
= &pSheet
->GetItemSet();
347 pISet
->Put(XLineStyleItem(drawing::LineStyle_NONE
)); // no border
352 aA0Name
= SdResId(STR_POOLSHEET_A0
);
353 pSheet
= &(pSSPool
->Make(aA0Name
, SfxStyleFamily::Para
, nMask
));
354 pSheet
->SetParent(aTextName
);
355 pSheet
->SetHelpId( aHelpFile
, HID_POOLSHEET_A0
);
356 pISet
= &pSheet
->GetItemSet();
357 pISet
->Put(SvxFontHeightItem(1692, 100, EE_CHAR_FONTHEIGHT
)); // 48 pt
358 pISet
->Put(XFillStyleItem(drawing::FillStyle_NONE
)); // no filling
362 aName
= SdResId(STR_POOLSHEET_A0_TITLE
);
363 pSheet
= &(pSSPool
->Make(aName
, SfxStyleFamily::Para
, nMask
));
364 pSheet
->SetParent(aA0Name
);
365 pSheet
->SetHelpId( aHelpFile
, HID_POOLSHEET_A0_TITLE
);
366 pISet
= &pSheet
->GetItemSet();
367 pISet
->Put(SvxFontHeightItem(3385, 100, EE_CHAR_FONTHEIGHT
)); // 96 pt
368 pISet
->Put(XLineStyleItem(drawing::LineStyle_NONE
)); // no border
370 // Text > A0 > Headline
372 aName
= SdResId(STR_POOLSHEET_A0_HEADLINE
);
373 pSheet
= &(pSSPool
->Make(aName
, SfxStyleFamily::Para
, nMask
));
374 pSheet
->SetParent(aA0Name
);
375 pSheet
->SetHelpId( aHelpFile
, HID_POOLSHEET_A0_HEADLINE
);
376 pISet
= &pSheet
->GetItemSet();
377 pISet
->Put(SvxFontHeightItem(2538, 100, EE_CHAR_FONTHEIGHT
)); // 72 pt
378 pISet
->Put(XLineStyleItem(drawing::LineStyle_NONE
)); // no border
382 aName
= SdResId(STR_POOLSHEET_A0_TEXT
);
383 pSheet
= &(pSSPool
->Make(aName
, SfxStyleFamily::Para
, nMask
));
384 pSheet
->SetParent(aA0Name
);
385 pSheet
->SetHelpId( aHelpFile
, HID_POOLSHEET_A0_TEXT
);
386 pISet
= &pSheet
->GetItemSet();
387 pISet
->Put(XLineStyleItem(drawing::LineStyle_NONE
)); // no border
391 OUString aGraphicName
;
392 XFillGradientItem aFillGradient
;
393 basegfx::BGradient aGradient
;
396 aGraphicName
= SdResId(STR_POOLSHEET_GRAPHIC
);
397 pSheet
= &(pSSPool
->Make(aGraphicName
, SfxStyleFamily::Para
, nMask
));
398 pSheet
->SetHelpId( aHelpFile
, HID_POOLSHEET_GRAPHIC
);
399 pISet
= &pSheet
->GetItemSet();
400 aSvxFontItem
.SetFamilyName(u
"Liberation Sans"_ustr
); // Liberation Sans
401 pISet
->Put( aSvxFontItem
);
402 pISet
->Put( SvxFontHeightItem(635, 100, EE_CHAR_FONTHEIGHT
) ); // 18 pt
403 pISet
->Put( XFillStyleItem(drawing::FillStyle_SOLID
) ); // solid fill
404 pISet
->Put( XFillColorItem(OUString(), COL_WHITE
) ); // filled white
408 OUString aShapesName
;
410 aShapesName
= SdResId(STR_POOLSHEET_SHAPES
);
411 pSheet
= &(pSSPool
->Make(aShapesName
, SfxStyleFamily::Para
, nMask
));
412 pSheet
->SetParent( aGraphicName
);
413 pSheet
->SetHelpId( aHelpFile
, HID_POOLSHEET_SHAPES
);
414 pISet
= &pSheet
->GetItemSet();
415 pISet
->Put(XFillStyleItem(drawing::FillStyle_GRADIENT
)); // fill with gradient
416 aGradient
.SetGradientStyle( ::awt::GradientStyle_RECT
); // square type
417 aGradient
.SetAngle( 0_deg10
); // 0° angle
419 aGradient
.SetColorStops(
420 basegfx::BColorStops(
421 Color(0xcccccc).getBColor(), // light gray 3
422 COL_WHITE
.getBColor())); // white
424 aFillGradient
.SetName( aShapesName
);
425 aFillGradient
.SetGradientValue(aGradient
);
426 pISet
->Put( aFillGradient
);
427 pISet
->Put( XLineStyleItem(drawing::LineStyle_NONE
) ); // no border
428 pISet
->Put( SvxFontHeightItem(494, 100, EE_CHAR_FONTHEIGHT
) ); // 14 pt
429 pISet
->Put( SvxWeightItem(WEIGHT_BOLD
, EE_CHAR_WEIGHT
) ); // bold
431 // Graphic > Shapes > Filled
432 OUString
aFilledName(SdResId(STR_POOLSHEET_FILLED
));
435 pSheet
= &(pSSPool
->Make(aName
, SfxStyleFamily::Para
, nMask
));
436 pSheet
->SetHelpId( aHelpFile
, HID_POOLSHEET_FILLED
);
437 pSheet
->SetParent( aShapesName
);
438 pISet
= &pSheet
->GetItemSet();
440 aGradient
.SetGradientStyle( ::awt::GradientStyle_LINEAR
);
441 aGradient
.SetAngle( 300_deg10
);
443 aGradient
.SetColorStops(
444 basegfx::BColorStops(
445 COL_WHITE
.getBColor(), // white
446 Color(0xcccccc).getBColor())); // light gray 3
448 aFillGradient
.SetName( aName
);
449 aFillGradient
.SetGradientValue(aGradient
);
450 pISet
->Put( XFillStyleItem(drawing::FillStyle_GRADIENT
) );
451 pISet
->Put( aFillGradient
);
453 // Graphic > Shapes > Filled > Blue
455 aName
=SdResId(STR_POOLSHEET_FILLED_BLUE
);
456 pSheet
= &(pSSPool
->Make(aName
, SfxStyleFamily::Para
, nMask
));
457 pSheet
->SetParent(aFilledName
);
458 pSheet
->SetHelpId( aHelpFile
, HID_POOLSHEET_FILLED_BLUE
);
459 pISet
= &pSheet
->GetItemSet();
461 aGradient
.SetColorStops(
462 basegfx::BColorStops(
463 Color(0x00729fcf).getBColor(), // light blue 2
464 Color(0x00355269).getBColor())); // dark blue 2
466 aFillGradient
.SetName( aName
);
467 aFillGradient
.SetGradientValue(aGradient
);
468 pISet
->Put( aFillGradient
);
469 pISet
->Put( SvxColorItem(COL_WHITE
, EE_CHAR_COLOR
)); // font white
471 // Graphic > Shapes > Filled > Green
473 aName
=SdResId(STR_POOLSHEET_FILLED_GREEN
);
474 pSheet
= &(pSSPool
->Make(aName
, SfxStyleFamily::Para
, nMask
));
475 pSheet
->SetParent(aFilledName
);
476 pSheet
->SetHelpId( aHelpFile
, HID_POOLSHEET_FILLED_GREEN
);
477 pISet
= &pSheet
->GetItemSet();
479 aGradient
.SetColorStops(
480 basegfx::BColorStops(
481 Color(0x0077bc65).getBColor(), // light green 2
482 Color(0x00127622).getBColor())); // dark green 2
484 aFillGradient
.SetName( aName
);
485 aFillGradient
.SetGradientValue(aGradient
);
486 pISet
->Put( aFillGradient
);
487 pISet
->Put( aSvxFontItem
); // font name
488 pISet
->Put( SvxColorItem(COL_WHITE
, EE_CHAR_COLOR
)); // font white
490 // Graphic > Shapes > Filled > Red
492 aName
=SdResId(STR_POOLSHEET_FILLED_RED
);
493 pSheet
= &(pSSPool
->Make(aName
, SfxStyleFamily::Para
, nMask
));
494 pSheet
->SetParent(aFilledName
);
495 pSheet
->SetHelpId( aHelpFile
, HID_POOLSHEET_FILLED_RED
);
496 pISet
= &pSheet
->GetItemSet();
498 aGradient
.SetColorStops(
499 basegfx::BColorStops(
500 Color(0x00ff6d6d).getBColor(), // light red 2
501 Color(0x00c9211e).getBColor())); // dark red 2
503 aFillGradient
.SetName( aName
);
504 aFillGradient
.SetGradientValue(aGradient
);
505 pISet
->Put( aFillGradient
);
506 pISet
->Put( SvxColorItem(COL_WHITE
, EE_CHAR_COLOR
)); // font white
508 // Graphic > Shapes > Filled > Yellow
510 aName
=SdResId(STR_POOLSHEET_FILLED_YELLOW
);
511 pSheet
= &(pSSPool
->Make(aName
, SfxStyleFamily::Para
, nMask
));
512 pSheet
->SetParent(aFilledName
);
513 pSheet
->SetHelpId( aHelpFile
, HID_POOLSHEET_FILLED_YELLOW
);
514 pISet
= &pSheet
->GetItemSet();
516 aGradient
.SetColorStops(
517 basegfx::BColorStops(
518 Color(0x00ffde59).getBColor(), // light gold 2
519 Color(0x00b47804).getBColor())); // dark gold 2
521 aFillGradient
.SetName( aName
);
522 aFillGradient
.SetGradientValue(aGradient
);
523 pISet
->Put( aFillGradient
);
524 pISet
->Put( SvxColorItem(COL_WHITE
, EE_CHAR_COLOR
)); // font white
526 // Graphic > Shapes > Outlines
527 OUString
aOutlineName(SdResId(STR_POOLSHEET_OUTLINE
));
529 aName
= aOutlineName
;
530 pSheet
= &(pSSPool
->Make(aName
, SfxStyleFamily::Para
, nMask
));
531 pSheet
->SetHelpId( aHelpFile
, HID_POOLSHEET_OUTLINE
);
532 pSheet
->SetParent( aShapesName
);
533 pISet
= &pSheet
->GetItemSet();
534 pISet
->Put( XFillStyleItem(drawing::FillStyle_NONE
) ); // clear
535 pISet
->Put( XLineStyleItem(drawing::LineStyle_SOLID
) ); // solide line
536 pISet
->Put( XLineWidthItem(81) ); // 2.3 pt
537 pISet
->Put( XLineColorItem(OUString(), COL_BLACK
) ); // b/w
539 // Graphic > Shapes > Outlines > Blue
541 aName
=SdResId(STR_POOLSHEET_OUTLINE_BLUE
);
542 pSheet
= &(pSSPool
->Make(aName
, SfxStyleFamily::Para
, nMask
));
543 pSheet
->SetParent(aOutlineName
);
544 pSheet
->SetHelpId( aHelpFile
, HID_POOLSHEET_OUTLINE_BLUE
);
545 pISet
= &pSheet
->GetItemSet();
546 pISet
->Put( XLineColorItem(OUString(), Color(0x00355269)) ); // dark blue 2
547 pISet
->Put( SvxColorItem(Color(0x00355269), EE_CHAR_COLOR
)); // font color
549 // Graphic > Shapes > Outlines > Green
551 aName
=SdResId(STR_POOLSHEET_OUTLINE_GREEN
);
552 pSheet
= &(pSSPool
->Make(aName
, SfxStyleFamily::Para
, nMask
));
553 pSheet
->SetParent(aOutlineName
);
554 pSheet
->SetHelpId( aHelpFile
, HID_POOLSHEET_OUTLINE_GREEN
);
555 pISet
= &pSheet
->GetItemSet();
556 pISet
->Put( XLineColorItem(OUString(), Color(0x00127622)) ); // dark green 2
557 pISet
->Put( SvxColorItem(Color(0x00127622), EE_CHAR_COLOR
)); // font color
559 // Graphic > Shapes > Outlines > Red
561 aName
=SdResId(STR_POOLSHEET_OUTLINE_RED
);
562 pSheet
= &(pSSPool
->Make(aName
, SfxStyleFamily::Para
, nMask
));
563 pSheet
->SetParent(aOutlineName
);
564 pSheet
->SetHelpId( aHelpFile
, HID_POOLSHEET_OUTLINE_RED
);
565 pISet
= &pSheet
->GetItemSet();
566 pISet
->Put( XLineColorItem(OUString(), Color(0x00c9211e)) ); // dark red 2
567 pISet
->Put( SvxColorItem(Color(0x00c9211e), EE_CHAR_COLOR
)); // font color
569 // Graphic > Shapes > Outlines > Yellow
571 aName
=SdResId(STR_POOLSHEET_OUTLINE_YELLOW
);
572 pSheet
= &(pSSPool
->Make(aName
, SfxStyleFamily::Para
, nMask
));
573 pSheet
->SetParent(aOutlineName
);
574 pSheet
->SetHelpId( aHelpFile
, HID_POOLSHEET_OUTLINE_YELLOW
);
575 pISet
= &pSheet
->GetItemSet();
576 pISet
->Put( XLineStyleItem(drawing::LineStyle_SOLID
));
577 pISet
->Put( XLineColorItem(OUString(), Color(0x00b47804)) ); // dark gold 2
578 pISet
->Put( SvxColorItem(Color(0x00b47804), EE_CHAR_COLOR
)); // font color
583 aLinesName
= SdResId(STR_POOLSHEET_LINES
);
584 pSheet
= &(pSSPool
->Make(aLinesName
, SfxStyleFamily::Para
, nMask
));
585 pSheet
->SetParent( aGraphicName
);
586 pSheet
->SetHelpId( aHelpFile
, HID_POOLSHEET_LINES
);
587 pISet
= &pSheet
->GetItemSet();
588 pISet
->Put( XFillStyleItem(drawing::FillStyle_NONE
) ); // clear
589 pISet
->Put( XLineStyleItem(drawing::LineStyle_SOLID
) ); // solide line
590 pISet
->Put( XLineColorItem(OUString(), COL_BLACK
) ); // b/w
592 // Graphic > Lines > Measurements
594 aName
= SdResId(STR_POOLSHEET_MEASURE
);
595 pSheet
= &(pSSPool
->Make(aName
, SfxStyleFamily::Para
, nMask
));
596 pSheet
->SetParent(aLinesName
);
597 pSheet
->SetHelpId( aHelpFile
, HID_POOLSHEET_MEASURE
);
598 pISet
= &pSheet
->GetItemSet();
600 ::basegfx::B2DPolygon aArrow
; // arrows
601 aArrow
.append(::basegfx::B2DPoint(10.0, 0.0));
602 aArrow
.append(::basegfx::B2DPoint(0.0, 30.0));
603 aArrow
.append(::basegfx::B2DPoint(20.0, 30.0));
604 aArrow
.setClosed(true);
606 pISet
->Put(XLineStartItem(SvxResId(RID_SVXSTR_ARROW
),::basegfx::B2DPolyPolygon(aArrow
)));
607 pISet
->Put(XLineStartWidthItem(200));
608 pISet
->Put(XLineEndItem(SvxResId(RID_SVXSTR_ARROW
),::basegfx::B2DPolyPolygon(aArrow
)));
609 pISet
->Put(XLineEndWidthItem(200));
610 pISet
->Put(SdrYesNoItem(SDRATTR_MEASURESHOWUNIT
, true));
612 // Graphic > Lines > Dashed
614 aName
= SdResId(STR_POOLSHEET_LINES_DASHED
);
615 pSheet
= &(pSSPool
->Make(aName
, SfxStyleFamily::Para
, nMask
));
616 pSheet
->SetParent(aLinesName
);
617 pSheet
->SetHelpId( aHelpFile
, HID_POOLSHEET_LINES_DASHED
);
618 pISet
= &pSheet
->GetItemSet();
619 pISet
->Put( XLineStyleItem(drawing::LineStyle_DASH
) ); // dashed line
622 // Generate presentation templates for default layout.
623 OUString aPrefix
= SdResId(STR_LAYOUT_DEFAULT_NAME
);
624 pSSPool
->CreateLayoutStyleSheets(aPrefix
);
627 void SdDrawDocument::CreateDefaultCellStyles()
629 if (comphelper::IsFuzzing())
632 Reference
<css::uno::XComponentContext
> xContext(comphelper::getProcessComponentContext());
633 Reference
<css::document::XImporter
> xImporter(xContext
->getServiceManager()->createInstanceWithArgumentsAndContext(
634 u
"com.sun.star.comp.Draw.XMLOasisStylesImporter"_ustr
,
635 { Any(comphelper::makePropertyValue(u
"OrganizerMode"_ustr
, true)) }, xContext
), UNO_QUERY
);
637 xImporter
->setTargetDocument(mpDocSh
->GetModel());
639 OUString
aURL(u
"$BRAND_BASE_DIR/" LIBO_SHARE_FOLDER
"/config/soffice.cfg/simpress/styles.xml"_ustr
);
640 rtl::Bootstrap::expandMacros(aURL
);
641 SvFileStream
aFile(aURL
, StreamMode::READ
);
643 css::xml::sax::InputSource aParserInput
;
644 aParserInput
.sPublicId
= aURL
;
645 aParserInput
.aInputStream
.set(new utl::OInputStreamWrapper(aFile
));
646 Reference
<css::xml::sax::XFastParser
> xFastParser(xImporter
, UNO_QUERY
);
648 xFastParser
->parseStream(aParserInput
);
650 // Set default fonts, if they were not defined in the xml.
651 vcl::Font aLatinFont
, aCJKFont
, aCTLFont
;
653 getDefaultFonts( aLatinFont
, aCJKFont
, aCTLFont
);
655 SvxFontItem
aSvxFontItem( aLatinFont
.GetFamilyType(), aLatinFont
.GetFamilyName(), aLatinFont
.GetStyleName(), aLatinFont
.GetPitch(),
656 aLatinFont
.GetCharSet(), EE_CHAR_FONTINFO
);
658 SvxFontItem
aSvxFontItemCJK( aCJKFont
.GetFamilyType(), aCJKFont
.GetFamilyName(), aCJKFont
.GetStyleName(), aCJKFont
.GetPitch(),
659 aCJKFont
.GetCharSet(), EE_CHAR_FONTINFO_CJK
);
661 SvxFontItem
aSvxFontItemCTL( aCTLFont
.GetFamilyType(), aCTLFont
.GetFamilyName(), aCTLFont
.GetStyleName(), aCTLFont
.GetPitch(),
662 aCTLFont
.GetCharSet(), EE_CHAR_FONTINFO_CTL
);
664 SdStyleSheetPool
* pSSPool
= static_cast<SdStyleSheetPool
*>(GetStyleSheetPool());
665 SfxStyleSheetBase
* pDefaultStyle
= pSSPool
->Find(u
"default"_ustr
, SfxStyleFamily::Frame
);
668 SfxItemSet
& rSet(pDefaultStyle
->GetItemSet());
669 if (!rSet
.HasItem(EE_CHAR_FONTINFO
))
670 rSet
.Put(aSvxFontItem
);
671 if (!rSet
.HasItem(EE_CHAR_FONTINFO_CJK
))
672 rSet
.Put(aSvxFontItemCJK
);
673 if (!rSet
.HasItem(EE_CHAR_FONTINFO_CTL
))
674 rSet
.Put(aSvxFontItemCTL
);
677 // Reset the user defined flag.
678 SfxStyleSheetBase
* pSheet
= pSSPool
->First(SfxStyleFamily::Frame
);
681 pSheet
->SetMask(SfxStyleSearchBits::Auto
);
682 pSheet
= pSSPool
->Next();
685 Reference
<form::XReset
> xReset(pSSPool
->getByName(u
"table"_ustr
), UNO_QUERY
);
690 // Number of pages that reference a master page
691 sal_uInt16
SdDrawDocument::GetMasterPageUserCount(SdrPage
const * pMaster
) const
693 sal_uInt16 nResult
= 0;
695 sal_uInt16 nPageCount
= GetPageCount();
697 for (nPage
= 0; nPage
< nPageCount
; nPage
++)
699 const SdrPage
* pPage
= GetPage(nPage
);
701 if(pPage
->TRG_HasMasterPage())
703 if(&(pPage
->TRG_GetMasterPage()) == pMaster
)
712 // Finish OnlineSpelling in the background
714 void SdDrawDocument::StopOnlineSpelling()
716 if (mpOnlineSpellingIdle
&& mpOnlineSpellingIdle
->IsActive())
718 mpOnlineSpellingIdle
->Stop();
721 mpOnlineSpellingIdle
.reset();
722 mpOnlineSpellingList
.reset();
725 // Start OnlineSpelling in the background
726 void SdDrawDocument::StartOnlineSpelling(bool bForceSpelling
)
728 if ( !mbOnlineSpell
|| !(bForceSpelling
|| mbInitialOnlineSpellingEnabled
) ||
729 !mpDocSh
|| mpDocSh
->IsReadOnly() )
732 StopOnlineSpelling();
734 SdOutliner
* pOutl
= GetInternalOutliner();
736 Reference
< XSpellChecker1
> xSpellChecker( LinguMgr::GetSpellChecker() );
737 if ( xSpellChecker
.is() )
738 pOutl
->SetSpeller( xSpellChecker
);
740 Reference
< XHyphenator
> xHyphenator( LinguMgr::GetHyphenator() );
741 if( xHyphenator
.is() )
742 pOutl
->SetHyphenator( xHyphenator
);
744 pOutl
->SetDefaultLanguage( meLanguage
);
746 mpOnlineSpellingList
.reset(new ShapeList
);
749 for ( nPage
= 0; nPage
< GetPageCount(); nPage
++ )
751 // Search in all pages
752 FillOnlineSpellingList(static_cast<SdPage
*>(GetPage(nPage
)));
755 for (nPage
= 0; nPage
< GetMasterPageCount(); nPage
++)
757 // Search all master pages
758 FillOnlineSpellingList(static_cast<SdPage
*>( GetMasterPage(nPage
) ));
761 mpOnlineSpellingList
->seekShape(0);
762 mpOnlineSpellingIdle
.reset(new Idle("OnlineSpelling"));
763 mpOnlineSpellingIdle
->SetInvokeHandler( LINK(this, SdDrawDocument
, OnlineSpellingHdl
) );
764 mpOnlineSpellingIdle
->SetPriority(TaskPriority::LOWEST
);
765 mpOnlineSpellingIdle
->Start();
768 // Fill OnlineSpelling list
769 void SdDrawDocument::FillOnlineSpellingList(SdPage
const * pPage
)
771 SdrObjListIter
aIter(pPage
, SdrIterMode::Flat
);
773 while (aIter
.IsMore())
775 SdrObject
* pObj
= aIter
.Next();
780 if (pObj
->GetOutlinerParaObject())
782 // Found a text object
783 mpOnlineSpellingList
->addShape(*pObj
);
785 else if (pObj
->GetObjIdentifier() == SdrObjKind::Group
)
787 // Found a group object
788 SdrObjListIter
aGroupIter(static_cast< SdrObjGroup
* >(pObj
)->GetSubList(), SdrIterMode::DeepNoGroups
);
790 bool bSubTextObjFound
= false;
792 while (aGroupIter
.IsMore() && !bSubTextObjFound
)
794 if (aGroupIter
.Next()->GetOutlinerParaObject())
796 // Found a text object in a group object
797 bSubTextObjFound
= true;
801 if (bSubTextObjFound
)
803 mpOnlineSpellingList
->addShape(*pObj
);
809 // OnlineSpelling in the background
810 IMPL_LINK_NOARG(SdDrawDocument
, OnlineSpellingHdl
, Timer
*, void)
812 if (mpOnlineSpellingList
!=nullptr
813 && ( !mbOnlineSpell
|| mpOnlineSpellingList
->hasMore()))
816 SdrObject
* pObj
= mpOnlineSpellingList
->getNextShape();
820 if (pObj
->GetOutlinerParaObject() && DynCastSdrTextObj( pObj
) != nullptr)
823 SpellObject(static_cast<SdrTextObj
*>(pObj
));
825 else if (pObj
->GetObjIdentifier() == SdrObjKind::Group
)
827 // Found a group object
828 SdrObjListIter
aGroupIter(static_cast< SdrObjGroup
* >(pObj
)->GetSubList(), SdrIterMode::DeepNoGroups
);
831 while (aGroupIter
.IsMore())
833 SdrObject
* pSubObj
= aGroupIter
.Next();
835 if (pSubObj
->GetOutlinerParaObject())
836 if (auto pTextObj
= DynCastSdrTextObj( pSubObj
))
837 // Found a text object in a group object
838 SpellObject(pTextObj
);
844 mpOnlineSpellingIdle
->Start();
848 // Initial spelling has finished
849 mbInitialOnlineSpellingEnabled
= false;
852 StopOnlineSpelling();
854 mpOnlineSearchItem
.reset();
858 // Spell object (for OnlineSpelling)
859 void SdDrawDocument::SpellObject(SdrTextObj
* pObj
)
861 if (!(pObj
&& pObj
->GetOutlinerParaObject()) /* && pObj != pView->GetTextEditObject() */)
864 mbHasOnlineSpellErrors
= false;
865 SdOutliner
* pOutl
= GetInternalOutliner();
866 pOutl
->SetUpdateLayout(true);
867 Link
<EditStatus
&,void> aEvtHdl
= pOutl
->GetStatusEventHdl();
868 pOutl
->SetStatusEventHdl(LINK(this, SdDrawDocument
, OnlineSpellEventHdl
));
870 OutlinerMode nOldOutlMode
= pOutl
->GetOutlinerMode();
871 OutlinerMode nOutlMode
= OutlinerMode::TextObject
;
872 if (pObj
->GetObjInventor() == SdrInventor::Default
&&
873 pObj
->GetObjIdentifier() == SdrObjKind::OutlineText
)
875 nOutlMode
= OutlinerMode::OutlineObject
;
877 pOutl
->Init( nOutlMode
);
879 // Put text into the outliner
880 pOutl
->SetText(*pObj
->GetOutlinerParaObject());
882 if (!mpOnlineSearchItem
|| pOutl
->HasText(*mpOnlineSearchItem
))
885 pOutl
->CompleteOnlineSpelling();
887 if (mbHasOnlineSpellErrors
)
889 std::optional
<OutlinerParaObject
> pOPO
= pOutl
->CreateParaObject();
892 if ( *pOPO
!= *pObj
->GetOutlinerParaObject() ||
893 !pObj
->GetOutlinerParaObject()->isWrongListEqual( *pOPO
))
895 sd::ModifyGuard
aGuard( this );
897 // taking text from the outliner
898 // use non-broadcasting version to avoid O(n^2)
899 pObj
->NbcSetOutlinerParaObject( std::move(pOPO
) );
905 pOutl
->SetStatusEventHdl(aEvtHdl
);
906 pOutl
->SetUpdateLayout(false);
907 pOutl
->Init( nOldOutlMode
);
908 mbHasOnlineSpellErrors
= false;
911 // Object was inserted into model
912 void SdDrawDocument::InsertObject(SdrObject
* pObj
)
914 if(mpOnlineSpellingList
&& pObj
)
916 if (pObj
->GetOutlinerParaObject() || (pObj
->GetObjIdentifier() == SdrObjKind::Group
))
918 // Add object to OnlineSpelling list
919 mpOnlineSpellingList
->addShape(*pObj
);
924 // Object removed from model
925 void SdDrawDocument::RemoveObject(SdrObject
* pObj
)
927 if(mpOnlineSpellingList
&& pObj
)
929 if (pObj
->GetOutlinerParaObject() || (pObj
->GetObjIdentifier() == SdrObjKind::Group
))
931 // Replace object in OnlineSpelling list by 0 pointer
932 mpOnlineSpellingList
->removeShape(*pObj
);
937 // Callback for ExecuteSpellPopup()
938 IMPL_LINK(SdDrawDocument
, OnlineSpellEventHdl
, EditStatus
&, rEditStat
, void)
940 EditStatusFlags nStat
= rEditStat
.GetStatusWord();
941 mbHasOnlineSpellErrors
= bool(nStat
& EditStatusFlags::WRONGWORDCHANGED
);
944 // Callback for ExecuteSpellPopup()
946 // removed link and replaced with Imp method
947 void SdDrawDocument::ImpOnlineSpellCallback(SpellCallbackInfo
const * pInfo
, SdrObject
* pObj
, SdrOutliner
const * pOutl
)
949 mpOnlineSearchItem
.reset();
951 SpellCallbackCommand nCommand
= pInfo
->nCommand
;
953 if (nCommand
== SpellCallbackCommand::IGNOREWORD
954 // restart when add to dictionary takes place, too.
955 || nCommand
== SpellCallbackCommand::ADDTODICTIONARY
)
958 if (auto pTextObj
= DynCastSdrTextObj( pObj
))
960 bool bModified(IsChanged());
961 pTextObj
->SetOutlinerParaObject(pOutl
->CreateParaObject());
962 SetChanged(bModified
);
963 pObj
->BroadcastObjectChange();
966 mpOnlineSearchItem
.reset(new SvxSearchItem( SID_SEARCH_ITEM
) );
967 mpOnlineSearchItem
->SetSearchString(pInfo
->aWord
);
968 StartOnlineSpelling();
970 else if (nCommand
== SpellCallbackCommand::STARTSPELLDLG
)
972 if (SfxViewFrame
* pViewFrame
= SfxViewFrame::Current())
973 pViewFrame
->GetDispatcher()->Execute( SID_SPELL_DIALOG
, SfxCallMode::ASYNCHRON
);
975 else if (nCommand
== SpellCallbackCommand::AUTOCORRECT_OPTIONS
)
977 if (SfxViewFrame
* pViewFrame
= SfxViewFrame::Current())
978 pViewFrame
->GetDispatcher()->Execute( SID_AUTO_CORRECT_DLG
, SfxCallMode::ASYNCHRON
);
982 // Return formatted page number (1, I, i, a, etc.)
983 OUString
SdDrawDocument::CreatePageNumValue(sal_uInt16 nNum
) const
985 OUString aPageNumValue
;
988 switch (mePageNumType
)
990 case css::style::NumberingType::CHARS_UPPER_LETTER
:
991 aPageNumValue
+= OUStringChar( sal_Unicode((nNum
- 1) % 26 + 'A') );
993 case css::style::NumberingType::CHARS_LOWER_LETTER
:
994 aPageNumValue
+= OUStringChar( sal_Unicode((nNum
- 1) % 26 + 'a') );
996 case css::style::NumberingType::ROMAN_UPPER
:
999 case css::style::NumberingType::ROMAN_LOWER
:
1000 aPageNumValue
+= SvxNumberFormat::CreateRomanString(nNum
, bUpper
);
1002 case css::style::NumberingType::NUMBER_NONE
:
1003 aPageNumValue
= " ";
1006 aPageNumValue
+= OUString::number(nNum
);
1009 return aPageNumValue
;
1012 // Rename layout template
1013 // Keep in mind that rOldLayoutName contains the _complete_ name of the layout
1014 // (including ~LT~). This is unlike rNewName.
1015 void SdDrawDocument::RenameLayoutTemplate(const OUString
& rOldLayoutName
, const OUString
& rNewName
)
1017 OUString
aOldName(rOldLayoutName
);
1018 sal_Int32 nPos
= aOldName
.indexOf( SD_LT_SEPARATOR
);
1020 // erase everything after '~LT~'
1022 aOldName
= aOldName
.copy(0, nPos
+ SD_LT_SEPARATOR
.getLength());
1024 std::vector
<StyleReplaceData
> aReplList
;
1025 SfxStyleSheetIterator
aIter(mxStyleSheetPool
.get(), SfxStyleFamily::Page
);
1026 SfxStyleSheetBase
* pSheet
= aIter
.First();
1030 OUString aSheetName
= pSheet
->GetName();
1032 // if the sheetname starts with aOldName + "~LT~"
1033 if (aSheetName
.startsWith(aOldName
))
1035 aSheetName
= aSheetName
.replaceAt(0, aOldName
.getLength() - SD_LT_SEPARATOR
.getLength(), rNewName
);
1037 StyleReplaceData aReplData
;
1038 aReplData
.nFamily
= pSheet
->GetFamily();
1039 aReplData
.nNewFamily
= pSheet
->GetFamily();
1040 aReplData
.aName
= pSheet
->GetName();
1041 aReplData
.aNewName
= aSheetName
;
1042 aReplList
.push_back(aReplData
);
1044 pSheet
->SetName(aSheetName
, /*bReindexNow*/false);
1047 pSheet
= aIter
.Next();
1049 mxStyleSheetPool
->Reindex();
1051 // Now set the layout name of the drawing and the notes page, as well as
1052 // their master pages.
1053 OUString aPageLayoutName
= rNewName
+ SD_LT_SEPARATOR
+ STR_LAYOUT_OUTLINE
;
1055 // Inform all text objects on pages that use the renamed layout and set the
1058 for (nPage
= 0; nPage
< GetPageCount(); nPage
++)
1060 SdPage
* pPage
= static_cast<SdPage
*>(GetPage(nPage
));
1061 OUString
aTemp(pPage
->GetLayoutName());
1063 if (aTemp
== rOldLayoutName
)
1065 pPage
->SetLayoutName(aPageLayoutName
);
1067 for (const rtl::Reference
<SdrObject
>& pObj
: *pPage
)
1069 if (pObj
->GetObjInventor() == SdrInventor::Default
)
1071 switch( pObj
->GetObjIdentifier() )
1073 case SdrObjKind::Text
:
1074 case SdrObjKind::OutlineText
:
1075 case SdrObjKind::TitleText
:
1077 OutlinerParaObject
* pOPO
= static_cast<SdrTextObj
*>(pObj
.get())->GetOutlinerParaObject();
1081 for (const auto& rRepl
: aReplList
)
1082 pOPO
->ChangeStyleSheets( rRepl
.aName
, rRepl
.nFamily
, rRepl
.aNewName
, rRepl
.nNewFamily
);
1095 // Now do this again for all master pages.
1096 // The affected master pages get the name of the layout as their page name.
1097 for (nPage
= 0; nPage
< GetMasterPageCount(); nPage
++)
1099 SdPage
* pPage
= static_cast<SdPage
*>( GetMasterPage(nPage
) );
1100 OUString
aTemp(pPage
->GetLayoutName());
1102 if (aTemp
== rOldLayoutName
)
1104 pPage
->SetLayoutName(aPageLayoutName
);
1105 pPage
->SetName(rNewName
);
1107 for (const rtl::Reference
<SdrObject
>& pObj
: *pPage
)
1109 if (pObj
->GetObjInventor() == SdrInventor::Default
)
1111 switch(pObj
->GetObjIdentifier())
1113 case SdrObjKind::Text
:
1114 case SdrObjKind::OutlineText
:
1115 case SdrObjKind::TitleText
:
1117 OutlinerParaObject
* pOPO
= static_cast<SdrTextObj
*>(pObj
.get())->GetOutlinerParaObject();
1121 for (const auto& rRepl
: aReplList
)
1122 pOPO
->ChangeStyleSheets( rRepl
.aName
, rRepl
.nFamily
, rRepl
.aNewName
, rRepl
.nNewFamily
);
1136 // Set outliner defaults (pool defaults)
1137 void SdDrawDocument::SetTextDefaults() const
1139 // BulletItem and BulletFont for Title and Outline
1140 SvxBulletItem
aBulletItem(EE_PARA_BULLET
);
1141 vcl::Font
aBulletFont( SdStyleSheetPool::GetBulletFont() );
1142 aBulletFont
.SetFontSize(Size(0,846)); // 24 pt
1143 aBulletItem
.SetFont(aBulletFont
);
1144 aBulletItem
.SetStyle(SvxBulletStyle::BULLET
);
1145 aBulletItem
.SetStart(1);
1146 aBulletItem
.SetScale(45); // In percent
1147 aBulletItem
.SetSymbol( 0x25CF ); // In points
1148 m_pItemPool
->SetUserDefaultItem( aBulletItem
);
1151 SvxNumberFormat
aNumberFormat(SVX_NUM_CHAR_SPECIAL
);
1152 aNumberFormat
.SetBulletFont(&aBulletFont
);
1153 aNumberFormat
.SetBulletChar( 0x25CF ); // StarBats: 0xF000 + 34
1154 aNumberFormat
.SetBulletRelSize(45);
1155 aNumberFormat
.SetBulletColor(COL_AUTO
);
1156 aNumberFormat
.SetStart(1);
1157 aNumberFormat
.SetNumAdjust(SvxAdjust::Left
);
1159 SvxNumRule
aNumRule( SvxNumRuleFlags::BULLET_REL_SIZE
| SvxNumRuleFlags::BULLET_COLOR
, SVX_MAX_NUM
, false);
1161 //aNumberFormat.SetAbsLSpace( 0 );
1162 //aNumberFormat.SetFirstLineOffset( 0 );
1163 //aNumRule.SetLevel( 0, aNumberFormat );
1165 for( sal_uInt16 i
= 0; i
< aNumRule
.GetLevelCount(); i
++ )
1167 const auto nLSpace
= (i
+ 1) * 600;
1168 aNumberFormat
.SetAbsLSpace(nLSpace
);
1169 aNumberFormat
.SetFirstLineOffset(-600);
1170 aNumRule
.SetLevel( i
, aNumberFormat
);
1173 SvxNumBulletItem
aNumBulletItem( std::move(aNumRule
), EE_PARA_NUMBULLET
);
1174 m_pItemPool
->SetUserDefaultItem( aNumBulletItem
);
1177 css::text::WritingMode
SdDrawDocument::GetDefaultWritingMode() const
1179 const SfxPoolItem
* pItem
= ( m_pItemPool
? m_pItemPool
->GetUserDefaultItem( EE_PARA_WRITINGDIR
) : nullptr );
1180 css::text::WritingMode eRet
= css::text::WritingMode_LR_TB
;
1184 switch( static_cast<const SvxFrameDirectionItem
&>( *pItem
).GetValue() )
1186 case SvxFrameDirection::Horizontal_LR_TB
: eRet
= css::text::WritingMode_LR_TB
; break;
1187 case SvxFrameDirection::Horizontal_RL_TB
: eRet
= css::text::WritingMode_RL_TB
; break;
1188 case SvxFrameDirection::Vertical_RL_TB
: eRet
= css::text::WritingMode_TB_RL
; break;
1191 OSL_FAIL( "Frame direction not supported yet" );
1199 void SdDrawDocument::SetDefaultWritingMode(css::text::WritingMode eMode
)
1204 SvxFrameDirection nVal
;
1207 case css::text::WritingMode_LR_TB
: nVal
= SvxFrameDirection::Horizontal_LR_TB
; break;
1208 case css::text::WritingMode_RL_TB
: nVal
= SvxFrameDirection::Horizontal_RL_TB
; break;
1209 case css::text::WritingMode_TB_RL
: nVal
= SvxFrameDirection::Vertical_RL_TB
; break;
1211 OSL_FAIL( "Frame direction not supported yet" );
1215 SvxFrameDirectionItem
aModeItem( nVal
, EE_PARA_WRITINGDIR
);
1216 m_pItemPool
->SetUserDefaultItem( aModeItem
);
1218 SvxAdjustItem
aAdjust( SvxAdjust::Left
, EE_PARA_JUST
);
1220 if( eMode
== css::text::WritingMode_RL_TB
)
1221 aAdjust
.SetAdjust( SvxAdjust::Right
);
1223 m_pItemPool
->SetUserDefaultItem( aAdjust
);
1226 void SdDrawDocument::getDefaultFonts( vcl::Font
& rLatinFont
, vcl::Font
& rCJKFont
, vcl::Font
& rCTLFont
)
1228 LanguageType eLatin
= GetLanguage( EE_CHAR_LANGUAGE
);
1230 // If the UI language is Korean, the default Latin font has to
1231 // be queried for Korean, too (the Latin language from the document can't be Korean).
1232 // This is the same logic as in SwDocShell::InitNew.
1233 LanguageType eUiLanguage
= Application::GetSettings().GetUILanguageTag().getLanguageType();
1234 if (MsLangId::isKorean(eUiLanguage
))
1235 eLatin
= eUiLanguage
;
1237 rLatinFont
= OutputDevice::GetDefaultFont( DefaultFontType::LATIN_PRESENTATION
, eLatin
, GetDefaultFontFlags::OnlyOne
);
1238 rCJKFont
= OutputDevice::GetDefaultFont( DefaultFontType::CJK_PRESENTATION
, GetLanguage( EE_CHAR_LANGUAGE_CJK
), GetDefaultFontFlags::OnlyOne
);
1239 rCTLFont
= OutputDevice::GetDefaultFont( DefaultFontType::CTL_PRESENTATION
, GetLanguage( EE_CHAR_LANGUAGE_CTL
), GetDefaultFontFlags::OnlyOne
) ;
1242 /* converts the given western font height to a corresponding ctl font height, depending on the system language */
1243 sal_uInt32
SdDrawDocument::convertFontHeightToCTL( sal_uInt32 nWesternFontHeight
)
1245 LanguageType eRealCTLLanguage
= Application::GetSettings().GetLanguageTag().getLanguageType();
1246 if( LANGUAGE_THAI
== eRealCTLLanguage
)
1248 // http://specs.openoffice.org/g11n/font_sizes/42775_42725_Individual_configurable_font_size_for_default_fonts.odt
1249 double fTemp
= double(nWesternFontHeight
) * 1.333;
1250 nWesternFontHeight
= static_cast<sal_uInt32
>(fTemp
);
1251 // make some nice values for UI that displays PT instead of 1/100th mm
1252 nWesternFontHeight
= convertPointToMm100(convertMm100ToPoint(nWesternFontHeight
));
1254 return nWesternFontHeight
;
1257 SdStyleSheetPool
* SdDrawDocument::GetSdStyleSheetPool() const
1259 return dynamic_cast< SdStyleSheetPool
* >( GetStyleSheetPool() );
1262 ModifyGuard::ModifyGuard( SdDrawDocument
* pDoc
)
1263 : mpDocShell( nullptr ), mpDoc( pDoc
)
1268 void ModifyGuard::init()
1272 mpDoc
= mpDocShell
->GetDoc();
1276 mpDocShell
= mpDoc
->GetDocSh();
1279 mbIsEnableSetModified
= mpDocShell
&& mpDocShell
->IsEnableSetModified();
1280 mbIsDocumentChanged
= mpDoc
&& mpDoc
->IsChanged();
1282 if( mbIsEnableSetModified
)
1283 mpDocShell
->EnableSetModified( false );
1286 ModifyGuard::~ModifyGuard()
1288 if( mbIsEnableSetModified
)
1289 mpDocShell
->EnableSetModified();
1291 if( mpDoc
&& (mpDoc
->IsChanged() != mbIsDocumentChanged
) )
1292 mpDoc
->SetChanged(mbIsDocumentChanged
);
1295 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */