vclptr: switch printers away from boost_shared.

Also continue to move to extended toolkit/ API.

Change-Id: Ibd4337b014ee096c84d0ad4435e2c5de1b258afe
diff --git a/dbaccess/source/ui/control/toolboxcontroller.cxx b/dbaccess/source/ui/control/toolboxcontroller.cxx
index cb6d306..ca97d79 100644
--- a/dbaccess/source/ui/control/toolboxcontroller.cxx
+++ b/dbaccess/source/ui/control/toolboxcontroller.cxx
@@ -131,7 +131,7 @@ namespace dbaui
        for (; aIter != aEnd; ++aIter)
            addStatusListener(aIter->first);

        ToolBox*    pToolBox = static_cast<ToolBox*>(VCLUnoHelper::GetWindow(getParent()));
        VclPtr< ToolBox > pToolBox = static_cast<ToolBox*>(VCLUnoHelper::GetWindow(getParent()).get());
        if ( pToolBox )
        {
            sal_uInt16 nCount = pToolBox->GetItemCount();
diff --git a/include/toolkit/awt/vclxprinter.hxx b/include/toolkit/awt/vclxprinter.hxx
index 892cc4c..2c20ccd 100644
--- a/include/toolkit/awt/vclxprinter.hxx
+++ b/include/toolkit/awt/vclxprinter.hxx
@@ -57,11 +57,11 @@ class VCLXPrinterPropertySet    :public VCLXPrinterPropertySet_Base
                                ,public ::cppu::OPropertySetHelper
{
protected:
    std::shared_ptr<Printer>                      mxPrinter;
    VclPtr<Printer>             mpPrinter;
    ::com::sun::star::uno::Reference< ::com::sun::star::awt::XDevice >  mxPrnDevice;

    sal_Int16                   mnOrientation;
    bool                    mbHorizontal;
    bool                        mbHorizontal;
public:
    VCLXPrinterPropertySet( const OUString& rPrinterName );
    virtual ~VCLXPrinterPropertySet();
diff --git a/include/vcl/oldprintadaptor.hxx b/include/vcl/oldprintadaptor.hxx
index 72d1163..987b58f 100644
--- a/include/vcl/oldprintadaptor.hxx
+++ b/include/vcl/oldprintadaptor.hxx
@@ -29,7 +29,7 @@ namespace vcl
    {
        ImplOldStyleAdaptorData*    mpData;
    public:
        OldStylePrintAdaptor(const std::shared_ptr<Printer>&);
        OldStylePrintAdaptor( const VclPtr< Printer >& );
        virtual ~OldStylePrintAdaptor();

        void StartPage();
diff --git a/include/vcl/print.hxx b/include/vcl/print.hxx
index d749769..bf7ea47 100644
--- a/include/vcl/print.hxx
+++ b/include/vcl/print.hxx
@@ -426,7 +426,7 @@ class VCL_DLLPUBLIC PrinterController
{
    ImplPrinterControllerData* mpImplData;
protected:
    PrinterController( const std::shared_ptr<Printer>& );
    PrinterController( const VclPtr<Printer>& );
public:
    enum NupOrderType
    { LRTB, TBLR, TBRL, RLTB };
@@ -469,7 +469,7 @@ public:

    virtual ~PrinterController();

    const std::shared_ptr<Printer>& getPrinter() const;
    const VclPtr<Printer>& getPrinter() const;
    /* for implementations: get current job properties as changed by e.g. print dialog
       this gets the current set of properties initially told to Printer::PrintJob

@@ -550,7 +550,7 @@ public:
    SAL_DLLPRIVATE PageSize getPageFile( int i_inUnfilteredPage, GDIMetaFile& rMtf, bool i_bMayUseCache = false );
    VCL_PLUGIN_PUBLIC PageSize getFilteredPageFile( int i_nFilteredPage, GDIMetaFile& o_rMtf, bool i_bMayUseCache = false );
    VCL_PLUGIN_PUBLIC void printFilteredPage( int i_nPage );
    SAL_DLLPRIVATE void setPrinter( const std::shared_ptr<Printer>& );
    SAL_DLLPRIVATE void setPrinter( const VclPtr<Printer>& );
    SAL_DLLPRIVATE void setOptionChangeHdl( const Link& );
    VCL_PLUGIN_PUBLIC void createProgressDialog();
    VCL_PLUGIN_PUBLIC bool isProgressCanceled() const;
diff --git a/sfx2/source/dialog/backingcomp.cxx b/sfx2/source/dialog/backingcomp.cxx
index fdc4f1c3..ff6b506 100644
--- a/sfx2/source/dialog/backingcomp.cxx
+++ b/sfx2/source/dialog/backingcomp.cxx
@@ -431,7 +431,7 @@ void SAL_CALL BackingComp::attachFrame( /*IN*/ const css::uno::Reference< css::f
    }

    // inform BackingWindow about frame
    BackingWindow* pBack = dynamic_cast<BackingWindow*>(pWindow );
    BackingWindow* pBack = dynamic_cast<BackingWindow*>(pWindow.get());
    if( pBack )
        pBack->setOwningFrame( m_xFrame );

diff --git a/sfx2/source/view/viewprn.cxx b/sfx2/source/view/viewprn.cxx
index d30b5ee..4b6e56d 100644
--- a/sfx2/source/view/viewprn.cxx
+++ b/sfx2/source/view/viewprn.cxx
@@ -59,7 +59,7 @@ class SfxPrinterController : public vcl::PrinterController, public SfxListener
    Any                                     maCompleteSelection;
    Any                                     maSelection;
    Reference< view::XRenderable >          mxRenderable;
    mutable Printer*                        mpLastPrinter;
    mutable VclPtr<Printer>                 mpLastPrinter;
    mutable Reference<awt::XDevice>         mxDevice;
    SfxViewShell*                           mpViewShell;
    SfxObjectShell*                         mpObjectShell;
@@ -74,7 +74,7 @@ class SfxPrinterController : public vcl::PrinterController, public SfxListener
    const Any& getSelectionObject() const;

public:
    SfxPrinterController( const std::shared_ptr<Printer>& i_rPrinter,
    SfxPrinterController( const VclPtr<Printer>& i_rPrinter,
                          const Any& i_rComplete,
                          const Any& i_rSelection,
                          const Any& i_rViewProp,
@@ -94,7 +94,7 @@ public:
    virtual void jobFinished( com::sun::star::view::PrintableState ) SAL_OVERRIDE;
};

SfxPrinterController::SfxPrinterController( const std::shared_ptr<Printer>& i_rPrinter,
SfxPrinterController::SfxPrinterController( const VclPtr<Printer>& i_rPrinter,
                                            const Any& i_rComplete,
                                            const Any& i_rSelection,
                                            const Any& i_rViewProp,
@@ -204,12 +204,12 @@ const Any& SfxPrinterController::getSelectionObject() const

Sequence< beans::PropertyValue > SfxPrinterController::getMergedOptions() const
{
    std::shared_ptr<Printer> xPrinter(getPrinter());
    if (xPrinter.get() != mpLastPrinter)
    VclPtr<Printer> xPrinter( getPrinter() );
    if( xPrinter.get() != mpLastPrinter )
    {
        mpLastPrinter = xPrinter.get();
        VCLXDevice* pXDevice = new VCLXDevice();
        pXDevice->SetOutputDevicePtr( mpLastPrinter );
        pXDevice->SetOutputDevice( mpLastPrinter );
        mxDevice = Reference< awt::XDevice >( pXDevice );
    }

@@ -224,8 +224,8 @@ Sequence< beans::PropertyValue > SfxPrinterController::getMergedOptions() const
int SfxPrinterController::getPageCount() const
{
    int nPages = 0;
    std::shared_ptr<Printer> xPrinter(getPrinter());
    if (mxRenderable.is() && xPrinter)
    VclPtr<Printer> xPrinter( getPrinter() );
    if( mxRenderable.is() && pPrinter )
    {
        Sequence< beans::PropertyValue > aJobOptions( getMergedOptions() );
        try
@@ -244,7 +244,7 @@ int SfxPrinterController::getPageCount() const

Sequence< beans::PropertyValue > SfxPrinterController::getPageParameters( int i_nPage ) const
{
    std::shared_ptr<Printer> xPrinter(getPrinter());
    VclPtr<Printer> xPrinter( getPrinter() );
    Sequence< beans::PropertyValue > aResult;

    if (mxRenderable.is() && xPrinter)
@@ -269,8 +269,8 @@ Sequence< beans::PropertyValue > SfxPrinterController::getPageParameters( int i_

void SfxPrinterController::printPage( int i_nPage ) const
{
    std::shared_ptr<Printer> xPrinter(getPrinter());
    if (mxRenderable.is() && xPrinter)
    VclPtr<Printer> xPrinter( getPrinter() );
    if( mxRenderable.is() && pPrinter )
    {
        Sequence< beans::PropertyValue > aJobOptions( getMergedOptions() );
        try
@@ -451,8 +451,8 @@ IMPL_LINK_NOARG(SfxDialogExecutor_Impl, Execute)
        return 0;

    // Create Dialog
    boost::scoped_ptr<SfxPrintOptionsDialog> pDlg(new SfxPrintOptionsDialog( static_cast<vcl::Window*>(_pSetupParent),
                                                             _pViewSh, _pOptions ));
    VclPtr<SfxPrintOptionsDialog> pDlg(new SfxPrintOptionsDialog( static_cast<vcl::Window*>(_pSetupParent),
                                                                  _pViewSh, _pOptions ));
    if ( _bHelpDisabled )
        pDlg->DisableHelp();
    if ( pDlg->Execute() == RET_OK )
@@ -582,7 +582,7 @@ void SfxViewShell::StartPrint( const uno::Sequence < beans::PropertyValue >& rPr
        aSelection <<= GetObjectShell()->GetModel();
    Any aComplete( makeAny( GetObjectShell()->GetModel() ) );
    Any aViewProp( makeAny( xController ) );
    std::shared_ptr<Printer> aPrt;
    VclPtr<Printer> aPrt;

    const beans::PropertyValue* pVal = rProps.getConstArray();
    for( sal_Int32 i = 0; i < rProps.getLength(); i++ )
diff --git a/vcl/generic/print/genprnpsp.cxx b/vcl/generic/print/genprnpsp.cxx
index 62a4bdd..1977e2d 100644
--- a/vcl/generic/print/genprnpsp.cxx
+++ b/vcl/generic/print/genprnpsp.cxx
@@ -1079,7 +1079,7 @@ bool PspSalPrinter::StartJob( const OUString* i_pFileName, const OUString& i_rJo

    std::shared_ptr<vcl::PDFWriter> xWriter;
    std::vector< PDFPrintFile > aPDFFiles;
    std::shared_ptr<Printer> xPrinter(i_rController.getPrinter());
    VclPtr<Printer> xPrinter( i_rController.getPrinter() );
    int nAllPages = i_rController.getFilteredPageCount();
    i_rController.createProgressDialog();
    bool bAborted = false;
diff --git a/vcl/osx/salprn.cxx b/vcl/osx/salprn.cxx
index 0becb85..ed631b0 100644
--- a/vcl/osx/salprn.cxx
+++ b/vcl/osx/salprn.cxx
@@ -448,7 +448,7 @@ bool AquaSalInfoPrinter::StartJob( const OUString* i_pFileName,
            // information (e.g. brochure printing scales to the found paper size)
            // also SetPaperSizeUser has the advantage that we can share a
            // platform independent paper matching algorithm
            std::shared_ptr<Printer> pPrinter( i_rController.getPrinter() );
            VclPtr<Printer> pPrinter( i_rController.getPrinter() );
            pPrinter->SetMapMode( MapMode( MAP_100TH_MM ) );
            pPrinter->SetPaperSizeUser( aCurSize, true );

diff --git a/vcl/source/gdi/oldprintadaptor.cxx b/vcl/source/gdi/oldprintadaptor.cxx
index b1485a9..b71d9dd 100644
--- a/vcl/source/gdi/oldprintadaptor.cxx
+++ b/vcl/source/gdi/oldprintadaptor.cxx
@@ -44,8 +44,8 @@ using namespace com::sun::star;
using namespace com::sun::star::uno;
using namespace com::sun::star::beans;

OldStylePrintAdaptor::OldStylePrintAdaptor(const std::shared_ptr< Printer >& i_xPrinter)
    : PrinterController(i_xPrinter)
OldStylePrintAdaptor::OldStylePrintAdaptor( const VclPtr< Printer >& i_xPrinter )
    : PrinterController( i_xPrinter )
    , mpData( new ImplOldStyleAdaptorData() )
{
}
@@ -64,7 +64,7 @@ void OldStylePrintAdaptor::StartPage()
    getPrinter()->SetConnectMetaFile( &mpData->maPages.back().maPage );

    // copy state into metafile
    std::shared_ptr<Printer> xPrinter(getPrinter());
    VclPtr<Printer> xPrinter( getPrinter() );
    xPrinter->SetMapMode(xPrinter->GetMapMode());
    xPrinter->SetFont(xPrinter->GetFont());
    xPrinter->SetDrawMode(xPrinter->GetDrawMode());
diff --git a/vcl/source/gdi/print3.cxx b/vcl/source/gdi/print3.cxx
index 9821154e..c6d33e0 100644
--- a/vcl/source/gdi/print3.cxx
+++ b/vcl/source/gdi/print3.cxx
@@ -140,7 +140,7 @@ public:
    typedef std::unordered_map< OUString, ControlDependency, OUStringHash > ControlDependencyMap;
    typedef std::unordered_map< OUString, Sequence< sal_Bool >, OUStringHash > ChoiceDisableMap;

    std::shared_ptr<Printer>                                    mxPrinter;
    VclPtr< Printer >                                           mxPrinter;
    Sequence< PropertyValue >                                   maUIOptions;
    std::vector< PropertyValue >                                maUIProperties;
    std::vector< bool >                                         maUIPropertyEnabled;
@@ -206,7 +206,7 @@ public:
    void resetPaperToLastConfigured();
};

PrinterController::PrinterController(const std::shared_ptr<Printer>& i_xPrinter)
PrinterController::PrinterController( const VclPtr<Printer>& i_xPrinter )
    : mpImplData( new ImplPrinterControllerData )
{
    mpImplData->mxPrinter = i_xPrinter;
@@ -319,7 +319,7 @@ void Printer::PreparePrintJob(std::shared_ptr<PrinterController> xController,
    if (!xController->getPrinter())
    {
        OUString aPrinterName( i_rInitSetup.GetPrinterName() );
        std::shared_ptr<Printer> xPrinter(std::make_shared<Printer>(aPrinterName));
        VclPtr<Printer> xPrinter( new Printer( aPrinterName ) );
        xPrinter->SetJobSetup(i_rInitSetup);
        xController->setPrinter(xPrinter);
    }
@@ -770,12 +770,12 @@ void PrinterController::setJobState( view::PrintableState i_eState )
    mpImplData->meJobState = i_eState;
}

const std::shared_ptr<Printer>& PrinterController::getPrinter() const
const VclPtr<Printer>& PrinterController::getPrinter() const
{
    return mpImplData->mxPrinter;
}

void PrinterController::setPrinter(const std::shared_ptr<Printer>& i_rPrinter)
void PrinterController::setPrinter( const VclPtr<Printer>& i_rPrinter )
{
    mpImplData->mxPrinter = i_rPrinter;
    setValue( OUString( "Name" ),
diff --git a/vcl/source/window/printdlg.cxx b/vcl/source/window/printdlg.cxx
index 096f26f..d9c89f0 100644
--- a/vcl/source/window/printdlg.cxx
+++ b/vcl/source/window/printdlg.cxx
@@ -623,13 +623,13 @@ PrintDialog::PrintDialog( vcl::Window* i_pParent, const std::shared_ptr<PrinterC
        if( maJobPage.mpPrinters->GetEntryPos( aValue ) != LISTBOX_ENTRY_NOTFOUND )
        {
            maJobPage.mpPrinters->SelectEntry( aValue );
            maPController->setPrinter(std::make_shared<Printer>(aValue));
            maPController->setPrinter( VclPtr<Printer>( new Printer( aValue ) ) );
        }
        else
        {
            // fall back to default printer
            maJobPage.mpPrinters->SelectEntry( Printer::GetDefaultPrinterName() );
            maPController->setPrinter(std::make_shared<Printer>(Printer::GetDefaultPrinterName()));
            maPController->setPrinter( VclPtr<Printer>( new Printer( Printer::GetDefaultPrinterName() ) ) );
        }
    }
    // not printing to file
@@ -1327,7 +1327,7 @@ void PrintDialog::preparePreview( bool i_bNewPage, bool i_bMayUseCache )
    {
        const MapMode aMapMode( MAP_100TH_MM );
        GDIMetaFile aMtf;
        std::shared_ptr<Printer> aPrt(maPController->getPrinter());
        VclPtr<Printer> aPrt( maPController->getPrinter() );
        if( nPages > 0 )
        {
            PrinterController::PageSize aPageSize =
@@ -1520,7 +1520,7 @@ IMPL_LINK( PrintDialog, SelectHdl, ListBox*, pBox )
    {
        OUString aNewPrinter( pBox->GetSelectEntry() );
        // set new printer
        maPController->setPrinter(std::make_shared<Printer>(aNewPrinter));
        maPController->setPrinter( VclPtr<Printer>( new Printer( aNewPrinter ) ) );
        maPController->resetPrinterOptions( maOptionsPage.mpToFileBox->IsChecked() );
        // update text fields
        updatePrinterText();