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