Version 6.1.0.2, tag libreoffice-6.1.0.2
[LibreOffice.git] / sd / source / core / drawdoc4.cxx
blobb886954196a241f3b95017ff017f726fb73b7765
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
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/mslangid.hxx>
25 #include <sfx2/docfile.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/settings.hxx>
34 #include <vcl/svapp.hxx>
36 #include <editeng/autokernitem.hxx>
38 #include <svx/svxids.hrc>
39 #include <svl/srchitem.hxx>
40 #include <editeng/lrspitem.hxx>
41 #include <editeng/ulspitem.hxx>
42 #include <editeng/lspcitem.hxx>
43 #include <editeng/adjustitem.hxx>
44 #include <editeng/numdef.hxx>
45 #include <svx/strings.hrc>
46 #include <svx/dialmgr.hxx>
47 #include <editeng/bulletitem.hxx>
48 #include <svx/xtable.hxx>
49 #include <editeng/borderline.hxx>
50 #include <editeng/boxitem.hxx>
51 #include <svx/xit.hxx>
52 #include <svx/xlineit0.hxx>
53 #include <svx/sdshitm.hxx>
54 #include <svx/svdotext.hxx>
55 #include <svx/xfillit0.hxx>
56 #include <svx/sdshcitm.hxx>
57 #include <editeng/editstat.hxx>
58 #include <editeng/colritem.hxx>
59 #include <editeng/fhgtitem.hxx>
60 #include <editeng/wghtitem.hxx>
61 #include <editeng/postitem.hxx>
62 #include <editeng/crossedoutitem.hxx>
63 #include <editeng/udlnitem.hxx>
64 #include <editeng/contouritem.hxx>
65 #include <editeng/emphasismarkitem.hxx>
66 #include <editeng/fontitem.hxx>
67 #include <editeng/shdditem.hxx>
68 #include <editeng/cmapitem.hxx>
69 #include <editeng/memberids.h>
70 #include <svx/xbtmpit.hxx>
71 #include <svx/xflhtit.hxx>
72 #include <svx/xflgrit.hxx>
73 #include <svx/xflclit.hxx>
74 #include <svx/xlnedcit.hxx>
75 #include <svx/xlnstcit.hxx>
76 #include <svx/xlnedwit.hxx>
77 #include <svx/xlnstwit.hxx>
78 #include <svx/xlnedit.hxx>
79 #include <editeng/charreliefitem.hxx>
80 #include <svx/xlnstit.hxx>
81 #include <svx/xlndsit.hxx>
82 #include <svx/xlnwtit.hxx>
83 #include <svx/xlnclit.hxx>
84 #include <svx/svditer.hxx>
85 #include <svx/svdogrp.hxx>
86 #include <svx/svdlayer.hxx>
87 #include <editeng/numitem.hxx>
88 #include <editeng/editeng.hxx>
89 #include <editeng/unolingu.hxx>
90 #include <com/sun/star/linguistic2/XHyphenator.hpp>
91 #include <svl/itempool.hxx>
92 #include <editeng/outlobj.hxx>
93 #include <sfx2/viewfrm.hxx>
94 #include <editeng/langitem.hxx>
95 #include <editeng/frmdiritem.hxx>
97 #include <sdresid.hxx>
98 #include <drawdoc.hxx>
99 #include <sdpage.hxx>
100 #include <strings.hrc>
101 #include <glob.hxx>
102 #include <stlpool.hxx>
103 #include <helpids.h>
104 #include <sdiocmpt.hxx>
105 #include <shapelist.hxx>
106 #include <basegfx/point/b2dpoint.hxx>
107 #include <basegfx/polygon/b2dpolygon.hxx>
108 #include <svl/itemset.hxx>
109 #include <app.hrc>
110 #include <strings.hxx>
112 using namespace ::com::sun::star;
113 using namespace ::com::sun::star::uno;
114 using namespace ::com::sun::star::lang;
115 using namespace ::com::sun::star::style;
116 using namespace ::com::sun::star::container;
117 using namespace ::com::sun::star::linguistic2;
118 using namespace ::sd;
120 // CreateLayoutTemplates
121 // At the moment (31.03.1995), the StyleSheetPool only saves styleheets that
122 // have an ItemSet. To save all stylesheets, we force the creation of an ItemSet
123 // with a GetItemSet call.
124 // We can remove this behavior once the pool saves styleheets even without an ItemSet
125 void SdDrawDocument::CreateLayoutTemplates()
127 SdStyleSheetPool* pSSPool = static_cast<SdStyleSheetPool*>(GetStyleSheetPool());
128 SfxStyleSheetBase* pSheet = nullptr;
129 OUString aHelpFile;
130 OUString aStdName(SdResId(STR_STANDARD_STYLESHEET_NAME));
132 // Default style
134 SfxStyleSearchBits nMask = SfxStyleSearchBits::Auto;
136 OUString aName(aStdName);
137 pSheet = &(pSSPool->Make(aName, SfxStyleFamily::Para, nMask));
138 pSheet->SetHelpId( aHelpFile, HID_STANDARD_STYLESHEET_NAME );
139 SfxItemSet& rISet = pSheet->GetItemSet();
141 ::basegfx::B2DPolyPolygon aNullPolyPolygon;
142 Color aNullCol(COL_DEFAULT_SHAPE_STROKE);
144 XDash aNullDash;
145 XGradient aNullGrad(aNullCol,COL_WHITE);
146 aNullGrad.SetStartIntens( 100 );
147 aNullGrad.SetEndIntens( 100 );
148 XHatch aNullHatch(aNullCol);
150 // Line attributes (Extended OutputDevice)
151 rISet.Put(XLineStyleItem(drawing::LineStyle_SOLID));
152 rISet.Put(XLineColorItem(OUString(), COL_DEFAULT_SHAPE_STROKE));
153 rISet.Put(XLineWidthItem(0));
154 rISet.Put(XLineDashItem(aNullDash));
155 rISet.Put(XLineStartItem(aNullPolyPolygon));
156 rISet.Put(XLineEndItem(aNullPolyPolygon));
157 rISet.Put(XLineStartWidthItem(200));
158 rISet.Put(XLineEndWidthItem(200));
159 rISet.Put(XLineStartCenterItem());
160 rISet.Put(XLineEndCenterItem());
161 rISet.Put(SdrTextHorzAdjustItem(SDRTEXTHORZADJUST_BLOCK));
163 // Fill attributes (Extended OutputDevice)
164 rISet.Put(XFillStyleItem(drawing::FillStyle_SOLID));
165 rISet.Put(XFillColorItem(OUString(), COL_DEFAULT_SHAPE_FILLING));
167 rISet.Put( XFillGradientItem( aNullGrad) );
168 rISet.Put(XFillHatchItem(aNullHatch));
169 Size aNullSize( 32, 32 );
170 Bitmap aNullBmp( aNullSize, 8 );
171 aNullBmp.Erase( COL_WHITE );
172 rISet.Put(XFillBitmapItem(Graphic(aNullBmp)));
174 // Shadow attributes (Drawing Engine)
175 rISet.Put(makeSdrShadowItem(false));
176 rISet.Put(makeSdrShadowColorItem(COL_GRAY));
177 rISet.Put(makeSdrShadowXDistItem(200)); // 3 mm Shadow distance
178 rISet.Put(makeSdrShadowYDistItem(200));
180 vcl::Font aLatinFont, aCJKFont, aCTLFont;
182 getDefaultFonts( aLatinFont, aCJKFont, aCTLFont );
184 SvxFontItem aSvxFontItem( aLatinFont.GetFamilyType(), aLatinFont.GetFamilyName(), aLatinFont.GetStyleName(), aLatinFont.GetPitch(),
185 aLatinFont.GetCharSet(), EE_CHAR_FONTINFO );
187 SvxFontItem aSvxFontItemCJK( aCJKFont.GetFamilyType(), aCJKFont.GetFamilyName(), aCJKFont.GetStyleName(), aCJKFont.GetPitch(),
188 aCJKFont.GetCharSet(), EE_CHAR_FONTINFO_CJK );
190 SvxFontItem aSvxFontItemCTL( aCTLFont.GetFamilyType(), aCTLFont.GetFamilyName(), aCTLFont.GetStyleName(), aCTLFont.GetPitch(),
191 aCTLFont.GetCharSet(), EE_CHAR_FONTINFO_CTL );
193 rISet.Put( aSvxFontItem );
194 rISet.Put( aSvxFontItemCJK );
195 rISet.Put( aSvxFontItemCTL );
197 rISet.Put( SvxFontHeightItem( 635, 100, EE_CHAR_FONTHEIGHT ) ); // sj: (i33745) changed default from 24 to 18 pt
198 rISet.Put( SvxFontHeightItem( 635, 100, EE_CHAR_FONTHEIGHT_CJK ) ); // 18 pt
199 rISet.Put( SvxFontHeightItem( convertFontHeightToCTL( 635 ), 100, EE_CHAR_FONTHEIGHT_CTL ) ); // 18 pt
201 rISet.Put( SvxWeightItem( WEIGHT_NORMAL, EE_CHAR_WEIGHT ) );
202 rISet.Put( SvxWeightItem( WEIGHT_NORMAL, EE_CHAR_WEIGHT_CJK ) );
203 rISet.Put( SvxWeightItem( WEIGHT_NORMAL, EE_CHAR_WEIGHT_CTL ) );
205 rISet.Put( SvxPostureItem( ITALIC_NONE, EE_CHAR_ITALIC ) );
206 rISet.Put( SvxPostureItem( ITALIC_NONE, EE_CHAR_ITALIC_CJK ) );
207 rISet.Put( SvxPostureItem( ITALIC_NONE, EE_CHAR_ITALIC_CTL ) );
209 rISet.Put(SvxContourItem(false, EE_CHAR_OUTLINE ));
210 rISet.Put(SvxShadowedItem(false, EE_CHAR_SHADOW ));
211 rISet.Put(SvxUnderlineItem(LINESTYLE_NONE, EE_CHAR_UNDERLINE));
212 rISet.Put(SvxOverlineItem(LINESTYLE_NONE, EE_CHAR_OVERLINE));
213 rISet.Put(SvxCrossedOutItem(STRIKEOUT_NONE, EE_CHAR_STRIKEOUT ));
214 rISet.Put(SvxCaseMapItem(SvxCaseMap::NotMapped, EE_CHAR_CASEMAP ));
215 rISet.Put(SvxEmphasisMarkItem(FontEmphasisMark::NONE, EE_CHAR_EMPHASISMARK));
216 rISet.Put(SvxCharReliefItem(FontRelief::NONE, EE_CHAR_RELIEF));
217 rISet.Put(SvxColorItem(COL_AUTO, EE_CHAR_COLOR ));
219 // Paragraph attributes (Edit Engine)
220 rISet.Put(SvxLRSpaceItem(EE_PARA_LRSPACE));
221 rISet.Put(SvxULSpaceItem(EE_PARA_ULSPACE));
223 rISet.Put( makeSdrTextLeftDistItem( 250 ) ); // sj: (i33745) using text frame distances seems to be a better default
224 rISet.Put( makeSdrTextRightDistItem( 250 ) );
225 rISet.Put( makeSdrTextUpperDistItem( 125 ) );
226 rISet.Put( makeSdrTextLowerDistItem( 125 ) );
228 rISet.Put( SvxLineSpacingItem( LINE_SPACE_DEFAULT_HEIGHT, EE_PARA_SBL ) );
230 // #i16874# enable kerning by default but only for new documents
231 rISet.Put( SvxAutoKernItem( true, EE_CHAR_PAIRKERNING ) );
233 // Bullet
234 // BulletItem and BulletFont for title and outline
235 SvxBulletItem aBulletItem(EE_PARA_BULLET);
236 // Identical in all layers
237 aBulletItem.SetStyle(SvxBulletStyle::BULLET);
238 aBulletItem.SetStart(1);
239 aBulletItem.SetScale(45); // In percent
241 vcl::Font aBulletFont( SdStyleSheetPool::GetBulletFont() );
243 aBulletFont.SetFontSize(Size(0,635)); // sj: (i33745) changed default from 24 to 18 pt
245 aBulletItem.SetFont(aBulletFont);
246 aBulletItem.SetSymbol( 0x25CF ); // In points
247 rISet.Put(aBulletItem);
249 // New BulletItem
250 SdStyleSheetPool::PutNumBulletItem( pSheet, aBulletFont );
252 SfxItemSet* pISet = nullptr;
254 // Object without filling
255 aName = SdResId(STR_POOLSHEET_OBJWITHOUTFILL);
256 pSheet = &(pSSPool->Make(aName, SfxStyleFamily::Para, nMask));
257 pSheet->SetParent(aStdName);
258 pSheet->SetHelpId( aHelpFile, HID_POOLSHEET_OBJWITHOUTFILL );
259 pISet = &pSheet->GetItemSet();
261 pISet->Put(XFillStyleItem(drawing::FillStyle_NONE));
262 pISet->Put(XLineColorItem(OUString(), COL_BLACK));
264 // Object no fill no line
265 aName = SdResId(STR_POOLSHEET_OBJNOLINENOFILL);
266 pSheet = &(pSSPool->Make(aName, SfxStyleFamily::Para, nMask));
267 pSheet->SetParent(aStdName);
268 pSheet->SetHelpId( aHelpFile, HID_POOLSHEET_OBJNOLINENOFILL );
269 pISet = &pSheet->GetItemSet();
271 pISet->Put(XFillStyleItem(drawing::FillStyle_NONE));
272 pISet->Put(XLineStyleItem(drawing::LineStyle_NONE));
274 // Text
276 aName = SdResId(STR_POOLSHEET_TEXT);
277 pSheet = &(pSSPool->Make(aName, SfxStyleFamily::Para, nMask));
278 pSheet->SetParent(aStdName);
279 pSheet->SetHelpId( aHelpFile, HID_POOLSHEET_TEXT );
280 pISet = &pSheet->GetItemSet();
282 pISet->Put(XLineStyleItem(drawing::LineStyle_NONE));
283 pISet->Put(XFillStyleItem(drawing::FillStyle_NONE));
285 // Title
287 aName = SdResId(STR_POOLSHEET_TITLE);
288 pSheet = &(pSSPool->Make(aName, SfxStyleFamily::Para, nMask));
289 pSheet->SetParent(aStdName);
290 pSheet->SetHelpId( aHelpFile, HID_POOLSHEET_TITLE );
291 pISet = &pSheet->GetItemSet();
293 pISet->Put(XLineStyleItem(drawing::LineStyle_NONE));
294 pISet->Put(XFillStyleItem(drawing::FillStyle_NONE));
296 pISet->Put(SvxFontHeightItem(1551, 100, EE_CHAR_FONTHEIGHT )); // 44 pt
298 // Headline
300 aName = SdResId(STR_POOLSHEET_HEADLINE);
301 pSheet = &(pSSPool->Make(aName, SfxStyleFamily::Para, nMask));
302 pSheet->SetParent(aStdName);
303 pSheet->SetHelpId( aHelpFile, HID_POOLSHEET_HEADLINE );
304 pISet = &pSheet->GetItemSet();
306 pISet->Put(XLineStyleItem(drawing::LineStyle_NONE));
307 pISet->Put(XFillStyleItem(drawing::FillStyle_NONE));
309 pISet->Put(SvxFontHeightItem(846, 100, EE_CHAR_FONTHEIGHT )); // 24 pt
311 pISet->Put(SvxULSpaceItem(420, 210, EE_PARA_ULSPACE )); // Paragraph margin above: 4,2 mm,
312 // Paragraph margin below: 2,1 mm
313 // Measurements
314 aName = SdResId(STR_POOLSHEET_MEASURE);
315 pSheet = &(pSSPool->Make(aName, SfxStyleFamily::Para, nMask));
316 pSheet->SetParent(aStdName);
317 pSheet->SetHelpId( aHelpFile, HID_POOLSHEET_MEASURE );
318 pISet = &pSheet->GetItemSet();
320 pISet->Put(XFillStyleItem(drawing::FillStyle_NONE));
321 pISet->Put(XLineColorItem(OUString(), COL_BLACK));
323 pISet->Put(SvxFontHeightItem(423, 100, EE_CHAR_FONTHEIGHT )); // 12 pt
325 ::basegfx::B2DPolygon aArrow;
326 aArrow.append(::basegfx::B2DPoint(10.0, 0.0));
327 aArrow.append(::basegfx::B2DPoint(0.0, 30.0));
328 aArrow.append(::basegfx::B2DPoint(20.0, 30.0));
329 aArrow.setClosed(true);
331 pISet->Put(XLineStartItem(SvxResId(RID_SVXSTR_ARROW),::basegfx::B2DPolyPolygon(aArrow)));
332 pISet->Put(XLineStartWidthItem(200));
333 pISet->Put(XLineEndItem(SvxResId(RID_SVXSTR_ARROW),::basegfx::B2DPolyPolygon(aArrow)));
334 pISet->Put(XLineEndWidthItem(200));
335 pISet->Put(XLineStyleItem(drawing::LineStyle_SOLID));
336 pISet->Put(SdrYesNoItem(SDRATTR_MEASURESHOWUNIT, true));
338 // Filled
339 OUString aFilledName(SdResId(STR_POOLSHEET_FILLED));
340 XFillGradientItem aFillGradient;
341 XGradient aGradient;
342 aGradient.SetGradientStyle( ::awt::GradientStyle_LINEAR );
343 aGradient.SetAngle( 300 );
344 aSvxFontItem.SetFamilyName("Noto Sans");
346 aName = aFilledName;
347 pSheet = &(pSSPool->Make(aName, SfxStyleFamily::Para, nMask));
348 pSheet->SetHelpId( aHelpFile, HID_POOLSHEET_FILLED );
349 pISet = &pSheet->GetItemSet();
350 pISet->Put( XFillStyleItem(drawing::FillStyle_SOLID) ); // filled solid
351 pISet->Put( XFillColorItem(OUString(), Color(0x00ffffff)) ); // white
352 pISet->Put( XLineColorItem(OUString(), COL_BLACK) ); // black
353 pISet->Put( aSvxFontItem ); // Noto Sans
354 pISet->Put( SvxFontHeightItem(494, 100, EE_CHAR_FONTHEIGHT) ); // 14 pt
355 pISet->Put( SvxWeightItem(WEIGHT_BOLD, EE_CHAR_WEIGHT) ); // bold
357 // Blue
358 aName =SdResId(STR_POOLSHEET_FILLED_BLUE);
359 pSheet = &(pSSPool->Make(aName, SfxStyleFamily::Para, nMask));
360 pSheet->SetParent(aFilledName);
361 pSheet->SetHelpId( aHelpFile, HID_POOLSHEET_FILLED_BLUE );
362 pISet = &pSheet->GetItemSet();
364 aGradient.SetStartColor( Color(0x00729fcf) ); // light blue 2
365 aGradient.SetEndColor( Color(0x00355269) ); // dark blue 2
366 aFillGradient.SetGradientValue(aGradient);
367 aFillGradient.SetName( aName );
368 pISet->Put( XFillStyleItem(drawing::FillStyle_GRADIENT) );
369 pISet->Put( aFillGradient );
370 pISet->Put( XLineStyleItem(drawing::LineStyle_NONE) );
371 pISet->Put( SvxFontHeightItem(494, 100, EE_CHAR_FONTHEIGHT) ); // 14 pt
372 pISet->Put( SvxWeightItem(WEIGHT_BOLD, EE_CHAR_WEIGHT) ); // bold
373 pISet->Put( aSvxFontItem ); // font name
374 pISet->Put( SvxColorItem(COL_WHITE, EE_CHAR_COLOR )); // font color
376 // Green
377 aName =SdResId(STR_POOLSHEET_FILLED_GREEN);
378 pSheet = &(pSSPool->Make(aName, SfxStyleFamily::Para, nMask));
379 pSheet->SetParent(aFilledName);
380 pSheet->SetHelpId( aHelpFile, HID_POOLSHEET_FILLED_GREEN );
381 pISet = &pSheet->GetItemSet();
383 aGradient.SetStartColor( Color(0x0077bc65) ); // light green 2
384 aGradient.SetEndColor( Color(0x00127622) ); // dark green 2
385 aFillGradient.SetGradientValue(aGradient);
386 aFillGradient.SetName( aName );
387 pISet->Put( XFillStyleItem(drawing::FillStyle_GRADIENT) );
388 pISet->Put( aFillGradient );
389 pISet->Put( XLineStyleItem(drawing::LineStyle_NONE) );
390 pISet->Put( SvxFontHeightItem(494, 100, EE_CHAR_FONTHEIGHT) ); // 14 pt
391 pISet->Put( SvxWeightItem(WEIGHT_BOLD, EE_CHAR_WEIGHT) ); // bold
392 pISet->Put( aSvxFontItem ); // font name
393 pISet->Put( SvxColorItem(COL_WHITE, EE_CHAR_COLOR )); // font color
395 // Red
396 aName =SdResId(STR_POOLSHEET_FILLED_RED);
397 pSheet = &(pSSPool->Make(aName, SfxStyleFamily::Para, nMask));
398 pSheet->SetParent(aFilledName);
399 pSheet->SetHelpId( aHelpFile, HID_POOLSHEET_FILLED_RED );
400 pISet = &pSheet->GetItemSet();
402 aGradient.SetStartColor( Color(0x00ff6d6d) ); // light red 2
403 aGradient.SetEndColor( Color(0x00c9211e) ); // dark red 2
404 aFillGradient.SetGradientValue(aGradient);
405 aFillGradient.SetName( aName );
406 pISet->Put( XFillStyleItem(drawing::FillStyle_GRADIENT) );
407 pISet->Put( aFillGradient );
408 pISet->Put( XLineStyleItem(drawing::LineStyle_NONE) );
409 pISet->Put( SvxFontHeightItem(494, 100, EE_CHAR_FONTHEIGHT) ); // 14 pt
410 pISet->Put( SvxWeightItem(WEIGHT_BOLD, EE_CHAR_WEIGHT) ); // bold
411 pISet->Put( aSvxFontItem ); // font name
412 pISet->Put( SvxColorItem(COL_WHITE, EE_CHAR_COLOR )); // font color
414 // Yellow
415 aName =SdResId(STR_POOLSHEET_FILLED_YELLOW);
416 pSheet = &(pSSPool->Make(aName, SfxStyleFamily::Para, nMask));
417 pSheet->SetParent(aFilledName);
418 pSheet->SetHelpId( aHelpFile, HID_POOLSHEET_FILLED_YELLOW );
419 pISet = &pSheet->GetItemSet();
421 aGradient.SetStartColor( Color(0x00ffde59) ); // light gold 2
422 aGradient.SetEndColor( Color(0x00b47804) ); // dark gold 2
423 aFillGradient.SetGradientValue(aGradient);
424 aFillGradient.SetName( aName );
425 pISet->Put( XFillStyleItem(drawing::FillStyle_GRADIENT) );
426 pISet->Put( aFillGradient );
427 pISet->Put( XLineStyleItem(drawing::LineStyle_NONE) );
428 pISet->Put( SvxFontHeightItem(494, 100, EE_CHAR_FONTHEIGHT) ); // 14 pt
429 pISet->Put( SvxWeightItem(WEIGHT_BOLD, EE_CHAR_WEIGHT) ); // bold
430 pISet->Put( aSvxFontItem ); // font name
431 pISet->Put( SvxColorItem(COL_WHITE, EE_CHAR_COLOR )); // font color
433 // Outlines
434 OUString aOutlineName(SdResId(STR_POOLSHEET_OUTLINE));
436 aName = aOutlineName;
437 pSheet = &(pSSPool->Make(aName, SfxStyleFamily::Para, nMask));
438 pSheet->SetHelpId( aHelpFile, HID_POOLSHEET_OUTLINE );
439 pISet = &pSheet->GetItemSet();
440 pISet->Put( XLineWidthItem(81)); // 2.3 pt
441 pISet->Put( XFillStyleItem(drawing::FillStyle_NONE)); // clear
442 pISet->Put( XLineColorItem(OUString(), COL_BLACK)); // b/w
443 pISet->Put( aSvxFontItem ); // font name
444 pISet->Put( SvxFontHeightItem(494, 100, EE_CHAR_FONTHEIGHT) ); // 14 pt
445 pISet->Put( SvxWeightItem(WEIGHT_BOLD, EE_CHAR_WEIGHT) ); // bold
447 // blue
448 aName =SdResId(STR_POOLSHEET_OUTLINE_BLUE);
449 pSheet = &(pSSPool->Make(aName, SfxStyleFamily::Para, nMask));
450 pSheet->SetParent(aOutlineName);
451 pSheet->SetHelpId( aHelpFile, HID_POOLSHEET_OUTLINE_BLUE );
452 pISet = &pSheet->GetItemSet();
454 pISet->Put( XLineStyleItem(drawing::LineStyle_SOLID));
455 pISet->Put( XLineColorItem(OUString(), Color(0x00355269)) ); // dark blue 2
456 pISet->Put( XLineWidthItem(81)); // 2.3 pt
457 pISet->Put( SvxFontHeightItem(494, 100, EE_CHAR_FONTHEIGHT) ); // 14 pt
458 pISet->Put( SvxWeightItem(WEIGHT_BOLD, EE_CHAR_WEIGHT) ); // bold
459 pISet->Put( aSvxFontItem ); // font name
460 pISet->Put( SvxColorItem(Color(0x00355269), EE_CHAR_COLOR )); // font color
462 // green
463 aName =SdResId(STR_POOLSHEET_OUTLINE_GREEN);
464 pSheet = &(pSSPool->Make(aName, SfxStyleFamily::Para, nMask));
465 pSheet->SetParent(aOutlineName);
466 pSheet->SetHelpId( aHelpFile, HID_POOLSHEET_OUTLINE_GREEN );
467 pISet = &pSheet->GetItemSet();
469 pISet->Put( XLineStyleItem(drawing::LineStyle_SOLID));
470 pISet->Put( XLineColorItem(OUString(), Color(0x00127622)) ); // dark green 2
471 pISet->Put( XLineWidthItem(81)); // 2.3 pt
472 pISet->Put( SvxFontHeightItem(494, 100, EE_CHAR_FONTHEIGHT) ); // 14 pt
473 pISet->Put( SvxWeightItem(WEIGHT_BOLD, EE_CHAR_WEIGHT) ); // bold
474 pISet->Put( aSvxFontItem ); // font name
475 pISet->Put( SvxColorItem(Color(0x00127622), EE_CHAR_COLOR )); // font color
477 // red
478 aName =SdResId(STR_POOLSHEET_OUTLINE_RED);
479 pSheet = &(pSSPool->Make(aName, SfxStyleFamily::Para, nMask));
480 pSheet->SetParent(aOutlineName);
481 pSheet->SetHelpId( aHelpFile, HID_POOLSHEET_OUTLINE_RED );
482 pISet = &pSheet->GetItemSet();
484 pISet->Put( XLineStyleItem(drawing::LineStyle_SOLID));
485 pISet->Put( XLineColorItem(OUString(), Color(0x00c9211e)) ); // dark red 2
486 pISet->Put( XLineWidthItem(81)); // 2.3 pt
487 pISet->Put( SvxFontHeightItem(494, 100, EE_CHAR_FONTHEIGHT) ); // 14 pt
488 pISet->Put( SvxWeightItem(WEIGHT_BOLD, EE_CHAR_WEIGHT) ); // bold
489 pISet->Put( aSvxFontItem ); // font name
490 pISet->Put( SvxColorItem(Color(0x00c9211e), EE_CHAR_COLOR )); // font color
492 // yellow
493 aName =SdResId(STR_POOLSHEET_OUTLINE_YELLOW);
494 pSheet = &(pSSPool->Make(aName, SfxStyleFamily::Para, nMask));
495 pSheet->SetParent(aOutlineName);
496 pSheet->SetHelpId( aHelpFile, HID_POOLSHEET_OUTLINE_YELLOW );
497 pISet = &pSheet->GetItemSet();
499 pISet->Put( XLineStyleItem(drawing::LineStyle_SOLID));
500 pISet->Put( XLineColorItem(OUString(), Color(0x00b47804)) ); // dark gold 2
501 pISet->Put( XLineWidthItem(81)); // 2.3 pt
502 pISet->Put( SvxFontHeightItem(494, 100, EE_CHAR_FONTHEIGHT) ); // 14 pt
503 pISet->Put( SvxWeightItem(WEIGHT_BOLD, EE_CHAR_WEIGHT) ); // bold
504 pISet->Put( aSvxFontItem ); // font name
505 pISet->Put( SvxColorItem(Color(0x00b47804), EE_CHAR_COLOR )); // font color
507 // Generate presentation templates for default layout.
508 OUString aPrefix = SdResId(STR_LAYOUT_DEFAULT_NAME);
509 pSSPool->CreateLayoutStyleSheets(aPrefix);
512 static Any implMakeSolidCellStyle( SdStyleSheetPool* pSSPool, const OUString& rName, const OUString& rParent, const Color& rColor )
514 SfxStyleSheetBase* pSheet = &(pSSPool->Make(rName, SfxStyleFamily::Frame, SfxStyleSearchBits::Auto));
515 pSheet->SetParent(rParent);
516 SfxItemSet* pISet = &pSheet->GetItemSet();
517 pISet->Put(XFillStyleItem(drawing::FillStyle_SOLID));
518 pISet->Put(XFillColorItem(OUString(), rColor));
520 return Any( Reference< XStyle >( static_cast< XWeak* >( pSheet ), UNO_QUERY ) );
523 static void implCreateTableTemplate( const Reference< XNameContainer >& xTableFamily, const OUString& rName, const Any& rBody, const Any& rHeading, const Any& rBanding )
525 if( xTableFamily.is() ) try
527 if( !xTableFamily->hasByName( rName ) )
529 Reference< XSingleServiceFactory > xFactory( xTableFamily, UNO_QUERY_THROW );
530 Reference< XNameReplace > xDefaultTableStyle( xFactory->createInstance(), UNO_QUERY_THROW );
531 xTableFamily->insertByName( rName, Any( xDefaultTableStyle ) );
533 xDefaultTableStyle->replaceByName( "body", rBody );
534 xDefaultTableStyle->replaceByName( "odd-rows" , rBanding );
535 xDefaultTableStyle->replaceByName( "odd-columns" , rBanding );
536 xDefaultTableStyle->replaceByName( "first-row" , rHeading );
537 xDefaultTableStyle->replaceByName( "first-column" , rHeading );
538 xDefaultTableStyle->replaceByName( "last-row" , rHeading );
539 xDefaultTableStyle->replaceByName( "last-column" , rHeading );
542 catch( Exception& )
544 OSL_FAIL("sd::implCreateTableTemplate(), exception caught!");
548 void SdDrawDocument::CreateDefaultCellStyles()
550 SdStyleSheetPool* pSSPool = static_cast< SdStyleSheetPool* >(GetStyleSheetPool());
551 SfxStyleSheetBase* pSheet = nullptr;
553 Reference< XNameContainer > xTableFamily( pSSPool->getByName( "table" ), UNO_QUERY );
555 // ---- Default -----------------------------------------------
557 OUString aDefaultCellStyleName( "default" );
559 pSheet = &(pSSPool->Make(aDefaultCellStyleName, SfxStyleFamily::Frame, SfxStyleSearchBits::Auto));
560 pSheet->SetHelpId( OUString(), HID_SD_CELL_STYLE_DEFAULT );
561 SfxItemSet& rISet = pSheet->GetItemSet();
563 Color aNullCol(COL_BLACK);
565 XHatch aNullHatch(aNullCol);
567 rISet.Put(XFillStyleItem(drawing::FillStyle_SOLID));
568 rISet.Put(XFillColorItem(OUString(), Color(0x00ccccff)));
570 vcl::Font aLatinFont, aCJKFont, aCTLFont;
572 getDefaultFonts( aLatinFont, aCJKFont, aCTLFont );
574 SvxFontItem aSvxFontItem( aLatinFont.GetFamilyType(), aLatinFont.GetFamilyName(), aLatinFont.GetStyleName(), aLatinFont.GetPitch(),
575 aLatinFont.GetCharSet(), EE_CHAR_FONTINFO );
577 SvxFontItem aSvxFontItemCJK( aCJKFont.GetFamilyType(), aCJKFont.GetFamilyName(), aCJKFont.GetStyleName(), aCJKFont.GetPitch(),
578 aCJKFont.GetCharSet(), EE_CHAR_FONTINFO_CJK );
580 SvxFontItem aSvxFontItemCTL( aCTLFont.GetFamilyType(), aCTLFont.GetFamilyName(), aCTLFont.GetStyleName(), aCTLFont.GetPitch(),
581 aCTLFont.GetCharSet(), EE_CHAR_FONTINFO_CTL );
583 rISet.Put( aSvxFontItem );
584 rISet.Put( aSvxFontItemCJK );
585 rISet.Put( aSvxFontItemCTL );
587 rISet.Put( SvxFontHeightItem( 635, 100, EE_CHAR_FONTHEIGHT ) ); // sj: (i33745) changed default from 24 to 18 pt
588 rISet.Put( SvxFontHeightItem( 635, 100, EE_CHAR_FONTHEIGHT_CJK ) ); // 18 pt
589 rISet.Put( SvxFontHeightItem( convertFontHeightToCTL( 635 ), 100, EE_CHAR_FONTHEIGHT_CTL ) ); // 18 pt
591 rISet.Put(SvxColorItem(COL_AUTO, EE_CHAR_COLOR ));
593 // Paragraph attributes (Edit Engine)
594 rISet.Put(SvxLRSpaceItem(EE_PARA_LRSPACE));
595 rISet.Put(SvxULSpaceItem(EE_PARA_ULSPACE));
597 rISet.Put( makeSdrTextLeftDistItem( 250 ) );
598 rISet.Put( makeSdrTextRightDistItem( 250 ) );
599 rISet.Put( makeSdrTextUpperDistItem( 130 ) );
600 rISet.Put( makeSdrTextLowerDistItem( 130 ) );
602 rISet.Put( SvxLineSpacingItem( LINE_SPACE_DEFAULT_HEIGHT, EE_PARA_SBL ) );
603 rISet.Put( SvxAutoKernItem( true, EE_CHAR_PAIRKERNING ) );
604 rISet.Put( SdrTextVertAdjustItem(SDRTEXTVERTADJUST_TOP) );
605 rISet.Put( SdrTextHorzAdjustItem(SDRTEXTHORZADJUST_LEFT) );
607 Color aWhite( COL_WHITE );
608 ::editeng::SvxBorderLine aBorderLine(
609 &aWhite, 1, SvxBorderLineStyle::SOLID);
611 SvxBoxItem aBoxItem( SDRATTR_TABLE_BORDER );
612 aBoxItem.SetLine( &aBorderLine, SvxBoxItemLine::TOP );
613 aBoxItem.SetLine( &aBorderLine, SvxBoxItemLine::BOTTOM );
614 aBoxItem.SetLine( &aBorderLine, SvxBoxItemLine::LEFT );
615 aBoxItem.SetLine( &aBorderLine, SvxBoxItemLine::RIGHT );
617 rISet.Put( aBoxItem );
619 // ---- default --------------------------------------------------
621 Any aGray1( implMakeSolidCellStyle( pSSPool, "gray1" , aDefaultCellStyleName, Color(230,230,230)));
622 Any aGray2( implMakeSolidCellStyle( pSSPool, "gray2" , aDefaultCellStyleName, Color(204,204,204)));
623 Any aGray3( implMakeSolidCellStyle( pSSPool, "gray3" , aDefaultCellStyleName, Color(179,179,179)));
625 implCreateTableTemplate( xTableFamily, "default" , aGray1, aGray3, aGray2 );
627 // ---- BW ------------------------------------------------
629 Any aBW1( implMakeSolidCellStyle( pSSPool, "bw1" , aDefaultCellStyleName, Color(255,255,255)));
630 Any aBW2( implMakeSolidCellStyle( pSSPool, "bw2" , aDefaultCellStyleName, Color(230,230,230)));
631 Any aBW3( implMakeSolidCellStyle( pSSPool, "bw3" , aDefaultCellStyleName, Color(0,0,0)));
633 implCreateTableTemplate( xTableFamily, "bw" , aBW1, aBW3, aBW2 );
635 // ---- Orange --------------------------------------------------
637 Any aOrange1( implMakeSolidCellStyle( pSSPool, "orange1" , aDefaultCellStyleName, Color(255,204,153)));
638 Any aOrange2( implMakeSolidCellStyle( pSSPool, "orange2" , aDefaultCellStyleName, Color(255,153,102)));
639 Any aOrange3( implMakeSolidCellStyle( pSSPool, "orange3" , aDefaultCellStyleName, Color(255,102,51)));
641 implCreateTableTemplate( xTableFamily, "orange" , aOrange1, aOrange3, aOrange2 );
643 // ---- Turquoise --------------------------------------------------
645 Any aTurquoise1( implMakeSolidCellStyle( pSSPool, "turquoise1" , aDefaultCellStyleName, Color(71,184,184)));
646 Any aTurquoise2( implMakeSolidCellStyle( pSSPool, "turquoise2" , aDefaultCellStyleName, Color(51,163,163)));
647 Any aTurquoise3( implMakeSolidCellStyle( pSSPool, "turquoise3" , aDefaultCellStyleName, Color(25,138,138)));
649 implCreateTableTemplate( xTableFamily, "turquoise" , aTurquoise1, aTurquoise3, aTurquoise2 );
651 // ---- Gray ------------------------------------------------
653 Any aBlue1( implMakeSolidCellStyle( pSSPool, "blue1" , aDefaultCellStyleName, Color(153,204,255)));
654 Any aBlue2( implMakeSolidCellStyle( pSSPool, "blue2" , aDefaultCellStyleName, Color(0,153,255)));
655 Any aBlue3( implMakeSolidCellStyle( pSSPool, "blue3" , aDefaultCellStyleName, Color(0,102,204)));
657 implCreateTableTemplate( xTableFamily, "blue" , aBlue1, aBlue3, aBlue2 );
659 // ---- Sun ------------------------------------------------
661 Any aSun1( implMakeSolidCellStyle( pSSPool, "sun1" , aDefaultCellStyleName, Color(230,230,255)));
662 Any aSun2( implMakeSolidCellStyle( pSSPool, "sun2" , aDefaultCellStyleName, Color(204,204,255)));
663 Any aSun3( implMakeSolidCellStyle( pSSPool, "sun3" , aDefaultCellStyleName, Color(153,153,255)));
665 implCreateTableTemplate( xTableFamily, "sun" , aSun1, aSun3, aSun2 );
667 // ---- Earth ----------------------------------------------
669 Any aEarth1( implMakeSolidCellStyle( pSSPool, "earth1" , aDefaultCellStyleName, Color(255,255,204)));
670 Any aEarth2( implMakeSolidCellStyle( pSSPool, "earth2" , aDefaultCellStyleName, Color(255,204,153)));
671 Any aEarth3( implMakeSolidCellStyle( pSSPool, "earth3" , aDefaultCellStyleName, Color(204,102,51)));
673 implCreateTableTemplate( xTableFamily, "earth" , aEarth1, aEarth3, aEarth2 );
675 // ---- Green ----------------------------------------------
677 Any aGreen1( implMakeSolidCellStyle( pSSPool, "green1" , aDefaultCellStyleName, Color(255,255,204)));
678 Any aGreen2( implMakeSolidCellStyle( pSSPool, "green2" , aDefaultCellStyleName, Color(148,189,94)));
679 Any aGreen3( implMakeSolidCellStyle( pSSPool, "green3" , aDefaultCellStyleName, Color(92,133,38)));
681 implCreateTableTemplate( xTableFamily, "green" , aGreen1, aGreen3, aGreen2 );
683 // ---- Seaweed ----------------------------------------------
685 Any aSeetang1( implMakeSolidCellStyle( pSSPool, "seetang1" , aDefaultCellStyleName, Color(204,255,255)));
686 Any aSeetang2( implMakeSolidCellStyle( pSSPool, "seetang2" , aDefaultCellStyleName, Color(71,184,184)));
687 Any aSeetang3( implMakeSolidCellStyle( pSSPool, "seetang3" , aDefaultCellStyleName, Color(51,163,163)));
689 implCreateTableTemplate( xTableFamily, "seetang" , aSeetang1, aSeetang3, aSeetang2 );
691 // ---- LightBlue ----------------------------------------------
693 Any aLightBlue1( implMakeSolidCellStyle( pSSPool, "lightblue1" , aDefaultCellStyleName, Color(255,255,255)));
694 Any aLightBlue2( implMakeSolidCellStyle( pSSPool, "lightblue2" , aDefaultCellStyleName, Color(230,230,255)));
695 Any aLightBlue3( implMakeSolidCellStyle( pSSPool, "lightblue3" , aDefaultCellStyleName, Color(153,153,204)));
697 implCreateTableTemplate( xTableFamily, "lightblue" , aLightBlue1, aLightBlue3, aLightBlue2 );
699 // ---- Yellow ----------------------------------------------
701 Any aYellow1( implMakeSolidCellStyle( pSSPool, "yellow1" , aDefaultCellStyleName, Color(255,255,204)));
702 Any aYellow2( implMakeSolidCellStyle( pSSPool, "yellow2" , aDefaultCellStyleName, Color(255,255,153)));
703 Any aYellow3( implMakeSolidCellStyle( pSSPool, "yellow3" , aDefaultCellStyleName, Color(255,204,153)));
705 implCreateTableTemplate( xTableFamily, "yellow" , aYellow1, aYellow3, aYellow2 );
708 // Number of pages that reference a master page
709 sal_uInt16 SdDrawDocument::GetMasterPageUserCount(SdrPage const * pMaster) const
711 sal_uInt16 nResult = 0;
712 sal_uInt16 nPage;
713 sal_uInt16 nPageCount = GetPageCount();
715 for (nPage = 0; nPage < nPageCount; nPage++)
717 const SdrPage* pPage = GetPage(nPage);
719 if(pPage->TRG_HasMasterPage())
721 if(&(pPage->TRG_GetMasterPage()) == pMaster)
723 nResult++;
727 return nResult;
730 // Finish OnlineSpelling in the background
732 void SdDrawDocument::StopOnlineSpelling()
734 if (mpOnlineSpellingIdle && mpOnlineSpellingIdle->IsActive())
736 mpOnlineSpellingIdle->Stop();
739 delete mpOnlineSpellingIdle;
740 mpOnlineSpellingIdle = nullptr;
742 delete mpOnlineSpellingList;
743 mpOnlineSpellingList = nullptr;
746 // Start OnlineSpelling in the background
747 void SdDrawDocument::StartOnlineSpelling(bool bForceSpelling)
749 if (mbOnlineSpell && (bForceSpelling || mbInitialOnlineSpellingEnabled) &&
750 mpDocSh && !mpDocSh->IsReadOnly() )
752 StopOnlineSpelling();
754 SdOutliner* pOutl = GetInternalOutliner();
756 Reference< XSpellChecker1 > xSpellChecker( LinguMgr::GetSpellChecker() );
757 if ( xSpellChecker.is() )
758 pOutl->SetSpeller( xSpellChecker );
760 Reference< XHyphenator > xHyphenator( LinguMgr::GetHyphenator() );
761 if( xHyphenator.is() )
762 pOutl->SetHyphenator( xHyphenator );
764 pOutl->SetDefaultLanguage( meLanguage );
766 mpOnlineSpellingList = new ShapeList;
767 sal_uInt16 nPage;
769 for ( nPage = 0; nPage < GetPageCount(); nPage++ )
771 // Search in all pages
772 FillOnlineSpellingList(static_cast<SdPage*>(GetPage(nPage)));
775 for (nPage = 0; nPage < GetMasterPageCount(); nPage++)
777 // Search all master pages
778 FillOnlineSpellingList(static_cast<SdPage*>( GetMasterPage(nPage) ));
781 mpOnlineSpellingList->seekShape(0);
782 mpOnlineSpellingIdle = new Idle("OnlineSpelling");
783 mpOnlineSpellingIdle->SetInvokeHandler( LINK(this, SdDrawDocument, OnlineSpellingHdl) );
784 mpOnlineSpellingIdle->SetPriority(TaskPriority::LOWEST);
785 mpOnlineSpellingIdle->Start();
789 // Fill OnlineSpelling list
790 void SdDrawDocument::FillOnlineSpellingList(SdPage const * pPage)
792 SdrObjListIter aIter(*pPage, SdrIterMode::Flat);
794 while (aIter.IsMore())
796 SdrObject* pObj = aIter.Next();
798 if( !pObj )
799 continue;
801 if (pObj->GetOutlinerParaObject())
803 // Found a text object
804 mpOnlineSpellingList->addShape(*pObj);
806 else if (pObj->GetObjIdentifier() == OBJ_GRUP)
808 // Found a group object
809 SdrObjListIter aGroupIter(*static_cast<SdrObjGroup*>(pObj)->GetSubList(),
810 SdrIterMode::DeepNoGroups);
812 bool bSubTextObjFound = false;
814 while (aGroupIter.IsMore() && !bSubTextObjFound)
816 if (aGroupIter.Next()->GetOutlinerParaObject())
818 // Found a text object in a group object
819 bSubTextObjFound = true;
823 if (bSubTextObjFound)
825 mpOnlineSpellingList->addShape(*pObj);
831 // OnlineSpelling in the background
832 IMPL_LINK_NOARG(SdDrawDocument, OnlineSpellingHdl, Timer *, void)
834 if (mpOnlineSpellingList!=nullptr
835 && ( !mbOnlineSpell || mpOnlineSpellingList->hasMore()))
837 // Spell next object
838 SdrObject* pObj = mpOnlineSpellingList->getNextShape();
840 if (pObj)
842 if (pObj->GetOutlinerParaObject() && dynamic_cast< const SdrTextObj *>( pObj ) != nullptr)
844 // Spell text object
845 SpellObject(static_cast<SdrTextObj*>(pObj));
847 else if (pObj->GetObjIdentifier() == OBJ_GRUP)
849 // Found a group object
850 SdrObjListIter aGroupIter(*static_cast<SdrObjGroup*>(pObj)->GetSubList(),
851 SdrIterMode::DeepNoGroups);
854 while (aGroupIter.IsMore())
856 SdrObject* pSubObj = aGroupIter.Next();
858 if (pSubObj->GetOutlinerParaObject() && dynamic_cast< SdrTextObj *>( pSubObj ) != nullptr)
860 // Found a text object in a group object
861 SpellObject(static_cast<SdrTextObj*>(pSubObj));
867 // Continue search
868 mpOnlineSpellingIdle->Start();
870 else
872 // Initial spelling has finished
873 mbInitialOnlineSpellingEnabled = false;
875 // Stop search
876 StopOnlineSpelling();
878 mpOnlineSearchItem.reset();
882 // Spell object (for OnlineSpelling)
883 void SdDrawDocument::SpellObject(SdrTextObj* pObj)
885 if (pObj && pObj->GetOutlinerParaObject() /* && pObj != pView->GetTextEditObject() */)
887 mbHasOnlineSpellErrors = false;
888 SdOutliner* pOutl = GetInternalOutliner();
889 pOutl->SetUpdateMode(true);
890 Link<EditStatus&,void> aEvtHdl = pOutl->GetStatusEventHdl();
891 pOutl->SetStatusEventHdl(LINK(this, SdDrawDocument, OnlineSpellEventHdl));
893 OutlinerMode nOldOutlMode = pOutl->GetMode();
894 OutlinerMode nOutlMode = OutlinerMode::TextObject;
895 if (pObj->GetObjInventor() == SdrInventor::Default &&
896 pObj->GetObjIdentifier() == OBJ_OUTLINETEXT)
898 nOutlMode = OutlinerMode::OutlineObject;
900 pOutl->Init( nOutlMode );
902 // Put text into the outliner
903 pOutl->SetText(*pObj->GetOutlinerParaObject());
905 if (!mpOnlineSearchItem || pOutl->HasText(*mpOnlineSearchItem))
907 // Spelling
908 pOutl->CompleteOnlineSpelling();
910 if (mbHasOnlineSpellErrors)
912 OutlinerParaObject* pOPO = pOutl->CreateParaObject();
913 if (pOPO)
915 if (!( *pOPO == *pObj->GetOutlinerParaObject() ) ||
916 !pObj->GetOutlinerParaObject()->isWrongListEqual( *pOPO ))
918 sd::ModifyGuard aGuard( this );
920 // taking text from the outliner
921 // use non-broadcasting version to avoid O(n^2)
922 pObj->NbcSetOutlinerParaObject( pOPO );
923 pOPO = nullptr;
926 delete pOPO;
930 pOutl->SetStatusEventHdl(aEvtHdl);
931 pOutl->SetUpdateMode(false);
932 pOutl->Init( nOldOutlMode );
933 mbHasOnlineSpellErrors = false;
937 // Object was inserted into model
938 void SdDrawDocument::InsertObject(SdrObject* pObj)
940 if(mpOnlineSpellingList && pObj)
942 if (pObj->GetOutlinerParaObject() || (pObj->GetObjIdentifier() == OBJ_GRUP))
944 // Add object to OnlineSpelling list
945 mpOnlineSpellingList->addShape(*pObj);
950 // Object removed from model
951 void SdDrawDocument::RemoveObject(SdrObject* pObj)
953 if(mpOnlineSpellingList && pObj)
955 if (pObj->GetOutlinerParaObject() || (pObj->GetObjIdentifier() == OBJ_GRUP))
957 // Replace object in OnlineSpelling list by 0 pointer
958 mpOnlineSpellingList->removeShape(*pObj);
963 // Callback for ExecuteSpellPopup()
964 IMPL_LINK(SdDrawDocument, OnlineSpellEventHdl, EditStatus&, rEditStat, void)
966 EditStatusFlags nStat = rEditStat.GetStatusWord();
967 mbHasOnlineSpellErrors = bool(nStat & EditStatusFlags::WRONGWORDCHANGED);
970 // Callback for ExecuteSpellPopup()
972 // removed link and replaced with Imp method
973 void SdDrawDocument::ImpOnlineSpellCallback(SpellCallbackInfo const * pInfo, SdrObject* pObj, SdrOutliner const * pOutl)
975 mpOnlineSearchItem.reset();
977 SpellCallbackCommand nCommand = pInfo->nCommand;
979 if (nCommand == SpellCallbackCommand::IGNOREWORD
980 // restart when add to dictionary takes place, too.
981 || nCommand == SpellCallbackCommand::ADDTODICTIONARY)
983 if(pObj && pOutl && dynamic_cast< const SdrTextObj *>( pObj ) != nullptr)
985 bool bModified(IsChanged());
986 static_cast<SdrTextObj*>(pObj)->SetOutlinerParaObject(pOutl->CreateParaObject());
987 SetChanged(bModified);
988 pObj->BroadcastObjectChange();
991 mpOnlineSearchItem.reset(new SvxSearchItem( SID_SEARCH_ITEM ) );
992 mpOnlineSearchItem->SetSearchString(pInfo->aWord);
993 StartOnlineSpelling();
995 else if (nCommand == SpellCallbackCommand::STARTSPELLDLG)
996 SfxViewFrame::Current()->GetDispatcher()->Execute( SID_SPELL_DIALOG, SfxCallMode::ASYNCHRON );
997 else if (nCommand == SpellCallbackCommand::AUTOCORRECT_OPTIONS)
998 SfxViewFrame::Current()->GetDispatcher()->Execute( SID_AUTO_CORRECT_DLG, SfxCallMode::ASYNCHRON );
1001 // Replace the unambiguous names of the default layers by their names in the
1002 // native language
1003 void SdDrawDocument::RestoreLayerNames()
1005 SdrLayerAdmin& rLayerAdmin = GetLayerAdmin();
1006 sal_uInt16 nLayerCount = rLayerAdmin.GetLayerCount();
1008 for (sal_uInt16 nLayer = 0; nLayer < nLayerCount; nLayer++)
1010 SdrLayer* pLayer = rLayerAdmin.GetLayer(nLayer);
1012 if (pLayer)
1014 OUString aLayerName(pLayer->GetName());
1016 if (aLayerName == "LAYER_LAYOUT")
1018 pLayer->SetName(SdResId(STR_LAYER_LAYOUT));
1020 else if (aLayerName == "LAYER_BCKGRND")
1022 pLayer->SetName(SdResId(STR_LAYER_BCKGRND));
1024 else if (aLayerName == "LAYER_BACKGRNDOBJ")
1026 pLayer->SetName(SdResId(STR_LAYER_BCKGRNDOBJ));
1028 else if (aLayerName == "LAYER_CONTROLS")
1030 pLayer->SetName(SdResId(STR_LAYER_CONTROLS));
1032 else if (aLayerName == "LAYER_MEASURELINES")
1034 pLayer->SetName(SdResId(STR_LAYER_MEASURELINES));
1040 // Return formatted page number (1, I, i, a, etc.)
1041 OUString SdDrawDocument::CreatePageNumValue(sal_uInt16 nNum) const
1043 OUString aPageNumValue;
1044 bool bUpper = false;
1046 switch (mePageNumType)
1048 case css::style::NumberingType::CHARS_UPPER_LETTER:
1049 aPageNumValue += OUStringLiteral1( (nNum - 1) % 26 + 'A' );
1050 break;
1051 case css::style::NumberingType::CHARS_LOWER_LETTER:
1052 aPageNumValue += OUStringLiteral1( (nNum - 1) % 26 + 'a' );
1053 break;
1054 case css::style::NumberingType::ROMAN_UPPER:
1055 bUpper = true;
1056 SAL_FALLTHROUGH;
1057 case css::style::NumberingType::ROMAN_LOWER:
1058 aPageNumValue += SvxNumberFormat::CreateRomanString(nNum, bUpper);
1059 break;
1060 case css::style::NumberingType::NUMBER_NONE:
1061 aPageNumValue = " ";
1062 break;
1063 default:
1064 aPageNumValue += OUString::number(nNum);
1067 return aPageNumValue;
1070 // Rename layout template
1071 // Keep in mind that rOldLayoutName contains the _complete_ name of the layout
1072 // (including ~LT~). This is unlike rNewName.
1073 void SdDrawDocument::RenameLayoutTemplate(const OUString& rOldLayoutName, const OUString& rNewName)
1075 OUString aSep(SD_LT_SEPARATOR);
1076 OUString aOldName(rOldLayoutName);
1077 sal_Int32 nPos = aOldName.indexOf( aSep );
1079 // erase everything after '~LT~'
1080 if (nPos != -1)
1081 aOldName = aOldName.copy(0, nPos + aSep.getLength());
1083 std::vector<StyleReplaceData> aReplList;
1084 SfxStyleSheetIterator aIter(mxStyleSheetPool.get(), SfxStyleFamily::Page);
1085 SfxStyleSheetBase* pSheet = aIter.First();
1087 while (pSheet)
1089 OUString aSheetName = pSheet->GetName();
1091 // if the sheetname starts with aOldName + "~LT~"
1092 if (aSheetName.startsWith(aOldName))
1094 aSheetName = aSheetName.replaceAt(0, aOldName.getLength() - aSep.getLength(), rNewName);
1096 StyleReplaceData aReplData;
1097 aReplData.nFamily = pSheet->GetFamily();
1098 aReplData.nNewFamily = pSheet->GetFamily();
1099 aReplData.aName = pSheet->GetName();
1100 aReplData.aNewName = aSheetName;
1101 aReplList.push_back(aReplData);
1103 pSheet->SetName(aSheetName);
1106 pSheet = aIter.Next();
1109 // Now set the layout name of the drawing and the notes page, as well as
1110 // their master pages.
1111 OUString aPageLayoutName(rNewName);
1112 aPageLayoutName += aSep + STR_LAYOUT_OUTLINE;
1114 // Inform all text objects on pages that use the renamed layout and set the
1115 // new name.
1116 sal_uInt16 nPage;
1117 for (nPage = 0; nPage < GetPageCount(); nPage++)
1119 SdPage* pPage = static_cast<SdPage*>(GetPage(nPage));
1120 OUString aTemp(pPage->GetLayoutName());
1122 if (aTemp == rOldLayoutName)
1124 pPage->SetLayoutName(aPageLayoutName);
1126 for (size_t nObj = 0; nObj < pPage->GetObjCount(); ++nObj)
1128 SdrObject* pObj = pPage->GetObj(nObj);
1130 if (pObj->GetObjInventor() == SdrInventor::Default)
1132 switch( pObj->GetObjIdentifier() )
1134 case OBJ_TEXT:
1135 case OBJ_OUTLINETEXT:
1136 case OBJ_TITLETEXT:
1138 OutlinerParaObject* pOPO = static_cast<SdrTextObj*>(pObj)->GetOutlinerParaObject();
1140 if (pOPO)
1142 std::vector<StyleReplaceData>::iterator it;
1143 for (it = aReplList.begin(); it != aReplList.end(); ++it)
1144 pOPO->ChangeStyleSheets( it->aName, it->nFamily, it->aNewName, it->nNewFamily );
1147 break;
1149 default:
1150 break;
1157 // Now do this again for all master pages.
1158 // The affected master pages get the name of the layout as their page name.
1159 for (nPage = 0; nPage < GetMasterPageCount(); nPage++)
1161 SdPage* pPage = static_cast<SdPage*>( GetMasterPage(nPage) );
1162 OUString aTemp(pPage->GetLayoutName());
1164 if (aTemp == rOldLayoutName)
1166 pPage->SetLayoutName(aPageLayoutName);
1167 pPage->SetName(rNewName);
1169 for (size_t nObj = 0; nObj < pPage->GetObjCount(); ++nObj)
1171 SdrObject* pObj = pPage->GetObj(nObj);
1173 if (pObj->GetObjInventor() == SdrInventor::Default)
1175 switch(pObj->GetObjIdentifier())
1177 case OBJ_TEXT:
1178 case OBJ_OUTLINETEXT:
1179 case OBJ_TITLETEXT:
1181 OutlinerParaObject* pOPO = static_cast<SdrTextObj*>(pObj)->GetOutlinerParaObject();
1183 if (pOPO)
1185 std::vector<StyleReplaceData>::iterator it;
1186 for (it = aReplList.begin(); it != aReplList.end(); ++it)
1187 pOPO->ChangeStyleSheets( it->aName, it->nFamily, it->aNewName, it->nNewFamily );
1190 break;
1192 default:
1193 break;
1201 // Set outliner defaults (pool defaults)
1202 void SdDrawDocument::SetTextDefaults() const
1204 // BulletItem and BulletFont for Title and Outline
1205 SvxBulletItem aBulletItem(EE_PARA_BULLET);
1206 vcl::Font aBulletFont( SdStyleSheetPool::GetBulletFont() );
1207 aBulletFont.SetFontSize(Size(0,846)); // 24 pt
1208 aBulletItem.SetFont(aBulletFont);
1209 aBulletItem.SetStyle(SvxBulletStyle::BULLET);
1210 aBulletItem.SetStart(1);
1211 aBulletItem.SetScale(45); // In percent
1212 aBulletItem.SetSymbol( 0x25CF ); // In points
1213 pItemPool->SetPoolDefaultItem( aBulletItem );
1215 // New BulletItem
1216 SvxNumberFormat aNumberFormat(SVX_NUM_CHAR_SPECIAL);
1217 aNumberFormat.SetBulletFont(&aBulletFont);
1218 aNumberFormat.SetBulletChar( 0x25CF ); // StarBats: 0xF000 + 34
1219 aNumberFormat.SetBulletRelSize(45);
1220 aNumberFormat.SetBulletColor(COL_AUTO);
1221 aNumberFormat.SetStart(1);
1222 aNumberFormat.SetNumAdjust(SvxAdjust::Left);
1224 SvxNumRule aNumRule( SvxNumRuleFlags::BULLET_REL_SIZE | SvxNumRuleFlags::BULLET_COLOR | SvxNumRuleFlags::CHAR_TEXT_DISTANCE, SVX_MAX_NUM, false);
1226 //aNumberFormat.SetAbsLSpace( 0 );
1227 //aNumberFormat.SetFirstLineOffset( 0 );
1228 //aNumRule.SetLevel( 0, aNumberFormat );
1230 for( sal_uInt16 i = 0; i < aNumRule.GetLevelCount(); i++ )
1232 const short nLSpace = (i + 1) * 600;
1233 aNumberFormat.SetAbsLSpace(nLSpace);
1234 aNumberFormat.SetFirstLineOffset(-600);
1235 aNumRule.SetLevel( i, aNumberFormat );
1238 SvxNumBulletItem aNumBulletItem( aNumRule, EE_PARA_NUMBULLET );
1239 pItemPool->SetPoolDefaultItem( aNumBulletItem );
1242 css::text::WritingMode SdDrawDocument::GetDefaultWritingMode() const
1244 const SfxPoolItem* pItem = ( pItemPool ? pItemPool->GetPoolDefaultItem( EE_PARA_WRITINGDIR ) : nullptr );
1245 css::text::WritingMode eRet = css::text::WritingMode_LR_TB;
1247 if( pItem )
1249 switch( static_cast<const SvxFrameDirectionItem&>( *pItem ).GetValue() )
1251 case SvxFrameDirection::Horizontal_LR_TB: eRet = css::text::WritingMode_LR_TB; break;
1252 case SvxFrameDirection::Horizontal_RL_TB: eRet = css::text::WritingMode_RL_TB; break;
1253 case SvxFrameDirection::Vertical_RL_TB: eRet = css::text::WritingMode_TB_RL; break;
1255 default:
1256 OSL_FAIL( "Frame direction not supported yet" );
1257 break;
1261 return eRet;
1264 void SdDrawDocument::SetDefaultWritingMode(css::text::WritingMode eMode )
1266 if( pItemPool )
1268 SvxFrameDirection nVal;
1269 switch( eMode )
1271 case css::text::WritingMode_LR_TB: nVal = SvxFrameDirection::Horizontal_LR_TB; break;
1272 case css::text::WritingMode_RL_TB: nVal = SvxFrameDirection::Horizontal_RL_TB; break;
1273 case css::text::WritingMode_TB_RL: nVal = SvxFrameDirection::Vertical_RL_TB; break;
1274 default:
1275 OSL_FAIL( "Frame direction not supported yet" );
1276 return;
1279 SvxFrameDirectionItem aModeItem( nVal, EE_PARA_WRITINGDIR );
1280 pItemPool->SetPoolDefaultItem( aModeItem );
1282 SvxAdjustItem aAdjust( SvxAdjust::Left, EE_PARA_JUST );
1284 if( eMode == css::text::WritingMode_RL_TB )
1285 aAdjust.SetAdjust( SvxAdjust::Right );
1287 pItemPool->SetPoolDefaultItem( aAdjust );
1292 void SdDrawDocument::getDefaultFonts( vcl::Font& rLatinFont, vcl::Font& rCJKFont, vcl::Font& rCTLFont )
1294 LanguageType eLatin = GetLanguage( EE_CHAR_LANGUAGE );
1296 // If the UI language is Korean, the default Latin font has to
1297 // be queried for Korean, too (the Latin language from the document can't be Korean).
1298 // This is the same logic as in SwDocShell::InitNew.
1299 LanguageType eUiLanguage = Application::GetSettings().GetUILanguageTag().getLanguageType();
1300 if (MsLangId::isKorean(eUiLanguage))
1301 eLatin = eUiLanguage;
1303 rLatinFont = OutputDevice::GetDefaultFont( DefaultFontType::LATIN_PRESENTATION, eLatin, GetDefaultFontFlags::OnlyOne );
1304 rCJKFont = OutputDevice::GetDefaultFont( DefaultFontType::CJK_PRESENTATION, GetLanguage( EE_CHAR_LANGUAGE_CJK ), GetDefaultFontFlags::OnlyOne );
1305 rCTLFont = OutputDevice::GetDefaultFont( DefaultFontType::CTL_PRESENTATION, GetLanguage( EE_CHAR_LANGUAGE_CTL ), GetDefaultFontFlags::OnlyOne ) ;
1308 /* converts the given western font height to a corresponding ctl font height, depending on the system language */
1309 sal_uInt32 SdDrawDocument::convertFontHeightToCTL( sal_uInt32 nWesternFontHeight )
1311 LanguageType eRealCTLLanguage = Application::GetSettings().GetLanguageTag().getLanguageType();
1312 if( LANGUAGE_THAI == eRealCTLLanguage )
1314 // http://specs.openoffice.org/g11n/font_sizes/42775_42725_Individual_configurable_font_size_for_default_fonts.odt
1315 double fTemp = double(nWesternFontHeight) * 1.333;
1316 nWesternFontHeight = static_cast<sal_uInt32>(fTemp);
1317 // make some nice values for UI that displays PT instead of 1/100th mm
1318 nWesternFontHeight = ((nWesternFontHeight * 72) + 1270) / 2540L;
1319 nWesternFontHeight = ((nWesternFontHeight * 2540L) + 36) / 72;
1321 return nWesternFontHeight;
1324 SdStyleSheetPool* SdDrawDocument::GetSdStyleSheetPool() const
1326 return dynamic_cast< SdStyleSheetPool* >( GetStyleSheetPool() );
1329 ModifyGuard::ModifyGuard( SdDrawDocument* pDoc )
1330 : mpDocShell( nullptr ), mpDoc( pDoc )
1332 init();
1335 void ModifyGuard::init()
1337 if( mpDocShell )
1339 mpDoc = mpDocShell->GetDoc();
1341 else if( mpDoc )
1343 mpDocShell = mpDoc->GetDocSh();
1346 mbIsEnableSetModified = mpDocShell && mpDocShell->IsEnableSetModified();
1347 mbIsDocumentChanged = mpDoc && mpDoc->IsChanged();
1349 if( mbIsEnableSetModified )
1350 mpDocShell->EnableSetModified( false );
1353 ModifyGuard::~ModifyGuard()
1355 if( mbIsEnableSetModified )
1356 mpDocShell->EnableSetModified();
1358 if( mpDoc && (mpDoc->IsChanged() != mbIsDocumentChanged) )
1359 mpDoc->SetChanged(mbIsDocumentChanged);
1362 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */