Register OpenGL windows to ScGridWindow upon file load.

Change-Id: I6fdce232ef41079f20a983dc72da032196078858
diff --git a/include/sfx2/sfxbasecontroller.hxx b/include/sfx2/sfxbasecontroller.hxx
index cff3417..5389d8f 100644
--- a/include/sfx2/sfxbasecontroller.hxx
+++ b/include/sfx2/sfxbasecontroller.hxx
@@ -35,7 +35,8 @@
#include <com/sun/star/frame/XTitleChangeBroadcaster.hpp>
#include <com/sun/star/util/URL.hpp>
#include <com/sun/star/lang/XTypeProvider.hpp>
#include <cppuhelper/implbase9.hxx>
#include <com/sun/star/lang/XInitialization.hpp>
#include <cppuhelper/implbase10.hxx>
#include <cppuhelper/basemutex.hxx>
#include <osl/mutex.hxx>
#include <com/sun/star/task/XStatusIndicatorSupplier.hpp>
@@ -60,7 +61,7 @@ sal_Int16 MapGroupIDToCommandGroup( sal_Int16 nGroupID );
//  class declarations


typedef ::cppu::WeakImplHelper9 <   css::frame::XController2
typedef ::cppu::WeakImplHelper10 <   css::frame::XController2
                                ,   css::frame::XControllerBorder
                                ,   css::frame::XDispatchProvider
                                ,   css::task::XStatusIndicatorSupplier
@@ -69,6 +70,7 @@ typedef ::cppu::WeakImplHelper9 <   css::frame::XController2
                                ,   css::frame::XDispatchInformationProvider
                                ,   css::frame::XTitle
                                ,   css::frame::XTitleChangeBroadcaster
                                ,   css::lang::XInitialization
                                >   SfxBaseController_Base;

class SFX2_DLLPUBLIC SfxBaseController  :public SfxBaseController_Base
@@ -166,6 +168,9 @@ public:
    virtual void SAL_CALL addTitleChangeListener( const css::uno::Reference< css::frame::XTitleChangeListener >& xListener )     throw (css::uno::RuntimeException, std::exception) SAL_OVERRIDE;
    virtual void SAL_CALL removeTitleChangeListener( const css::uno::Reference< css::frame::XTitleChangeListener >& xListener ) throw (css::uno::RuntimeException, std::exception) SAL_OVERRIDE;

    // css::lang::XInitialization
    virtual void SAL_CALL initialize( const ::css::uno::Sequence< ::css::uno::Any >& aArguments ) SAL_OVERRIDE;

    // FIXME: TL needs this in sw/source/ui/uno/unotxdoc.cxx now;
    // either the _Impl name should vanish or there should be an "official" API
    SfxViewShell* GetViewShell_Impl() const;
diff --git a/include/sfx2/viewsh.hxx b/include/sfx2/viewsh.hxx
index 13eb515..7c43c93 100644
--- a/include/sfx2/viewsh.hxx
+++ b/include/sfx2/viewsh.hxx
@@ -190,6 +190,13 @@ public:
    void                        VisAreaChanged(const Rectangle& rRect);

    // Misc

    /**
     * Initialize is called after the frame has been loaded and the controller
     * has been set.  By the time this is called the document has been fully
     * imported.
     */
    virtual void                Initialize();
    virtual bool                PrepareClose( bool bUI = true );
    virtual OUString            GetSelectionText( bool bCompleteWords = false );
    virtual bool                HasSelection( bool bText = true ) const;
diff --git a/sc/inc/document.hxx b/sc/inc/document.hxx
index ad080ae..08f1ca4 100644
--- a/sc/inc/document.hxx
+++ b/sc/inc/document.hxx
@@ -569,6 +569,9 @@ public:
    bool            HasChartAtPoint( SCTAB nTab, const Point& rPos, OUString& rName );

    ::com::sun::star::uno::Reference< ::com::sun::star::chart2::XChartDocument > GetChartByName( const OUString& rChartName );
    std::vector<std::pair<css::uno::Reference<
        css::chart2::XChartDocument>, Rectangle> > GetAllCharts();

    SC_DLLPUBLIC void            GetChartRanges( const OUString& rChartName, ::std::vector< ScRangeList >& rRanges, ScDocument* pSheetNameDoc );
    void            SetChartRanges( const OUString& rChartName, const ::std::vector< ScRangeList >& rRanges );

