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