xref: /trunk/main/svl/qa/complex/ConfigItems/helper/PrintOptTest.cxx (revision 1ecadb572e7010ff3b3382ad9bf179dbc6efadbb)
1 /*************************************************************************
2  *
3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4  *
5  * Copyright 2000, 2010 Oracle and/or its affiliates.
6  *
7  * OpenOffice.org - a multi-platform office productivity suite
8  *
9  * This file is part of OpenOffice.org.
10  *
11  * OpenOffice.org is free software: you can redistribute it and/or modify
12  * it under the terms of the GNU Lesser General Public License version 3
13  * only, as published by the Free Software Foundation.
14  *
15  * OpenOffice.org is distributed in the hope that it will be useful,
16  * but WITHOUT ANY WARRANTY; without even the implied warranty of
17  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18  * GNU Lesser General Public License version 3 for more details
19  * (a copy is included in the LICENSE file that accompanied this code).
20  *
21  * You should have received a copy of the GNU Lesser General Public License
22  * version 3 along with OpenOffice.org.  If not, see
23  * <http://www.openoffice.org/license.html>
24  * for a copy of the LGPLv3 License.
25  *
26  ************************************************************************/
27 
28 #include "PrintOptTest.hxx"
29 
30 #include <com/sun/star/beans/XPropertySet.hpp>
31 
32 #include <unotools/processfactory.hxx>
33 #include <comphelper/configurationhelper.hxx>
34 
35 namespace css = ::com::sun::star;
36 
37 // using test  only
38 #define ROOTNODE_PRINTOPTION                            rtl::OUString::createFromAscii("org.openoffice.Office.Common/Print/Option")
39 #define PROPERTYNAME_REDUCETRANSPARENCY                 rtl::OUString::createFromAscii("ReduceTransparency")
40 #define PROPERTYNAME_REDUCEDTRANSPARENCYMODE            rtl::OUString::createFromAscii("ReducedTransparencyMode")
41 #define PROPERTYNAME_REDUCEGRADIENTS                    rtl::OUString::createFromAscii("ReduceGradients")
42 #define PROPERTYNAME_REDUCEDGRADIENTMODE                rtl::OUString::createFromAscii("ReducedGradientMode")
43 #define PROPERTYNAME_REDUCEDGRADIENTSTEPCOUNT           rtl::OUString::createFromAscii("ReducedGradientStepCount")
44 #define PROPERTYNAME_REDUCEBITMAPS                      rtl::OUString::createFromAscii("ReduceBitmaps")
45 #define PROPERTYNAME_REDUCEDBITMAPMODE                  rtl::OUString::createFromAscii("ReducedBitmapMode")
46 #define PROPERTYNAME_REDUCEDBITMAPRESOLUTION            rtl::OUString::createFromAscii("ReducedBitmapResolution")
47 #define PROPERTYNAME_REDUCEDBITMAPINCLUDESTRANSPARENCY  rtl::OUString::createFromAscii("ReducedBitmapIncludesTransparency")
48 #define PROPERTYNAME_CONVERTTOGREYSCALES                rtl::OUString::createFromAscii("ConvertToGreyscales")
49 
50 PrintOptTest::PrintOptTest()
51 {
52     m_xCfg = css::uno::Reference< css::container::XNameAccess >(
53             ::comphelper::ConfigurationHelper::openConfig(
54             ::utl::getProcessServiceFactory(),
55             rtl::OUString::createFromAscii("org.openoffice.Office.Common/Print/Option"),
56             ::comphelper::ConfigurationHelper::E_STANDARD),
57             css::uno::UNO_QUERY);
58 
59         if (m_xCfg.is())
60         {
61             //UniString  sTmp = UniString("printer");
62             //xub_StrLen nTokenCount = sTmp.GetTokenCount('/');
63             //sTmp = sTmp.GetToken(nTokenCount - 1, '/');
64             m_xCfg->getByName(rtl::OUString::createFromAscii("Printer")) >>= m_xNode;
65         }
66 }
67 
68 sal_Int16 PrintOptTest::impl_GetReducedTransparencyMode() const
69 {
70     sal_Int16 nRet = 0;
71     if (m_xNode.is())
72     {
73         css::uno::Reference< css::beans::XPropertySet > xSet(m_xNode, css::uno::UNO_QUERY);
74         if (xSet.is())
75             xSet->getPropertyValue(PROPERTYNAME_REDUCEDTRANSPARENCYMODE) >>= nRet;
76     }
77     return  nRet;
78 }
79 void PrintOptTest::impl_SetReducedTransparencyMode(sal_Int16 nMode )
80 {
81     if (m_xNode.is())
82     {
83         css::uno::Reference<css::beans::XPropertySet> xSet(m_xNode, css::uno::UNO_QUERY);
84         if (xSet.is())
85         {
86             sal_Int16 nUpdate;
87             xSet->getPropertyValue(PROPERTYNAME_REDUCEDTRANSPARENCYMODE) >>= nUpdate;
88             if (nUpdate != nMode)
89             {
90                 xSet->setPropertyValue( PROPERTYNAME_REDUCEDTRANSPARENCYMODE, css::uno::makeAny(nMode));
91                 ::comphelper::ConfigurationHelper::flush(m_xCfg);
92             }
93         }
94     }
95 }
96 
97 sal_Bool PrintOptTest::impl_IsReduceTransparency() const
98 {
99     sal_Bool bRet = sal_False;
100     if (m_xNode.is())
101     {
102         css::uno::Reference< css::beans::XPropertySet > xSet(m_xNode, css::uno::UNO_QUERY);
103         if (xSet.is())
104             xSet->getPropertyValue(PROPERTYNAME_REDUCETRANSPARENCY) >>= bRet;
105     }
106     return bRet;
107 }
108 void PrintOptTest::impl_SetReduceTransparency(sal_Bool bState )
109 {
110     if (m_xNode.is())
111     {
112         css::uno::Reference<css::beans::XPropertySet> xSet(m_xNode, css::uno::UNO_QUERY);
113         if (xSet.is())
114         {
115             sal_Bool bUpdate;
116             xSet->getPropertyValue(PROPERTYNAME_REDUCETRANSPARENCY) >>= bUpdate;
117             if (bUpdate != bState)
118             {
119                 xSet->setPropertyValue( PROPERTYNAME_REDUCETRANSPARENCY, css::uno::makeAny(bState));
120                 ::comphelper::ConfigurationHelper::flush(m_xCfg);
121             }
122         }
123     }
124 }
125 
126 sal_Bool PrintOptTest::impl_IsReduceGradients() const
127 {
128     sal_Bool bRet = sal_False;
129     if (m_xNode.is())
130     {
131         css::uno::Reference<css::beans::XPropertySet> xSet(m_xNode, css::uno::UNO_QUERY);
132         if (xSet.is())
133         {
134             xSet->getPropertyValue(PROPERTYNAME_REDUCEGRADIENTS) >>= bRet;
135         }
136     }
137     return bRet;
138 }
139 
140 void PrintOptTest::impl_SetReduceGradients(sal_Bool bState )
141 {
142     if (m_xNode.is())
143     {
144         css::uno::Reference<css::beans::XPropertySet> xSet(m_xNode, css::uno::UNO_QUERY);
145         if (xSet.is())
146         {
147             sal_Bool bUpdate;
148             xSet->getPropertyValue(PROPERTYNAME_REDUCEGRADIENTS) >>= bUpdate;
149             if (bUpdate != bState)
150             {
151                 xSet->setPropertyValue( PROPERTYNAME_REDUCEGRADIENTS, css::uno::makeAny(bState));
152                 ::comphelper::ConfigurationHelper::flush(m_xCfg);
153             }
154         }
155     }
156 }
157 
158 sal_Int16 PrintOptTest::impl_GetReducedGradientMode() const
159 {
160     sal_Int16 nRet = 0;
161     if (m_xNode.is())
162     {
163         css::uno::Reference<css::beans::XPropertySet> xSet(m_xNode, css::uno::UNO_QUERY);
164         if (xSet.is())
165         {
166             xSet->getPropertyValue(PROPERTYNAME_REDUCEDGRADIENTMODE) >>= nRet;
167         }
168     }
169     return nRet;
170 }
171 
172 void PrintOptTest::impl_SetReducedGradientMode(sal_Int16 nMode )
173 {
174     if (m_xNode.is())
175     {
176         css::uno::Reference<css::beans::XPropertySet> xSet(m_xNode, css::uno::UNO_QUERY);
177         if (xSet.is())
178         {
179             sal_Int16 nUpdate;
180             xSet->getPropertyValue(PROPERTYNAME_REDUCEDGRADIENTMODE) >>= nUpdate;
181             if (nUpdate != nMode)
182             {
183                 xSet->setPropertyValue( PROPERTYNAME_REDUCEDGRADIENTMODE, css::uno::makeAny(nMode));
184                 ::comphelper::ConfigurationHelper::flush(m_xCfg);
185             }
186         }
187     }
188 }
189 
190 sal_Int16 PrintOptTest::impl_GetReducedGradientStepCount() const
191 {
192     sal_Int16 nRet = 64;
193     if (m_xNode.is())
194     {
195         css::uno::Reference<css::beans::XPropertySet> xSet(m_xNode, css::uno::UNO_QUERY);
196         if (xSet.is())
197         {
198             xSet->getPropertyValue(PROPERTYNAME_REDUCEDGRADIENTSTEPCOUNT) >>= nRet;
199         }
200     }
201     return nRet;
202 }
203 void PrintOptTest::impl_SetReducedGradientStepCount(sal_Int16 nStepCount )
204 {
205     if (m_xNode.is())
206     {
207         css::uno::Reference<css::beans::XPropertySet> xSet(m_xNode, css::uno::UNO_QUERY);
208         if (xSet.is())
209         {
210             sal_Int16 nUpdate;
211             xSet->getPropertyValue(PROPERTYNAME_REDUCEDGRADIENTSTEPCOUNT) >>= nUpdate;
212             if (nUpdate != nStepCount)
213             {
214                 xSet->setPropertyValue( PROPERTYNAME_REDUCEDGRADIENTSTEPCOUNT, css::uno::makeAny(nStepCount));
215                 ::comphelper::ConfigurationHelper::flush(m_xCfg);
216             }
217         }
218     }
219 }
220 
221 sal_Bool PrintOptTest::impl_IsReduceBitmaps() const
222 {
223     sal_Bool bRet = sal_False;
224     if (m_xNode.is())
225     {
226         css::uno::Reference<css::beans::XPropertySet> xSet(m_xNode, css::uno::UNO_QUERY);
227         if (xSet.is())
228         {
229             xSet->getPropertyValue(PROPERTYNAME_REDUCEBITMAPS) >>= bRet;
230         }
231     }
232     return bRet;
233 }
234 
235 void PrintOptTest::impl_SetReduceBitmaps(sal_Bool bState )
236 {
237     if (m_xNode.is())
238     {
239         css::uno::Reference<css::beans::XPropertySet> xSet(m_xNode, css::uno::UNO_QUERY);
240         if (xSet.is())
241         {
242             sal_Bool bUpdate;
243             xSet->getPropertyValue(PROPERTYNAME_REDUCEBITMAPS) >>= bUpdate;
244             if (bUpdate != bState)
245             {
246                 xSet->setPropertyValue( PROPERTYNAME_REDUCEBITMAPS, css::uno::makeAny(bState));
247                 ::comphelper::ConfigurationHelper::flush(m_xCfg);
248             }
249         }
250     }
251 }
252 
253 sal_Int16 PrintOptTest::impl_GetReducedBitmapMode() const
254 {
255     sal_Int16 nRet = 1;
256     if (m_xNode.is())
257     {
258         css::uno::Reference<css::beans::XPropertySet> xSet(m_xNode, css::uno::UNO_QUERY);
259         if (xSet.is())
260         {
261             xSet->getPropertyValue(PROPERTYNAME_REDUCEDBITMAPMODE) >>= nRet;
262         }
263     }
264     return nRet;
265 }
266 
267 void PrintOptTest::impl_SetReducedBitmapMode(sal_Int16 nMode )
268 {
269     if (m_xNode.is())
270     {
271         css::uno::Reference<css::beans::XPropertySet> xSet(m_xNode, css::uno::UNO_QUERY);
272         if (xSet.is())
273         {
274             sal_Int16 nUpdate;
275             xSet->getPropertyValue(PROPERTYNAME_REDUCEDBITMAPMODE) >>= nUpdate;
276             if (nUpdate != nMode)
277             {
278                 xSet->setPropertyValue( PROPERTYNAME_REDUCEDBITMAPMODE, css::uno::makeAny(nMode));
279                 ::comphelper::ConfigurationHelper::flush(m_xCfg);
280             }
281         }
282     }
283 }
284 
285 sal_Int16  PrintOptTest::impl_GetReducedBitmapResolution() const
286 {
287     sal_Int16 nRet = 3;
288     if (m_xNode.is())
289     {
290         css::uno::Reference<css::beans::XPropertySet> xSet(m_xNode, css::uno::UNO_QUERY);
291         if (xSet.is())
292         {
293             xSet->getPropertyValue(PROPERTYNAME_REDUCEDBITMAPRESOLUTION) >>= nRet;
294         }
295     }
296     return  nRet;
297 }
298 
299 void PrintOptTest::impl_SetReducedBitmapResolution(sal_Int16 nResolution )
300 {
301     if (m_xNode.is())
302     {
303         css::uno::Reference<css::beans::XPropertySet> xSet(m_xNode, css::uno::UNO_QUERY);
304         if (xSet.is())
305         {
306             sal_Int16 nUpdate;
307             xSet->getPropertyValue(PROPERTYNAME_REDUCEDBITMAPRESOLUTION) >>= nUpdate;
308             if (nUpdate != nResolution)
309             {
310                 xSet->setPropertyValue( PROPERTYNAME_REDUCEDBITMAPRESOLUTION, css::uno::makeAny(nResolution));
311                 ::comphelper::ConfigurationHelper::flush(m_xCfg);
312             }
313         }
314     }
315 }
316 
317 sal_Bool PrintOptTest::impl_IsReducedBitmapIncludesTransparency() const
318 {
319     sal_Bool bRet = sal_True;
320     if (m_xNode.is())
321     {
322         css::uno::Reference<css::beans::XPropertySet> xSet(m_xNode, css::uno::UNO_QUERY);
323         if (xSet.is())
324         {
325             xSet->getPropertyValue(PROPERTYNAME_REDUCEDBITMAPINCLUDESTRANSPARENCY) >>= bRet;
326         }
327     }
328     return  bRet;
329 }
330 
331 void PrintOptTest::impl_SetReducedBitmapIncludesTransparency(sal_Bool bState )
332 {
333     if (m_xNode.is())
334     {
335         css::uno::Reference<css::beans::XPropertySet> xSet(m_xNode, css::uno::UNO_QUERY);
336         if (xSet.is())
337         {
338             sal_Bool bUpdate;
339             xSet->getPropertyValue(PROPERTYNAME_REDUCEDBITMAPINCLUDESTRANSPARENCY) >>= bUpdate;
340             if (bUpdate != bState)
341             {
342                 xSet->setPropertyValue( PROPERTYNAME_REDUCEDBITMAPINCLUDESTRANSPARENCY, css::uno::makeAny(bState));
343                 ::comphelper::ConfigurationHelper::flush(m_xCfg);
344             }
345         }
346     }
347 }
348 
349 sal_Bool PrintOptTest::impl_IsConvertToGreyscales() const
350 {
351     sal_Bool bRet = sal_False;
352     if (m_xNode.is())
353     {
354         css::uno::Reference<css::beans::XPropertySet> xSet(m_xNode, css::uno::UNO_QUERY);
355         if (xSet.is())
356         {
357             xSet->getPropertyValue(PROPERTYNAME_CONVERTTOGREYSCALES) >>= bRet;
358         }
359     }
360     return  bRet;
361 }
362 
363 void PrintOptTest::impl_SetConvertToGreyscales(sal_Bool bState )
364 {
365     if (m_xNode.is())
366     {
367         css::uno::Reference<css::beans::XPropertySet> xSet(m_xNode, css::uno::UNO_QUERY);
368         if (xSet.is())
369         {
370             sal_Bool bUpdate;
371             xSet->getPropertyValue(PROPERTYNAME_CONVERTTOGREYSCALES) >>= bUpdate;
372             if (bUpdate != bState)
373             {
374                 xSet->setPropertyValue( PROPERTYNAME_CONVERTTOGREYSCALES, css::uno::makeAny(bState));
375                 ::comphelper::ConfigurationHelper::flush(m_xCfg);
376             }
377         }
378     }
379 }
380 
381 
382 PrintOptTest::~PrintOptTest()
383 {
384 }
385 
386 void PrintOptTest::impl_checkPrint()
387 {
388     //test SetReduceTransparency()
389     sal_Bool bNewValue = sal_False;
390     sal_Bool bOldValue = sal_False;
391     bOldValue = PrintOptTest::impl_IsReduceTransparency();
392     bNewValue = !bOldValue;
393     aPrintOpt.SetReduceTransparency(bNewValue) ;
394     bNewValue = impl_IsReduceTransparency();
395    // if(bNewValue != bOldValue) // test the old source
396     if ( bNewValue == bOldValue ) // test the new source
397     {
398         throw css::uno::RuntimeException(
399             rtl::OUString::createFromAscii(
400             "null com.sun.star.configuration."
401             "the SetReduceTransparency() error!"),
402             0);
403     }
404 
405     //test IsReduceTransparemcy()
406     bNewValue = bOldValue = sal_False;
407     bOldValue = impl_IsReduceTransparency();
408     bNewValue = !bOldValue;
409     impl_SetReduceTransparency(bNewValue);
410     bNewValue = aPrintOpt.IsReduceTransparency();
411     //if(bNewValue != bOldValue) // test the old source
412     if(bNewValue == bOldValue) // test the new source
413     {
414         throw css::uno::RuntimeException(
415             rtl::OUString::createFromAscii(
416             "null com.sun.star.configuration."
417             "the IsReduceTransparency() error!"),
418             0);
419     }
420 
421     // test SetReducedTransparencyMode()
422     sal_Int16 nOldMode, nNewMode;
423     nOldMode = nNewMode = 0;
424     nOldMode = impl_GetReducedTransparencyMode();
425     nNewMode = nOldMode + 1;
426     aPrintOpt.SetReducedTransparencyMode( nNewMode );
427     nNewMode = impl_GetReducedTransparencyMode();
428     //if(nNewMode != nOldMode)      // test the old source
429     if ( nNewMode == nOldMode ) // test the new source
430     {
431         throw css::uno::RuntimeException(
432             rtl::OUString::createFromAscii(
433             "null com.sun.star.configuration."
434             "the SetReducedTransparencyMode() error!"),
435             0);
436     }
437 
438     //test IsReducedTransparencyMode()
439     nOldMode = nNewMode = 0;
440     nOldMode = impl_GetReducedTransparencyMode();
441     nNewMode = nOldMode + 1;
442     impl_SetReducedTransparencyMode(nNewMode);
443     nNewMode = aPrintOpt.GetReducedTransparencyMode();
444     //if(nNewMode != nOldMode)    // test the old source
445     if(nNewMode == nOldMode)  // test the new source
446     {
447         throw css::uno::RuntimeException(
448             rtl::OUString::createFromAscii(
449             "null com.sun.star.configuration."
450             "the IsReducedTransparencyMode() error!"
451             "nOldMode's value is :"),
452             0);
453     }
454 
455     // test the SetReduceGradients()
456     bNewValue = bOldValue = sal_False;
457     bOldValue = impl_IsReduceGradients();
458     bNewValue = !bOldValue;
459     aPrintOpt.SetReduceGradients(bNewValue);
460     bNewValue = impl_IsReduceGradients();
461     //if (bNewValue != bOldValue)   //test the old source
462     if (bNewValue == bOldValue)   //test the new source
463     {
464         throw css::uno::RuntimeException(
465             rtl::OUString::createFromAscii(
466             "null com.sun.star.configuration."
467             "the SetReduceGradients() error!"),
468             0);
469 
470     }
471 
472     // test the IsReduceGradients()
473     bNewValue = bOldValue = sal_False;
474     bOldValue = impl_IsReduceGradients();
475     bNewValue = !bOldValue;
476     this->impl_SetReduceGradients(bNewValue);
477     bNewValue = aPrintOpt.IsReduceGradients();
478    // if (bNewValue != bOldValue)   // test the old source
479     if (bNewValue == bOldValue) // test the new source
480     {
481         throw css::uno::RuntimeException(
482             rtl::OUString::createFromAscii(
483             "null com.sun.star.configuration."
484             "the IsReduceGradients() error!"),
485             0);
486 
487     }
488 
489     //test SetRedecedGradientMode()
490     nOldMode = nNewMode = 0;
491     nOldMode = this->impl_GetReducedGradientMode();
492     nNewMode = nOldMode + 1;
493     aPrintOpt.SetReducedGradientMode(nNewMode);
494     nNewMode = this->impl_GetReducedGradientMode();
495     //if (nNewMode != nOldMode)  // test the old source
496     if (nNewMode == nOldMode)// test the new source
497     {
498         throw css::uno::RuntimeException(
499             rtl::OUString::createFromAscii(
500             "null com.sun.star.configuration."
501             "the SetRedecedGradientMode() error!"),
502             0);
503     }
504 
505     // test GetReducedGradientMode()
506     nOldMode = nNewMode = 0;
507     nOldMode = this->impl_GetReducedGradientMode();
508     nNewMode = nOldMode + 1;
509     this->impl_SetReducedGradientMode(nNewMode);
510     nNewMode = aPrintOpt.GetReducedGradientMode();
511     //if (nNewMode != nOldMode) // test the old source
512     if (nNewMode == nOldMode) // test the new source
513     {
514         throw css::uno::RuntimeException(
515             rtl::OUString::createFromAscii(
516             "null com.sun.star.configuration."
517             "the GetReducedGradientMode() error!"),
518             0);
519 
520     }
521 
522     //test the SetReducedGradientStepCount()
523     sal_Int16 nNewStepCount;
524     sal_Int16 nOldStepCount;
525     nNewStepCount = nOldStepCount = 0;
526     nOldStepCount = this->impl_GetReducedGradientStepCount();
527     nNewStepCount = nOldStepCount + 1;
528     aPrintOpt.SetReducedGradientStepCount(nNewStepCount);
529     nNewStepCount = this->impl_GetReducedGradientStepCount();
530    // if (nNewStepCount != nOldStepCount) // test the old source
531     if (nNewStepCount == nOldStepCount) // test the new source
532     {
533         throw css::uno::RuntimeException(
534             rtl::OUString::createFromAscii(
535             "null com.sun.star.configuration."
536             "the SetReducedGradientStepCount() error!"),
537             0);
538 
539     }
540 
541     // test the GetReduceGradientStepCount()
542     nNewStepCount = nOldStepCount = 0;
543     nOldStepCount = this->impl_GetReducedGradientStepCount();
544     nNewStepCount = nOldStepCount + 1;
545     this->impl_SetReducedGradientStepCount(nNewStepCount);
546     nNewStepCount = aPrintOpt.GetReducedGradientStepCount();
547    // if (nNewStepCount != nOldStepCount)  //test the old source
548     if (nNewStepCount == nOldStepCount)  //test the new source
549     {
550         throw css::uno::RuntimeException(
551             rtl::OUString::createFromAscii(
552             "null com.sun.star.configuration."
553             "the GetReduceGradientStepCount() error!"),
554             0);
555     }
556 
557     // test the SetReduceBitmaps()
558     bNewValue = bOldValue = sal_False;
559     bOldValue = this->impl_IsReduceBitmaps();
560     bNewValue = !bOldValue;
561     aPrintOpt.SetReduceBitmaps(bNewValue);
562     bNewValue = this->impl_IsReduceBitmaps();
563     //if (bNewValue != bOldValue) // test the old source
564     if (bNewValue == bOldValue) // test the new source
565     {
566         throw css::uno::RuntimeException(
567             rtl::OUString::createFromAscii(
568             "null com.sun.star.configuration."
569             "the SetReduceBitmaps() error!"),
570             0);
571     }
572 
573     // test the IsReduceBitmaps()
574     bNewValue = bOldValue = sal_False;
575     bOldValue = this->impl_IsReduceBitmaps();
576     bNewValue = !bOldValue;
577     this->impl_SetReduceBitmaps(bNewValue);
578     bNewValue = aPrintOpt.IsReduceBitmaps();
579     //if (bNewValue != bOldValue)   // test the old source
580     if (bNewValue == bOldValue) // test the new source
581     {
582         throw css::uno::RuntimeException(
583             rtl::OUString::createFromAscii(
584             "null com.sun.star.configuration."
585             "the IsReduceBitmaps() error!"),
586             0);
587     }
588 
589     // test the SetReduceBitmap()
590     nNewMode = nOldMode = 0;
591     nOldMode = impl_GetReducedBitmapMode();
592     nNewMode = nOldMode + 1;
593     aPrintOpt.SetReducedBitmapMode(nNewMode);
594     nNewMode = impl_GetReducedBitmapMode();
595     //if (nNewMode != nOldMode)  // test the old source
596     if (nNewMode == nOldMode)// test the new source
597     {
598         throw css::uno::RuntimeException(
599             rtl::OUString::createFromAscii(
600             "null com.sun.star.configuration."
601             "the SetReduceBitmap() error!"),
602             0);
603     }
604 
605     // test the SetReduceBitmapMode()
606     nNewMode = nOldMode = 0;
607     nOldMode = this->impl_GetReducedBitmapMode();
608     nNewMode = nOldMode + 1;
609     aPrintOpt.SetReducedBitmapMode(nNewMode);
610     nNewMode = this->impl_GetReducedBitmapMode();
611     //if (nNewMode != nOldMode) // test the old source
612     if (nNewMode == nOldMode)  // test the new source
613     {
614         throw css::uno::RuntimeException(
615             rtl::OUString::createFromAscii(
616             "null com.sun.star.configuration."
617             "the SetReduceBitmapMode() error!"),
618             0);
619     }
620 
621     // test the GetReduceBitmapMode()
622     nNewMode = nOldMode = 0;
623     nOldMode = this->impl_GetReducedBitmapMode();
624     nNewMode = nOldMode + 1;
625     this->impl_SetReducedBitmapMode(nNewMode);
626     nNewMode = aPrintOpt.GetReducedBitmapMode();
627     //if (nNewMode != nOldMode)  // test the old source
628     if (nNewMode == nOldMode)// test the new source
629     {
630         throw css::uno::RuntimeException(
631             rtl::OUString::createFromAscii(
632             "null com.sun.star.configuration."
633             "the GetReduceBitmapMode() error!"),
634             0);
635 
636     }
637 
638     // test the SetReducedBitmapResolution()
639     sal_Int16 nOldResolution ;
640     sal_Int16 nNewResolution ;
641     nNewResolution = nOldResolution = 0;
642     nOldResolution = impl_GetReducedBitmapResolution();
643     nNewResolution = nOldResolution + 1;
644     aPrintOpt.SetReducedBitmapResolution(nNewResolution);
645     nNewResolution = impl_GetReducedBitmapResolution();
646     //if (nNewResolution != nOldResolution)  // test the old source
647     if (nNewResolution == nOldResolution)// test the new source
648     {
649         throw css::uno::RuntimeException(
650             rtl::OUString::createFromAscii(
651             "null com.sun.star.configuration."
652             "the SetReducedBitmapResolution() error!"),
653             0);
654     }
655 
656     // test the GetReduceBitmapResolution()
657     nNewResolution = nOldResolution = 0;
658     nOldResolution = impl_GetReducedBitmapResolution();
659     nNewResolution = nOldResolution + 1;
660     impl_SetReducedBitmapResolution(nNewResolution);
661     nNewResolution = impl_GetReducedBitmapResolution();
662     //if (nNewResolution != nOldResolution)   // test the old source
663     if (nNewResolution == nOldResolution) // test the new source
664     {
665         throw css::uno::RuntimeException(
666             rtl::OUString::createFromAscii(
667             "null com.sun.star.configuration."
668             "the GetReduceBitmapResolution() error!"),
669             0);
670     }
671 
672     // test SetReducedBitmapIncludesTransparency()
673     bNewValue = bOldValue = sal_False;
674     bOldValue = impl_IsReducedBitmapIncludesTransparency();
675     bNewValue = !bOldValue;
676     aPrintOpt.SetReducedBitmapIncludesTransparency(bNewValue);
677     bNewValue = impl_IsReducedBitmapIncludesTransparency();
678     //if (bNewValue != bOldValue) // test the new source
679     if (bNewValue == bOldValue) // test the old source
680     {
681         throw css::uno::RuntimeException(
682             rtl::OUString::createFromAscii(
683             "null com.sun.star.configuration."
684             "the SetReducedBitmapIncludesTransparency() error!"),
685             0);
686     }
687 
688     // test the IsReducedBitmapIncludesTransparency()
689     bNewValue = bOldValue = sal_False;
690     bOldValue = impl_IsReducedBitmapIncludesTransparency();
691     bNewValue = !bOldValue;
692     impl_SetReducedBitmapIncludesTransparency(bNewValue);
693     bNewValue = aPrintOpt.IsReducedBitmapIncludesTransparency();
694     //if (bNewValue != bOldValue)   // test the old source
695     if (bNewValue == bOldValue) // test the new source
696     {
697         throw css::uno::RuntimeException(
698             rtl::OUString::createFromAscii(
699             "null com.sun.star.configuration."
700             "the IsReducedBitmapIncludesTransparency() error!"),
701             0);
702     }
703 
704     // test the SetConvertToGreyscales()
705     bNewValue = bOldValue = sal_False;
706     bOldValue = this->impl_IsConvertToGreyscales();
707     bNewValue = !bOldValue;
708     aPrintOpt.SetConvertToGreyscales(bNewValue);
709     bNewValue = this->impl_IsConvertToGreyscales();
710     //if (bNewValue != bOldValue) // test the old source
711     if (bNewValue == bOldValue) // test the new source
712     {
713         throw css::uno::RuntimeException(
714             rtl::OUString::createFromAscii(
715             "null com.sun.star.configuration."
716             "the SetConvertToGreyscales() error!"),
717             0);
718     }
719 
720     // test the IsConvertToGreyscales()
721     bNewValue = bOldValue = sal_False;
722     bOldValue = this->impl_IsConvertToGreyscales();
723     bNewValue = !bOldValue;
724     impl_SetConvertToGreyscales(bNewValue);
725     bNewValue = aPrintOpt.IsConvertToGreyscales();
726     //if (bNewValue != bOldValue) // test the old source
727     if (bNewValue == bOldValue) // test the new source
728     {
729         throw css::uno::RuntimeException(
730             rtl::OUString::createFromAscii(
731             "null com.sun.star.configuration."
732             "the IsConvertToGreyscales() error!"),
733             0);
734     }
735 }
736