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/presentation/FadeEffect.hpp>
21 :
22 : #include <svx/dialogs.hrc>
23 :
24 : #include "sdattr.hxx"
25 : #include "strings.hrc"
26 :
27 : #include "diactrl.hxx"
28 :
29 : #include "sdresid.hxx"
30 : #include "app.hrc"
31 : #include "res_bmp.hrc"
32 : #include <sfx2/dispatch.hxx>
33 : #include <sfx2/viewfrm.hxx>
34 : #include <sfx2/app.hxx>
35 :
36 : using namespace ::com::sun::star;
37 :
38 11 : SFX_IMPL_TOOLBOX_CONTROL( SdTbxCtlDiaPages, SfxUInt16Item )
39 :
40 :
41 : //========================================================================
42 : // SdPagesField
43 : //========================================================================
44 :
45 0 : SdPagesField::SdPagesField( Window* pParent,
46 : const uno::Reference< frame::XFrame >& rFrame,
47 : WinBits nBits ) :
48 : SvxMetricField ( pParent, rFrame, nBits ),
49 0 : m_xFrame ( rFrame )
50 : {
51 0 : String aStr( SdResId( STR_SLIDE_PLURAL ) );
52 0 : SetCustomUnitText( aStr );
53 :
54 : // set size
55 0 : aStr.AppendAscii( "XXX" );
56 0 : Size aSize( GetTextWidth( aStr )+20, GetTextHeight()+6 );
57 :
58 :
59 0 : SetSizePixel( aSize );
60 :
61 : // set parameter of MetricFields
62 0 : SetUnit( FUNIT_CUSTOM );
63 0 : SetMin( 1 );
64 0 : SetFirst( 1 );
65 0 : SetMax( 15 );
66 0 : SetLast( 15 );
67 0 : SetSpinSize( 1 );
68 0 : SetDecimalDigits( 0 );
69 0 : Show();
70 0 : }
71 :
72 : // -----------------------------------------------------------------------
73 :
74 0 : SdPagesField::~SdPagesField()
75 : {
76 0 : }
77 :
78 : // -----------------------------------------------------------------------
79 :
80 0 : void SdPagesField::UpdatePagesField( const SfxUInt16Item* pItem )
81 : {
82 0 : if( pItem )
83 : {
84 0 : long nValue = (long) pItem->GetValue();
85 0 : SetValue( nValue );
86 0 : if( nValue == 1 )
87 0 : SetCustomUnitText( String( SdResId( STR_SLIDE_SINGULAR ) ) );
88 : else
89 0 : SetCustomUnitText( String( SdResId( STR_SLIDE_PLURAL ) ) );
90 : }
91 : else
92 0 : SetText( String() );
93 0 : }
94 :
95 : // -----------------------------------------------------------------------
96 :
97 0 : void SdPagesField::Modify()
98 : {
99 0 : SfxUInt16Item aItem( SID_PAGES_PER_ROW, (sal_uInt16) GetValue() );
100 :
101 0 : ::uno::Any a;
102 0 : ::uno::Sequence< ::beans::PropertyValue > aArgs( 1 );
103 0 : aArgs[0].Name = "PagesPerRow";
104 0 : aItem.QueryValue( a );
105 0 : aArgs[0].Value = a;
106 0 : SfxToolBoxControl::Dispatch( ::uno::Reference< ::frame::XDispatchProvider >( m_xFrame->getController(), ::uno::UNO_QUERY ),
107 : ".uno:PagesPerRow",
108 0 : aArgs );
109 0 : }
110 :
111 0 : SdTbxCtlDiaPages::SdTbxCtlDiaPages( sal_uInt16 nSlotId, sal_uInt16 nId, ToolBox& rTbx ) :
112 0 : SfxToolBoxControl( nSlotId, nId, rTbx )
113 : {
114 0 : }
115 :
116 : //========================================================================
117 :
118 0 : SdTbxCtlDiaPages::~SdTbxCtlDiaPages()
119 : {
120 0 : }
121 :
122 : //========================================================================
123 :
124 0 : void SdTbxCtlDiaPages::StateChanged( sal_uInt16,
125 : SfxItemState eState, const SfxPoolItem* pState )
126 : {
127 0 : SdPagesField* pFld = (SdPagesField*) GetToolBox().GetItemWindow( GetId() );
128 : DBG_ASSERT( pFld, "Window not found" );
129 :
130 0 : if ( eState == SFX_ITEM_DISABLED )
131 : {
132 0 : pFld->Disable();
133 0 : pFld->SetText( String() );
134 : }
135 : else
136 : {
137 0 : pFld->Enable();
138 :
139 0 : const SfxUInt16Item* pItem = 0;
140 0 : if ( eState == SFX_ITEM_AVAILABLE )
141 : {
142 0 : pItem = dynamic_cast< const SfxUInt16Item* >( pState );
143 : DBG_ASSERT( pItem, "sd::SdTbxCtlDiaPages::StateChanged(), wrong item type!" );
144 : }
145 :
146 0 : pFld->UpdatePagesField( pItem );
147 : }
148 0 : }
149 :
150 : //========================================================================
151 :
152 0 : Window* SdTbxCtlDiaPages::CreateItemWindow( Window* pParent )
153 : {
154 0 : return new SdPagesField( pParent, m_xFrame );
155 33 : }
156 :
157 :
158 :
159 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|