LibreOffice Module sc (master) 1
printopt.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 <com/sun/star/uno/Any.hxx>
21#include <com/sun/star/uno/Sequence.hxx>
22#include <osl/diagnose.h>
23
24#include <printopt.hxx>
25#include <sc.hrc>
26
27using namespace utl;
28using namespace com::sun::star::uno;
29
30
32{
34}
35
37{
38 bSkipEmpty = true;
39 bAllSheets = false;
40 bForceBreaks = false;
41}
42
44{
45 return bSkipEmpty == rOpt.bSkipEmpty
46 && bAllSheets == rOpt.bAllSheets
47 && bForceBreaks == rOpt.bForceBreaks;
48}
49
51 SfxPoolItem ( SID_SCPRINTOPTIONS ),
52 theOptions ( rOpt )
53{
54}
55
57{
58}
59
60bool ScTpPrintItem::operator==( const SfxPoolItem& rItem ) const
61{
62 assert(SfxPoolItem::operator==(rItem));
63
64 const ScTpPrintItem& rPItem = static_cast<const ScTpPrintItem&>(rItem);
65 return ( theOptions == rPItem.theOptions );
66}
67
69{
70 return new ScTpPrintItem( *this );
71}
72
73constexpr OUStringLiteral CFGPATH_PRINT = u"Office.Calc/Print";
74
75#define SCPRINTOPT_EMPTYPAGES 0
76#define SCPRINTOPT_ALLSHEETS 1
77#define SCPRINTOPT_FORCEBREAKS 2
78
80{
81 return {"Page/EmptyPages", // SCPRINTOPT_EMPTYPAGES
82 "Other/AllSheets", // SCPRINTOPT_ALLSHEETS
83 "Page/ForceBreaks"}; // SCPRINTOPT_FORCEBREAKS;
84}
85
88{
90 EnableNotification(aNames);
91 ReadCfg();
92}
93
95{
96 const Sequence<OUString> aNames = GetPropertyNames();
97 const Sequence<Any> aValues = GetProperties(aNames);
98 OSL_ENSURE(aValues.getLength() == aNames.getLength(), "GetProperties failed");
99 if(aValues.getLength() != aNames.getLength())
100 return;
101
102 if (bool bVal; aValues[SCPRINTOPT_EMPTYPAGES] >>= bVal)
103 SetSkipEmpty(!bVal); // reversed
104 if (bool bVal; aValues[SCPRINTOPT_ALLSHEETS] >>= bVal)
105 SetAllSheets(bVal);
106 if (bool bVal; aValues[SCPRINTOPT_FORCEBREAKS] >>= bVal)
107 SetForceBreaks(bVal);
108}
109
111{
113 Sequence<Any> aValues(aNames.getLength());
114 Any* pValues = aValues.getArray();
115
116 pValues[SCPRINTOPT_EMPTYPAGES] <<= !GetSkipEmpty(); // reversed
119 PutProperties(aNames, aValues);
120}
121
123{
124 *static_cast<ScPrintOptions*>(this) = rNew;
125 SetModified();
126 Commit();
127}
128
129void ScPrintCfg::Notify( const css::uno::Sequence< OUString >& ) { ReadCfg(); }
130
131/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
const PropertyValue * pValues
void ReadCfg()
Definition: printopt.cxx:94
void SetOptions(const ScPrintOptions &rNew)
Definition: printopt.cxx:122
static css::uno::Sequence< OUString > GetPropertyNames()
Definition: printopt.cxx:79
virtual void Notify(const css::uno::Sequence< OUString > &aPropertyNames) override
Definition: printopt.cxx:129
virtual void ImplCommit() override
Definition: printopt.cxx:110
bool bForceBreaks
Definition: printopt.hxx:31
bool GetSkipEmpty() const
Definition: printopt.hxx:36
void SetDefaults()
Definition: printopt.cxx:36
bool operator==(const ScPrintOptions &rOpt) const
Definition: printopt.cxx:43
void SetSkipEmpty(bool bVal)
Definition: printopt.hxx:37
bool GetForceBreaks() const
Definition: printopt.hxx:40
void SetAllSheets(bool bVal)
Definition: printopt.hxx:39
void SetForceBreaks(bool bVal)
Definition: printopt.hxx:41
bool GetAllSheets() const
Definition: printopt.hxx:38
virtual ScTpPrintItem * Clone(SfxItemPool *pPool=nullptr) const override
Definition: printopt.cxx:68
ScTpPrintItem(const ScPrintOptions &rOpt)
Definition: printopt.cxx:50
virtual bool operator==(const SfxPoolItem &) const override
Definition: printopt.cxx:60
virtual ~ScTpPrintItem() override
Definition: printopt.cxx:56
ScPrintOptions theOptions
Definition: printopt.hxx:67
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)
bool EnableNotification(const css::uno::Sequence< OUString > &rNames, bool bEnableInternalNotification=false)
static css::uno::Sequence< css::uno::Any > GetProperties(css::uno::Reference< css::container::XHierarchicalNameAccess > const &xHierarchyAccess, const css::uno::Sequence< OUString > &rNames, bool bAllLocales)
float u
#define SCPRINTOPT_FORCEBREAKS
Definition: printopt.cxx:77
constexpr OUStringLiteral CFGPATH_PRINT
Definition: printopt.cxx:73
#define SCPRINTOPT_ALLSHEETS
Definition: printopt.cxx:76
#define SCPRINTOPT_EMPTYPAGES
Definition: printopt.cxx:75