summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKohei Yoshida <kohei.yoshida@suse.com>2011-11-28 22:57:23 -0500
committerKohei Yoshida <kohei.yoshida@suse.com>2011-11-29 00:04:23 -0500
commit380b7827d3ce74182195b4e02aeafaa026dc81f1 (patch)
tree43ec96de5f7337d87f3662d95fd54e6a8e2fcfa3
parent7a16f31752990abd1d0d4afc682259b67f24ea60 (diff)
fdo#32826: Finally return the real selected sheets, and use it.
This should solve the problem reported in fdo#32826, which is, when printing from print preview window always prints all sheets regardless of currently selected sheets.
-rw-r--r--sc/inc/markdata.hxx4
-rw-r--r--sc/source/core/data/markdata.cxx11
-rw-r--r--sc/source/ui/inc/preview.hxx1
-rw-r--r--sc/source/ui/unoobj/docuno.cxx35
-rw-r--r--sc/source/ui/unoobj/viewuno.cxx42
-rw-r--r--sc/source/ui/view/preview.cxx7
6 files changed, 67 insertions, 33 deletions
diff --git a/sc/inc/markdata.hxx b/sc/inc/markdata.hxx
index ef2671d82b51..b3c9528b781f 100644
--- a/sc/inc/markdata.hxx
+++ b/sc/inc/markdata.hxx
@@ -89,7 +89,9 @@ public:
SCTAB GetSelectCount() const;
SCTAB GetFirstSelected() const;
SCTAB GetLastSelected() const;
- void GetSelectedTabs(MarkedTabsType& rTabs) const;
+
+ const MarkedTabsType& GetSelectedTabs() const;
+ void SetSelectedTabs(const MarkedTabsType& rTabs);
void SetMarkNegative( bool bFlag ) { bMarkIsNeg = bFlag; }
bool IsMarkNegative() const { return bMarkIsNeg; }
diff --git a/sc/source/core/data/markdata.cxx b/sc/source/core/data/markdata.cxx
index 70df85a89151..eb2905520731 100644
--- a/sc/source/core/data/markdata.cxx
+++ b/sc/source/core/data/markdata.cxx
@@ -228,10 +228,15 @@ SCTAB ScMarkData::GetLastSelected() const
return 0;
}
-void ScMarkData::GetSelectedTabs(MarkedTabsType& rTabs) const
+const ScMarkData::MarkedTabsType& ScMarkData::GetSelectedTabs() const
{
- MarkedTabsType aTabs(maTabMarked.begin(), maTabMarked.end());
- rTabs.swap(aTabs);
+ return maTabMarked;
+}
+
+void ScMarkData::SetSelectedTabs(const MarkedTabsType& rTabs)
+{
+ MarkedTabsType aTabs(rTabs.begin(), rTabs.end());
+ maTabMarked.swap(aTabs);
}
void ScMarkData::MarkToMulti()
diff --git a/sc/source/ui/inc/preview.hxx b/sc/source/ui/inc/preview.hxx
index c3c1af53ab55..9313d7510d37 100644
--- a/sc/source/ui/inc/preview.hxx
+++ b/sc/source/ui/inc/preview.hxx
@@ -171,6 +171,7 @@ public:
FmFormView* GetDrawView() { return pDrawView; }
void SetSelectedTabs(const ScMarkData& rMark);
+ const ScMarkData::MarkedTabsType& GetSelectedTabs() const;
};
diff --git a/sc/source/ui/unoobj/docuno.cxx b/sc/source/ui/unoobj/docuno.cxx
index cb6b3f750b2f..b5de718c35ee 100644
--- a/sc/source/ui/unoobj/docuno.cxx
+++ b/sc/source/ui/unoobj/docuno.cxx
@@ -54,6 +54,7 @@
#include <com/sun/star/util/Date.hpp>
#include <com/sun/star/sheet/XNamedRanges.hpp>
#include <com/sun/star/sheet/XLabelRanges.hpp>
+#include <com/sun/star/sheet/XSelectedSheetsSupplier.hpp>
#include <com/sun/star/sheet/XUnnamedDatabaseRanges.hpp>
#include <com/sun/star/i18n/XForbiddenCharacters.hpp>
#include <com/sun/star/script/XLibraryContainer.hpp>
@@ -88,7 +89,6 @@
#include "rangeutl.hxx"
#include "markdata.hxx"
#include "docoptio.hxx"
-#include "scextopt.hxx"
#include "unonames.hxx"
#include "shapeuno.hxx"
#include "viewuno.hxx"
@@ -894,31 +894,14 @@ bool ScModelObj::FillRenderMarkData( const uno::Any& aSelection,
}
// restrict to selected sheets if a view is available
- if ( bSelectedSheetsOnly && xView.is() )
- {
- ScTabViewObj* pViewObj = ScTabViewObj::getImplementation( xView );
- if (pViewObj)
- {
- ScTabViewShell* pViewSh = pViewObj->GetViewShell();
- if (pViewSh)
- {
- // #i95280# when printing from the shell, the view is never activated,
- // so Excel view settings must also be evaluated here.
- ScExtDocOptions* pExtOpt = pDocShell->GetDocument()->GetExtDocOptions();
- if ( pExtOpt && pExtOpt->IsChanged() )
- {
- pViewSh->GetViewData()->ReadExtOptions(*pExtOpt); // Excel view settings
- pViewSh->SetTabNo( pViewSh->GetViewData()->GetTabNo(), true );
- pExtOpt->SetChanged( false );
- }
-
- const ScMarkData& rViewMark = pViewSh->GetViewData()->GetMarkData();
- SCTAB nTabCount = pDocShell->GetDocument()->GetTableCount();
- for (SCTAB nTab = 0; nTab < nTabCount; nTab++)
- if (!rViewMark.GetTableSelect(nTab))
- rMark.SelectTable( nTab, false );
- }
- }
+ uno::Reference<sheet::XSelectedSheetsSupplier> xSelectedSheets(xView, uno::UNO_QUERY);
+ if (bSelectedSheetsOnly && xSelectedSheets.is())
+ {
+ uno::Sequence<sal_Int32> aSelected = xSelectedSheets->getSelectedSheets();
+ ScMarkData::MarkedTabsType aSelectedTabs;
+ for (sal_Int32 i = 0, n = aSelected.getLength(); i < n; ++i)
+ aSelectedTabs.insert(static_cast<SCTAB>(aSelected[i]));
+ rMark.SetSelectedTabs(aSelectedTabs);
}
ScPrintOptions aNewOptions;
diff --git a/sc/source/ui/unoobj/viewuno.cxx b/sc/source/ui/unoobj/viewuno.cxx
index 16955534cc15..e0b0c1479994 100644
--- a/sc/source/ui/unoobj/viewuno.cxx
+++ b/sc/source/ui/unoobj/viewuno.cxx
@@ -73,6 +73,8 @@
#include "sheetevents.hxx"
#include "markdata.hxx"
#include "AccessibilityHints.hxx"
+#include "scextopt.hxx"
+#include "preview.hxx"
#include <svx/sdrhittesthelper.hxx>
using namespace com::sun::star;
@@ -2372,10 +2374,42 @@ void SAL_CALL ScTabViewObj::insertTransferable( const ::com::sun::star::uno::Ref
}
}
+namespace {
+
+uno::Sequence<sal_Int32> toSequence(const ScMarkData::MarkedTabsType& rSelected)
+{
+ uno::Sequence<sal_Int32> aRet(rSelected.size());
+ ScMarkData::MarkedTabsType::const_iterator itr = rSelected.begin(), itrEnd = rSelected.end();
+ for (size_t i = 0; itr != itrEnd; ++itr, ++i)
+ aRet[i] = static_cast<sal_Int32>(*itr);
+
+ return aRet;
+}
+
+}
+
uno::Sequence<sal_Int32> ScTabViewObj::getSelectedSheets()
throw (uno::RuntimeException)
{
- return uno::Sequence<sal_Int32>();
+ ScTabViewShell* pViewSh = GetViewShell();
+ if (!pViewSh)
+ return uno::Sequence<sal_Int32>();
+
+ ScViewData* pViewData = pViewSh->GetViewData();
+ if (!pViewData)
+ return uno::Sequence<sal_Int32>();
+
+ // #i95280# when printing from the shell, the view is never activated,
+ // so Excel view settings must also be evaluated here.
+ ScExtDocOptions* pExtOpt = pViewData->GetDocument()->GetExtDocOptions();
+ if (pExtOpt && pExtOpt->IsChanged())
+ {
+ pViewSh->GetViewData()->ReadExtOptions(*pExtOpt); // Excel view settings
+ pViewSh->SetTabNo(pViewSh->GetViewData()->GetTabNo(), true);
+ pExtOpt->SetChanged(false);
+ }
+
+ return toSequence(pViewData->GetMarkData().GetSelectedTabs());
}
ScPreviewObj::ScPreviewObj(ScPreviewShell* pViewSh) :
@@ -2419,7 +2453,11 @@ void ScPreviewObj::Notify(SfxBroadcaster&, const SfxHint& rHint)
uno::Sequence<sal_Int32> ScPreviewObj::getSelectedSheets()
throw (uno::RuntimeException)
{
- return uno::Sequence<sal_Int32>();
+ ScPreview* p = mpViewShell->GetPreview();
+ if (!p)
+ return uno::Sequence<sal_Int32>();
+
+ return toSequence(p->GetSelectedTabs());
}
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sc/source/ui/view/preview.cxx b/sc/source/ui/view/preview.cxx
index 41232d0a5fed..a72b8a8d1081 100644
--- a/sc/source/ui/view/preview.cxx
+++ b/sc/source/ui/view/preview.cxx
@@ -1548,7 +1548,12 @@ void ScPreview::DrawInvert( long nDragPos, sal_uInt16 nFlags )
void ScPreview::SetSelectedTabs(const ScMarkData& rMark)
{
- rMark.GetSelectedTabs(maSelectedTabs);
+ maSelectedTabs = rMark.GetSelectedTabs();
+}
+
+const ScMarkData::MarkedTabsType& ScPreview::GetSelectedTabs() const
+{
+ return maSelectedTabs;
}
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */