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/document/PrinterIndependentLayout.hpp>
21 : #include <com/sun/star/lang/XMultiServiceFactory.hpp>
22 : #include <com/sun/star/frame/Desktop.hpp>
23 : #include <com/sun/star/lang/XComponent.hpp>
24 : #include <com/sun/star/container/XEnumerationAccess.hpp>
25 : #include <comphelper/processfactory.hxx>
26 : #include <comphelper/string.hxx>
27 : #include <com/sun/star/uno/Exception.hpp>
28 : #include <sfx2/module.hxx>
29 : #include <sfx2/app.hxx>
30 : #include <svx/svxids.hrc>
31 : #include <svx/dialogs.hrc>
32 : #include <svx/strarray.hxx>
33 : #include <svx/dlgutil.hxx>
34 : #include <vcl/msgbox.hxx>
35 :
36 : #include "sdattr.hxx"
37 : #include "sdresid.hxx"
38 : #include "optsitem.hxx"
39 : #include "tpoption.hxx"
40 : #include "strings.hrc"
41 : #include "app.hrc"
42 : #include <svl/intitem.hxx>
43 : #include <sfx2/request.hxx>
44 :
45 : using namespace ::com::sun::star;
46 : using namespace ::com::sun::star::uno;
47 :
48 0 : SdTpOptionsSnap::SdTpOptionsSnap( vcl::Window* pParent, const SfxItemSet& rInAttrs ) :
49 0 : SvxGridTabPage(pParent, rInAttrs)
50 : {
51 0 : pSnapFrames->Show();
52 0 : }
53 :
54 0 : SdTpOptionsSnap::~SdTpOptionsSnap()
55 : {
56 0 : }
57 :
58 0 : bool SdTpOptionsSnap::FillItemSet( SfxItemSet* rAttrs )
59 : {
60 0 : SvxGridTabPage::FillItemSet(rAttrs);
61 0 : SdOptionsSnapItem aOptsItem( ATTR_OPTIONS_SNAP );
62 :
63 0 : aOptsItem.GetOptionsSnap().SetSnapHelplines( pCbxSnapHelplines->IsChecked() );
64 0 : aOptsItem.GetOptionsSnap().SetSnapBorder( pCbxSnapBorder->IsChecked() );
65 0 : aOptsItem.GetOptionsSnap().SetSnapFrame( pCbxSnapFrame->IsChecked() );
66 0 : aOptsItem.GetOptionsSnap().SetSnapPoints( pCbxSnapPoints->IsChecked() );
67 0 : aOptsItem.GetOptionsSnap().SetOrtho( pCbxOrtho->IsChecked() );
68 0 : aOptsItem.GetOptionsSnap().SetBigOrtho( pCbxBigOrtho->IsChecked() );
69 0 : aOptsItem.GetOptionsSnap().SetRotate( pCbxRotate->IsChecked() );
70 0 : aOptsItem.GetOptionsSnap().SetSnapArea( (sal_Int16) pMtrFldSnapArea->GetValue() );
71 0 : aOptsItem.GetOptionsSnap().SetAngle( (sal_Int16) pMtrFldAngle->GetValue() );
72 0 : aOptsItem.GetOptionsSnap().SetEliminatePolyPointLimitAngle( (sal_Int16) pMtrFldBezAngle->GetValue() );
73 :
74 0 : rAttrs->Put( aOptsItem );
75 :
76 : // we get a possible existing GridItem, this ensures that we do net set
77 : // some default values by accident
78 0 : return true;
79 : }
80 :
81 0 : void SdTpOptionsSnap::Reset( const SfxItemSet* rAttrs )
82 : {
83 0 : SvxGridTabPage::Reset(rAttrs);
84 :
85 : SdOptionsSnapItem aOptsItem( (const SdOptionsSnapItem&) rAttrs->
86 0 : Get( ATTR_OPTIONS_SNAP ) );
87 :
88 0 : pCbxSnapHelplines->Check( aOptsItem.GetOptionsSnap().IsSnapHelplines() );
89 0 : pCbxSnapBorder->Check( aOptsItem.GetOptionsSnap().IsSnapBorder() );
90 0 : pCbxSnapFrame->Check( aOptsItem.GetOptionsSnap().IsSnapFrame() );
91 0 : pCbxSnapPoints->Check( aOptsItem.GetOptionsSnap().IsSnapPoints() );
92 0 : pCbxOrtho->Check( aOptsItem.GetOptionsSnap().IsOrtho() );
93 0 : pCbxBigOrtho->Check( aOptsItem.GetOptionsSnap().IsBigOrtho() );
94 0 : pCbxRotate->Check( aOptsItem.GetOptionsSnap().IsRotate() );
95 0 : pMtrFldSnapArea->SetValue( aOptsItem.GetOptionsSnap().GetSnapArea() );
96 0 : pMtrFldAngle->SetValue( aOptsItem.GetOptionsSnap().GetAngle() );
97 0 : pMtrFldBezAngle->SetValue( aOptsItem.GetOptionsSnap().GetEliminatePolyPointLimitAngle() );
98 :
99 0 : pCbxRotate->GetClickHdl().Call(0);
100 0 : }
101 :
102 0 : SfxTabPage* SdTpOptionsSnap::Create( vcl::Window* pWindow,
103 : const SfxItemSet* rAttrs )
104 : {
105 0 : return( new SdTpOptionsSnap( pWindow, *rAttrs ) );
106 : }
107 :
108 : /*************************************************************************
109 : |*
110 : |* TabPage to adjust the content options
111 : |*
112 : \************************************************************************/
113 :
114 0 : SdTpOptionsContents::SdTpOptionsContents( vcl::Window* pParent, const SfxItemSet& rInAttrs ) :
115 0 : SfxTabPage ( pParent, "SdViewPage", "modules/simpress/ui/sdviewpage.ui", &rInAttrs )
116 : {
117 0 : get( m_pCbxRuler, "ruler");
118 0 : get( m_pCbxDragStripes, "dragstripes");
119 0 : get( m_pCbxHandlesBezier, "handlesbezier");
120 0 : get( m_pCbxMoveOutline, "moveoutline");
121 0 : }
122 :
123 0 : SdTpOptionsContents::~SdTpOptionsContents()
124 : {
125 0 : }
126 :
127 0 : bool SdTpOptionsContents::FillItemSet( SfxItemSet* rAttrs )
128 : {
129 0 : bool bModified = false;
130 :
131 0 : if( m_pCbxRuler->IsValueChangedFromSaved() ||
132 0 : m_pCbxMoveOutline->IsValueChangedFromSaved() ||
133 0 : m_pCbxDragStripes->IsValueChangedFromSaved() ||
134 0 : m_pCbxHandlesBezier->IsValueChangedFromSaved() )
135 : {
136 0 : SdOptionsLayoutItem aOptsItem( ATTR_OPTIONS_LAYOUT );
137 :
138 0 : aOptsItem.GetOptionsLayout().SetRulerVisible( m_pCbxRuler->IsChecked() );
139 0 : aOptsItem.GetOptionsLayout().SetMoveOutline( m_pCbxMoveOutline->IsChecked() );
140 0 : aOptsItem.GetOptionsLayout().SetDragStripes( m_pCbxDragStripes->IsChecked() );
141 0 : aOptsItem.GetOptionsLayout().SetHandlesBezier( m_pCbxHandlesBezier->IsChecked() );
142 :
143 0 : rAttrs->Put( aOptsItem );
144 0 : bModified = true;
145 : }
146 0 : return( bModified );
147 : }
148 :
149 0 : void SdTpOptionsContents::Reset( const SfxItemSet* rAttrs )
150 : {
151 : SdOptionsContentsItem aOptsItem( (const SdOptionsContentsItem&) rAttrs->
152 0 : Get( ATTR_OPTIONS_CONTENTS ) );
153 :
154 : SdOptionsLayoutItem aLayoutItem( (const SdOptionsLayoutItem&) rAttrs->
155 0 : Get( ATTR_OPTIONS_LAYOUT ) );
156 :
157 0 : m_pCbxRuler->Check( aLayoutItem.GetOptionsLayout().IsRulerVisible() );
158 0 : m_pCbxMoveOutline->Check( aLayoutItem.GetOptionsLayout().IsMoveOutline() );
159 0 : m_pCbxDragStripes->Check( aLayoutItem.GetOptionsLayout().IsDragStripes() );
160 0 : m_pCbxHandlesBezier->Check( aLayoutItem.GetOptionsLayout().IsHandlesBezier() );
161 :
162 0 : m_pCbxRuler->SaveValue();
163 0 : m_pCbxMoveOutline->SaveValue();
164 0 : m_pCbxDragStripes->SaveValue();
165 0 : m_pCbxHandlesBezier->SaveValue();
166 0 : }
167 :
168 0 : SfxTabPage* SdTpOptionsContents::Create( vcl::Window* pWindow,
169 : const SfxItemSet* rAttrs )
170 : {
171 0 : return( new SdTpOptionsContents( pWindow, *rAttrs ) );
172 : }
173 :
174 : /*************************************************************************
175 : |*
176 : |* TabPage to adjust the misc options
177 : |*
178 : \************************************************************************/
179 : #define TABLE_COUNT 12
180 : #define TOKEN ':'
181 :
182 0 : SdTpOptionsMisc::SdTpOptionsMisc(vcl::Window* pParent, const SfxItemSet& rInAttrs)
183 : : SfxTabPage(pParent, "OptSavePage", "modules/simpress/ui/optimpressgeneralpage.ui", &rInAttrs)
184 : , nWidth(0)
185 0 : , nHeight(0)
186 : {
187 0 : get(m_pCbxQuickEdit , "qickedit");
188 0 : get(m_pCbxPickThrough , "textselected");
189 0 : get(m_pNewDocumentFrame, "newdocumentframe");
190 0 : get(m_pCbxStartWithTemplate,"startwithwizard");
191 0 : get(m_pCbxMasterPageCache , "backgroundback");
192 0 : get(m_pCbxCopy , "copywhenmove");
193 0 : get(m_pCbxMarkedHitMovesAlways , "objalwymov");
194 0 : get(m_pLbMetric , "units");
195 0 : get(m_pCbxEnableSdremote , "enremotcont");
196 0 : get(m_pCbxEnablePresenterScreen , "enprsntcons");
197 0 : get(m_pCbxUsePrinterMetrics , "printermetrics");
198 0 : get(m_pPresentationFrame , "presentationframe");
199 0 : get(m_pScaleFrame , "scaleframe");
200 0 : get(m_pCbScale , "scaleBox");
201 0 : get(m_pMtrFldTabstop , "metricFields");
202 0 : get(m_pMtrFldOriginalWidth , "metricWidthFields");
203 0 : get(m_pMtrFldOriginalHeight , "metricHeightFields");
204 0 : get(m_pMtrFldInfo1 , "metricInfo1Fields");
205 0 : get(m_pMtrFldInfo2 , "metricInfo2Fields");
206 0 : get(m_pCbxCompatibility ,"cbCompatibility" );
207 0 : get(m_pFiInfo1 , "info1");
208 0 : get(m_pFiInfo2 , "info2");
209 0 : get(m_pNewDocLb , "newdoclbl");
210 0 : get(m_pWidthLb , "widthlbl");
211 0 : get(m_pHeightLb , "heightlbl");
212 0 : get(m_pCbxDistrot , "distrotcb");
213 :
214 0 : SetExchangeSupport();
215 :
216 : // set metric
217 : FieldUnit eFUnit;
218 :
219 0 : sal_uInt16 nWhich = GetWhich( SID_ATTR_METRIC );
220 0 : if ( rInAttrs.GetItemState( nWhich ) >= SfxItemState::DEFAULT )
221 : {
222 0 : const SfxUInt16Item& rItem = (SfxUInt16Item&)rInAttrs.Get( nWhich );
223 0 : eFUnit = (FieldUnit)rItem.GetValue();
224 : }
225 : else
226 0 : eFUnit = SfxModule::GetCurrentFieldUnit();
227 :
228 0 : SetFieldUnit( *m_pMtrFldTabstop , eFUnit );
229 :
230 : // Impress is default mode, let' hide the entire scale frame etc.
231 0 : m_pCbxDistrot->Hide();
232 0 : m_pScaleFrame->Hide();
233 :
234 : // fill ListBox with metrics
235 0 : SvxStringArray aMetricArr( RID_SVXSTR_FIELDUNIT_TABLE );
236 : sal_uInt16 i;
237 :
238 0 : for ( i = 0; i < aMetricArr.Count(); ++i )
239 : {
240 0 : OUString sMetric = aMetricArr.GetStringByPos( i );
241 0 : sal_IntPtr nFieldUnit = aMetricArr.GetValue( i );
242 0 : sal_Int32 nPos = m_pLbMetric->InsertEntry( sMetric );
243 0 : m_pLbMetric->SetEntryData( nPos, (void*)nFieldUnit );
244 0 : }
245 0 : m_pLbMetric->SetSelectHdl( LINK( this, SdTpOptionsMisc, SelectMetricHdl_Impl ) );
246 :
247 0 : SetFieldUnit( *m_pMtrFldOriginalWidth, eFUnit );
248 0 : SetFieldUnit( *m_pMtrFldOriginalHeight, eFUnit );
249 0 : m_pMtrFldOriginalWidth->SetLast( 999999999 );
250 0 : m_pMtrFldOriginalWidth->SetMax( 999999999 );
251 0 : m_pMtrFldOriginalHeight->SetLast( 999999999 );
252 0 : m_pMtrFldOriginalHeight->SetMax( 999999999 );
253 :
254 : // temporary fields for info texts (for formatting/calculation)
255 0 : m_pMtrFldInfo1->SetUnit( eFUnit );
256 0 : m_pMtrFldInfo1->SetMax( 999999999 );
257 0 : m_pMtrFldInfo1->SetDecimalDigits( 2 );
258 0 : m_pMtrFldInfo2->SetUnit( eFUnit );
259 0 : m_pMtrFldInfo2->SetMax( 999999999 );
260 0 : m_pMtrFldInfo2->SetDecimalDigits( 2 );
261 :
262 : // determine PoolUnit
263 0 : SfxItemPool* pPool = rInAttrs.GetPool();
264 : DBG_ASSERT( pPool, "Where is the Pool?" );
265 0 : ePoolUnit = pPool->GetMetric( SID_ATTR_FILL_HATCH );
266 :
267 : // Fuellen der CB
268 : sal_uInt16 aTable[ TABLE_COUNT ] =
269 0 : { 1, 2, 4, 5, 8, 10, 16, 20, 30, 40, 50, 100 };
270 :
271 0 : for( i = 0; i < TABLE_COUNT; i++ )
272 0 : m_pCbScale->InsertEntry( GetScale( 1, aTable[i] ) );
273 0 : for( i = 1; i < TABLE_COUNT; i++ )
274 0 : m_pCbScale->InsertEntry( GetScale( aTable[i], 1 ) );
275 0 : }
276 :
277 0 : SdTpOptionsMisc::~SdTpOptionsMisc()
278 : {
279 0 : }
280 :
281 0 : void SdTpOptionsMisc::ActivatePage( const SfxItemSet& rSet )
282 : {
283 : // We have to call SaveValue again since it can happen that the value
284 : // has no effect on other TabPages
285 0 : m_pLbMetric->SaveValue();
286 : // change metric if necessary (since TabPage is in the Dialog where
287 : // the metric is set)
288 0 : const SfxPoolItem* pAttr = NULL;
289 0 : if( SfxItemState::SET == rSet.GetItemState( SID_ATTR_METRIC , false,
290 0 : (const SfxPoolItem**)&pAttr ))
291 : {
292 0 : const SfxUInt16Item* pItem = (SfxUInt16Item*) pAttr;
293 :
294 0 : FieldUnit eFUnit = (FieldUnit)(long)pItem->GetValue();
295 :
296 0 : if( eFUnit != m_pMtrFldOriginalWidth->GetUnit() )
297 : {
298 : // set metrics
299 0 : sal_Int64 nVal = m_pMtrFldOriginalWidth->Denormalize( m_pMtrFldOriginalWidth->GetValue( FUNIT_TWIP ) );
300 0 : SetFieldUnit( *m_pMtrFldOriginalWidth, eFUnit, true );
301 0 : m_pMtrFldOriginalWidth->SetValue( m_pMtrFldOriginalWidth->Normalize( nVal ), FUNIT_TWIP );
302 :
303 0 : nVal = m_pMtrFldOriginalHeight->Denormalize( m_pMtrFldOriginalHeight->GetValue( FUNIT_TWIP ) );
304 0 : SetFieldUnit( *m_pMtrFldOriginalHeight, eFUnit, true );
305 0 : m_pMtrFldOriginalHeight->SetValue( m_pMtrFldOriginalHeight->Normalize( nVal ), FUNIT_TWIP );
306 :
307 0 : if( nWidth != 0 && nHeight != 0 )
308 : {
309 0 : m_pMtrFldInfo1->SetUnit( eFUnit );
310 0 : m_pMtrFldInfo2->SetUnit( eFUnit );
311 :
312 0 : SetMetricValue( *m_pMtrFldInfo1, nWidth, ePoolUnit );
313 0 : aInfo1 = m_pMtrFldInfo1->GetText();
314 0 : m_pFiInfo1->SetText( aInfo1 );
315 :
316 0 : SetMetricValue( *m_pMtrFldInfo2, nHeight, ePoolUnit );
317 0 : aInfo2 = m_pMtrFldInfo2->GetText();
318 0 : m_pFiInfo2->SetText( aInfo2 );
319 : }
320 : }
321 : }
322 0 : }
323 :
324 0 : int SdTpOptionsMisc::DeactivatePage( SfxItemSet* pActiveSet )
325 : {
326 : // check parser
327 : sal_Int32 nX, nY;
328 0 : if( SetScale( m_pCbScale->GetText(), nX, nY ) )
329 : {
330 0 : if( pActiveSet )
331 0 : FillItemSet( pActiveSet );
332 0 : return( LEAVE_PAGE );
333 : }
334 0 : WarningBox aWarnBox( GetParent(), WB_YES_NO, SD_RESSTR( STR_WARN_SCALE_FAIL ) );
335 0 : short nReturn = aWarnBox.Execute();
336 :
337 0 : if( nReturn == RET_YES )
338 0 : return( KEEP_PAGE );
339 :
340 0 : if( pActiveSet )
341 0 : FillItemSet( pActiveSet );
342 :
343 0 : return( LEAVE_PAGE );
344 : }
345 :
346 0 : bool SdTpOptionsMisc::FillItemSet( SfxItemSet* rAttrs )
347 : {
348 0 : bool bModified = false;
349 :
350 0 : if( m_pCbxStartWithTemplate->IsValueChangedFromSaved() ||
351 0 : m_pCbxMarkedHitMovesAlways->IsValueChangedFromSaved() ||
352 0 : m_pCbxQuickEdit->IsValueChangedFromSaved() ||
353 0 : m_pCbxPickThrough->IsValueChangedFromSaved() ||
354 0 : m_pCbxMasterPageCache->IsValueChangedFromSaved() ||
355 0 : m_pCbxCopy->IsValueChangedFromSaved() ||
356 0 : m_pCbxEnableSdremote->IsValueChangedFromSaved() ||
357 0 : m_pCbxEnablePresenterScreen->IsValueChangedFromSaved() ||
358 0 : m_pCbxCompatibility->IsValueChangedFromSaved() ||
359 0 : m_pCbxUsePrinterMetrics->IsValueChangedFromSaved() )
360 : {
361 0 : SdOptionsMiscItem aOptsItem( ATTR_OPTIONS_MISC );
362 :
363 0 : aOptsItem.GetOptionsMisc().SetStartWithTemplate( m_pCbxStartWithTemplate->IsChecked() );
364 0 : aOptsItem.GetOptionsMisc().SetMarkedHitMovesAlways( m_pCbxMarkedHitMovesAlways->IsChecked() );
365 0 : aOptsItem.GetOptionsMisc().SetQuickEdit( m_pCbxQuickEdit->IsChecked() );
366 0 : aOptsItem.GetOptionsMisc().SetPickThrough( m_pCbxPickThrough->IsChecked() );
367 0 : aOptsItem.GetOptionsMisc().SetMasterPagePaintCaching( m_pCbxMasterPageCache->IsChecked() );
368 0 : aOptsItem.GetOptionsMisc().SetDragWithCopy( m_pCbxCopy->IsChecked() );
369 0 : aOptsItem.GetOptionsMisc().SetEnableSdremote( m_pCbxEnableSdremote->IsChecked() );
370 0 : aOptsItem.GetOptionsMisc().SetEnablePresenterScreen( m_pCbxEnablePresenterScreen->IsChecked() );
371 0 : aOptsItem.GetOptionsMisc().SetSummationOfParagraphs( m_pCbxCompatibility->IsChecked() );
372 0 : aOptsItem.GetOptionsMisc().SetPrinterIndependentLayout (
373 0 : m_pCbxUsePrinterMetrics->IsChecked()
374 : ? ::com::sun::star::document::PrinterIndependentLayout::DISABLED
375 0 : : ::com::sun::star::document::PrinterIndependentLayout::ENABLED);
376 0 : rAttrs->Put( aOptsItem );
377 :
378 0 : bModified = true;
379 : }
380 :
381 : // metric
382 0 : const sal_Int32 nMPos = m_pLbMetric->GetSelectEntryPos();
383 0 : if ( m_pLbMetric->IsValueChangedFromSaved() )
384 : {
385 0 : sal_uInt16 nFieldUnit = (sal_uInt16)(sal_IntPtr)m_pLbMetric->GetEntryData( nMPos );
386 0 : rAttrs->Put( SfxUInt16Item( GetWhich( SID_ATTR_METRIC ),
387 0 : (sal_uInt16)nFieldUnit ) );
388 0 : bModified = true;
389 : }
390 :
391 : // tabulator space
392 0 : if( m_pMtrFldTabstop->IsValueChangedFromSaved() )
393 : {
394 0 : sal_uInt16 nWh = GetWhich( SID_ATTR_DEFTABSTOP );
395 0 : SfxMapUnit eUnit = rAttrs->GetPool()->GetMetric( nWh );
396 0 : SfxUInt16Item aDef( nWh,(sal_uInt16)GetCoreValue( *m_pMtrFldTabstop, eUnit ) );
397 0 : rAttrs->Put( aDef );
398 0 : bModified = true;
399 : }
400 :
401 : sal_Int32 nX, nY;
402 0 : if( SetScale( m_pCbScale->GetText(), nX, nY ) )
403 : {
404 0 : rAttrs->Put( SfxInt32Item( ATTR_OPTIONS_SCALE_X, nX ) );
405 0 : rAttrs->Put( SfxInt32Item( ATTR_OPTIONS_SCALE_Y, nY ) );
406 :
407 0 : bModified = true;
408 : }
409 :
410 0 : return( bModified );
411 : }
412 :
413 0 : void SdTpOptionsMisc::Reset( const SfxItemSet* rAttrs )
414 : {
415 : SdOptionsMiscItem aOptsItem( (const SdOptionsMiscItem&) rAttrs->
416 0 : Get( ATTR_OPTIONS_MISC ) );
417 :
418 0 : m_pCbxStartWithTemplate->Check( aOptsItem.GetOptionsMisc().IsStartWithTemplate() );
419 0 : m_pCbxMarkedHitMovesAlways->Check( aOptsItem.GetOptionsMisc().IsMarkedHitMovesAlways() );
420 0 : m_pCbxQuickEdit->Check( aOptsItem.GetOptionsMisc().IsQuickEdit() );
421 0 : m_pCbxPickThrough->Check( aOptsItem.GetOptionsMisc().IsPickThrough() );
422 0 : m_pCbxMasterPageCache->Check( aOptsItem.GetOptionsMisc().IsMasterPagePaintCaching() );
423 0 : m_pCbxCopy->Check( aOptsItem.GetOptionsMisc().IsDragWithCopy() );
424 0 : m_pCbxEnableSdremote->Check( aOptsItem.GetOptionsMisc().IsEnableSdremote() );
425 0 : m_pCbxEnablePresenterScreen->Check( aOptsItem.GetOptionsMisc().IsEnablePresenterScreen() );
426 0 : m_pCbxCompatibility->Check( aOptsItem.GetOptionsMisc().IsSummationOfParagraphs() );
427 0 : m_pCbxUsePrinterMetrics->Check( aOptsItem.GetOptionsMisc().GetPrinterIndependentLayout()==1 );
428 0 : m_pCbxStartWithTemplate->SaveValue();
429 0 : m_pCbxMarkedHitMovesAlways->SaveValue();
430 0 : m_pCbxQuickEdit->SaveValue();
431 0 : m_pCbxPickThrough->SaveValue();
432 :
433 0 : m_pCbxMasterPageCache->SaveValue();
434 0 : m_pCbxCopy->SaveValue();
435 0 : m_pCbxEnableSdremote->SaveValue();
436 0 : m_pCbxEnablePresenterScreen->SaveValue();
437 0 : m_pCbxCompatibility->SaveValue();
438 0 : m_pCbxUsePrinterMetrics->SaveValue();
439 :
440 : // metric
441 0 : sal_uInt16 nWhich = GetWhich( SID_ATTR_METRIC );
442 0 : m_pLbMetric->SetNoSelection();
443 :
444 0 : if ( rAttrs->GetItemState( nWhich ) >= SfxItemState::DEFAULT )
445 : {
446 0 : const SfxUInt16Item& rItem = (SfxUInt16Item&)rAttrs->Get( nWhich );
447 0 : long nFieldUnit = (long)rItem.GetValue();
448 :
449 0 : for ( sal_Int32 i = 0; i < m_pLbMetric->GetEntryCount(); ++i )
450 : {
451 0 : if ( (sal_IntPtr)m_pLbMetric->GetEntryData( i ) == nFieldUnit )
452 : {
453 0 : m_pLbMetric->SelectEntryPos( i );
454 0 : break;
455 : }
456 : }
457 : }
458 :
459 : // tabulator space
460 0 : nWhich = GetWhich( SID_ATTR_DEFTABSTOP );
461 0 : if( rAttrs->GetItemState( nWhich ) >= SfxItemState::DEFAULT )
462 : {
463 0 : SfxMapUnit eUnit = rAttrs->GetPool()->GetMetric( nWhich );
464 0 : const SfxUInt16Item& rItem = (SfxUInt16Item&)rAttrs->Get( nWhich );
465 0 : SetMetricValue( *m_pMtrFldTabstop, rItem.GetValue(), eUnit );
466 : }
467 0 : m_pLbMetric->SaveValue();
468 0 : m_pMtrFldTabstop->SaveValue();
469 : //Scale
470 : sal_Int32 nX = ( (const SfxInt32Item&) rAttrs->
471 0 : Get( ATTR_OPTIONS_SCALE_X ) ).GetValue();
472 : sal_Int32 nY = ( (const SfxInt32Item&) rAttrs->
473 0 : Get( ATTR_OPTIONS_SCALE_Y ) ).GetValue();
474 : nWidth = ( (const SfxUInt32Item&) rAttrs->
475 0 : Get( ATTR_OPTIONS_SCALE_WIDTH ) ).GetValue();
476 : nHeight = ( (const SfxUInt32Item&) rAttrs->
477 0 : Get( ATTR_OPTIONS_SCALE_HEIGHT ) ).GetValue();
478 :
479 0 : m_pCbScale->SetText( GetScale( nX, nY ) );
480 :
481 0 : m_pMtrFldOriginalWidth->Hide();
482 0 : m_pMtrFldOriginalWidth->SetText( aInfo1 ); // empty
483 0 : m_pMtrFldOriginalHeight->Hide();
484 0 : m_pMtrFldOriginalHeight->SetText( aInfo2 ); //empty
485 0 : m_pFiInfo1->Hide();
486 0 : m_pFiInfo2->Hide();
487 :
488 0 : UpdateCompatibilityControls ();
489 0 : }
490 :
491 0 : SfxTabPage* SdTpOptionsMisc::Create( vcl::Window* pWindow,
492 : const SfxItemSet* rAttrs )
493 : {
494 0 : return( new SdTpOptionsMisc( pWindow, *rAttrs ) );
495 : }
496 :
497 0 : IMPL_LINK_NOARG(SdTpOptionsMisc, SelectMetricHdl_Impl)
498 : {
499 0 : sal_Int32 nPos = m_pLbMetric->GetSelectEntryPos();
500 :
501 0 : if( nPos != LISTBOX_ENTRY_NOTFOUND )
502 : {
503 0 : FieldUnit eUnit = (FieldUnit)(sal_IntPtr)m_pLbMetric->GetEntryData( nPos );
504 : sal_Int64 nVal =
505 0 : m_pMtrFldTabstop->Denormalize( m_pMtrFldTabstop->GetValue( FUNIT_TWIP ) );
506 0 : SetFieldUnit( *m_pMtrFldTabstop, eUnit );
507 0 : m_pMtrFldTabstop->SetValue( m_pMtrFldTabstop->Normalize( nVal ), FUNIT_TWIP );
508 : }
509 0 : return 0;
510 : }
511 :
512 0 : void SdTpOptionsMisc::SetImpressMode (void)
513 : {
514 : #ifndef ENABLE_SDREMOTE_BLUETOOTH
515 : m_pCbxEnableSdremote->Hide();
516 : #endif
517 0 : }
518 :
519 0 : void SdTpOptionsMisc::SetDrawMode()
520 : {
521 0 : m_pScaleFrame->Show();
522 0 : m_pNewDocumentFrame->Hide();
523 0 : m_pCbxEnableSdremote->Hide();
524 0 : m_pCbxEnablePresenterScreen->Hide();
525 0 : m_pCbxCompatibility->Hide();
526 0 : m_pNewDocLb->Hide();
527 0 : m_pCbScale->Show();
528 0 : m_pPresentationFrame->Hide();
529 0 : m_pMtrFldInfo1->Hide();
530 0 : m_pMtrFldInfo2->Hide();
531 0 : m_pWidthLb->Hide();
532 0 : m_pHeightLb->Hide();
533 0 : m_pFiInfo1->Show();
534 0 : m_pMtrFldOriginalWidth->Show();
535 0 : m_pFiInfo2->Show();
536 0 : m_pMtrFldOriginalHeight->Show();
537 0 : m_pCbxDistrot->Show();
538 0 : m_pCbxCompatibility->Hide();
539 : // Move the printer-independent-metrics check box in the place that the
540 : // spacing-between-paragraphs check box normally is in.
541 0 : m_pCbxUsePrinterMetrics->SetPosPixel (m_pCbxCompatibility->GetPosPixel());
542 0 : }
543 :
544 0 : OUString SdTpOptionsMisc::GetScale( sal_Int32 nX, sal_Int32 nY )
545 : {
546 0 : return OUString::number(nX) + OUString(TOKEN) + OUString::number(nY);
547 : }
548 :
549 0 : bool SdTpOptionsMisc::SetScale( const OUString& aScale, sal_Int32& rX, sal_Int32& rY )
550 : {
551 0 : if( comphelper::string::getTokenCount(aScale, TOKEN) != 2 )
552 0 : return false;
553 :
554 0 : OUString aTmp(aScale.getToken(0, TOKEN));
555 0 : if (!comphelper::string::isdigitAsciiString(aTmp))
556 0 : return false;
557 :
558 0 : rX = (long) aTmp.toInt32();
559 0 : if( rX == 0 )
560 0 : return false;
561 :
562 0 : aTmp = aScale.getToken(1, TOKEN);
563 0 : if (!comphelper::string::isdigitAsciiString(aTmp))
564 0 : return false;
565 :
566 0 : rY = (long) aTmp.toInt32();
567 0 : if( rY == 0 )
568 0 : return false;
569 :
570 0 : return true;
571 : }
572 :
573 0 : void SdTpOptionsMisc::UpdateCompatibilityControls (void)
574 : {
575 : // Disable the compatibility controls by default. Enable them only when
576 : // there is at least one open document.
577 0 : bool bIsEnabled = false;
578 :
579 : try
580 : {
581 : // Get a component enumeration from the desktop and search it for documents.
582 0 : Reference<uno::XComponentContext> xContext( ::comphelper::getProcessComponentContext());
583 : do
584 : {
585 0 : Reference<frame::XDesktop2> xDesktop = frame::Desktop::create(xContext);
586 :
587 : Reference<container::XEnumerationAccess> xComponents (
588 0 : xDesktop->getComponents(), UNO_QUERY);
589 0 : if ( ! xComponents.is())
590 0 : break;
591 :
592 : Reference<container::XEnumeration> xEnumeration (
593 0 : xComponents->createEnumeration());
594 0 : if ( ! xEnumeration.is())
595 0 : break;
596 :
597 0 : while (xEnumeration->hasMoreElements())
598 : {
599 0 : Reference<frame::XModel> xModel (xEnumeration->nextElement(), UNO_QUERY);
600 0 : if (xModel.is())
601 : {
602 : // There is at leas one model/document: Enable the compatibility controls.
603 0 : bIsEnabled = true;
604 0 : break;
605 : }
606 0 : }
607 :
608 : }
609 0 : while (false); // One 'loop'.
610 : }
611 0 : catch (const uno::Exception&)
612 : {
613 : // When there is an exception then simply use the default value of
614 : // bIsEnabled and disable the controls.
615 : }
616 :
617 0 : m_pCbxCompatibility->Enable(bIsEnabled);
618 0 : m_pCbxUsePrinterMetrics->Enable (bIsEnabled);
619 0 : }
620 :
621 0 : void SdTpOptionsMisc::PageCreated(const SfxAllItemSet& aSet)
622 : {
623 0 : SFX_ITEMSET_ARG (&aSet,pFlagItem,SfxUInt32Item,SID_SDMODE_FLAG,false);
624 0 : if (pFlagItem)
625 : {
626 0 : sal_uInt32 nFlags=pFlagItem->GetValue();
627 0 : if ( ( nFlags & SD_DRAW_MODE ) == SD_DRAW_MODE )
628 0 : SetDrawMode();
629 0 : if ( ( nFlags & SD_IMPRESS_MODE ) == SD_IMPRESS_MODE )
630 0 : SetImpressMode();
631 : }
632 0 : }
633 :
634 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|