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 @@ ...@@ -1659,6 +1659,13 @@
</info> </info>
<value>false</value> <value>false</value>
</prop> </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>
<group oor:name="Other"> <group oor:name="Other">
<info> <info>
......
...@@ -29,6 +29,7 @@ class SC_DLLPUBLIC ScPrintOptions ...@@ -29,6 +29,7 @@ class SC_DLLPUBLIC ScPrintOptions
private: private:
sal_Bool bSkipEmpty; sal_Bool bSkipEmpty;
sal_Bool bAllSheets; sal_Bool bAllSheets;
sal_Bool bForceBreaks;
public: public:
ScPrintOptions(); ScPrintOptions();
...@@ -39,6 +40,8 @@ public: ...@@ -39,6 +40,8 @@ public:
void SetSkipEmpty( sal_Bool bVal ) { bSkipEmpty = bVal; } void SetSkipEmpty( sal_Bool bVal ) { bSkipEmpty = bVal; }
sal_Bool GetAllSheets() const { return bAllSheets; } sal_Bool GetAllSheets() const { return bAllSheets; }
void SetAllSheets( sal_Bool bVal ) { bAllSheets = bVal; } void SetAllSheets( sal_Bool bVal ) { bAllSheets = bVal; }
sal_Bool GetForceBreaks() const { return bForceBreaks; }
void SetForceBreaks( sal_Bool bVal ) { bForceBreaks = bVal; }
void SetDefaults(); void SetDefaults();
......
...@@ -194,6 +194,7 @@ private: ...@@ -194,6 +194,7 @@ private:
bool bPrintEntireSheet:1; bool bPrintEntireSheet:1;
bool bActiveScenario:1; bool bActiveScenario:1;
bool mbPageBreaksValid:1; bool mbPageBreaksValid:1;
bool mbForceBreaks:1;
friend class ScDocument; // for FillInfo friend class ScDocument; // for FillInfo
friend class ScValueIterator; friend class ScValueIterator;
......
...@@ -271,7 +271,8 @@ ScTable::ScTable( ScDocument* pDoc, SCTAB nNewTab, const OUString& rNewName, ...@@ -271,7 +271,8 @@ ScTable::ScTable( ScDocument* pDoc, SCTAB nNewTab, const OUString& rNewName,
bGlobalKeepQuery(false), bGlobalKeepQuery(false),
bPrintEntireSheet(true), bPrintEntireSheet(true),
bActiveScenario(false), bActiveScenario(false),
mbPageBreaksValid(false) mbPageBreaksValid(false),
mbForceBreaks(false)
{ {
if (bColInfo) if (bColInfo)
......
...@@ -38,11 +38,14 @@ ...@@ -38,11 +38,14 @@
#include "segmenttree.hxx" #include "segmenttree.hxx"
#include "columniterator.hxx" #include "columniterator.hxx"
#include "globalnames.hxx" #include "globalnames.hxx"
#include "scmod.hxx"
#include "printopt.hxx"
#include <com/sun/star/sheet/TablePageBreakData.hpp> #include <com/sun/star/sheet/TablePageBreakData.hpp>
#include <algorithm> #include <algorithm>
#include <limits> #include <limits>
#include <iostream>
using ::com::sun::star::uno::Sequence; using ::com::sun::star::uno::Sequence;
using ::com::sun::star::sheet::TablePageBreakData; using ::com::sun::star::sheet::TablePageBreakData;
...@@ -66,7 +69,8 @@ void ScTable::UpdatePageBreaks( const ScRange* pUserArea ) ...@@ -66,7 +69,8 @@ void ScTable::UpdatePageBreaks( const ScRange* pUserArea )
if (!bPageSizeValid) if (!bPageSizeValid)
return; return;
if (mbPageBreaksValid) // Always update breaks if force breaks option has changed
if (mbPageBreaksValid && mbForceBreaks == SC_MOD()->GetPrintOptions().GetForceBreaks())
return; return;
} }
...@@ -120,24 +124,29 @@ void ScTable::UpdatePageBreaks( const ScRange* pUserArea ) ...@@ -120,24 +124,29 @@ void ScTable::UpdatePageBreaks( const ScRange* pUserArea )
} }
// get bSkipColBreaks/bSkipRowBreaks flags: // 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 bSkipColBreaks = false;
bool bSkipRowBreaks = false; bool bSkipRowBreaks = false;
if ( pStyleSet->GetItemState( ATTR_PAGE_SCALETOPAGES, false, &pItem ) == SFX_ITEM_SET ) if (!mbForceBreaks)
{
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 if ( pStyleSet->GetItemState( ATTR_PAGE_SCALETOPAGES, false, &pItem ) == SFX_ITEM_SET )
const ScPageScaleToItem* pScaleToItem = static_cast<const ScPageScaleToItem*>(pItem); {
if ( pScaleToItem->GetWidth() > 0 ) OSL_ENSURE( pItem->ISA(SfxUInt16Item), "invalid Item" );
bSkipColBreaks = true; bSkipColBreaks = bSkipRowBreaks = ( ((const SfxUInt16Item*)pItem)->GetValue() > 0 );
if ( pScaleToItem->GetHeight() > 0 ) }
bSkipRowBreaks = true;
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() ...@@ -35,7 +35,8 @@ ScPrintOptions::ScPrintOptions()
ScPrintOptions::ScPrintOptions( const ScPrintOptions& rCpy ) : ScPrintOptions::ScPrintOptions( const ScPrintOptions& rCpy ) :
bSkipEmpty( rCpy.bSkipEmpty ), bSkipEmpty( rCpy.bSkipEmpty ),
bAllSheets( rCpy.bAllSheets ) bAllSheets( rCpy.bAllSheets ),
bForceBreaks( rCpy.bForceBreaks )
{ {
} }
...@@ -47,19 +48,22 @@ void ScPrintOptions::SetDefaults() ...@@ -47,19 +48,22 @@ void ScPrintOptions::SetDefaults()
{ {
bSkipEmpty = sal_True; bSkipEmpty = sal_True;
bAllSheets = false; bAllSheets = false;
bForceBreaks = false;
} }
const ScPrintOptions& ScPrintOptions::operator=( const ScPrintOptions& rCpy ) const ScPrintOptions& ScPrintOptions::operator=( const ScPrintOptions& rCpy )
{ {
bSkipEmpty = rCpy.bSkipEmpty; bSkipEmpty = rCpy.bSkipEmpty;
bAllSheets = rCpy.bAllSheets; bAllSheets = rCpy.bAllSheets;
bForceBreaks = rCpy.bForceBreaks;
return *this; return *this;
} }
bool ScPrintOptions::operator==( const ScPrintOptions& rOpt ) const bool ScPrintOptions::operator==( const ScPrintOptions& rOpt ) const
{ {
return bSkipEmpty == rOpt.bSkipEmpty return bSkipEmpty == rOpt.bSkipEmpty
&& bAllSheets == rOpt.bAllSheets; && bAllSheets == rOpt.bAllSheets
&& bForceBreaks == rOpt.bForceBreaks;
} }
bool ScPrintOptions::operator!=( const ScPrintOptions& rOpt ) const bool ScPrintOptions::operator!=( const ScPrintOptions& rOpt ) const
...@@ -105,14 +109,16 @@ SfxPoolItem* ScTpPrintItem::Clone( SfxItemPool * ) const ...@@ -105,14 +109,16 @@ SfxPoolItem* ScTpPrintItem::Clone( SfxItemPool * ) const
#define SCPRINTOPT_EMPTYPAGES 0 #define SCPRINTOPT_EMPTYPAGES 0
#define SCPRINTOPT_ALLSHEETS 1 #define SCPRINTOPT_ALLSHEETS 1
#define SCPRINTOPT_COUNT 2 #define SCPRINTOPT_FORCEBREAKS 2
#define SCPRINTOPT_COUNT 3
Sequence<OUString> ScPrintCfg::GetPropertyNames() Sequence<OUString> ScPrintCfg::GetPropertyNames()
{ {
static const char* aPropNames[] = static const char* aPropNames[] =
{ {
"Page/EmptyPages", // SCPRINTOPT_EMPTYPAGES "Page/EmptyPages", // SCPRINTOPT_EMPTYPAGES
"Other/AllSheets" // SCPRINTOPT_ALLSHEETS "Other/AllSheets", // SCPRINTOPT_ALLSHEETS
"Page/ForceBreaks" // SCPRINTOPT_FORCEBREAKS
}; };
Sequence<OUString> aNames(SCPRINTOPT_COUNT); Sequence<OUString> aNames(SCPRINTOPT_COUNT);
OUString* pNames = aNames.getArray(); OUString* pNames = aNames.getArray();
...@@ -145,6 +151,9 @@ ScPrintCfg::ScPrintCfg() : ...@@ -145,6 +151,9 @@ ScPrintCfg::ScPrintCfg() :
case SCPRINTOPT_ALLSHEETS: case SCPRINTOPT_ALLSHEETS:
SetAllSheets( ScUnoHelpFunctions::GetBoolFromAny( pValues[nProp] ) ); SetAllSheets( ScUnoHelpFunctions::GetBoolFromAny( pValues[nProp] ) );
break; break;
case SCPRINTOPT_FORCEBREAKS:
SetForceBreaks( ScUnoHelpFunctions::GetBoolFromAny( pValues[nProp] ) );
break;
} }
} }
} }
...@@ -168,6 +177,9 @@ void ScPrintCfg::Commit() ...@@ -168,6 +177,9 @@ void ScPrintCfg::Commit()
case SCPRINTOPT_ALLSHEETS: case SCPRINTOPT_ALLSHEETS:
ScUnoHelpFunctions::SetBoolInAny( pValues[nProp], GetAllSheets() ); ScUnoHelpFunctions::SetBoolInAny( pValues[nProp], GetAllSheets() );
break; break;
case SCPRINTOPT_FORCEBREAKS:
ScUnoHelpFunctions::SetBoolInAny( pValues[nProp], GetForceBreaks() );
break;
} }
} }
PutProperties(aNames, aValues); PutProperties(aNames, aValues);
......
...@@ -29,6 +29,7 @@ class ScTpPrintOptions : public SfxTabPage ...@@ -29,6 +29,7 @@ class ScTpPrintOptions : public SfxTabPage
{ {
CheckBox* m_pSkipEmptyPagesCB; CheckBox* m_pSkipEmptyPagesCB;
CheckBox* m_pSelectedSheetsCB; CheckBox* m_pSelectedSheetsCB;
CheckBox* m_pForceBreaksCB;
ScTpPrintOptions( Window* pParent, const SfxItemSet& rCoreSet ); ScTpPrintOptions( Window* pParent, const SfxItemSet& rCoreSet );
~ScTpPrintOptions(); ~ScTpPrintOptions();
......
...@@ -40,6 +40,7 @@ ScTpPrintOptions::ScTpPrintOptions( Window* pParent, ...@@ -40,6 +40,7 @@ ScTpPrintOptions::ScTpPrintOptions( Window* pParent,
{ {
get( m_pSkipEmptyPagesCB , "suppressCB" ); get( m_pSkipEmptyPagesCB , "suppressCB" );
get( m_pSelectedSheetsCB , "printCB" ); get( m_pSelectedSheetsCB , "printCB" );
get( m_pForceBreaksCB, "forceBreaksCB" );
} }
ScTpPrintOptions::~ScTpPrintOptions() ScTpPrintOptions::~ScTpPrintOptions()
...@@ -87,6 +88,8 @@ void ScTpPrintOptions::Reset( const SfxItemSet& rCoreSet ) ...@@ -87,6 +88,8 @@ void ScTpPrintOptions::Reset( const SfxItemSet& rCoreSet )
m_pSkipEmptyPagesCB->Check( aOptions.GetSkipEmpty() ); m_pSkipEmptyPagesCB->Check( aOptions.GetSkipEmpty() );
m_pSkipEmptyPagesCB->SaveValue(); m_pSkipEmptyPagesCB->SaveValue();
m_pSelectedSheetsCB->SaveValue(); m_pSelectedSheetsCB->SaveValue();
m_pForceBreaksCB->Check( aOptions.GetForceBreaks() );
m_pForceBreaksCB->SaveValue();
} }
// ----------------------------------------------------------------------- // -----------------------------------------------------------------------
...@@ -97,12 +100,14 @@ sal_Bool ScTpPrintOptions::FillItemSet( SfxItemSet& rCoreAttrs ) ...@@ -97,12 +100,14 @@ sal_Bool ScTpPrintOptions::FillItemSet( SfxItemSet& rCoreAttrs )
bool bSkipEmptyChanged = ( m_pSkipEmptyPagesCB->GetSavedValue() != m_pSkipEmptyPagesCB->IsChecked() ); bool bSkipEmptyChanged = ( m_pSkipEmptyPagesCB->GetSavedValue() != m_pSkipEmptyPagesCB->IsChecked() );
bool bSelectedSheetsChanged = ( m_pSelectedSheetsCB->GetSavedValue() != m_pSelectedSheetsCB->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; ScPrintOptions aOpt;
aOpt.SetSkipEmpty( m_pSkipEmptyPagesCB->IsChecked() ); aOpt.SetSkipEmpty( m_pSkipEmptyPagesCB->IsChecked() );
aOpt.SetAllSheets( !m_pSelectedSheetsCB->IsChecked() ); aOpt.SetAllSheets( !m_pSelectedSheetsCB->IsChecked() );
aOpt.SetForceBreaks( m_pForceBreaksCB->IsChecked() );
rCoreAttrs.Put( ScTpPrintItem( SID_SCPRINTOPTIONS, aOpt ) ); rCoreAttrs.Put( ScTpPrintItem( SID_SCPRINTOPTIONS, aOpt ) );
if ( bSelectedSheetsChanged ) if ( bSelectedSheetsChanged )
{ {
......
...@@ -41,6 +41,22 @@ ...@@ -41,6 +41,22 @@
<property name="position">0</property> <property name="position">0</property>
</packing> </packing>
</child> </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> </object>
</child> </child>
</object> </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