[Libreoffice-commits] .: 10 commits - offapi/com offapi/UnoApi_offapi.mk sc/inc sc/source

Kohei Yoshida kohei at kemper.freedesktop.org
Mon Nov 28 21:04:55 PST 2011


 offapi/UnoApi_offapi.mk                               |    1 
 offapi/com/sun/star/sheet/XSelectedSheetsSupplier.idl |   44 ++++++
 sc/inc/docuno.hxx                                     |    2 
 sc/inc/markdata.hxx                                   |    8 +
 sc/inc/viewuno.hxx                                    |   33 ++++
 sc/source/core/data/markdata.cxx                      |   19 ++
 sc/source/ui/inc/preview.hxx                          |   67 +++++-----
 sc/source/ui/inc/viewdata.hxx                         |    4 
 sc/source/ui/unoobj/docuno.cxx                        |   51 ++-----
 sc/source/ui/unoobj/viewuno.cxx                       |  120 +++++++++++++++---
 sc/source/ui/view/preview.cxx                         |  117 +++++++++--------
 sc/source/ui/view/prevwsh.cxx                         |    6 
 sc/source/ui/view/viewdata.cxx                        |    4 
 13 files changed, 325 insertions(+), 151 deletions(-)

New commits:
commit 6a4bb3e17c79d1ce8b2528a4b9c22456be911f32
Author: Kohei Yoshida <kohei.yoshida at suse.com>
Date:   Mon Nov 28 23:44:47 2011 -0500

    More meaningless comments removed.

diff --git a/sc/source/ui/view/preview.cxx b/sc/source/ui/view/preview.cxx
index 19fc66a..272be84 100644
--- a/sc/source/ui/view/preview.cxx
+++ b/sc/source/ui/view/preview.cxx
@@ -937,7 +937,6 @@ void ScPreview::DataChanged( const DataChangedEvent& rDCEvt )
     }
 }
 
-//Issue51656 Add resizeable margin on page preview from maoyg
 void ScPreview::MouseButtonDown( const MouseEvent& rMEvt )
 {
     Fraction  aPreviewZoom( nZoom, 100 );
@@ -1471,7 +1470,7 @@ void ScPreview::MouseMove( const MouseEvent& rMEvt )
         }
     }
 }
-//Issue51656 Add resizeable margin on page preview from maoyg
+
 void ScPreview::InvalidateLocationData(sal_uLong nId)
 {
     bLocationValid = false;
commit 4bbef9595f12dd5ac3c6f4558f4d466f84b8f5ad
Author: Kohei Yoshida <kohei.yoshida at suse.com>
Date:   Mon Nov 28 23:43:49 2011 -0500

    Arg to CalcPages() no longer used.

diff --git a/sc/source/ui/inc/preview.hxx b/sc/source/ui/inc/preview.hxx
index 26ef7b3..f698291 100644
--- a/sc/source/ui/inc/preview.hxx
+++ b/sc/source/ui/inc/preview.hxx
@@ -104,7 +104,7 @@ private:
     long            nFooterHeight;
 
     void    TestLastPage();
-    void    CalcPages( SCTAB nToWhichTab );
+    void    CalcPages();
     void    RecalcPages();
     void    UpdateDrawView();
     void    DoPrint( ScPreviewLocationData* pFillLocation );
@@ -154,15 +154,15 @@ public:
     sal_uInt16  GetZoom() const     { return nZoom; }
     Point   GetOffset() const   { return aOffset; }
 
-    SCTAB   GetTab()            { if (!bValid) { CalcPages(0); RecalcPages(); } return nTab; }
-    long    GetTotalPages()     { if (!bValid) { CalcPages(0); RecalcPages(); } return nTotalPages; }
+    SCTAB   GetTab()            { if (!bValid) { CalcPages(); RecalcPages(); } return nTab; }
+    long    GetTotalPages()     { if (!bValid) { CalcPages(); RecalcPages(); } return nTotalPages; }
 
     bool    AllTested() const   { return bValid && nTabsTested >= nTabCount; }
 
     sal_uInt16  GetOptimalZoom(bool bWidthOnly);
     long    GetFirstPage(SCTAB nTab);
 
-    void    CalcAll()           { CalcPages(MAXTAB); }
+    void    CalcAll()           { CalcPages(); }
     void    SetInGetState(bool bSet) { bInGetState = bSet; }
 
     DECL_STATIC_LINK( ScPreview, InvalidateHdl, void* );
diff --git a/sc/source/ui/view/preview.cxx b/sc/source/ui/view/preview.cxx
index fb72a8b..19fc66a 100644
--- a/sc/source/ui/view/preview.cxx
+++ b/sc/source/ui/view/preview.cxx
@@ -223,7 +223,7 @@ void ScPreview::TestLastPage()
 }
 
 
