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 <miscuno.hxx>
26 #include <sc.hrc>
27 
28 using namespace utl;
29 using namespace com::sun::star::uno;
30 
31 
33 {
34  SetDefaults();
35 }
36 
38 {
39  bSkipEmpty = true;
40  bAllSheets = false;
41  bForceBreaks = false;
42 }
43 
44 bool ScPrintOptions::operator==( const ScPrintOptions& rOpt ) const
45 {
46  return bSkipEmpty == rOpt.bSkipEmpty
47  && bAllSheets == rOpt.bAllSheets
48  && bForceBreaks == rOpt.bForceBreaks;
49 }
50 
52  SfxPoolItem ( SID_SCPRINTOPTIONS ),
53  theOptions ( rOpt )
54 {
55 }
56 
58 {
59 }
60 
61 bool ScTpPrintItem::operator==( const SfxPoolItem& rItem ) const
62 {
63  assert(SfxPoolItem::operator==(rItem));
64 
65  const ScTpPrintItem& rPItem = static_cast<const ScTpPrintItem&>(rItem);
66  return ( theOptions == rPItem.theOptions );
67 }
68 
70 {
71  return new ScTpPrintItem( *this );
72 }
73 
74 #define CFGPATH_PRINT "Office.Calc/Print"
75 
76 #define SCPRINTOPT_EMPTYPAGES 0
77 #define SCPRINTOPT_ALLSHEETS 1
78 #define SCPRINTOPT_FORCEBREAKS 2
79 
81 {
82  return {"Page/EmptyPages", // SCPRINTOPT_EMPTYPAGES
83  "Other/AllSheets", // SCPRINTOPT_ALLSHEETS
84  "Page/ForceBreaks"}; // SCPRINTOPT_FORCEBREAKS;
85 }
86 
89 {
91  Sequence<Any> aValues = GetProperties(aNames);
92  const Any* pValues = aValues.getConstArray();
93  OSL_ENSURE(aValues.getLength() == aNames.getLength(), "GetProperties failed");
94  if(aValues.getLength() != aNames.getLength())
95  return;
96 
97  for(int nProp = 0; nProp < aNames.getLength(); nProp++)
98  {
99  OSL_ENSURE(pValues[nProp].hasValue(), "property value missing");
100  if(pValues[nProp].hasValue())
101  {
102  switch(nProp)
103  {
105  // reversed
106  SetSkipEmpty( !ScUnoHelpFunctions::GetBoolFromAny( pValues[nProp] ) );
107  break;
110  break;
113  break;
114  }
115  }
116  }
117 }
118 
120 {
122  Sequence<Any> aValues(aNames.getLength());
123  Any* pValues = aValues.getArray();
124 
125  for(int nProp = 0; nProp < aNames.getLength(); nProp++)
126  {
127  switch(nProp)
128  {
130  // reversed
131  pValues[nProp] <<= !GetSkipEmpty();
132  break;
134  pValues[nProp] <<= GetAllSheets();
135  break;
137  pValues[nProp] <<= GetForceBreaks();
138  break;
139  }
140  }
141  PutProperties(aNames, aValues);
142 }
143 
145 {
146  *static_cast<ScPrintOptions*>(this) = rNew;
147  SetModified();
148 }
149 
150 void ScPrintCfg::Notify( const css::uno::Sequence< OUString >& ) {}
151 
152 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
virtual void ImplCommit() override
Definition: printopt.cxx:119
static css::uno::Sequence< OUString > GetPropertyNames()
Definition: printopt.cxx:80
virtual ~ScTpPrintItem() override
Definition: printopt.cxx:57
virtual bool operator==(const SfxPoolItem &) const override
Definition: printopt.cxx:61
bool operator==(const ScPrintOptions &rOpt) const
Definition: printopt.cxx:44
void SetForceBreaks(bool bVal)
Definition: printopt.hxx:42
ScPrintOptions theOptions
Definition: printopt.hxx:68
const BorderLinePrimitive2D *pCandidateB assert(pCandidateA)
void SetDefaults()
Definition: printopt.cxx:37
bool GetForceBreaks() const
Definition: printopt.hxx:41
#define SCPRINTOPT_ALLSHEETS
Definition: printopt.cxx:77
bool PutProperties(const css::uno::Sequence< OUString > &rNames, const css::uno::Sequence< css::uno::Any > &rValues)
void SetAllSheets(bool bVal)
Definition: printopt.hxx:40
#define CFGPATH_PRINT
Definition: printopt.cxx:74
#define SCPRINTOPT_EMPTYPAGES
Definition: printopt.cxx:76
css::uno::Sequence< css::uno::Any > GetProperties(const css::uno::Sequence< OUString > &rNames)
virtual void Notify(const css::uno::Sequence< OUString > &aPropertyNames) override
Definition: printopt.cxx:150
const PropertyValue * pValues
#define SCPRINTOPT_FORCEBREAKS
Definition: printopt.cxx:78
bool GetAllSheets() const
Definition: printopt.hxx:39
virtual ScTpPrintItem * Clone(SfxItemPool *pPool=nullptr) const override
Definition: printopt.cxx:69
void SetSkipEmpty(bool bVal)
Definition: printopt.hxx:38
bool GetSkipEmpty() const
Definition: printopt.hxx:37
static bool GetBoolFromAny(const css::uno::Any &aAny)
Definition: miscuno.cxx:138
bool bForceBreaks
Definition: printopt.hxx:32
ScTpPrintItem(const ScPrintOptions &rOpt)
Definition: printopt.cxx:51
void SetOptions(const ScPrintOptions &rNew)
Definition: printopt.cxx:144