Kaydet (Commit) 7e4f8eb5 authored tarafından Eilidh McAdam's avatar Eilidh McAdam Kaydeden (comit) Eike Rathke

fdo#40788: Allow manual breaks in Calc to be forced

If the scale settings specify that the print ranges must be scaled
across a specific number of pages, the default behaviour is to ignore
breaks to avoid the case where breaks force more pages than specified.
Here, an option under Calc -> Print -> Pages is added so that the user
can specify that manual row and column breaks should be forced.

Change-Id: I445cd7ce9e16e4ec2d0c320f059edad62b40f22d
Reviewed-on: https://gerrit.libreoffice.org/6531Tested-by: 's avatarEike Rathke <erack@redhat.com>
Reviewed-by: 's avatarEike Rathke <erack@redhat.com>
üst a3709207
......@@ -1659,6 +1659,13 @@
</info>
<value>false</value>
</prop>
<prop oor:name="ForceBreaks" oor:type="xs:boolean" oor:nillable="false">
<info>
<desc>Specifies whether manual row and column breaks should be forced, regardless of sheet scale settings.</desc>
<label>Force manual breaks</label>
</info>
<value>false</value>
</prop>
</group>
<group oor:name="Other">
<info>
......
......@@ -29,6 +29,7 @@ class SC_DLLPUBLIC ScPrintOptions
private:
sal_Bool bSkipEmpty;
sal_Bool bAllSheets;
sal_Bool bForceBreaks;
public:
ScPrintOptions();
......@@ -39,6 +40,8 @@ public:
void SetSkipEmpty( sal_Bool bVal ) { bSkipEmpty = bVal; }
sal_Bool GetAllSheets() const { return bAllSheets; }
void SetAllSheets( sal_Bool bVal ) { bAllSheets = bVal; }
sal_Bool GetForceBreaks() const { return bForceBreaks; }
void SetForceBreaks( sal_Bool bVal ) { bForceBreaks = bVal; }
void SetDefaults();
......
......@@ -194,6 +194,7 @@ private:
bool bPrintEntireSheet:1;
bool bActiveScenario:1;
bool mbPageBreaksValid:1;
bool mbForceBreaks:1;
friend class ScDocument; // for FillInfo
friend class ScValueIterator;
......
......@@ -271,7 +271,8 @@ ScTable::ScTable( ScDocument* pDoc, SCTAB nNewTab, const OUString& rNewName,
bGlobalKeepQuery(false),
bPrintEntireSheet(true),
bActiveScenario(false),
mbPageBreaksValid(false)
mbPageBreaksValid(false),
mbForceBreaks(false)
{
if (bColInfo)
......
......@@ -38,11 +38,14 @@
#include "segmenttree.hxx"
#include "columniterator.hxx"
#include "globalnames.hxx"
#include "scmod.hxx"
#include "printopt.hxx"
#include <com/sun/star/sheet/TablePageBreakData.hpp>
#include <algorithm>
#include <limits>
#include <iostream>
using ::com::sun::star::uno::Sequence;
using ::com::sun::star::sheet::TablePageBreakData;
......@@ -66,7 +69,8 @@ void ScTable::UpdatePageBreaks( const ScRange* pUserArea )
if (!bPageSizeValid)
return;
if (mbPageBreaksValid)
// Always update breaks if force breaks option has changed
if (mbPageBreaksValid && mbForceBreaks == SC_MOD()->GetPrintOptions().GetForceBreaks())
return;
}
......@@ -120,24 +124,29 @@ void ScTable::UpdatePageBreaks( const ScRange* pUserArea )
}
// get bSkipColBreaks/bSkipRowBreaks flags:
// fdo#40788 - print range scale settings can cause manual breaks to be
// ignored (see below). This behaviour may now be set by the user.
mbForceBreaks = SC_MOD()->GetPrintOptions().GetForceBreaks();
bool bSkipColBreaks = false;
bool bSkipRowBreaks = false;
if ( pStyleSet->GetItemState( ATTR_PAGE_SCALETOPAGES, false, &pItem ) == SFX_ITEM_SET )
{
OSL_ENSURE( pItem->ISA(SfxUInt16Item), "invalid Item" );
bSkipColBreaks = bSkipRowBreaks = ( ((const SfxUInt16Item*)pItem)->GetValue() > 0 );
}
if ( !bSkipColBreaks && pStyleSet->GetItemState(ATTR_PAGE_SCALETO, false, &pItem) == SFX_ITEM_SET )
if (!mbForceBreaks)
{
// #i54993# when fitting to width or height, ignore only manual breaks in that direction
const ScPageScaleToItem* pScaleToItem = static_cast<const ScPageScaleToItem*>(pItem);
if ( pScaleToItem->GetWidth() > 0 )
bSkipColBreaks = true;
if ( pScaleToItem->GetHeight() > 0 )
bSkipRowBreaks = true;
if ( pStyleSet->GetItemState( ATTR_PAGE_SCALETOPAGES, false, &pItem ) == SFX_ITEM_SET )
{
OSL_ENSURE( pItem->ISA(SfxUInt16Item), "invalid Item" );
bSkipColBreaks = bSkipRowBreaks = ( ((const SfxUInt16Item*)pItem)->GetValue() > 0 );
}
if ( !bSkipColBreaks && pStyleSet->GetItemState(ATTR_PAGE_SCALETO, false, &pItem) == SFX_ITEM_SET )
{
// #i54993# when fitting to width or height, ignore only manual breaks in that direction
const ScPageScaleToItem* pScaleToItem = static_cast<const ScPageScaleToItem*>(pItem);
if ( pScaleToItem->GetWidth() > 0 )
bSkipColBreaks = true;
if ( pScaleToItem->GetHeight() > 0 )
bSkipRowBreaks = true;
}
}
//--------------------------------------------------------------------------
......
......@@ -35,7 +35,8 @@ ScPrintOptions::ScPrintOptions()
ScPrintOptions::ScPrintOptions( const ScPrintOptions& rCpy ) :
bSkipEmpty( rCpy.bSkipEmpty ),
bAllSheets( rCpy.bAllSheets )
bAllSheets( rCpy.bAllSheets ),
bForceBreaks( rCpy.bForceBreaks )
{
}
......@@ -47,19 +48,22 @@ void ScPrintOptions::SetDefaults()
{
bSkipEmpty = sal_True;
bAllSheets = false;
bForceBreaks = false;
}
const ScPrintOptions& ScPrintOptions::operator=( const ScPrintOptions& rCpy )
{
bSkipEmpty = rCpy.bSkipEmpty;
bAllSheets = rCpy.bAllSheets;
bForceBreaks = rCpy.bForceBreaks;
return *this;
}
bool ScPrintOptions::operator==( const ScPrintOptions& rOpt ) const
{
return bSkipEmpty == rOpt.bSkipEmpty
&& bAllSheets == rOpt.bAllSheets;
&& bAllSheets == rOpt.bAllSheets
&& bForceBreaks == rOpt.bForceBreaks;
}
bool ScPrintOptions::operator!=( const ScPrintOptions& rOpt ) const
......@@ -105,14 +109,16 @@ SfxPoolItem* ScTpPrintItem::Clone( SfxItemPool * ) const
#define SCPRINTOPT_EMPTYPAGES 0
#define SCPRINTOPT_ALLSHEETS 1
#define SCPRINTOPT_COUNT 2
#define SCPRINTOPT_FORCEBREAKS 2
#define SCPRINTOPT_COUNT 3
Sequence<OUString> ScPrintCfg::GetPropertyNames()
{
static const char* aPropNames[] =
{
"Page/EmptyPages", // SCPRINTOPT_EMPTYPAGES
"Other/AllSheets" // SCPRINTOPT_ALLSHEETS
"Other/AllSheets", // SCPRINTOPT_ALLSHEETS
"Page/ForceBreaks" // SCPRINTOPT_FORCEBREAKS
};
Sequence<OUString> aNames(SCPRINTOPT_COUNT);
OUString* pNames = aNames.getArray();
......@@ -145,6 +151,9 @@ ScPrintCfg::ScPrintCfg() :
case SCPRINTOPT_ALLSHEETS:
SetAllSheets( ScUnoHelpFunctions::GetBoolFromAny( pValues[nProp] ) );
break;
case SCPRINTOPT_FORCEBREAKS:
SetForceBreaks( ScUnoHelpFunctions::GetBoolFromAny( pValues[nProp] ) );
break;
}
}
}
......@@ -168,6 +177,9 @@ void ScPrintCfg::Commit()
case SCPRINTOPT_ALLSHEETS:
ScUnoHelpFunctions::SetBoolInAny( pValues[nProp], GetAllSheets() );
break;
case SCPRINTOPT_FORCEBREAKS:
ScUnoHelpFunctions::SetBoolInAny( pValues[nProp], GetForceBreaks() );
break;
}
}
PutProperties(aNames, aValues);
......
......@@ -29,6 +29,7 @@ class ScTpPrintOptions : public SfxTabPage
{
CheckBox* m_pSkipEmptyPagesCB;
CheckBox* m_pSelectedSheetsCB;
CheckBox* m_pForceBreaksCB;
ScTpPrintOptions( Window* pParent, const SfxItemSet& rCoreSet );
~ScTpPrintOptions();
......
......@@ -40,6 +40,7 @@ ScTpPrintOptions::ScTpPrintOptions( Window* pParent,
{
get( m_pSkipEmptyPagesCB , "suppressCB" );
get( m_pSelectedSheetsCB , "printCB" );
get( m_pForceBreaksCB, "forceBreaksCB" );
}
ScTpPrintOptions::~ScTpPrintOptions()
......@@ -87,6 +88,8 @@ void ScTpPrintOptions::Reset( const SfxItemSet& rCoreSet )
m_pSkipEmptyPagesCB->Check( aOptions.GetSkipEmpty() );
m_pSkipEmptyPagesCB->SaveValue();
m_pSelectedSheetsCB->SaveValue();
m_pForceBreaksCB->Check( aOptions.GetForceBreaks() );
m_pForceBreaksCB->SaveValue();
}
// -----------------------------------------------------------------------
......@@ -97,12 +100,14 @@ sal_Bool ScTpPrintOptions::FillItemSet( SfxItemSet& rCoreAttrs )
bool bSkipEmptyChanged = ( m_pSkipEmptyPagesCB->GetSavedValue() != m_pSkipEmptyPagesCB->IsChecked() );
bool bSelectedSheetsChanged = ( m_pSelectedSheetsCB->GetSavedValue() != m_pSelectedSheetsCB->IsChecked() );
bool bForceBreaksChanged = ( m_pForceBreaksCB->GetSavedValue() != m_pForceBreaksCB->IsChecked() );
if ( bSkipEmptyChanged || bSelectedSheetsChanged )
if ( bSkipEmptyChanged || bSelectedSheetsChanged || bForceBreaksChanged )
{
ScPrintOptions aOpt;
aOpt.SetSkipEmpty( m_pSkipEmptyPagesCB->IsChecked() );
aOpt.SetAllSheets( !m_pSelectedSheetsCB->IsChecked() );
aOpt.SetForceBreaks( m_pForceBreaksCB->IsChecked() );
rCoreAttrs.Put( ScTpPrintItem( SID_SCPRINTOPTIONS, aOpt ) );
if ( bSelectedSheetsChanged )
{
......
......@@ -41,6 +41,22 @@
<property name="position">0</property>
</packing>
</child>
<child>
<object class="GtkCheckButton" id="forceBreaksCB">
<property name="label" translatable="yes">_Always apply manual breaks</property>
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="receives_default">False</property>
<property name="use_underline">True</property>
<property name="xalign">0</property>
<property name="draw_indicator">True</property>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">0</property>
</packing>
</child>
</object>
</child>
</object>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment