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