-void ScPreview::CalcPages( SCTAB /*nToWhichTab*/ )
+void ScPreview::CalcPages()
 {
     WaitObject( this );
 
@@ -314,7 +314,7 @@ void ScPreview::RecalcPages()                   // nur nPageNo geaendert
     bool bDone = false;
     while (nPageNo >= nTotalPages && nTabsTested < nTabCount)
     {
-        CalcPages( nTabsTested );
+        CalcPages();
         bDone = true;
     }
 
@@ -351,7 +351,7 @@ void ScPreview::DoPrint( ScPreviewLocationData* pFillLocation )
 {
     if (!bValid)
     {
-        CalcPages(0);
+        CalcPages();
         RecalcPages();
         UpdateDrawView();       // Tabelle evtl. geaendert
     }
@@ -674,7 +674,7 @@ String ScPreview::GetPosString()
 {
     if (!bValid)
     {
-        CalcPages(nTab);
+        CalcPages();
         UpdateDrawView();       // Tabelle evtl. geaendert
     }
 
@@ -742,7 +742,7 @@ long ScPreview::GetFirstPage(SCTAB nTabP)
     long nPage = 0;
     if (nTabP>0)
     {
-        CalcPages( nTabP );
+        CalcPages();
         UpdateDrawView();       // Tabelle evtl. geaendert
 
         for (SCTAB i=0; i<nTabP; i++)
commit 8ea81446029b314ae78e45fddb64903ea6ac5509
Author: Kohei Yoshida <kohei.yoshida at suse.com>
Date:   Mon Nov 28 23:41:09 2011 -0500

    sal_Bool cleanup in ScPreview.

diff --git a/sc/source/ui/inc/preview.hxx b/sc/source/ui/inc/preview.hxx
index 9313d75..26ef7b3 100644
--- a/sc/source/ui/inc/preview.hxx
+++ b/sc/source/ui/inc/preview.hxx
@@ -49,7 +49,6 @@ private:
     Point           aOffset;            // positiv
 
                                         // berechnet:
-    sal_Bool            bValid;             // folgende Werte gueltig
     SCTAB           nTabCount;
     SCTAB           nTabsTested;        // fuer wieviele Tabellen ist nPages gueltig?
     std::vector<long>       nPages;
@@ -62,8 +61,6 @@ private:
     Time            aTime;
     long            nTotalPages;
     Size            aPageSize;          // fuer GetOptimalZoom
-    sal_Bool            bStateValid;
-    sal_Bool            bLocationValid;
     ScPrintState    aState;
     ScPreviewLocationData* pLocationData;   // stores table layout for accessibility API
     FmFormView*     pDrawView;
@@ -71,27 +68,30 @@ private:
     SCTAB           nCurTab;
 
                                         // intern:
-    bool            bInPaint;
-    bool            bInSetZoom;
-    sal_Bool            bInGetState;
     ScDocShell*     pDocShell;
     ScPreviewShell* pViewShell;
 
-    sal_Bool            bLeftRulerMove;
-    sal_Bool            bRightRulerMove;
-    sal_Bool            bTopRulerMove;
-    sal_Bool            bBottomRulerMove;
-    sal_Bool            bHeaderRulerMove;
-    sal_Bool            bFooterRulerMove;
-
-    sal_Bool            bLeftRulerChange;
-    sal_Bool            bRightRulerChange;
-    sal_Bool            bTopRulerChange;
-    sal_Bool            bBottomRulerChange;
-    sal_Bool            bHeaderRulerChange;
-    sal_Bool            bFooterRulerChange;
-    sal_Bool            bPageMargin;
-    sal_Bool            bColRulerMove;
+    bool            bInGetState:1;
+    bool            bValid:1;             // folgende Werte gueltig
+    bool            bStateValid:1;
+    bool            bLocationValid:1;
+    bool            bInPaint:1;
+    bool            bInSetZoom:1;
+    bool            bLeftRulerMove:1;
+    bool            bRightRulerMove:1;
+    bool            bTopRulerMove:1;
+    bool            bBottomRulerMove:1;
+    bool            bHeaderRulerMove:1;
+    bool            bFooterRulerMove:1;
+    bool            bLeftRulerChange:1;
+    bool            bRightRulerChange:1;
+    bool            bTopRulerChange:1;
+    bool            bBottomRulerChange:1;
+    bool            bHeaderRulerChange:1;
+    bool            bFooterRulerChange:1;
+    bool            bPageMargin:1;
+    bool            bColRulerMove:1;
+
     ScRange         aPageArea;
     long            nRight[ MAXCOL+1 ];
     long            nLeftPosition;
@@ -132,7 +132,7 @@ public:
 
     virtual void DataChanged( const DataChangedEvent& rDCEvt );
 
-    void    DataChanged(sal_Bool bNewTime = false);             // statt Invalidate rufen
+    void    DataChanged(bool bNewTime = false);             // statt Invalidate rufen
     void    DoInvalidate();
 
     void    SetXOffset( long nX );
@@ -140,8 +140,8 @@ public:
     void    SetZoom(sal_uInt16 nNewZoom);
     void    SetPageNo( long nPage );
 
-    sal_Bool    GetPageMargins()const { return bPageMargin; }
-    void    SetPageMargins( sal_Bool bVal )  { bPageMargin = bVal; }
+    bool    GetPageMargins() const { return bPageMargin; }
+    void    SetPageMargins( bool bVal )  { bPageMargin = bVal; }
     void    DrawInvert( long nDragPos, sal_uInt16 nFlags );
     void    DragMove( long nDragMovePos, sal_uInt16 nFlags );
 
@@ -157,13 +157,13 @@ public:
     SCTAB   GetTab()            { if (!bValid) { CalcPages(0); RecalcPages(); } return nTab; }
     long    GetTotalPages()     { if (!bValid) { CalcPages(0); RecalcPages(); } return nTotalPages; }
 
-    sal_Bool    AllTested() const   { return bValid && nTabsTested >= nTabCount; }
+    bool    AllTested() const   { return bValid && nTabsTested >= nTabCount; }
 
-    sal_uInt16  GetOptimalZoom(sal_Bool bWidthOnly);
+    sal_uInt16  GetOptimalZoom(bool bWidthOnly);
     long    GetFirstPage(SCTAB nTab);
 
     void    CalcAll()           { CalcPages(MAXTAB); }
-    void    SetInGetState(sal_Bool bSet) { bInGetState = bSet; }
+    void    SetInGetState(bool bSet) { bInGetState = bSet; }
 
     DECL_STATIC_LINK( ScPreview, InvalidateHdl, void* );
     static void StaticInvalidate();
diff --git a/sc/source/ui/view/preview.cxx b/sc/source/ui/view/preview.cxx
index c1dfa74..fb72a8b 100644
--- a/sc/source/ui/view/preview.cxx
+++ b/sc/source/ui/view/preview.cxx
@@ -98,7 +98,6 @@ ScPreview::ScPreview( Window* pParent, ScDocShell* pDocSh, ScPreviewShell* pView
     Window( pParent ),
     nPageNo( 0 ),
     nZoom( 100 ),
-    bValid( false ),
     nTabsTested( 0 ),
     nPages(),
     nFirstAttr(),
@@ -106,16 +105,17 @@ ScPreview::ScPreview( Window* pParent, ScDocShell* pDocSh, ScPreviewShell* pView
     nTabStart( 0 ),
     nDisplayStart( 0 ),
     nTotalPages( 0 ),
-    bStateValid( false ),
-    bLocationValid( false ),
     pLocationData( NULL ),
     pDrawView( NULL ),
     nCurTab ( ScDocShell::GetCurTab() ),
-    bInPaint( false ),
-    bInSetZoom( false ),
-    bInGetState( false ),
     pDocShell( pDocSh ),
     pViewShell( pViewSh ),
+    bInGetState( false ),
+    bValid( false ),
+    bStateValid( false ),
+    bLocationValid( false ),
+    bInPaint( false ),
+    bInSetZoom( false ),
     bLeftRulerMove( false ),
     bRightRulerMove( false ),
     bTopRulerMove( false ),
@@ -175,8 +175,8 @@ void ScPreview::UpdateDrawView()        // nTab muss richtig sein
             pDrawView = new FmFormView( pModel, this );
             // die DrawView uebernimmt den Design-Modus vom Model
             // (Einstellung "Im Entwurfsmodus oeffnen"), darum hier zuruecksetzen
-            pDrawView->SetDesignMode( sal_True );
-            pDrawView->SetPrintPreview( sal_True );
+            pDrawView->SetDesignMode( true );
+            pDrawView->SetPrintPreview( true );
             pDrawView->ShowSdrPage(pPage);
         }
     }
@@ -298,8 +298,8 @@ void ScPreview::CalcPages( SCTAB /*nToWhichTab*/ )
 
     aState.nDocPages = nTotalPages;
 
-    bValid = sal_True;
-    bStateValid = sal_True;
+    bValid = true;
+    bStateValid = true;
     DoInvalidate();
 }
 
@@ -311,11 +311,11 @@ void ScPreview::RecalcPages()                   // nur nPageNo geaendert
 
     SCTAB nOldTab = nTab;
 
-    sal_Bool bDone = false;
+    bool bDone = false;
     while (nPageNo >= nTotalPages && nTabsTested < nTabCount)
     {
         CalcPages( nTabsTested );
-        bDone = sal_True;
+        bDone = true;
     }
 
     if (!bDone)
@@ -360,8 +360,8 @@ void ScPreview::DoPrint( ScPreviewLocationData* pFillLocation )
     Fraction aHorPrevZoom( (long)( 100 * nZoom / pDocShell->GetOutputFactor() ), 10000 );
     MapMode aMMMode( MAP_100TH_MM, Point(), aHorPrevZoom, aPreviewZoom );
 
-    sal_Bool bDoPrint = ( pFillLocation == NULL );
-    sal_Bool bValidPage = ( nPageNo < nTotalPages );
+    bool bDoPrint = ( pFillLocation == NULL );
+    bool bValidPage = ( nPageNo < nTotalPages );
 
     ScModule* pScMod = SC_MOD();
     const svtools::ColorConfig& rColorCfg = pScMod->GetColorConfig();
@@ -404,7 +404,7 @@ void ScPreview::DoPrint( ScPreviewLocationData* pFillLocation )
         pPrintFunc->SetOffset(aOffset);
         pPrintFunc->SetManualZoom(nZoom);
         pPrintFunc->SetDateTime(aDate,aTime);
-        pPrintFunc->SetClearFlag(sal_True);
+        pPrintFunc->SetClearFlag(true);
         pPrintFunc->SetUseStyleColor( pScMod->GetAccessOptions().GetIsForPagePreviews() );
 
         pPrintFunc->SetDrawView( pDrawView );
@@ -480,7 +480,7 @@ void ScPreview::DoPrint( ScPreviewLocationData* pFillLocation )
         {
             pPrintFunc->GetPrintState( aState );
             aState.nDocPages = nTotalPages;
-            bStateValid = sal_True;
+            bStateValid = true;
         }
         delete pPrintFunc;
     }
@@ -494,8 +494,8 @@ void ScPreview::DoPrint( ScPreviewLocationData* pFillLocation )
 
         Size aWinSize = GetOutputSize();
         Point aWinEnd( aWinSize.Width(), aWinSize.Height() );
-        sal_Bool bRight  = nPageEndX <= aWinEnd.X();
-        sal_Bool bBottom = nPageEndY <= aWinEnd.Y();
+        bool bRight  = nPageEndX <= aWinEnd.X();
+        bool bBottom = nPageEndY <= aWinEnd.Y();
 
         if( bPageMargin && bValidPage )
         {
@@ -599,7 +599,7 @@ void ScPreview::Command( const CommandEvent& rCEvt )
     sal_uInt16 nCmd = rCEvt.GetCommand();
     if ( nCmd == COMMAND_WHEEL || nCmd == COMMAND_STARTAUTOSCROLL || nCmd == COMMAND_AUTOSCROLL )
     {
-        sal_Bool bDone = pViewShell->ScrollCommand( rCEvt );
+        bool bDone = pViewShell->ScrollCommand( rCEvt );
         if (!bDone)
             Window::Command(rCEvt);
     }
@@ -617,7 +617,7 @@ void ScPreview::KeyInput( const KeyEvent& rKEvt )
 
     const KeyCode& rKeyCode = rKEvt.GetKeyCode();
     sal_uInt16 nKey = rKeyCode.GetCode();
-    sal_Bool bHandled = false;
+    bool bHandled = false;
     if(!rKeyCode.GetModifier())
     {
         sal_uInt16 nSlot = 0;
@@ -629,7 +629,7 @@ void ScPreview::KeyInput( const KeyEvent& rKEvt )
         }
         if(nSlot)
         {
-            bHandled = sal_True;
+            bHandled = true;
             pViewShell->GetViewFrame()->GetDispatcher()->Execute( nSlot, SFX_CALLMODE_ASYNCHRON );
         }
     }
@@ -650,13 +650,13 @@ const ScPreviewLocationData& ScPreview::GetLocationData()
     {
         pLocationData->Clear();
         DoPrint( pLocationData );
-        bLocationValid = sal_True;
+        bLocationValid = true;
     }
     return *pLocationData;
 }
 
 
-void ScPreview::DataChanged(sal_Bool bNewTime)
+void ScPreview::DataChanged(bool bNewTime)
 {
     if (bNewTime)
     {
@@ -776,7 +776,7 @@ Size lcl_GetDocPageSize( ScDocument* pDoc, SCTAB nTab )
 }
 
 
-sal_uInt16 ScPreview::GetOptimalZoom(sal_Bool bWidthOnly)
+sal_uInt16 ScPreview::GetOptimalZoom(bool bWidthOnly)
 {
     double nWinScaleX = ScGlobal::nScreenPPTX / pDocShell->GetOutputFactor();
     double nWinScaleY = ScGlobal::nScreenPPTY;
@@ -955,14 +955,14 @@ void ScPreview::MouseButtonDown( const MouseEvent& rMEvt )
         if( bLeftRulerChange )
         {
            DrawInvert( aButtonDownChangePoint.X(), POINTER_HSIZEBAR );
-           bLeftRulerMove = sal_True;
+           bLeftRulerMove = true;
            bRightRulerMove = false;
         }
         else if( bRightRulerChange )
         {
            DrawInvert( aButtonDownChangePoint.X(), POINTER_HSIZEBAR );
            bLeftRulerMove = false;
-           bRightRulerMove = sal_True;
+           bRightRulerMove = true;
         }
     }
 
@@ -972,26 +972,26 @@ void ScPreview::MouseButtonDown( const MouseEvent& rMEvt )
         if( bTopRulerChange )
         {
             DrawInvert( aButtonDownChangePoint.Y(), POINTER_VSIZEBAR );
-            bTopRulerMove = sal_True;
+            bTopRulerMove = true;
             bBottomRulerMove = false;
         }
         else if( bBottomRulerChange )
         {
             DrawInvert( aButtonDownChangePoint.Y(), POINTER_VSIZEBAR );
             bTopRulerMove = false;
-            bBottomRulerMove = sal_True;
+            bBottomRulerMove = true;
         }
         else if( bHeaderRulerChange )
         {
             DrawInvert( aButtonDownChangePoint.Y(), POINTER_VSIZEBAR );
-            bHeaderRulerMove = sal_True;
+            bHeaderRulerMove = true;
             bFooterRulerMove = false;
         }
         else if( bFooterRulerChange )
         {
             DrawInvert( aButtonDownChangePoint.Y(), POINTER_VSIZEBAR );
             bHeaderRulerMove = false;
-            bFooterRulerMove = sal_True;
+            bFooterRulerMove = true;
         }
     }
 
@@ -1017,7 +1017,7 @@ void ScPreview::MouseButtonDown( const MouseEvent& rMEvt )
             DrawInvert( PixelToLogic( Point( nRight[ nColNumberButttonDown-1 ], 0 ),aMMMode ).X() ,POINTER_HSPLIT );
 
         DrawInvert( aButtonDownChangePoint.X(), POINTER_HSPLIT );
-        bColRulerMove = sal_True;
+        bColRulerMove = true;
     }
 }
 