diff --git a/sc/source/core/data/documen5.cxx b/sc/source/core/data/documen5.cxx
index ff49e24..4076b43 100644
--- a/sc/source/core/data/documen5.cxx
+++ b/sc/source/core/data/documen5.cxx
@@ -663,6 +663,38 @@ uno::Reference< embed::XEmbeddedObject >
    return uno::Reference< embed::XEmbeddedObject >();
}

std::vector<std::pair<uno::Reference<chart2::XChartDocument>, Rectangle> > ScDocument::GetAllCharts()
{
    std::vector<std::pair<uno::Reference<chart2::XChartDocument>, Rectangle> > aRet;
    if (!pDrawLayer)
        return aRet;

    for (SCTAB nTab=0; nTab< static_cast<SCTAB>(maTabs.size()); nTab++)
    {
        if (!maTabs[nTab])
            continue;

        SdrPage* pPage = pDrawLayer->GetPage(static_cast<sal_uInt16>(nTab));
        OSL_ENSURE(pPage,"Page ?");

        if (!pPage)
            continue;

        SdrObjListIter aIter( *pPage, IM_DEEPNOGROUPS );

        for (SdrObject* pObject = aIter.Next(); pObject; pObject = aIter.Next())
        {
            if ( pObject->GetObjIdentifier() != OBJ_OLE2 )
                continue;

            uno::Reference< chart2::XChartDocument > xChartDoc( ScChartHelper::GetChartFromSdrObject( pObject ) );
            Rectangle aRect = pObject->GetLastBoundRect();
            aRet.push_back(std::pair<uno::Reference<chart2::XChartDocument>, Rectangle>(xChartDoc, aRect));
        }
    }
    return aRet;
}

void ScDocument::UpdateChartListenerCollection()
{
    OSL_ASSERT(pChartListenerCollection);
@@ -702,8 +734,6 @@ void ScDocument::UpdateChartListenerCollection()
            }
            else
            {
                bool bIsChart = false;

                uno::Reference< embed::XEmbeddedObject > xIPObj = ((SdrOle2Obj*)pObject)->GetObjRef();
                OSL_ENSURE( xIPObj.is(), "No embedded object is given!");
                uno::Reference< ::com::sun::star::chart2::data::XDataReceiver > xReceiver;
@@ -728,15 +758,12 @@ void ScDocument::UpdateChartListenerCollection()
                    // => we have to do this stuff here, BEFORE the chart is actually loaded
                }

                if (!bIsChart)
                {
                    //  put into list of other ole objects, so the object doesn't have to
                    //  be swapped in the next time UpdateChartListenerCollection is called
                    //! remove names when objects are no longer there?
                    //  (object names aren't used again before reloading the document)
                //  put into list of other ole objects, so the object doesn't have to
                //  be swapped in the next time UpdateChartListenerCollection is called
                //! remove names when objects are no longer there?
                //  (object names aren't used again before reloading the document)

                    rNonOleObjects.insert(aObjName);
                }
                rNonOleObjects.insert(aObjName);
            }
        }
    }
diff --git a/sc/source/ui/Accessibility/AccessibleSpreadsheet.cxx b/sc/source/ui/Accessibility/AccessibleSpreadsheet.cxx
index bdc9b1d..6d26093 100644
--- a/sc/source/ui/Accessibility/AccessibleSpreadsheet.cxx
+++ b/sc/source/ui/Accessibility/AccessibleSpreadsheet.cxx
@@ -26,6 +26,7 @@
#include "hints.hxx"
#include "scmod.hxx"
#include "markdata.hxx"
#include <gridwin.hxx>

#include <unotools/accessiblestatesethelper.hxx>
#include <com/sun/star/accessibility/AccessibleRole.hpp>
diff --git a/sc/source/ui/app/client.cxx b/sc/source/ui/app/client.cxx
index e130446..089790d 100644
--- a/sc/source/ui/app/client.cxx
+++ b/sc/source/ui/app/client.cxx
@@ -35,6 +35,7 @@
#include "client.hxx"
#include "tabvwsh.hxx"
#include "docsh.hxx"
#include <gridwin.hxx>

using namespace com::sun::star;

diff --git a/sc/source/ui/app/inputhdl.cxx b/sc/source/ui/app/inputhdl.cxx
index 8b8d051..d354cba 100644
--- a/sc/source/ui/app/inputhdl.cxx
+++ b/sc/source/ui/app/inputhdl.cxx
@@ -78,6 +78,7 @@
#include "funcdesc.hxx"
#include "markdata.hxx"
#include "tokenarray.hxx"
#include <gridwin.hxx>

// Maximum Ranges in RangeFinder
#define RANGEFIND_MAX   32
diff --git a/sc/source/ui/app/transobj.cxx b/sc/source/ui/app/transobj.cxx
index eec781a..a538cd3 100644
--- a/sc/source/ui/app/transobj.cxx
+++ b/sc/source/ui/app/transobj.cxx
@@ -62,6 +62,7 @@
#include "cellsuno.hxx"
#include "stringutil.hxx"
#include "formulaiter.hxx"
#include <gridwin.hxx>

using namespace com::sun::star;

diff --git a/sc/source/ui/drawfunc/drawsh.cxx b/sc/source/ui/drawfunc/drawsh.cxx
index a7552d3..3cc796f 100644
--- a/sc/source/ui/drawfunc/drawsh.cxx
+++ b/sc/source/ui/drawfunc/drawsh.cxx
@@ -47,6 +47,7 @@
#include <svx/drawitem.hxx>
#include <svx/xtable.hxx>
#include "tabvwsh.hxx"
#include <gridwin.hxx>
#include <sfx2/bindings.hxx>

#define ScDrawShell
diff --git a/sc/source/ui/drawfunc/drawsh2.cxx b/sc/source/ui/drawfunc/drawsh2.cxx
index f436fe2..afc1ecd 100644
--- a/sc/source/ui/drawfunc/drawsh2.cxx
+++ b/sc/source/ui/drawfunc/drawsh2.cxx
@@ -45,6 +45,7 @@
#include "document.hxx"
#include "drwlayer.hxx"
#include "userdat.hxx"
#include <gridwin.hxx>
#include <svx/svdoole2.hxx>
#include <svx/svdocapt.hxx>

diff --git a/sc/source/ui/drawfunc/drtxtob.cxx b/sc/source/ui/drawfunc/drtxtob.cxx
index f0ed72e..ba9f349 100644
--- a/sc/source/ui/drawfunc/drtxtob.cxx
+++ b/sc/source/ui/drawfunc/drtxtob.cxx
@@ -72,6 +72,7 @@
#include "viewutil.hxx"
#include "scresid.hxx"
#include "tabvwsh.hxx"
#include <gridwin.hxx>

#define ScDrawTextObjectBar
#include "scslots.hxx"
diff --git a/sc/source/ui/drawfunc/drtxtob1.cxx b/sc/source/ui/drawfunc/drtxtob1.cxx
index 5cb6368..a437078 100644
--- a/sc/source/ui/drawfunc/drtxtob1.cxx
+++ b/sc/source/ui/drawfunc/drtxtob1.cxx
@@ -36,6 +36,7 @@
#include "drawview.hxx"
#include "viewdata.hxx"
#include "scresid.hxx"
#include <gridwin.hxx>

#include "scabstdlg.hxx"
#include <boost/scoped_ptr.hpp>
diff --git a/sc/source/ui/inc/tabview.hxx b/sc/source/ui/inc/tabview.hxx
index 34a107b9..dfb8e8b 100644
--- a/sc/source/ui/inc/tabview.hxx
+++ b/sc/source/ui/inc/tabview.hxx
@@ -324,7 +324,7 @@ public:
    void            StopMarking();
    void            FakeButtonUp( ScSplitPos eWhich );

    Window*         GetActiveWin();
    ScGridWindow*   GetActiveWin();
    Window*         GetWindowByPos( ScSplitPos ePos );

    ScSplitPos      FindWindow( Window* pWindow ) const;
diff --git a/sc/source/ui/inc/tabvwsh.hxx b/sc/source/ui/inc/tabvwsh.hxx
index 691dfa5..9eeb6f8 100644
--- a/sc/source/ui/inc/tabvwsh.hxx
+++ b/sc/source/ui/inc/tabvwsh.hxx
@@ -191,6 +191,8 @@ private:
    void          DoReadUserDataSequence( const ::com::sun::star::uno::Sequence<
                                     ::com::sun::star::beans::PropertyValue >& rSettings );

    void AddOpenGLChartWindows();

    DECL_LINK( SimpleRefClose, void* );
    DECL_LINK( SimpleRefDone, OUString* );
    DECL_LINK( SimpleRefAborted, OUString* );
@@ -331,7 +333,7 @@ public:
    ObjectSelectionType GetCurObjectSelectionType();

    virtual ErrCode DoVerb(long nVerb) SAL_OVERRIDE;

    virtual void Initialize() SAL_OVERRIDE;

    void            StopEditShell();
    bool            IsDrawTextShell() const;
diff --git a/sc/source/ui/inc/viewdata.hxx b/sc/source/ui/inc/viewdata.hxx
index c36aba9..6a86e46 100644
--- a/sc/source/ui/inc/viewdata.hxx
+++ b/sc/source/ui/inc/viewdata.hxx
@@ -101,6 +101,7 @@ class ScPatternAttr;
class ScExtDocOptions;
class ScViewData;
class ScMarkData;
class ScGridWindow;

class ScViewDataTable                           // per-sheet data
{
@@ -240,7 +241,7 @@ public:
    const ScMarkData& GetMarkData() const;

