LibreOffice Module sd (master) 1
drawdoc4.cxx
Go to the documentation of this file.
1/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2/*
3 * This file is part of the LibreOffice project.
4 *
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/.
8 *
9 * This file incorporates work covered by the following license notice:
10 *
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 .
18 */
19
20#include <sal/config.h>
21#include <config_folders.h>
22
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>
31#include <sfx2/dispatch.hxx>
32#include <Outliner.hxx>
33#include <editeng/outliner.hxx>
34
35#include <DrawDocShell.hxx>
36#include <editeng/eeitem.hxx>
40#include <rtl/bootstrap.hxx>
43#include <tools/stream.hxx>
45
46#include <vcl/idle.hxx>
47#include <vcl/settings.hxx>
48#include <vcl/svapp.hxx>
49
51
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>
58#include <editeng/numdef.hxx>
59#include <svx/strings.hrc>
60#include <svx/dialmgr.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>
75#include <editeng/udlnitem.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>
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>
108
109#include <sdresid.hxx>
110#include <drawdoc.hxx>
111#include <sdpage.hxx>
112#include <strings.hrc>
113#include <glob.hxx>
114#include <stlpool.hxx>
115#include <shapelist.hxx>
118#include <svl/itemset.hxx>
119#include <app.hrc>
120#include <strings.hxx>
121
122namespace com::sun::star::linguistic2 { class XHyphenator; }
123
124using namespace ::com::sun::star;
125using namespace ::com::sun::star::uno;
126using namespace ::com::sun::star::lang;
127using namespace ::com::sun::star::style;
128using namespace ::com::sun::star::container;
129using namespace ::com::sun::star::linguistic2;
130using namespace ::sd;
131
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
138{
139 SdStyleSheetPool* pSSPool = static_cast<SdStyleSheetPool*>(GetStyleSheetPool());
140 SfxStyleSheetBase* pSheet = nullptr;
141 const OUString aHelpFile;
142 OUString aStdName(SdResId(STR_STANDARD_STYLESHEET_NAME));
143
144 // Default style
145
146 SfxStyleSearchBits nMask = SfxStyleSearchBits::Auto;
147
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();
152
153 ::basegfx::B2DPolyPolygon aNullPolyPolygon;
155
156 XDash aNullDash;
157 basegfx::BGradient aNullGrad(
159 aNullCol.getBColor(),
161 aNullGrad.SetStartIntens( 100 );
162 aNullGrad.SetEndIntens( 100 );
163 XHatch aNullHatch(aNullCol);
164
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());
177
178 // Fill attributes (Extended OutputDevice)
179 rISet.Put(XFillStyleItem(drawing::FillStyle_SOLID));
180 rISet.Put(XFillColorItem(OUString(), COL_DEFAULT_SHAPE_FILLING));
181
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))));
188
189 // Shadow attributes (Drawing Engine)
190 rISet.Put(makeSdrShadowItem(false));
192 rISet.Put(makeSdrShadowXDistItem(200)); // 3 mm Shadow distance
193 rISet.Put(makeSdrShadowYDistItem(200));
194
195 vcl::Font aLatinFont, aCJKFont, aCTLFont;
196
197 getDefaultFonts( aLatinFont, aCJKFont, aCTLFont );
198
199 SvxFontItem aSvxFontItem( aLatinFont.GetFamilyType(), aLatinFont.GetFamilyName(), aLatinFont.GetStyleName(), aLatinFont.GetPitch(),
200 aLatinFont.GetCharSet(), EE_CHAR_FONTINFO );
201
202 SvxFontItem aSvxFontItemCJK( aCJKFont.GetFamilyType(), aCJKFont.GetFamilyName(), aCJKFont.GetStyleName(), aCJKFont.GetPitch(),
203 aCJKFont.GetCharSet(), EE_CHAR_FONTINFO_CJK );
204
205 SvxFontItem aSvxFontItemCTL( aCTLFont.GetFamilyType(), aCTLFont.GetFamilyName(), aCTLFont.GetStyleName(), aCTLFont.GetPitch(),
206 aCTLFont.GetCharSet(), EE_CHAR_FONTINFO_CTL );
207
208 rISet.Put( aSvxFontItem );
209 rISet.Put( aSvxFontItemCJK );
210 rISet.Put( aSvxFontItemCTL );
211
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
215
219
223
224 rISet.Put(SvxContourItem(false, EE_CHAR_OUTLINE ));
225 rISet.Put(SvxShadowedItem(false, EE_CHAR_SHADOW ));
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));
233
234 // Paragraph attributes (Edit Engine)
237
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 ) );
242
243 // Set Word-wrap to true by default
244 rISet.Put( makeSdrTextWordWrapItem(true) );
245
247
248 // #i16874# enable kerning by default but only for new documents
249 rISet.Put( SvxAutoKernItem( true, EE_CHAR_PAIRKERNING ) );
250
251 // Bullet
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
258
260
261 aBulletFont.SetFontSize(Size(0,635)); // sj: (i33745) changed default from 24 to 18 pt
262
263 aBulletItem.SetFont(aBulletFont);
264 aBulletItem.SetSymbol( 0x25CF ); // In points
265 rISet.Put(aBulletItem);
266
267 // New BulletItem
268 SdStyleSheetPool::PutNumBulletItem( pSheet, aBulletFont );
269
270 SfxItemSet* pISet = nullptr;
271
272 // Default > Object without filling
273 {
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();
279
280 pISet->Put(XFillStyleItem(drawing::FillStyle_NONE));
281 }
282 // Default > Object no fill no line
283 {
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();
289
290 pISet->Put(XFillStyleItem(drawing::FillStyle_NONE));
291 pISet->Put(XLineStyleItem(drawing::LineStyle_NONE));
292 }
293
294 // tdf#94369
295
296 // Text
297 OUString aTextName;
298 {
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
309 }
310 // Text > A4
311 OUString aA4Name;
312 {
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
320 }
321 // Text > A4 > Title
322 {
323
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
331 }
332 // Text > A4 > Headline
333 {
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
341 }
342 // Text > A4 > Text
343 {
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
350 }
351 // Text > A0
352 OUString aA0Name;
353 {
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
361 }
362 // Text > A0 > Title
363 {
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
371 }
372 // Text > A0 > Headline
373 {
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
381 }
382 // Text > A0 > Text
383 {
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
390 }
391
392 // Graphic
393 OUString aGraphicName;
394 XFillGradientItem aFillGradient;
395 basegfx::BGradient aGradient;
396
397 {
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
407
408 }
409 // Graphic > Shapes
410 OUString aShapesName;
411 {
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
420
421 aGradient.SetColorStops(
423 Color(0xcccccc).getBColor(), // light gray 3
424 COL_WHITE.getBColor())); // white
425
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
432 }
433 // Graphic > Shapes > Filled
434 OUString aFilledName(SdResId(STR_POOLSHEET_FILLED));
435 {
436 aName = aFilledName;
437 pSheet = &(pSSPool->Make(aName, SfxStyleFamily::Para, nMask));
438 pSheet->SetHelpId( aHelpFile, HID_POOLSHEET_FILLED );
439 pSheet->SetParent( aShapesName );
440 pISet = &pSheet->GetItemSet();
441
442 aGradient.SetGradientStyle( ::awt::GradientStyle_LINEAR );
443 aGradient.SetAngle( 300_deg10 );
444
445 aGradient.SetColorStops(
447 COL_WHITE.getBColor(), // white
448 Color(0xcccccc).getBColor())); // light gray 3
449
450 aFillGradient.SetName( aName );
451 aFillGradient.SetGradientValue(aGradient);
452 pISet->Put( XFillStyleItem(drawing::FillStyle_GRADIENT) );
453 pISet->Put( aFillGradient );
454 }
455 // Graphic > Shapes > Filled > Blue
456 {
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();
462
463 aGradient.SetColorStops(
465 Color(0x00729fcf).getBColor(), // light blue 2
466 Color(0x00355269).getBColor())); // dark blue 2
467
468 aFillGradient.SetName( aName );
469 aFillGradient.SetGradientValue(aGradient);
470 pISet->Put( aFillGradient );
471 pISet->Put( SvxColorItem(COL_WHITE, EE_CHAR_COLOR )); // font white
472 }
473 // Graphic > Shapes > Filled > Green
474 {
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();
480
481 aGradient.SetColorStops(
483 Color(0x0077bc65).getBColor(), // light green 2
484 Color(0x00127622).getBColor())); // dark green 2
485
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
491 }
492 // Graphic > Shapes > Filled > Red
493 {
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();
499
500 aGradient.SetColorStops(
502 Color(0x00ff6d6d).getBColor(), // light red 2
503 Color(0x00c9211e).getBColor())); // dark red 2
504
505 aFillGradient.SetName( aName );
506 aFillGradient.SetGradientValue(aGradient);
507 pISet->Put( aFillGradient );
508 pISet->Put( SvxColorItem(COL_WHITE, EE_CHAR_COLOR )); // font white
509 }
510 // Graphic > Shapes > Filled > Yellow
511 {
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();
517
518 aGradient.SetColorStops(
520 Color(0x00ffde59).getBColor(), // light gold 2
521 Color(0x00b47804).getBColor())); // dark gold 2
522
523 aFillGradient.SetName( aName );
524 aFillGradient.SetGradientValue(aGradient);
525 pISet->Put( aFillGradient );
526 pISet->Put( SvxColorItem(COL_WHITE, EE_CHAR_COLOR )); // font white
527 }
528 // Graphic > Shapes > Outlines
529 OUString aOutlineName(SdResId(STR_POOLSHEET_OUTLINE));
530 {
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
540 }
541 // Graphic > Shapes > Outlines > Blue
542 {
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
550 }
551 // Graphic > Shapes > Outlines > Green
552 {
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
560 }
561 // Graphic > Shapes > Outlines > Red
562 {
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
570 }
571 // Graphic > Shapes > Outlines > Yellow
572 {
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
581 }
582 // Graphic > Lines
583 OUString aLinesName;
584 {
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
593 }
594 // Graphic > Lines > Measurements
595 {
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();
601
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);
607
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));
613 }
614 // Graphic > Lines > Dashed
615 {
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
622 }
623
624 // Generate presentation templates for default layout.
625 OUString aPrefix = SdResId(STR_LAYOUT_DEFAULT_NAME);
626 pSSPool->CreateLayoutStyleSheets(aPrefix);
627}
628
630{
632 return;
633
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);
638 if (xImporter)
639 xImporter->setTargetDocument(mpDocSh->GetModel());
640
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));
645
646 css::xml::sax::InputSource aParserInput;
647 aParserInput.sPublicId = aURL;
648 aParserInput.aInputStream = xInputStream;
649 Reference<css::xml::sax::XFastParser> xFastParser(xImporter, UNO_QUERY);
650 if (xFastParser)
651 xFastParser->parseStream(aParserInput);
652
653 // Set default fonts, if they were not defined in the xml.
654 vcl::Font aLatinFont, aCJKFont, aCTLFont;
655
656 getDefaultFonts( aLatinFont, aCJKFont, aCTLFont );
657
658 SvxFontItem aSvxFontItem( aLatinFont.GetFamilyType(), aLatinFont.GetFamilyName(), aLatinFont.GetStyleName(), aLatinFont.GetPitch(),
659 aLatinFont.GetCharSet(), EE_CHAR_FONTINFO );
660
661 SvxFontItem aSvxFontItemCJK( aCJKFont.GetFamilyType(), aCJKFont.GetFamilyName(), aCJKFont.GetStyleName(), aCJKFont.GetPitch(),
662 aCJKFont.GetCharSet(), EE_CHAR_FONTINFO_CJK );
663
664 SvxFontItem aSvxFontItemCTL( aCTLFont.GetFamilyType(), aCTLFont.GetFamilyName(), aCTLFont.GetStyleName(), aCTLFont.GetPitch(),
665 aCTLFont.GetCharSet(), EE_CHAR_FONTINFO_CTL );
666
667 SdStyleSheetPool* pSSPool = static_cast<SdStyleSheetPool*>(GetStyleSheetPool());
668 SfxStyleSheetBase* pDefaultStyle = pSSPool->Find("default", SfxStyleFamily::Frame);
669 if (pDefaultStyle)
670 {
671 SfxItemSet& rSet(pDefaultStyle->GetItemSet());
673 rSet.Put(aSvxFontItem);
675 rSet.Put(aSvxFontItemCJK);
677 rSet.Put(aSvxFontItemCTL);
678 }
679
680 // Reset the user defined flag.
681 SfxStyleSheetBase* pSheet = pSSPool->First(SfxStyleFamily::Frame);
682 while (pSheet)
683 {
684 pSheet->SetMask(SfxStyleSearchBits::Auto);
685 pSheet = pSSPool->Next();
686 }
687
688 Reference<form::XReset> xReset(pSSPool->getByName("table"), UNO_QUERY);
689 if (xReset)
690 xReset->reset();
691}
692
693// Number of pages that reference a master page
694sal_uInt16 SdDrawDocument::GetMasterPageUserCount(SdrPage const * pMaster) const
695{
696 sal_uInt16 nResult = 0;
697 sal_uInt16 nPage;
698 sal_uInt16 nPageCount = GetPageCount();
699
700 for (nPage = 0; nPage < nPageCount; nPage++)
701 {
702 const SdrPage* pPage = GetPage(nPage);
703
704 if(pPage->TRG_HasMasterPage())
705 {
706 if(&(pPage->TRG_GetMasterPage()) == pMaster)
707 {
708 nResult++;
709 }
710 }
711 }
712 return nResult;
713}
714
715// Finish OnlineSpelling in the background
716
718{
720 {
721 mpOnlineSpellingIdle->Stop();
722 }
723
724 mpOnlineSpellingIdle.reset();
725 mpOnlineSpellingList.reset();
726}
727
728// Start OnlineSpelling in the background
729void SdDrawDocument::StartOnlineSpelling(bool bForceSpelling)
730{
731 if ( !mbOnlineSpell || !(bForceSpelling || mbInitialOnlineSpellingEnabled) ||
732 !mpDocSh || mpDocSh->IsReadOnly() )
733 return;
734
736
738
739 Reference< XSpellChecker1 > xSpellChecker( LinguMgr::GetSpellChecker() );
740 if ( xSpellChecker.is() )
741 pOutl->SetSpeller( xSpellChecker );
742
743 Reference< XHyphenator > xHyphenator( LinguMgr::GetHyphenator() );
744 if( xHyphenator.is() )
745 pOutl->SetHyphenator( xHyphenator );
746
747 pOutl->SetDefaultLanguage( meLanguage );
748
749 mpOnlineSpellingList.reset(new ShapeList);
750 sal_uInt16 nPage;
751
752 for ( nPage = 0; nPage < GetPageCount(); nPage++ )
753 {
754 // Search in all pages
755 FillOnlineSpellingList(static_cast<SdPage*>(GetPage(nPage)));
756 }
757
758 for (nPage = 0; nPage < GetMasterPageCount(); nPage++)
759 {
760 // Search all master pages
761 FillOnlineSpellingList(static_cast<SdPage*>( GetMasterPage(nPage) ));
762 }
763
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();
769}
770
771// Fill OnlineSpelling list
773{
774 SdrObjListIter aIter(pPage, SdrIterMode::Flat);
775
776 while (aIter.IsMore())
777 {
778 SdrObject* pObj = aIter.Next();
779
780 if( !pObj )
781 continue;
782
783 if (pObj->GetOutlinerParaObject())
784 {
785 // Found a text object
786 mpOnlineSpellingList->addShape(*pObj);
787 }
788 else if (pObj->GetObjIdentifier() == SdrObjKind::Group)
789 {
790 // Found a group object
791 SdrObjListIter aGroupIter(static_cast< SdrObjGroup* >(pObj)->GetSubList(), SdrIterMode::DeepNoGroups);
792
793 bool bSubTextObjFound = false;
794
795 while (aGroupIter.IsMore() && !bSubTextObjFound)
796 {
797 if (aGroupIter.Next()->GetOutlinerParaObject())
798 {
799 // Found a text object in a group object
800 bSubTextObjFound = true;
801 }
802 }
803
804 if (bSubTextObjFound)
805 {
806 mpOnlineSpellingList->addShape(*pObj);
807 }
808 }
809 }
810}
811
812// OnlineSpelling in the background
813IMPL_LINK_NOARG(SdDrawDocument, OnlineSpellingHdl, Timer *, void)
814{
815 if (mpOnlineSpellingList!=nullptr
816 && ( !mbOnlineSpell || mpOnlineSpellingList->hasMore()))
817 {
818 // Spell next object
819 SdrObject* pObj = mpOnlineSpellingList->getNextShape();
820
821 if (pObj)
822 {
823 if (pObj->GetOutlinerParaObject() && DynCastSdrTextObj( pObj ) != nullptr)
824 {
825 // Spell text object
826 SpellObject(static_cast<SdrTextObj*>(pObj));
827 }
828 else if (pObj->GetObjIdentifier() == SdrObjKind::Group)
829 {
830 // Found a group object
831 SdrObjListIter aGroupIter(static_cast< SdrObjGroup* >(pObj)->GetSubList(), SdrIterMode::DeepNoGroups);
832
833
834 while (aGroupIter.IsMore())
835 {
836 SdrObject* pSubObj = aGroupIter.Next();
837
838 if (pSubObj->GetOutlinerParaObject())
839 if (auto pTextObj = DynCastSdrTextObj( pSubObj ))
840 // Found a text object in a group object
841 SpellObject(pTextObj);
842 }
843 }
844 }
845
846 // Continue search
847 mpOnlineSpellingIdle->Start();
848 }
849 else
850 {
851 // Initial spelling has finished
852 mbInitialOnlineSpellingEnabled = false;
853
854 // Stop search
855 StopOnlineSpelling();
856
857 mpOnlineSearchItem.reset();
858 }
859}
860
861// Spell object (for OnlineSpelling)
863{
864 if (!(pObj && pObj->GetOutlinerParaObject()) /* && pObj != pView->GetTextEditObject() */)
865 return;
866
869 pOutl->SetUpdateLayout(true);
870 Link<EditStatus&,void> aEvtHdl = pOutl->GetStatusEventHdl();
871 pOutl->SetStatusEventHdl(LINK(this, SdDrawDocument, OnlineSpellEventHdl));
872
873 OutlinerMode nOldOutlMode = pOutl->GetOutlinerMode();
874 OutlinerMode nOutlMode = OutlinerMode::TextObject;
875 if (pObj->GetObjInventor() == SdrInventor::Default &&
876 pObj->GetObjIdentifier() == SdrObjKind::OutlineText)
877 {
878 nOutlMode = OutlinerMode::OutlineObject;
879 }
880 pOutl->Init( nOutlMode );
881
882 // Put text into the outliner
883 pOutl->SetText(*pObj->GetOutlinerParaObject());
884
885 if (!mpOnlineSearchItem || pOutl->HasText(*mpOnlineSearchItem))
886 {
887 // Spelling
888 pOutl->CompleteOnlineSpelling();
889
891 {
892 std::optional<OutlinerParaObject> pOPO = pOutl->CreateParaObject();
893 if (pOPO)
894 {
895 if ( *pOPO != *pObj->GetOutlinerParaObject() ||
896 !pObj->GetOutlinerParaObject()->isWrongListEqual( *pOPO ))
897 {
898 sd::ModifyGuard aGuard( this );
899
900 // taking text from the outliner
901 // use non-broadcasting version to avoid O(n^2)
902 pObj->NbcSetOutlinerParaObject( std::move(pOPO) );
903 }
904 }
905 }
906 }
907
908 pOutl->SetStatusEventHdl(aEvtHdl);
909 pOutl->SetUpdateLayout(false);
910 pOutl->Init( nOldOutlMode );
912}
913
914// Object was inserted into model
916{
917 if(mpOnlineSpellingList && pObj)
918 {
919 if (pObj->GetOutlinerParaObject() || (pObj->GetObjIdentifier() == SdrObjKind::Group))
920 {
921 // Add object to OnlineSpelling list
922 mpOnlineSpellingList->addShape(*pObj);
923 }
924 }
925}
926
927// Object removed from model
929{
930 if(mpOnlineSpellingList && pObj)
931 {
932 if (pObj->GetOutlinerParaObject() || (pObj->GetObjIdentifier() == SdrObjKind::Group))
933 {
934 // Replace object in OnlineSpelling list by 0 pointer
935 mpOnlineSpellingList->removeShape(*pObj);
936 }
937 }
938}
939
940// Callback for ExecuteSpellPopup()
941IMPL_LINK(SdDrawDocument, OnlineSpellEventHdl, EditStatus&, rEditStat, void)
942{
943 EditStatusFlags nStat = rEditStat.GetStatusWord();
944 mbHasOnlineSpellErrors = bool(nStat & EditStatusFlags::WRONGWORDCHANGED);
945}
946
947// Callback for ExecuteSpellPopup()
948
949// removed link and replaced with Imp method
951{
952 mpOnlineSearchItem.reset();
953
954 SpellCallbackCommand nCommand = pInfo->nCommand;
955
956 if (nCommand == SpellCallbackCommand::IGNOREWORD
957 // restart when add to dictionary takes place, too.
958 || nCommand == SpellCallbackCommand::ADDTODICTIONARY)
959 {
960 if(pOutl)
961 if (auto pTextObj = DynCastSdrTextObj( pObj ))
962 {
963 bool bModified(IsChanged());
964 pTextObj->SetOutlinerParaObject(pOutl->CreateParaObject());
965 SetChanged(bModified);
966 pObj->BroadcastObjectChange();
967 }
968
969 mpOnlineSearchItem.reset(new SvxSearchItem( SID_SEARCH_ITEM ) );
970 mpOnlineSearchItem->SetSearchString(pInfo->aWord);
972 }
973 else if (nCommand == SpellCallbackCommand::STARTSPELLDLG)
974 {
975 if (SfxViewFrame* pViewFrame = SfxViewFrame::Current())
976 pViewFrame->GetDispatcher()->Execute( SID_SPELL_DIALOG, SfxCallMode::ASYNCHRON );
977 }
978 else if (nCommand == SpellCallbackCommand::AUTOCORRECT_OPTIONS)
979 {
980 if (SfxViewFrame* pViewFrame = SfxViewFrame::Current())
981 pViewFrame->GetDispatcher()->Execute( SID_AUTO_CORRECT_DLG, SfxCallMode::ASYNCHRON );
982 }
983}
984
985// Return formatted page number (1, I, i, a, etc.)
986OUString SdDrawDocument::CreatePageNumValue(sal_uInt16 nNum) const
987{
988 OUString aPageNumValue;
989 bool bUpper = false;
990
991 switch (mePageNumType)
992 {
993 case css::style::NumberingType::CHARS_UPPER_LETTER:
994 aPageNumValue += OUStringChar( sal_Unicode((nNum - 1) % 26 + 'A') );
995 break;
996 case css::style::NumberingType::CHARS_LOWER_LETTER:
997 aPageNumValue += OUStringChar( sal_Unicode((nNum - 1) % 26 + 'a') );
998 break;
999 case css::style::NumberingType::ROMAN_UPPER:
1000 bUpper = true;
1001 [[fallthrough]];
1002 case css::style::NumberingType::ROMAN_LOWER:
1003 aPageNumValue += SvxNumberFormat::CreateRomanString(nNum, bUpper);
1004 break;
1005 case css::style::NumberingType::NUMBER_NONE:
1006 aPageNumValue = " ";
1007 break;
1008 default:
1009 aPageNumValue += OUString::number(nNum);
1010 }
1011
1012 return aPageNumValue;
1013}
1014
1015// Rename layout template
1016// Keep in mind that rOldLayoutName contains the _complete_ name of the layout
1017// (including ~LT~). This is unlike rNewName.
1018void SdDrawDocument::RenameLayoutTemplate(const OUString& rOldLayoutName, const OUString& rNewName)
1019{
1020 OUString aSep(SD_LT_SEPARATOR);
1021 OUString aOldName(rOldLayoutName);
1022 sal_Int32 nPos = aOldName.indexOf( aSep );
1023
1024 // erase everything after '~LT~'
1025 if (nPos != -1)
1026 aOldName = aOldName.copy(0, nPos + aSep.getLength());
1027
1028 std::vector<StyleReplaceData> aReplList;
1029 SfxStyleSheetIterator aIter(mxStyleSheetPool.get(), SfxStyleFamily::Page);
1030 SfxStyleSheetBase* pSheet = aIter.First();
1031
1032 while (pSheet)
1033 {
1034 OUString aSheetName = pSheet->GetName();
1035
1036 // if the sheetname starts with aOldName + "~LT~"
1037 if (aSheetName.startsWith(aOldName))
1038 {
1039 aSheetName = aSheetName.replaceAt(0, aOldName.getLength() - aSep.getLength(), rNewName);
1040
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);
1047
1048 pSheet->SetName(aSheetName);
1049 }
1050
1051 pSheet = aIter.Next();
1052 }
1053
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;
1057
1058 // Inform all text objects on pages that use the renamed layout and set the
1059 // new name.
1060 sal_uInt16 nPage;
1061 for (nPage = 0; nPage < GetPageCount(); nPage++)
1062 {
1063 SdPage* pPage = static_cast<SdPage*>(GetPage(nPage));
1064 OUString aTemp(pPage->GetLayoutName());
1065
1066 if (aTemp == rOldLayoutName)
1067 {
1068 pPage->SetLayoutName(aPageLayoutName);
1069
1070 for (size_t nObj = 0; nObj < pPage->GetObjCount(); ++nObj)
1071 {
1072 SdrObject* pObj = pPage->GetObj(nObj);
1073
1074 if (pObj->GetObjInventor() == SdrInventor::Default)
1075 {
1076 switch( pObj->GetObjIdentifier() )
1077 {
1078 case SdrObjKind::Text:
1079 case SdrObjKind::OutlineText:
1080 case SdrObjKind::TitleText:
1081 {
1082 OutlinerParaObject* pOPO = static_cast<SdrTextObj*>(pObj)->GetOutlinerParaObject();
1083
1084 if (pOPO)
1085 {
1086 for (const auto& rRepl : aReplList)
1087 pOPO->ChangeStyleSheets( rRepl.aName, rRepl.nFamily, rRepl.aNewName, rRepl.nNewFamily );
1088 }
1089 }
1090 break;
1091
1092 default:
1093 break;
1094 }
1095 }
1096 }
1097 }
1098 }
1099
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++)
1103 {
1104 SdPage* pPage = static_cast<SdPage*>( GetMasterPage(nPage) );
1105 OUString aTemp(pPage->GetLayoutName());
1106
1107 if (aTemp == rOldLayoutName)
1108 {
1109 pPage->SetLayoutName(aPageLayoutName);
1110 pPage->SetName(rNewName);
1111
1112 for (size_t nObj = 0; nObj < pPage->GetObjCount(); ++nObj)
1113 {
1114 SdrObject* pObj = pPage->GetObj(nObj);
1115
1116 if (pObj->GetObjInventor() == SdrInventor::Default)
1117 {
1118 switch(pObj->GetObjIdentifier())
1119 {
1120 case SdrObjKind::Text:
1121 case SdrObjKind::OutlineText:
1122 case SdrObjKind::TitleText:
1123 {
1124 OutlinerParaObject* pOPO = static_cast<SdrTextObj*>(pObj)->GetOutlinerParaObject();
1125
1126 if (pOPO)
1127 {
1128 for (const auto& rRepl : aReplList)
1129 pOPO->ChangeStyleSheets( rRepl.aName, rRepl.nFamily, rRepl.aNewName, rRepl.nNewFamily );
1130 }
1131 }
1132 break;
1133
1134 default:
1135 break;
1136 }
1137 }
1138 }
1139 }
1140 }
1141}
1142
1143// Set outliner defaults (pool defaults)
1145{
1146 // BulletItem and BulletFont for Title and Outline
1147 SvxBulletItem aBulletItem(EE_PARA_BULLET);
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 );
1156
1157 // New BulletItem
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);
1165
1166 SvxNumRule aNumRule( SvxNumRuleFlags::BULLET_REL_SIZE | SvxNumRuleFlags::BULLET_COLOR, SVX_MAX_NUM, false);
1167
1168 //aNumberFormat.SetAbsLSpace( 0 );
1169 //aNumberFormat.SetFirstLineOffset( 0 );
1170 //aNumRule.SetLevel( 0, aNumberFormat );
1171
1172 for( sal_uInt16 i = 0; i < aNumRule.GetLevelCount(); i++ )
1173 {
1174 const auto nLSpace = (i + 1) * 600;
1175 aNumberFormat.SetAbsLSpace(nLSpace);
1176 aNumberFormat.SetFirstLineOffset(-600);
1177 aNumRule.SetLevel( i, aNumberFormat );
1178 }
1179
1180 SvxNumBulletItem aNumBulletItem( std::move(aNumRule), EE_PARA_NUMBULLET );
1181 m_pItemPool->SetPoolDefaultItem( aNumBulletItem );
1182}
1183
1184css::text::WritingMode SdDrawDocument::GetDefaultWritingMode() const
1185{
1186 const SfxPoolItem* pItem = ( m_pItemPool ? m_pItemPool->GetPoolDefaultItem( EE_PARA_WRITINGDIR ) : nullptr );
1187 css::text::WritingMode eRet = css::text::WritingMode_LR_TB;
1188
1189 if( pItem )
1190 {
1191 switch( static_cast<const SvxFrameDirectionItem&>( *pItem ).GetValue() )
1192 {
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;
1196
1197 default:
1198 OSL_FAIL( "Frame direction not supported yet" );
1199 break;
1200 }
1201 }
1202
1203 return eRet;
1204}
1205
1206void SdDrawDocument::SetDefaultWritingMode(css::text::WritingMode eMode )
1207{
1208 if( !m_pItemPool )
1209 return;
1210
1211 SvxFrameDirection nVal;
1212 switch( eMode )
1213 {
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;
1217 default:
1218 OSL_FAIL( "Frame direction not supported yet" );
1219 return;
1220 }
1221
1222 SvxFrameDirectionItem aModeItem( nVal, EE_PARA_WRITINGDIR );
1223 m_pItemPool->SetPoolDefaultItem( aModeItem );
1224
1225 SvxAdjustItem aAdjust( SvxAdjust::Left, EE_PARA_JUST );
1226
1227 if( eMode == css::text::WritingMode_RL_TB )
1228 aAdjust.SetAdjust( SvxAdjust::Right );
1229
1230 m_pItemPool->SetPoolDefaultItem( aAdjust );
1231}
1232
1233void SdDrawDocument::getDefaultFonts( vcl::Font& rLatinFont, vcl::Font& rCJKFont, vcl::Font& rCTLFont )
1234{
1236
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.
1241 if (MsLangId::isKorean(eUiLanguage))
1242 eLatin = eUiLanguage;
1243
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 ) ;
1247}
1248
1249/* converts the given western font height to a corresponding ctl font height, depending on the system language */
1250sal_uInt32 SdDrawDocument::convertFontHeightToCTL( sal_uInt32 nWesternFontHeight )
1251{
1253 if( LANGUAGE_THAI == eRealCTLLanguage )
1254 {
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));
1260 }
1261 return nWesternFontHeight;
1262}
1263
1265{
1266 return dynamic_cast< SdStyleSheetPool* >( GetStyleSheetPool() );
1267}
1268
1269ModifyGuard::ModifyGuard( SdDrawDocument* pDoc )
1270: mpDocShell( nullptr ), mpDoc( pDoc )
1271{
1272 init();
1273}
1274
1276{
1277 if( mpDocShell )
1278 {
1279 mpDoc = mpDocShell->GetDoc();
1280 }
1281 else if( mpDoc )
1282 {
1284 }
1285
1288
1290 mpDocShell->EnableSetModified( false );
1291}
1292
1294{
1297
1298 if( mpDoc && (mpDoc->IsChanged() != mbIsDocumentChanged) )
1300}
1301
1302/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
constexpr auto convertPointToMm100(N n)
constexpr auto convertMm100ToPoint(N n)
const LanguageTag & GetLanguageTag() const
const LanguageTag & GetUILanguageTag() const
static const AllSettings & GetSettings()
bool Erase(const Color &rFillColor)
basegfx::BColor getBColor() const
LanguageType getLanguageType(bool bResolveSystem=true) const
static css::uno::Reference< css::linguistic2::XSpellChecker1 > GetSpellChecker()
static css::uno::Reference< css::linguistic2::XHyphenator > GetHyphenator()
static bool isKorean(LanguageType nLang)
void SetName(const OUString &rName)
bool isWrongListEqual(const OutlinerParaObject &rCompare) const
bool ChangeStyleSheets(std::u16string_view rOldName, SfxStyleFamily eOldFamily, const OUString &rNewName, SfxStyleFamily eNewFamily)
static vcl::Font GetDefaultFont(DefaultFontType nType, LanguageType eLang, GetDefaultFontFlags nFlags, const OutputDevice *pOutDev=nullptr)
SAL_DLLPRIVATE void InsertObject(SdrObject *pObj)
Definition: drawdoc4.cxx:915
SAL_DLLPRIVATE void RemoveObject(SdrObject *pObj)
Definition: drawdoc4.cxx:928
SAL_DLLPRIVATE void FillOnlineSpellingList(SdPage const *pPage)
Definition: drawdoc4.cxx:772
SAL_DLLPRIVATE sal_uInt16 GetMasterPageUserCount(SdrPage const *pMaster) const
Definition: drawdoc4.cxx:694
LanguageType meLanguage
Definition: drawdoc.hxx:159
SAL_DLLPRIVATE void StopOnlineSpelling()
Definition: drawdoc4.cxx:717
SAL_DLLPRIVATE void CreateLayoutTemplates()
Definition: drawdoc4.cxx:137
std::unique_ptr< SvxSearchItem > mpOnlineSearchItem
Definition: drawdoc.hxx:138
SAL_DLLPRIVATE void ImpOnlineSpellCallback(SpellCallbackInfo const *pInfo, SdrObject *pObj, SdrOutliner const *pOutl)
Definition: drawdoc4.cxx:950
OUString CreatePageNumValue(sal_uInt16 nNum) const
Definition: drawdoc4.cxx:986
SdOutliner * GetInternalOutliner(bool bCreateOutliner=true)
Definition: drawdoc.cxx:930
SAL_DLLPRIVATE void SpellObject(SdrTextObj *pObj)
Definition: drawdoc4.cxx:862
::sd::DrawDocShell * mpDocSh
Definition: drawdoc.hxx:142
bool mbHasOnlineSpellErrors
Definition: drawdoc.hxx:144
std::unique_ptr< Idle > mpOnlineSpellingIdle
Definition: drawdoc.hxx:134
SAL_DLLPRIVATE void CreateDefaultCellStyles()
Definition: drawdoc4.cxx:629
SAL_DLLPRIVATE void StartOnlineSpelling(bool bForceSpelling=true)
Definition: drawdoc4.cxx:729
SAL_DLLPRIVATE void SetTextDefaults() const
Definition: drawdoc4.cxx:1144
SAL_DLLPRIVATE void SetDefaultWritingMode(css::text::WritingMode eMode)
Definition: drawdoc4.cxx:1206
SAL_DLLPRIVATE void RenameLayoutTemplate(const OUString &rOldLayoutName, const OUString &rNewName)
Definition: drawdoc4.cxx:1018
SdStyleSheetPool * GetSdStyleSheetPool() const
Get the style sheet pool if it was a SdStyleSheetPool.
Definition: drawdoc4.cxx:1264
SAL_DLLPRIVATE void getDefaultFonts(vcl::Font &rLatinFont, vcl::Font &rCJKFont, vcl::Font &rCTLFont)
return the document fonts for latin, cjk and ctl according to the current languages set at this docum...
Definition: drawdoc4.cxx:1233
SvxNumType mePageNumType
Definition: drawdoc.hxx:162
std::unique_ptr< sd::ShapeList > mpOnlineSpellingList
Definition: drawdoc.hxx:136
bool mbOnlineSpell
Definition: drawdoc.hxx:155
SAL_DLLPRIVATE LanguageType GetLanguage(const sal_uInt16 nId) const
Definition: drawdoc2.cxx:875
css::text::WritingMode GetDefaultWritingMode() const
Definition: drawdoc4.cxx:1184
bool mbInitialOnlineSpellingEnabled
Definition: drawdoc.hxx:145
virtual SAL_DLLPRIVATE void SetChanged(bool bFlag=true) override
Definition: drawdoc.cxx:658
SAL_DLLPRIVATE::sd::DrawDocShell * GetDocSh() const
Definition: drawdoc.hxx:242
static SAL_DLLPRIVATE sal_uInt32 convertFontHeightToCTL(sal_uInt32 nWesternFontHeight)
converts the given western font height to a corresponding ctl font height, depending on the system la...
Definition: drawdoc4.cxx:1250
The main purpose of this class is searching and replacing as well as spelling of impress documents.
Definition: Outliner.hxx:123
void SetLayoutName(const OUString &aName)
Definition: sdpage.cxx:2487
virtual OUString GetLayoutName() const override
Definition: sdpage.hxx:255
void SetName(const OUString &rName)
Set the name of the page and broadcast a model change.
Definition: sdpage.cxx:2703
virtual css::uno::Any SAL_CALL getByName(const OUString &aName) override
Definition: stlpool.cxx:1221
static void PutNumBulletItem(SfxStyleSheetBase *pSheet, vcl::Font &rBulletFont)
Definition: stlpool.cxx:1059
static vcl::Font GetBulletFont()
Definition: stlpool.cxx:1157
SD_DLLPUBLIC void CreateLayoutStyleSheets(std::u16string_view rLayoutName, bool bCheck=false)
creates all layout style sheets for the given layout name if they don't exist yet.
Definition: stlpool.cxx:172
const SdrPage * GetMasterPage(sal_uInt16 nPgNum) const
bool IsChanged() const
sal_uInt16 GetMasterPageCount() const
rtl::Reference< SfxItemPool > m_pItemPool
SfxStyleSheetBasePool * GetStyleSheetPool() const
const SdrPage * GetPage(sal_uInt16 nPgNum) const
rtl::Reference< SfxStyleSheetBasePool > mxStyleSheetPool
sal_uInt16 GetPageCount() const
SdrObject * Next()
bool IsMore() const
SdrObject * GetObj(size_t nNum) const
size_t GetObjCount() const
void BroadcastObjectChange() const
virtual SdrInventor GetObjInventor() const
virtual OutlinerParaObject * GetOutlinerParaObject() const
virtual SdrObjKind GetObjIdentifier() const
SdrPage & TRG_GetMasterPage() const
bool TRG_HasMasterPage() const
virtual OutlinerParaObject * GetOutlinerParaObject() const override
virtual void NbcSetOutlinerParaObject(std::optional< OutlinerParaObject > pTextObject) override
virtual SdrObjKind GetObjIdentifier() const override
bool HasItem(sal_uInt16 nWhich, const SfxPoolItem **ppItem=nullptr) const
const SfxPoolItem * Put(const SfxPoolItem &rItem, sal_uInt16 nWhich)
bool IsEnableSetModified() const
bool IsReadOnly() const
css::uno::Reference< css::frame::XModel3 > GetModel() const
void EnableSetModified(bool bEnable=true)
virtual bool SetName(const OUString &rNewName, bool bReindexNow=true)
const OUString & GetName() const
SfxStyleFamily GetFamily() const
virtual void SetHelpId(const OUString &r, sal_uLong nId)
virtual bool SetParent(const OUString &)
virtual SfxItemSet & GetItemSet()
void SetMask(SfxStyleSearchBits mask)
virtual SfxStyleSheetBase * Next()
virtual SfxStyleSheetBase * First()
static SAL_WARN_UNUSED_RESULT SfxViewFrame * Current()
void SetAdjust(const SvxAdjust eType)
void SetStart(sal_uInt16 nNew)
void SetStyle(SvxBulletStyle nNew)
void SetFont(const vcl::Font &rNew)
void SetScale(sal_uInt16 nNew)
void SetSymbol(sal_Unicode c)
void SetFamilyName(const OUString &rFamilyName)
sal_uInt16 GetLevelCount() const
void SetLevel(sal_uInt16 nLevel, const SvxNumberFormat &rFmt, bool bIsValid=true)
void SetStart(sal_uInt16 nSet)
void SetAbsLSpace(sal_Int32 nSet)
void SetBulletFont(const vcl::Font *pFont)
void SetBulletColor(Color nSet)
void SetNumAdjust(SvxAdjust eSet)
void SetBulletRelSize(sal_uInt16 nSet)
void SetFirstLineOffset(sal_Int32 nSet)
static OUString CreateRomanString(sal_Int32 nNo, bool bUpper)
void SetBulletChar(sal_UCS4 cSet)
void SetGradientValue(const basegfx::BGradient &rNew)
void append(const basegfx::B2DPoint &rPoint, sal_uInt32 nCount)
void setClosed(bool bNew)
void SetGradientStyle(css::awt::GradientStyle eNewStyle)
void SetColorStops(const basegfx::BColorStops &rSteps)
void SetEndIntens(sal_uInt16 nNewIntens)
void SetStartIntens(sal_uInt16 nNewIntens)
void SetAngle(Degree10 nNewAngle)
SdDrawDocument * GetDoc()
an instance of this guard disables modification of a document during its lifetime
Definition: drawdoc.hxx:705
bool mbIsEnableSetModified
Definition: drawdoc.hxx:715
DrawDocShell * mpDocShell
Definition: drawdoc.hxx:713
bool mbIsDocumentChanged
Definition: drawdoc.hxx:716
SdDrawDocument * mpDoc
Definition: drawdoc.hxx:714
static bool IsFuzzing()
void SetFontSize(const Size &)
FontFamily GetFamilyType()
const OUString & GetStyleName() const
const OUString & GetFamilyName() const
FontPitch GetPitch()
rtl_TextEncoding GetCharSet() const
constexpr ::Color COL_GRAY(0x80, 0x80, 0x80)
constexpr ::Color COL_WHITE(0xFF, 0xFF, 0xFF)
constexpr ::Color COL_AUTO(ColorTransparency, 0xFF, 0xFF, 0xFF, 0xFF)
constexpr ::Color COL_BLACK(0x00, 0x00, 0x00)
SVXCORE_DLLPUBLIC OUString SvxResId(TranslateId aId)
URL aURL
IMPL_LINK(SdDrawDocument, OnlineSpellEventHdl, EditStatus &, rEditStat, void)
Definition: drawdoc4.cxx:941
IMPL_LINK_NOARG(SdDrawDocument, OnlineSpellingHdl, Timer *, void)
Definition: drawdoc4.cxx:813
SpellCallbackCommand
EditStatusFlags
constexpr TypedWhichId< SvxContourItem > EE_CHAR_OUTLINE(EE_CHAR_START+8)
constexpr TypedWhichId< SvxFontItem > EE_CHAR_FONTINFO_CJK(EE_CHAR_START+17)
constexpr TypedWhichId< SvxUnderlineItem > EE_CHAR_UNDERLINE(EE_CHAR_START+5)
constexpr TypedWhichId< SvxAdjustItem > EE_PARA_JUST(EE_PARA_START+16)
constexpr TypedWhichId< SvxFontHeightItem > EE_CHAR_FONTHEIGHT(EE_CHAR_START+2)
constexpr TypedWhichId< SvxAutoKernItem > EE_CHAR_PAIRKERNING(EE_CHAR_START+11)
constexpr TypedWhichId< SvxShadowedItem > EE_CHAR_SHADOW(EE_CHAR_START+9)
constexpr TypedWhichId< SvxULSpaceItem > EE_PARA_ULSPACE(EE_PARA_START+14)
constexpr TypedWhichId< SvxOverlineItem > EE_CHAR_OVERLINE(EE_CHAR_START+29)
constexpr TypedWhichId< SvxLanguageItem > EE_CHAR_LANGUAGE_CTL(EE_CHAR_START+16)
constexpr TypedWhichId< SvxWeightItem > EE_CHAR_WEIGHT(EE_CHAR_START+4)
constexpr TypedWhichId< SvxLRSpaceItem > EE_PARA_LRSPACE(EE_PARA_START+13)
constexpr TypedWhichId< SvxColorItem > EE_CHAR_COLOR(EE_CHAR_START+0)
constexpr TypedWhichId< SvxWeightItem > EE_CHAR_WEIGHT_CTL(EE_CHAR_START+22)
constexpr TypedWhichId< SvxCrossedOutItem > EE_CHAR_STRIKEOUT(EE_CHAR_START+6)
constexpr TypedWhichId< SvxPostureItem > EE_CHAR_ITALIC(EE_CHAR_START+7)
constexpr TypedWhichId< SvxLineSpacingItem > EE_PARA_SBL(EE_PARA_START+15)
constexpr TypedWhichId< SvxEmphasisMarkItem > EE_CHAR_EMPHASISMARK(EE_CHAR_START+25)
constexpr TypedWhichId< SvxBulletItem > EE_PARA_BULLET(EE_PARA_START+12)
constexpr TypedWhichId< SvxFontHeightItem > EE_CHAR_FONTHEIGHT_CTL(EE_CHAR_START+20)
constexpr TypedWhichId< SvxWeightItem > EE_CHAR_WEIGHT_CJK(EE_CHAR_START+21)
constexpr TypedWhichId< SvxLanguageItem > EE_CHAR_LANGUAGE_CJK(EE_CHAR_START+15)
constexpr TypedWhichId< SvxFrameDirectionItem > EE_PARA_WRITINGDIR(EE_PARA_START+0)
constexpr TypedWhichId< SvxPostureItem > EE_CHAR_ITALIC_CJK(EE_CHAR_START+23)
constexpr TypedWhichId< SvxCaseMapItem > EE_CHAR_CASEMAP(EE_CHAR_START+30)
constexpr TypedWhichId< SvxFontItem > EE_CHAR_FONTINFO_CTL(EE_CHAR_START+18)
constexpr TypedWhichId< SvxPostureItem > EE_CHAR_ITALIC_CTL(EE_CHAR_START+24)
constexpr TypedWhichId< SvxLanguageItem > EE_CHAR_LANGUAGE(EE_CHAR_START+14)
constexpr TypedWhichId< SvxNumBulletItem > EE_PARA_NUMBULLET(EE_PARA_START+5)
constexpr TypedWhichId< SvxCharReliefItem > EE_CHAR_RELIEF(EE_CHAR_START+26)
constexpr TypedWhichId< SvxFontHeightItem > EE_CHAR_FONTHEIGHT_CJK(EE_CHAR_START+19)
constexpr TypedWhichId< SvxFontItem > EE_CHAR_FONTINFO(EE_CHAR_START+1)
LINESTYLE_NONE
STRIKEOUT_NONE
ITALIC_NONE
WEIGHT_BOLD
WEIGHT_NORMAL
SvxFrameDirection
constexpr OUStringLiteral SD_LT_SEPARATOR
Definition: glob.hxx:49
OUString aName
Mode eMode
#define LANGUAGE_THAI
sal_uInt16 nPos
#define LINE_SPACE_DEFAULT_HEIGHT
Reference< XComponentContext > getProcessComponentContext()
int i
#define SVX_MAX_NUM
OutlinerMode
SdrOnOffItem makeSdrTextWordWrapItem(bool bAuto)
OUString SdResId(TranslateId aId)
Definition: sdmod.cxx:83
XColorItem makeSdrShadowColorItem(const Color &rTheColor)
SdrOnOffItem makeSdrShadowItem(bool bShadow)
SdrMetricItem makeSdrShadowXDistItem(tools::Long nDist)
SdrMetricItem makeSdrShadowYDistItem(tools::Long nDist)
SDRTEXTHORZADJUST_BLOCK
SdrMetricItem makeSdrTextUpperDistItem(tools::Long mnHeight)
SdrMetricItem makeSdrTextRightDistItem(tools::Long mnHeight)
SdrMetricItem makeSdrTextLowerDistItem(tools::Long mnHeight)
SdrMetricItem makeSdrTextLeftDistItem(tools::Long mnHeight)
static SfxItemSet & rSet
constexpr OUStringLiteral STR_LAYOUT_OUTLINE
Definition: strings.hxx:16
SpellCallbackCommand nCommand
OUString aName
Definition: drawdoc.hxx:85
OUString aNewName
Definition: drawdoc.hxx:86
SfxStyleFamily nNewFamily
Definition: drawdoc.hxx:84
SfxStyleFamily nFamily
Definition: drawdoc.hxx:83
SfxStyleSearchBits
constexpr TypedWhichId< SdrYesNoItem > SDRATTR_MEASURESHOWUNIT(SDRATTR_MEASURE_FIRST+14)
SVXCORE_DLLPUBLIC SdrTextObj * DynCastSdrTextObj(SdrObject *)
SVX_NUM_CHAR_SPECIAL
sal_uInt16 sal_Unicode
#define COL_DEFAULT_SHAPE_FILLING
#define COL_DEFAULT_SHAPE_STROKE