update emoji autocorrect entries from po-files
[LibreOffice.git] / sd / source / core / drawdoc4.cxx
blobb9b4558adf4fa18739e289f68e6eed334ce7ddbf
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 <com/sun/star/container/XNameAccess.hpp>
25 #include <i18nlangtag/mslangid.hxx>
26 #include <sfx2/docfile.hxx>
27 #include <sfx2/dispatch.hxx>
28 #include "Outliner.hxx"
29 #include <comphelper/processfactory.hxx>
30 #include <editeng/outliner.hxx>
32 #include "../ui/inc/DrawDocShell.hxx"
33 #include <editeng/eeitem.hxx>
35 #include <vcl/settings.hxx>
36 #include <vcl/svapp.hxx>
38 #include <editeng/autokernitem.hxx>
40 #include <svx/svxids.hrc>
41 #include <svl/srchitem.hxx>
42 #include <editeng/lrspitem.hxx>
43 #include <editeng/ulspitem.hxx>
44 #include <editeng/lspcitem.hxx>
45 #include <editeng/adjustitem.hxx>
46 #include <editeng/numdef.hxx>
47 #include <svx/dialogs.hrc>
48 #include <svx/dialmgr.hxx>
49 #include <editeng/bulletitem.hxx>
50 #include <svx/xtable.hxx>
51 #include <svx/sxmsuitm.hxx>
52 #include <editeng/borderline.hxx>
53 #include <editeng/boxitem.hxx>
54 #include <svx/xit.hxx>
55 #include <svx/xlineit0.hxx>
56 #include <svx/sdshitm.hxx>
57 #include <svx/svdotext.hxx>
58 #include <svx/xfillit0.hxx>
59 #include <svx/sdshcitm.hxx>
60 #include <editeng/editstat.hxx>
61 #include <editeng/colritem.hxx>
62 #include <editeng/fhgtitem.hxx>
63 #include <editeng/wghtitem.hxx>
64 #include <editeng/postitem.hxx>
65 #include <editeng/crossedoutitem.hxx>
66 #include <editeng/udlnitem.hxx>
67 #include <editeng/contouritem.hxx>
68 #include <editeng/emphasismarkitem.hxx>
69 #include <editeng/fontitem.hxx>
70 #include <editeng/shdditem.hxx>
71 #include <editeng/cmapitem.hxx>
72 #include <svx/xbtmpit.hxx>
73 #include <svx/xflhtit.hxx>
74 #include <svx/xflgrit.hxx>
75 #include <svx/xflclit.hxx>
76 #include <svx/xlnedcit.hxx>
77 #include <svx/xlnstcit.hxx>
78 #include <svx/xlnedwit.hxx>
79 #include <svx/xlnstwit.hxx>
80 #include <svx/xlnedit.hxx>
81 #include <editeng/charreliefitem.hxx>
82 #include <svx/xlnstit.hxx>
83 #include <svx/xlndsit.hxx>
84 #include <svx/xlnwtit.hxx>
85 #include <svx/xlnclit.hxx>
86 #include <svx/svditer.hxx>
87 #include <svx/svdogrp.hxx>
88 #include <tools/shl.hxx>
89 #include <editeng/numitem.hxx>
90 #include <editeng/editeng.hxx>
91 #include <editeng/unolingu.hxx>
92 #include <com/sun/star/linguistic2/XHyphenator.hpp>
93 #include <com/sun/star/lang/XMultiServiceFactory.hpp>
94 #include <svl/itempool.hxx>
95 #include <editeng/outlobj.hxx>
96 #include <sfx2/viewfrm.hxx>
97 #include <editeng/langitem.hxx>
98 #include <editeng/frmdiritem.hxx>
100 #include "sdresid.hxx"
101 #include "drawdoc.hxx"
102 #include "sdpage.hxx"
103 #include "glob.hrc"
104 #include "glob.hxx"
105 #include "stlpool.hxx"
106 #include "helpids.h"
107 #include "sdiocmpt.hxx"
108 #include "shapelist.hxx"
109 #include <basegfx/point/b2dpoint.hxx>
110 #include <basegfx/polygon/b2dpolygon.hxx>
111 #include <svl/itemset.hxx>
112 #include "app.hrc"
114 using namespace ::com::sun::star;
115 using namespace ::com::sun::star::uno;
116 using namespace ::com::sun::star::lang;
117 using namespace ::com::sun::star::style;
118 using namespace ::com::sun::star::container;
119 using namespace ::com::sun::star::linguistic2;
120 using namespace ::sd;
122 // CreateLayoutTemplates
123 // At the moment (31.03.1995), the StyleSheetPool only saves styleheets that
124 // have an ItemSet. To save all stylesheets, we force the creation of an ItemSet
125 // with a GetItemSet call.
126 // We can remove this behavior once the pool saves styleheets even without an ItemSet
127 void SdDrawDocument::CreateLayoutTemplates()
129 SdStyleSheetPool* pSSPool = static_cast<SdStyleSheetPool*>(GetStyleSheetPool());
130 SfxStyleSheetBase* pSheet = NULL;
131 OUString aHelpFile;
132 OUString aStdName(SD_RESSTR(STR_STANDARD_STYLESHEET_NAME));
134 // Default style
136 sal_uInt16 nMask = SFXSTYLEBIT_AUTO;
138 OUString aName(aStdName);
139 pSheet = &(pSSPool->Make(aName, SD_STYLE_FAMILY_GRAPHICS, nMask));
140 pSheet->SetHelpId( aHelpFile, HID_STANDARD_STYLESHEET_NAME );
141 SfxItemSet& rISet = pSheet->GetItemSet();
142 SfxItemPool* pPool = rISet.GetPool();
144 ::basegfx::B2DPolyPolygon aNullPolyPolygon;
145 Color aNullCol(RGB_Color(COL_DEFAULT_SHAPE_STROKE));
147 XDash aNullDash;
148 XGradient aNullGrad(aNullCol,RGB_Color(COL_WHITE));
149 aNullGrad.SetStartIntens( 100 );
150 aNullGrad.SetEndIntens( 100 );
151 XHatch aNullHatch(aNullCol);
153 // Line attributes (Extended OutputDevice)
154 rISet.Put(XLineStyleItem(drawing::LineStyle_SOLID));
155 rISet.Put(XLineColorItem(OUString(), RGB_Color(COL_DEFAULT_SHAPE_STROKE)));
156 rISet.Put(XLineWidthItem(0));
157 rISet.Put(XLineDashItem(pPool,aNullDash));
158 rISet.Put(XLineStartItem(pPool,aNullPolyPolygon));
159 rISet.Put(XLineEndItem(pPool,aNullPolyPolygon));
160 rISet.Put(XLineStartWidthItem(200));
161 rISet.Put(XLineEndWidthItem(200));
162 rISet.Put(XLineStartCenterItem());
163 rISet.Put(XLineEndCenterItem());
164 rISet.Put(SdrTextHorzAdjustItem(SDRTEXTHORZADJUST_BLOCK));
166 // Fill attributes (Extended OutputDevice)
167 rISet.Put(XFillStyleItem(drawing::FillStyle_SOLID));
168 rISet.Put(XFillColorItem(OUString(), RGB_Color(COL_DEFAULT_SHAPE_FILLING)));
170 rISet.Put( XFillGradientItem( aNullGrad) );
171 rISet.Put(XFillHatchItem(pPool,aNullHatch));
172 Size aNullSize( 32, 32 );
173 Color aNullColor( COL_WHITE );
174 Bitmap aNullBmp( aNullSize, 8 );
175 aNullBmp.Erase( aNullColor );
176 rISet.Put(XFillBitmapItem(pPool, Graphic(aNullBmp)));
178 // Shadow attributes (Drawing Engine)
179 rISet.Put(makeSdrShadowItem(false));
180 rISet.Put(makeSdrShadowColorItem(RGB_Color(COL_GRAY)));
181 rISet.Put(makeSdrShadowXDistItem(200)); // 3 mm Shadow distance
182 rISet.Put(makeSdrShadowYDistItem(200));
184 vcl::Font aLatinFont, aCJKFont, aCTLFont;
186 getDefaultFonts( aLatinFont, aCJKFont, aCTLFont );
188 SvxFontItem aSvxFontItem( aLatinFont.GetFamily(), aLatinFont.GetName(), aLatinFont.GetStyleName(), aLatinFont.GetPitch(),
189 aLatinFont.GetCharSet(), EE_CHAR_FONTINFO );
191 SvxFontItem aSvxFontItemCJK( aCJKFont.GetFamily(), aCJKFont.GetName(), aCJKFont.GetStyleName(), aCJKFont.GetPitch(),
192 aCJKFont.GetCharSet(), EE_CHAR_FONTINFO_CJK );
194 SvxFontItem aSvxFontItemCTL( aCTLFont.GetFamily(), aCTLFont.GetName(), aCTLFont.GetStyleName(), aCTLFont.GetPitch(),
195 aCTLFont.GetCharSet(), EE_CHAR_FONTINFO_CTL );
197 rISet.Put( aSvxFontItem );
198 rISet.Put( aSvxFontItemCJK );
199 rISet.Put( aSvxFontItemCTL );
201 rISet.Put( SvxFontHeightItem( 635, 100, EE_CHAR_FONTHEIGHT ) ); // sj: (i33745) changed default from 24 to 18 pt
202 rISet.Put( SvxFontHeightItem( 635, 100, EE_CHAR_FONTHEIGHT_CJK ) ); // 18 pt
203 rISet.Put( SvxFontHeightItem( convertFontHeightToCTL( 635 ), 100, EE_CHAR_FONTHEIGHT_CTL ) ); // 18 pt
205 rISet.Put( SvxWeightItem( WEIGHT_NORMAL, EE_CHAR_WEIGHT ) );
206 rISet.Put( SvxWeightItem( WEIGHT_NORMAL, EE_CHAR_WEIGHT_CJK ) );
207 rISet.Put( SvxWeightItem( WEIGHT_NORMAL, EE_CHAR_WEIGHT_CTL ) );
209 rISet.Put( SvxPostureItem( ITALIC_NONE, EE_CHAR_ITALIC ) );
210 rISet.Put( SvxPostureItem( ITALIC_NONE, EE_CHAR_ITALIC_CJK ) );
211 rISet.Put( SvxPostureItem( ITALIC_NONE, EE_CHAR_ITALIC_CTL ) );
213 rISet.Put(SvxContourItem(false, EE_CHAR_OUTLINE ));
214 rISet.Put(SvxShadowedItem(false, EE_CHAR_SHADOW ));
215 rISet.Put(SvxUnderlineItem(UNDERLINE_NONE, EE_CHAR_UNDERLINE));
216 rISet.Put(SvxOverlineItem(UNDERLINE_NONE, EE_CHAR_OVERLINE));
217 rISet.Put(SvxCrossedOutItem(STRIKEOUT_NONE, EE_CHAR_STRIKEOUT ));
218 rISet.Put(SvxCaseMapItem(SVX_CASEMAP_NOT_MAPPED, EE_CHAR_CASEMAP ));
219 rISet.Put(SvxEmphasisMarkItem(EMPHASISMARK_NONE, EE_CHAR_EMPHASISMARK));
220 rISet.Put(SvxCharReliefItem(RELIEF_NONE, EE_CHAR_RELIEF));
221 rISet.Put(SvxColorItem(Color(COL_AUTO), EE_CHAR_COLOR ));
223 // Paragraph attributes (Edit Engine)
224 rISet.Put(SvxLRSpaceItem(EE_PARA_LRSPACE));
225 rISet.Put(SvxULSpaceItem(EE_PARA_ULSPACE));
227 rISet.Put( makeSdrTextLeftDistItem( 250 ) ); // sj: (i33745) using text frame distances seems to be a better default
228 rISet.Put( makeSdrTextRightDistItem( 250 ) );
229 rISet.Put( makeSdrTextUpperDistItem( 125 ) );
230 rISet.Put( makeSdrTextLowerDistItem( 125 ) );
232 rISet.Put( SvxLineSpacingItem( LINE_SPACE_DEFAULT_HEIGHT, EE_PARA_SBL ) );
234 // #i16874# enable kerning by default but only for new documents
235 rISet.Put( SvxAutoKernItem( true, EE_CHAR_PAIRKERNING ) );
237 // Bullet
238 // BulletItem and BulletFont for title and outline
239 SvxBulletItem aBulletItem(EE_PARA_BULLET);
240 // Identical in all layers
241 aBulletItem.SetStyle(SvxBulletStyle::BULLET);
242 aBulletItem.SetStart(1);
243 aBulletItem.SetScale(45); // In percent
245 vcl::Font aBulletFont( SdStyleSheetPool::GetBulletFont() );
247 aBulletFont.SetSize(Size(0,635)); // sj: (i33745) changed default from 24 to 18 pt
249 aBulletItem.SetFont(aBulletFont);
250 aBulletItem.SetSymbol( 0x25CF ); // In points
251 rISet.Put(aBulletItem);
253 // New BulletItem
254 SdStyleSheetPool::PutNumBulletItem( pSheet, aBulletFont );
256 SfxItemSet* pISet = NULL;
258 // Object with arrowhead
259 aName = SD_RESSTR(STR_POOLSHEET_OBJWITHARROW);
260 pSheet = &(pSSPool->Make(aName, SD_STYLE_FAMILY_GRAPHICS, nMask));
261 pSheet->SetParent(aStdName);
262 pSheet->SetHelpId( aHelpFile, HID_POOLSHEET_OBJWITHARROW );
263 pISet = &pSheet->GetItemSet();
265 pISet->Put(XLineStyleItem(drawing::LineStyle_SOLID));
266 pISet->Put(XLineColorItem(OUString(), RGB_Color(COL_BLACK)));
267 pISet->Put(XLineWidthItem(150));
269 ::basegfx::B2DPolygon aArrow;
270 aArrow.append(::basegfx::B2DPoint(10.0, 0.0));
271 aArrow.append(::basegfx::B2DPoint(0.0, 30.0));
272 aArrow.append(::basegfx::B2DPoint(20.0, 30.0));
273 aArrow.setClosed(true);
274 pISet->Put(XLineStartItem(SVX_RESSTR(RID_SVXSTR_ARROW),::basegfx::B2DPolyPolygon(aArrow)));
276 pISet->Put(XLineStartWidthItem(700));
277 pISet->Put(XLineEndWidthItem(300));
278 pISet->Put(XLineStartCenterItem(true));
280 // Object with Shadow
281 aName = SD_RESSTR(STR_POOLSHEET_OBJWITHSHADOW);
282 pSheet = &(pSSPool->Make(aName, SD_STYLE_FAMILY_GRAPHICS, nMask));
283 pSheet->SetParent(aStdName);
284 pSheet->SetHelpId( aHelpFile, HID_POOLSHEET_OBJWITHSHADOW );
285 pISet = &pSheet->GetItemSet();
287 pISet->Put(makeSdrShadowItem(true));
288 pISet->Put(makeSdrShadowColorItem(RGB_Color(COL_GRAY)));
289 pISet->Put(makeSdrShadowXDistItem(200)); // 3 mm shadow distance
290 pISet->Put(makeSdrShadowYDistItem(200));
292 // Object without fillung
293 aName = SD_RESSTR(STR_POOLSHEET_OBJWITHOUTFILL);
294 pSheet = &(pSSPool->Make(aName, SD_STYLE_FAMILY_GRAPHICS, nMask));
295 pSheet->SetParent(aStdName);
296 pSheet->SetHelpId( aHelpFile, HID_POOLSHEET_OBJWITHOUTFILL );
297 pISet = &pSheet->GetItemSet();
299 pISet->Put(XFillStyleItem(drawing::FillStyle_NONE));
300 pISet->Put(XLineColorItem(OUString(), RGB_Color(COL_BLACK)));
302 // Object no fill no line
304 aName = SD_RESSTR(STR_POOLSHEET_OBJNOLINENOFILL);
305 pSheet = &(pSSPool->Make(aName, SD_STYLE_FAMILY_GRAPHICS, nMask));
306 pSheet->SetParent(aStdName);
307 pSheet->SetHelpId( aHelpFile, HID_POOLSHEET_OBJNOLINENOFILL );
308 pISet = &pSheet->GetItemSet();
310 pISet->Put(XFillStyleItem(drawing::FillStyle_NONE));
311 pISet->Put(XLineStyleItem(drawing::LineStyle_NONE));
313 // Text
315 aName = SD_RESSTR(STR_POOLSHEET_TEXT);
316 pSheet = &(pSSPool->Make(aName, SD_STYLE_FAMILY_GRAPHICS, nMask));
317 pSheet->SetParent(aStdName);
318 pSheet->SetHelpId( aHelpFile, HID_POOLSHEET_TEXT );
319 pISet = &pSheet->GetItemSet();
321 pISet->Put(XLineStyleItem(drawing::LineStyle_NONE));
322 pISet->Put(XFillStyleItem(drawing::FillStyle_NONE));
324 // Text body
325 aName = SD_RESSTR(STR_POOLSHEET_TEXTBODY);
326 pSheet = &(pSSPool->Make(aName, SD_STYLE_FAMILY_GRAPHICS, nMask));
327 pSheet->SetParent(aStdName);
328 pSheet->SetHelpId( aHelpFile, HID_POOLSHEET_TEXTBODY );
329 pISet = &pSheet->GetItemSet();
331 pISet->Put(XLineStyleItem(drawing::LineStyle_NONE));
332 pISet->Put(XFillStyleItem(drawing::FillStyle_NONE));
334 pISet->Put(SvxFontHeightItem(564, 100, EE_CHAR_FONTHEIGHT)); // 16 pt
336 // Text body, justified
337 aName = SD_RESSTR(STR_POOLSHEET_TEXTBODY_JUSTIFY);
338 pSheet = &(pSSPool->Make(aName, SD_STYLE_FAMILY_GRAPHICS, nMask));
339 pSheet->SetParent(aStdName);
340 pSheet->SetHelpId( aHelpFile, HID_POOLSHEET_TEXTBODY_JUSTIFY );
341 pISet = &pSheet->GetItemSet();
343 pISet->Put(XLineStyleItem(drawing::LineStyle_NONE));
344 pISet->Put(XFillStyleItem(drawing::FillStyle_NONE));
346 pISet->Put(SvxAdjustItem(SVX_ADJUST_BLOCK, EE_PARA_JUST ));
348 // Text body, indented
349 aName = SD_RESSTR(STR_POOLSHEET_TEXTBODY_INDENT);
350 pSheet = &(pSSPool->Make(aName, SD_STYLE_FAMILY_GRAPHICS, nMask));
351 pSheet->SetParent(aStdName);
352 pSheet->SetHelpId( aHelpFile, HID_POOLSHEET_TEXTBODY_INDENT );
353 pISet = &pSheet->GetItemSet();
355 pISet->Put(XLineStyleItem(drawing::LineStyle_NONE));
356 pISet->Put(XFillStyleItem(drawing::FillStyle_NONE));
358 SvxLRSpaceItem aLRSpaceItem( EE_PARA_LRSPACE );
359 aLRSpaceItem.SetTextFirstLineOfst(600); // Indentation of first line: 6mm; right: 0
360 pISet->Put(aLRSpaceItem);
362 // Title
364 aName = SD_RESSTR(STR_POOLSHEET_TITLE);
365 pSheet = &(pSSPool->Make(aName, SD_STYLE_FAMILY_GRAPHICS, nMask));
366 pSheet->SetParent(aStdName);
367 pSheet->SetHelpId( aHelpFile, HID_POOLSHEET_TITLE );
368 pISet = &pSheet->GetItemSet();
370 pISet->Put(XLineStyleItem(drawing::LineStyle_NONE));
371 pISet->Put(XFillStyleItem(drawing::FillStyle_NONE));
373 pISet->Put(SvxFontHeightItem(1551, 100, EE_CHAR_FONTHEIGHT )); // 44 pt
375 // Title1
376 aName = SD_RESSTR(STR_POOLSHEET_TITLE1);
377 pSheet = &(pSSPool->Make(aName, SD_STYLE_FAMILY_GRAPHICS, nMask));
378 pSheet->SetParent(aStdName);
379 pSheet->SetHelpId( aHelpFile, HID_POOLSHEET_TITLE1 );
380 pISet = &pSheet->GetItemSet();
382 pISet->Put(XLineStyleItem(drawing::LineStyle_NONE));
383 pISet->Put(XFillStyleItem(drawing::FillStyle_SOLID));
384 pISet->Put(XFillColorItem(OUString(), RGB_Color(COL_CYAN)));
386 pISet->Put(makeSdrShadowItem(true));
387 pISet->Put(makeSdrShadowColorItem(RGB_Color(COL_GRAY)));
388 pISet->Put(makeSdrShadowXDistItem(200)); // 2 mm shadow distance
389 pISet->Put(makeSdrShadowYDistItem(200));
391 pISet->Put(SvxFontHeightItem(846, 100, EE_CHAR_FONTHEIGHT )); // 24 pt
393 pISet->Put(SvxAdjustItem(SVX_ADJUST_CENTER, EE_PARA_JUST ));
395 // Title2
397 aName = SD_RESSTR(STR_POOLSHEET_TITLE2);
398 pSheet = &(pSSPool->Make(aName, SD_STYLE_FAMILY_GRAPHICS, nMask));
399 pSheet->SetParent(aStdName);
400 pSheet->SetHelpId( aHelpFile, HID_POOLSHEET_TITLE2 );
401 pISet = &pSheet->GetItemSet();
403 pISet->Put(XLineWidthItem(50));
405 // Don't get color from the color table, because the color might have been
406 // deleted or changed there
407 Color aOrange4(255, 204, 153);
408 pISet->Put(XFillColorItem(OUString(), aOrange4));
410 pISet->Put(makeSdrShadowItem(true));
411 pISet->Put(makeSdrShadowColorItem(RGB_Color(COL_GRAY)));
412 pISet->Put(makeSdrShadowXDistItem(200)); // 2 mm shadow distance
413 pISet->Put(makeSdrShadowYDistItem(200));
415 pISet->Put(SvxFontHeightItem(1270, 100, EE_CHAR_FONTHEIGHT )); // 36 pt
417 SvxLRSpaceItem aLRSpItem( 200, 200, 0, 0, EE_PARA_LRSPACE);
418 pISet->Put( aLRSpItem ); // Indentation of first line: 0 mm; left and right: 2 mm
420 pISet->Put(SvxULSpaceItem(100, 100, EE_PARA_ULSPACE )); // Paragraph margin above/below: 1 mm
422 pISet->Put(SvxAdjustItem(SVX_ADJUST_CENTER, EE_PARA_JUST ));
424 // Headline
426 aName = SD_RESSTR(STR_POOLSHEET_HEADLINE);
427 pSheet = &(pSSPool->Make(aName, SD_STYLE_FAMILY_GRAPHICS, nMask));
428 pSheet->SetParent(aStdName);
429 pSheet->SetHelpId( aHelpFile, HID_POOLSHEET_HEADLINE );
430 pISet = &pSheet->GetItemSet();
432 pISet->Put(XLineStyleItem(drawing::LineStyle_NONE));
433 pISet->Put(XFillStyleItem(drawing::FillStyle_NONE));
435 pISet->Put(SvxFontHeightItem(846, 100, EE_CHAR_FONTHEIGHT )); // 24 pt
437 pISet->Put(SvxULSpaceItem(420, 210, EE_PARA_ULSPACE )); // Paragraph margin above: 4,2 mm,
438 // Paragraph margin below: 2,1 mm
440 // Headline1
441 aName = SD_RESSTR(STR_POOLSHEET_HEADLINE1);
442 pSheet = &(pSSPool->Make(aName, SD_STYLE_FAMILY_GRAPHICS, nMask));
443 pSheet->SetParent(aStdName);
444 pSheet->SetHelpId( aHelpFile, HID_POOLSHEET_HEADLINE1 );
445 pISet = &pSheet->GetItemSet();
447 pISet->Put(XLineStyleItem(drawing::LineStyle_NONE));
448 pISet->Put(XFillStyleItem(drawing::FillStyle_NONE));
450 pISet->Put(SvxWeightItem(WEIGHT_BOLD, EE_CHAR_WEIGHT ));
452 pISet->Put(SvxFontHeightItem(635, 100, EE_CHAR_FONTHEIGHT )); // 18 pt
454 pISet->Put(SvxULSpaceItem(420, 210, EE_PARA_ULSPACE )); // Paragraph margin above: 4,2 mm,
455 // Paragraph margin below: 2,1 mm
457 // Headline2
458 aName = SD_RESSTR(STR_POOLSHEET_HEADLINE2);
459 pSheet = &(pSSPool->Make(aName, SD_STYLE_FAMILY_GRAPHICS, nMask));
460 pSheet->SetParent(aStdName);
461 pSheet->SetHelpId( aHelpFile, HID_POOLSHEET_HEADLINE2 );
462 pISet = &pSheet->GetItemSet();
464 pISet->Put(XLineStyleItem(drawing::LineStyle_NONE));
465 pISet->Put(XFillStyleItem(drawing::FillStyle_NONE));
467 pISet->Put(SvxPostureItem(ITALIC_NORMAL, EE_CHAR_ITALIC ));
468 pISet->Put(SvxWeightItem(WEIGHT_BOLD, EE_CHAR_WEIGHT));
470 pISet->Put(SvxFontHeightItem(494, 100, EE_CHAR_FONTHEIGHT )); // 14 pt
472 pISet->Put(SvxULSpaceItem(420, 210, EE_PARA_ULSPACE )); // Paragraph margin above: 4,2 mm,
473 // Paragraph margin below: 2,1 mm
475 // Measurements
476 aName = SD_RESSTR(STR_POOLSHEET_MEASURE);
477 pSheet = &(pSSPool->Make(aName, SD_STYLE_FAMILY_GRAPHICS, nMask));
478 pSheet->SetParent(aStdName);
479 pSheet->SetHelpId( aHelpFile, HID_POOLSHEET_MEASURE );
480 pISet = &pSheet->GetItemSet();
482 pISet->Put(XFillStyleItem(drawing::FillStyle_NONE));
483 pISet->Put(XLineColorItem(OUString(), RGB_Color(COL_BLACK)));
485 pISet->Put(SvxFontHeightItem(423, 100, EE_CHAR_FONTHEIGHT )); // 12 pt
487 pISet->Put(XLineStartItem(SVX_RESSTR(RID_SVXSTR_ARROW),::basegfx::B2DPolyPolygon(aArrow)));
488 pISet->Put(XLineStartWidthItem(200));
489 pISet->Put(XLineEndItem(SVX_RESSTR(RID_SVXSTR_ARROW),::basegfx::B2DPolyPolygon(aArrow)));
490 pISet->Put(XLineEndWidthItem(200));
491 pISet->Put(XLineStyleItem(drawing::LineStyle_SOLID));
492 pISet->Put(makeSdrMeasureShowUnitItem(true));
494 // Generate presentation templates for default layout.
495 OUString aPrefix = SD_RESSTR(STR_LAYOUT_DEFAULT_NAME);
496 pSSPool->CreateLayoutStyleSheets(aPrefix);
499 static Any implMakeSolidCellStyle( SdStyleSheetPool* pSSPool, const OUString& rName, const OUString& rParent, const Color& rColor )
501 SfxStyleSheetBase* pSheet = &(pSSPool->Make(rName, SD_STYLE_FAMILY_CELL, SFXSTYLEBIT_AUTO));
502 pSheet->SetParent(rParent);
503 SfxItemSet* pISet = &pSheet->GetItemSet();
504 pISet->Put(XFillStyleItem(drawing::FillStyle_SOLID));
505 pISet->Put(XFillColorItem(OUString(), rColor));
507 return Any( Reference< XStyle >( static_cast< XWeak* >( pSheet ), UNO_QUERY ) );
510 static void implCreateTableTemplate( const Reference< XNameContainer >& xTableFamily, const OUString& rName, const Any& rBody, const Any& rHeading, const Any& rBanding )
512 if( xTableFamily.is() ) try
514 if( !xTableFamily->hasByName( OUString( rName ) ) )
516 Reference< XSingleServiceFactory > xFactory( xTableFamily, UNO_QUERY_THROW );
517 Reference< XNameReplace > xDefaultTableStyle( xFactory->createInstance(), UNO_QUERY_THROW );
518 xTableFamily->insertByName( OUString( rName ), Any( xDefaultTableStyle ) );
520 xDefaultTableStyle->replaceByName( "body", rBody );
521 xDefaultTableStyle->replaceByName( "odd-rows" , rBanding );
522 xDefaultTableStyle->replaceByName( "odd-columns" , rBanding );
523 xDefaultTableStyle->replaceByName( "first-row" , rHeading );
524 xDefaultTableStyle->replaceByName( "first-column" , rHeading );
525 xDefaultTableStyle->replaceByName( "last-row" , rHeading );
526 xDefaultTableStyle->replaceByName( "last-column" , rHeading );
529 catch( Exception& )
531 OSL_FAIL("sd::implCreateTableTemplate(), exception caught!");
535 void SdDrawDocument::CreateDefaultCellStyles()
537 SdStyleSheetPool* pSSPool = static_cast< SdStyleSheetPool* >(GetStyleSheetPool());
538 SfxStyleSheetBase* pSheet = NULL;
539 OUString aHelpFile;
541 Reference< XNameContainer > xTableFamily( pSSPool->getByName( "table" ), UNO_QUERY );
543 // ---- Default -----------------------------------------------
545 sal_uInt16 nMask = SFXSTYLEBIT_AUTO;
547 OUString aDefaultCellStyleName( "default" );
549 pSheet = &(pSSPool->Make(aDefaultCellStyleName, SD_STYLE_FAMILY_CELL, nMask));
550 pSheet->SetHelpId( aHelpFile, HID_SD_CELL_STYLE_DEFAULT );
551 SfxItemSet& rISet = pSheet->GetItemSet();
553 Color aNullCol(RGB_Color(COL_BLACK));
555 XDash aNullDash;
556 XGradient aNullGrad(aNullCol,RGB_Color(COL_WHITE));
557 aNullGrad.SetStartIntens( 100 );
558 aNullGrad.SetEndIntens( 100 );
559 XHatch aNullHatch(aNullCol);
561 rISet.Put(XFillStyleItem(drawing::FillStyle_SOLID));
562 rISet.Put(XFillColorItem(OUString(), RGB_Color(0x00ccccff)));
564 vcl::Font aLatinFont, aCJKFont, aCTLFont;
566 getDefaultFonts( aLatinFont, aCJKFont, aCTLFont );
568 SvxFontItem aSvxFontItem( aLatinFont.GetFamily(), aLatinFont.GetName(), aLatinFont.GetStyleName(), aLatinFont.GetPitch(),
569 aLatinFont.GetCharSet(), EE_CHAR_FONTINFO );
571 SvxFontItem aSvxFontItemCJK( aCJKFont.GetFamily(), aCJKFont.GetName(), aCJKFont.GetStyleName(), aCJKFont.GetPitch(),
572 aCJKFont.GetCharSet(), EE_CHAR_FONTINFO_CJK );
574 SvxFontItem aSvxFontItemCTL( aCTLFont.GetFamily(), aCTLFont.GetName(), aCTLFont.GetStyleName(), aCTLFont.GetPitch(),
575 aCTLFont.GetCharSet(), EE_CHAR_FONTINFO_CTL );
577 rISet.Put( aSvxFontItem );
578 rISet.Put( aSvxFontItemCJK );
579 rISet.Put( aSvxFontItemCTL );
581 rISet.Put( SvxFontHeightItem( 635, 100, EE_CHAR_FONTHEIGHT ) ); // sj: (i33745) changed default from 24 to 18 pt
582 rISet.Put( SvxFontHeightItem( 635, 100, EE_CHAR_FONTHEIGHT_CJK ) ); // 18 pt
583 rISet.Put( SvxFontHeightItem( convertFontHeightToCTL( 635 ), 100, EE_CHAR_FONTHEIGHT_CTL ) ); // 18 pt
585 rISet.Put(SvxColorItem(Color(COL_AUTO), EE_CHAR_COLOR ));
587 // Paragraph attributes (Edit Engine)
588 rISet.Put(SvxLRSpaceItem(EE_PARA_LRSPACE));
589 rISet.Put(SvxULSpaceItem(EE_PARA_ULSPACE));
591 rISet.Put( makeSdrTextLeftDistItem( 250 ) );
592 rISet.Put( makeSdrTextRightDistItem( 250 ) );
593 rISet.Put( makeSdrTextUpperDistItem( 130 ) );
594 rISet.Put( makeSdrTextLowerDistItem( 130 ) );
596 rISet.Put( SvxLineSpacingItem( LINE_SPACE_DEFAULT_HEIGHT, EE_PARA_SBL ) );
597 rISet.Put( SvxAutoKernItem( true, EE_CHAR_PAIRKERNING ) );
598 rISet.Put( SdrTextVertAdjustItem(SDRTEXTVERTADJUST_TOP) );
599 rISet.Put( SdrTextHorzAdjustItem(SDRTEXTHORZADJUST_LEFT) );
601 Color aWhite( COL_WHITE );
602 ::editeng::SvxBorderLine aBorderLine(
603 &aWhite, 1, table::BorderLineStyle::SOLID);
605 SvxBoxItem aBoxItem( SDRATTR_TABLE_BORDER );
606 aBoxItem.SetLine( &aBorderLine, SvxBoxItemLine::TOP );
607 aBoxItem.SetLine( &aBorderLine, SvxBoxItemLine::BOTTOM );
608 aBoxItem.SetLine( &aBorderLine, SvxBoxItemLine::LEFT );
609 aBoxItem.SetLine( &aBorderLine, SvxBoxItemLine::RIGHT );
611 rISet.Put( aBoxItem );
613 // ---- default --------------------------------------------------
615 Any aGray1( implMakeSolidCellStyle( pSSPool, "gray1" , aDefaultCellStyleName, RGB_COLORDATA(230,230,230)));
616 Any aGray2( implMakeSolidCellStyle( pSSPool, "gray2" , aDefaultCellStyleName, RGB_COLORDATA(204,204,204)));
617 Any aGray3( implMakeSolidCellStyle( pSSPool, "gray3" , aDefaultCellStyleName, RGB_COLORDATA(179,179,179)));
619 implCreateTableTemplate( xTableFamily, "default" , aGray1, aGray3, aGray2 );
621 // ---- BW ------------------------------------------------
623 Any aBW1( implMakeSolidCellStyle( pSSPool, "bw1" , aDefaultCellStyleName, RGB_COLORDATA(255,255,255)));
624 Any aBW2( implMakeSolidCellStyle( pSSPool, "bw2" , aDefaultCellStyleName, RGB_COLORDATA(230,230,230)));
625 Any aBW3( implMakeSolidCellStyle( pSSPool, "bw3" , aDefaultCellStyleName, RGB_COLORDATA(0,0,0)));
627 implCreateTableTemplate( xTableFamily, "bw" , aBW1, aBW3, aBW2 );
629 // ---- Orange --------------------------------------------------
631 Any aOrange1( implMakeSolidCellStyle( pSSPool, "orange1" , aDefaultCellStyleName, RGB_COLORDATA(255,204,153)));
632 Any aOrange2( implMakeSolidCellStyle( pSSPool, "orange2" , aDefaultCellStyleName, RGB_COLORDATA(255,153,102)));
633 Any aOrange3( implMakeSolidCellStyle( pSSPool, "orange3" , aDefaultCellStyleName, RGB_COLORDATA(255,102,51)));
635 implCreateTableTemplate( xTableFamily, "orange" , aOrange1, aOrange3, aOrange2 );
637 // ---- Turquoise --------------------------------------------------
639 Any aTurquoise1( implMakeSolidCellStyle( pSSPool, "turquoise1" , aDefaultCellStyleName, RGB_COLORDATA(71,184,184)));
640 Any aTurquoise2( implMakeSolidCellStyle( pSSPool, "turquoise2" , aDefaultCellStyleName, RGB_COLORDATA(51,163,163)));
641 Any aTurquoise3( implMakeSolidCellStyle( pSSPool, "turquoise3" , aDefaultCellStyleName, RGB_COLORDATA(25,138,138)));
643 implCreateTableTemplate( xTableFamily, "turquoise" , aTurquoise1, aTurquoise3, aTurquoise2 );
645 // ---- Gray ------------------------------------------------
647 Any aBlue1( implMakeSolidCellStyle( pSSPool, "blue1" , aDefaultCellStyleName, RGB_COLORDATA(153,204,255)));
648 Any aBlue2( implMakeSolidCellStyle( pSSPool, "blue2" , aDefaultCellStyleName, RGB_COLORDATA(0,153,255)));
649 Any aBlue3( implMakeSolidCellStyle( pSSPool, "blue3" , aDefaultCellStyleName, RGB_COLORDATA(0,102,204)));
651 implCreateTableTemplate( xTableFamily, "blue" , aBlue1, aBlue3, aBlue2 );
653 // ---- Sun ------------------------------------------------
655 Any aSun1( implMakeSolidCellStyle( pSSPool, "sun1" , aDefaultCellStyleName, RGB_COLORDATA(230,230,255)));
656 Any aSun2( implMakeSolidCellStyle( pSSPool, "sun2" , aDefaultCellStyleName, RGB_COLORDATA(204,204,255)));
657 Any aSun3( implMakeSolidCellStyle( pSSPool, "sun3" , aDefaultCellStyleName, RGB_COLORDATA(153,153,255)));
659 implCreateTableTemplate( xTableFamily, "sun" , aSun1, aSun3, aSun2 );
661 // ---- Earth ----------------------------------------------
663 Any aEarth1( implMakeSolidCellStyle( pSSPool, "earth1" , aDefaultCellStyleName, RGB_COLORDATA(255,255,204)));
664 Any aEarth2( implMakeSolidCellStyle( pSSPool, "earth2" , aDefaultCellStyleName, RGB_COLORDATA(255,204,153)));
665 Any aEarth3( implMakeSolidCellStyle( pSSPool, "earth3" , aDefaultCellStyleName, RGB_COLORDATA(204,102,51)));
667 implCreateTableTemplate( xTableFamily, "earth" , aEarth1, aEarth3, aEarth2 );
669 // ---- Green ----------------------------------------------
671 Any aGreen1( implMakeSolidCellStyle( pSSPool, "green1" , aDefaultCellStyleName, RGB_COLORDATA(255,255,204)));
672 Any aGreen2( implMakeSolidCellStyle( pSSPool, "green2" , aDefaultCellStyleName, RGB_COLORDATA(148,189,94)));
673 Any aGreen3( implMakeSolidCellStyle( pSSPool, "green3" , aDefaultCellStyleName, RGB_COLORDATA(92,133,38)));
675 implCreateTableTemplate( xTableFamily, "green" , aGreen1, aGreen3, aGreen2 );
677 // ---- Seaweed ----------------------------------------------
679 Any aSeetang1( implMakeSolidCellStyle( pSSPool, "seetang1" , aDefaultCellStyleName, RGB_COLORDATA(204,255,255)));
680 Any aSeetang2( implMakeSolidCellStyle( pSSPool, "seetang2" , aDefaultCellStyleName, RGB_COLORDATA(71,184,184)));
681 Any aSeetang3( implMakeSolidCellStyle( pSSPool, "seetang3" , aDefaultCellStyleName, RGB_COLORDATA(51,163,163)));
683 implCreateTableTemplate( xTableFamily, "seetang" , aSeetang1, aSeetang3, aSeetang2 );
685 // ---- LightBlue ----------------------------------------------
687 Any aLightBlue1( implMakeSolidCellStyle( pSSPool, "lightblue1" , aDefaultCellStyleName, RGB_COLORDATA(255,255,255)));
688 Any aLightBlue2( implMakeSolidCellStyle( pSSPool, "lightblue2" , aDefaultCellStyleName, RGB_COLORDATA(230,230,255)));
689 Any aLightBlue3( implMakeSolidCellStyle( pSSPool, "lightblue3" , aDefaultCellStyleName, RGB_COLORDATA(153,153,204)));
691 implCreateTableTemplate( xTableFamily, "lightblue" , aLightBlue1, aLightBlue3, aLightBlue2 );
693 // ---- Yellow ----------------------------------------------
695 Any aYellow1( implMakeSolidCellStyle( pSSPool, "yellow1" , aDefaultCellStyleName, RGB_COLORDATA(255,255,204)));
696 Any aYellow2( implMakeSolidCellStyle( pSSPool, "yellow2" , aDefaultCellStyleName, RGB_COLORDATA(255,255,153)));
697 Any aYellow3( implMakeSolidCellStyle( pSSPool, "yellow3" , aDefaultCellStyleName, RGB_COLORDATA(255,204,153)));
699 implCreateTableTemplate( xTableFamily, "yellow" , aYellow1, aYellow3, aYellow2 );
702 // Number of pages that reference a master page
703 sal_uInt16 SdDrawDocument::GetMasterPageUserCount(SdrPage* pMaster) const
705 sal_uInt16 nResult = 0;
706 sal_uInt16 nPage;
707 sal_uInt16 nPageCount = GetPageCount();
709 for (nPage = 0; nPage < nPageCount; nPage++)
711 const SdrPage* pPage = GetPage(nPage);
713 if(pPage->TRG_HasMasterPage())
715 if(&(pPage->TRG_GetMasterPage()) == pMaster)
717 nResult++;
721 return nResult;
724 // Finish OnlineSpelling in the background
726 void SdDrawDocument::StopOnlineSpelling()
728 if (mpOnlineSpellingIdle && mpOnlineSpellingIdle->IsActive())
730 mpOnlineSpellingIdle->Stop();
733 delete mpOnlineSpellingIdle;
734 mpOnlineSpellingIdle = NULL;
736 delete mpOnlineSpellingList;
737 mpOnlineSpellingList = NULL;
740 // Start OnlineSpelling in the background
741 void SdDrawDocument::StartOnlineSpelling(bool bForceSpelling)
743 if (mbOnlineSpell && (bForceSpelling || mbInitialOnlineSpellingEnabled) &&
744 mpDocSh && !mpDocSh->IsReadOnly() )
746 StopOnlineSpelling();
748 ::sd::Outliner* pOutl = GetInternalOutliner(true);
750 Reference< XSpellChecker1 > xSpellChecker( LinguMgr::GetSpellChecker() );
751 if ( xSpellChecker.is() )
752 pOutl->SetSpeller( xSpellChecker );
754 Reference< XHyphenator > xHyphenator( LinguMgr::GetHyphenator() );
755 if( xHyphenator.is() )
756 pOutl->SetHyphenator( xHyphenator );
758 pOutl->SetDefaultLanguage( meLanguage );
760 mpOnlineSpellingList = new ShapeList;
761 sal_uInt16 nPage;
763 for ( nPage = 0; nPage < GetPageCount(); nPage++ )
765 // Search in all pages
766 FillOnlineSpellingList(static_cast<SdPage*>(GetPage(nPage)));
769 for (nPage = 0; nPage < GetMasterPageCount(); nPage++)
771 // Search all master pages
772 FillOnlineSpellingList(static_cast<SdPage*>( GetMasterPage(nPage) ));
775 mpOnlineSpellingList->seekShape(0);
776 mpOnlineSpellingIdle = new Idle();
777 mpOnlineSpellingIdle->SetIdleHdl( LINK(this, SdDrawDocument, OnlineSpellingHdl) );
778 mpOnlineSpellingIdle->SetPriority(SchedulerPriority::LOWEST);
779 mpOnlineSpellingIdle->Start();
783 // Fill OnlineSpelling list
784 void SdDrawDocument::FillOnlineSpellingList(SdPage* pPage)
786 SdrObjListIter aIter(*pPage, IM_FLAT);
788 while (aIter.IsMore())
790 SdrObject* pObj = aIter.Next();
792 if( !pObj )
793 continue;
795 if (pObj->GetOutlinerParaObject())
797 // Found a text object
798 mpOnlineSpellingList->addShape(*pObj);
800 else if (pObj->GetObjIdentifier() == OBJ_GRUP)
802 // Found a group object
803 SdrObjListIter aGroupIter(*static_cast<SdrObjGroup*>(pObj)->GetSubList(),
804 IM_DEEPNOGROUPS);
806 bool bSubTextObjFound = false;
808 while (aGroupIter.IsMore() && !bSubTextObjFound)
810 if (aGroupIter.Next()->GetOutlinerParaObject())
812 // Found a text object in a group object
813 bSubTextObjFound = true;
817 if (bSubTextObjFound)
819 mpOnlineSpellingList->addShape(*pObj);
825 // OnlineSpelling in the background
826 IMPL_LINK_NOARG_TYPED(SdDrawDocument, OnlineSpellingHdl, Idle *, void)
828 if (mpOnlineSpellingList!=NULL
829 && ( !mbOnlineSpell || mpOnlineSpellingList->hasMore()))
831 // Spell next object
832 SdrObject* pObj = mpOnlineSpellingList->getNextShape();
834 if (pObj)
836 if (pObj->GetOutlinerParaObject() && pObj->ISA(SdrTextObj))
838 // Spell text object
839 SpellObject(static_cast<SdrTextObj*>(pObj));
841 else if (pObj->GetObjIdentifier() == OBJ_GRUP)
843 // Found a group object
844 SdrObjListIter aGroupIter(*static_cast<SdrObjGroup*>(pObj)->GetSubList(),
845 IM_DEEPNOGROUPS);
848 while (aGroupIter.IsMore())
850 SdrObject* pSubObj = aGroupIter.Next();
852 if (pSubObj->GetOutlinerParaObject() && pSubObj->ISA(SdrTextObj))
854 // Found a text object in a group object
855 SpellObject(static_cast<SdrTextObj*>(pSubObj));
861 // Continue search
862 mpOnlineSpellingIdle->Start();
864 else
866 // Initial spelling has finished
867 mbInitialOnlineSpellingEnabled = false;
869 // Stop search
870 StopOnlineSpelling();
872 delete mpOnlineSearchItem;
873 mpOnlineSearchItem = NULL;
877 // Spell object (for OnlineSpelling)
878 void SdDrawDocument::SpellObject(SdrTextObj* pObj)
880 if (pObj && pObj->GetOutlinerParaObject() /* && pObj != pView->GetTextEditObject() */)
882 mbHasOnlineSpellErrors = false;
883 ::sd::Outliner* pOutl = GetInternalOutliner(true);
884 pOutl->SetUpdateMode(true);
885 Link<> aEvtHdl = pOutl->GetStatusEventHdl();
886 pOutl->SetStatusEventHdl(LINK(this, SdDrawDocument, OnlineSpellEventHdl));
888 sal_uInt16 nOldOutlMode = pOutl->GetMode();
889 sal_uInt16 nOutlMode = OUTLINERMODE_TEXTOBJECT;
890 if (pObj->GetObjInventor() == SdrInventor &&
891 pObj->GetObjIdentifier() == OBJ_OUTLINETEXT)
893 nOutlMode = OUTLINERMODE_OUTLINEOBJECT;
895 pOutl->Init( nOutlMode );
897 // Put text into the outliner
898 pOutl->SetText(*pObj->GetOutlinerParaObject());
900 if (!mpOnlineSearchItem || pOutl->HasText(*mpOnlineSearchItem))
902 // Spelling
903 pOutl->CompleteOnlineSpelling();
905 if (mbHasOnlineSpellErrors)
907 sd::ModifyGuard aGuard( this );
908 SdrModel* pModel = pObj->GetModel();
909 bool bLock = false;
910 if ( pModel )
912 bLock = pModel->isLocked();
913 pModel->setLock(true);
915 // taking text from the outliner
916 pObj->SetOutlinerParaObject( pOutl->CreateParaObject() );
918 pObj->BroadcastObjectChange();
919 if ( pModel )
920 pModel->setLock(bLock);
924 pOutl->SetStatusEventHdl(aEvtHdl);
925 pOutl->SetUpdateMode(false);
926 pOutl->Init( nOldOutlMode );
927 mbHasOnlineSpellErrors = false;
931 // Object was inserted into model
932 void SdDrawDocument::InsertObject(SdrObject* pObj, SdPage* /*pPage*/)
934 if(mpOnlineSpellingList && pObj)
936 if (pObj->GetOutlinerParaObject() || (pObj->GetObjIdentifier() == OBJ_GRUP))
938 // Add object to OnlineSpelling list
939 mpOnlineSpellingList->addShape(*pObj);
944 // Object removed from model
945 void SdDrawDocument::RemoveObject(SdrObject* pObj, SdPage* /*pPage*/)
947 if(mpOnlineSpellingList && pObj)
949 if (pObj->GetOutlinerParaObject() || (pObj->GetObjIdentifier() == OBJ_GRUP))
951 // Replace object in OnlineSpelling list by 0 pointer
952 mpOnlineSpellingList->removeShape(*pObj);
957 // Callback for ExecuteSpellPopup()
958 IMPL_LINK(SdDrawDocument, OnlineSpellEventHdl, EditStatus*, pEditStat)
960 EditStatusFlags nStat = pEditStat->GetStatusWord();
961 mbHasOnlineSpellErrors = bool(nStat & EditStatusFlags::WRONGWORDCHANGED);
963 return 0;
966 // Callback for ExecuteSpellPopup()
968 // removed link and replaced with Imp method
969 void SdDrawDocument::ImpOnlineSpellCallback(SpellCallbackInfo* pInfo, SdrObject* pObj, SdrOutliner* pOutl)
971 delete mpOnlineSearchItem;
972 mpOnlineSearchItem = NULL;
974 SpellCallbackCommand nCommand = pInfo->nCommand;
976 if (nCommand == SpellCallbackCommand::IGNOREWORD
977 // restart when add to dictionary takes place, too.
978 || nCommand == SpellCallbackCommand::ADDTODICTIONARY)
980 if(pObj && pOutl && pObj->ISA(SdrTextObj))
982 bool bModified(IsChanged());
983 static_cast<SdrTextObj*>(pObj)->SetOutlinerParaObject(pOutl->CreateParaObject());
984 SetChanged(bModified);
985 pObj->BroadcastObjectChange();
988 mpOnlineSearchItem = new SvxSearchItem( SID_SEARCH_ITEM );
989 mpOnlineSearchItem->SetSearchString(pInfo->aWord);
990 StartOnlineSpelling();
992 else if (nCommand == SpellCallbackCommand::STARTSPELLDLG)
994 SfxViewFrame::Current()->GetDispatcher()->Execute( SID_SPELL_DIALOG,
995 SfxCallMode::ASYNCHRON );
999 // Replace the unambiguous names of the default layers by their names in the
1000 // native language
1001 void SdDrawDocument::RestoreLayerNames()
1003 SdrLayerAdmin& rLayerAdmin = GetLayerAdmin();
1004 sal_uInt16 nLayerCount = rLayerAdmin.GetLayerCount();
1006 for (sal_uInt16 nLayer = 0; nLayer < nLayerCount; nLayer++)
1008 SdrLayer* pLayer = rLayerAdmin.GetLayer(nLayer);
1010 if (pLayer)
1012 OUString aLayerName(pLayer->GetName());
1014 if (aLayerName == "LAYER_LAYOUT")
1016 pLayer->SetName(SD_RESSTR(STR_LAYER_LAYOUT));
1018 else if (aLayerName == "LAYER_BCKGRND")
1020 pLayer->SetName(SD_RESSTR(STR_LAYER_BCKGRND));
1022 else if (aLayerName == "LAYER_BACKGRNDOBJ")
1024 pLayer->SetName(SD_RESSTR(STR_LAYER_BCKGRNDOBJ));
1026 else if (aLayerName == "LAYER_CONTROLS")
1028 pLayer->SetName(SD_RESSTR(STR_LAYER_CONTROLS));
1030 else if (aLayerName == "LAYER_MEASURELINES")
1032 pLayer->SetName(SD_RESSTR(STR_LAYER_MEASURELINES));
1038 // Return formatted page number (1, I, i, a, etc.)
1039 OUString SdDrawDocument::CreatePageNumValue(sal_uInt16 nNum) const
1041 OUString aPageNumValue;
1042 bool bUpper = false;
1044 switch (mePageNumType)
1046 case SVX_CHARS_UPPER_LETTER:
1047 aPageNumValue += OUString( (sal_Unicode)(char)((nNum - 1) % 26 + 'A') );
1048 break;
1049 case SVX_CHARS_LOWER_LETTER:
1050 aPageNumValue += OUString( (sal_Unicode)(char)((nNum - 1) % 26 + 'a') );
1051 break;
1052 case SVX_ROMAN_UPPER:
1053 bUpper = true;
1054 //fall-through
1055 case SVX_ROMAN_LOWER:
1056 aPageNumValue += SvxNumberFormat::CreateRomanString(nNum, bUpper);
1057 break;
1058 case SVX_NUMBER_NONE:
1059 aPageNumValue = " ";
1060 break;
1061 default:
1062 aPageNumValue += OUString::number(nNum);
1065 return aPageNumValue;
1068 // Rename layout template
1069 // Keep in mind that rOldLayoutName contains the _complete_ name of the layout
1070 // (including ~LT~). This is unlike rNewName.
1071 void SdDrawDocument::RenameLayoutTemplate(const OUString& rOldLayoutName, const OUString& rNewName)
1073 OUString aSep(SD_LT_SEPARATOR);
1074 OUString aOldName(rOldLayoutName);
1075 sal_Int32 nPos = aOldName.indexOf( aSep );
1077 // erase everything after '~LT~'
1078 if (nPos != -1)
1079 aOldName = aOldName.copy(0, nPos + aSep.getLength());
1081 std::vector<StyleReplaceData> aReplList;
1082 SfxStyleSheetIterator aIter(mxStyleSheetPool.get(), SD_STYLE_FAMILY_MASTERPAGE);
1083 SfxStyleSheetBase* pSheet = aIter.First();
1085 while (pSheet)
1087 OUString aSheetName = pSheet->GetName();
1089 // if the sheetname starts with aOldName + "~LT~"
1090 if (aSheetName.startsWith(aOldName))
1092 aSheetName = aSheetName.replaceAt(0, aOldName.getLength() - aSep.getLength(), rNewName);
1094 StyleReplaceData aReplData;
1095 aReplData.nFamily = pSheet->GetFamily();
1096 aReplData.nNewFamily = pSheet->GetFamily();
1097 aReplData.aName = pSheet->GetName();
1098 aReplData.aNewName = aSheetName;
1099 aReplList.push_back(aReplData);
1101 pSheet->SetName(aSheetName);
1104 pSheet = aIter.Next();
1107 // Now set the layout name of the drawing and the notes page, as well as
1108 // their master pages.
1109 OUString aPageLayoutName(rNewName);
1110 aPageLayoutName += aSep + SD_RESSTR(STR_LAYOUT_OUTLINE);
1112 // Inform all text objects on pages that use the renamed layout and set the
1113 // new name.
1114 sal_uInt16 nPage;
1115 for (nPage = 0; nPage < GetPageCount(); nPage++)
1117 SdPage* pPage = static_cast<SdPage*>(GetPage(nPage));
1118 OUString aTemp(pPage->GetLayoutName());
1120 if (aTemp == rOldLayoutName)
1122 pPage->SetLayoutName(aPageLayoutName);
1124 for (size_t nObj = 0; nObj < pPage->GetObjCount(); ++nObj)
1126 SdrObject* pObj = pPage->GetObj(nObj);
1128 if (pObj->GetObjInventor() == SdrInventor)
1130 switch( pObj->GetObjIdentifier() )
1132 case OBJ_TEXT:
1133 case OBJ_OUTLINETEXT:
1134 case OBJ_TITLETEXT:
1136 OutlinerParaObject* pOPO = static_cast<SdrTextObj*>(pObj)->GetOutlinerParaObject();
1138 if (pOPO)
1140 std::vector<StyleReplaceData>::iterator it;
1141 for (it = aReplList.begin(); it != aReplList.end(); ++it)
1142 pOPO->ChangeStyleSheets( it->aName, it->nFamily, it->aNewName, it->nNewFamily );
1145 break;
1147 default:
1148 break;
1155 // Now do this again for all master pages.
1156 // The affected master pages get the name of the layout as their page name.
1157 for (nPage = 0; nPage < GetMasterPageCount(); nPage++)
1159 SdPage* pPage = static_cast<SdPage*>( GetMasterPage(nPage) );
1160 OUString aTemp(pPage->GetLayoutName());
1162 if (aTemp == rOldLayoutName)
1164 pPage->SetLayoutName(aPageLayoutName);
1165 pPage->SetName(rNewName);
1167 for (size_t nObj = 0; nObj < pPage->GetObjCount(); ++nObj)
1169 SdrObject* pObj = pPage->GetObj(nObj);
1171 if (pObj->GetObjInventor() == SdrInventor)
1173 switch(pObj->GetObjIdentifier())
1175 case OBJ_TEXT:
1176 case OBJ_OUTLINETEXT:
1177 case OBJ_TITLETEXT:
1179 OutlinerParaObject* pOPO = static_cast<SdrTextObj*>(pObj)->GetOutlinerParaObject();
1181 if (pOPO)
1183 std::vector<StyleReplaceData>::iterator it;
1184 for (it = aReplList.begin(); it != aReplList.end(); ++it)
1185 pOPO->ChangeStyleSheets( it->aName, it->nFamily, it->aNewName, it->nNewFamily );
1188 break;
1190 default:
1191 break;
1199 // Set outliner defaults (pool defaults)
1200 void SdDrawDocument::SetTextDefaults() const
1202 // BulletItem and BulletFont for Titel and Outline
1203 SvxBulletItem aBulletItem(EE_PARA_BULLET);
1204 vcl::Font aBulletFont( SdStyleSheetPool::GetBulletFont() );
1205 aBulletFont.SetSize(Size(0,846)); // 24 pt
1206 aBulletItem.SetFont(aBulletFont);
1207 aBulletItem.SetStyle(SvxBulletStyle::BULLET);
1208 aBulletItem.SetStart(1);
1209 aBulletItem.SetScale(45); // In percent
1210 aBulletItem.SetSymbol( 0x25CF ); // In points
1211 pItemPool->SetPoolDefaultItem( aBulletItem );
1213 // New BulletItem
1214 SvxNumberFormat aNumberFormat(SVX_NUM_CHAR_SPECIAL);
1215 aNumberFormat.SetBulletFont(&aBulletFont);
1216 aNumberFormat.SetBulletChar( 0x25CF ); // StarBats: 0xF000 + 34
1217 aNumberFormat.SetBulletRelSize(45);
1218 aNumberFormat.SetBulletColor(Color(COL_AUTO));
1219 aNumberFormat.SetStart(1);
1220 aNumberFormat.SetNumAdjust(SVX_ADJUST_LEFT);
1222 SvxNumRule aNumRule( SvxNumRuleFlags::BULLET_REL_SIZE | SvxNumRuleFlags::BULLET_COLOR | SvxNumRuleFlags::CHAR_TEXT_DISTANCE, SVX_MAX_NUM, false);
1224 //aNumberFormat.SetAbsLSpace( 0 );
1225 //aNumberFormat.SetFirstLineOffset( 0 );
1226 //aNumRule.SetLevel( 0, aNumberFormat );
1228 for( sal_uInt16 i = 0; i < aNumRule.GetLevelCount(); i++ )
1230 const short nLSpace = (i + 1) * 600;
1231 aNumberFormat.SetAbsLSpace(nLSpace);
1232 aNumberFormat.SetFirstLineOffset(-600);
1233 aNumRule.SetLevel( i, aNumberFormat );
1236 SvxNumBulletItem aNumBulletItem( aNumRule, EE_PARA_NUMBULLET );
1237 pItemPool->SetPoolDefaultItem( aNumBulletItem );
1240 ::com::sun::star::text::WritingMode SdDrawDocument::GetDefaultWritingMode() const
1242 const SfxPoolItem* pItem = ( pItemPool ? pItemPool->GetPoolDefaultItem( EE_PARA_WRITINGDIR ) : NULL );
1243 ::com::sun::star::text::WritingMode eRet = ::com::sun::star::text::WritingMode_LR_TB;
1245 if( pItem )
1247 switch( static_cast<const SvxFrameDirectionItem&>( *pItem ).GetValue() )
1249 case( FRMDIR_HORI_LEFT_TOP ): eRet = ::com::sun::star::text::WritingMode_LR_TB; break;
1250 case( FRMDIR_HORI_RIGHT_TOP ): eRet = ::com::sun::star::text::WritingMode_RL_TB; break;
1251 case( FRMDIR_VERT_TOP_RIGHT ): eRet = ::com::sun::star::text::WritingMode_TB_RL; break;
1253 default:
1254 OSL_FAIL( "Frame direction not supported yet" );
1255 break;
1259 return eRet;
1262 void SdDrawDocument::SetDefaultWritingMode(::com::sun::star::text::WritingMode eMode )
1264 if( pItemPool )
1266 SvxFrameDirection nVal;
1267 switch( eMode )
1269 case ::com::sun::star::text::WritingMode_LR_TB: nVal = FRMDIR_HORI_LEFT_TOP; break;
1270 case ::com::sun::star::text::WritingMode_RL_TB: nVal = FRMDIR_HORI_RIGHT_TOP; break;
1271 case ::com::sun::star::text::WritingMode_TB_RL: nVal = FRMDIR_VERT_TOP_RIGHT; break;
1272 default:
1273 OSL_FAIL( "Frame direction not supported yet" );
1274 return;
1277 SvxFrameDirectionItem aModeItem( nVal, EE_PARA_WRITINGDIR );
1278 pItemPool->SetPoolDefaultItem( aModeItem );
1280 SvxAdjustItem aAdjust( SVX_ADJUST_LEFT, EE_PARA_JUST );
1282 if( eMode == ::com::sun::star::text::WritingMode_RL_TB )
1283 aAdjust.SetEnumValue( SVX_ADJUST_RIGHT );
1285 pItemPool->SetPoolDefaultItem( aAdjust );
1290 void SdDrawDocument::getDefaultFonts( vcl::Font& rLatinFont, vcl::Font& rCJKFont, vcl::Font& rCTLFont )
1292 LanguageType eLatin = GetLanguage( EE_CHAR_LANGUAGE );
1294 // If the UI language is Korean, the default Latin font has to
1295 // be queried for Korean, too (the Latin language from the document can't be Korean).
1296 // This is the same logic as in SwDocShell::InitNew.
1297 LanguageType eUiLanguage = Application::GetSettings().GetUILanguageTag().getLanguageType();
1298 if (MsLangId::isKorean(eUiLanguage))
1299 eLatin = eUiLanguage;
1301 rLatinFont = OutputDevice::GetDefaultFont( DefaultFontType::LATIN_PRESENTATION, eLatin, GetDefaultFontFlags::OnlyOne );
1302 rCJKFont = OutputDevice::GetDefaultFont( DefaultFontType::CJK_PRESENTATION, GetLanguage( EE_CHAR_LANGUAGE_CJK ), GetDefaultFontFlags::OnlyOne );
1303 rCTLFont = OutputDevice::GetDefaultFont( DefaultFontType::CTL_PRESENTATION, GetLanguage( EE_CHAR_LANGUAGE_CTL ), GetDefaultFontFlags::OnlyOne ) ;
1306 /* converts the given western font height to a corresponding ctl font height, depending on the system language */
1307 sal_uInt32 SdDrawDocument::convertFontHeightToCTL( sal_uInt32 nWesternFontHeight )
1309 LanguageType eRealCTLLanguage = Application::GetSettings().GetLanguageTag().getLanguageType();
1310 if( LANGUAGE_THAI == eRealCTLLanguage )
1312 // http://specs.openoffice.org/g11n/font_sizes/42775_42725_Individual_configurable_font_size_for_default_fonts.odt
1313 double fTemp = double(nWesternFontHeight) * 1.333;
1314 nWesternFontHeight = (sal_uInt32)fTemp;
1315 // make some nice values for UI that displays PT instead of 1/100th mm
1316 nWesternFontHeight = ((nWesternFontHeight * 72) + 1270) / 2540L;
1317 nWesternFontHeight = ((nWesternFontHeight * 2540L) + 36) / 72;
1319 return nWesternFontHeight;
1322 SdStyleSheetPool* SdDrawDocument::GetSdStyleSheetPool() const
1324 return dynamic_cast< SdStyleSheetPool* >( GetStyleSheetPool() );
1327 ModifyGuard::ModifyGuard( SdDrawDocument* pDoc )
1328 : mpDocShell( 0 ), mpDoc( pDoc )
1330 init();
1333 void ModifyGuard::init()
1335 if( mpDocShell )
1337 mpDoc = mpDocShell->GetDoc();
1339 else if( mpDoc )
1341 mpDocShell = mpDoc->GetDocSh();
1344 mbIsEnableSetModified = mpDocShell && mpDocShell->IsEnableSetModified();
1345 mbIsDocumentChanged = mpDoc && mpDoc->IsChanged();
1347 if( mbIsEnableSetModified )
1348 mpDocShell->EnableSetModified( false );
1351 ModifyGuard::~ModifyGuard()
1353 if( mbIsEnableSetModified )
1354 mpDocShell->EnableSetModified( true );
1356 if( mpDoc && (mpDoc->IsChanged() != mbIsDocumentChanged) )
1357 mpDoc->SetChanged(mbIsDocumentChanged);
1360 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */