summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEilidh McAdam <eilidh@lanedo.com>2013-11-02 20:35:44 +0000
committerEike Rathke <erack@redhat.com>2013-11-04 09:40:03 -0600
commit7e4f8eb5eff642c7fc8bfa665289d55a1c5b054b (patch)
treeecb84ba465c3721a5150a05af629f5c0a015ba3c
parenta37092075791ccbe6081e3e01990df6d9e6cdce6 (diff)
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/6531 Tested-by: Eike Rathke <erack@redhat.com> Reviewed-by: Eike Rathke <erack@redhat.com>
-rw-r--r--officecfg/registry/schema/org/openoffice/Office/Calc.xcs7
-rw-r--r--sc/inc/printopt.hxx3
-rw-r--r--sc/inc/table.hxx1
-rw-r--r--sc/source/core/data/table1.cxx3
-rw-r--r--sc/source/core/data/table5.cxx39
-rw-r--r--sc/source/core/tool/printopt.cxx20
-rw-r--r--sc/source/ui/inc/tpprint.hxx1
-rw-r--r--sc/source/ui/optdlg/tpprint.cxx7
-rw-r--r--sc/uiconfig/scalc/ui/optdlg.ui16
9 files changed, 76 insertions, 21 deletions
diff --git a/officecfg/registry/schema/org/openoffice/Office/Calc.xcs b/officecfg/registry/schema/org/openoffice/Office/Calc.xcs
index 4c583a43895a..0cdb9d51cd1e 100644
--- a/officecfg/registry/schema/org/openoffice/Office/Calc.xcs
+++ b/officecfg/registry/schema/org/openoffice/Office/Calc.xcs
@@ -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>
diff --git a/sc/inc/printopt.hxx b/sc/inc/printopt.hxx
index 7148c68da3f9..ff1fd674d2fa 100644
--- a/sc/inc/printopt.hxx
+++ b/sc/inc/printopt.hxx
@@ -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();
diff --git a/sc/inc/table.hxx b/sc/inc/table.hxx
index 394847f9ed72..126b0ae83dda 100644
--- a/sc/inc/table.hxx
+++ b/sc/inc/table.hxx
@@ -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;
diff --git a/sc/source/core/data/table1.cxx b/sc/source/core/data/table1.cxx
index ca8a07c0ede9..4eed3b05ab6c 100644
--- a/sc/source/core/data/table1.cxx
+++ b/sc/source/core/data/table1.cxx
@@ -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)
diff --git a/sc/source/core/data/table5.cxx b/sc/source/core/data/table5.cxx
index 0392b21befc9..8c8d6bf235ca 100644
--- a/sc/source/core/data/table5.cxx
+++ b/sc/source/core/data/table5.cxx
@@ -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;
+ }
}
//--------------------------------------------------------------------------
diff --git a/sc/source/core/tool/printopt.cxx b/sc/source/core/tool/printopt.cxx
index b56bf987ade7..be1da7e93e49 100644
--- a/sc/source/core/tool/printopt.cxx
+++ b/sc/source/core/tool/printopt.cxx
@@ -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);
diff --git a/sc/source/ui/inc/tpprint.hxx b/sc/source/ui/inc/tpprint.hxx
index 2b9eac7a2b73..60a0126fd987 100644
--- a/sc/source/ui/inc/tpprint.hxx
+++ b/sc/source/ui/inc/tpprint.hxx
@@ -29,6 +29,7 @@ class ScTpPrintOptions : public SfxTabPage
{
CheckBox* m_pSkipEmptyPagesCB;
CheckBox* m_pSelectedSheetsCB;
+ CheckBox* m_pForceBreaksCB;
ScTpPrintOptions( Window* pParent, const SfxItemSet& rCoreSet );
~ScTpPrintOptions();
diff --git a/sc/source/ui/optdlg/tpprint.cxx b/sc/source/ui/optdlg/tpprint.cxx
index cdfc5eb6759e..0c9564133210 100644
--- a/sc/source/ui/optdlg/tpprint.cxx
+++ b/sc/source/ui/optdlg/tpprint.cxx
@@ -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 )
{
diff --git a/sc/uiconfig/scalc/ui/optdlg.ui b/sc/uiconfig/scalc/ui/optdlg.ui
index 7426d3471466..50dc6f5d4417 100644
--- a/sc/uiconfig/scalc/ui/optdlg.ui
+++ b/sc/uiconfig/scalc/ui/optdlg.ui
@@ -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>