@@ -1036,11 +1036,11 @@ void ScPreview::MouseButtonUp( const MouseEvent& rMEvt )
         {
             SetPointer( Pointer( POINTER_ARROW ) );
 
-            sal_Bool bMoveRulerAction= sal_True;
+            bool bMoveRulerAction= true;
 
             ScDocument * pDoc = pDocShell->GetDocument();
             String   aOldName = pDoc->GetPageStyle( nTab );
-            sal_Bool  bUndo( pDoc->IsUndoEnabled() );
+            bool bUndo = pDoc->IsUndoEnabled();
             ScStyleSheetPool* pStylePool = pDoc->GetStyleSheetPool();
             SfxStyleSheetBase* pStyleSheet = pStylePool->Find( aOldName, SFX_STYLE_FAMILY_PAGE );
 
@@ -1120,7 +1120,7 @@ void ScPreview::MouseButtonUp( const MouseEvent& rMEvt )
         {
             SetPointer( POINTER_ARROW );
 
-            sal_Bool  bMoveRulerAction = sal_True;
+            bool bMoveRulerAction = true;
             if( ( bTopRulerChange || bBottomRulerChange || bHeaderRulerChange || bFooterRulerChange ) && ( aButtonUpPt.Y() <= ( 0 - aOffset.Y() ) || aButtonUpPt.Y() > nHeight * HMM_PER_TWIPS -aOffset.Y() ) )
             {
                 bMoveRulerAction = false;
@@ -1134,7 +1134,7 @@ void ScPreview::MouseButtonUp( const MouseEvent& rMEvt )
             if( bMoveRulerAction )
             {
                 ScDocument * pDoc = pDocShell->GetDocument();
-                sal_Bool  bUndo( pDoc->IsUndoEnabled() );
+                bool bUndo = pDoc->IsUndoEnabled();
                 ScStyleSheetPool* pStylePool = pDoc->GetStyleSheetPool();
                 SfxStyleSheetBase* pStyleSheet = pStylePool->Find( pDoc->GetPageStyle( nTab ), SFX_STYLE_FAMILY_PAGE );
                 OSL_ENSURE( pStyleSheet, "PageStyle not found" );
@@ -1225,8 +1225,8 @@ void ScPreview::MouseButtonUp( const MouseEvent& rMEvt )
         {
             SetPointer(POINTER_ARROW);
             ScDocument* pDoc = pDocShell->GetDocument();
-            sal_Bool  bLayoutRTL = pDoc->IsLayoutRTL( nTab );
-            sal_Bool  bMoveRulerAction = sal_True;
+            bool bLayoutRTL = pDoc->IsLayoutRTL( nTab );
+            bool bMoveRulerAction = true;
             if( aButtonDownPt.X() == aButtonUpPt.X() )
             {
                 bMoveRulerAction = false;
@@ -1328,7 +1328,7 @@ void ScPreview::MouseMove( const MouseEvent& rMEvt )
     Point   aHeaderLeft = LogicToPixel( Point(  -aOffset.X(), nHeaderHeight ), aMMMode );
     Point   aFooderLeft = LogicToPixel( Point( -aOffset.X(), nFooterHeight ), aMMMode );
 
-    sal_Bool   bOnColRulerChange = false;
+    bool bOnColRulerChange = false;
 
     for( SCCOL i=aPageArea.aStart.Col(); i<= aPageArea.aEnd.Col(); i++ )
     {
@@ -1338,7 +1338,7 @@ void ScPreview::MouseMove( const MouseEvent& rMEvt )
             && ( aPixPt.Y() > aColumnTop.Y() ) && ( aPixPt.Y() < aColumnBottom.Y() ) && !bLeftRulerMove && !bRightRulerMove
             && !bTopRulerMove && !bBottomRulerMove && !bHeaderRulerMove && !bFooterRulerMove )
         {
-            bOnColRulerChange = sal_True;
+            bOnColRulerChange = true;
             if( !rMEvt.GetButtons() && GetPointer() == POINTER_HSPLIT )
                 nColNumberButttonDown = i;
             break;
@@ -1347,17 +1347,17 @@ void ScPreview::MouseMove( const MouseEvent& rMEvt )
 
     if( aPixPt.X() < ( aLeftTop.X() + 2 ) && aPixPt.X() > ( aLeftTop.X() - 2 ) && !bRightRulerMove )
     {
-        bLeftRulerChange = sal_True;
+        bLeftRulerChange = true;
         bRightRulerChange = false;
     }
     else if( aPixPt.X() < ( aRightTop.X() + 2 ) && aPixPt.X() > ( aRightTop.X() - 2 ) && !bLeftRulerMove )
     {
         bLeftRulerChange = false;
-        bRightRulerChange = sal_True;
+        bRightRulerChange = true;
     }
     else if( aPixPt.Y() < ( aTopLeft.Y() + 2 ) && aPixPt.Y() > ( aTopLeft.Y() - 2 ) && !bBottomRulerMove && !bHeaderRulerMove && !bFooterRulerMove )
     {
-        bTopRulerChange = sal_True;
+        bTopRulerChange = true;
         bBottomRulerChange = false;
         bHeaderRulerChange = false;
         bFooterRulerChange = false;
@@ -1365,7 +1365,7 @@ void ScPreview::MouseMove( const MouseEvent& rMEvt )
     else if( aPixPt.Y() < ( aBottomLeft.Y() + 2 ) && aPixPt.Y() > ( aBottomLeft.Y() - 2 ) && !bTopRulerMove && !bHeaderRulerMove && !bFooterRulerMove )
     {
         bTopRulerChange = false;
-        bBottomRulerChange = sal_True;
+        bBottomRulerChange = true;
         bHeaderRulerChange = false;
         bFooterRulerChange = false;
     }
@@ -1373,7 +1373,7 @@ void ScPreview::MouseMove( const MouseEvent& rMEvt )
     {
         bTopRulerChange = false;
         bBottomRulerChange = false;
-        bHeaderRulerChange = sal_True;
+        bHeaderRulerChange = true;
         bFooterRulerChange = false;
     }
     else if( aPixPt.Y() < ( aFooderLeft.Y() + 2 ) && aPixPt.Y() > ( aFooderLeft.Y() - 2 ) && !bTopRulerMove && !bBottomRulerMove && !bHeaderRulerMove )
@@ -1381,7 +1381,7 @@ void ScPreview::MouseMove( const MouseEvent& rMEvt )
         bTopRulerChange = false;
         bBottomRulerChange = false;
         bHeaderRulerChange = false;
-        bFooterRulerChange = sal_True;
+        bFooterRulerChange = true;
     }
 
     if( bPageMargin )
commit 2761dd4894a22ff63e5da3a786d51fffb4977aa1
Author: Kohei Yoshida <kohei.yoshida at suse.com>
Date:   Mon Nov 28 23:28:19 2011 -0500

    Removed meaningless comments.

diff --git a/sc/source/ui/view/preview.cxx b/sc/source/ui/view/preview.cxx
index a72b8a8..c1dfa74 100644
--- a/sc/source/ui/view/preview.cxx
+++ b/sc/source/ui/view/preview.cxx
@@ -581,7 +581,6 @@ void ScPreview::DoPrint( ScPreviewLocationData* pFillLocation )
     }
 }
 
-//Issue51656 Add resizeable margin on page preview from maoyg
 void ScPreview::Paint( const Rectangle& /* rRect */ )
 {
     bool bWasInPaint = bInPaint;        // nested calls shouldn't be necessary, but allow for now
@@ -594,7 +593,6 @@ void ScPreview::Paint( const Rectangle& /* rRect */ )
 
     bInPaint = bWasInPaint;
 }
-//Issue51656 Add resizeable margin on page preview from maoyg
 
 void ScPreview::Command( const CommandEvent& rCEvt )
 {
@@ -1502,7 +1500,6 @@ com::sun::star::uno::Reference<com::sun::star::accessibility::XAccessible> ScPre
     return xAccessible;
 }
 
-//Issue51656 Add resizeable margin on page preview from maoyg
 void ScPreview::DragMove( long nDragMovePos, sal_uInt16 nFlags )
 {
     Fraction aPreviewZoom( nZoom, 100 );
commit 380b7827d3ce74182195b4e02aeafaa026dc81f1
Author: Kohei Yoshida <kohei.yoshida at suse.com>
Date:   Mon Nov 28 22:57:23 2011 -0500

    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.

diff --git a/sc/inc/markdata.hxx b/sc/inc/markdata.hxx
index ef2671d..b3c9528 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 70df85a..eb29055 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 c3c1af5..9313d75 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 cb6b3f7..b5de718 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 1695553..e0b0c14 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 41232d0..a72b8a8 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: */
commit 7a16f31752990abd1d0d4afc682259b67f24ea60
Author: Kohei Yoshida <kohei.yoshida at suse.com>
Date:   Mon Nov 28 22:15:03 2011 -0500

    New UNO API to return currently selected sheets.
    
    Both from the sheet view and preview modes.

diff --git a/offapi/UnoApi_offapi.mk b/offapi/UnoApi_offapi.mk
index 66e5944..5fe45e9 100644
--- a/offapi/UnoApi_offapi.mk
+++ b/offapi/UnoApi_offapi.mk
@@ -3428,6 +3428,7 @@ $(eval $(call gb_UnoApiTarget_add_idlfiles,offapi,offapi/com/sun/star/sheet,\
 	XScenarioEnhanced \
 	XScenarios \
 	XScenariosSupplier \
+	XSelectedSheetsSupplier \
 	XSheetAnnotation \
 	XSheetAnnotationAnchor \
 	XSheetAnnotationShapeSupplier \
diff --git a/offapi/com/sun/star/sheet/XSelectedSheetsSupplier.idl b/offapi/com/sun/star/sheet/XSelectedSheetsSupplier.idl
new file mode 100644
index 0000000..786dba3
--- /dev/null
+++ b/offapi/com/sun/star/sheet/XSelectedSheetsSupplier.idl
@@ -0,0 +1,44 @@
+/*
+ * Version: MPL 1.1 / GPLv3+ / LGPLv3+
+ *
+ * The contents of this file are subject to the Mozilla Public License Version
+ * 1.1 (the "License"); you may not use this file except in compliance with
+ * the License or as specified alternatively below. You may obtain a copy of
+ * the License at http://www.mozilla.org/MPL/
+ *
+ * Software distributed under the License is distributed on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
+ * for the specific language governing rights and limitations under the
+ * License.
+ *
+ * Major Contributor(s):
+ *   Copyright (C) 2011 Kohei Yoshida <kohei.yoshida at suse.com>
+ *
+ * All Rights Reserved.
+ *
+ * For minor contributions see the git repository.
+ *
+ * Alternatively, the contents of this file may be used under the terms of
+ * either the GNU General Public License Version 3 or later (the "GPLv3+"), or
+ * the GNU Lesser General Public License Version 3 or later (the "LGPLv3+"),
+ * in which case the provisions of the GPLv3+ or the LGPLv3+ are applicable
+ * instead of those above.
+ */
+
+#ifndef __com_sun_star_sheet_XSelectedSheetsSupplier_idl__
+#define __com_sun_star_sheet_XSelectedSheetsSupplier_idl__
+
+module com { module sun { module star { module sheet {
+
+interface XSelectedSheetsSupplier: com::sun::star::uno::XInterface
+{
+    /**
+       returns the indices of currently selected sheets.  Sheet indices are
+       0-based.
+     */
+    sequence<long> getSelectedSheets();
+};
+
+}; }; }; };
+
+#endif
diff --git a/sc/inc/viewuno.hxx b/sc/inc/viewuno.hxx
index 2c129f8..b062fd8 100644
--- a/sc/inc/viewuno.hxx
+++ b/sc/inc/viewuno.hxx
@@ -38,6 +38,7 @@
 #include <com/sun/star/sheet/XCellRangeReferrer.hpp>
 #include <com/sun/star/sheet/XViewSplitable.hpp>
 #include <com/sun/star/sheet/XViewFreezable.hpp>
+#include <com/sun/star/sheet/XSelectedSheetsSupplier.hpp>
 #include <com/sun/star/sheet/XSpreadsheetView.hpp>
 #include <com/sun/star/sheet/XEnhancedMouseClickBroadcaster.hpp>
 #include <com/sun/star/sheet/XActivationBroadcaster.hpp>
@@ -189,7 +190,8 @@ class ScTabViewObj : public ScViewPaneBase,
                      public com::sun::star::sheet::XViewFreezable,
                      public com::sun::star::sheet::XRangeSelection,
                      public com::sun::star::lang::XUnoTunnel,
-                     public com::sun::star::datatransfer::XTransferableSupplier
+                     public com::sun::star::datatransfer::XTransferableSupplier,
+                     public com::sun::star::sheet::XSelectedSheetsSupplier
 {
 private:
     SfxItemPropertySet                      aPropSet;
@@ -395,19 +397,36 @@ public:
     virtual ::com::sun::star::uno::Sequence< sal_Int8 > SAL_CALL getImplementationId()
                                 throw(::com::sun::star::uno::RuntimeException);
 
-    //XTransferableSupplier
+    // XTransferableSupplier
     virtual ::com::sun::star::uno::Reference< ::com::sun::star::datatransfer::XTransferable > SAL_CALL getTransferable(  ) throw (::com::sun::star::uno::RuntimeException);
     virtual void SAL_CALL insertTransferable( const ::com::sun::star::uno::Reference< ::com::sun::star::datatransfer::XTransferable >& xTrans ) throw (::com::sun::star::datatransfer::UnsupportedFlavorException, ::com::sun::star::uno::RuntimeException);
+
+    // XSelectedSheetsSupplier
+    virtual ::com::sun::star::uno::Sequence<sal_Int32> SAL_CALL getSelectedSheets()
+        throw(::com::sun::star::uno::RuntimeException);
 };
 
-class ScPreviewObj : public SfxBaseController, SfxListener
+class ScPreviewObj : public SfxBaseController,
+                     public SfxListener,
+                     public com::sun::star::sheet::XSelectedSheetsSupplier
 {
     ScPreviewShell* mpViewShell;
 public:
     ScPreviewObj(ScPreviewShell* pViewSh);
     virtual ~ScPreviewObj();
 
+    virtual ::com::sun::star::uno::Any SAL_CALL queryInterface(
+        const ::com::sun::star::uno::Type & rType)
+            throw(::com::sun::star::uno::RuntimeException);
+
+    virtual void SAL_CALL acquire() throw();
+    virtual void SAL_CALL release() throw();
+
     virtual void Notify(SfxBroadcaster&, const SfxHint& rHint);
+
+    // XSelectedSheetsSupplier
+    virtual ::com::sun::star::uno::Sequence<sal_Int32> SAL_CALL getSelectedSheets()
+        throw(::com::sun::star::uno::RuntimeException);
 };
 
 #endif
diff --git a/sc/source/ui/unoobj/viewuno.cxx b/sc/source/ui/unoobj/viewuno.cxx
index 598b35d..1695553 100644
--- a/sc/source/ui/unoobj/viewuno.cxx
+++ b/sc/source/ui/unoobj/viewuno.cxx
@@ -614,6 +614,7 @@ uno::Any SAL_CALL ScTabViewObj::queryInterface( const uno::Type& rType )
     SC_QUERYINTERFACE( sheet::XRangeSelection )
     SC_QUERYINTERFACE( lang::XUnoTunnel )
     SC_QUERYINTERFACE( datatransfer::XTransferableSupplier )
+    SC_QUERYINTERFACE( sheet::XSelectedSheetsSupplier )
 
     uno::Any aRet(ScViewPaneBase::queryInterface( rType ));
     if (!aRet.hasValue())
@@ -2371,6 +2372,12 @@ void SAL_CALL ScTabViewObj::insertTransferable( const ::com::sun::star::uno::Ref
     }
 }
 
+uno::Sequence<sal_Int32> ScTabViewObj::getSelectedSheets()
+    throw (uno::RuntimeException)
+{
+    return uno::Sequence<sal_Int32>();
+}
+
 ScPreviewObj::ScPreviewObj(ScPreviewShell* pViewSh) :
     SfxBaseController(pViewSh),
     mpViewShell(pViewSh)
@@ -2385,6 +2392,23 @@ ScPreviewObj::~ScPreviewObj()
         EndListening(*mpViewShell);
 }
 
+uno::Any ScPreviewObj::queryInterface(const uno::Type& rType)
+    throw(uno::RuntimeException)
+{
+    SC_QUERYINTERFACE(sheet::XSelectedSheetsSupplier)
+    return SfxBaseController::queryInterface(rType);
+}
+
+void ScPreviewObj::acquire() throw()
+{
+    SfxBaseController::acquire();
+}
+
+void ScPreviewObj::release() throw()
+{
+    SfxBaseController::release();
+}
+
 void ScPreviewObj::Notify(SfxBroadcaster&, const SfxHint& rHint)
 {
     const SfxSimpleHint* p = dynamic_cast<const SfxSimpleHint*>(&rHint);
@@ -2392,4 +2416,10 @@ void ScPreviewObj::Notify(SfxBroadcaster&, const SfxHint& rHint)
         mpViewShell = NULL;
 }
 
+uno::Sequence<sal_Int32> ScPreviewObj::getSelectedSheets()
+    throw (uno::RuntimeException)
+{
+    return uno::Sequence<sal_Int32>();
+}
+
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
commit ffca779f3765f730cc9f4f416b728ecdf762931c
Author: Kohei Yoshida <kohei.yoshida at suse.com>
Date:   Mon Nov 28 21:41:13 2011 -0500

    Create an UNO controller object for the preview shell.

diff --git a/sc/inc/viewuno.hxx b/sc/inc/viewuno.hxx
index 9b4e276..2c129f8 100644
--- a/sc/inc/viewuno.hxx
+++ b/sc/inc/viewuno.hxx
@@ -52,6 +52,7 @@
 #include "address.hxx"
 
 class ScTabViewShell;
+class ScPreviewShell;
 
 #define SC_VIEWPANE_ACTIVE  0xFFFF
 
@@ -399,6 +400,15 @@ public:
     virtual void SAL_CALL insertTransferable( const ::com::sun::star::uno::Reference< ::com::sun::star::datatransfer::XTransferable >& xTrans ) throw (::com::sun::star::datatransfer::UnsupportedFlavorException, ::com::sun::star::uno::RuntimeException);
 };
 
+class ScPreviewObj : public SfxBaseController, SfxListener
+{
+    ScPreviewShell* mpViewShell;
+public:
+    ScPreviewObj(ScPreviewShell* pViewSh);
+    virtual ~ScPreviewObj();
+
+    virtual void Notify(SfxBroadcaster&, const SfxHint& rHint);
+};
 
 #endif
 
diff --git a/sc/source/ui/unoobj/viewuno.cxx b/sc/source/ui/unoobj/viewuno.cxx
index cdcfa55..598b35d 100644
--- a/sc/source/ui/unoobj/viewuno.cxx
+++ b/sc/source/ui/unoobj/viewuno.cxx
@@ -60,6 +60,7 @@
 #include "cellsuno.hxx"
 #include "miscuno.hxx"
 #include "tabvwsh.hxx"
+#include "prevwsh.hxx"
 #include "docsh.hxx"
 #include "drwlayer.hxx"
 #include "drawview.hxx"
@@ -562,23 +563,24 @@ ScTabViewObj::ScTabViewObj( ScTabViewShell* pViewSh ) :
     nPreviousTab( 0 ),
     bDrawSelModeSet(false)
 {
-    if (pViewSh)
-    {
-        nPreviousTab = pViewSh->GetViewData()->GetTabNo();
+    if (!pViewSh)
+        return;
+
+    nPreviousTab = pViewSh->GetViewData()->GetTabNo();
     ScViewData* pViewData = pViewSh->GetViewData();
-    if( pViewData )
-    {
-            uno::Reference< script::vba::XVBAEventProcessor > xVbaEventsHelper (pViewData->GetDocument()->GetVbaEventProcessor(), uno::UNO_QUERY );
-            if ( xVbaEventsHelper.is() )
-            {
-                ScTabViewEventListener* pEventListener = new ScTabViewEventListener( this, xVbaEventsHelper );
-                uno::Reference< awt::XEnhancedMouseClickHandler > aMouseClickHandler( *pEventListener, uno::UNO_QUERY );
-                addEnhancedMouseClickHandler( aMouseClickHandler );
-                uno::Reference< view::XSelectionChangeListener > aSelectionChangeListener( *pEventListener, uno::UNO_QUERY );
-                addSelectionChangeListener( aSelectionChangeListener );
-            }
-    }
-    }
+    if (!pViewData)
+        return;
+
+    uno::Reference< script::vba::XVBAEventProcessor > xVbaEventsHelper(
+        pViewData->GetDocument()->GetVbaEventProcessor(), uno::UNO_QUERY );
+    if (!xVbaEventsHelper.is())
+        return;
+
+    ScTabViewEventListener* pEventListener = new ScTabViewEventListener( this, xVbaEventsHelper );
+    uno::Reference< awt::XEnhancedMouseClickHandler > aMouseClickHandler( *pEventListener, uno::UNO_QUERY );
+    addEnhancedMouseClickHandler( aMouseClickHandler );
+    uno::Reference< view::XSelectionChangeListener > aSelectionChangeListener( *pEventListener, uno::UNO_QUERY );
+    addSelectionChangeListener( aSelectionChangeListener );
 }
 
 ScTabViewObj::~ScTabViewObj()
@@ -2369,9 +2371,25 @@ void SAL_CALL ScTabViewObj::insertTransferable( const ::com::sun::star::uno::Ref
     }
 }
 
-//------------------------------------------------------------------------
-
+ScPreviewObj::ScPreviewObj(ScPreviewShell* pViewSh) :
+    SfxBaseController(pViewSh),
+    mpViewShell(pViewSh)
+{
+    if (mpViewShell)
+        StartListening(*mpViewShell);
+}
 
+ScPreviewObj::~ScPreviewObj()
+{
+    if (mpViewShell)
+        EndListening(*mpViewShell);
+}
 
+void ScPreviewObj::Notify(SfxBroadcaster&, const SfxHint& rHint)
+{
+    const SfxSimpleHint* p = dynamic_cast<const SfxSimpleHint*>(&rHint);
+    if (p && p->GetId() == SFX_HINT_DYING)
+        mpViewShell = NULL;
+}
 
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sc/source/ui/view/prevwsh.cxx b/sc/source/ui/view/prevwsh.cxx
index 5f90335..89fd968 100644
--- a/sc/source/ui/view/prevwsh.cxx
+++ b/sc/source/ui/view/prevwsh.cxx
@@ -67,6 +67,7 @@
 #include "ViewSettingsSequenceDefines.hxx"
 #include "tpprint.hxx"
 #include "printopt.hxx"
+#include "viewuno.hxx"
 #include <sax/tools/converter.hxx>
 #include <rtl/ustrbuf.hxx>
 
@@ -167,6 +168,8 @@ ScPreviewShell::ScPreviewShell( SfxViewFrame* pViewFrame,
         if ( pDrawView )
             nSourceDesignMode = pDrawView->IsDesignMode();
     }
+
+    new ScPreviewObj(this);
 }
 
 ScPreviewShell::~ScPreviewShell()
commit 654d9eb40c4232c180b5f88ed2774cb9c9bb18c1
Author: Kohei Yoshida <kohei.yoshida at suse.com>
Date:   Mon Nov 28 20:19:31 2011 -0500

    These methods can be const.

diff --git a/sc/source/ui/inc/viewdata.hxx b/sc/source/ui/inc/viewdata.hxx
index e812840..402cdab 100644
--- a/sc/source/ui/inc/viewdata.hxx
+++ b/sc/source/ui/inc/viewdata.hxx
@@ -155,7 +155,7 @@ private:
 
     void            WriteUserDataSequence(
                         com::sun::star::uno::Sequence <com::sun::star::beans::PropertyValue>& rSettings,
-                        const ScViewData& rViewData, SCTAB nTab );
+                        const ScViewData& rViewData, SCTAB nTab ) const;
 
     void            ReadUserDataSequence(
                         const com::sun::star::uno::Sequence <com::sun::star::beans::PropertyValue>& rSettings,
@@ -267,7 +267,7 @@ public:
     void            ReadUserData(const String& rData);
     void            WriteExtOptions( ScExtDocOptions& rOpt ) const;
     void            ReadExtOptions( const ScExtDocOptions& rOpt );
-    void            WriteUserDataSequence(com::sun::star::uno::Sequence <com::sun::star::beans::PropertyValue>& rSettings);
+    void            WriteUserDataSequence(com::sun::star::uno::Sequence <com::sun::star::beans::PropertyValue>& rSettings) const;
     void            ReadUserDataSequence(const com::sun::star::uno::Sequence <com::sun::star::beans::PropertyValue>& rSettings);
 
     ScDocument*     GetDocument() const;
diff --git a/sc/source/ui/view/prevwsh.cxx b/sc/source/ui/view/prevwsh.cxx
index ab33d56..5f90335 100644
--- a/sc/source/ui/view/prevwsh.cxx
+++ b/sc/source/ui/view/prevwsh.cxx
@@ -156,7 +156,7 @@ ScPreviewShell::ScPreviewShell( SfxViewFrame* pViewFrame,
         //! or completely forget aSourceData on ScTablesHint?
 
         ScTabViewShell* pTabViewShell = ((ScTabViewShell*)pOldSh);
-        ScViewData* pData = pTabViewShell->GetViewData();
+        const ScViewData* pData = pTabViewShell->GetViewData();
         pData->WriteUserDataSequence( aSourceData );
         InitStartTable( pData->GetTabNo() );
         pPreview->SetSelectedTabs(pData->GetMarkData());
diff --git a/sc/source/ui/view/viewdata.cxx b/sc/source/ui/view/viewdata.cxx
index 446b0b0..691b651 100644
--- a/sc/source/ui/view/viewdata.cxx
+++ b/sc/source/ui/view/viewdata.cxx
@@ -113,7 +113,7 @@ ScViewDataTable::~ScViewDataTable()
 {
 }
 
-void ScViewDataTable::WriteUserDataSequence(uno::Sequence <beans::PropertyValue>& rSettings, const ScViewData& /*rViewData*/, SCTAB /*nTab*/)
+void ScViewDataTable::WriteUserDataSequence(uno::Sequence <beans::PropertyValue>& rSettings, const ScViewData& /*rViewData*/, SCTAB /*nTab*/) const
 {
     rSettings.realloc(SC_TABLE_VIEWSETTINGS_COUNT);
     beans::PropertyValue* pSettings = rSettings.getArray();
@@ -2615,7 +2615,7 @@ void ScViewData::ReadExtOptions( const ScExtDocOptions& rDocOpt )
     // RecalcPixPos oder so - auch nMPos - auch bei ReadUserData ??!?!
 }
 
-void ScViewData::WriteUserDataSequence(uno::Sequence <beans::PropertyValue>& rSettings)
+void ScViewData::WriteUserDataSequence(uno::Sequence <beans::PropertyValue>& rSettings) const
 {
     rSettings.realloc(SC_VIEWSETTINGS_COUNT);
     // + 1, because we have to put the view id in the sequence
commit 8724aa7d6dc6a89855c0c0a1a5d5b9dc0331a679
Author: Kohei Yoshida <kohei.yoshida at suse.com>
Date:   Mon Nov 28 20:08:01 2011 -0500

    Passed the selected sheet info to ScPreview.

diff --git a/sc/inc/markdata.hxx b/sc/inc/markdata.hxx
index 05157a2..ef2671d 100644
--- a/sc/inc/markdata.hxx
+++ b/sc/inc/markdata.hxx
@@ -45,11 +45,14 @@ class ScRangeList;
 
 class SC_DLLPUBLIC ScMarkData
 {
+public:
+    typedef std::set<SCTAB> MarkedTabsType;
 private:
+    MarkedTabsType  maTabMarked;
+
     ScRange         aMarkRange;             // area
     ScRange         aMultiRange;            // maximum area altogether
     ScMarkArray*    pMultiSel;              // multi selection
-    ::std::set<SCTAB> maTabMarked;
     bool            bMarked:1;                // rectangle marked
     bool            bMultiMarked:1;
 
@@ -86,6 +89,7 @@ public:
     SCTAB       GetSelectCount() const;
     SCTAB       GetFirstSelected() const;
     SCTAB       GetLastSelected() const;
+    void        GetSelectedTabs(MarkedTabsType& rTabs) const;
 
     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 68a1129..70df85a 100644
--- a/sc/source/core/data/markdata.cxx
+++ b/sc/source/core/data/markdata.cxx
@@ -40,17 +40,17 @@
 //------------------------------------------------------------------------
 
 ScMarkData::ScMarkData() :
-    pMultiSel( NULL ),
-    maTabMarked()
+    maTabMarked(),
+    pMultiSel( NULL )
 {
     ResetMark();
 }
 
 ScMarkData::ScMarkData(const ScMarkData& rData) :
+    maTabMarked( rData.maTabMarked ),
     aMarkRange( rData.aMarkRange ),
     aMultiRange( rData.aMultiRange ),
-    pMultiSel( NULL ),
-    maTabMarked( rData.maTabMarked )
+    pMultiSel( NULL )
 {
     bMarked      = rData.bMarked;
     bMultiMarked = rData.bMultiMarked;
@@ -228,6 +228,12 @@ SCTAB ScMarkData::GetLastSelected() const
     return 0;
 }
 
+void ScMarkData::GetSelectedTabs(MarkedTabsType& rTabs) const
+{
+    MarkedTabsType aTabs(maTabMarked.begin(), maTabMarked.end());
+    rTabs.swap(aTabs);
+}
+
 void ScMarkData::MarkToMulti()
 {
     if ( bMarked && !bMarking )
diff --git a/sc/source/ui/inc/preview.hxx b/sc/source/ui/inc/preview.hxx
index c284cac..c3c1af5 100644
--- a/sc/source/ui/inc/preview.hxx
+++ b/sc/source/ui/inc/preview.hxx
@@ -31,6 +31,7 @@
 
 #include <vcl/window.hxx>
 #include "printfun.hxx"     // ScPrintState
+#include "markdata.hxx"
 
 #include <vector>
 
@@ -41,6 +42,7 @@ class FmFormView;
 class ScPreview : public Window
 {
 private:
+    ScMarkData::MarkedTabsType maSelectedTabs;
                                         // eingestellt:
     long            nPageNo;            // Seite im Dokument
     sal_uInt16          nZoom;              // eingestellter Zoom
@@ -167,6 +169,8 @@ public:
     static void StaticInvalidate();
 
     FmFormView* GetDrawView() { return pDrawView; }
+
+    void SetSelectedTabs(const ScMarkData& rMark);
 };
 
 
diff --git a/sc/source/ui/view/preview.cxx b/sc/source/ui/view/preview.cxx
index 269b637..41232d0 100644
--- a/sc/source/ui/view/preview.cxx
+++ b/sc/source/ui/view/preview.cxx
@@ -1545,6 +1545,10 @@ void ScPreview::DrawInvert( long nDragPos, sal_uInt16 nFlags )
         Invert( aRect,INVERT_50 );
     }
 }
-//Issue51656 Add resizeable margin on page preview from maoyg
+
+void ScPreview::SetSelectedTabs(const ScMarkData& rMark)
+{
+    rMark.GetSelectedTabs(maSelectedTabs);
+}
 
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sc/source/ui/view/prevwsh.cxx b/sc/source/ui/view/prevwsh.cxx
index fc152b0..ab33d56 100644
--- a/sc/source/ui/view/prevwsh.cxx
+++ b/sc/source/ui/view/prevwsh.cxx
@@ -159,6 +159,7 @@ ScPreviewShell::ScPreviewShell( SfxViewFrame* pViewFrame,
         ScViewData* pData = pTabViewShell->GetViewData();
         pData->WriteUserDataSequence( aSourceData );
         InitStartTable( pData->GetTabNo() );
+        pPreview->SetSelectedTabs(pData->GetMarkData());
 
         //  also have to store the TabView's DesignMode state
         //  (only if draw view exists)
commit 12854c322f799a8795b0054293ea987f11170d64
Author: Kohei Yoshida <kohei.yoshida at suse.com>
Date:   Mon Nov 28 19:25:43 2011 -0500

    sal_Bool to bool.

diff --git a/sc/inc/docuno.hxx b/sc/inc/docuno.hxx
index 35296da..261a21d 100644
--- a/sc/inc/docuno.hxx
+++ b/sc/inc/docuno.hxx
@@ -111,7 +111,7 @@ private:
 
     ::cppu::OInterfaceContainerHelper maChangesListeners;
 
-    sal_Bool                    FillRenderMarkData( const com::sun::star::uno::Any& aSelection,
+    bool                    FillRenderMarkData( const com::sun::star::uno::Any& aSelection,
                                                 const com::sun::star::uno::Sequence< com::sun::star::beans::PropertyValue >& rOptions,
                                                 ScMarkData& rMark, ScPrintSelectionStatus& rStatus, String& rPagesStr ) const;
     com::sun::star::uno::Reference<com::sun::star::uno::XAggregation> GetFormatter();
diff --git a/sc/source/ui/unoobj/docuno.cxx b/sc/source/ui/unoobj/docuno.cxx
index affcb56..cb6b3f7 100644
--- a/sc/source/ui/unoobj/docuno.cxx
+++ b/sc/source/ui/unoobj/docuno.cxx
@@ -752,7 +752,7 @@ bool lcl_ParseTarget( const String& rTarget, ScRange& rTargetRange, Rectangle& r
     return bRangeValid;
 }
 
-sal_Bool ScModelObj::FillRenderMarkData( const uno::Any& aSelection,
+bool ScModelObj::FillRenderMarkData( const uno::Any& aSelection,
                                      const uno::Sequence< beans::PropertyValue >& rOptions,
                                      ScMarkData& rMark,
                                      ScPrintSelectionStatus& rStatus, String& rPagesStr ) const
@@ -760,13 +760,13 @@ sal_Bool ScModelObj::FillRenderMarkData( const uno::Any& aSelection,
     OSL_ENSURE( !rMark.IsMarked() && !rMark.IsMultiMarked(), "FillRenderMarkData: MarkData must be empty" );
     OSL_ENSURE( pDocShell, "FillRenderMarkData: DocShell must be set" );
 
-    sal_Bool bDone = false;
+    bool bDone = false;
 
     uno::Reference<frame::XController> xView;
 
     // defaults when no options are passed: all sheets, include empty pages
     sal_Bool bSelectedSheetsOnly = false;
-    sal_Bool bIncludeEmptyPages = sal_True;
+    sal_Bool bIncludeEmptyPages = true;
 
     bool bHasPrintContent = false;
     sal_Int32 nPrintContent = 0;        // all sheets / selected sheets / selected cells
@@ -813,8 +813,8 @@ sal_Bool ScModelObj::FillRenderMarkData( const uno::Any& aSelection,
         uno::Reference< drawing::XShapes > xShapes( xInterface, uno::UNO_QUERY );
         if ( pSelObj && pSelObj->GetDocShell() == pDocShell )
         {
-            sal_Bool bSheet = ( ScTableSheetObj::getImplementation( xInterface ) != NULL );
-            sal_Bool bCursor = pSelObj->IsCursorOnly();
+            bool bSheet = ( ScTableSheetObj::getImplementation( xInterface ) != NULL );
+            bool bCursor = pSelObj->IsCursorOnly();
             const ScRangeList& rRanges = pSelObj->GetRangeList();
 
             rMark.MarkFromRangeList( rRanges, false );
@@ -843,7 +843,7 @@ sal_Bool ScModelObj::FillRenderMarkData( const uno::Any& aSelection,
                     rStatus.SetMode( SC_PRINTSEL_RANGE );
 
                 rStatus.SetRanges( rRanges );
-                bDone = sal_True;
+                bDone = true;
             }
             // multi selection isn't supported
         }
@@ -872,7 +872,7 @@ sal_Bool ScModelObj::FillRenderMarkData( const uno::Any& aSelection,
                             if( rMark.IsMarked() && !rMark.IsMultiMarked() )
                             {
                                 rStatus.SetMode( SC_PRINTSEL_RANGE_EXCLUSIVELY_OLE_AND_DRAW_OBJECTS );
-                                bDone = sal_True;
+                                bDone = true;
                             }
                         }
                     }
@@ -888,7 +888,7 @@ sal_Bool ScModelObj::FillRenderMarkData( const uno::Any& aSelection,
             for (SCTAB nTab = 0; nTab < nTabCount; nTab++)
                 rMark.SelectTable( nTab, sal_True );
             rStatus.SetMode( SC_PRINTSEL_DOCUMENT );
-            bDone = sal_True;
+            bDone = true;
         }
         // other selection types aren't supported
     }


More information about the Libreoffice-commits mailing list