xref: /aoo42x/main/sw/source/ui/config/prtopt.cxx (revision cdf0e10c)
1*cdf0e10cSrcweir /*************************************************************************
2*cdf0e10cSrcweir  *
3*cdf0e10cSrcweir  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4*cdf0e10cSrcweir  *
5*cdf0e10cSrcweir  * Copyright 2000, 2010 Oracle and/or its affiliates.
6*cdf0e10cSrcweir  *
7*cdf0e10cSrcweir  * OpenOffice.org - a multi-platform office productivity suite
8*cdf0e10cSrcweir  *
9*cdf0e10cSrcweir  * This file is part of OpenOffice.org.
10*cdf0e10cSrcweir  *
11*cdf0e10cSrcweir  * OpenOffice.org is free software: you can redistribute it and/or modify
12*cdf0e10cSrcweir  * it under the terms of the GNU Lesser General Public License version 3
13*cdf0e10cSrcweir  * only, as published by the Free Software Foundation.
14*cdf0e10cSrcweir  *
15*cdf0e10cSrcweir  * OpenOffice.org is distributed in the hope that it will be useful,
16*cdf0e10cSrcweir  * but WITHOUT ANY WARRANTY; without even the implied warranty of
17*cdf0e10cSrcweir  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18*cdf0e10cSrcweir  * GNU Lesser General Public License version 3 for more details
19*cdf0e10cSrcweir  * (a copy is included in the LICENSE file that accompanied this code).
20*cdf0e10cSrcweir  *
21*cdf0e10cSrcweir  * You should have received a copy of the GNU Lesser General Public License
22*cdf0e10cSrcweir  * version 3 along with OpenOffice.org.  If not, see
23*cdf0e10cSrcweir  * <http://www.openoffice.org/license.html>
24*cdf0e10cSrcweir  * for a copy of the LGPLv3 License.
25*cdf0e10cSrcweir  *
26*cdf0e10cSrcweir  ************************************************************************/
27*cdf0e10cSrcweir 
28*cdf0e10cSrcweir // MARKER(update_precomp.py): autogen include statement, do not remove
29*cdf0e10cSrcweir #include "precompiled_sw.hxx"
30*cdf0e10cSrcweir 
31*cdf0e10cSrcweir #include <unotools/configmgr.hxx>
32*cdf0e10cSrcweir #include <prtopt.hxx>
33*cdf0e10cSrcweir #include <tools/debug.hxx>
34*cdf0e10cSrcweir #include <com/sun/star/uno/Any.hxx>
35*cdf0e10cSrcweir #include <com/sun/star/uno/Sequence.hxx>
36*cdf0e10cSrcweir 
37*cdf0e10cSrcweir #include <unomid.h>
38*cdf0e10cSrcweir 
39*cdf0e10cSrcweir 
40*cdf0e10cSrcweir using namespace utl;
41*cdf0e10cSrcweir using rtl::OUString;
42*cdf0e10cSrcweir using namespace com::sun::star::uno;
43*cdf0e10cSrcweir 
44*cdf0e10cSrcweir /*--------------------------------------------------------------------
45*cdf0e10cSrcweir 	 Beschreibung: Ctor
46*cdf0e10cSrcweir  --------------------------------------------------------------------*/
47*cdf0e10cSrcweir 
48*cdf0e10cSrcweir Sequence<OUString> SwPrintOptions::GetPropertyNames()
49*cdf0e10cSrcweir {
50*cdf0e10cSrcweir 	static const char* aPropNames[] =
51*cdf0e10cSrcweir 	{
52*cdf0e10cSrcweir 		"Content/Graphic",				//  0
53*cdf0e10cSrcweir 		"Content/Table",            	//  1
54*cdf0e10cSrcweir 		"Content/Control",          	//  2
55*cdf0e10cSrcweir 		"Content/Background",       	//  3
56*cdf0e10cSrcweir 		"Content/PrintBlack",       	//  4
57*cdf0e10cSrcweir 		"Content/Note",             	//  5
58*cdf0e10cSrcweir         "Page/Reversed",                //  6
59*cdf0e10cSrcweir         "Page/Brochure",                //  7
60*cdf0e10cSrcweir         "Page/BrochureRightToLeft",     //  8
61*cdf0e10cSrcweir         "Output/SinglePrintJob",        //  9
62*cdf0e10cSrcweir         "Output/Fax",                   // 10
63*cdf0e10cSrcweir         "Papertray/FromPrinterSetup",   // 11
64*cdf0e10cSrcweir         "Content/Drawing",              // 12 not in SW/Web
65*cdf0e10cSrcweir         "Page/LeftPage",                // 13 not in SW/Web
66*cdf0e10cSrcweir         "Page/RightPage",               // 14 not in SW/Web
67*cdf0e10cSrcweir         "EmptyPages",                   // 15 not in SW/Web
68*cdf0e10cSrcweir         "Content/PrintPlaceholders",    // 16 not in Sw/Web
69*cdf0e10cSrcweir         "Content/PrintHiddenText"       // 17 not in Sw/Web
70*cdf0e10cSrcweir 	};
71*cdf0e10cSrcweir     const int nCount = bIsWeb ? 12 : 18;
72*cdf0e10cSrcweir 	Sequence<OUString> aNames(nCount);
73*cdf0e10cSrcweir 	OUString* pNames = aNames.getArray();
74*cdf0e10cSrcweir 	for(int i = 0; i < nCount; i++)
75*cdf0e10cSrcweir 	{
76*cdf0e10cSrcweir 		pNames[i] = OUString::createFromAscii(aPropNames[i]);
77*cdf0e10cSrcweir 	}
78*cdf0e10cSrcweir 	return aNames;
79*cdf0e10cSrcweir }
80*cdf0e10cSrcweir /* -----------------------------06.09.00 16:44--------------------------------
81*cdf0e10cSrcweir 
82*cdf0e10cSrcweir  ---------------------------------------------------------------------------*/
83*cdf0e10cSrcweir SwPrintOptions::SwPrintOptions(sal_Bool bWeb) :
84*cdf0e10cSrcweir     ConfigItem(bWeb ? C2U("Office.WriterWeb/Print") :  C2U("Office.Writer/Print"),
85*cdf0e10cSrcweir         CONFIG_MODE_DELAYED_UPDATE|CONFIG_MODE_RELEASE_TREE),
86*cdf0e10cSrcweir 	bIsWeb(bWeb)
87*cdf0e10cSrcweir {
88*cdf0e10cSrcweir     bPrintPageBackground = !bWeb;
89*cdf0e10cSrcweir     bPrintBlackFont = bWeb;
90*cdf0e10cSrcweir     bPrintTextPlaceholder = bPrintHiddenText = sal_False;
91*cdf0e10cSrcweir     if (bWeb)
92*cdf0e10cSrcweir         bPrintEmptyPages = sal_False;
93*cdf0e10cSrcweir 
94*cdf0e10cSrcweir     Sequence<OUString> aNames = GetPropertyNames();
95*cdf0e10cSrcweir 	Sequence<Any> aValues = GetProperties(aNames);
96*cdf0e10cSrcweir 	const Any* pValues = aValues.getConstArray();
97*cdf0e10cSrcweir 	DBG_ASSERT(aValues.getLength() == aNames.getLength(), "GetProperties failed");
98*cdf0e10cSrcweir 	if(aValues.getLength() == aNames.getLength())
99*cdf0e10cSrcweir 	{
100*cdf0e10cSrcweir 		for(int nProp = 0; nProp < aNames.getLength(); nProp++)
101*cdf0e10cSrcweir 		{
102*cdf0e10cSrcweir 			if(pValues[nProp].hasValue())
103*cdf0e10cSrcweir 			{
104*cdf0e10cSrcweir 				switch(nProp)
105*cdf0e10cSrcweir 				{
106*cdf0e10cSrcweir 					case  0: bPrintGraphic 		= *(sal_Bool*)pValues[nProp].getValue(); break;
107*cdf0e10cSrcweir 					case  1: bPrintTable		 	= *(sal_Bool*)pValues[nProp].getValue();  break;
108*cdf0e10cSrcweir 					case  2: bPrintControl	  	= *(sal_Bool*)pValues[nProp].getValue()	;  break;
109*cdf0e10cSrcweir 					case  3: bPrintPageBackground= *(sal_Bool*)pValues[nProp].getValue();  break;
110*cdf0e10cSrcweir 					case  4: bPrintBlackFont	    = *(sal_Bool*)pValues[nProp].getValue();  break;
111*cdf0e10cSrcweir                     case  5:
112*cdf0e10cSrcweir                     {
113*cdf0e10cSrcweir                         sal_Int32 nTmp = 0;
114*cdf0e10cSrcweir                         pValues[nProp] >>=  nTmp;
115*cdf0e10cSrcweir                         nPrintPostIts = (sal_Int16)nTmp;
116*cdf0e10cSrcweir                     }
117*cdf0e10cSrcweir                     break;
118*cdf0e10cSrcweir                     case  6: bPrintReverse      = *(sal_Bool*)pValues[nProp].getValue();  break;
119*cdf0e10cSrcweir                     case  7: bPrintProspect      = *(sal_Bool*)pValues[nProp].getValue();  break;
120*cdf0e10cSrcweir                     case  8: bPrintProspectRTL  = *(sal_Bool*)pValues[nProp].getValue();  break;
121*cdf0e10cSrcweir                     case  9: bPrintSingleJobs   = *(sal_Bool*)pValues[nProp].getValue();  break;
122*cdf0e10cSrcweir                     case 10: pValues[nProp] >>= sFaxName;  break;
123*cdf0e10cSrcweir                     case 11: bPaperFromSetup    = *(sal_Bool*)pValues[nProp].getValue();  break;
124*cdf0e10cSrcweir                     case 12: bPrintDraw         = *(sal_Bool*)pValues[nProp].getValue() ;  break;
125*cdf0e10cSrcweir                     case 13: bPrintLeftPages    = *(sal_Bool*)pValues[nProp].getValue();  break;
126*cdf0e10cSrcweir                     case 14: bPrintRightPages       = *(sal_Bool*)pValues[nProp].getValue();  break;
127*cdf0e10cSrcweir                     case 15: bPrintEmptyPages       = *(sal_Bool*)pValues[nProp].getValue();  break;
128*cdf0e10cSrcweir                     case 16: bPrintTextPlaceholder = *(sal_Bool*)pValues[nProp].getValue();  break;
129*cdf0e10cSrcweir                     case 17: bPrintHiddenText = *(sal_Bool*)pValues[nProp].getValue();  break;
130*cdf0e10cSrcweir                 }
131*cdf0e10cSrcweir 			}
132*cdf0e10cSrcweir 		}
133*cdf0e10cSrcweir 	}
134*cdf0e10cSrcweir 
135*cdf0e10cSrcweir     // currently there is just one checkbox for print drawings and print graphics
136*cdf0e10cSrcweir     // In the UI. (File/Print dialog and Tools/Options/.../Print)
137*cdf0e10cSrcweir     // And since print graphics is the only available in Writer and WrtierWeb ...
138*cdf0e10cSrcweir 
139*cdf0e10cSrcweir     bPrintDraw = bPrintGraphic;
140*cdf0e10cSrcweir }
141*cdf0e10cSrcweir /* -----------------------------06.09.00 16:50--------------------------------
142*cdf0e10cSrcweir 
143*cdf0e10cSrcweir  ---------------------------------------------------------------------------*/
144*cdf0e10cSrcweir SwPrintOptions::~SwPrintOptions()
145*cdf0e10cSrcweir {
146*cdf0e10cSrcweir }
147*cdf0e10cSrcweir /* -----------------------------06.09.00 16:43--------------------------------
148*cdf0e10cSrcweir 
149*cdf0e10cSrcweir  ---------------------------------------------------------------------------*/
150*cdf0e10cSrcweir 
151*cdf0e10cSrcweir void SwPrintOptions::Notify( const ::com::sun::star::uno::Sequence< rtl::OUString >& ) {}
152*cdf0e10cSrcweir 
153*cdf0e10cSrcweir void	SwPrintOptions::Commit()
154*cdf0e10cSrcweir {
155*cdf0e10cSrcweir 	Sequence<OUString> aNames = GetPropertyNames();
156*cdf0e10cSrcweir 
157*cdf0e10cSrcweir 	Sequence<Any> aValues(aNames.getLength());
158*cdf0e10cSrcweir 	Any* pValues = aValues.getArray();
159*cdf0e10cSrcweir 
160*cdf0e10cSrcweir 	const Type& rType = ::getBooleanCppuType();
161*cdf0e10cSrcweir 	sal_Bool bVal;
162*cdf0e10cSrcweir 	for(int nProp = 0; nProp < aNames.getLength(); nProp++)
163*cdf0e10cSrcweir 	{
164*cdf0e10cSrcweir 		switch(nProp)
165*cdf0e10cSrcweir 		{
166*cdf0e10cSrcweir 			case  0: bVal = bPrintGraphic; pValues[nProp].setValue(&bVal, rType);break;
167*cdf0e10cSrcweir 			case  1: bVal = bPrintTable		    ;pValues[nProp].setValue(&bVal, rType);  break;
168*cdf0e10cSrcweir 			case  2: bVal = bPrintControl		 ; pValues[nProp].setValue(&bVal, rType);  break;
169*cdf0e10cSrcweir 			case  3: bVal = bPrintPageBackground; pValues[nProp].setValue(&bVal, rType);  break;
170*cdf0e10cSrcweir 			case  4: bVal = bPrintBlackFont	    ; pValues[nProp].setValue(&bVal, rType);  break;
171*cdf0e10cSrcweir             case  5: pValues[nProp] <<=  (sal_Int32)nPrintPostIts       ; break;
172*cdf0e10cSrcweir             case  6: bVal = bPrintReverse       ; pValues[nProp].setValue(&bVal, rType);  break;
173*cdf0e10cSrcweir             case  7: bVal = bPrintProspect      ; pValues[nProp].setValue(&bVal, rType);  break;
174*cdf0e10cSrcweir             case  8: bVal = bPrintProspectRTL      ; pValues[nProp].setValue(&bVal, rType);  break;
175*cdf0e10cSrcweir             case  9: bVal = bPrintSingleJobs     ; pValues[nProp].setValue(&bVal, rType);  break;
176*cdf0e10cSrcweir             case 10: pValues[nProp] <<= sFaxName;  break;
177*cdf0e10cSrcweir             case 11: bVal = bPaperFromSetup     ; pValues[nProp].setValue(&bVal, rType);  break;
178*cdf0e10cSrcweir             case 12: bVal = bPrintDraw           ; pValues[nProp].setValue(&bVal, rType);  break;
179*cdf0e10cSrcweir             case 13: bVal = bPrintLeftPages      ; pValues[nProp].setValue(&bVal, rType);  break;
180*cdf0e10cSrcweir             case 14: bVal = bPrintRightPages    ; pValues[nProp].setValue(&bVal, rType);  break;
181*cdf0e10cSrcweir             case 15: bVal = bPrintEmptyPages    ; pValues[nProp].setValue(&bVal, rType);  break;
182*cdf0e10cSrcweir             case 16: bVal = bPrintTextPlaceholder; pValues[nProp].setValue(&bVal, rType);  break;
183*cdf0e10cSrcweir             case 17: bVal = bPrintHiddenText; pValues[nProp].setValue(&bVal, rType);  break;
184*cdf0e10cSrcweir         }
185*cdf0e10cSrcweir 	}
186*cdf0e10cSrcweir 
187*cdf0e10cSrcweir     // currently there is just one checkbox for print drawings and print graphics
188*cdf0e10cSrcweir     // In the UI. (File/Print dialog and Tools/Options/.../Print)
189*cdf0e10cSrcweir     // And since print graphics is the only available in Writer and WrtierWeb ...
190*cdf0e10cSrcweir     bPrintDraw = bPrintGraphic;
191*cdf0e10cSrcweir 
192*cdf0e10cSrcweir     PutProperties(aNames, aValues);
193*cdf0e10cSrcweir }
194*cdf0e10cSrcweir 
195*cdf0e10cSrcweir 
196*cdf0e10cSrcweir 
197*cdf0e10cSrcweir 
198