LibreOffice Module sw (master)  1
prtopt.cxx
Go to the documentation of this file.
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 <o3tl/any.hxx>
23 #include <osl/diagnose.h>
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 // Ctor
33 {
34  static const char* aPropNames[] =
35  {
36  "Content/Graphic", // 0
37  "Content/Table", // 1
38  "Content/Control", // 2
39  "Content/Background", // 3
40  "Content/PrintBlack", // 4
41  "Content/Note", // 5
42  "Page/Reversed", // 6
43  "Page/Brochure", // 7
44  "Page/BrochureRightToLeft", // 8
45  "Output/SinglePrintJob", // 9
46  "Output/Fax", // 10
47  "Papertray/FromPrinterSetup", // 11
48  "Content/Drawing", // 12 not in SW/Web
49  "Page/LeftPage", // 13 not in SW/Web
50  "Page/RightPage", // 14 not in SW/Web
51  "EmptyPages", // 15 not in SW/Web
52  "Content/PrintPlaceholders", // 16 not in Sw/Web
53  "Content/PrintHiddenText" // 17 not in Sw/Web
54  };
55  const int nCount = bIsWeb ? 12 : 18;
56  Sequence<OUString> aNames(nCount);
57  OUString* pNames = aNames.getArray();
58  for(int i = 0; i < nCount; i++)
59  {
60  pNames[i] = OUString::createFromAscii(aPropNames[i]);
61  }
62  return aNames;
63 }
64 
66  ConfigItem(bWeb ? OUString("Office.WriterWeb/Print") : OUString("Office.Writer/Print"),
68  bIsWeb(bWeb)
69 {
70  m_bPrintPageBackground = !bWeb;
71  m_bPrintBlackFont = bWeb;
73  if (bWeb)
74  m_bPrintEmptyPages = false;
75 
77  Sequence<Any> aValues = GetProperties(aNames);
78  const Any* pValues = aValues.getConstArray();
79  OSL_ENSURE(aValues.getLength() == aNames.getLength(), "GetProperties failed");
80  if(aValues.getLength() == aNames.getLength())
81  {
82  for(int nProp = 0; nProp < aNames.getLength(); nProp++)
83  {
84  if(pValues[nProp].hasValue())
85  {
86  switch(nProp)
87  {
88  case 0: m_bPrintGraphic = *o3tl::doAccess<bool>(pValues[nProp]); break;
89  case 1: m_bPrintTable = *o3tl::doAccess<bool>(pValues[nProp]); break;
90  case 2: m_bPrintControl = *o3tl::doAccess<bool>(pValues[nProp]); break;
91  case 3: m_bPrintPageBackground= *o3tl::doAccess<bool>(pValues[nProp]); break;
92  case 4: m_bPrintBlackFont = *o3tl::doAccess<bool>(pValues[nProp]); break;
93  case 5:
94  {
95  sal_Int32 nTmp = 0;
96  pValues[nProp] >>= nTmp;
97  m_nPrintPostIts = static_cast<SwPostItMode>(nTmp);
98  }
99  break;
100  case 6: m_bPrintReverse = *o3tl::doAccess<bool>(pValues[nProp]); break;
101  case 7: m_bPrintProspect = *o3tl::doAccess<bool>(pValues[nProp]); break;
102  case 8: m_bPrintProspectRTL = *o3tl::doAccess<bool>(pValues[nProp]); break;
103  case 9: m_bPrintSingleJobs = *o3tl::doAccess<bool>(pValues[nProp]); break;
104  case 10: pValues[nProp] >>= m_sFaxName; break;
105  case 11: m_bPaperFromSetup = *o3tl::doAccess<bool>(pValues[nProp]); break;
106  case 12: m_bPrintDraw = *o3tl::doAccess<bool>(pValues[nProp]); break;
107  case 13: m_bPrintLeftPages = *o3tl::doAccess<bool>(pValues[nProp]); break;
108  case 14: m_bPrintRightPages = *o3tl::doAccess<bool>(pValues[nProp]); break;
109  case 15: m_bPrintEmptyPages = *o3tl::doAccess<bool>(pValues[nProp]); break;
110  case 16: m_bPrintTextPlaceholder = *o3tl::doAccess<bool>(pValues[nProp]); break;
111  case 17: m_bPrintHiddenText = *o3tl::doAccess<bool>(pValues[nProp]); break;
112  }
113  }
114  }
115  }
116 
117  // currently there is just one checkbox for print drawings and print graphics
118  // In the UI. (File/Print dialog and Tools/Options/.../Print)
119  // And since print graphics is the only available in Writer and WrtierWeb ...
120 
122 }
123 
125 {
126 }
127 
128 void SwPrintOptions::Notify( const css::uno::Sequence< OUString >& ) {}
129 
131 {
133 
134  Sequence<Any> aValues(aNames.getLength());
135  Any* pValues = aValues.getArray();
136 
137  for(int nProp = 0; nProp < aNames.getLength(); nProp++)
138  {
139  switch(nProp)
140  {
141  case 0: pValues[nProp] <<= m_bPrintGraphic; break;
142  case 1: pValues[nProp] <<= m_bPrintTable; break;
143  case 2: pValues[nProp] <<= m_bPrintControl; break;
144  case 3: pValues[nProp] <<= m_bPrintPageBackground; break;
145  case 4: pValues[nProp] <<= m_bPrintBlackFont; break;
146  case 5: pValues[nProp] <<= static_cast<sal_Int32>(m_nPrintPostIts) ; break;
147  case 6: pValues[nProp] <<= m_bPrintReverse; break;
148  case 7: pValues[nProp] <<= m_bPrintProspect; break;
149  case 8: pValues[nProp] <<= m_bPrintProspectRTL; break;
150  case 9: pValues[nProp] <<= m_bPrintSingleJobs; break;
151  case 10: pValues[nProp] <<= m_sFaxName; break;
152  case 11: pValues[nProp] <<= m_bPaperFromSetup; break;
153  case 12: pValues[nProp] <<= m_bPrintDraw; break;
154  case 13: pValues[nProp] <<= m_bPrintLeftPages; break;
155  case 14: pValues[nProp] <<= m_bPrintRightPages; break;
156  case 15: pValues[nProp] <<= m_bPrintEmptyPages; break;
157  case 16: pValues[nProp] <<= m_bPrintTextPlaceholder; break;
158  case 17: pValues[nProp] <<= m_bPrintHiddenText; break;
159  }
160  }
161 
162  // currently there is just one checkbox for print drawings and print graphics
163  // In the UI. (File/Print dialog and Tools/Options/.../Print)
164  // And since print graphics is the only available in Writer and WrtierWeb ...
166 
167  PutProperties(aNames, aValues);
168 }
169 
170 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
SwPrintOptions(bool bWeb)
Definition: prtopt.cxx:65
OUString m_sFaxName
Definition: printdata.hxx:69
ConfigItemMode
bool m_bPrintSingleJobs
Definition: printdata.hxx:58
css::uno::Sequence< OUString > GetPropertyNames()
Definition: prtopt.cxx:32
bool m_bPrintRightPages
Definition: printdata.hxx:58
bool m_bPrintReverse
Definition: printdata.hxx:58
bool m_bPrintProspectRTL
Definition: printdata.hxx:58
bool m_bPrintGraphic
Definition: printdata.hxx:58
bool m_bPrintProspect
Definition: printdata.hxx:58
virtual void Notify(const css::uno::Sequence< OUString > &aPropertyNames) override
Definition: prtopt.cxx:128
bool m_bPrintPageBackground
Definition: printdata.hxx:58
bool m_bPrintTextPlaceholder
Definition: printdata.hxx:58
virtual void ImplCommit() override
Definition: prtopt.cxx:130
bool m_bPrintLeftPages
Definition: printdata.hxx:58
bool PutProperties(const css::uno::Sequence< OUString > &rNames, const css::uno::Sequence< css::uno::Any > &rValues)
int i
bool m_bPrintDraw
Definition: printdata.hxx:58
bool m_bPrintTable
Definition: printdata.hxx:58
css::uno::Sequence< css::uno::Any > GetProperties(const css::uno::Sequence< OUString > &rNames)
bool m_bPrintControl
Definition: printdata.hxx:58
SwPostItMode
this must match the definitions in css::text::NotePrintMode
Definition: printdata.hxx:42
bool m_bPrintBlackFont
Definition: printdata.hxx:58
bool m_bPaperFromSetup
Definition: printdata.hxx:58
bool m_bPrintHiddenText
Definition: printdata.hxx:58
bool m_bPrintEmptyPages
Print empty pages.
Definition: printdata.hxx:58
virtual ~SwPrintOptions() override
Definition: prtopt.cxx:124
SwPostItMode m_nPrintPostIts
Definition: printdata.hxx:68