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