Line data Source code
1 : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 : /*
3 : * This file is part of the LibreOffice project.
4 : *
5 : * This Source Code Form is subject to the terms of the Mozilla Public
6 : * License, v. 2.0. If a copy of the MPL was not distributed with this
7 : * file, You can obtain one at http://mozilla.org/MPL/2.0/.
8 : *
9 : * This file incorporates work covered by the following license notice:
10 : *
11 : * Licensed to the Apache Software Foundation (ASF) under one or more
12 : * contributor license agreements. See the NOTICE file distributed
13 : * with this work for additional information regarding copyright
14 : * ownership. The ASF licenses this file to you under the Apache
15 : * License, Version 2.0 (the "License"); you may not use this file
16 : * except in compliance with the License. You may obtain a copy of
17 : * the License at http://www.apache.org/licenses/LICENSE-2.0 .
18 : */
19 :
20 : #include <com/sun/star/style/XStyleFamiliesSupplier.hpp>
21 : #include <com/sun/star/beans/XPropertySet.hpp>
22 : #include <com/sun/star/container/XNameAccess.hpp>
23 :
24 : #include "futempl.hxx"
25 :
26 : #include <editeng/editdata.hxx>
27 : #include <editeng/bulletitem.hxx>
28 : #include <svx/svxids.hrc>
29 : #include <sfx2/bindings.hxx>
30 : #include <svl/aeitem.hxx>
31 : #include <sfx2/dispatch.hxx>
32 : #include <vcl/msgbox.hxx>
33 : #include <editeng/eeitem.hxx>
34 : #include <sfx2/request.hxx>
35 : #include <editeng/numitem.hxx>
36 : #include <editeng/editeng.hxx>
37 : #include <editeng/lrspitem.hxx>
38 : #include <svx/svdopage.hxx>
39 : #include <svx/svditer.hxx>
40 : #include <svx/sdr/properties/properties.hxx>
41 :
42 : #include <sfx2/viewfrm.hxx>
43 : #include <svx/xlndsit.hxx>
44 : #include <svx/xlnstit.hxx>
45 : #include <svx/xlnedit.hxx>
46 : #include "app.hrc"
47 : #include "stlsheet.hxx"
48 : #include "sdpage.hxx"
49 : #include "stlpool.hxx"
50 : #include "sdmod.hxx"
51 : #include "View.hxx"
52 : #include "Window.hxx"
53 : #include "drawview.hxx"
54 : #include "drawdoc.hxx"
55 : #include "DrawDocShell.hxx"
56 : #include "DrawViewShell.hxx"
57 : #include "ViewShell.hxx"
58 : #include "res_bmp.hrc"
59 : #include "glob.hrc"
60 : #include "prlayout.hxx"
61 : #include "prltempl.hrc"
62 : #include <svx/xfillit.hxx>
63 : #include "sdresid.hxx"
64 : #include "OutlineViewShell.hxx"
65 : #include "strings.hrc"
66 : #include "helpids.h"
67 : #include "sdabstdlg.hxx"
68 : #include <boost/scoped_ptr.hpp>
69 :
70 : using namespace com::sun::star::uno;
71 : using namespace com::sun::star::container;
72 : using namespace com::sun::star::beans;
73 : using namespace com::sun::star::style;
74 :
75 : namespace sd
76 : {
77 :
78 0 : TYPEINIT1( FuTemplate, FuPoor );
79 :
80 0 : FuTemplate::FuTemplate (
81 : ViewShell* pViewSh,
82 : ::sd::Window* pWin,
83 : ::sd::View* pView,
84 : SdDrawDocument* pDoc,
85 : SfxRequest& rReq )
86 0 : : FuPoor( pViewSh, pWin, pView, pDoc, rReq )
87 : {
88 0 : }
89 :
90 0 : rtl::Reference<FuPoor> FuTemplate::Create( ViewShell* pViewSh, ::sd::Window* pWin, ::sd::View* pView, SdDrawDocument* pDoc, SfxRequest& rReq )
91 : {
92 0 : rtl::Reference<FuPoor> xFunc( new FuTemplate( pViewSh, pWin, pView, pDoc, rReq ) );
93 0 : xFunc->DoExecute(rReq);
94 0 : return xFunc;
95 : }
96 :
97 0 : void FuTemplate::DoExecute( SfxRequest& rReq )
98 : {
99 0 : const SfxItemSet* pArgs = rReq.GetArgs();
100 0 : sal_uInt16 nSId = rReq.GetSlot();
101 :
102 : // get StyleSheet parameter
103 0 : SfxStyleSheetBasePool* pSSPool = mpDoc->GetDocSh()->GetStyleSheetPool();
104 0 : SfxStyleSheetBase* pStyleSheet = NULL;
105 :
106 : const SfxPoolItem* pItem;
107 0 : sal_uInt16 nFamily = USHRT_MAX;
108 0 : if( pArgs && SfxItemState::SET == pArgs->GetItemState( SID_STYLE_FAMILY,
109 0 : false, &pItem ))
110 : {
111 0 : nFamily = static_cast<const SfxUInt16Item &>( pArgs->Get( SID_STYLE_FAMILY ) ).GetValue();
112 : }
113 0 : else if( pArgs && SfxItemState::SET == pArgs->GetItemState( SID_STYLE_FAMILYNAME,
114 0 : false, &pItem ))
115 : {
116 0 : OUString sFamily = static_cast<const SfxStringItem &>( pArgs->Get( SID_STYLE_FAMILYNAME ) ).GetValue();
117 0 : if (sFamily == "graphics")
118 0 : nFamily = SD_STYLE_FAMILY_GRAPHICS;
119 : else
120 0 : nFamily = SD_STYLE_FAMILY_PSEUDO;
121 : }
122 :
123 0 : OUString aStyleName;
124 0 : sal_uInt16 nRetMask = SFXSTYLEBIT_ALL;
125 :
126 0 : switch( nSId )
127 : {
128 : case SID_STYLE_APPLY:
129 : case SID_STYLE_EDIT:
130 : case SID_STYLE_DELETE:
131 : case SID_STYLE_HIDE:
132 : case SID_STYLE_SHOW:
133 : case SID_STYLE_FAMILY:
134 : case SID_STYLE_NEW_BY_EXAMPLE:
135 : {
136 0 : SFX_REQUEST_ARG( rReq, pNameItem, SfxStringItem, SID_APPLY_STYLE, false );
137 0 : SFX_REQUEST_ARG( rReq, pFamilyItem, SfxStringItem, SID_STYLE_FAMILYNAME, false );
138 0 : if ( pFamilyItem && pNameItem )
139 : {
140 : try
141 : {
142 0 : Reference< XStyleFamiliesSupplier > xModel(mpDoc->GetDocSh()->GetModel(), UNO_QUERY_THROW );
143 0 : Reference< XNameAccess > xCont( xModel->getStyleFamilies() );
144 0 : Reference< XNameAccess > xStyles( xCont->getByName(pFamilyItem->GetValue()), UNO_QUERY_THROW );
145 0 : Reference< XPropertySet > xInfo( xStyles->getByName( pNameItem->GetValue() ), UNO_QUERY_THROW );
146 :
147 0 : OUString aUIName;
148 0 : xInfo->getPropertyValue( "DisplayName" ) >>= aUIName;
149 0 : if ( !aUIName.isEmpty() )
150 0 : rReq.AppendItem( SfxStringItem( nSId, aUIName ) );
151 : }
152 0 : catch( Exception& )
153 : {
154 : }
155 : }
156 :
157 0 : if (pArgs && pArgs->GetItemState(nSId) == SfxItemState::SET)
158 0 : aStyleName = static_cast<const SfxStringItem &>( pArgs->Get( nSId ) ).GetValue();
159 : }
160 : }
161 :
162 0 : switch( nSId )
163 : {
164 : case SID_STYLE_NEW:
165 : {
166 0 : SfxStyleSheetBase *p = pSSPool->Find(aStyleName, (SfxStyleFamily) nFamily, SFXSTYLEBIT_ALL );
167 0 : if(p)
168 : {
169 0 : pSSPool->Remove(p);
170 0 : p = 0;
171 : }
172 0 : pStyleSheet = &pSSPool->Make( aStyleName, (SfxStyleFamily) nFamily, SFXSTYLEBIT_USERDEF );
173 :
174 0 : if (pArgs && pArgs->GetItemState(SID_STYLE_REFERENCE) == SfxItemState::SET)
175 : {
176 0 : OUString aParentName(static_cast<const SfxStringItem&>( pArgs->Get(SID_STYLE_REFERENCE)).GetValue());
177 0 : pStyleSheet->SetParent(aParentName);
178 : }
179 : else
180 : {
181 0 : pStyleSheet->SetParent(SD_RESSTR(STR_STANDARD_STYLESHEET_NAME));
182 : }
183 : }
184 0 : break;
185 :
186 : case SID_STYLE_NEW_BY_EXAMPLE:
187 : {
188 : // at the moment, the dialog to enter the name of the template is still opened
189 0 : SfxStyleSheetBase *p = pSSPool->Find(aStyleName, (SfxStyleFamily) nFamily, SFXSTYLEBIT_ALL );
190 0 : if(p)
191 : {
192 0 : pSSPool->Remove(p);
193 0 : p = 0;
194 : }
195 0 : pStyleSheet = &pSSPool->Make( aStyleName, (SfxStyleFamily) nFamily, SFXSTYLEBIT_USERDEF );
196 0 : pStyleSheet->SetParent(SD_RESSTR(STR_STANDARD_STYLESHEET_NAME));
197 : }
198 0 : break;
199 :
200 : case SID_STYLE_EDIT:
201 0 : pStyleSheet = pSSPool->Find( aStyleName, (SfxStyleFamily) nFamily);
202 0 : break;
203 :
204 : case SID_STYLE_DELETE:
205 0 : pStyleSheet = pSSPool->Find( aStyleName, (SfxStyleFamily) nFamily);
206 0 : if( pStyleSheet )
207 : {
208 0 : pSSPool->Remove( pStyleSheet );
209 0 : nRetMask = sal_uInt16(true);
210 0 : mpDoc->SetChanged(true);
211 : }
212 : else
213 : {
214 0 : nRetMask = sal_uInt16(false);
215 : }
216 0 : break;
217 :
218 : case SID_STYLE_HIDE:
219 : case SID_STYLE_SHOW:
220 0 : pStyleSheet = pSSPool->Find( aStyleName, (SfxStyleFamily) nFamily);
221 0 : pStyleSheet->SetHidden( nSId == SID_STYLE_HIDE );
222 0 : nRetMask = sal_uInt16(true);
223 0 : break;
224 :
225 : case SID_STYLE_APPLY:
226 : // apply the template to the document
227 0 : pStyleSheet = pSSPool->Find( aStyleName, (SfxStyleFamily) nFamily);
228 :
229 : // do not set presentation styles, they will be set implicit
230 0 : if ( pStyleSheet && pStyleSheet->GetFamily() != SD_STYLE_FAMILY_PSEUDO )
231 : {
232 0 : SfxStyleSheet* pOldStyleSheet = mpView->GetStyleSheet();
233 0 : OUString aStr;
234 :
235 0 : if( // if the object had no style sheet, allow all
236 0 : !pOldStyleSheet ||
237 :
238 : // allow if old and new style sheet has same family
239 0 : pStyleSheet->GetFamily() == pOldStyleSheet->GetFamily() ||
240 :
241 : // allow if old was background objects and new is graphics
242 0 : (pStyleSheet->GetFamily() == SD_STYLE_FAMILY_GRAPHICS && pOldStyleSheet->GetHelpId( aStr ) == HID_PSEUDOSHEET_BACKGROUNDOBJECTS) ||
243 :
244 : // allow if old was presentation and we are a drawing document
245 0 : (pOldStyleSheet->GetFamily() == SD_STYLE_FAMILY_MASTERPAGE && mpDoc->GetDocumentType() == DOCUMENT_TYPE_DRAW) )
246 : {
247 0 : mpView->SetStyleSheet( static_cast<SfxStyleSheet*>(pStyleSheet));
248 0 : mpDoc->SetChanged(true);
249 0 : mpViewShell->GetViewFrame()->GetBindings().Invalidate( SID_STYLE_FAMILY2 );
250 0 : }
251 : }
252 0 : break;
253 :
254 : case SID_STYLE_WATERCAN:
255 : {
256 0 : if( !SD_MOD()->GetWaterCan() )
257 : {
258 0 : if (pArgs && pArgs->GetItemState( nSId ) == SfxItemState::SET)
259 : {
260 0 : aStyleName = static_cast<const SfxStringItem &>( pArgs->Get( nSId ) ).GetValue();
261 0 : SD_MOD()->SetWaterCan( true );
262 0 : pStyleSheet = pSSPool->Find( aStyleName, (SfxStyleFamily) nFamily);
263 : }
264 : // no presentation object templates, they are only allowed implicitly
265 0 : if( pStyleSheet && pStyleSheet->GetFamily() != SD_STYLE_FAMILY_PSEUDO )
266 : {
267 0 : static_cast<SdStyleSheetPool*>( pSSPool )->SetActualStyleSheet( pStyleSheet );
268 :
269 : // we switch explicitly into selection mode
270 : mpViewShell->GetViewFrame()->GetDispatcher()->Execute( SID_OBJECT_SELECT,
271 0 : SfxCallMode::ASYNCHRON | SfxCallMode::RECORD );
272 :
273 : }
274 : else
275 0 : SD_MOD()->SetWaterCan( false );
276 : }
277 : else
278 : {
279 0 : SD_MOD()->SetWaterCan( false );
280 : // we have to re-enable to tools-bar
281 0 : mpViewShell->Invalidate();
282 : }
283 : }
284 0 : break;
285 :
286 : default:
287 0 : break;
288 : }
289 :
290 0 : switch( nSId )
291 : {
292 : case SID_STYLE_NEW:
293 : case SID_STYLE_EDIT:
294 : {
295 0 : PresentationObjects ePO = PO_OUTLINE_1;
296 :
297 0 : if( pStyleSheet )
298 : {
299 0 : boost::scoped_ptr<SfxAbstractTabDialog> pStdDlg;
300 0 : boost::scoped_ptr<SfxAbstractTabDialog> pPresDlg;
301 0 : SdAbstractDialogFactory* pFact = SdAbstractDialogFactory::Create();
302 0 : bool bOldDocInOtherLanguage = false;
303 0 : SfxItemSet aOriSet( pStyleSheet->GetItemSet() );
304 :
305 0 : SfxStyleFamily eFamily = pStyleSheet->GetFamily();
306 :
307 0 : if (eFamily == SD_STYLE_FAMILY_GRAPHICS)
308 : {
309 0 : pStdDlg.reset(pFact ? pFact->CreateSdTabTemplateDlg( 0, mpDoc->GetDocSh(), *pStyleSheet, mpDoc, mpView ) : 0);
310 : }
311 0 : else if (eFamily == SD_STYLE_FAMILY_PSEUDO)
312 : {
313 0 : OUString aName(pStyleSheet->GetName());
314 0 : sal_uInt16 nDlgId = 0;
315 :
316 0 : if (aName == SD_RESSTR(STR_PSEUDOSHEET_TITLE))
317 : {
318 0 : nDlgId = TAB_PRES_LAYOUT_TEMPLATE;
319 0 : ePO = PO_TITLE;
320 : }
321 0 : else if (aName == SD_RESSTR(STR_PSEUDOSHEET_SUBTITLE))
322 : {
323 0 : nDlgId = TAB_PRES_LAYOUT_TEMPLATE;
324 0 : ePO = PO_SUBTITLE;
325 : }
326 0 : else if (aName ==
327 : SD_RESSTR(STR_PSEUDOSHEET_BACKGROUND))
328 : {
329 0 : nDlgId = TAB_PRES_LAYOUT_TEMPLATE_BACKGROUND;
330 0 : ePO = PO_BACKGROUND;
331 : }
332 0 : else if (aName ==
333 : SD_RESSTR(STR_PSEUDOSHEET_BACKGROUNDOBJECTS))
334 : {
335 0 : nDlgId = TAB_PRES_LAYOUT_TEMPLATE;
336 0 : ePO = PO_BACKGROUNDOBJECTS;
337 : }
338 0 : else if (aName ==
339 : SD_RESSTR(STR_PSEUDOSHEET_NOTES))
340 : {
341 0 : nDlgId = TAB_PRES_LAYOUT_TEMPLATE;
342 0 : ePO = PO_NOTES;
343 : }
344 0 : else if(aName.indexOf(SD_RESSTR(STR_PSEUDOSHEET_OUTLINE)) != -1)
345 : {
346 0 : nDlgId = TAB_PRES_LAYOUT_TEMPLATE;
347 :
348 0 : OUString aOutlineStr(SD_RESSTR(STR_PSEUDOSHEET_OUTLINE));
349 : // determine number, mind the blank between name and number
350 0 : OUString aNumStr(aName.copy(aOutlineStr.getLength() + 1));
351 0 : sal_uInt16 nLevel = (sal_uInt16)aNumStr.toInt32();
352 0 : switch (nLevel)
353 : {
354 0 : case 1: ePO = PO_OUTLINE_1; break;
355 0 : case 2: ePO = PO_OUTLINE_2; break;
356 0 : case 3: ePO = PO_OUTLINE_3; break;
357 0 : case 4: ePO = PO_OUTLINE_4; break;
358 0 : case 5: ePO = PO_OUTLINE_5; break;
359 0 : case 6: ePO = PO_OUTLINE_6; break;
360 0 : case 7: ePO = PO_OUTLINE_7; break;
361 0 : case 8: ePO = PO_OUTLINE_8; break;
362 0 : case 9: ePO = PO_OUTLINE_9; break;
363 0 : }
364 : }
365 : else
366 : {
367 : OSL_FAIL("StyleSheet from older version with different language");
368 0 : bOldDocInOtherLanguage = true;
369 : }
370 :
371 0 : if( !bOldDocInOtherLanguage )
372 : {
373 0 : pPresDlg.reset(pFact ? pFact->CreateSdPresLayoutTemplateDlg( mpDocSh, NULL, SdResId(nDlgId), *pStyleSheet, ePO, pSSPool ) : 0);
374 0 : }
375 : }
376 : else if (eFamily == SD_STYLE_FAMILY_CELL)
377 : {
378 : }
379 :
380 0 : sal_uInt16 nResult = RET_CANCEL;
381 0 : const SfxItemSet* pOutSet = NULL;
382 0 : if (pStdDlg)
383 : {
384 0 : nResult = pStdDlg->Execute();
385 0 : pOutSet = pStdDlg->GetOutputItemSet();
386 : }
387 0 : else if( pPresDlg )
388 : {
389 0 : nResult = pPresDlg->Execute();
390 0 : pOutSet = pPresDlg->GetOutputItemSet();
391 : }
392 :
393 0 : switch( nResult )
394 : {
395 : case RET_OK:
396 : {
397 0 : nRetMask = pStyleSheet->GetMask();
398 :
399 0 : if (eFamily == SD_STYLE_FAMILY_PSEUDO)
400 : {
401 0 : SfxItemSet aTempSet(*pOutSet);
402 0 : static_cast<SdStyleSheet*>(pStyleSheet)->AdjustToFontHeight(aTempSet);
403 :
404 : /* Special treatment: reset the INVALIDS to
405 : NULL-Pointer (otherwise INVALIDs or pointer point
406 : to DefaultItems in the template; both would
407 : prevent the attribute inheritance) */
408 0 : aTempSet.ClearInvalidItems();
409 :
410 : // EE_PARA_NUMBULLET item is only valid in first outline template
411 0 : if( (ePO >= PO_OUTLINE_2) && (ePO <= PO_OUTLINE_9) )
412 : {
413 0 : if (aTempSet.GetItemState(EE_PARA_NUMBULLET) == SfxItemState::SET)
414 : {
415 0 : SvxNumRule aRule(*static_cast<const SvxNumBulletItem*>(aTempSet.GetItem(EE_PARA_NUMBULLET))->GetNumRule());
416 :
417 0 : OUString sStyleName(SD_RESSTR(STR_PSEUDOSHEET_OUTLINE) + " 1");
418 0 : SfxStyleSheetBase* pFirstStyleSheet = pSSPool->Find( sStyleName, SD_STYLE_FAMILY_PSEUDO);
419 :
420 0 : if(pFirstStyleSheet)
421 : {
422 0 : pFirstStyleSheet->GetItemSet().Put( SvxNumBulletItem( aRule, EE_PARA_NUMBULLET ));
423 0 : SdStyleSheet* pRealSheet = static_cast<SdStyleSheet*>(pFirstStyleSheet)->GetRealStyleSheet();
424 0 : pRealSheet->Broadcast(SfxSimpleHint(SFX_HINT_DATACHANGED));
425 : }
426 :
427 0 : aTempSet.ClearItem( EE_PARA_NUMBULLET );
428 : }
429 : }
430 :
431 0 : pStyleSheet->GetItemSet().Put(aTempSet);
432 0 : SdStyleSheet::BroadcastSdStyleSheetChange(pStyleSheet, ePO, pSSPool);
433 : }
434 :
435 0 : SfxItemSet& rAttr = pStyleSheet->GetItemSet();
436 :
437 0 : sdr::properties::CleanupFillProperties( rAttr );
438 :
439 : // check for unique names of named items for xml
440 0 : if( rAttr.GetItemState( XATTR_FILLBITMAP ) == SfxItemState::SET )
441 : {
442 0 : const SfxPoolItem* pOldItem = rAttr.GetItem( XATTR_FILLBITMAP );
443 0 : SfxPoolItem* pNewItem = static_cast<const XFillBitmapItem*>(pOldItem)->checkForUniqueItem( mpDoc );
444 0 : if( pNewItem )
445 : {
446 0 : rAttr.Put( *pNewItem );
447 0 : delete pNewItem;
448 : }
449 : }
450 0 : if( rAttr.GetItemState( XATTR_LINEDASH ) == SfxItemState::SET )
451 : {
452 0 : const SfxPoolItem* pOldItem = rAttr.GetItem( XATTR_LINEDASH );
453 0 : SfxPoolItem* pNewItem = static_cast<const XLineDashItem*>(pOldItem)->checkForUniqueItem( mpDoc );
454 0 : if( pNewItem )
455 : {
456 0 : rAttr.Put( *pNewItem );
457 0 : delete pNewItem;
458 : }
459 : }
460 0 : if( rAttr.GetItemState( XATTR_LINESTART ) == SfxItemState::SET )
461 : {
462 0 : const SfxPoolItem* pOldItem = rAttr.GetItem( XATTR_LINESTART );
463 0 : SfxPoolItem* pNewItem = static_cast<const XLineStartItem*>(pOldItem)->checkForUniqueItem( mpDoc );
464 0 : if( pNewItem )
465 : {
466 0 : rAttr.Put( *pNewItem );
467 0 : delete pNewItem;
468 : }
469 : }
470 0 : if( rAttr.GetItemState( XATTR_LINEEND ) == SfxItemState::SET )
471 : {
472 0 : const SfxPoolItem* pOldItem = rAttr.GetItem( XATTR_LINEEND );
473 0 : SfxPoolItem* pNewItem = static_cast<const XLineEndItem*>(pOldItem)->checkForUniqueItem( mpDoc );
474 0 : if( pNewItem )
475 : {
476 0 : rAttr.Put( *pNewItem );
477 0 : delete pNewItem;
478 : }
479 : }
480 0 : if( rAttr.GetItemState( XATTR_FILLGRADIENT ) == SfxItemState::SET )
481 : {
482 0 : const SfxPoolItem* pOldItem = rAttr.GetItem( XATTR_FILLGRADIENT );
483 0 : SfxPoolItem* pNewItem = static_cast<const XFillGradientItem*>(pOldItem)->checkForUniqueItem( mpDoc );
484 0 : if( pNewItem )
485 : {
486 0 : rAttr.Put( *pNewItem );
487 0 : delete pNewItem;
488 : }
489 : }
490 0 : if( rAttr.GetItemState( XATTR_FILLFLOATTRANSPARENCE ) == SfxItemState::SET )
491 : {
492 0 : const SfxPoolItem* pOldItem = rAttr.GetItem( XATTR_FILLFLOATTRANSPARENCE );
493 0 : SfxPoolItem* pNewItem = static_cast<const XFillFloatTransparenceItem*>(pOldItem)->checkForUniqueItem( mpDoc );
494 0 : if( pNewItem )
495 : {
496 0 : rAttr.Put( *pNewItem );
497 0 : delete pNewItem;
498 : }
499 : }
500 0 : if( rAttr.GetItemState( XATTR_FILLHATCH ) == SfxItemState::SET )
501 : {
502 0 : const SfxPoolItem* pOldItem = rAttr.GetItem( XATTR_FILLHATCH );
503 0 : SfxPoolItem* pNewItem = static_cast<const XFillHatchItem*>(pOldItem)->checkForUniqueItem( mpDoc );
504 0 : if( pNewItem )
505 : {
506 0 : rAttr.Put( *pNewItem );
507 0 : delete pNewItem;
508 : }
509 : }
510 :
511 0 : static_cast<SfxStyleSheet*>( pStyleSheet )->Broadcast( SfxSimpleHint( SFX_HINT_DATACHANGED ) );
512 :
513 0 : DrawViewShell* pDrawViewShell = dynamic_cast< DrawViewShell* >( mpViewShell );
514 0 : if( pDrawViewShell )
515 : {
516 0 : PageKind ePageKind = pDrawViewShell->GetPageKind();
517 0 : if( ePageKind == PK_NOTES || ePageKind == PK_HANDOUT )
518 : {
519 0 : SdPage* pPage = mpViewShell->GetActualPage();
520 :
521 0 : if(pDrawViewShell->GetEditMode() == EM_MASTERPAGE)
522 : {
523 0 : pPage = static_cast<SdPage*>((&(pPage->TRG_GetMasterPage())));
524 : }
525 :
526 0 : if( pPage )
527 : {
528 0 : SdrObjListIter aIter( *pPage );
529 0 : while( aIter.IsMore() )
530 : {
531 0 : SdrObject* pObj = aIter.Next();
532 0 : if( pObj->ISA(SdrPageObj) )
533 : {
534 : // repaint only
535 0 : pObj->ActionChanged();
536 : // pObj->SendRepaintBroadcast();
537 : }
538 0 : }
539 : }
540 : }
541 : }
542 :
543 0 : if( mpDoc->GetOnlineSpell() )
544 : {
545 : const SfxPoolItem* pTempItem;
546 0 : if( SfxItemState::SET == rAttr.GetItemState(EE_CHAR_LANGUAGE, false, &pTempItem ) ||
547 0 : SfxItemState::SET == rAttr.GetItemState(EE_CHAR_LANGUAGE_CJK, false, &pTempItem ) ||
548 0 : SfxItemState::SET == rAttr.GetItemState(EE_CHAR_LANGUAGE_CTL, false, &pTempItem ) )
549 : {
550 0 : mpDoc->StopOnlineSpelling();
551 0 : mpDoc->StartOnlineSpelling();
552 : }
553 : }
554 :
555 0 : mpDoc->SetChanged(true);
556 : }
557 0 : break;
558 :
559 : default:
560 : {
561 0 : if( nSId == SID_STYLE_NEW )
562 0 : pSSPool->Remove( pStyleSheet );
563 : }
564 0 : return; // Cancel
565 0 : }
566 : }
567 : }
568 0 : break;
569 :
570 : case SID_STYLE_NEW_BY_EXAMPLE:
571 : {
572 0 : if( pStyleSheet )
573 : {
574 0 : nRetMask = pStyleSheet->GetMask();
575 0 : SfxItemSet aCoreSet( mpDoc->GetPool() );
576 0 : mpView->GetAttributes( aCoreSet, true );
577 :
578 : // if the object had a template, this becomes parent of the new template
579 0 : SfxStyleSheet* pOldStyle = mpView->GetStyleSheet();
580 :
581 : // if pOldStyle == pStyleSheet -> recursion
582 0 : if( pOldStyle != pStyleSheet )
583 : {
584 0 : if (pOldStyle)
585 : {
586 0 : pStyleSheet->SetParent(pOldStyle->GetName());
587 : }
588 :
589 0 : SfxItemSet* pStyleSet = &pStyleSheet->GetItemSet();
590 0 : pStyleSet->Put(aCoreSet);
591 :
592 : /* apply template (but not when somebody is editing a text.
593 : To do this, the edit engine had to be capable to use
594 : templates on a character level. */
595 0 : if (!mpView->GetTextEditObject())
596 : {
597 0 : mpView->SetStyleSheet( static_cast<SfxStyleSheet*>(pStyleSheet));
598 : }
599 :
600 0 : static_cast<SfxStyleSheet*>( pStyleSheet )->Broadcast( SfxSimpleHint( SFX_HINT_DATACHANGED ) );
601 0 : mpDoc->SetChanged(true);
602 :
603 0 : mpViewShell->GetViewFrame()->GetBindings().Invalidate( SID_STYLE_FAMILY2 );
604 0 : }
605 : }
606 : }
607 0 : break;
608 :
609 : case SID_STYLE_UPDATE_BY_EXAMPLE:
610 : {
611 0 : if ((mpView->AreObjectsMarked() && mpView->GetMarkedObjectList().GetMarkCount() == 1) ||
612 0 : mpView->ISA(OutlineView))
613 : {
614 0 : pStyleSheet = mpView->GetStyleSheet();
615 :
616 0 : if( pStyleSheet )
617 : {
618 0 : nRetMask = pStyleSheet->GetMask();
619 0 : SfxItemSet aCoreSet( mpDoc->GetPool() );
620 0 : mpView->GetAttributes( aCoreSet );
621 :
622 0 : SfxItemSet* pStyleSet = &pStyleSheet->GetItemSet();
623 0 : pStyleSet->Put( aCoreSet );
624 :
625 0 : mpView->SetStyleSheet( static_cast<SfxStyleSheet*>(pStyleSheet));
626 :
627 0 : static_cast<SfxStyleSheet*>( pStyleSheet )->Broadcast( SfxSimpleHint( SFX_HINT_DATACHANGED ) );
628 0 : mpDoc->SetChanged(true);
629 0 : mpViewShell->GetViewFrame()->GetBindings().Invalidate( SID_STYLE_FAMILY2 );
630 : }
631 : }
632 : }
633 0 : break;
634 :
635 : }
636 0 : if( nRetMask != SFXSTYLEBIT_ALL )
637 0 : rReq.SetReturnValue( SfxUInt16Item( nSId, nRetMask ) );
638 : }
639 :
640 0 : void FuTemplate::Activate()
641 : {
642 0 : }
643 :
644 0 : void FuTemplate::Deactivate()
645 : {
646 0 : }
647 :
648 66 : } // end of namespace sd
649 :
650 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|