1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
|
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
/*
* This file is part of the LibreOffice project.
*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*
* This file incorporates work covered by the following license notice:
*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed
* with this work for additional information regarding copyright
* ownership. The ASF licenses this file to you under the Apache
* License, Version 2.0 (the "License"); you may not use this file
* except in compliance with the License. You may obtain a copy of
* the License at http://www.apache.org/licenses/LICENSE-2.0 .
*/
#include <com/sun/star/presentation/FadeEffect.hpp>
#include <svx/dialogs.hrc>
#include "sdattr.hxx"
#include "strings.hrc"
#define _SD_DIACTRL_CXX
#include "diactrl.hxx"
#include "sdresid.hxx"
#include "app.hrc"
#include "res_bmp.hrc"
#include <sfx2/dispatch.hxx>
#include <sfx2/viewfrm.hxx>
#include <sfx2/app.hxx>
using namespace ::com::sun::star;
SFX_IMPL_TOOLBOX_CONTROL( SdTbxCtlDiaPages, SfxUInt16Item )
//========================================================================
// SdPagesField
//========================================================================
SdPagesField::SdPagesField( Window* pParent,
const uno::Reference< frame::XFrame >& rFrame,
WinBits nBits ) :
SvxMetricField ( pParent, rFrame, nBits ),
m_xFrame ( rFrame )
{
String aStr( SdResId( STR_SLIDE_PLURAL ) );
SetCustomUnitText( aStr );
// set size
aStr.AppendAscii( RTL_CONSTASCII_STRINGPARAM( "XXX" ) );
Size aSize( GetTextWidth( aStr )+20, GetTextHeight()+6 );
SetSizePixel( aSize );
// set parameter of MetricFields
SetUnit( FUNIT_CUSTOM );
SetMin( 1 );
SetFirst( 1 );
SetMax( 15 );
SetLast( 15 );
SetSpinSize( 1 );
SetDecimalDigits( 0 );
Show();
}
// -----------------------------------------------------------------------
SdPagesField::~SdPagesField()
{
}
// -----------------------------------------------------------------------
void SdPagesField::UpdatePagesField( const SfxUInt16Item* pItem )
{
if( pItem )
{
long nValue = (long) pItem->GetValue();
SetValue( nValue );
if( nValue == 1 )
SetCustomUnitText( String( SdResId( STR_SLIDE_SINGULAR ) ) );
else
SetCustomUnitText( String( SdResId( STR_SLIDE_PLURAL ) ) );
}
else
SetText( String() );
}
// -----------------------------------------------------------------------
void SdPagesField::Modify()
{
SfxUInt16Item aItem( SID_PAGES_PER_ROW, (sal_uInt16) GetValue() );
::uno::Any a;
::uno::Sequence< ::beans::PropertyValue > aArgs( 1 );
aArgs[0].Name = "PagesPerRow";
aItem.QueryValue( a );
aArgs[0].Value = a;
SfxToolBoxControl::Dispatch( ::uno::Reference< ::frame::XDispatchProvider >( m_xFrame->getController(), ::uno::UNO_QUERY ),
".uno:PagesPerRow",
aArgs );
}
SdTbxCtlDiaPages::SdTbxCtlDiaPages( sal_uInt16 nSlotId, sal_uInt16 nId, ToolBox& rTbx ) :
SfxToolBoxControl( nSlotId, nId, rTbx )
{
}
//========================================================================
SdTbxCtlDiaPages::~SdTbxCtlDiaPages()
{
}
//========================================================================
void SdTbxCtlDiaPages::StateChanged( sal_uInt16,
SfxItemState eState, const SfxPoolItem* pState )
{
SdPagesField* pFld = (SdPagesField*) GetToolBox().GetItemWindow( GetId() );
DBG_ASSERT( pFld, "Window not found" );
if ( eState == SFX_ITEM_DISABLED )
{
pFld->Disable();
pFld->SetText( String() );
}
else
{
pFld->Enable();
const SfxUInt16Item* pItem = 0;
if ( eState == SFX_ITEM_AVAILABLE )
{
pItem = dynamic_cast< const SfxUInt16Item* >( pState );
DBG_ASSERT( pItem, "sd::SdTbxCtlDiaPages::StateChanged(), wrong item type!" );
}
pFld->UpdatePagesField( pItem );
}
}
//========================================================================
Window* SdTbxCtlDiaPages::CreateItemWindow( Window* pParent )
{
return new SdPagesField( pParent, m_xFrame );
}
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|