Update ooo320-m1
[ooovba.git] / sw / source / ui / config / prtopt.cxx
blob6eed7fb1f882037ffec00061bf412bc34351a6c6
1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: prtopt.cxx,v $
10 * $Revision: 1.15 $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
31 // MARKER(update_precomp.py): autogen include statement, do not remove
32 #include "precompiled_sw.hxx"
35 #include <unotools/configmgr.hxx>
36 #include <prtopt.hxx>
37 #include <swprtopt.hxx>
38 #include <tools/debug.hxx>
39 #include <com/sun/star/uno/Any.hxx>
40 #include <com/sun/star/uno/Sequence.hxx>
42 #include <unomid.h>
44 using namespace utl;
45 using rtl::OUString;
46 using namespace com::sun::star::uno;
48 /*--------------------------------------------------------------------
49 Beschreibung: Ctor
50 --------------------------------------------------------------------*/
52 Sequence<OUString> SwPrintOptions::GetPropertyNames()
54 static const char* aPropNames[] =
56 "Content/Graphic", // 0
57 "Content/Table", // 1
58 "Content/Control", // 2
59 "Content/Background", // 3
60 "Content/PrintBlack", // 4
61 "Content/Note", // 5
62 "Page/Reversed", // 6
63 "Page/Brochure", // 7
64 "Page/BrochureRightToLeft", // 8
65 "Output/SinglePrintJob", // 9
66 "Output/Fax", // 10
67 "Papertray/FromPrinterSetup", // 11
68 "Content/Drawing", // 12 not in SW/Web
69 "Page/LeftPage", // 13 not in SW/Web
70 "Page/RightPage", // 14 not in SW/Web
71 "EmptyPages", // 15 not in SW/Web
72 "Content/PrintPlaceholders", // 16 not in Sw/Web
73 "Content/PrintHiddenText" // 17
75 const int nCount = bIsWeb ? 12 : 18;
76 Sequence<OUString> aNames(nCount);
77 OUString* pNames = aNames.getArray();
78 for(int i = 0; i < nCount; i++)
80 pNames[i] = OUString::createFromAscii(aPropNames[i]);
82 return aNames;
84 /* -----------------------------06.09.00 16:44--------------------------------
86 ---------------------------------------------------------------------------*/
87 SwPrintOptions::SwPrintOptions(sal_Bool bWeb) :
88 ConfigItem(bWeb ? C2U("Office.WriterWeb/Print") : C2U("Office.Writer/Print"),
89 CONFIG_MODE_DELAYED_UPDATE|CONFIG_MODE_RELEASE_TREE),
90 bIsWeb(bWeb)
92 bPrintPageBackground = !bWeb;
93 bPrintBlackFont = bWeb;
94 bPrintTextPlaceholder = bPrintHiddenText = sal_False;
96 Sequence<OUString> aNames = GetPropertyNames();
97 Sequence<Any> aValues = GetProperties(aNames);
98 const Any* pValues = aValues.getConstArray();
99 DBG_ASSERT(aValues.getLength() == aNames.getLength(), "GetProperties failed");
100 if(aValues.getLength() == aNames.getLength())
102 for(int nProp = 0; nProp < aNames.getLength(); nProp++)
104 if(pValues[nProp].hasValue())
106 switch(nProp)
108 case 0: bPrintGraphic = *(sal_Bool*)pValues[nProp].getValue(); break;
109 case 1: bPrintTable = *(sal_Bool*)pValues[nProp].getValue(); break;
110 case 2: bPrintControl = *(sal_Bool*)pValues[nProp].getValue() ; break;
111 case 3: bPrintPageBackground= *(sal_Bool*)pValues[nProp].getValue(); break;
112 case 4: bPrintBlackFont = *(sal_Bool*)pValues[nProp].getValue(); break;
113 case 5:
115 sal_Int32 nTmp = 0;
116 pValues[nProp] >>= nTmp;
117 nPrintPostIts = (sal_Int16)nTmp;
119 break;
120 case 6: bPrintReverse = *(sal_Bool*)pValues[nProp].getValue(); break;
121 case 7: bPrintProspect = *(sal_Bool*)pValues[nProp].getValue(); break;
122 case 8: bPrintProspect_RTL = *(sal_Bool*)pValues[nProp].getValue(); break;
123 case 9: bPrintSingleJobs = *(sal_Bool*)pValues[nProp].getValue(); break;
124 case 10: pValues[nProp] >>= sFaxName; break;
125 case 11: bPaperFromSetup = *(sal_Bool*)pValues[nProp].getValue(); break;
126 case 12: bPrintDraw = *(sal_Bool*)pValues[nProp].getValue() ; break;
127 case 13: bPrintLeftPage = *(sal_Bool*)pValues[nProp].getValue(); break;
128 case 14: bPrintRightPage = *(sal_Bool*)pValues[nProp].getValue(); break;
129 case 15: bPrintEmptyPages = *(sal_Bool*)pValues[nProp].getValue(); break;
130 case 16: bPrintTextPlaceholder = *(sal_Bool*)pValues[nProp].getValue(); break;
131 case 17: bPrintHiddenText = *(sal_Bool*)pValues[nProp].getValue(); break;
137 /* -----------------------------06.09.00 16:50--------------------------------
139 ---------------------------------------------------------------------------*/
140 SwPrintOptions::~SwPrintOptions()
143 /* -----------------------------06.09.00 16:43--------------------------------
145 ---------------------------------------------------------------------------*/
146 void SwPrintOptions::Commit()
148 Sequence<OUString> aNames = GetPropertyNames();
150 Sequence<Any> aValues(aNames.getLength());
151 Any* pValues = aValues.getArray();
153 const Type& rType = ::getBooleanCppuType();
154 BOOL bVal;
155 for(int nProp = 0; nProp < aNames.getLength(); nProp++)
157 switch(nProp)
159 case 0: bVal = bPrintGraphic; pValues[nProp].setValue(&bVal, rType);break;
160 case 1: bVal = bPrintTable ;pValues[nProp].setValue(&bVal, rType); break;
161 case 2: bVal = bPrintControl ; pValues[nProp].setValue(&bVal, rType); break;
162 case 3: bVal = bPrintPageBackground; pValues[nProp].setValue(&bVal, rType); break;
163 case 4: bVal = bPrintBlackFont ; pValues[nProp].setValue(&bVal, rType); break;
164 case 5: pValues[nProp] <<= (sal_Int32)nPrintPostIts ; break;
165 case 6: bVal = bPrintReverse ; pValues[nProp].setValue(&bVal, rType); break;
166 case 7: bVal = bPrintProspect ; pValues[nProp].setValue(&bVal, rType); break;
167 case 8: bVal = bPrintProspect_RTL ; pValues[nProp].setValue(&bVal, rType); break;
168 case 9: bVal = bPrintSingleJobs ; pValues[nProp].setValue(&bVal, rType); break;
169 case 10: pValues[nProp] <<= sFaxName; break;
170 case 11: bVal = bPaperFromSetup ; pValues[nProp].setValue(&bVal, rType); break;
171 case 12: bVal = bPrintDraw ; pValues[nProp].setValue(&bVal, rType); break;
172 case 13: bVal = bPrintLeftPage ; pValues[nProp].setValue(&bVal, rType); break;
173 case 14: bVal = bPrintRightPage ; pValues[nProp].setValue(&bVal, rType); break;
174 case 15: bVal = bPrintEmptyPages ; pValues[nProp].setValue(&bVal, rType); break;
175 case 16: bVal = bPrintTextPlaceholder; pValues[nProp].setValue(&bVal, rType); break;
176 case 17: bVal = bPrintHiddenText; pValues[nProp].setValue(&bVal, rType); break;
179 PutProperties(aNames, aValues);