    Window*         GetDialogParent();          // forwarded from tabvwsh
    Window*         GetActiveWin();             // from View
    ScGridWindow*   GetActiveWin();             // from View
    ScDrawView*     GetScDrawView();            // from View
    bool            IsMinimized();              // from View

diff --git a/sc/source/ui/undo/undoblk.cxx b/sc/source/ui/undo/undoblk.cxx
index dd0577e..0c5c495 100644
--- a/sc/source/ui/undo/undoblk.cxx
+++ b/sc/source/ui/undo/undoblk.cxx
@@ -51,6 +51,7 @@
#include <refhint.hxx>
#include <refupdatecontext.hxx>
#include <validat.hxx>
#include <gridwin.hxx>

#include <set>
#include <boost/scoped_ptr.hpp>
diff --git a/sc/source/ui/vba/excelvbahelper.cxx b/sc/source/ui/vba/excelvbahelper.cxx
index 3b654bf..d57988c 100644
--- a/sc/source/ui/vba/excelvbahelper.cxx
+++ b/sc/source/ui/vba/excelvbahelper.cxx
@@ -28,6 +28,7 @@
#include "transobj.hxx"
#include "scmod.hxx"
#include "cellsuno.hxx"
#include <gridwin.hxx>

#include <com/sun/star/script/vba/VBAEventId.hpp>
#include <com/sun/star/script/vba/XVBACompatibility.hpp>
diff --git a/sc/source/ui/view/cellsh.cxx b/sc/source/ui/view/cellsh.cxx
index 2a5aa5b..eca9ed8 100644
--- a/sc/source/ui/view/cellsh.cxx
+++ b/sc/source/ui/view/cellsh.cxx
@@ -56,6 +56,7 @@
#include "cliputil.hxx"
#include "clipparam.hxx"
#include "markdata.hxx"
#include <gridwin.hxx>

#define ScCellShell
#define CellMovement
diff --git a/sc/source/ui/view/cellsh1.cxx b/sc/source/ui/view/cellsh1.cxx
index 3cccca4..8781fb7 100644
--- a/sc/source/ui/view/cellsh1.cxx
+++ b/sc/source/ui/view/cellsh1.cxx
@@ -83,6 +83,7 @@
#include <cellvalue.hxx>
#include <tokenarray.hxx>
#include <formulacell.hxx>
#include <gridwin.hxx>

#include <com/sun/star/ui/dialogs/XExecutableDialog.hpp>
#include <com/sun/star/lang/XInitialization.hpp>
diff --git a/sc/source/ui/view/cliputil.cxx b/sc/source/ui/view/cliputil.cxx
index 239c809..7c37d61 100644
--- a/sc/source/ui/view/cliputil.cxx
+++ b/sc/source/ui/view/cliputil.cxx
@@ -18,6 +18,7 @@
#include "rangelst.hxx"
#include "viewutil.hxx"
#include "markdata.hxx"
#include <gridwin.hxx>

#include <vcl/waitobj.hxx>

diff --git a/sc/source/ui/view/drawvie4.cxx b/sc/source/ui/view/drawvie4.cxx
index ad38c2c..d5e280d 100644
--- a/sc/source/ui/view/drawvie4.cxx
+++ b/sc/source/ui/view/drawvie4.cxx
@@ -39,6 +39,7 @@
#include "scmod.hxx"
#include "globstr.hrc"
#include "chartarr.hxx"
#include <gridwin.hxx>

#include <com/sun/star/embed/NoVisualAreaSizeException.hpp>
#include <com/sun/star/embed/Aspects.hpp>
diff --git a/sc/source/ui/view/editsh.cxx b/sc/source/ui/view/editsh.cxx
index 7cb2936..fed79b5 100644
--- a/sc/source/ui/view/editsh.cxx
+++ b/sc/source/ui/view/editsh.cxx
@@ -69,6 +69,7 @@
#include "tabvwsh.hxx"
#include "editutil.hxx"
#include "globstr.hrc"
#include <gridwin.hxx>

#define ScEditShell
#include "scslots.hxx"
diff --git a/sc/source/ui/view/select.cxx b/sc/source/ui/view/select.cxx
index 52d19072..378e469 100644
--- a/sc/source/ui/view/select.cxx
+++ b/sc/source/ui/view/select.cxx
@@ -30,6 +30,7 @@
#include "docsh.hxx"
#include "tabprotection.hxx"
#include "markdata.hxx"
#include <gridwin.hxx>

#if defined WNT
#define SC_SELENG_REFMODE_UPDATE_INTERVAL_MIN 65
diff --git a/sc/source/ui/view/spelldialog.cxx b/sc/source/ui/view/spelldialog.cxx
index ae2849a..03e4073 100644
--- a/sc/source/ui/view/spelldialog.cxx
+++ b/sc/source/ui/view/spelldialog.cxx
@@ -34,6 +34,7 @@
#include "scmod.hxx"
#include "editable.hxx"
#include "undoblk.hxx"
#include <gridwin.hxx>
#include <refupdatecontext.hxx>

SFX_IMPL_CHILDWINDOW_WITHID( ScSpellDialogChildWindow, SID_SPELL_DIALOG )
diff --git a/sc/source/ui/view/tabcont.cxx b/sc/source/ui/view/tabcont.cxx
index c6c41c0..e609277 100644
--- a/sc/source/ui/view/tabcont.cxx
+++ b/sc/source/ui/view/tabcont.cxx
@@ -33,6 +33,7 @@
#include "clipparam.hxx"
#include "dragdata.hxx"
#include "markdata.hxx"
#include <gridwin.hxx>

// STATIC DATA -----------------------------------------------------------

diff --git a/sc/source/ui/view/tabview.cxx b/sc/source/ui/view/tabview.cxx
index 0541d05..286f1c1 100644
--- a/sc/source/ui/view/tabview.cxx
+++ b/sc/source/ui/view/tabview.cxx
@@ -863,7 +863,7 @@ double ScTabView::GetPendingRelTabBarWidth() const
    return mfPendingTabBarWidth;
}

Window* ScTabView::GetActiveWin()
ScGridWindow* ScTabView::GetActiveWin()
{
    ScSplitPos ePos = aViewData.GetActivePart();
    OSL_ENSURE(pGridWin[ePos],"kein aktives Fenster");
diff --git a/sc/source/ui/view/tabvwsh2.cxx b/sc/source/ui/view/tabvwsh2.cxx
index 1542a00..a2810c1 100644
--- a/sc/source/ui/view/tabvwsh2.cxx
+++ b/sc/source/ui/view/tabvwsh2.cxx
@@ -41,6 +41,7 @@
#include "sc.hrc"
#include "scmod.hxx"
#include "appoptio.hxx"
#include <gridwin.hxx>

// Create default drawing objects via keyboard
#include <svx/svdpagv.hxx>
diff --git a/sc/source/ui/view/tabvwsh4.cxx b/sc/source/ui/view/tabvwsh4.cxx
index 955d9bf..01c171d 100644
--- a/sc/source/ui/view/tabvwsh4.cxx
+++ b/sc/source/ui/view/tabvwsh4.cxx
@@ -39,6 +39,7 @@
#include <unotools/moduleoptions.hxx>
#include <tools/urlobj.hxx>
#include <sfx2/docfile.hxx>
#include <vcl/openglwin.hxx>

#include "tabvwsh.hxx"
#include "sc.hrc"
@@ -88,8 +89,10 @@
#include "preview.hxx"
#include "docoptio.hxx"
#include <documentlinkmgr.hxx>
#include <gridwin.hxx>

#include <com/sun/star/document/XDocumentProperties.hpp>
#include <com/sun/star/chart2/X3DChartWindowProvider.hpp>

extern SfxViewShell* pScActiveViewShell;            // global.cxx

@@ -529,6 +532,30 @@ void ScTabViewShell::DoReadUserDataSequence( const uno::Sequence < beans::Proper
    //! if ViewData has more tables than document, remove tables in ViewData
}

void ScTabViewShell::AddOpenGLChartWindows()
{
    ScDocument* pDoc = GetViewData()->GetDocument();
    ScGridWindow* pParentWindow = GetActiveWin();

    std::vector<std::pair<uno::Reference<chart2::XChartDocument>, Rectangle> > aCharts = pDoc->GetAllCharts();

    for(std::vector<std::pair<uno::Reference<chart2::XChartDocument>, Rectangle> >::iterator itr = aCharts.begin(),
            itrEnd = aCharts.end(); itr != itrEnd; ++itr)
    {
        OpenGLWindow* pOpenGLWindow = new OpenGLWindow(pParentWindow);
        pOpenGLWindow->Show(false);
        Size aSize = itr->second.GetSize();

        pOpenGLWindow->SetSizePixel(aSize);
        Point aPos = itr->second.TopLeft();
        pOpenGLWindow->SetPosPixel(aPos);
        pParentWindow->AddChildWindow(pOpenGLWindow);
        uno::Reference< chart2::X3DChartWindowProvider > x3DWindowProvider( itr->first, uno::UNO_QUERY_THROW );
        sal_uInt64 nWindowPtr = reinterpret_cast<sal_uInt64>(pOpenGLWindow);
        x3DWindowProvider->setWindow(nWindowPtr);
    }
}

// DoReadUserData is also called from ctor when switching from print preview

void ScTabViewShell::DoReadUserData( const OUString& rData )
diff --git a/sc/source/ui/view/tabvwshb.cxx b/sc/source/ui/view/tabvwshb.cxx
index 7d70114..3871bc8 100644
--- a/sc/source/ui/view/tabvwshb.cxx
+++ b/sc/source/ui/view/tabvwshb.cxx
@@ -58,6 +58,7 @@
#include "chartarr.hxx"
#include "drawview.hxx"
#include "ChartRangeSelectionListener.hxx"
#include <gridwin.hxx>

#include <tools/urlobj.hxx>
#include <com/sun/star/ui/dialogs/TemplateDescription.hpp>
@@ -243,6 +244,11 @@ ErrCode ScTabViewShell::DoVerb(long nVerb)
    return nErr;
}

