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 <unotools/configmgr.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::container
;
129 using namespace ::com::sun::star::linguistic2
;
130 using namespace ::sd
;
132 // CreateLayoutTemplates
133 // At the moment (31.03.1995), the StyleSheetPool only saves styleheets that
134 // have an ItemSet. To save all stylesheets, we force the creation of an ItemSet
135 // with a GetItemSet call.
136 // We can remove this behavior once the pool saves styleheets even without an ItemSet
137 void SdDrawDocument::CreateLayoutTemplates()
139 SdStyleSheetPool
* pSSPool
= static_cast<SdStyleSheetPool
*>(GetStyleSheetPool());
140 SfxStyleSheetBase
* pSheet
= nullptr;
141 const OUString aHelpFile
;
142 OUString
aStdName(SdResId(STR_STANDARD_STYLESHEET_NAME
));
146 SfxStyleSearchBits nMask
= SfxStyleSearchBits::Auto
;
148 OUString
aName(aStdName
);
149 pSheet
= &(pSSPool
->Make(aName
, SfxStyleFamily::Para
, nMask
));
150 pSheet
->SetHelpId( aHelpFile
, HID_STANDARD_STYLESHEET_NAME
);
151 SfxItemSet
& rISet
= pSheet
->GetItemSet();
153 ::basegfx::B2DPolyPolygon aNullPolyPolygon
;
154 Color
aNullCol(COL_DEFAULT_SHAPE_STROKE
);
157 basegfx::BGradient
aNullGrad(
158 basegfx::BColorStops(
159 aNullCol
.getBColor(),
160 COL_WHITE
.getBColor()));
161 aNullGrad
.SetStartIntens( 100 );
162 aNullGrad
.SetEndIntens( 100 );
163 XHatch
aNullHatch(aNullCol
);
165 // Line attributes (Extended OutputDevice)
166 rISet
.Put(XLineStyleItem(drawing::LineStyle_SOLID
));
167 rISet
.Put(XLineColorItem(OUString(), COL_DEFAULT_SHAPE_STROKE
));
168 rISet
.Put(XLineWidthItem(0));
169 rISet
.Put(XLineDashItem(aNullDash
));
170 rISet
.Put(XLineStartItem(aNullPolyPolygon
));
171 rISet
.Put(XLineEndItem(aNullPolyPolygon
));
172 rISet
.Put(XLineStartWidthItem(200));
173 rISet
.Put(XLineEndWidthItem(200));
174 rISet
.Put(XLineStartCenterItem());
175 rISet
.Put(XLineEndCenterItem());
176 rISet
.Put(SdrTextHorzAdjustItem(SDRTEXTHORZADJUST_BLOCK
));
178 // Fill attributes (Extended OutputDevice)
179 rISet
.Put(XFillStyleItem(drawing::FillStyle_SOLID
));
180 rISet
.Put(XFillColorItem(OUString(), COL_DEFAULT_SHAPE_FILLING
));
182 rISet
.Put( XFillGradientItem( aNullGrad
) );
183 rISet
.Put(XFillHatchItem(aNullHatch
));
184 Size
aNullSize( 32, 32 );
185 Bitmap
aNullBmp(aNullSize
, vcl::PixelFormat::N8_BPP
);
186 aNullBmp
.Erase( COL_WHITE
);
187 rISet
.Put(XFillBitmapItem(Graphic(BitmapEx(aNullBmp
))));
189 // Shadow attributes (Drawing Engine)
190 rISet
.Put(makeSdrShadowItem(false));
191 rISet
.Put(makeSdrShadowColorItem(COL_GRAY
));
192 rISet
.Put(makeSdrShadowXDistItem(200)); // 3 mm Shadow distance
193 rISet
.Put(makeSdrShadowYDistItem(200));
195 vcl::Font aLatinFont
, aCJKFont
, aCTLFont
;
197 getDefaultFonts( aLatinFont
, aCJKFont
, aCTLFont
);
199 SvxFontItem
aSvxFontItem( aLatinFont
.GetFamilyType(), aLatinFont
.GetFamilyName(), aLatinFont
.GetStyleName(), aLatinFont
.GetPitch(),
200 aLatinFont
.GetCharSet(), EE_CHAR_FONTINFO
);
202 SvxFontItem
aSvxFontItemCJK( aCJKFont
.GetFamilyType(), aCJKFont
.GetFamilyName(), aCJKFont
.GetStyleName(), aCJKFont
.GetPitch(),
203 aCJKFont
.GetCharSet(), EE_CHAR_FONTINFO_CJK
);
205 SvxFontItem
aSvxFontItemCTL( aCTLFont
.GetFamilyType(), aCTLFont
.GetFamilyName(), aCTLFont
.GetStyleName(), aCTLFont
.GetPitch(),
206 aCTLFont
.GetCharSet(), EE_CHAR_FONTINFO_CTL
);
208 rISet
.Put( aSvxFontItem
);
209 rISet
.Put( aSvxFontItemCJK
);
210 rISet
.Put( aSvxFontItemCTL
);
212 rISet
.Put( SvxFontHeightItem( 635, 100, EE_CHAR_FONTHEIGHT
) ); // sj: (i33745) changed default from 24 to 18 pt
213 rISet
.Put( SvxFontHeightItem( 635, 100, EE_CHAR_FONTHEIGHT_CJK
) ); // 18 pt
214 rISet
.Put( SvxFontHeightItem( convertFontHeightToCTL( 635 ), 100, EE_CHAR_FONTHEIGHT_CTL
) ); // 18 pt
216 rISet
.Put( SvxWeightItem( WEIGHT_NORMAL
, EE_CHAR_WEIGHT
) );
217 rISet
.Put( SvxWeightItem( WEIGHT_NORMAL
, EE_CHAR_WEIGHT_CJK
) );
218 rISet
.Put( SvxWeightItem( WEIGHT_NORMAL
, EE_CHAR_WEIGHT_CTL
) );
220 rISet
.Put( SvxPostureItem( ITALIC_NONE
, EE_CHAR_ITALIC
) );
221 rISet
.Put( SvxPostureItem( ITALIC_NONE
, EE_CHAR_ITALIC_CJK
) );
222 rISet
.Put( SvxPostureItem( ITALIC_NONE
, EE_CHAR_ITALIC_CTL
) );
224 rISet
.Put(SvxContourItem(false, EE_CHAR_OUTLINE
));
225 rISet
.Put(SvxShadowedItem(false, EE_CHAR_SHADOW
));
226 rISet
.Put(SvxUnderlineItem(LINESTYLE_NONE
, EE_CHAR_UNDERLINE
));
227 rISet
.Put(SvxOverlineItem(LINESTYLE_NONE
, EE_CHAR_OVERLINE
));
228 rISet
.Put(SvxCrossedOutItem(STRIKEOUT_NONE
, EE_CHAR_STRIKEOUT
));
229 rISet
.Put(SvxCaseMapItem(SvxCaseMap::NotMapped
, EE_CHAR_CASEMAP
));
230 rISet
.Put(SvxEmphasisMarkItem(FontEmphasisMark::NONE
, EE_CHAR_EMPHASISMARK
));
231 rISet
.Put(SvxCharReliefItem(FontRelief::NONE
, EE_CHAR_RELIEF
));
232 rISet
.Put(SvxColorItem(COL_AUTO
, EE_CHAR_COLOR
));
234 // Paragraph attributes (Edit Engine)
235 rISet
.Put(SvxLRSpaceItem(EE_PARA_LRSPACE
));
236 rISet
.Put(SvxULSpaceItem(EE_PARA_ULSPACE
));
238 rISet
.Put( makeSdrTextLeftDistItem( 250 ) ); // sj: (i33745) using text frame distances seems to be a better default
239 rISet
.Put( makeSdrTextRightDistItem( 250 ) );
240 rISet
.Put( makeSdrTextUpperDistItem( 125 ) );
241 rISet
.Put( makeSdrTextLowerDistItem( 125 ) );
243 // Set Word-wrap to true by default
244 rISet
.Put( makeSdrTextWordWrapItem(true) );
246 rISet
.Put( SvxLineSpacingItem( LINE_SPACE_DEFAULT_HEIGHT
, EE_PARA_SBL
) );
248 // #i16874# enable kerning by default but only for new documents
249 rISet
.Put( SvxAutoKernItem( true, EE_CHAR_PAIRKERNING
) );
252 // BulletItem and BulletFont for title and outline
253 SvxBulletItem
aBulletItem(EE_PARA_BULLET
);
254 // Identical in all layers
255 aBulletItem
.SetStyle(SvxBulletStyle::BULLET
);
256 aBulletItem
.SetStart(1);
257 aBulletItem
.SetScale(45); // In percent
259 vcl::Font
aBulletFont( SdStyleSheetPool::GetBulletFont() );
261 aBulletFont
.SetFontSize(Size(0,635)); // sj: (i33745) changed default from 24 to 18 pt
263 aBulletItem
.SetFont(aBulletFont
);
264 aBulletItem
.SetSymbol( 0x25CF ); // In points
265 rISet
.Put(aBulletItem
);
268 SdStyleSheetPool::PutNumBulletItem( pSheet
, aBulletFont
);
270 SfxItemSet
* pISet
= nullptr;
272 // Default > Object without filling
274 aName
= SdResId(STR_POOLSHEET_OBJWITHOUTFILL
);
275 pSheet
= &(pSSPool
->Make(aName
, SfxStyleFamily::Para
, nMask
));
276 pSheet
->SetParent(aStdName
);
277 pSheet
->SetHelpId( aHelpFile
, HID_POOLSHEET_OBJWITHOUTFILL
);
278 pISet
= &pSheet
->GetItemSet();
280 pISet
->Put(XFillStyleItem(drawing::FillStyle_NONE
));
282 // Default > Object no fill no line
284 aName
= SdResId(STR_POOLSHEET_OBJNOLINENOFILL
);
285 pSheet
= &(pSSPool
->Make(aName
, SfxStyleFamily::Para
, nMask
));
286 pSheet
->SetParent(aStdName
);
287 pSheet
->SetHelpId( aHelpFile
, HID_POOLSHEET_OBJNOLINENOFILL
);
288 pISet
= &pSheet
->GetItemSet();
290 pISet
->Put(XFillStyleItem(drawing::FillStyle_NONE
));
291 pISet
->Put(XLineStyleItem(drawing::LineStyle_NONE
));
299 aTextName
= SdResId(STR_POOLSHEET_TEXT
);
300 pSheet
= &(pSSPool
->Make(aTextName
, SfxStyleFamily::Para
, nMask
));
301 pSheet
->SetHelpId( aHelpFile
, HID_POOLSHEET_TEXT
);
302 pISet
= &pSheet
->GetItemSet();
303 aSvxFontItem
.SetFamilyName("Noto Sans");
304 pISet
->Put( aSvxFontItem
); // Noto Sans
305 pISet
->Put(XFillStyleItem(drawing::FillStyle_SOLID
)); // solid fill
306 pISet
->Put(XFillColorItem(OUString(), Color(0xeeeeee))); // light gray 5
307 pISet
->Put(XLineStyleItem(drawing::LineStyle_SOLID
)); // solid fill
308 pISet
->Put(XLineColorItem(OUString(), Color(0xcccccc))); // light gray 3
313 aA4Name
= SdResId(STR_POOLSHEET_A4
);
314 pSheet
= &(pSSPool
->Make(aA4Name
, SfxStyleFamily::Para
, nMask
));
315 pSheet
->SetParent( aTextName
);
316 pSheet
->SetHelpId( aHelpFile
, HID_POOLSHEET_A4
);
317 pISet
= &pSheet
->GetItemSet();
318 pISet
->Put(SvxFontHeightItem(635, 100, EE_CHAR_FONTHEIGHT
)); // 18 pt
319 pISet
->Put(XFillStyleItem(drawing::FillStyle_NONE
)); // no filling
324 aName
= SdResId(STR_POOLSHEET_A4_TITLE
);
325 pSheet
= &(pSSPool
->Make(aName
, SfxStyleFamily::Para
, nMask
));
326 pSheet
->SetParent( aA4Name
);
327 pSheet
->SetHelpId( aHelpFile
, HID_POOLSHEET_A4_TITLE
);
328 pISet
= &pSheet
->GetItemSet();
329 pISet
->Put(SvxFontHeightItem(1551, 100, EE_CHAR_FONTHEIGHT
)); // 44 pt
330 pISet
->Put(XLineStyleItem(drawing::LineStyle_NONE
)); // no border
332 // Text > A4 > Headline
334 aName
= SdResId(STR_POOLSHEET_A4_HEADLINE
);
335 pSheet
= &(pSSPool
->Make(aName
, SfxStyleFamily::Para
, nMask
));
336 pSheet
->SetParent( aA4Name
);
337 pSheet
->SetHelpId( aHelpFile
, HID_POOLSHEET_A4_HEADLINE
);
338 pISet
= &pSheet
->GetItemSet();
339 pISet
->Put(SvxFontHeightItem(847, 100, EE_CHAR_FONTHEIGHT
)); // 24 pt
340 pISet
->Put(XLineStyleItem(drawing::LineStyle_NONE
)); // no border
344 aName
= SdResId(STR_POOLSHEET_A4_TEXT
);
345 pSheet
= &(pSSPool
->Make(aName
, SfxStyleFamily::Para
, nMask
));
346 pSheet
->SetParent(aA4Name
);
347 pSheet
->SetHelpId( aHelpFile
, HID_POOLSHEET_A4_TEXT
);
348 pISet
= &pSheet
->GetItemSet();
349 pISet
->Put(XLineStyleItem(drawing::LineStyle_NONE
)); // no border
354 aA0Name
= SdResId(STR_POOLSHEET_A0
);
355 pSheet
= &(pSSPool
->Make(aA0Name
, SfxStyleFamily::Para
, nMask
));
356 pSheet
->SetParent(aTextName
);
357 pSheet
->SetHelpId( aHelpFile
, HID_POOLSHEET_A0
);
358 pISet
= &pSheet
->GetItemSet();
359 pISet
->Put(SvxFontHeightItem(1692, 100, EE_CHAR_FONTHEIGHT
)); // 48 pt
360 pISet
->Put(XFillStyleItem(drawing::FillStyle_NONE
)); // no filling
364 aName
= SdResId(STR_POOLSHEET_A0_TITLE
);
365 pSheet
= &(pSSPool
->Make(aName
, SfxStyleFamily::Para
, nMask
));
366 pSheet
->SetParent(aA0Name
);
367 pSheet
->SetHelpId( aHelpFile
, HID_POOLSHEET_A0_TITLE
);
368 pISet
= &pSheet
->GetItemSet();
369 pISet
->Put(SvxFontHeightItem(3385, 100, EE_CHAR_FONTHEIGHT
)); // 96 pt
370 pISet
->Put(XLineStyleItem(drawing::LineStyle_NONE
)); // no border
372 // Text > A0 > Headline
374 aName
= SdResId(STR_POOLSHEET_A0_HEADLINE
);
375 pSheet
= &(pSSPool
->Make(aName
, SfxStyleFamily::Para
, nMask
));
376 pSheet
->SetParent(aA0Name
);
377 pSheet
->SetHelpId( aHelpFile
, HID_POOLSHEET_A0_HEADLINE
);
378 pISet
= &pSheet
->GetItemSet();
379 pISet
->Put(SvxFontHeightItem(2538, 100, EE_CHAR_FONTHEIGHT
)); // 72 pt
380 pISet
->Put(XLineStyleItem(drawing::LineStyle_NONE
)); // no border
384 aName
= SdResId(STR_POOLSHEET_A0_TEXT
);
385 pSheet
= &(pSSPool
->Make(aName
, SfxStyleFamily::Para
, nMask
));
386 pSheet
->SetParent(aA0Name
);
387 pSheet
->SetHelpId( aHelpFile
, HID_POOLSHEET_A0_TEXT
);
388 pISet
= &pSheet
->GetItemSet();
389 pISet
->Put(XLineStyleItem(drawing::LineStyle_NONE
)); // no border
393 OUString aGraphicName
;
394 XFillGradientItem aFillGradient
;
395 basegfx::BGradient aGradient
;
398 aGraphicName
= SdResId(STR_POOLSHEET_GRAPHIC
);
399 pSheet
= &(pSSPool
->Make(aGraphicName
, SfxStyleFamily::Para
, nMask
));
400 pSheet
->SetHelpId( aHelpFile
, HID_POOLSHEET_GRAPHIC
);
401 pISet
= &pSheet
->GetItemSet();
402 aSvxFontItem
.SetFamilyName("Liberation Sans"); // Liberation Sans
403 pISet
->Put( aSvxFontItem
);
404 pISet
->Put( SvxFontHeightItem(635, 100, EE_CHAR_FONTHEIGHT
) ); // 18 pt
405 pISet
->Put( XFillStyleItem(drawing::FillStyle_SOLID
) ); // solid fill
406 pISet
->Put( XFillColorItem(OUString(), COL_WHITE
) ); // filled white
410 OUString aShapesName
;
412 aShapesName
= SdResId(STR_POOLSHEET_SHAPES
);
413 pSheet
= &(pSSPool
->Make(aShapesName
, SfxStyleFamily::Para
, nMask
));
414 pSheet
->SetParent( aGraphicName
);
415 pSheet
->SetHelpId( aHelpFile
, HID_POOLSHEET_SHAPES
);
416 pISet
= &pSheet
->GetItemSet();
417 pISet
->Put(XFillStyleItem(drawing::FillStyle_GRADIENT
)); // fill with gradient
418 aGradient
.SetGradientStyle( ::awt::GradientStyle_RECT
); // square type
419 aGradient
.SetAngle( 0_deg10
); // 0° angle
421 aGradient
.SetColorStops(
422 basegfx::BColorStops(
423 Color(0xcccccc).getBColor(), // light gray 3
424 COL_WHITE
.getBColor())); // white
426 aFillGradient
.SetName( aShapesName
);
427 aFillGradient
.SetGradientValue(aGradient
);
428 pISet
->Put( aFillGradient
);
429 pISet
->Put( XLineStyleItem(drawing::LineStyle_NONE
) ); // no border
430 pISet
->Put( SvxFontHeightItem(494, 100, EE_CHAR_FONTHEIGHT
) ); // 14 pt
431 pISet
->Put( SvxWeightItem(WEIGHT_BOLD
, EE_CHAR_WEIGHT
) ); // bold
433 // Graphic > Shapes > Filled
434 OUString
aFilledName(SdResId(STR_POOLSHEET_FILLED
));
437 pSheet
= &(pSSPool
->Make(aName
, SfxStyleFamily::Para
, nMask
));
438 pSheet
->SetHelpId( aHelpFile
, HID_POOLSHEET_FILLED
);
439 pSheet
->SetParent( aShapesName
);
440 pISet
= &pSheet
->GetItemSet();
442 aGradient
.SetGradientStyle( ::awt::GradientStyle_LINEAR
);
443 aGradient
.SetAngle( 300_deg10
);
445 aGradient
.SetColorStops(
446 basegfx::BColorStops(
447 COL_WHITE
.getBColor(), // white
448 Color(0xcccccc).getBColor())); // light gray 3
450 aFillGradient
.SetName( aName
);
451 aFillGradient
.SetGradientValue(aGradient
);
452 pISet
->Put( XFillStyleItem(drawing::FillStyle_GRADIENT
) );
453 pISet
->Put( aFillGradient
);
455 // Graphic > Shapes > Filled > Blue
457 aName
=SdResId(STR_POOLSHEET_FILLED_BLUE
);
458 pSheet
= &(pSSPool
->Make(aName
, SfxStyleFamily::Para
, nMask
));
459 pSheet
->SetParent(aFilledName
);
460 pSheet
->SetHelpId( aHelpFile
, HID_POOLSHEET_FILLED_BLUE
);
461 pISet
= &pSheet
->GetItemSet();
463 aGradient
.SetColorStops(
464 basegfx::BColorStops(
465 Color(0x00729fcf).getBColor(), // light blue 2
466 Color(0x00355269).getBColor())); // dark blue 2
468 aFillGradient
.SetName( aName
);
469 aFillGradient
.SetGradientValue(aGradient
);
470 pISet
->Put( aFillGradient
);
471 pISet
->Put( SvxColorItem(COL_WHITE
, EE_CHAR_COLOR
)); // font white
473 // Graphic > Shapes > Filled > Green
475 aName
=SdResId(STR_POOLSHEET_FILLED_GREEN
);
476 pSheet
= &(pSSPool
->Make(aName
, SfxStyleFamily::Para
, nMask
));
477 pSheet
->SetParent(aFilledName
);
478 pSheet
->SetHelpId( aHelpFile
, HID_POOLSHEET_FILLED_GREEN
);
479 pISet
= &pSheet
->GetItemSet();
481 aGradient
.SetColorStops(
482 basegfx::BColorStops(
483 Color(0x0077bc65).getBColor(), // light green 2
484 Color(0x00127622).getBColor())); // dark green 2
486 aFillGradient
.SetName( aName
);
487 aFillGradient
.SetGradientValue(aGradient
);
488 pISet
->Put( aFillGradient
);
489 pISet
->Put( aSvxFontItem
); // font name
490 pISet
->Put( SvxColorItem(COL_WHITE
, EE_CHAR_COLOR
)); // font white
492 // Graphic > Shapes > Filled > Red
494 aName
=SdResId(STR_POOLSHEET_FILLED_RED
);
495 pSheet
= &(pSSPool
->Make(aName
, SfxStyleFamily::Para
, nMask
));
496 pSheet
->SetParent(aFilledName
);
497 pSheet
->SetHelpId( aHelpFile
, HID_POOLSHEET_FILLED_RED
);
498 pISet
= &pSheet
->GetItemSet();
500 aGradient
.SetColorStops(
501 basegfx::BColorStops(
502 Color(0x00ff6d6d).getBColor(), // light red 2
503 Color(0x00c9211e).getBColor())); // dark red 2
505 aFillGradient
.SetName( aName
);
506 aFillGradient
.SetGradientValue(aGradient
);
507 pISet
->Put( aFillGradient
);
508 pISet
->Put( SvxColorItem(COL_WHITE
, EE_CHAR_COLOR
)); // font white
510 // Graphic > Shapes > Filled > Yellow
512 aName
=SdResId(STR_POOLSHEET_FILLED_YELLOW
);
513 pSheet
= &(pSSPool
->Make(aName
, SfxStyleFamily::Para
, nMask
));
514 pSheet
->SetParent(aFilledName
);
515 pSheet
->SetHelpId( aHelpFile
, HID_POOLSHEET_FILLED_YELLOW
);
516 pISet
= &pSheet
->GetItemSet();
518 aGradient
.SetColorStops(
519 basegfx::BColorStops(
520 Color(0x00ffde59).getBColor(), // light gold 2
521 Color(0x00b47804).getBColor())); // dark gold 2
523 aFillGradient
.SetName( aName
);
524 aFillGradient
.SetGradientValue(aGradient
);
525 pISet
->Put( aFillGradient
);
526 pISet
->Put( SvxColorItem(COL_WHITE
, EE_CHAR_COLOR
)); // font white
528 // Graphic > Shapes > Outlines
529 OUString
aOutlineName(SdResId(STR_POOLSHEET_OUTLINE
));
531 aName
= aOutlineName
;
532 pSheet
= &(pSSPool
->Make(aName
, SfxStyleFamily::Para
, nMask
));
533 pSheet
->SetHelpId( aHelpFile
, HID_POOLSHEET_OUTLINE
);
534 pSheet
->SetParent( aShapesName
);
535 pISet
= &pSheet
->GetItemSet();
536 pISet
->Put( XFillStyleItem(drawing::FillStyle_NONE
) ); // clear
537 pISet
->Put( XLineStyleItem(drawing::LineStyle_SOLID
) ); // solide line
538 pISet
->Put( XLineWidthItem(81) ); // 2.3 pt
539 pISet
->Put( XLineColorItem(OUString(), COL_BLACK
) ); // b/w
541 // Graphic > Shapes > Outlines > Blue
543 aName
=SdResId(STR_POOLSHEET_OUTLINE_BLUE
);
544 pSheet
= &(pSSPool
->Make(aName
, SfxStyleFamily::Para
, nMask
));
545 pSheet
->SetParent(aOutlineName
);
546 pSheet
->SetHelpId( aHelpFile
, HID_POOLSHEET_OUTLINE_BLUE
);
547 pISet
= &pSheet
->GetItemSet();
548 pISet
->Put( XLineColorItem(OUString(), Color(0x00355269)) ); // dark blue 2
549 pISet
->Put( SvxColorItem(Color(0x00355269), EE_CHAR_COLOR
)); // font color
551 // Graphic > Shapes > Outlines > Green
553 aName
=SdResId(STR_POOLSHEET_OUTLINE_GREEN
);
554 pSheet
= &(pSSPool
->Make(aName
, SfxStyleFamily::Para
, nMask
));
555 pSheet
->SetParent(aOutlineName
);
556 pSheet
->SetHelpId( aHelpFile
, HID_POOLSHEET_OUTLINE_GREEN
);
557 pISet
= &pSheet
->GetItemSet();
558 pISet
->Put( XLineColorItem(OUString(), Color(0x00127622)) ); // dark green 2
559 pISet
->Put( SvxColorItem(Color(0x00127622), EE_CHAR_COLOR
)); // font color
561 // Graphic > Shapes > Outlines > Red
563 aName
=SdResId(STR_POOLSHEET_OUTLINE_RED
);
564 pSheet
= &(pSSPool
->Make(aName
, SfxStyleFamily::Para
, nMask
));
565 pSheet
->SetParent(aOutlineName
);
566 pSheet
->SetHelpId( aHelpFile
, HID_POOLSHEET_OUTLINE_RED
);
567 pISet
= &pSheet
->GetItemSet();
568 pISet
->Put( XLineColorItem(OUString(), Color(0x00c9211e)) ); // dark red 2
569 pISet
->Put( SvxColorItem(Color(0x00c9211e), EE_CHAR_COLOR
)); // font color
571 // Graphic > Shapes > Outlines > Yellow
573 aName
=SdResId(STR_POOLSHEET_OUTLINE_YELLOW
);
574 pSheet
= &(pSSPool
->Make(aName
, SfxStyleFamily::Para
, nMask
));
575 pSheet
->SetParent(aOutlineName
);
576 pSheet
->SetHelpId( aHelpFile
, HID_POOLSHEET_OUTLINE_YELLOW
);
577 pISet
= &pSheet
->GetItemSet();
578 pISet
->Put( XLineStyleItem(drawing::LineStyle_SOLID
));
579 pISet
->Put( XLineColorItem(OUString(), Color(0x00b47804)) ); // dark gold 2
580 pISet
->Put( SvxColorItem(Color(0x00b47804), EE_CHAR_COLOR
)); // font color
585 aLinesName
= SdResId(STR_POOLSHEET_LINES
);
586 pSheet
= &(pSSPool
->Make(aLinesName
, SfxStyleFamily::Para
, nMask
));
587 pSheet
->SetParent( aGraphicName
);
588 pSheet
->SetHelpId( aHelpFile
, HID_POOLSHEET_LINES
);
589 pISet
= &pSheet
->GetItemSet();
590 pISet
->Put( XFillStyleItem(drawing::FillStyle_NONE
) ); // clear
591 pISet
->Put( XLineStyleItem(drawing::LineStyle_SOLID
) ); // solide line
592 pISet
->Put( XLineColorItem(OUString(), COL_BLACK
) ); // b/w
594 // Graphic > Lines > Measurements
596 aName
= SdResId(STR_POOLSHEET_MEASURE
);
597 pSheet
= &(pSSPool
->Make(aName
, SfxStyleFamily::Para
, nMask
));
598 pSheet
->SetParent(aLinesName
);
599 pSheet
->SetHelpId( aHelpFile
, HID_POOLSHEET_MEASURE
);
600 pISet
= &pSheet
->GetItemSet();
602 ::basegfx::B2DPolygon aArrow
; // arrows
603 aArrow
.append(::basegfx::B2DPoint(10.0, 0.0));
604 aArrow
.append(::basegfx::B2DPoint(0.0, 30.0));
605 aArrow
.append(::basegfx::B2DPoint(20.0, 30.0));
606 aArrow
.setClosed(true);
608 pISet
->Put(XLineStartItem(SvxResId(RID_SVXSTR_ARROW
),::basegfx::B2DPolyPolygon(aArrow
)));
609 pISet
->Put(XLineStartWidthItem(200));
610 pISet
->Put(XLineEndItem(SvxResId(RID_SVXSTR_ARROW
),::basegfx::B2DPolyPolygon(aArrow
)));
611 pISet
->Put(XLineEndWidthItem(200));
612 pISet
->Put(SdrYesNoItem(SDRATTR_MEASURESHOWUNIT
, true));
614 // Graphic > Lines > Dashed
616 aName
= SdResId(STR_POOLSHEET_LINES_DASHED
);
617 pSheet
= &(pSSPool
->Make(aName
, SfxStyleFamily::Para
, nMask
));
618 pSheet
->SetParent(aLinesName
);
619 pSheet
->SetHelpId( aHelpFile
, HID_POOLSHEET_LINES_DASHED
);
620 pISet
= &pSheet
->GetItemSet();
621 pISet
->Put( XLineStyleItem(drawing::LineStyle_DASH
) ); // dashed line
624 // Generate presentation templates for default layout.
625 OUString aPrefix
= SdResId(STR_LAYOUT_DEFAULT_NAME
);
626 pSSPool
->CreateLayoutStyleSheets(aPrefix
);
629 void SdDrawDocument::CreateDefaultCellStyles()
631 if (utl::ConfigManager::IsFuzzing())
634 Reference
<css::uno::XComponentContext
> xContext(comphelper::getProcessComponentContext());
635 Reference
<css::document::XImporter
> xImporter(xContext
->getServiceManager()->createInstanceWithArgumentsAndContext(
636 "com.sun.star.comp.Draw.XMLOasisStylesImporter",
637 { Any(comphelper::makePropertyValue("OrganizerMode", true)) }, xContext
), UNO_QUERY
);
639 xImporter
->setTargetDocument(mpDocSh
->GetModel());
641 OUString
aURL("$BRAND_BASE_DIR/" LIBO_SHARE_FOLDER
"/config/soffice.cfg/simpress/styles.xml");
642 rtl::Bootstrap::expandMacros(aURL
);
643 SvFileStream
aFile(aURL
, StreamMode::READ
);
644 Reference
<css::io::XInputStream
> xInputStream(new utl::OInputStreamWrapper(aFile
));
646 css::xml::sax::InputSource aParserInput
;
647 aParserInput
.sPublicId
= aURL
;
648 aParserInput
.aInputStream
= xInputStream
;
649 Reference
<css::xml::sax::XFastParser
> xFastParser(xImporter
, UNO_QUERY
);
651 xFastParser
->parseStream(aParserInput
);
653 // Set default fonts, if they were not defined in the xml.
654 vcl::Font aLatinFont
, aCJKFont
, aCTLFont
;
656 getDefaultFonts( aLatinFont
, aCJKFont
, aCTLFont
);
658 SvxFontItem
aSvxFontItem( aLatinFont
.GetFamilyType(), aLatinFont
.GetFamilyName(), aLatinFont
.GetStyleName(), aLatinFont
.GetPitch(),
659 aLatinFont
.GetCharSet(), EE_CHAR_FONTINFO
);
661 SvxFontItem
aSvxFontItemCJK( aCJKFont
.GetFamilyType(), aCJKFont
.GetFamilyName(), aCJKFont
.GetStyleName(), aCJKFont
.GetPitch(),
662 aCJKFont
.GetCharSet(), EE_CHAR_FONTINFO_CJK
);
664 SvxFontItem
aSvxFontItemCTL( aCTLFont
.GetFamilyType(), aCTLFont
.GetFamilyName(), aCTLFont
.GetStyleName(), aCTLFont
.GetPitch(),
665 aCTLFont
.GetCharSet(), EE_CHAR_FONTINFO_CTL
);
667 SdStyleSheetPool
* pSSPool
= static_cast<SdStyleSheetPool
*>(GetStyleSheetPool());
668 SfxStyleSheetBase
* pDefaultStyle
= pSSPool
->Find("default", SfxStyleFamily::Frame
);
671 SfxItemSet
& rSet(pDefaultStyle
->GetItemSet());
672 if (!rSet
.HasItem(EE_CHAR_FONTINFO
))
673 rSet
.Put(aSvxFontItem
);
674 if (!rSet
.HasItem(EE_CHAR_FONTINFO_CJK
))
675 rSet
.Put(aSvxFontItemCJK
);
676 if (!rSet
.HasItem(EE_CHAR_FONTINFO_CTL
))
677 rSet
.Put(aSvxFontItemCTL
);
680 // Reset the user defined flag.
681 SfxStyleSheetBase
* pSheet
= pSSPool
->First(SfxStyleFamily::Frame
);
684 pSheet
->SetMask(SfxStyleSearchBits::Auto
);
685 pSheet
= pSSPool
->Next();
688 Reference
<form::XReset
> xReset(pSSPool
->getByName("table"), UNO_QUERY
);
693 // Number of pages that reference a master page
694 sal_uInt16
SdDrawDocument::GetMasterPageUserCount(SdrPage
const * pMaster
) const
696 sal_uInt16 nResult
= 0;
698 sal_uInt16 nPageCount
= GetPageCount();
700 for (nPage
= 0; nPage
< nPageCount
; nPage
++)
702 const SdrPage
* pPage
= GetPage(nPage
);
704 if(pPage
->TRG_HasMasterPage())
706 if(&(pPage
->TRG_GetMasterPage()) == pMaster
)
715 // Finish OnlineSpelling in the background
717 void SdDrawDocument::StopOnlineSpelling()
719 if (mpOnlineSpellingIdle
&& mpOnlineSpellingIdle
->IsActive())
721 mpOnlineSpellingIdle
->Stop();
724 mpOnlineSpellingIdle
.reset();
725 mpOnlineSpellingList
.reset();
728 // Start OnlineSpelling in the background
729 void SdDrawDocument::StartOnlineSpelling(bool bForceSpelling
)
731 if ( !mbOnlineSpell
|| !(bForceSpelling
|| mbInitialOnlineSpellingEnabled
) ||
732 !mpDocSh
|| mpDocSh
->IsReadOnly() )
735 StopOnlineSpelling();
737 SdOutliner
* pOutl
= GetInternalOutliner();
739 Reference
< XSpellChecker1
> xSpellChecker( LinguMgr::GetSpellChecker() );
740 if ( xSpellChecker
.is() )
741 pOutl
->SetSpeller( xSpellChecker
);
743 Reference
< XHyphenator
> xHyphenator( LinguMgr::GetHyphenator() );
744 if( xHyphenator
.is() )
745 pOutl
->SetHyphenator( xHyphenator
);
747 pOutl
->SetDefaultLanguage( meLanguage
);
749 mpOnlineSpellingList
.reset(new ShapeList
);
752 for ( nPage
= 0; nPage
< GetPageCount(); nPage
++ )
754 // Search in all pages
755 FillOnlineSpellingList(static_cast<SdPage
*>(GetPage(nPage
)));
758 for (nPage
= 0; nPage
< GetMasterPageCount(); nPage
++)
760 // Search all master pages
761 FillOnlineSpellingList(static_cast<SdPage
*>( GetMasterPage(nPage
) ));
764 mpOnlineSpellingList
->seekShape(0);
765 mpOnlineSpellingIdle
.reset(new Idle("OnlineSpelling"));
766 mpOnlineSpellingIdle
->SetInvokeHandler( LINK(this, SdDrawDocument
, OnlineSpellingHdl
) );
767 mpOnlineSpellingIdle
->SetPriority(TaskPriority::LOWEST
);
768 mpOnlineSpellingIdle
->Start();
771 // Fill OnlineSpelling list
772 void SdDrawDocument::FillOnlineSpellingList(SdPage
const * pPage
)
774 SdrObjListIter
aIter(pPage
, SdrIterMode::Flat
);
776 while (aIter
.IsMore())
778 SdrObject
* pObj
= aIter
.Next();
783 if (pObj
->GetOutlinerParaObject())
785 // Found a text object
786 mpOnlineSpellingList
->addShape(*pObj
);
788 else if (pObj
->GetObjIdentifier() == SdrObjKind::Group
)
790 // Found a group object
791 SdrObjListIter
aGroupIter(static_cast< SdrObjGroup
* >(pObj
)->GetSubList(), SdrIterMode::DeepNoGroups
);
793 bool bSubTextObjFound
= false;
795 while (aGroupIter
.IsMore() && !bSubTextObjFound
)
797 if (aGroupIter
.Next()->GetOutlinerParaObject())
799 // Found a text object in a group object
800 bSubTextObjFound
= true;
804 if (bSubTextObjFound
)
806 mpOnlineSpellingList
->addShape(*pObj
);
812 // OnlineSpelling in the background
813 IMPL_LINK_NOARG(SdDrawDocument
, OnlineSpellingHdl
, Timer
*, void)
815 if (mpOnlineSpellingList
!=nullptr
816 && ( !mbOnlineSpell
|| mpOnlineSpellingList
->hasMore()))
819 SdrObject
* pObj
= mpOnlineSpellingList
->getNextShape();
823 if (pObj
->GetOutlinerParaObject() && DynCastSdrTextObj( pObj
) != nullptr)
826 SpellObject(static_cast<SdrTextObj
*>(pObj
));
828 else if (pObj
->GetObjIdentifier() == SdrObjKind::Group
)
830 // Found a group object
831 SdrObjListIter
aGroupIter(static_cast< SdrObjGroup
* >(pObj
)->GetSubList(), SdrIterMode::DeepNoGroups
);
834 while (aGroupIter
.IsMore())
836 SdrObject
* pSubObj
= aGroupIter
.Next();
838 if (pSubObj
->GetOutlinerParaObject())
839 if (auto pTextObj
= DynCastSdrTextObj( pSubObj
))
840 // Found a text object in a group object
841 SpellObject(pTextObj
);
847 mpOnlineSpellingIdle
->Start();
851 // Initial spelling has finished
852 mbInitialOnlineSpellingEnabled
= false;
855 StopOnlineSpelling();
857 mpOnlineSearchItem
.reset();
861 // Spell object (for OnlineSpelling)
862 void SdDrawDocument::SpellObject(SdrTextObj
* pObj
)
864 if (!(pObj
&& pObj
->GetOutlinerParaObject()) /* && pObj != pView->GetTextEditObject() */)
867 mbHasOnlineSpellErrors
= false;
868 SdOutliner
* pOutl
= GetInternalOutliner();
869 pOutl
->SetUpdateLayout(true);
870 Link
<EditStatus
&,void> aEvtHdl
= pOutl
->GetStatusEventHdl();
871 pOutl
->SetStatusEventHdl(LINK(this, SdDrawDocument
, OnlineSpellEventHdl
));
873 OutlinerMode nOldOutlMode
= pOutl
->GetOutlinerMode();
874 OutlinerMode nOutlMode
= OutlinerMode::TextObject
;
875 if (pObj
->GetObjInventor() == SdrInventor::Default
&&
876 pObj
->GetObjIdentifier() == SdrObjKind::OutlineText
)
878 nOutlMode
= OutlinerMode::OutlineObject
;
880 pOutl
->Init( nOutlMode
);
882 // Put text into the outliner
883 pOutl
->SetText(*pObj
->GetOutlinerParaObject());
885 if (!mpOnlineSearchItem
|| pOutl
->HasText(*mpOnlineSearchItem
))
888 pOutl
->CompleteOnlineSpelling();
890 if (mbHasOnlineSpellErrors
)
892 std::optional
<OutlinerParaObject
> pOPO
= pOutl
->CreateParaObject();
895 if ( *pOPO
!= *pObj
->GetOutlinerParaObject() ||
896 !pObj
->GetOutlinerParaObject()->isWrongListEqual( *pOPO
))
898 sd::ModifyGuard
aGuard( this );
900 // taking text from the outliner
901 // use non-broadcasting version to avoid O(n^2)
902 pObj
->NbcSetOutlinerParaObject( std::move(pOPO
) );
908 pOutl
->SetStatusEventHdl(aEvtHdl
);
909 pOutl
->SetUpdateLayout(false);
910 pOutl
->Init( nOldOutlMode
);
911 mbHasOnlineSpellErrors
= false;
914 // Object was inserted into model
915 void SdDrawDocument::InsertObject(SdrObject
* pObj
)
917 if(mpOnlineSpellingList
&& pObj
)
919 if (pObj
->GetOutlinerParaObject() || (pObj
->GetObjIdentifier() == SdrObjKind::Group
))
921 // Add object to OnlineSpelling list
922 mpOnlineSpellingList
->addShape(*pObj
);
927 // Object removed from model
928 void SdDrawDocument::RemoveObject(SdrObject
* pObj
)
930 if(mpOnlineSpellingList
&& pObj
)
932 if (pObj
->GetOutlinerParaObject() || (pObj
->GetObjIdentifier() == SdrObjKind::Group
))
934 // Replace object in OnlineSpelling list by 0 pointer
935 mpOnlineSpellingList
->removeShape(*pObj
);
940 // Callback for ExecuteSpellPopup()
941 IMPL_LINK(SdDrawDocument
, OnlineSpellEventHdl
, EditStatus
&, rEditStat
, void)
943 EditStatusFlags nStat
= rEditStat
.GetStatusWord();
944 mbHasOnlineSpellErrors
= bool(nStat
& EditStatusFlags::WRONGWORDCHANGED
);
947 // Callback for ExecuteSpellPopup()
949 // removed link and replaced with Imp method
950 void SdDrawDocument::ImpOnlineSpellCallback(SpellCallbackInfo
const * pInfo
, SdrObject
* pObj
, SdrOutliner
const * pOutl
)
952 mpOnlineSearchItem
.reset();
954 SpellCallbackCommand nCommand
= pInfo
->nCommand
;
956 if (nCommand
== SpellCallbackCommand::IGNOREWORD
957 // restart when add to dictionary takes place, too.
958 || nCommand
== SpellCallbackCommand::ADDTODICTIONARY
)
961 if (auto pTextObj
= DynCastSdrTextObj( pObj
))
963 bool bModified(IsChanged());
964 pTextObj
->SetOutlinerParaObject(pOutl
->CreateParaObject());
965 SetChanged(bModified
);
966 pObj
->BroadcastObjectChange();
969 mpOnlineSearchItem
.reset(new SvxSearchItem( SID_SEARCH_ITEM
) );
970 mpOnlineSearchItem
->SetSearchString(pInfo
->aWord
);
971 StartOnlineSpelling();
973 else if (nCommand
== SpellCallbackCommand::STARTSPELLDLG
)
975 if (SfxViewFrame
* pViewFrame
= SfxViewFrame::Current())
976 pViewFrame
->GetDispatcher()->Execute( SID_SPELL_DIALOG
, SfxCallMode::ASYNCHRON
);
978 else if (nCommand
== SpellCallbackCommand::AUTOCORRECT_OPTIONS
)
980 if (SfxViewFrame
* pViewFrame
= SfxViewFrame::Current())
981 pViewFrame
->GetDispatcher()->Execute( SID_AUTO_CORRECT_DLG
, SfxCallMode::ASYNCHRON
);
985 // Return formatted page number (1, I, i, a, etc.)
986 OUString
SdDrawDocument::CreatePageNumValue(sal_uInt16 nNum
) const
988 OUString aPageNumValue
;
991 switch (mePageNumType
)
993 case css::style::NumberingType::CHARS_UPPER_LETTER
:
994 aPageNumValue
+= OUStringChar( sal_Unicode((nNum
- 1) % 26 + 'A') );
996 case css::style::NumberingType::CHARS_LOWER_LETTER
:
997 aPageNumValue
+= OUStringChar( sal_Unicode((nNum
- 1) % 26 + 'a') );
999 case css::style::NumberingType::ROMAN_UPPER
:
1002 case css::style::NumberingType::ROMAN_LOWER
:
1003 aPageNumValue
+= SvxNumberFormat::CreateRomanString(nNum
, bUpper
);
1005 case css::style::NumberingType::NUMBER_NONE
:
1006 aPageNumValue
= " ";
1009 aPageNumValue
+= OUString::number(nNum
);
1012 return aPageNumValue
;
1015 // Rename layout template
1016 // Keep in mind that rOldLayoutName contains the _complete_ name of the layout
1017 // (including ~LT~). This is unlike rNewName.
1018 void SdDrawDocument::RenameLayoutTemplate(const OUString
& rOldLayoutName
, const OUString
& rNewName
)
1020 OUString
aSep(SD_LT_SEPARATOR
);
1021 OUString
aOldName(rOldLayoutName
);
1022 sal_Int32 nPos
= aOldName
.indexOf( aSep
);
1024 // erase everything after '~LT~'
1026 aOldName
= aOldName
.copy(0, nPos
+ aSep
.getLength());
1028 std::vector
<StyleReplaceData
> aReplList
;
1029 SfxStyleSheetIterator
aIter(mxStyleSheetPool
.get(), SfxStyleFamily::Page
);
1030 SfxStyleSheetBase
* pSheet
= aIter
.First();
1034 OUString aSheetName
= pSheet
->GetName();
1036 // if the sheetname starts with aOldName + "~LT~"
1037 if (aSheetName
.startsWith(aOldName
))
1039 aSheetName
= aSheetName
.replaceAt(0, aOldName
.getLength() - aSep
.getLength(), rNewName
);
1041 StyleReplaceData aReplData
;
1042 aReplData
.nFamily
= pSheet
->GetFamily();
1043 aReplData
.nNewFamily
= pSheet
->GetFamily();
1044 aReplData
.aName
= pSheet
->GetName();
1045 aReplData
.aNewName
= aSheetName
;
1046 aReplList
.push_back(aReplData
);
1048 pSheet
->SetName(aSheetName
);
1051 pSheet
= aIter
.Next();
1054 // Now set the layout name of the drawing and the notes page, as well as
1055 // their master pages.
1056 OUString aPageLayoutName
= rNewName
+ aSep
+ STR_LAYOUT_OUTLINE
;
1058 // Inform all text objects on pages that use the renamed layout and set the
1061 for (nPage
= 0; nPage
< GetPageCount(); nPage
++)
1063 SdPage
* pPage
= static_cast<SdPage
*>(GetPage(nPage
));
1064 OUString
aTemp(pPage
->GetLayoutName());
1066 if (aTemp
== rOldLayoutName
)
1068 pPage
->SetLayoutName(aPageLayoutName
);
1070 for (size_t nObj
= 0; nObj
< pPage
->GetObjCount(); ++nObj
)
1072 SdrObject
* pObj
= pPage
->GetObj(nObj
);
1074 if (pObj
->GetObjInventor() == SdrInventor::Default
)
1076 switch( pObj
->GetObjIdentifier() )
1078 case SdrObjKind::Text
:
1079 case SdrObjKind::OutlineText
:
1080 case SdrObjKind::TitleText
:
1082 OutlinerParaObject
* pOPO
= static_cast<SdrTextObj
*>(pObj
)->GetOutlinerParaObject();
1086 for (const auto& rRepl
: aReplList
)
1087 pOPO
->ChangeStyleSheets( rRepl
.aName
, rRepl
.nFamily
, rRepl
.aNewName
, rRepl
.nNewFamily
);
1100 // Now do this again for all master pages.
1101 // The affected master pages get the name of the layout as their page name.
1102 for (nPage
= 0; nPage
< GetMasterPageCount(); nPage
++)
1104 SdPage
* pPage
= static_cast<SdPage
*>( GetMasterPage(nPage
) );
1105 OUString
aTemp(pPage
->GetLayoutName());
1107 if (aTemp
== rOldLayoutName
)
1109 pPage
->SetLayoutName(aPageLayoutName
);
1110 pPage
->SetName(rNewName
);
1112 for (size_t nObj
= 0; nObj
< pPage
->GetObjCount(); ++nObj
)
1114 SdrObject
* pObj
= pPage
->GetObj(nObj
);
1116 if (pObj
->GetObjInventor() == SdrInventor::Default
)
1118 switch(pObj
->GetObjIdentifier())
1120 case SdrObjKind::Text
:
1121 case SdrObjKind::OutlineText
:
1122 case SdrObjKind::TitleText
:
1124 OutlinerParaObject
* pOPO
= static_cast<SdrTextObj
*>(pObj
)->GetOutlinerParaObject();
1128 for (const auto& rRepl
: aReplList
)
1129 pOPO
->ChangeStyleSheets( rRepl
.aName
, rRepl
.nFamily
, rRepl
.aNewName
, rRepl
.nNewFamily
);
1143 // Set outliner defaults (pool defaults)
1144 void SdDrawDocument::SetTextDefaults() const
1146 // BulletItem and BulletFont for Title and Outline
1147 SvxBulletItem
aBulletItem(EE_PARA_BULLET
);
1148 vcl::Font
aBulletFont( SdStyleSheetPool::GetBulletFont() );
1149 aBulletFont
.SetFontSize(Size(0,846)); // 24 pt
1150 aBulletItem
.SetFont(aBulletFont
);
1151 aBulletItem
.SetStyle(SvxBulletStyle::BULLET
);
1152 aBulletItem
.SetStart(1);
1153 aBulletItem
.SetScale(45); // In percent
1154 aBulletItem
.SetSymbol( 0x25CF ); // In points
1155 m_pItemPool
->SetPoolDefaultItem( aBulletItem
);
1158 SvxNumberFormat
aNumberFormat(SVX_NUM_CHAR_SPECIAL
);
1159 aNumberFormat
.SetBulletFont(&aBulletFont
);
1160 aNumberFormat
.SetBulletChar( 0x25CF ); // StarBats: 0xF000 + 34
1161 aNumberFormat
.SetBulletRelSize(45);
1162 aNumberFormat
.SetBulletColor(COL_AUTO
);
1163 aNumberFormat
.SetStart(1);
1164 aNumberFormat
.SetNumAdjust(SvxAdjust::Left
);
1166 SvxNumRule
aNumRule( SvxNumRuleFlags::BULLET_REL_SIZE
| SvxNumRuleFlags::BULLET_COLOR
, SVX_MAX_NUM
, false);
1168 //aNumberFormat.SetAbsLSpace( 0 );
1169 //aNumberFormat.SetFirstLineOffset( 0 );
1170 //aNumRule.SetLevel( 0, aNumberFormat );
1172 for( sal_uInt16 i
= 0; i
< aNumRule
.GetLevelCount(); i
++ )
1174 const auto nLSpace
= (i
+ 1) * 600;
1175 aNumberFormat
.SetAbsLSpace(nLSpace
);
1176 aNumberFormat
.SetFirstLineOffset(-600);
1177 aNumRule
.SetLevel( i
, aNumberFormat
);
1180 SvxNumBulletItem
aNumBulletItem( std::move(aNumRule
), EE_PARA_NUMBULLET
);
1181 m_pItemPool
->SetPoolDefaultItem( aNumBulletItem
);
1184 css::text::WritingMode
SdDrawDocument::GetDefaultWritingMode() const
1186 const SfxPoolItem
* pItem
= ( m_pItemPool
? m_pItemPool
->GetPoolDefaultItem( EE_PARA_WRITINGDIR
) : nullptr );
1187 css::text::WritingMode eRet
= css::text::WritingMode_LR_TB
;
1191 switch( static_cast<const SvxFrameDirectionItem
&>( *pItem
).GetValue() )
1193 case SvxFrameDirection::Horizontal_LR_TB
: eRet
= css::text::WritingMode_LR_TB
; break;
1194 case SvxFrameDirection::Horizontal_RL_TB
: eRet
= css::text::WritingMode_RL_TB
; break;
1195 case SvxFrameDirection::Vertical_RL_TB
: eRet
= css::text::WritingMode_TB_RL
; break;
1198 OSL_FAIL( "Frame direction not supported yet" );
1206 void SdDrawDocument::SetDefaultWritingMode(css::text::WritingMode eMode
)
1211 SvxFrameDirection nVal
;
1214 case css::text::WritingMode_LR_TB
: nVal
= SvxFrameDirection::Horizontal_LR_TB
; break;
1215 case css::text::WritingMode_RL_TB
: nVal
= SvxFrameDirection::Horizontal_RL_TB
; break;
1216 case css::text::WritingMode_TB_RL
: nVal
= SvxFrameDirection::Vertical_RL_TB
; break;
1218 OSL_FAIL( "Frame direction not supported yet" );
1222 SvxFrameDirectionItem
aModeItem( nVal
, EE_PARA_WRITINGDIR
);
1223 m_pItemPool
->SetPoolDefaultItem( aModeItem
);
1225 SvxAdjustItem
aAdjust( SvxAdjust::Left
, EE_PARA_JUST
);
1227 if( eMode
== css::text::WritingMode_RL_TB
)
1228 aAdjust
.SetAdjust( SvxAdjust::Right
);
1230 m_pItemPool
->SetPoolDefaultItem( aAdjust
);
1233 void SdDrawDocument::getDefaultFonts( vcl::Font
& rLatinFont
, vcl::Font
& rCJKFont
, vcl::Font
& rCTLFont
)
1235 LanguageType eLatin
= GetLanguage( EE_CHAR_LANGUAGE
);
1237 // If the UI language is Korean, the default Latin font has to
1238 // be queried for Korean, too (the Latin language from the document can't be Korean).
1239 // This is the same logic as in SwDocShell::InitNew.
1240 LanguageType eUiLanguage
= Application::GetSettings().GetUILanguageTag().getLanguageType();
1241 if (MsLangId::isKorean(eUiLanguage
))
1242 eLatin
= eUiLanguage
;
1244 rLatinFont
= OutputDevice::GetDefaultFont( DefaultFontType::LATIN_PRESENTATION
, eLatin
, GetDefaultFontFlags::OnlyOne
);
1245 rCJKFont
= OutputDevice::GetDefaultFont( DefaultFontType::CJK_PRESENTATION
, GetLanguage( EE_CHAR_LANGUAGE_CJK
), GetDefaultFontFlags::OnlyOne
);
1246 rCTLFont
= OutputDevice::GetDefaultFont( DefaultFontType::CTL_PRESENTATION
, GetLanguage( EE_CHAR_LANGUAGE_CTL
), GetDefaultFontFlags::OnlyOne
) ;
1249 /* converts the given western font height to a corresponding ctl font height, depending on the system language */
1250 sal_uInt32
SdDrawDocument::convertFontHeightToCTL( sal_uInt32 nWesternFontHeight
)
1252 LanguageType eRealCTLLanguage
= Application::GetSettings().GetLanguageTag().getLanguageType();
1253 if( LANGUAGE_THAI
== eRealCTLLanguage
)
1255 // http://specs.openoffice.org/g11n/font_sizes/42775_42725_Individual_configurable_font_size_for_default_fonts.odt
1256 double fTemp
= double(nWesternFontHeight
) * 1.333;
1257 nWesternFontHeight
= static_cast<sal_uInt32
>(fTemp
);
1258 // make some nice values for UI that displays PT instead of 1/100th mm
1259 nWesternFontHeight
= convertPointToMm100(convertMm100ToPoint(nWesternFontHeight
));
1261 return nWesternFontHeight
;
1264 SdStyleSheetPool
* SdDrawDocument::GetSdStyleSheetPool() const
1266 return dynamic_cast< SdStyleSheetPool
* >( GetStyleSheetPool() );
1269 ModifyGuard::ModifyGuard( SdDrawDocument
* pDoc
)
1270 : mpDocShell( nullptr ), mpDoc( pDoc
)
1275 void ModifyGuard::init()
1279 mpDoc
= mpDocShell
->GetDoc();
1283 mpDocShell
= mpDoc
->GetDocSh();
1286 mbIsEnableSetModified
= mpDocShell
&& mpDocShell
->IsEnableSetModified();
1287 mbIsDocumentChanged
= mpDoc
&& mpDoc
->IsChanged();
1289 if( mbIsEnableSetModified
)
1290 mpDocShell
->EnableSetModified( false );
1293 ModifyGuard::~ModifyGuard()
1295 if( mbIsEnableSetModified
)
1296 mpDocShell
->EnableSetModified();
1298 if( mpDoc
&& (mpDoc
->IsChanged() != mbIsDocumentChanged
) )
1299 mpDoc
->SetChanged(mbIsDocumentChanged
);
1302 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */