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