tdf#130857 qt weld: Implement QtInstanceWidget::strip_mnemonic
[LibreOffice.git] / sc / source / core / tool / prnsave.cxx
blobabf49260017a402537da7bcfb02537c55fa829f3
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3 * This file is part of the LibreOffice project.
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/.
9 * This file incorporates work covered by the following license notice:
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 .
20 #include <prnsave.hxx>
21 #include <address.hxx>
23 #include <osl/diagnose.h>
24 #include <tools/json_writer.hxx>
26 // Data per table
28 ScPrintSaverTab::ScPrintSaverTab() :
29 mbEntireSheet(false)
33 ScPrintSaverTab::~ScPrintSaverTab()
37 void ScPrintSaverTab::SetAreas( ScRangeVec&& rRanges, bool bEntireSheet )
39 maPrintRanges = std::move(rRanges);
40 mbEntireSheet = bEntireSheet;
43 void ScPrintSaverTab::SetRepeat( std::optional<ScRange> oCol, std::optional<ScRange> oRow )
45 moRepeatCol = std::move(oCol);
46 moRepeatRow = std::move(oRow);
49 bool ScPrintSaverTab::operator==( const ScPrintSaverTab& rCmp ) const
51 return
52 (moRepeatCol == rCmp.moRepeatCol) &&
53 (moRepeatRow == rCmp.moRepeatRow) &&
54 (mbEntireSheet == rCmp.mbEntireSheet) &&
55 (maPrintRanges == rCmp.maPrintRanges);
58 // Data for the whole document
60 ScPrintRangeSaver::ScPrintRangeSaver( SCTAB nCount ) :
61 nTabCount( nCount )
63 if (nCount > 0)
64 pData.reset( new ScPrintSaverTab[nCount] );
67 ScPrintRangeSaver::~ScPrintRangeSaver()
71 ScPrintSaverTab& ScPrintRangeSaver::GetTabData(SCTAB nTab)
73 OSL_ENSURE(nTab<nTabCount,"ScPrintRangeSaver Tab too big");
74 return pData[nTab];
77 const ScPrintSaverTab& ScPrintRangeSaver::GetTabData(SCTAB nTab) const
79 OSL_ENSURE(nTab<nTabCount,"ScPrintRangeSaver Tab too big");
80 return pData[nTab];
83 void ScPrintRangeSaver::GetPrintRangesInfo(tools::JsonWriter& rPrintRanges) const
85 // Array for sheets in the document.
86 auto printRanges = rPrintRanges.startArray("printranges");
87 for (SCTAB nTab = 0; nTab < nTabCount; nTab++)
89 auto sheetNode = rPrintRanges.startStruct();
90 const ScPrintSaverTab& rPsTab = pData[nTab];
91 const std::vector<ScRange>& rRangeVec = rPsTab.GetPrintRanges();
93 rPrintRanges.put("sheet", static_cast<sal_Int32>(nTab));
95 // Array for ranges within each sheet.
96 auto sheetRanges = rPrintRanges.startArray("ranges");
97 OStringBuffer aRanges;
98 sal_Int32 nLast = rRangeVec.size() - 1;
99 for (sal_Int32 nIdx = 0; nIdx <= nLast; ++nIdx)
101 const ScRange& rRange = rRangeVec[nIdx];
102 aRanges.append("[ " +
103 OString::number(rRange.aStart.Col()) + ", " +
104 OString::number(rRange.aStart.Row()) + ", " +
105 OString::number(rRange.aEnd.Col()) + ", " +
106 OString::number(rRange.aEnd.Row()) +
107 (nLast == nIdx ? std::string_view("]") : std::string_view("], ")));
110 rPrintRanges.putRaw(aRanges);
114 bool ScPrintRangeSaver::operator==( const ScPrintRangeSaver& rCmp ) const
116 bool bEqual = ( nTabCount == rCmp.nTabCount );
117 if (bEqual)
118 for (SCTAB i=0; i<nTabCount; i++)
119 if (!(pData[i]==rCmp.pData[i]))
121 bEqual = false;
122 break;
124 return bEqual;
127 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */