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