void ScTabViewShell::Initialize()
{
    AddOpenGLChartWindows();
}

void ScTabViewShell::DeactivateOle()
{
    // deactivate inplace editing if currently active
diff --git a/sc/source/ui/view/tabvwshd.cxx b/sc/source/ui/view/tabvwshd.cxx
index eac3ea4..f3431d3 100644
--- a/sc/source/ui/view/tabvwshd.cxx
+++ b/sc/source/ui/view/tabvwshd.cxx
@@ -28,6 +28,7 @@
#include "scmod.hxx"
#include "docsh.hxx"
#include "sc.hrc"
#include <gridwin.hxx>


// STATIC DATA -----------------------------------------------------------
diff --git a/sc/source/ui/view/tabvwshe.cxx b/sc/source/ui/view/tabvwshe.cxx
index 545db9f..2629d49 100644
--- a/sc/source/ui/view/tabvwshe.cxx
+++ b/sc/source/ui/view/tabvwshe.cxx
@@ -40,6 +40,7 @@
#include "inputhdl.hxx"
#include <svx/srchdlg.hxx>
#include "document.hxx"
#include <gridwin.hxx>

OUString ScTabViewShell::GetSelectionText( bool bWholeWord )
{
diff --git a/sc/source/ui/view/tabvwshg.cxx b/sc/source/ui/view/tabvwshg.cxx
index 53ede02..a2457bd 100644
--- a/sc/source/ui/view/tabvwshg.cxx
+++ b/sc/source/ui/view/tabvwshg.cxx
@@ -34,6 +34,7 @@ using namespace com::sun::star;
#include "document.hxx"
#include "drawview.hxx"
#include "globstr.hrc"
#include <gridwin.hxx>
#include <avmedia/mediawindow.hxx>

void ScTabViewShell::InsertURLButton( const OUString& rName, const OUString& rURL,
diff --git a/sc/source/ui/view/viewdata.cxx b/sc/source/ui/view/viewdata.cxx
index 50e7b12..90f1377 100644
--- a/sc/source/ui/view/viewdata.cxx
+++ b/sc/source/ui/view/viewdata.cxx
@@ -58,6 +58,7 @@
#include "markdata.hxx"
#include "stlalgorithm.hxx"
#include "ViewSettingsSequenceDefines.hxx"
#include <gridwin.hxx>
#include <rtl/ustrbuf.hxx>
#include <boost/checked_delete.hpp>
#include <comphelper/processfactory.hxx>
@@ -2115,7 +2116,7 @@ Window* ScViewData::GetDialogParent()
    return pViewShell->GetDialogParent();
}

Window* ScViewData::GetActiveWin()
ScGridWindow* ScViewData::GetActiveWin()
{
    OSL_ENSURE( pView, "GetActiveWin() ohne View" );
    return pView->GetActiveWin();
diff --git a/sc/source/ui/view/viewfun3.cxx b/sc/source/ui/view/viewfun3.cxx
index 2f7375e..d82e725 100644
--- a/sc/source/ui/view/viewfun3.cxx
+++ b/sc/source/ui/view/viewfun3.cxx
@@ -65,6 +65,7 @@
#include "undodat.hxx"
#include "drawview.hxx"
#include "cliputil.hxx"
#include <gridwin.hxx>
#include <boost/scoped_ptr.hpp>

using namespace com::sun::star;
diff --git a/sc/source/ui/view/viewfun4.cxx b/sc/source/ui/view/viewfun4.cxx
index 2e05759..73432c6 100644
--- a/sc/source/ui/view/viewfun4.cxx
+++ b/sc/source/ui/view/viewfun4.cxx
@@ -67,6 +67,7 @@
#include "compiler.hxx"
#include "tokenarray.hxx"
#include <refupdatecontext.hxx>
#include <gridwin.hxx>

#include <boost/scoped_ptr.hpp>

diff --git a/sc/source/ui/view/viewfun7.cxx b/sc/source/ui/view/viewfun7.cxx
index ba35fe6..4cf39cf 100644
--- a/sc/source/ui/view/viewfun7.cxx
+++ b/sc/source/ui/view/viewfun7.cxx
@@ -46,6 +46,7 @@
#include "docsh.hxx"
#include "convuno.hxx"
#include "dragdata.hxx"
#include <gridwin.hxx>

extern Point aDragStartDiff;

diff --git a/sfx2/source/view/frmload.cxx b/sfx2/source/view/frmload.cxx
index 5351212..afbf092 100644
--- a/sfx2/source/view/frmload.cxx
+++ b/sfx2/source/view/frmload.cxx
@@ -50,6 +50,7 @@
#include <com/sun/star/frame/XController2.hpp>
#include <com/sun/star/frame/XModel2.hpp>
#include <com/sun/star/lang/XServiceInfo.hpp>
#include <com/sun/star/lang/XInitialization.hpp>

#include <comphelper/interaction.hxx>
#include <comphelper/namedvaluecollection.hxx>
@@ -71,6 +72,7 @@
#include <ucbhelper/simpleinteractionrequest.hxx>
#include <osl/mutex.hxx>

using namespace com::sun::star;
using ::com::sun::star::beans::PropertyValue;
using ::com::sun::star::container::XContainerQuery;
using ::com::sun::star::container::XEnumeration;
@@ -720,7 +722,16 @@ sal_Bool SAL_CALL SfxFrameLoader_Impl::load( const Sequence< PropertyValue >& rA
        const OUString sViewName( xDoc->GetFactory().GetViewFactory( nViewNo ).GetAPIViewName() );

        // plug the document into the frame
        impl_createDocumentView( xModel, _rTargetFrame, aViewCreationArgs, sViewName );
        Reference<XController2> xController =
            impl_createDocumentView( xModel, _rTargetFrame, aViewCreationArgs, sViewName );

        Reference<lang::XInitialization> xInit(xController, UNO_QUERY);
        if (xInit.is())
        {
            uno::Sequence<uno::Any> aArgs; // empty for now.
            xInit->initialize(aArgs);
        }

        bLoadSuccess = true;
    }
    catch ( Exception& )
diff --git a/sfx2/source/view/sfxbasecontroller.cxx b/sfx2/source/view/sfxbasecontroller.cxx
index bd7d5da..cc4930a 100644
--- a/sfx2/source/view/sfxbasecontroller.cxx
+++ b/sfx2/source/view/sfxbasecontroller.cxx
@@ -1524,4 +1524,10 @@ void SAL_CALL SfxBaseController::removeTitleChangeListener(const Reference< fram
        xBroadcaster->removeTitleChangeListener (xListener);
}

void SfxBaseController::initialize( const ::css::uno::Sequence< ::css::uno::Any >& /*aArguments*/ )
{
    if (m_pData->m_pViewShell)
        m_pData->m_pViewShell->Initialize();
}

/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sfx2/source/view/viewsh.cxx b/sfx2/source/view/viewsh.cxx
index 7bb2d4c..c8b8eb7 100644
--- a/sfx2/source/view/viewsh.cxx
+++ b/sfx2/source/view/viewsh.cxx
@@ -1269,7 +1269,10 @@ SfxViewShell::~SfxViewShell()
    DELETEZ( pIPClientList );
}


void SfxViewShell::Initialize()
{
    // overloaded by the application.
}

bool SfxViewShell::PrepareClose
(