1*5b190011SAndrew Rist /**************************************************************
2*5b190011SAndrew Rist *
3*5b190011SAndrew Rist * Licensed to the Apache Software Foundation (ASF) under one
4*5b190011SAndrew Rist * or more contributor license agreements. See the NOTICE file
5*5b190011SAndrew Rist * distributed with this work for additional information
6*5b190011SAndrew Rist * regarding copyright ownership. The ASF licenses this file
7*5b190011SAndrew Rist * to you under the Apache License, Version 2.0 (the
8*5b190011SAndrew Rist * "License"); you may not use this file except in compliance
9*5b190011SAndrew Rist * with the License. You may obtain a copy of the License at
10*5b190011SAndrew Rist *
11*5b190011SAndrew Rist * http://www.apache.org/licenses/LICENSE-2.0
12*5b190011SAndrew Rist *
13*5b190011SAndrew Rist * Unless required by applicable law or agreed to in writing,
14*5b190011SAndrew Rist * software distributed under the License is distributed on an
15*5b190011SAndrew Rist * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16*5b190011SAndrew Rist * KIND, either express or implied. See the License for the
17*5b190011SAndrew Rist * specific language governing permissions and limitations
18*5b190011SAndrew Rist * under the License.
19*5b190011SAndrew Rist *
20*5b190011SAndrew Rist *************************************************************/
21*5b190011SAndrew Rist
22*5b190011SAndrew Rist
23cdf0e10cSrcweir
24cdf0e10cSrcweir // MARKER(update_precomp.py): autogen include statement, do not remove
25cdf0e10cSrcweir #include "precompiled_sd.hxx"
26cdf0e10cSrcweir
27cdf0e10cSrcweir #include <com/sun/star/frame/XFrame.hpp>
28cdf0e10cSrcweir #include <com/sun/star/text/WritingMode.hpp>
29cdf0e10cSrcweir #include <com/sun/star/frame/status/FontHeight.hpp>
30cdf0e10cSrcweir #include <com/sun/star/frame/XDispatchProvider.hpp>
31cdf0e10cSrcweir #include <com/sun/star/beans/PropertyValue.hpp>
32cdf0e10cSrcweir #include <com/sun/star/beans/XPropertySet.hpp>
33cdf0e10cSrcweir #include <com/sun/star/drawing/DrawViewMode.hpp>
34cdf0e10cSrcweir
35cdf0e10cSrcweir #include <memory>
36cdf0e10cSrcweir #include <boost/scoped_ptr.hpp>
37cdf0e10cSrcweir
38cdf0e10cSrcweir #include <vos/mutex.hxx>
39cdf0e10cSrcweir
40cdf0e10cSrcweir #include <vcl/svapp.hxx>
41cdf0e10cSrcweir #include <vcl/toolbox.hxx>
42cdf0e10cSrcweir
43cdf0e10cSrcweir #include <svl/languageoptions.hxx>
44cdf0e10cSrcweir
45cdf0e10cSrcweir #include <svtools/ctrltool.hxx>
46cdf0e10cSrcweir #include <svtools/ctrlbox.hxx>
47cdf0e10cSrcweir #include <svtools/toolbarmenu.hxx>
48cdf0e10cSrcweir #include <svtools/valueset.hxx>
49cdf0e10cSrcweir
50cdf0e10cSrcweir #include <toolkit/helper/vclunohelper.hxx>
51cdf0e10cSrcweir
52cdf0e10cSrcweir #include <sfx2/imagemgr.hxx>
53cdf0e10cSrcweir
54cdf0e10cSrcweir #include "app.hrc"
55cdf0e10cSrcweir #include "glob.hrc"
56cdf0e10cSrcweir #include "strings.hrc"
57cdf0e10cSrcweir #include "res_bmp.hrc"
58cdf0e10cSrcweir #include "sdresid.hxx"
59cdf0e10cSrcweir #include "pres.hxx"
60cdf0e10cSrcweir #include "slidelayoutcontroller.hxx"
61cdf0e10cSrcweir
62cdf0e10cSrcweir using rtl::OUString;
63cdf0e10cSrcweir
64cdf0e10cSrcweir using namespace ::com::sun::star;
65cdf0e10cSrcweir using namespace ::com::sun::star::uno;
66cdf0e10cSrcweir using namespace ::com::sun::star::lang;
67cdf0e10cSrcweir using namespace ::com::sun::star::text;
68cdf0e10cSrcweir using namespace ::com::sun::star::frame;
69cdf0e10cSrcweir using namespace ::com::sun::star::drawing;
70cdf0e10cSrcweir using namespace ::com::sun::star::beans;
71cdf0e10cSrcweir
72cdf0e10cSrcweir namespace sd
73cdf0e10cSrcweir {
74cdf0e10cSrcweir
75cdf0e10cSrcweir extern ::rtl::OUString ImplRetrieveLabelFromCommand( const Reference< XFrame >& xFrame, const OUString& aCmdURL );
76cdf0e10cSrcweir
77cdf0e10cSrcweir // -----------------------------------------------------------------------
78cdf0e10cSrcweir
79cdf0e10cSrcweir class LayoutToolbarMenu : public svtools::ToolbarMenu
80cdf0e10cSrcweir {
81cdf0e10cSrcweir public:
82cdf0e10cSrcweir LayoutToolbarMenu( SlideLayoutController& rController, const Reference< XFrame >& xFrame, ::Window* pParent, const bool bInsertPage );
83cdf0e10cSrcweir virtual ~LayoutToolbarMenu();
84cdf0e10cSrcweir
85cdf0e10cSrcweir protected:
86cdf0e10cSrcweir DECL_LINK( SelectHdl, void * );
87cdf0e10cSrcweir
88cdf0e10cSrcweir private:
89cdf0e10cSrcweir SlideLayoutController& mrController;
90cdf0e10cSrcweir Reference< XFrame > mxFrame;
91cdf0e10cSrcweir bool mbInsertPage;
92cdf0e10cSrcweir ValueSet* mpLayoutSet1;
93cdf0e10cSrcweir ValueSet* mpLayoutSet2;
94cdf0e10cSrcweir };
95cdf0e10cSrcweir
96cdf0e10cSrcweir // -----------------------------------------------------------------------
97cdf0e10cSrcweir
98cdf0e10cSrcweir struct snewfoil_value_info
99cdf0e10cSrcweir {
100cdf0e10cSrcweir sal_uInt16 mnBmpResId;
101cdf0e10cSrcweir sal_uInt16 mnHCBmpResId;
102cdf0e10cSrcweir sal_uInt16 mnStrResId;
103cdf0e10cSrcweir WritingMode meWritingMode;
104cdf0e10cSrcweir AutoLayout maAutoLayout;
105cdf0e10cSrcweir };
106cdf0e10cSrcweir
107cdf0e10cSrcweir static snewfoil_value_info notes[] =
108cdf0e10cSrcweir {
109cdf0e10cSrcweir {BMP_FOILN_01, BMP_FOILN_01_H, STR_AUTOLAYOUT_NOTES, WritingMode_LR_TB,
110cdf0e10cSrcweir AUTOLAYOUT_NOTES},
111cdf0e10cSrcweir {0, 0, 0, WritingMode_LR_TB, AUTOLAYOUT_NONE},
112cdf0e10cSrcweir };
113cdf0e10cSrcweir
114cdf0e10cSrcweir static snewfoil_value_info handout[] =
115cdf0e10cSrcweir {
116cdf0e10cSrcweir {BMP_FOILH_01, BMP_FOILH_01_H, STR_AUTOLAYOUT_HANDOUT1, WritingMode_LR_TB,
117cdf0e10cSrcweir AUTOLAYOUT_HANDOUT1},
118cdf0e10cSrcweir {BMP_FOILH_02, BMP_FOILH_02_H, STR_AUTOLAYOUT_HANDOUT2, WritingMode_LR_TB,
119cdf0e10cSrcweir AUTOLAYOUT_HANDOUT2},
120cdf0e10cSrcweir {BMP_FOILH_03, BMP_FOILH_03_H, STR_AUTOLAYOUT_HANDOUT3, WritingMode_LR_TB,
121cdf0e10cSrcweir AUTOLAYOUT_HANDOUT3},
122cdf0e10cSrcweir {BMP_FOILH_04, BMP_FOILH_04_H, STR_AUTOLAYOUT_HANDOUT4, WritingMode_LR_TB,
123cdf0e10cSrcweir AUTOLAYOUT_HANDOUT4},
124cdf0e10cSrcweir {BMP_FOILH_06, BMP_FOILH_06_H, STR_AUTOLAYOUT_HANDOUT6, WritingMode_LR_TB,
125cdf0e10cSrcweir AUTOLAYOUT_HANDOUT6},
126cdf0e10cSrcweir {BMP_FOILH_09, BMP_FOILH_09_H, STR_AUTOLAYOUT_HANDOUT9, WritingMode_LR_TB,
127cdf0e10cSrcweir AUTOLAYOUT_HANDOUT9},
128cdf0e10cSrcweir {0, 0, 0, WritingMode_LR_TB, AUTOLAYOUT_NONE},
129cdf0e10cSrcweir };
130cdf0e10cSrcweir
131cdf0e10cSrcweir static snewfoil_value_info standard[] =
132cdf0e10cSrcweir {
133cdf0e10cSrcweir {BMP_LAYOUT_EMPTY, BMP_LAYOUT_EMPTY_H, STR_AUTOLAYOUT_NONE, WritingMode_LR_TB, AUTOLAYOUT_NONE},
134cdf0e10cSrcweir {BMP_LAYOUT_HEAD03, BMP_LAYOUT_HEAD03_H, STR_AUTOLAYOUT_TITLE, WritingMode_LR_TB, AUTOLAYOUT_TITLE},
135cdf0e10cSrcweir {BMP_LAYOUT_HEAD02, BMP_LAYOUT_HEAD02_H, STR_AUTOLAYOUT_CONTENT, WritingMode_LR_TB, AUTOLAYOUT_ENUM},
136cdf0e10cSrcweir {BMP_LAYOUT_HEAD02A, BMP_LAYOUT_HEAD02A_H, STR_AUTOLAYOUT_2CONTENT, WritingMode_LR_TB, AUTOLAYOUT_2TEXT},
137cdf0e10cSrcweir {BMP_LAYOUT_HEAD01, BMP_LAYOUT_HEAD01_H, STR_AUTOLAYOUT_ONLY_TITLE, WritingMode_LR_TB, AUTOLAYOUT_ONLY_TITLE},
138cdf0e10cSrcweir {BMP_LAYOUT_TEXTONLY, BMP_LAYOUT_TEXTONLY_H, STR_AUTOLAYOUT_ONLY_TEXT, WritingMode_LR_TB, AUTOLAYOUT_ONLY_TEXT},
139cdf0e10cSrcweir {BMP_LAYOUT_HEAD03B, BMP_LAYOUT_HEAD03B_H, STR_AUTOLAYOUT_2CONTENT_CONTENT, WritingMode_LR_TB, AUTOLAYOUT_2OBJTEXT},
140cdf0e10cSrcweir {BMP_LAYOUT_HEAD03C, BMP_LAYOUT_HEAD03C_H, STR_AUTOLAYOUT_CONTENT_2CONTENT, WritingMode_LR_TB, AUTOLAYOUT_TEXT2OBJ},
141cdf0e10cSrcweir {BMP_LAYOUT_HEAD03A, BMP_LAYOUT_HEAD03A_H, STR_AUTOLAYOUT_2CONTENT_OVER_CONTENT,WritingMode_LR_TB, AUTOLAYOUT_2OBJOVERTEXT},
142cdf0e10cSrcweir {BMP_LAYOUT_HEAD02B, BMP_LAYOUT_HEAD02B_H, STR_AUTOLAYOUT_CONTENT_OVER_CONTENT, WritingMode_LR_TB, AUTOLAYOUT_OBJOVERTEXT},
143cdf0e10cSrcweir {BMP_LAYOUT_HEAD04, BMP_LAYOUT_HEAD04_H, STR_AUTOLAYOUT_4CONTENT, WritingMode_LR_TB, AUTOLAYOUT_4OBJ},
144cdf0e10cSrcweir {BMP_LAYOUT_HEAD06, BMP_LAYOUT_HEAD06_H, STR_AUTOLAYOUT_6CONTENT, WritingMode_LR_TB, AUTOLAYOUT_6CLIPART},
145cdf0e10cSrcweir {0, 0, 0, WritingMode_LR_TB, AUTOLAYOUT_NONE}
146cdf0e10cSrcweir };
147cdf0e10cSrcweir
148cdf0e10cSrcweir static snewfoil_value_info v_standard[] =
149cdf0e10cSrcweir {
150cdf0e10cSrcweir // vertical
151cdf0e10cSrcweir {BMP_LAYOUT_VERTICAL02, BMP_LAYOUT_VERTICAL02_H, STR_AL_VERT_TITLE_TEXT_CHART, WritingMode_TB_RL,AUTOLAYOUT_VERTICAL_TITLE_TEXT_CHART},
152cdf0e10cSrcweir {BMP_LAYOUT_VERTICAL01, BMP_LAYOUT_VERTICAL01_H, STR_AL_VERT_TITLE_VERT_OUTLINE, WritingMode_TB_RL, AUTOLAYOUT_VERTICAL_TITLE_VERTICAL_OUTLINE},
153cdf0e10cSrcweir {BMP_LAYOUT_HEAD02, BMP_LAYOUT_HEAD02_H, STR_AL_TITLE_VERT_OUTLINE, WritingMode_TB_RL, AUTOLAYOUT_TITLE_VERTICAL_OUTLINE},
154cdf0e10cSrcweir {BMP_LAYOUT_HEAD02A, BMP_LAYOUT_HEAD02A_H, STR_AL_TITLE_VERT_OUTLINE_CLIPART, WritingMode_TB_RL, AUTOLAYOUT_TITLE_VERTICAL_OUTLINE_CLIPART},
155cdf0e10cSrcweir {0, 0, 0, WritingMode_LR_TB, AUTOLAYOUT_NONE}
156cdf0e10cSrcweir };
157cdf0e10cSrcweir
158cdf0e10cSrcweir // -----------------------------------------------------------------------
159cdf0e10cSrcweir
fillLayoutValueSet(ValueSet * pValue,snewfoil_value_info * pInfo,const bool bHighContrast)160cdf0e10cSrcweir static void fillLayoutValueSet( ValueSet* pValue, snewfoil_value_info* pInfo, const bool bHighContrast )
161cdf0e10cSrcweir {
162cdf0e10cSrcweir Size aLayoutItemSize;
163cdf0e10cSrcweir for( ; pInfo->mnBmpResId; pInfo++ )
164cdf0e10cSrcweir {
165cdf0e10cSrcweir String aText( SdResId( pInfo->mnStrResId ) );
166cdf0e10cSrcweir BitmapEx aBmp( SdResId( (bHighContrast ? pInfo->mnHCBmpResId : pInfo->mnBmpResId) ) );
167cdf0e10cSrcweir
168cdf0e10cSrcweir pValue->InsertItem( static_cast<sal_uInt16>(pInfo->maAutoLayout)+1, aBmp, aText );
169cdf0e10cSrcweir
170cdf0e10cSrcweir aLayoutItemSize.Width() = std::max( aLayoutItemSize.Width(), aBmp.GetSizePixel().Width() );
171cdf0e10cSrcweir aLayoutItemSize.Height() = std::max( aLayoutItemSize.Height(), aBmp.GetSizePixel().Height() );
172cdf0e10cSrcweir }
173cdf0e10cSrcweir
174cdf0e10cSrcweir aLayoutItemSize = pValue->CalcItemSizePixel( aLayoutItemSize );
175cdf0e10cSrcweir pValue->SetSizePixel( pValue->CalcWindowSizePixel( aLayoutItemSize ) );
176cdf0e10cSrcweir }
177cdf0e10cSrcweir
178cdf0e10cSrcweir // -----------------------------------------------------------------------
179cdf0e10cSrcweir
LayoutToolbarMenu(SlideLayoutController & rController,const Reference<XFrame> & xFrame,::Window * pParent,const bool bInsertPage)180cdf0e10cSrcweir LayoutToolbarMenu::LayoutToolbarMenu( SlideLayoutController& rController, const Reference< XFrame >& xFrame, ::Window* pParent, const bool bInsertPage )
181cdf0e10cSrcweir : svtools::ToolbarMenu(xFrame, pParent, WB_CLIPCHILDREN )
182cdf0e10cSrcweir , mrController( rController )
183cdf0e10cSrcweir , mxFrame(xFrame)
184cdf0e10cSrcweir , mbInsertPage( bInsertPage )
185cdf0e10cSrcweir , mpLayoutSet1( 0 )
186cdf0e10cSrcweir , mpLayoutSet2( 0 )
187cdf0e10cSrcweir {
188cdf0e10cSrcweir DrawViewMode eMode = DrawViewMode_DRAW;
189cdf0e10cSrcweir
190cdf0e10cSrcweir // find out which view is running
191cdf0e10cSrcweir if( xFrame.is() ) try
192cdf0e10cSrcweir {
193cdf0e10cSrcweir Reference< XPropertySet > xControllerSet( xFrame->getController(), UNO_QUERY_THROW );
194cdf0e10cSrcweir xControllerSet->getPropertyValue( OUString( RTL_CONSTASCII_USTRINGPARAM( "DrawViewMode" ) ) ) >>= eMode;
195cdf0e10cSrcweir }
196cdf0e10cSrcweir catch( Exception& e )
197cdf0e10cSrcweir {
198cdf0e10cSrcweir (void)e;
199cdf0e10cSrcweir OSL_ASSERT(false);
200cdf0e10cSrcweir }
201cdf0e10cSrcweir
202cdf0e10cSrcweir const sal_Int32 LAYOUT_BORDER_PIX = 7;
203cdf0e10cSrcweir
204cdf0e10cSrcweir String aTitle1( SdResId( STR_GLUE_ESCDIR_HORZ ) );
205cdf0e10cSrcweir String aTitle2( SdResId( STR_GLUE_ESCDIR_VERT ) );
206cdf0e10cSrcweir
207cdf0e10cSrcweir const bool bHighContrast = GetSettings().GetStyleSettings().GetHighContrastMode();
208cdf0e10cSrcweir SvtLanguageOptions aLanguageOptions;
209cdf0e10cSrcweir const bool bVerticalEnabled = aLanguageOptions.IsVerticalTextEnabled();
210cdf0e10cSrcweir
211cdf0e10cSrcweir SetSelectHdl( LINK( this, LayoutToolbarMenu, SelectHdl ) );
212cdf0e10cSrcweir
213cdf0e10cSrcweir mpLayoutSet1 = createEmptyValueSetControl();
214cdf0e10cSrcweir mpLayoutSet1->SetSelectHdl( LINK( this, LayoutToolbarMenu, SelectHdl ) );
215cdf0e10cSrcweir
216cdf0e10cSrcweir snewfoil_value_info* pInfo = 0;
217cdf0e10cSrcweir sal_Int16 nColCount = 4;
218cdf0e10cSrcweir switch( eMode )
219cdf0e10cSrcweir {
220cdf0e10cSrcweir case DrawViewMode_DRAW: pInfo = &standard[0]; break;
221cdf0e10cSrcweir case DrawViewMode_HANDOUT: pInfo = &handout[0]; nColCount = 2; break;
222cdf0e10cSrcweir case DrawViewMode_NOTES: pInfo = ¬es[0]; nColCount = 1; break;
223cdf0e10cSrcweir default: break;
224cdf0e10cSrcweir }
225cdf0e10cSrcweir
226cdf0e10cSrcweir mpLayoutSet1->SetColCount( nColCount );
227cdf0e10cSrcweir
228cdf0e10cSrcweir fillLayoutValueSet( mpLayoutSet1, pInfo, bHighContrast );
229cdf0e10cSrcweir
230cdf0e10cSrcweir Size aSize( mpLayoutSet1->GetOutputSizePixel() );
231cdf0e10cSrcweir aSize.Width() += (mpLayoutSet1->GetColCount() + 1) * LAYOUT_BORDER_PIX;
232cdf0e10cSrcweir aSize.Height() += (mpLayoutSet1->GetLineCount() +1) * LAYOUT_BORDER_PIX;
233cdf0e10cSrcweir mpLayoutSet1->SetOutputSizePixel( aSize );
234cdf0e10cSrcweir
235cdf0e10cSrcweir if( bVerticalEnabled && (eMode == DrawViewMode_DRAW) )
236cdf0e10cSrcweir appendEntry( -1, aTitle1 );
237cdf0e10cSrcweir appendEntry( 0, mpLayoutSet1 );
238cdf0e10cSrcweir
239cdf0e10cSrcweir if( bVerticalEnabled && (eMode == DrawViewMode_DRAW) )
240cdf0e10cSrcweir {
241cdf0e10cSrcweir mpLayoutSet2 = new ValueSet( this, WB_TABSTOP | WB_MENUSTYLEVALUESET | WB_FLATVALUESET | WB_NOBORDER | WB_NO_DIRECTSELECT );
242cdf0e10cSrcweir // mpLayoutSet2->SetHelpId( HID_VALUESET_EXTRUSION_LIGHTING );
243cdf0e10cSrcweir
244cdf0e10cSrcweir mpLayoutSet2->SetSelectHdl( LINK( this, LayoutToolbarMenu, SelectHdl ) );
245cdf0e10cSrcweir mpLayoutSet2->SetColCount( 4 );
246cdf0e10cSrcweir mpLayoutSet2->EnableFullItemMode( sal_False );
247cdf0e10cSrcweir mpLayoutSet2->SetColor( GetControlBackground() );
248cdf0e10cSrcweir
249cdf0e10cSrcweir fillLayoutValueSet( mpLayoutSet2, &v_standard[0], bHighContrast );
250cdf0e10cSrcweir
251cdf0e10cSrcweir aSize = mpLayoutSet2->GetOutputSizePixel();
252cdf0e10cSrcweir aSize.Width() += (mpLayoutSet2->GetColCount() + 1) * LAYOUT_BORDER_PIX;
253cdf0e10cSrcweir aSize.Height() += (mpLayoutSet2->GetLineCount() + 1) * LAYOUT_BORDER_PIX;
254cdf0e10cSrcweir mpLayoutSet2->SetOutputSizePixel( aSize );
255cdf0e10cSrcweir
256cdf0e10cSrcweir appendEntry( -1, aTitle2 );
257cdf0e10cSrcweir appendEntry( 1, mpLayoutSet2 );
258cdf0e10cSrcweir }
259cdf0e10cSrcweir
260cdf0e10cSrcweir if( eMode == DrawViewMode_DRAW )
261cdf0e10cSrcweir {
262cdf0e10cSrcweir appendSeparator();
263cdf0e10cSrcweir
264cdf0e10cSrcweir OUString sSlotStr;
265cdf0e10cSrcweir Image aSlotImage;
266cdf0e10cSrcweir if( mxFrame.is() )
267cdf0e10cSrcweir {
268cdf0e10cSrcweir if( bInsertPage )
269cdf0e10cSrcweir sSlotStr = OUString( RTL_CONSTASCII_USTRINGPARAM( ".uno:DuplicatePage" ) );
270cdf0e10cSrcweir else
271cdf0e10cSrcweir sSlotStr = OUString( RTL_CONSTASCII_USTRINGPARAM( ".uno:Undo" ) );
272cdf0e10cSrcweir aSlotImage = ::GetImage( mxFrame, sSlotStr, sal_False, bHighContrast );
273cdf0e10cSrcweir
274cdf0e10cSrcweir String sSlotTitle;
275cdf0e10cSrcweir if( bInsertPage )
276cdf0e10cSrcweir sSlotTitle = ImplRetrieveLabelFromCommand( mxFrame, sSlotStr );
277cdf0e10cSrcweir else
278cdf0e10cSrcweir sSlotTitle = String( SdResId( STR_RESET_LAYOUT ) );
279cdf0e10cSrcweir appendEntry( 2, sSlotTitle, aSlotImage);
280cdf0e10cSrcweir }
281cdf0e10cSrcweir }
282cdf0e10cSrcweir
283cdf0e10cSrcweir SetOutputSizePixel( getMenuSize() );
284cdf0e10cSrcweir }
285cdf0e10cSrcweir
286cdf0e10cSrcweir // -----------------------------------------------------------------------
287cdf0e10cSrcweir
~LayoutToolbarMenu()288cdf0e10cSrcweir LayoutToolbarMenu::~LayoutToolbarMenu()
289cdf0e10cSrcweir {
290cdf0e10cSrcweir }
291cdf0e10cSrcweir
292cdf0e10cSrcweir // -----------------------------------------------------------------------
293cdf0e10cSrcweir
IMPL_LINK(LayoutToolbarMenu,SelectHdl,void *,pControl)294cdf0e10cSrcweir IMPL_LINK( LayoutToolbarMenu, SelectHdl, void *, pControl )
295cdf0e10cSrcweir {
296cdf0e10cSrcweir if ( IsInPopupMode() )
297cdf0e10cSrcweir EndPopupMode();
298cdf0e10cSrcweir
299cdf0e10cSrcweir Sequence< PropertyValue > aArgs;
300cdf0e10cSrcweir
301cdf0e10cSrcweir AutoLayout eLayout = AUTOLAYOUT__END;
302cdf0e10cSrcweir
303cdf0e10cSrcweir OUString sCommandURL( mrController.getCommandURL() );
304cdf0e10cSrcweir
305cdf0e10cSrcweir if( pControl == mpLayoutSet1 )
306cdf0e10cSrcweir {
307cdf0e10cSrcweir eLayout = static_cast< AutoLayout >(mpLayoutSet1->GetSelectItemId()-1);
308cdf0e10cSrcweir }
309cdf0e10cSrcweir else if( pControl == mpLayoutSet2 )
310cdf0e10cSrcweir {
311cdf0e10cSrcweir eLayout = static_cast< AutoLayout >(mpLayoutSet2->GetSelectItemId()-1);
312cdf0e10cSrcweir }
313cdf0e10cSrcweir
314cdf0e10cSrcweir if( eLayout != AUTOLAYOUT__END )
315cdf0e10cSrcweir {
316cdf0e10cSrcweir aArgs = Sequence< PropertyValue >(1);
317cdf0e10cSrcweir aArgs[0].Name = OUString( RTL_CONSTASCII_USTRINGPARAM( "WhatLayout" ) );
318cdf0e10cSrcweir aArgs[0].Value <<= (sal_Int32)eLayout;
319cdf0e10cSrcweir }
320cdf0e10cSrcweir else if( mbInsertPage )
321cdf0e10cSrcweir {
322cdf0e10cSrcweir sCommandURL = OUString( RTL_CONSTASCII_USTRINGPARAM( ".uno:DuplicatePage" ) );
323cdf0e10cSrcweir }
324cdf0e10cSrcweir
325cdf0e10cSrcweir mrController.dispatchCommand( sCommandURL, aArgs );
326cdf0e10cSrcweir
327cdf0e10cSrcweir return 0;
328cdf0e10cSrcweir }
329cdf0e10cSrcweir
330cdf0e10cSrcweir // ====================================================================
331cdf0e10cSrcweir
SlideLayoutController_getImplementationName()332cdf0e10cSrcweir OUString SlideLayoutController_getImplementationName()
333cdf0e10cSrcweir {
334cdf0e10cSrcweir return OUString(RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.comp.sd.SlideLayoutController" ));
335cdf0e10cSrcweir }
336cdf0e10cSrcweir
337cdf0e10cSrcweir // --------------------------------------------------------------------
338cdf0e10cSrcweir
SlideLayoutController_getSupportedServiceNames()339cdf0e10cSrcweir Sequence< OUString > SlideLayoutController_getSupportedServiceNames() throw( RuntimeException )
340cdf0e10cSrcweir {
341cdf0e10cSrcweir Sequence< OUString > aSNS( 1 );
342cdf0e10cSrcweir aSNS.getArray()[0] = OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.frame.ToolbarController" ));
343cdf0e10cSrcweir return aSNS;
344cdf0e10cSrcweir }
345cdf0e10cSrcweir
346cdf0e10cSrcweir // --------------------------------------------------------------------
347cdf0e10cSrcweir
SlideLayoutController_createInstance(const Reference<XMultiServiceFactory> & rSMgr)348cdf0e10cSrcweir Reference< XInterface > SAL_CALL SlideLayoutController_createInstance( const Reference< XMultiServiceFactory >& rSMgr ) throw( RuntimeException )
349cdf0e10cSrcweir {
350cdf0e10cSrcweir return *new SlideLayoutController( rSMgr, OUString( RTL_CONSTASCII_USTRINGPARAM( ".uno:AssignLayout" )), false );
351cdf0e10cSrcweir }
352cdf0e10cSrcweir
353cdf0e10cSrcweir // --------------------------------------------------------------------
354cdf0e10cSrcweir
InsertSlideController_getImplementationName()355cdf0e10cSrcweir OUString InsertSlideController_getImplementationName()
356cdf0e10cSrcweir {
357cdf0e10cSrcweir return OUString(RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.comp.sd.InsertSlideController" ));
358cdf0e10cSrcweir }
359cdf0e10cSrcweir
360cdf0e10cSrcweir // --------------------------------------------------------------------
361cdf0e10cSrcweir
InsertSlideController_getSupportedServiceNames()362cdf0e10cSrcweir Sequence< OUString > InsertSlideController_getSupportedServiceNames() throw( RuntimeException )
363cdf0e10cSrcweir {
364cdf0e10cSrcweir Sequence< OUString > aSNS( 1 );
365cdf0e10cSrcweir aSNS.getArray()[0] = OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.frame.ToolbarController" ));
366cdf0e10cSrcweir return aSNS;
367cdf0e10cSrcweir }
368cdf0e10cSrcweir
369cdf0e10cSrcweir // --------------------------------------------------------------------
370cdf0e10cSrcweir
InsertSlideController_createInstance(const Reference<XMultiServiceFactory> & rSMgr)371cdf0e10cSrcweir Reference< XInterface > SAL_CALL InsertSlideController_createInstance( const Reference< XMultiServiceFactory >& rSMgr ) throw( RuntimeException )
372cdf0e10cSrcweir {
373cdf0e10cSrcweir return *new SlideLayoutController( rSMgr, OUString( RTL_CONSTASCII_USTRINGPARAM( ".uno:InsertPage" )), true );
374cdf0e10cSrcweir }
375cdf0e10cSrcweir
376cdf0e10cSrcweir //========================================================================
377cdf0e10cSrcweir // class SlideLayoutController
378cdf0e10cSrcweir //========================================================================
379cdf0e10cSrcweir
SlideLayoutController(const Reference<lang::XMultiServiceFactory> & rServiceManager,const rtl::OUString & sCommandURL,bool bInsertPage)380cdf0e10cSrcweir SlideLayoutController::SlideLayoutController( const Reference< lang::XMultiServiceFactory >& rServiceManager, const rtl::OUString& sCommandURL, bool bInsertPage )
381cdf0e10cSrcweir : svt::PopupWindowController( rServiceManager, Reference< frame::XFrame >(), sCommandURL )
382cdf0e10cSrcweir , mbInsertPage( bInsertPage )
383cdf0e10cSrcweir {
384cdf0e10cSrcweir }
385cdf0e10cSrcweir
386cdf0e10cSrcweir // --------------------------------------------------------------------
387cdf0e10cSrcweir
createPopupWindow(::Window * pParent)388cdf0e10cSrcweir ::Window* SlideLayoutController::createPopupWindow( ::Window* pParent )
389cdf0e10cSrcweir {
390cdf0e10cSrcweir return new sd::LayoutToolbarMenu( *this, m_xFrame, pParent, mbInsertPage );
391cdf0e10cSrcweir }
392cdf0e10cSrcweir
393cdf0e10cSrcweir // --------------------------------------------------------------------
394cdf0e10cSrcweir // XServiceInfo
395cdf0e10cSrcweir // --------------------------------------------------------------------
396cdf0e10cSrcweir
getImplementationName()397cdf0e10cSrcweir OUString SAL_CALL SlideLayoutController::getImplementationName() throw( RuntimeException )
398cdf0e10cSrcweir {
399cdf0e10cSrcweir if( mbInsertPage )
400cdf0e10cSrcweir return InsertSlideController_getImplementationName();
401cdf0e10cSrcweir else
402cdf0e10cSrcweir return SlideLayoutController_getImplementationName();
403cdf0e10cSrcweir }
404cdf0e10cSrcweir
405cdf0e10cSrcweir // --------------------------------------------------------------------
406cdf0e10cSrcweir
getSupportedServiceNames()407cdf0e10cSrcweir Sequence< OUString > SAL_CALL SlideLayoutController::getSupportedServiceNames( ) throw( RuntimeException )
408cdf0e10cSrcweir {
409cdf0e10cSrcweir if( mbInsertPage )
410cdf0e10cSrcweir return InsertSlideController_getSupportedServiceNames();
411cdf0e10cSrcweir else
412cdf0e10cSrcweir return SlideLayoutController_getSupportedServiceNames();
413cdf0e10cSrcweir }
414cdf0e10cSrcweir
415cdf0e10cSrcweir }
416