Line data Source code
1 : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 : /*
3 : * This file is part of the LibreOffice project.
4 : *
5 : * This Source Code Form is subject to the terms of the Mozilla Public
6 : * License, v. 2.0. If a copy of the MPL was not distributed with this
7 : * file, You can obtain one at http://mozilla.org/MPL/2.0/.
8 : *
9 : * This file incorporates work covered by the following license notice:
10 : *
11 : * Licensed to the Apache Software Foundation (ASF) under one or more
12 : * contributor license agreements. See the NOTICE file distributed
13 : * with this work for additional information regarding copyright
14 : * ownership. The ASF licenses this file to you under the Apache
15 : * License, Version 2.0 (the "License"); you may not use this file
16 : * except in compliance with the License. You may obtain a copy of
17 : * the License at http://www.apache.org/licenses/LICENSE-2.0 .
18 : */
19 :
20 : #include <unotools/configmgr.hxx>
21 : #include <prtopt.hxx>
22 : #include <osl/diagnose.h>
23 : #include <com/sun/star/uno/Any.hxx>
24 : #include <com/sun/star/uno/Sequence.hxx>
25 :
26 : #include <unomid.h>
27 :
28 : using namespace utl;
29 : using namespace com::sun::star::uno;
30 :
31 : /*--------------------------------------------------------------------
32 : Description: Ctor
33 : --------------------------------------------------------------------*/
34 :
35 0 : Sequence<OUString> SwPrintOptions::GetPropertyNames()
36 : {
37 : static const char* aPropNames[] =
38 : {
39 : "Content/Graphic", // 0
40 : "Content/Table", // 1
41 : "Content/Control", // 2
42 : "Content/Background", // 3
43 : "Content/PrintBlack", // 4
44 : "Content/Note", // 5
45 : "Page/Reversed", // 6
46 : "Page/Brochure", // 7
47 : "Page/BrochureRightToLeft", // 8
48 : "Output/SinglePrintJob", // 9
49 : "Output/Fax", // 10
50 : "Papertray/FromPrinterSetup", // 11
51 : "Content/Drawing", // 12 not in SW/Web
52 : "Page/LeftPage", // 13 not in SW/Web
53 : "Page/RightPage", // 14 not in SW/Web
54 : "EmptyPages", // 15 not in SW/Web
55 : "Content/PrintPlaceholders", // 16 not in Sw/Web
56 : "Content/PrintHiddenText" // 17 not in Sw/Web
57 : };
58 0 : const int nCount = bIsWeb ? 12 : 18;
59 0 : Sequence<OUString> aNames(nCount);
60 0 : OUString* pNames = aNames.getArray();
61 0 : for(int i = 0; i < nCount; i++)
62 : {
63 0 : pNames[i] = OUString::createFromAscii(aPropNames[i]);
64 : }
65 0 : return aNames;
66 : }
67 :
68 0 : SwPrintOptions::SwPrintOptions(sal_Bool bWeb) :
69 : ConfigItem(bWeb ? OUString("Office.WriterWeb/Print") : OUString("Office.Writer/Print"),
70 : CONFIG_MODE_DELAYED_UPDATE|CONFIG_MODE_RELEASE_TREE),
71 0 : bIsWeb(bWeb)
72 : {
73 0 : bPrintPageBackground = !bWeb;
74 0 : bPrintBlackFont = bWeb;
75 0 : bPrintTextPlaceholder = bPrintHiddenText = sal_False;
76 0 : if (bWeb)
77 0 : bPrintEmptyPages = sal_False;
78 :
79 0 : Sequence<OUString> aNames = GetPropertyNames();
80 0 : Sequence<Any> aValues = GetProperties(aNames);
81 0 : const Any* pValues = aValues.getConstArray();
82 : OSL_ENSURE(aValues.getLength() == aNames.getLength(), "GetProperties failed");
83 0 : if(aValues.getLength() == aNames.getLength())
84 : {
85 0 : for(int nProp = 0; nProp < aNames.getLength(); nProp++)
86 : {
87 0 : if(pValues[nProp].hasValue())
88 : {
89 0 : switch(nProp)
90 : {
91 0 : case 0: bPrintGraphic = *(sal_Bool*)pValues[nProp].getValue(); break;
92 0 : case 1: bPrintTable = *(sal_Bool*)pValues[nProp].getValue(); break;
93 0 : case 2: bPrintControl = *(sal_Bool*)pValues[nProp].getValue() ; break;
94 0 : case 3: bPrintPageBackground= *(sal_Bool*)pValues[nProp].getValue(); break;
95 0 : case 4: bPrintBlackFont = *(sal_Bool*)pValues[nProp].getValue(); break;
96 : case 5:
97 : {
98 0 : sal_Int32 nTmp = 0;
99 0 : pValues[nProp] >>= nTmp;
100 0 : nPrintPostIts = (sal_Int16)nTmp;
101 : }
102 0 : break;
103 0 : case 6: bPrintReverse = *(sal_Bool*)pValues[nProp].getValue(); break;
104 0 : case 7: bPrintProspect = *(sal_Bool*)pValues[nProp].getValue(); break;
105 0 : case 8: bPrintProspectRTL = *(sal_Bool*)pValues[nProp].getValue(); break;
106 0 : case 9: bPrintSingleJobs = *(sal_Bool*)pValues[nProp].getValue(); break;
107 0 : case 10: pValues[nProp] >>= sFaxName; break;
108 0 : case 11: bPaperFromSetup = *(sal_Bool*)pValues[nProp].getValue(); break;
109 0 : case 12: bPrintDraw = *(sal_Bool*)pValues[nProp].getValue() ; break;
110 0 : case 13: bPrintLeftPages = *(sal_Bool*)pValues[nProp].getValue(); break;
111 0 : case 14: bPrintRightPages = *(sal_Bool*)pValues[nProp].getValue(); break;
112 0 : case 15: bPrintEmptyPages = *(sal_Bool*)pValues[nProp].getValue(); break;
113 0 : case 16: bPrintTextPlaceholder = *(sal_Bool*)pValues[nProp].getValue(); break;
114 0 : case 17: bPrintHiddenText = *(sal_Bool*)pValues[nProp].getValue(); break;
115 : }
116 : }
117 : }
118 : }
119 :
120 : // currently there is just one checkbox for print drawings and print graphics
121 : // In the UI. (File/Print dialog and Tools/Options/.../Print)
122 : // And since print graphics is the only available in Writer and WrtierWeb ...
123 :
124 0 : bPrintDraw = bPrintGraphic;
125 0 : }
126 :
127 0 : SwPrintOptions::~SwPrintOptions()
128 : {
129 0 : }
130 :
131 0 : void SwPrintOptions::Notify( const ::com::sun::star::uno::Sequence< OUString >& ) {}
132 :
133 0 : void SwPrintOptions::Commit()
134 : {
135 0 : Sequence<OUString> aNames = GetPropertyNames();
136 :
137 0 : Sequence<Any> aValues(aNames.getLength());
138 0 : Any* pValues = aValues.getArray();
139 :
140 0 : const Type& rType = ::getBooleanCppuType();
141 : sal_Bool bVal;
142 0 : for(int nProp = 0; nProp < aNames.getLength(); nProp++)
143 : {
144 0 : switch(nProp)
145 : {
146 0 : case 0: bVal = bPrintGraphic; pValues[nProp].setValue(&bVal, rType);break;
147 0 : case 1: bVal = bPrintTable ;pValues[nProp].setValue(&bVal, rType); break;
148 0 : case 2: bVal = bPrintControl ; pValues[nProp].setValue(&bVal, rType); break;
149 0 : case 3: bVal = bPrintPageBackground; pValues[nProp].setValue(&bVal, rType); break;
150 0 : case 4: bVal = bPrintBlackFont ; pValues[nProp].setValue(&bVal, rType); break;
151 0 : case 5: pValues[nProp] <<= (sal_Int32)nPrintPostIts ; break;
152 0 : case 6: bVal = bPrintReverse ; pValues[nProp].setValue(&bVal, rType); break;
153 0 : case 7: bVal = bPrintProspect ; pValues[nProp].setValue(&bVal, rType); break;
154 0 : case 8: bVal = bPrintProspectRTL ; pValues[nProp].setValue(&bVal, rType); break;
155 0 : case 9: bVal = bPrintSingleJobs ; pValues[nProp].setValue(&bVal, rType); break;
156 0 : case 10: pValues[nProp] <<= sFaxName; break;
157 0 : case 11: bVal = bPaperFromSetup ; pValues[nProp].setValue(&bVal, rType); break;
158 0 : case 12: bVal = bPrintDraw ; pValues[nProp].setValue(&bVal, rType); break;
159 0 : case 13: bVal = bPrintLeftPages ; pValues[nProp].setValue(&bVal, rType); break;
160 0 : case 14: bVal = bPrintRightPages ; pValues[nProp].setValue(&bVal, rType); break;
161 0 : case 15: bVal = bPrintEmptyPages ; pValues[nProp].setValue(&bVal, rType); break;
162 0 : case 16: bVal = bPrintTextPlaceholder; pValues[nProp].setValue(&bVal, rType); break;
163 0 : case 17: bVal = bPrintHiddenText; pValues[nProp].setValue(&bVal, rType); break;
164 : }
165 : }
166 :
167 : // currently there is just one checkbox for print drawings and print graphics
168 : // In the UI. (File/Print dialog and Tools/Options/.../Print)
169 : // And since print graphics is the only available in Writer and WrtierWeb ...
170 0 : bPrintDraw = bPrintGraphic;
171 :
172 0 : PutProperties(aNames, aValues);
173 0 : }
174 :
175 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|