xref: /aoo41x/main/sw/source/ui/config/prtopt.cxx (revision efeef26f)
1 /**************************************************************
2  *
3  * Licensed to the Apache Software Foundation (ASF) under one
4  * or more contributor license agreements.  See the NOTICE file
5  * distributed with this work for additional information
6  * regarding copyright ownership.  The ASF licenses this file
7  * to you under the Apache License, Version 2.0 (the
8  * "License"); you may not use this file except in compliance
9  * with the License.  You may obtain a copy of the License at
10  *
11  *   http://www.apache.org/licenses/LICENSE-2.0
12  *
13  * Unless required by applicable law or agreed to in writing,
14  * software distributed under the License is distributed on an
15  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16  * KIND, either express or implied.  See the License for the
17  * specific language governing permissions and limitations
18  * under the License.
19  *
20  *************************************************************/
21 
22 
23 
24 // MARKER(update_precomp.py): autogen include statement, do not remove
25 #include "precompiled_sw.hxx"
26 
27 #include <unotools/configmgr.hxx>
28 #include <prtopt.hxx>
29 #include <tools/debug.hxx>
30 #include <com/sun/star/uno/Any.hxx>
31 #include <com/sun/star/uno/Sequence.hxx>
32 
33 #include <unomid.h>
34 
35 
36 using namespace utl;
37 using rtl::OUString;
38 using namespace com::sun::star::uno;
39 
40 /*--------------------------------------------------------------------
41 	 Beschreibung: Ctor
42  --------------------------------------------------------------------*/
43 
GetPropertyNames()44 Sequence<OUString> SwPrintOptions::GetPropertyNames()
45 {
46 	static const char* aPropNames[] =
47 	{
48 		"Content/Graphic",				//  0
49 		"Content/Table",            	//  1
50 		"Content/Control",          	//  2
51 		"Content/Background",       	//  3
52 		"Content/PrintBlack",       	//  4
53 		"Content/Note",             	//  5
54         "Page/Reversed",                //  6
55         "Page/Brochure",                //  7
56         "Page/BrochureRightToLeft",     //  8
57         "Output/SinglePrintJob",        //  9
58         "Output/Fax",                   // 10
59         "Papertray/FromPrinterSetup",   // 11
60         "Content/Drawing",              // 12 not in SW/Web
61         "Page/LeftPage",                // 13 not in SW/Web
62         "Page/RightPage",               // 14 not in SW/Web
63         "EmptyPages",                   // 15 not in SW/Web
64         "Content/PrintPlaceholders",    // 16 not in Sw/Web
65         "Content/PrintHiddenText"       // 17 not in Sw/Web
66 	};
67     const int nCount = bIsWeb ? 12 : 18;
68 	Sequence<OUString> aNames(nCount);
69 	OUString* pNames = aNames.getArray();
70 	for(int i = 0; i < nCount; i++)
71 	{
72 		pNames[i] = OUString::createFromAscii(aPropNames[i]);
73 	}
74 	return aNames;
75 }
76 /* -----------------------------06.09.00 16:44--------------------------------
77 
78  ---------------------------------------------------------------------------*/
SwPrintOptions(sal_Bool bWeb)79 SwPrintOptions::SwPrintOptions(sal_Bool bWeb) :
80     ConfigItem(bWeb ? C2U("Office.WriterWeb/Print") :  C2U("Office.Writer/Print"),
81         CONFIG_MODE_DELAYED_UPDATE|CONFIG_MODE_RELEASE_TREE),
82 	bIsWeb(bWeb)
83 {
84     bPrintPageBackground = !bWeb;
85     bPrintBlackFont = bWeb;
86     bPrintTextPlaceholder = bPrintHiddenText = sal_False;
87     if (bWeb)
88         bPrintEmptyPages = sal_False;
89 
90     Sequence<OUString> aNames = GetPropertyNames();
91 	Sequence<Any> aValues = GetProperties(aNames);
92 	const Any* pValues = aValues.getConstArray();
93 	DBG_ASSERT(aValues.getLength() == aNames.getLength(), "GetProperties failed");
94 	if(aValues.getLength() == aNames.getLength())
95 	{
96 		for(int nProp = 0; nProp < aNames.getLength(); nProp++)
97 		{
98 			if(pValues[nProp].hasValue())
99 			{
100 				switch(nProp)
101 				{
102 					case  0: bPrintGraphic 		= *(sal_Bool*)pValues[nProp].getValue(); break;
103 					case  1: bPrintTable		 	= *(sal_Bool*)pValues[nProp].getValue();  break;
104 					case  2: bPrintControl	  	= *(sal_Bool*)pValues[nProp].getValue()	;  break;
105 					case  3: bPrintPageBackground= *(sal_Bool*)pValues[nProp].getValue();  break;
106 					case  4: bPrintBlackFont	    = *(sal_Bool*)pValues[nProp].getValue();  break;
107                     case  5:
108                     {
109                         sal_Int32 nTmp = 0;
110                         pValues[nProp] >>=  nTmp;
111                         nPrintPostIts = (sal_Int16)nTmp;
112                     }
113                     break;
114                     case  6: bPrintReverse      = *(sal_Bool*)pValues[nProp].getValue();  break;
115                     case  7: bPrintProspect      = *(sal_Bool*)pValues[nProp].getValue();  break;
116                     case  8: bPrintProspectRTL  = *(sal_Bool*)pValues[nProp].getValue();  break;
117                     case  9: bPrintSingleJobs   = *(sal_Bool*)pValues[nProp].getValue();  break;
118                     case 10: pValues[nProp] >>= sFaxName;  break;
119                     case 11: bPaperFromSetup    = *(sal_Bool*)pValues[nProp].getValue();  break;
120                     case 12: bPrintDraw         = *(sal_Bool*)pValues[nProp].getValue() ;  break;
121                     case 13: bPrintLeftPages    = *(sal_Bool*)pValues[nProp].getValue();  break;
122                     case 14: bPrintRightPages       = *(sal_Bool*)pValues[nProp].getValue();  break;
123                     case 15: bPrintEmptyPages       = *(sal_Bool*)pValues[nProp].getValue();  break;
124                     case 16: bPrintTextPlaceholder = *(sal_Bool*)pValues[nProp].getValue();  break;
125                     case 17: bPrintHiddenText = *(sal_Bool*)pValues[nProp].getValue();  break;
126                 }
127 			}
128 		}
129 	}
130 
131     // currently there is just one checkbox for print drawings and print graphics
132     // In the UI. (File/Print dialog and Tools/Options/.../Print)
133     // And since print graphics is the only available in Writer and WrtierWeb ...
134 
135     bPrintDraw = bPrintGraphic;
136 }
137 /* -----------------------------06.09.00 16:50--------------------------------
138 
139  ---------------------------------------------------------------------------*/
~SwPrintOptions()140 SwPrintOptions::~SwPrintOptions()
141 {
142 }
143 /* -----------------------------06.09.00 16:43--------------------------------
144 
145  ---------------------------------------------------------------------------*/
146 
Notify(const::com::sun::star::uno::Sequence<rtl::OUString> &)147 void SwPrintOptions::Notify( const ::com::sun::star::uno::Sequence< rtl::OUString >& ) {}
148 
Commit()149 void	SwPrintOptions::Commit()
150 {
151 	Sequence<OUString> aNames = GetPropertyNames();
152 
153 	Sequence<Any> aValues(aNames.getLength());
154 	Any* pValues = aValues.getArray();
155 
156 	const Type& rType = ::getBooleanCppuType();
157 	sal_Bool bVal;
158 	for(int nProp = 0; nProp < aNames.getLength(); nProp++)
159 	{
160 		switch(nProp)
161 		{
162 			case  0: bVal = bPrintGraphic; pValues[nProp].setValue(&bVal, rType);break;
163 			case  1: bVal = bPrintTable		    ;pValues[nProp].setValue(&bVal, rType);  break;
164 			case  2: bVal = bPrintControl		 ; pValues[nProp].setValue(&bVal, rType);  break;
165 			case  3: bVal = bPrintPageBackground; pValues[nProp].setValue(&bVal, rType);  break;
166 			case  4: bVal = bPrintBlackFont	    ; pValues[nProp].setValue(&bVal, rType);  break;
167             case  5: pValues[nProp] <<=  (sal_Int32)nPrintPostIts       ; break;
168             case  6: bVal = bPrintReverse       ; pValues[nProp].setValue(&bVal, rType);  break;
169             case  7: bVal = bPrintProspect      ; pValues[nProp].setValue(&bVal, rType);  break;
170             case  8: bVal = bPrintProspectRTL      ; pValues[nProp].setValue(&bVal, rType);  break;
171             case  9: bVal = bPrintSingleJobs     ; pValues[nProp].setValue(&bVal, rType);  break;
172             case 10: pValues[nProp] <<= sFaxName;  break;
173             case 11: bVal = bPaperFromSetup     ; pValues[nProp].setValue(&bVal, rType);  break;
174             case 12: bVal = bPrintDraw           ; pValues[nProp].setValue(&bVal, rType);  break;
175             case 13: bVal = bPrintLeftPages      ; pValues[nProp].setValue(&bVal, rType);  break;
176             case 14: bVal = bPrintRightPages    ; pValues[nProp].setValue(&bVal, rType);  break;
177             case 15: bVal = bPrintEmptyPages    ; pValues[nProp].setValue(&bVal, rType);  break;
178             case 16: bVal = bPrintTextPlaceholder; pValues[nProp].setValue(&bVal, rType);  break;
179             case 17: bVal = bPrintHiddenText; pValues[nProp].setValue(&bVal, rType);  break;
180         }
181 	}
182 
183     // currently there is just one checkbox for print drawings and print graphics
184     // In the UI. (File/Print dialog and Tools/Options/.../Print)
185     // And since print graphics is the only available in Writer and WrtierWeb ...
186     bPrintDraw = bPrintGraphic;
187 
188     PutProperties(aNames, aValues);
189 }
190 
191 
192 
193 
194