1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: fuprobjs.cxx,v $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
31 // MARKER(update_precomp.py): autogen include statement, do not remove
32 #include "precompiled_sd.hxx"
34 #include "fuprobjs.hxx"
36 #ifndef _MSGBOX_HXX //autogen
37 #include <vcl/msgbox.hxx>
39 #include <svtools/style.hxx>
40 #include <svx/outliner.hxx>
41 #include <svtools/smplhint.hxx>
45 #include "res_bmp.hrc"
46 #include "strings.hrc"
48 #include "prltempl.hrc"
50 #include "sdresid.hxx"
51 #include "drawdoc.hxx"
52 #ifndef SD_OUTLINE_VIEW_SHELL_HX
53 #include "OutlineViewShell.hxx"
55 #include "ViewShell.hxx"
58 #include "prlayout.hxx"
60 #include "sdabstdlg.hxx"
63 TYPEINIT1( FuPresentationObjects
, FuPoor
);
66 /*************************************************************************
70 \************************************************************************/
72 FuPresentationObjects::FuPresentationObjects (
78 : FuPoor(pViewSh
, pWin
, pView
, pDoc
, rReq
)
82 FunctionReference
FuPresentationObjects::Create( ViewShell
* pViewSh
, ::sd::Window
* pWin
, ::sd::View
* pView
, SdDrawDocument
* pDoc
, SfxRequest
& rReq
)
84 FunctionReference
xFunc( new FuPresentationObjects( pViewSh
, pWin
, pView
, pDoc
, rReq
) );
85 xFunc
->DoExecute(rReq
);
89 void FuPresentationObjects::DoExecute( SfxRequest
& )
91 OutlineViewShell
* pOutlineViewShell
= dynamic_cast< OutlineViewShell
* >( mpViewShell
);
92 DBG_ASSERT( pOutlineViewShell
, "sd::FuPresentationObjects::DoExecute(), does not work without an OutlineViewShell!");
93 if( !pOutlineViewShell
)
96 // ergibt die Selektion ein eindeutiges Praesentationslayout?
97 // wenn nicht, duerfen die Vorlagen nicht bearbeitet werden
98 SfxItemSet
aSet(mpDoc
->GetItemPool(), SID_STATUS_LAYOUT
, SID_STATUS_LAYOUT
);
99 pOutlineViewShell
->GetStatusBarState( aSet
);
100 String aLayoutName
= (((SfxStringItem
&)aSet
.Get(SID_STATUS_LAYOUT
)).GetValue());
101 DBG_ASSERT(aLayoutName
.Len(), "Layout unbestimmt");
103 BOOL bUnique
= FALSE
;
104 sal_Int16 nDepth
, nTmp
;
105 OutlineView
* pOlView
= static_cast<OutlineView
*>(pOutlineViewShell
->GetView());
106 OutlinerView
* pOutlinerView
= pOlView
->GetViewByWindow( (Window
*) mpWindow
);
107 ::Outliner
* pOutl
= pOutlinerView
->GetOutliner();
108 List
* pList
= pOutlinerView
->CreateSelectionList();
109 Paragraph
* pPara
= (Paragraph
*)pList
->First();
110 nDepth
= pOutl
->GetDepth((USHORT
)pOutl
->GetAbsPos( pPara
) );
111 bool bPage
= pOutl
->HasParaFlag( pPara
, PARAFLAG_ISPAGE
);
115 nTmp
= pOutl
->GetDepth((USHORT
) pOutl
->GetAbsPos( pPara
) );
123 if( pOutl
->HasParaFlag( pPara
, PARAFLAG_ISPAGE
) != bPage
)
130 pPara
= (Paragraph
*) pList
->Next();
135 String aStyleName
= aLayoutName
;
136 aStyleName
.AppendAscii( RTL_CONSTASCII_STRINGPARAM( SD_LT_SEPARATOR
) );
137 USHORT nDlgId
= TAB_PRES_LAYOUT_TEMPLATE
;
138 PresentationObjects ePO
;
143 String
aStr(SdResId( STR_LAYOUT_TITLE
));
144 aStyleName
.Append( aStr
);
148 ePO
= (PresentationObjects
) ( PO_OUTLINE_1
+ nDepth
- 1 );
149 String
aStr(SdResId( STR_LAYOUT_OUTLINE
));
150 aStyleName
.Append( aStr
);
151 aStyleName
.Append( sal_Unicode(' ') );
152 aStyleName
.Append( UniString::CreateFromInt32( nDepth
) );
155 SfxStyleSheetBasePool
* pStyleSheetPool
= mpDocSh
->GetStyleSheetPool();
156 SfxStyleSheetBase
* pStyleSheet
= pStyleSheetPool
->Find( aStyleName
, SD_STYLE_FAMILY_MASTERPAGE
);
157 DBG_ASSERT(pStyleSheet
, "StyleSheet nicht gefunden");
161 SfxStyleSheetBase
& rStyleSheet
= *pStyleSheet
;
163 SdAbstractDialogFactory
* pFact
= SdAbstractDialogFactory::Create();
164 SfxAbstractTabDialog
* pDlg
= pFact
? pFact
->CreateSdPresLayoutTemplateDlg( mpDocSh
, NULL
, SdResId( nDlgId
), rStyleSheet
, ePO
, pStyleSheetPool
) : 0;
165 if( pDlg
&& (pDlg
->Execute() == RET_OK
) )
167 const SfxItemSet
* pOutSet
= pDlg
->GetOutputItemSet();
169 StyleSheetUndoAction
* pAction
= new StyleSheetUndoAction
170 (mpDoc
, (SfxStyleSheet
*)pStyleSheet
,
172 mpDocSh
->GetUndoManager()->AddUndoAction(pAction
);
174 pStyleSheet
->GetItemSet().Put( *pOutSet
);
175 ( (SfxStyleSheet
*) pStyleSheet
)->Broadcast( SfxSimpleHint( SFX_HINT_DATACHANGED
) );
182 } // end of namespace sd