fdo#74697 Add Bluez 5 support for impress remote.
[LibreOffice.git] / sd / source / core / drawdoc4.cxx
blob040413c20f5b540e50f3373cc6b2789e79ffebc2
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 .
21 #include <com/sun/star/style/XStyle.hpp>
22 #include <com/sun/star/container/XNameAccess.hpp>
23 #include <i18nlangtag/mslangid.hxx>
24 #include <sfx2/docfile.hxx>
25 #include <sfx2/dispatch.hxx>
26 #include "Outliner.hxx"
27 #include <comphelper/processfactory.hxx>
28 #include <editeng/outliner.hxx>
30 #include "../ui/inc/DrawDocShell.hxx"
31 #include <editeng/eeitem.hxx>
32 #include <vcl/svapp.hxx>
34 #include <editeng/autokernitem.hxx>
36 #include <svx/svxids.hrc>
37 #include <svl/srchitem.hxx>
38 #include <editeng/lrspitem.hxx>
39 #include <editeng/ulspitem.hxx>
40 #include <editeng/lspcitem.hxx>
41 #include <editeng/adjustitem.hxx>
42 #include <editeng/numdef.hxx>
43 #include <svx/dialogs.hrc>
44 #include <svx/dialmgr.hxx> // SVX_RESSTR
45 #include <editeng/bulletitem.hxx>
46 #include <svx/xtable.hxx>
47 #include <svx/sxmsuitm.hxx>
48 #include <editeng/borderline.hxx>
49 #include <editeng/boxitem.hxx>
50 #include <svx/xit.hxx>
51 #include <svx/xlineit0.hxx>
52 #include <svx/sdshitm.hxx>
53 #include <svx/svdotext.hxx>
54 #include <svx/xfillit0.hxx>
55 #include <svx/sdshcitm.hxx>
56 #include <editeng/editstat.hxx>
57 #include <editeng/colritem.hxx>
58 #include <editeng/fhgtitem.hxx>
59 #include <editeng/wghtitem.hxx>
60 #include <editeng/postitem.hxx>
61 #include <editeng/crossedoutitem.hxx>
62 #include <editeng/udlnitem.hxx>
63 #include <editeng/contouritem.hxx>
64 #include <editeng/emphasismarkitem.hxx>
65 #include <editeng/fontitem.hxx>
66 #include <editeng/shdditem.hxx>
67 #include <svx/xbtmpit.hxx>
68 #include <svx/xflhtit.hxx>
69 #include <svx/xflgrit.hxx>
70 #include <svx/xflclit.hxx>
71 #include <svx/xlnedcit.hxx>
72 #include <svx/xlnstcit.hxx>
73 #include <svx/xlnedwit.hxx>
74 #include <svx/xlnstwit.hxx>
75 #include <svx/xlnedit.hxx>
76 #include <editeng/charreliefitem.hxx>
77 #include <svx/xlnstit.hxx>
78 #include <svx/xlndsit.hxx>
79 #include <svx/xlnwtit.hxx>
80 #include <svx/xlnclit.hxx>
81 #include <svx/svditer.hxx>
82 #include <svx/svdogrp.hxx>
83 #include <tools/shl.hxx>
84 #include <editeng/numitem.hxx>
85 #include <editeng/editeng.hxx>
86 #include <editeng/unolingu.hxx>
87 #include <com/sun/star/linguistic2/XHyphenator.hpp>
88 #include <com/sun/star/lang/XMultiServiceFactory.hpp>
89 #include <svl/itempool.hxx>
90 #include <editeng/outlobj.hxx>
91 #include <sfx2/viewfrm.hxx>
92 #include <editeng/langitem.hxx>
93 #include <editeng/frmdiritem.hxx>
95 #include "sdresid.hxx"
96 #include "drawdoc.hxx"
97 #include "sdpage.hxx"
98 #include "glob.hrc"
99 #include "glob.hxx"
100 #include "stlpool.hxx"
101 #include "helpids.h"
102 #include "sdiocmpt.hxx"
103 #include "shapelist.hxx"
104 #include <basegfx/point/b2dpoint.hxx>
105 #include <basegfx/polygon/b2dpolygon.hxx>
106 #include <svl/itemset.hxx>
107 #include "app.hrc"
109 using namespace ::com::sun::star;
110 using namespace ::com::sun::star::uno;
111 using namespace ::com::sun::star::lang;
112 using namespace ::com::sun::star::style;
113 using namespace ::com::sun::star::container;
114 using namespace ::com::sun::star::linguistic2;
115 using namespace ::sd;
117 // CreateLayoutTemplates
118 // At the moment (31.03.1995), the StyleSheetPool only saves styleheets that
119 // have an ItemSet. To save all stylesheets, we force the creation of an ItemSet
120 // with a GetItemSet call.
121 // We can remove this behavior once the pool saves styleheets even without an ItemSet
122 void SdDrawDocument::CreateLayoutTemplates()
124 SdStyleSheetPool* pSSPool = (SdStyleSheetPool*)GetStyleSheetPool();
125 SfxStyleSheetBase* pSheet = NULL;
126 String aHelpFile;
127 String aStdName = String(SdResId(STR_STANDARD_STYLESHEET_NAME));
129 // Default style
131 sal_uInt16 nMask = SFXSTYLEBIT_AUTO;
133 String aName(aStdName);
134 pSheet = &(pSSPool->Make(aName, SD_STYLE_FAMILY_GRAPHICS, nMask));
135 pSheet->SetHelpId( aHelpFile, HID_STANDARD_STYLESHEET_NAME );
136 SfxItemSet& rISet = pSheet->GetItemSet();
137 SfxItemPool* pPool = rISet.GetPool();
139 ::basegfx::B2DPolyPolygon aNullPolyPolygon;
140 Color aNullCol(RGB_Color(COL_DEFAULT_SHAPE_STROKE));
142 XDash aNullDash;
143 XGradient aNullGrad(aNullCol,RGB_Color(COL_WHITE));
144 aNullGrad.SetStartIntens( 100 );
145 aNullGrad.SetEndIntens( 100 );
146 XHatch aNullHatch(aNullCol);
148 // Line attributes (Extended OutputDevice)
149 rISet.Put(XLineStyleItem(XLINE_SOLID));
150 rISet.Put(XLineColorItem(String(), RGB_Color(COL_DEFAULT_SHAPE_STROKE)));
151 rISet.Put(XLineWidthItem(0));
152 rISet.Put(XLineDashItem(pPool,aNullDash));
153 rISet.Put(XLineStartItem(pPool,aNullPolyPolygon));
154 rISet.Put(XLineEndItem(pPool,aNullPolyPolygon));
155 rISet.Put(XLineStartWidthItem(200));
156 rISet.Put(XLineEndWidthItem(200));
157 rISet.Put(XLineStartCenterItem());
158 rISet.Put(XLineEndCenterItem());
159 rISet.Put(SdrTextHorzAdjustItem(SDRTEXTHORZADJUST_BLOCK));
161 // Fill attributes (Extended OutputDevice)
162 rISet.Put(XFillStyleItem(XFILL_SOLID));
163 rISet.Put(XFillColorItem(String(), RGB_Color(COL_DEFAULT_SHAPE_FILLING)));
165 rISet.Put( XFillGradientItem( aNullGrad) );
166 rISet.Put(XFillHatchItem(pPool,aNullHatch));
167 Size aNullSize( 32, 32 );
168 Color aNullColor( COL_WHITE );
169 Bitmap aNullBmp( aNullSize, 8 );
170 aNullBmp.Erase( aNullColor );
171 rISet.Put(XFillBitmapItem(pPool, Graphic(aNullBmp)));
173 // Shadow attributes (Drawing Engine)
174 rISet.Put(SdrShadowItem(sal_False));
175 rISet.Put(SdrShadowColorItem(RGB_Color(COL_GRAY)));
176 rISet.Put(SdrShadowXDistItem(200)); // 3 mm Shadow distance
177 rISet.Put(SdrShadowYDistItem(200));
179 Font aLatinFont, aCJKFont, aCTLFont;
181 getDefaultFonts( aLatinFont, aCJKFont, aCTLFont );
183 SvxFontItem aSvxFontItem( aLatinFont.GetFamily(), aLatinFont.GetName(), aLatinFont.GetStyleName(), aLatinFont.GetPitch(),
184 aLatinFont.GetCharSet(), EE_CHAR_FONTINFO );
186 SvxFontItem aSvxFontItemCJK( aCJKFont.GetFamily(), aCJKFont.GetName(), aCJKFont.GetStyleName(), aCJKFont.GetPitch(),
187 aCJKFont.GetCharSet(), EE_CHAR_FONTINFO_CJK );
189 SvxFontItem aSvxFontItemCTL( aCTLFont.GetFamily(), aCTLFont.GetName(), aCTLFont.GetStyleName(), aCTLFont.GetPitch(),
190 aCTLFont.GetCharSet(), EE_CHAR_FONTINFO_CTL );
192 rISet.Put( aSvxFontItem );
193 rISet.Put( aSvxFontItemCJK );
194 rISet.Put( aSvxFontItemCTL );
196 rISet.Put( SvxFontHeightItem( 635, 100, EE_CHAR_FONTHEIGHT ) ); // sj: (i33745) changed default from 24 to 18 pt
197 rISet.Put( SvxFontHeightItem( 635, 100, EE_CHAR_FONTHEIGHT_CJK ) ); // 18 pt
198 rISet.Put( SvxFontHeightItem( convertFontHeightToCTL( 635 ), 100, EE_CHAR_FONTHEIGHT_CTL ) ); // 18 pt
200 rISet.Put( SvxWeightItem( WEIGHT_NORMAL, EE_CHAR_WEIGHT ) );
201 rISet.Put( SvxWeightItem( WEIGHT_NORMAL, EE_CHAR_WEIGHT_CJK ) );
202 rISet.Put( SvxWeightItem( WEIGHT_NORMAL, EE_CHAR_WEIGHT_CTL ) );
204 rISet.Put( SvxPostureItem( ITALIC_NONE, EE_CHAR_ITALIC ) );
205 rISet.Put( SvxPostureItem( ITALIC_NONE, EE_CHAR_ITALIC_CJK ) );
206 rISet.Put( SvxPostureItem( ITALIC_NONE, EE_CHAR_ITALIC_CTL ) );
208 rISet.Put(SvxContourItem(sal_False, EE_CHAR_OUTLINE ));
209 rISet.Put(SvxShadowedItem(sal_False, EE_CHAR_SHADOW ));
210 rISet.Put(SvxUnderlineItem(UNDERLINE_NONE, EE_CHAR_UNDERLINE));
211 rISet.Put(SvxOverlineItem(UNDERLINE_NONE, EE_CHAR_OVERLINE));
212 rISet.Put(SvxCrossedOutItem(STRIKEOUT_NONE, EE_CHAR_STRIKEOUT ));
213 rISet.Put(SvxEmphasisMarkItem(EMPHASISMARK_NONE, EE_CHAR_EMPHASISMARK));
214 rISet.Put(SvxCharReliefItem(RELIEF_NONE, EE_CHAR_RELIEF));
215 rISet.Put(SvxColorItem(Color(COL_AUTO), EE_CHAR_COLOR ));
217 // Paragraph attributes (Edit Engine)
218 rISet.Put(SvxLRSpaceItem(EE_PARA_LRSPACE));
219 rISet.Put(SvxULSpaceItem(EE_PARA_ULSPACE));
221 rISet.Put( SdrTextLeftDistItem( 250 ) ); // sj: (i33745) using text frame distances seems to be a better default
222 rISet.Put( SdrTextRightDistItem( 250 ) );
223 rISet.Put( SdrTextUpperDistItem( 125 ) );
224 rISet.Put( SdrTextLowerDistItem( 125 ) );
226 rISet.Put( SvxLineSpacingItem( LINE_SPACE_DEFAULT_HEIGHT, EE_PARA_SBL ) );
228 // #i16874# enable kerning by default but only for new documents
229 rISet.Put( SvxAutoKernItem( sal_True, EE_CHAR_PAIRKERNING ) );
231 // Bullet
232 // BulletItem and BulletFont for title and outline
233 SvxBulletItem aBulletItem(EE_PARA_BULLET);
234 // Identical in all layers
235 aBulletItem.SetStyle(BS_BULLET);
236 aBulletItem.SetStart(1);
237 aBulletItem.SetScale(45); // In percent
239 Font aBulletFont( pSSPool->GetBulletFont() );
241 aBulletFont.SetSize(Size(0,635)); // sj: (i33745) changed default from 24 to 18 pt
243 aBulletItem.SetFont(aBulletFont);
244 aBulletItem.SetSymbol( 0x25CF ); // In points
245 rISet.Put(aBulletItem);
247 // New BulletItem
248 pSSPool->PutNumBulletItem( pSheet, aBulletFont );
250 SfxItemSet* pISet = NULL;
252 // Object with arrowhead
253 aName = String(SdResId(STR_POOLSHEET_OBJWITHARROW));
254 pSheet = &(pSSPool->Make(aName, SD_STYLE_FAMILY_GRAPHICS, nMask));
255 pSheet->SetParent(aStdName);
256 pSheet->SetHelpId( aHelpFile, HID_POOLSHEET_OBJWITHARROW );
257 pISet = &pSheet->GetItemSet();
259 pISet->Put(XLineStyleItem(XLINE_SOLID));
260 pISet->Put(XLineColorItem(String(), RGB_Color(COL_BLACK)));
261 pISet->Put(XLineWidthItem(150));
263 ::basegfx::B2DPolygon aArrow;
264 aArrow.append(::basegfx::B2DPoint(10.0, 0.0));
265 aArrow.append(::basegfx::B2DPoint(0.0, 30.0));
266 aArrow.append(::basegfx::B2DPoint(20.0, 30.0));
267 aArrow.setClosed(true);
268 pISet->Put(XLineStartItem(SVX_RESSTR(RID_SVXSTR_ARROW),::basegfx::B2DPolyPolygon(aArrow)));
270 pISet->Put(XLineStartWidthItem(700));
271 pISet->Put(XLineEndWidthItem(300));
272 pISet->Put(XLineStartCenterItem(sal_True));
274 // Object with Shadow
275 aName = String(SdResId(STR_POOLSHEET_OBJWITHSHADOW));
276 pSheet = &(pSSPool->Make(aName, SD_STYLE_FAMILY_GRAPHICS, nMask));
277 pSheet->SetParent(aStdName);
278 pSheet->SetHelpId( aHelpFile, HID_POOLSHEET_OBJWITHSHADOW );
279 pISet = &pSheet->GetItemSet();
281 pISet->Put(SdrShadowItem(sal_True));
282 pISet->Put(SdrShadowColorItem(RGB_Color(COL_GRAY)));
283 pISet->Put(SdrShadowXDistItem(200)); // 3 mm shadow distance
284 pISet->Put(SdrShadowYDistItem(200));
286 // Object without fillung
287 aName = String(SdResId(STR_POOLSHEET_OBJWITHOUTFILL));
288 pSheet = &(pSSPool->Make(aName, SD_STYLE_FAMILY_GRAPHICS, nMask));
289 pSheet->SetParent(aStdName);
290 pSheet->SetHelpId( aHelpFile, HID_POOLSHEET_OBJWITHOUTFILL );
291 pISet = &pSheet->GetItemSet();
293 pISet->Put(XFillStyleItem(XFILL_NONE));
294 pISet->Put(XLineColorItem(String(), RGB_Color(COL_BLACK)));
296 // Object no fill no line
298 aName = String(SdResId(STR_POOLSHEET_OBJNOLINENOFILL));
299 pSheet = &(pSSPool->Make(aName, SD_STYLE_FAMILY_GRAPHICS, nMask));
300 pSheet->SetParent(aStdName);
301 pSheet->SetHelpId( aHelpFile, HID_POOLSHEET_OBJNOLINENOFILL );
302 pISet = &pSheet->GetItemSet();
304 pISet->Put(XFillStyleItem(XFILL_NONE));
305 pISet->Put(XLineStyleItem(XLINE_NONE));
307 // Text
309 aName = String(SdResId(STR_POOLSHEET_TEXT));
310 pSheet = &(pSSPool->Make(aName, SD_STYLE_FAMILY_GRAPHICS, nMask));
311 pSheet->SetParent(aStdName);
312 pSheet->SetHelpId( aHelpFile, HID_POOLSHEET_TEXT );
313 pISet = &pSheet->GetItemSet();
315 pISet->Put(XLineStyleItem(XLINE_NONE));
316 pISet->Put(XFillStyleItem(XFILL_NONE));
318 // Text body
319 aName = String(SdResId(STR_POOLSHEET_TEXTBODY));
320 pSheet = &(pSSPool->Make(aName, SD_STYLE_FAMILY_GRAPHICS, nMask));
321 pSheet->SetParent(aStdName);
322 pSheet->SetHelpId( aHelpFile, HID_POOLSHEET_TEXTBODY );
323 pISet = &pSheet->GetItemSet();
325 pISet->Put(XLineStyleItem(XLINE_NONE));
326 pISet->Put(XFillStyleItem(XFILL_NONE));
328 pISet->Put(SvxFontHeightItem(564, 100, EE_CHAR_FONTHEIGHT)); // 16 pt
330 // Text body, justified
331 aName = String(SdResId(STR_POOLSHEET_TEXTBODY_JUSTIFY));
332 pSheet = &(pSSPool->Make(aName, SD_STYLE_FAMILY_GRAPHICS, nMask));
333 pSheet->SetParent(aStdName);
334 pSheet->SetHelpId( aHelpFile, HID_POOLSHEET_TEXTBODY_JUSTIFY );
335 pISet = &pSheet->GetItemSet();
337 pISet->Put(XLineStyleItem(XLINE_NONE));
338 pISet->Put(XFillStyleItem(XFILL_NONE));
340 pISet->Put(SvxAdjustItem(SVX_ADJUST_BLOCK, EE_PARA_JUST ));
342 // Text body, indented
343 aName = String(SdResId(STR_POOLSHEET_TEXTBODY_INDENT));
344 pSheet = &(pSSPool->Make(aName, SD_STYLE_FAMILY_GRAPHICS, nMask));
345 pSheet->SetParent(aStdName);
346 pSheet->SetHelpId( aHelpFile, HID_POOLSHEET_TEXTBODY_INDENT );
347 pISet = &pSheet->GetItemSet();
349 pISet->Put(XLineStyleItem(XLINE_NONE));
350 pISet->Put(XFillStyleItem(XFILL_NONE));
352 SvxLRSpaceItem aLRSpaceItem( EE_PARA_LRSPACE );
353 aLRSpaceItem.SetTxtFirstLineOfst(600); // Indentation of first line: 6mm; right: 0
354 pISet->Put(aLRSpaceItem);
356 // Title
358 aName = String(SdResId(STR_POOLSHEET_TITLE));
359 pSheet = &(pSSPool->Make(aName, SD_STYLE_FAMILY_GRAPHICS, nMask));
360 pSheet->SetParent(aStdName);
361 pSheet->SetHelpId( aHelpFile, HID_POOLSHEET_TITLE );
362 pISet = &pSheet->GetItemSet();
364 pISet->Put(XLineStyleItem(XLINE_NONE));
365 pISet->Put(XFillStyleItem(XFILL_NONE));
367 pISet->Put(SvxFontHeightItem(1551, 100, EE_CHAR_FONTHEIGHT )); // 44 pt
369 // Title1
370 aName = String(SdResId(STR_POOLSHEET_TITLE1));
371 pSheet = &(pSSPool->Make(aName, SD_STYLE_FAMILY_GRAPHICS, nMask));
372 pSheet->SetParent(aStdName);
373 pSheet->SetHelpId( aHelpFile, HID_POOLSHEET_TITLE1 );
374 pISet = &pSheet->GetItemSet();
376 pISet->Put(XLineStyleItem(XLINE_NONE));
377 pISet->Put(XFillStyleItem(XFILL_SOLID));
378 pISet->Put(XFillColorItem(String(), RGB_Color(COL_CYAN)));
380 pISet->Put(SdrShadowItem(sal_True));
381 pISet->Put(SdrShadowColorItem(RGB_Color(COL_GRAY)));
382 pISet->Put(SdrShadowXDistItem(200)); // 2 mm shadow distance
383 pISet->Put(SdrShadowYDistItem(200));
385 pISet->Put(SvxFontHeightItem(846, 100, EE_CHAR_FONTHEIGHT )); // 24 pt
387 pISet->Put(SvxAdjustItem(SVX_ADJUST_CENTER, EE_PARA_JUST ));
389 // Title2
391 aName = String(SdResId(STR_POOLSHEET_TITLE2));
392 pSheet = &(pSSPool->Make(aName, SD_STYLE_FAMILY_GRAPHICS, nMask));
393 pSheet->SetParent(aStdName);
394 pSheet->SetHelpId( aHelpFile, HID_POOLSHEET_TITLE2 );
395 pISet = &pSheet->GetItemSet();
397 pISet->Put(XLineWidthItem(50));
399 // Don't get color from the color table, because the color might have been
400 // deleted or changed there
401 Color aOrange4(255, 204, 153);
402 pISet->Put(XFillColorItem(String(), aOrange4));
404 pISet->Put(SdrShadowItem(sal_True));
405 pISet->Put(SdrShadowColorItem(RGB_Color(COL_GRAY)));
406 pISet->Put(SdrShadowXDistItem(200)); // 2 mm shadow distance
407 pISet->Put(SdrShadowYDistItem(200));
409 pISet->Put(SvxFontHeightItem(1270, 100, EE_CHAR_FONTHEIGHT )); // 36 pt
411 SvxLRSpaceItem aLRSpItem( 200, 200, 0, 0, EE_PARA_LRSPACE);
412 pISet->Put( aLRSpItem ); // Indentation of first line: 0 mm; left and right: 2 mm
414 pISet->Put(SvxULSpaceItem(100, 100, EE_PARA_ULSPACE )); // Paragraph margin above/below: 1 mm
416 pISet->Put(SvxAdjustItem(SVX_ADJUST_CENTER, EE_PARA_JUST ));
418 // Headline
420 aName = String(SdResId(STR_POOLSHEET_HEADLINE));
421 pSheet = &(pSSPool->Make(aName, SD_STYLE_FAMILY_GRAPHICS, nMask));
422 pSheet->SetParent(aStdName);
423 pSheet->SetHelpId( aHelpFile, HID_POOLSHEET_HEADLINE );
424 pISet = &pSheet->GetItemSet();
426 pISet->Put(XLineStyleItem(XLINE_NONE));
427 pISet->Put(XFillStyleItem(XFILL_NONE));
429 pISet->Put(SvxFontHeightItem(846, 100, EE_CHAR_FONTHEIGHT )); // 24 pt
431 pISet->Put(SvxULSpaceItem(420, 210, EE_PARA_ULSPACE )); // Paragraph margin above: 4,2 mm,
432 // Paragraph margin below: 2,1 mm
434 // Headline1
435 aName = String(SdResId(STR_POOLSHEET_HEADLINE1));
436 pSheet = &(pSSPool->Make(aName, SD_STYLE_FAMILY_GRAPHICS, nMask));
437 pSheet->SetParent(aStdName);
438 pSheet->SetHelpId( aHelpFile, HID_POOLSHEET_HEADLINE1 );
439 pISet = &pSheet->GetItemSet();
441 pISet->Put(XLineStyleItem(XLINE_NONE));
442 pISet->Put(XFillStyleItem(XFILL_NONE));
444 pISet->Put(SvxWeightItem(WEIGHT_BOLD, EE_CHAR_WEIGHT ));
446 pISet->Put(SvxFontHeightItem(635, 100, EE_CHAR_FONTHEIGHT )); // 18 pt
448 pISet->Put(SvxULSpaceItem(420, 210, EE_PARA_ULSPACE )); // Paragraph margin above: 4,2 mm,
449 // Paragraph margin below: 2,1 mm
451 // Headline2
452 aName = String(SdResId(STR_POOLSHEET_HEADLINE2));
453 pSheet = &(pSSPool->Make(aName, SD_STYLE_FAMILY_GRAPHICS, nMask));
454 pSheet->SetParent(aStdName);
455 pSheet->SetHelpId( aHelpFile, HID_POOLSHEET_HEADLINE2 );
456 pISet = &pSheet->GetItemSet();
458 pISet->Put(XLineStyleItem(XLINE_NONE));
459 pISet->Put(XFillStyleItem(XFILL_NONE));
461 pISet->Put(SvxPostureItem(ITALIC_NORMAL, EE_CHAR_ITALIC ));
462 pISet->Put(SvxWeightItem(WEIGHT_BOLD, EE_CHAR_WEIGHT));
464 pISet->Put(SvxFontHeightItem(494, 100, EE_CHAR_FONTHEIGHT )); // 14 pt
466 pISet->Put(SvxULSpaceItem(420, 210, EE_PARA_ULSPACE )); // Paragraph margin above: 4,2 mm,
467 // Paragraph margin below: 2,1 mm
469 // Measurements
470 aName = String(SdResId(STR_POOLSHEET_MEASURE));
471 pSheet = &(pSSPool->Make(aName, SD_STYLE_FAMILY_GRAPHICS, nMask));
472 pSheet->SetParent(aStdName);
473 pSheet->SetHelpId( aHelpFile, HID_POOLSHEET_MEASURE );
474 pISet = &pSheet->GetItemSet();
476 pISet->Put(XFillStyleItem(XFILL_NONE));
477 pISet->Put(XLineColorItem(String(), RGB_Color(COL_BLACK)));
479 pISet->Put(SvxFontHeightItem(423, 100, EE_CHAR_FONTHEIGHT )); // 12 pt
481 pISet->Put(XLineStartItem(SVX_RESSTR(RID_SVXSTR_ARROW),::basegfx::B2DPolyPolygon(aArrow)));
482 pISet->Put(XLineStartWidthItem(200));
483 pISet->Put(XLineEndItem(SVX_RESSTR(RID_SVXSTR_ARROW),::basegfx::B2DPolyPolygon(aArrow)));
484 pISet->Put(XLineEndWidthItem(200));
485 pISet->Put(XLineStyleItem(XLINE_SOLID));
486 pISet->Put(SdrMeasureShowUnitItem(true));
488 // Generate presentation templates for default layout.
489 String aPrefix = String(SdResId(STR_LAYOUT_DEFAULT_NAME));
490 pSSPool->CreateLayoutStyleSheets(aPrefix);
493 static Any implMakeSolidCellStyle( SdStyleSheetPool* pSSPool, const OUString& rName, const OUString rParent, const Color& rColor )
495 SfxStyleSheetBase* pSheet = &(pSSPool->Make(rName, SD_STYLE_FAMILY_CELL, SFXSTYLEBIT_AUTO));
496 pSheet->SetParent(rParent);
497 SfxItemSet* pISet = &pSheet->GetItemSet();
498 pISet->Put(XFillStyleItem(XFILL_SOLID));
499 pISet->Put(XFillColorItem(String(), rColor));
501 return Any( Reference< XStyle >( static_cast< XWeak* >( pSheet ), UNO_QUERY ) );
504 static void implCreateTableTemplate( const Reference< XNameContainer >& xTableFamily, const OUString& rName, const Any& rBody, const Any& rHeading, const Any& rBanding )
506 if( xTableFamily.is() ) try
508 if( !xTableFamily->hasByName( OUString( rName ) ) )
510 Reference< XSingleServiceFactory > xFactory( xTableFamily, UNO_QUERY_THROW );
511 Reference< XNameReplace > xDefaultTableStyle( xFactory->createInstance(), UNO_QUERY_THROW );
512 xTableFamily->insertByName( OUString( rName ), Any( xDefaultTableStyle ) );
514 xDefaultTableStyle->replaceByName( "body", rBody );
515 xDefaultTableStyle->replaceByName( "odd-rows" , rBanding );
516 xDefaultTableStyle->replaceByName( "odd-columns" , rBanding );
517 xDefaultTableStyle->replaceByName( "first-row" , rHeading );
518 xDefaultTableStyle->replaceByName( "first-column" , rHeading );
519 xDefaultTableStyle->replaceByName( "last-row" , rHeading );
520 xDefaultTableStyle->replaceByName( "last-column" , rHeading );
523 catch( Exception& )
525 OSL_FAIL("sd::implCreateTableTemplate(), exception caught!");
529 void SdDrawDocument::CreateDefaultCellStyles()
531 SdStyleSheetPool* pSSPool = static_cast< SdStyleSheetPool* >(GetStyleSheetPool());
532 SfxStyleSheetBase* pSheet = NULL;
533 String aHelpFile;
535 Reference< XNameContainer > xTableFamily( pSSPool->getByName( "table" ), UNO_QUERY );
537 // ---- Default -----------------------------------------------
539 sal_uInt16 nMask = SFXSTYLEBIT_AUTO;
541 OUString aDefaultCellStyleName( "default" );
543 pSheet = &(pSSPool->Make(aDefaultCellStyleName, SD_STYLE_FAMILY_CELL, nMask));
544 pSheet->SetHelpId( aHelpFile, HID_SD_CELL_STYLE_DEFAULT );
545 SfxItemSet& rISet = pSheet->GetItemSet();
547 Color aNullCol(RGB_Color(COL_BLACK));
549 XDash aNullDash;
550 XGradient aNullGrad(aNullCol,RGB_Color(COL_WHITE));
551 aNullGrad.SetStartIntens( 100 );
552 aNullGrad.SetEndIntens( 100 );
553 XHatch aNullHatch(aNullCol);
555 rISet.Put(XFillStyleItem(XFILL_SOLID));
556 rISet.Put(XFillColorItem(String(), RGB_Color(0x00ccccff)));
558 Font aLatinFont, aCJKFont, aCTLFont;
560 getDefaultFonts( aLatinFont, aCJKFont, aCTLFont );
562 SvxFontItem aSvxFontItem( aLatinFont.GetFamily(), aLatinFont.GetName(), aLatinFont.GetStyleName(), aLatinFont.GetPitch(),
563 aLatinFont.GetCharSet(), EE_CHAR_FONTINFO );
565 SvxFontItem aSvxFontItemCJK( aCJKFont.GetFamily(), aCJKFont.GetName(), aCJKFont.GetStyleName(), aCJKFont.GetPitch(),
566 aCJKFont.GetCharSet(), EE_CHAR_FONTINFO_CJK );
568 SvxFontItem aSvxFontItemCTL( aCTLFont.GetFamily(), aCTLFont.GetName(), aCTLFont.GetStyleName(), aCTLFont.GetPitch(),
569 aCTLFont.GetCharSet(), EE_CHAR_FONTINFO_CTL );
571 rISet.Put( aSvxFontItem );
572 rISet.Put( aSvxFontItemCJK );
573 rISet.Put( aSvxFontItemCTL );
575 rISet.Put( SvxFontHeightItem( 635, 100, EE_CHAR_FONTHEIGHT ) ); // sj: (i33745) changed default from 24 to 18 pt
576 rISet.Put( SvxFontHeightItem( 635, 100, EE_CHAR_FONTHEIGHT_CJK ) ); // 18 pt
577 rISet.Put( SvxFontHeightItem( convertFontHeightToCTL( 635 ), 100, EE_CHAR_FONTHEIGHT_CTL ) ); // 18 pt
579 rISet.Put(SvxColorItem(Color(COL_AUTO), EE_CHAR_COLOR ));
581 // Paragraph attributes (Edit Engine)
582 rISet.Put(SvxLRSpaceItem(EE_PARA_LRSPACE));
583 rISet.Put(SvxULSpaceItem(EE_PARA_ULSPACE));
585 rISet.Put( SdrTextLeftDistItem( 250 ) );
586 rISet.Put( SdrTextRightDistItem( 250 ) );
587 rISet.Put( SdrTextUpperDistItem( 130 ) );
588 rISet.Put( SdrTextLowerDistItem( 130 ) );
590 rISet.Put( SvxLineSpacingItem( LINE_SPACE_DEFAULT_HEIGHT, EE_PARA_SBL ) );
591 rISet.Put( SvxAutoKernItem( sal_True, EE_CHAR_PAIRKERNING ) );
592 rISet.Put( SdrTextVertAdjustItem(SDRTEXTVERTADJUST_TOP) );
593 rISet.Put( SdrTextHorzAdjustItem(SDRTEXTHORZADJUST_LEFT) );
595 Color aWhite( COL_WHITE );
596 ::editeng::SvxBorderLine aBorderLine(
597 &aWhite, 1, table::BorderLineStyle::SOLID);
599 SvxBoxItem aBoxItem( SDRATTR_TABLE_BORDER );
600 aBoxItem.SetLine( &aBorderLine, BOX_LINE_TOP );
601 aBoxItem.SetLine( &aBorderLine, BOX_LINE_BOTTOM );
602 aBoxItem.SetLine( &aBorderLine, BOX_LINE_LEFT );
603 aBoxItem.SetLine( &aBorderLine, BOX_LINE_RIGHT );
605 rISet.Put( aBoxItem );
607 Any aDefaultCellStyle( Reference< XStyle >( static_cast< XWeak* >( pSheet ), UNO_QUERY ) );
609 // ---- default --------------------------------------------------
611 Any aGray1( implMakeSolidCellStyle( pSSPool, "gray1" , aDefaultCellStyleName, RGB_COLORDATA(230,230,230)));
612 Any aGray2( implMakeSolidCellStyle( pSSPool, "gray2" , aDefaultCellStyleName, RGB_COLORDATA(204,204,204)));
613 Any aGray3( implMakeSolidCellStyle( pSSPool, "gray3" , aDefaultCellStyleName, RGB_COLORDATA(179,179,179)));
615 implCreateTableTemplate( xTableFamily, "default" , aGray1, aGray3, aGray2 );
617 // ---- BW ------------------------------------------------
619 Any aBW1( implMakeSolidCellStyle( pSSPool, "bw1" , aDefaultCellStyleName, RGB_COLORDATA(255,255,255)));
620 Any aBW2( implMakeSolidCellStyle( pSSPool, "bw2" , aDefaultCellStyleName, RGB_COLORDATA(230,230,230)));
621 Any aBW3( implMakeSolidCellStyle( pSSPool, "bw3" , aDefaultCellStyleName, RGB_COLORDATA(0,0,0)));
623 implCreateTableTemplate( xTableFamily, "bw" , aBW1, aBW3, aBW2 );
625 // ---- Orange --------------------------------------------------
627 Any aOrange1( implMakeSolidCellStyle( pSSPool, "orange1" , aDefaultCellStyleName, RGB_COLORDATA(255,204,153)));
628 Any aOrange2( implMakeSolidCellStyle( pSSPool, "orange2" , aDefaultCellStyleName, RGB_COLORDATA(255,153,102)));
629 Any aOrange3( implMakeSolidCellStyle( pSSPool, "orange3" , aDefaultCellStyleName, RGB_COLORDATA(255,102,51)));
631 implCreateTableTemplate( xTableFamily, "orange" , aOrange1, aOrange3, aOrange2 );
633 // ---- Turquoise --------------------------------------------------
635 Any aTurquise1( implMakeSolidCellStyle( pSSPool, "turquise1" , aDefaultCellStyleName, RGB_COLORDATA(71,184,184)));
636 Any aTurquise2( implMakeSolidCellStyle( pSSPool, "turquise2" , aDefaultCellStyleName, RGB_COLORDATA(51,163,163)));
637 Any aTurquise3( implMakeSolidCellStyle( pSSPool, "turquise3" , aDefaultCellStyleName, RGB_COLORDATA(25,138,138)));
639 implCreateTableTemplate( xTableFamily, "turquise" , aTurquise1, aTurquise3, aTurquise2 );
641 // ---- Gray ------------------------------------------------
643 Any aBlue1( implMakeSolidCellStyle( pSSPool, "blue1" , aDefaultCellStyleName, RGB_COLORDATA(153,204,255)));
644 Any aBlue2( implMakeSolidCellStyle( pSSPool, "blue2" , aDefaultCellStyleName, RGB_COLORDATA(0,153,255)));
645 Any aBlue3( implMakeSolidCellStyle( pSSPool, "blue3" , aDefaultCellStyleName, RGB_COLORDATA(0,102,204)));
647 implCreateTableTemplate( xTableFamily, "blue" , aBlue1, aBlue3, aBlue2 );
649 // ---- Sun ------------------------------------------------
651 Any aSun1( implMakeSolidCellStyle( pSSPool, "sun1" , aDefaultCellStyleName, RGB_COLORDATA(230,230,255)));
652 Any aSun2( implMakeSolidCellStyle( pSSPool, "sun2" , aDefaultCellStyleName, RGB_COLORDATA(204,204,255)));
653 Any aSun3( implMakeSolidCellStyle( pSSPool, "sun3" , aDefaultCellStyleName, RGB_COLORDATA(153,153,255)));
655 implCreateTableTemplate( xTableFamily, "sun" , aSun1, aSun3, aSun2 );
657 // ---- Earth ----------------------------------------------
659 Any aEarth1( implMakeSolidCellStyle( pSSPool, "earth1" , aDefaultCellStyleName, RGB_COLORDATA(255,255,204)));
660 Any aEarth2( implMakeSolidCellStyle( pSSPool, "earth2" , aDefaultCellStyleName, RGB_COLORDATA(255,204,153)));
661 Any aEarth3( implMakeSolidCellStyle( pSSPool, "earth3" , aDefaultCellStyleName, RGB_COLORDATA(204,102,51)));
663 implCreateTableTemplate( xTableFamily, "earth" , aEarth1, aEarth3, aEarth2 );
665 // ---- Green ----------------------------------------------
667 Any aGreen1( implMakeSolidCellStyle( pSSPool, "green1" , aDefaultCellStyleName, RGB_COLORDATA(255,255,204)));
668 Any aGreen2( implMakeSolidCellStyle( pSSPool, "green2" , aDefaultCellStyleName, RGB_COLORDATA(148,189,94)));
669 Any aGreen3( implMakeSolidCellStyle( pSSPool, "green3" , aDefaultCellStyleName, RGB_COLORDATA(92,133,38)));
671 implCreateTableTemplate( xTableFamily, "green" , aGreen1, aGreen3, aGreen2 );
673 // ---- Seaweed ----------------------------------------------
675 Any aSeetang1( implMakeSolidCellStyle( pSSPool, "seetang1" , aDefaultCellStyleName, RGB_COLORDATA(204,255,255)));
676 Any aSeetang2( implMakeSolidCellStyle( pSSPool, "seetang2" , aDefaultCellStyleName, RGB_COLORDATA(71,184,184)));
677 Any aSeetang3( implMakeSolidCellStyle( pSSPool, "seetang3" , aDefaultCellStyleName, RGB_COLORDATA(51,163,163)));
679 implCreateTableTemplate( xTableFamily, "seetang" , aSeetang1, aSeetang3, aSeetang2 );
681 // ---- LightBlue ----------------------------------------------
683 Any aLightBlue1( implMakeSolidCellStyle( pSSPool, "lightblue1" , aDefaultCellStyleName, RGB_COLORDATA(255,255,255)));
684 Any aLightBlue2( implMakeSolidCellStyle( pSSPool, "lightblue2" , aDefaultCellStyleName, RGB_COLORDATA(230,230,255)));
685 Any aLightBlue3( implMakeSolidCellStyle( pSSPool, "lightblue3" , aDefaultCellStyleName, RGB_COLORDATA(153,153,204)));
687 implCreateTableTemplate( xTableFamily, "lightblue" , aLightBlue1, aLightBlue3, aLightBlue2 );
689 // ---- Yellow ----------------------------------------------
691 Any aYellow1( implMakeSolidCellStyle( pSSPool, "yellow1" , aDefaultCellStyleName, RGB_COLORDATA(255,255,204)));
692 Any aYellow2( implMakeSolidCellStyle( pSSPool, "yellow2" , aDefaultCellStyleName, RGB_COLORDATA(255,255,153)));
693 Any aYellow3( implMakeSolidCellStyle( pSSPool, "yellow3" , aDefaultCellStyleName, RGB_COLORDATA(255,204,153)));
695 implCreateTableTemplate( xTableFamily, "yellow" , aYellow1, aYellow3, aYellow2 );
698 // Number of pages that reference a master page
699 sal_uInt16 SdDrawDocument::GetMasterPageUserCount(SdrPage* pMaster) const
701 sal_uInt16 nResult = 0;
702 sal_uInt16 nPage;
703 sal_uInt16 nPageCount = GetPageCount();
705 for (nPage = 0; nPage < nPageCount; nPage++)
707 const SdrPage* pPage = GetPage(nPage);
709 if(pPage->TRG_HasMasterPage())
711 if(&(pPage->TRG_GetMasterPage()) == pMaster)
713 nResult++;
717 return nResult;
721 // Finish OnlineSpelling in the background
723 void SdDrawDocument::StopOnlineSpelling()
725 if (mpOnlineSpellingTimer && mpOnlineSpellingTimer->IsActive())
727 mpOnlineSpellingTimer->Stop();
730 delete mpOnlineSpellingTimer;
731 mpOnlineSpellingTimer = NULL;
733 delete mpOnlineSpellingList;
734 mpOnlineSpellingList = NULL;
737 // Start OnlineSpelling in the background
738 void SdDrawDocument::StartOnlineSpelling(sal_Bool bForceSpelling)
740 if (mbOnlineSpell && (bForceSpelling || mbInitialOnlineSpellingEnabled) &&
741 mpDocSh && !mpDocSh->IsReadOnly() )
743 StopOnlineSpelling();
745 ::sd::Outliner* pOutl = GetInternalOutliner(sal_True);
747 Reference< XSpellChecker1 > xSpellChecker( LinguMgr::GetSpellChecker() );
748 if ( xSpellChecker.is() )
749 pOutl->SetSpeller( xSpellChecker );
751 Reference< XHyphenator > xHyphenator( LinguMgr::GetHyphenator() );
752 if( xHyphenator.is() )
753 pOutl->SetHyphenator( xHyphenator );
755 pOutl->SetDefaultLanguage( meLanguage );
757 mpOnlineSpellingList = new ShapeList;
758 sal_uInt16 nPage;
760 for ( nPage = 0; nPage < GetPageCount(); nPage++ )
762 // Search in all pages
763 FillOnlineSpellingList((SdPage*) GetPage(nPage));
766 for (nPage = 0; nPage < GetMasterPageCount(); nPage++)
768 // Search all master pages
769 FillOnlineSpellingList((SdPage*) GetMasterPage(nPage));
772 mpOnlineSpellingList->seekShape(0);
773 mpOnlineSpellingTimer = new Timer();
774 mpOnlineSpellingTimer->SetTimeoutHdl( LINK(this, SdDrawDocument, OnlineSpellingHdl) );
775 mpOnlineSpellingTimer->SetTimeout(250);
776 mpOnlineSpellingTimer->Start();
780 // Fill OnlineSpelling list
781 void SdDrawDocument::FillOnlineSpellingList(SdPage* pPage)
783 SdrObject* pObj = NULL;
784 SdrObjListIter aIter(*pPage, IM_FLAT);
786 while (aIter.IsMore())
788 pObj = aIter.Next();
790 if( !pObj )
791 continue;
793 if (pObj->GetOutlinerParaObject())
795 // Found a text object
796 mpOnlineSpellingList->addShape(*pObj);
798 else if (pObj->GetObjIdentifier() == OBJ_GRUP)
800 // Found a group object
801 SdrObjListIter aGroupIter(*((SdrObjGroup*)pObj)->GetSubList(),
802 IM_DEEPNOGROUPS);
804 sal_Bool bSubTextObjFound = sal_False;
806 while (aGroupIter.IsMore() && !bSubTextObjFound)
808 if (aGroupIter.Next()->GetOutlinerParaObject())
810 // Found a text object in a group object
811 bSubTextObjFound = sal_True;
815 if (bSubTextObjFound)
817 mpOnlineSpellingList->addShape(*pObj);
823 // OnlineSpelling in the background
824 IMPL_LINK_NOARG(SdDrawDocument, OnlineSpellingHdl)
826 if (mpOnlineSpellingList!=NULL
827 && ( !mbOnlineSpell || mpOnlineSpellingList->hasMore()))
829 // Spell next object
830 SdrObject* pObj = mpOnlineSpellingList->getNextShape();
832 if (pObj)
834 if (pObj->GetOutlinerParaObject() && pObj->ISA(SdrTextObj))
836 // Spell text object
837 SpellObject((SdrTextObj*) pObj);
839 else if (pObj->GetObjIdentifier() == OBJ_GRUP)
841 // Found a group object
842 SdrObjListIter aGroupIter(*((SdrObjGroup*)pObj)->GetSubList(),
843 IM_DEEPNOGROUPS);
845 SdrObject* pSubObj = NULL;
847 while (aGroupIter.IsMore())
849 pSubObj = aGroupIter.Next();
851 if (pSubObj->GetOutlinerParaObject() && pSubObj->ISA(SdrTextObj))
853 // Found a text object in a group object
854 SpellObject((SdrTextObj*) pSubObj);
860 // Continue search
861 mpOnlineSpellingTimer->Start();
863 else
865 // Initial spelling has finished
866 mbInitialOnlineSpellingEnabled = sal_False;
868 // Stop search
869 StopOnlineSpelling();
871 delete mpOnlineSearchItem;
872 mpOnlineSearchItem = NULL;
875 return(0);
878 // Spell object (for OnlineSpelling)
879 void SdDrawDocument::SpellObject(SdrTextObj* pObj)
881 if (pObj && pObj->GetOutlinerParaObject() /* && pObj != pView->GetTextEditObject() */)
883 mbHasOnlineSpellErrors = sal_False;
884 ::sd::Outliner* pOutl = GetInternalOutliner(sal_True);
885 pOutl->SetUpdateMode(sal_True);
886 Link aEvtHdl = pOutl->GetStatusEventHdl();
887 pOutl->SetStatusEventHdl(LINK(this, SdDrawDocument, OnlineSpellEventHdl));
889 sal_uInt16 nOldOutlMode = pOutl->GetMode();
890 sal_uInt16 nOutlMode = OUTLINERMODE_TEXTOBJECT;
891 if (((SdrTextObj*) pObj)->GetObjInventor() == SdrInventor &&
892 ((SdrTextObj*) pObj)->GetObjIdentifier() == OBJ_OUTLINETEXT)
894 nOutlMode = OUTLINERMODE_OUTLINEOBJECT;
896 pOutl->Init( nOutlMode );
898 // Put text into the outliner
899 pOutl->SetText(*((SdrTextObj*) pObj)->GetOutlinerParaObject());
901 if (!mpOnlineSearchItem || pOutl->HasText(*mpOnlineSearchItem))
903 // Spelling
904 pOutl->CompleteOnlineSpelling();
906 if (mbHasOnlineSpellErrors)
908 sd::ModifyGuard aGuard( this );
909 SdrModel* pModel = pObj->GetModel();
910 bool bLock = sal_False;
911 if ( pModel )
913 bLock = pModel->isLocked();
914 pModel->setLock(true);
916 // taking text from the outliner
917 ((SdrTextObj*) pObj)->SetOutlinerParaObject( pOutl->CreateParaObject() );
919 pObj->BroadcastObjectChange();
920 if ( pModel )
921 pModel->setLock(bLock);
925 pOutl->SetStatusEventHdl(aEvtHdl);
926 pOutl->SetUpdateMode(sal_False);
927 pOutl->Init( nOldOutlMode );
928 mbHasOnlineSpellErrors = sal_False;
932 // Object was inserted into model
933 void SdDrawDocument::InsertObject(SdrObject* pObj, SdPage* /*pPage*/)
935 if(mpOnlineSpellingList && pObj)
937 if (pObj->GetOutlinerParaObject() || (pObj->GetObjIdentifier() == OBJ_GRUP))
939 // Add object to OnlineSpelling list
940 mpOnlineSpellingList->addShape(*pObj);
945 // Object removed from model
946 void SdDrawDocument::RemoveObject(SdrObject* pObj, SdPage* /*pPage*/)
948 if(mpOnlineSpellingList && pObj)
950 if (pObj->GetOutlinerParaObject() || (pObj->GetObjIdentifier() == OBJ_GRUP))
952 // Replace object in OnlineSpelling list by 0 pointer
953 mpOnlineSpellingList->removeShape(*pObj);
958 // Callback for ExecuteSpellPopup()
959 IMPL_LINK(SdDrawDocument, OnlineSpellEventHdl, EditStatus*, pEditStat)
961 sal_uLong nStat = pEditStat->GetStatusWord();
962 mbHasOnlineSpellErrors = (nStat & EE_STAT_WRONGWORDCHANGED) != 0;
964 return(0);
967 // Callback for ExecuteSpellPopup()
969 // removed link and replaced with Imp method
970 void SdDrawDocument::ImpOnlineSpellCallback(SpellCallbackInfo* pInfo, SdrObject* pObj, SdrOutliner* pOutl)
972 delete mpOnlineSearchItem;
973 mpOnlineSearchItem = NULL;
975 sal_uInt16 nCommand = pInfo->nCommand;
977 if (nCommand == SPELLCMD_IGNOREWORD
978 // restart when add to dictionary takes place, too.
979 || nCommand == SPELLCMD_ADDTODICTIONARY)
981 if(pObj && pOutl && pObj->ISA(SdrTextObj))
983 sal_Bool bModified(IsChanged());
984 ((SdrTextObj*)pObj)->SetOutlinerParaObject(pOutl->CreateParaObject());
985 SetChanged(bModified);
986 pObj->BroadcastObjectChange();
989 mpOnlineSearchItem = new SvxSearchItem( SID_SEARCH_ITEM );
990 mpOnlineSearchItem->SetSearchString(pInfo->aWord);
991 StartOnlineSpelling();
993 else if (nCommand == SPELLCMD_STARTSPELLDLG)
995 SfxViewFrame::Current()->GetDispatcher()->Execute( SID_SPELL_DIALOG,
996 SFX_CALLMODE_ASYNCHRON );
1000 // Replace the unambiguous names of the default layers by their names in the
1001 // native language
1002 void SdDrawDocument::RestoreLayerNames()
1004 SdrLayerAdmin& rLayerAdmin = GetLayerAdmin();
1005 sal_uInt16 nLayerCount = rLayerAdmin.GetLayerCount();
1007 for (sal_uInt16 nLayer = 0; nLayer < nLayerCount; nLayer++)
1009 SdrLayer* pLayer = rLayerAdmin.GetLayer(nLayer);
1011 if (pLayer)
1013 String aLayerName(pLayer->GetName());
1015 if (aLayerName.EqualsAscii( "LAYER_LAYOUT" ))
1017 pLayer->SetName(String(SdResId(STR_LAYER_LAYOUT)));
1019 else if (aLayerName.EqualsAscii( "LAYER_BCKGRND" ))
1021 pLayer->SetName(String(SdResId(STR_LAYER_BCKGRND)));
1023 else if (aLayerName.EqualsAscii( "LAYER_BACKGRNDOBJ" ))
1025 pLayer->SetName(String(SdResId(STR_LAYER_BCKGRNDOBJ)));
1027 else if (aLayerName.EqualsAscii( "LAYER_CONTROLS" ))
1029 pLayer->SetName(String(SdResId(STR_LAYER_CONTROLS)));
1031 else if (aLayerName.EqualsAscii( "LAYER_MEASURELINES" ))
1033 pLayer->SetName(String(SdResId(STR_LAYER_MEASURELINES)));
1039 // Return formatted page number (1, I, i, a, etc.)
1040 String SdDrawDocument::CreatePageNumValue(sal_uInt16 nNum) const
1042 String aPageNumValue;
1043 sal_Bool bUpper = sal_False;
1045 switch (mePageNumType)
1047 case SVX_CHARS_UPPER_LETTER:
1048 aPageNumValue += (sal_Unicode)(char)((nNum - 1) % 26 + 'A');
1049 break;
1050 case SVX_CHARS_LOWER_LETTER:
1051 aPageNumValue += (sal_Unicode)(char)((nNum - 1) % 26 + 'a');
1052 break;
1053 case SVX_ROMAN_UPPER:
1054 bUpper = sal_True;
1055 case SVX_ROMAN_LOWER:
1056 aPageNumValue += SvxNumberFormat::CreateRomanString(nNum, bUpper);
1057 break;
1058 case SVX_NUMBER_NONE:
1059 aPageNumValue.Erase();
1060 aPageNumValue += sal_Unicode(' ');
1061 break;
1062 default:
1063 aPageNumValue += OUString::number(nNum);
1066 return(aPageNumValue);
1071 // Rename layout template
1072 // Keep in mind that rOldLayoutName contains the _complete_ name of the layout
1073 // (including ~LT~). This is unlike rNewName.
1074 void SdDrawDocument::RenameLayoutTemplate(const String& rOldLayoutName, const String& rNewName)
1076 String aOldName(rOldLayoutName);
1077 sal_uInt16 nPos = aOldName.SearchAscii( SD_LT_SEPARATOR );
1079 // erase everything after '~LT~'
1080 aOldName.Erase(nPos + sizeof(SD_LT_SEPARATOR) - 1 );
1081 sal_uInt16 nLen = aOldName.Len();
1083 std::vector<StyleReplaceData> aReplList;
1084 SfxStyleSheetIterator aIter(mxStyleSheetPool.get(), SD_STYLE_FAMILY_MASTERPAGE);
1085 SfxStyleSheetBase* pSheet = aIter.First();
1087 while (pSheet)
1089 String aSheetName = pSheet->GetName();
1091 // if the sheetname starts with aOldName + "~LT~"
1092 if (aSheetName.Match(aOldName) == nLen)
1094 aSheetName.Erase(0, nLen - sizeof(SD_LT_SEPARATOR) + 1 );
1095 aSheetName.Insert(rNewName, 0);
1097 StyleReplaceData aReplData;
1098 aReplData.nFamily = pSheet->GetFamily();
1099 aReplData.nNewFamily = pSheet->GetFamily();
1100 aReplData.aName = pSheet->GetName();
1101 aReplData.aNewName = aSheetName;
1102 aReplList.push_back(aReplData);
1104 pSheet->SetName(aSheetName);
1107 pSheet = aIter.Next();
1110 // Now set the layout name of the drawing and the notes page, as well as
1111 // their master pages.
1112 String aPageLayoutName(rNewName);
1113 aPageLayoutName.AppendAscii( RTL_CONSTASCII_STRINGPARAM( SD_LT_SEPARATOR ));
1114 aPageLayoutName += String(SdResId(STR_LAYOUT_OUTLINE));
1116 // Inform all text objects on pages that use the renamed layout and set the
1117 // new name.
1118 sal_uInt16 nPage;
1119 for (nPage = 0; nPage < GetPageCount(); nPage++)
1121 SdPage* pPage = (SdPage*) GetPage(nPage);
1122 String aTemp(pPage->GetLayoutName());
1124 if (aTemp == rOldLayoutName)
1126 pPage->SetLayoutName(aPageLayoutName);
1128 for (sal_uLong nObj = 0; nObj < pPage->GetObjCount(); nObj++)
1130 SdrObject* pObj = pPage->GetObj(nObj);
1132 if (pObj->GetObjInventor() == SdrInventor)
1134 switch( pObj->GetObjIdentifier() )
1136 case OBJ_TEXT:
1137 case OBJ_OUTLINETEXT:
1138 case OBJ_TITLETEXT:
1140 OutlinerParaObject* pOPO = ((SdrTextObj*) pObj)->GetOutlinerParaObject();
1142 if (pOPO)
1144 std::vector<StyleReplaceData>::iterator it;
1145 for (it = aReplList.begin(); it != aReplList.end(); ++it)
1146 pOPO->ChangeStyleSheets( it->aName, it->nFamily, it->aNewName, it->nNewFamily );
1149 break;
1151 default:
1152 break;
1159 // Now do this again for all master pages.
1160 // The affected master pages get the name of the layout as their page name.
1161 for (nPage = 0; nPage < GetMasterPageCount(); nPage++)
1163 SdPage* pPage = (SdPage*) GetMasterPage(nPage);
1164 String aTemp(pPage->GetLayoutName());
1166 if (aTemp == rOldLayoutName)
1168 pPage->SetLayoutName(aPageLayoutName);
1169 pPage->SetName(rNewName);
1171 for (sal_uLong nObj = 0; nObj < pPage->GetObjCount(); nObj++)
1173 SdrObject* pObj = pPage->GetObj(nObj);
1175 if (pObj->GetObjInventor() == SdrInventor)
1177 switch(pObj->GetObjIdentifier())
1179 case OBJ_TEXT:
1180 case OBJ_OUTLINETEXT:
1181 case OBJ_TITLETEXT:
1183 OutlinerParaObject* pOPO = ((SdrTextObj*)pObj)->GetOutlinerParaObject();
1185 if (pOPO)
1187 std::vector<StyleReplaceData>::iterator it;
1188 for (it = aReplList.begin(); it != aReplList.end(); ++it)
1189 pOPO->ChangeStyleSheets( it->aName, it->nFamily, it->aNewName, it->nNewFamily );
1192 break;
1194 default:
1195 break;
1203 // Set outliner defaults (pool defaults)
1204 void SdDrawDocument::SetTextDefaults() const
1206 // BulletItem and BulletFont for Titel and Outline
1207 SvxBulletItem aBulletItem(EE_PARA_BULLET);
1208 Font aBulletFont( static_cast<SdStyleSheetPool*>( mxStyleSheetPool.get())->GetBulletFont() );
1209 aBulletFont.SetSize(Size(0,846)); // 24 pt
1210 aBulletItem.SetFont(aBulletFont);
1211 aBulletItem.SetStyle(BS_BULLET);
1212 aBulletItem.SetStart(1);
1213 aBulletItem.SetScale(45); // In percent
1214 aBulletItem.SetSymbol( 0x25CF ); // In points
1215 pItemPool->SetPoolDefaultItem( aBulletItem );
1217 // New BulletItem
1218 SvxNumberFormat aNumberFormat(SVX_NUM_CHAR_SPECIAL);
1219 aNumberFormat.SetBulletFont(&aBulletFont);
1220 aNumberFormat.SetBulletChar( 0x25CF ); // StarBats: 0xF000 + 34
1221 aNumberFormat.SetBulletRelSize(45);
1222 aNumberFormat.SetBulletColor(Color(COL_AUTO));
1223 aNumberFormat.SetStart(1);
1224 aNumberFormat.SetNumAdjust(SVX_ADJUST_LEFT);
1226 SvxNumRule aNumRule( NUM_BULLET_REL_SIZE|NUM_BULLET_COLOR|NUM_CHAR_TEXT_DISTANCE, SVX_MAX_NUM, sal_False);
1228 //aNumberFormat.SetLSpace( 0 );
1229 //aNumberFormat.SetAbsLSpace( 0 );
1230 //aNumberFormat.SetFirstLineOffset( 0 );
1231 //aNumRule.SetLevel( 0, aNumberFormat );
1233 for( sal_uInt16 i = 0; i < aNumRule.GetLevelCount(); i++ )
1235 const short nLSpace = (i + 1) * 600;
1236 aNumberFormat.SetLSpace(nLSpace);
1237 aNumberFormat.SetAbsLSpace(nLSpace);
1238 aNumberFormat.SetFirstLineOffset(-600);
1239 aNumRule.SetLevel( i, aNumberFormat );
1242 SvxNumBulletItem aNumBulletItem( aNumRule, EE_PARA_NUMBULLET );
1243 pItemPool->SetPoolDefaultItem( aNumBulletItem );
1246 ::com::sun::star::text::WritingMode SdDrawDocument::GetDefaultWritingMode() const
1248 const SfxPoolItem* pItem = ( pItemPool ? pItemPool->GetPoolDefaultItem( EE_PARA_WRITINGDIR ) : NULL );
1249 ::com::sun::star::text::WritingMode eRet = ::com::sun::star::text::WritingMode_LR_TB;
1251 if( pItem )
1253 switch( ( (SvxFrameDirectionItem&)( *pItem ) ).GetValue() )
1255 case( FRMDIR_HORI_LEFT_TOP ): eRet = ::com::sun::star::text::WritingMode_LR_TB; break;
1256 case( FRMDIR_HORI_RIGHT_TOP ): eRet = ::com::sun::star::text::WritingMode_RL_TB; break;
1257 case( FRMDIR_VERT_TOP_RIGHT ): eRet = ::com::sun::star::text::WritingMode_TB_RL; break;
1259 default:
1260 OSL_FAIL( "Frame direction not supported yet" );
1261 break;
1265 return eRet;
1268 void SdDrawDocument::SetDefaultWritingMode(::com::sun::star::text::WritingMode eMode )
1270 if( pItemPool )
1272 SvxFrameDirection nVal;
1273 switch( eMode )
1275 case ::com::sun::star::text::WritingMode_LR_TB: nVal = FRMDIR_HORI_LEFT_TOP; break;
1276 case ::com::sun::star::text::WritingMode_RL_TB: nVal = FRMDIR_HORI_RIGHT_TOP; break;
1277 case ::com::sun::star::text::WritingMode_TB_RL: nVal = FRMDIR_VERT_TOP_RIGHT; break;
1278 default:
1279 OSL_FAIL( "Frame direction not supported yet" );
1280 return;
1283 SvxFrameDirectionItem aModeItem( nVal, EE_PARA_WRITINGDIR );
1284 pItemPool->SetPoolDefaultItem( aModeItem );
1286 SvxAdjustItem aAdjust( SVX_ADJUST_LEFT, EE_PARA_JUST );
1288 if( eMode == ::com::sun::star::text::WritingMode_RL_TB )
1289 aAdjust.SetEnumValue( SVX_ADJUST_RIGHT );
1291 pItemPool->SetPoolDefaultItem( aAdjust );
1297 void SdDrawDocument::getDefaultFonts( Font& rLatinFont, Font& rCJKFont, Font& rCTLFont )
1299 LanguageType eLatin = GetLanguage( EE_CHAR_LANGUAGE );
1301 // If the UI language is Korean, the default Latin font has to
1302 // be queried for Korean, too (the Latin language from the document can't be Korean).
1303 // This is the same logic as in SwDocShell::InitNew.
1304 LanguageType eUiLanguage = Application::GetSettings().GetUILanguageTag().getLanguageType();
1305 if (MsLangId::isKorean(eUiLanguage))
1306 eLatin = eUiLanguage;
1308 rLatinFont = OutputDevice::GetDefaultFont( DEFAULTFONT_LATIN_PRESENTATION, eLatin, DEFAULTFONT_FLAGS_ONLYONE );
1309 rCJKFont = OutputDevice::GetDefaultFont( DEFAULTFONT_CJK_PRESENTATION, GetLanguage( EE_CHAR_LANGUAGE_CJK ), DEFAULTFONT_FLAGS_ONLYONE );
1310 rCTLFont = OutputDevice::GetDefaultFont( DEFAULTFONT_CTL_PRESENTATION, GetLanguage( EE_CHAR_LANGUAGE_CTL ), DEFAULTFONT_FLAGS_ONLYONE ) ;
1313 /* converts the given western font height to a corresponding ctl font height, deppending on the system language */
1314 sal_uInt32 SdDrawDocument::convertFontHeightToCTL( sal_uInt32 nWesternFontHeight )
1316 LanguageType eRealCTLLanguage = Application::GetSettings().GetLanguageTag().getLanguageType();
1317 if( LANGUAGE_THAI == eRealCTLLanguage )
1319 // http://specs.openoffice.org/g11n/font_sizes/42775_42725_Individual_configurable_font_size_for_default_fonts.odt
1320 double fTemp = double(nWesternFontHeight) * 1.333;
1321 nWesternFontHeight = (sal_uInt32)fTemp;
1322 // make some nice values for UI that displays PT instead of 1/100th mm
1323 nWesternFontHeight = ((nWesternFontHeight * 72) + 1270) / 2540L;
1324 nWesternFontHeight = ((nWesternFontHeight * 2540L) + 36) / 72;
1326 return nWesternFontHeight;
1329 SdStyleSheetPool* SdDrawDocument::GetSdStyleSheetPool() const
1331 return dynamic_cast< SdStyleSheetPool* >( GetStyleSheetPool() );
1334 ModifyGuard::ModifyGuard( SdDrawDocument* pDoc )
1335 : mpDocShell( 0 ), mpDoc( pDoc )
1337 init();
1340 void ModifyGuard::init()
1342 if( mpDocShell )
1344 mpDoc = mpDocShell->GetDoc();
1346 else if( mpDoc )
1348 mpDocShell = mpDoc->GetDocSh();
1351 mbIsEnableSetModified = mpDocShell ? mpDocShell->IsEnableSetModified() : sal_False;
1352 mbIsDocumentChanged = mpDoc ? mpDoc->IsChanged() : sal_False;
1354 if( mbIsEnableSetModified )
1355 mpDocShell->EnableSetModified( sal_False );
1358 ModifyGuard::~ModifyGuard()
1360 if( mbIsEnableSetModified )
1361 mpDocShell->EnableSetModified( sal_True );
1363 if( mpDoc && (mpDoc->IsChanged() != mbIsDocumentChanged) )
1364 mpDoc->SetChanged(mbIsDocumentChanged);
1367 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */