LCOV - code coverage report
Current view: top level - sfx2/source/doc - new.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 0 276 0.0 %
Date: 2012-08-25 Functions: 0 37 0.0 %
Legend: Lines: hit not hit | Branches: + taken - not taken # not executed Branches: 0 672 0.0 %

           Branch data     Line data    Source code
       1                 :            : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
       2                 :            : /*
       3                 :            :  * This file is part of the LibreOffice project.
       4                 :            :  *
       5                 :            :  * This Source Code Form is subject to the terms of the Mozilla Public
       6                 :            :  * License, v. 2.0. If a copy of the MPL was not distributed with this
       7                 :            :  * file, You can obtain one at http://mozilla.org/MPL/2.0/.
       8                 :            :  *
       9                 :            :  * This file incorporates work covered by the following license notice:
      10                 :            :  *
      11                 :            :  *   Licensed to the Apache Software Foundation (ASF) under one or more
      12                 :            :  *   contributor license agreements. See the NOTICE file distributed
      13                 :            :  *   with this work for additional information regarding copyright
      14                 :            :  *   ownership. The ASF licenses this file to you under the Apache
      15                 :            :  *   License, Version 2.0 (the "License"); you may not use this file
      16                 :            :  *   except in compliance with the License. You may obtain a copy of
      17                 :            :  *   the License at http://www.apache.org/licenses/LICENSE-2.0 .
      18                 :            :  */
      19                 :            : 
      20                 :            : #include <comphelper/string.hxx>
      21                 :            : #include <sfx2/new.hxx>
      22                 :            : #include <vcl/msgbox.hxx>
      23                 :            : #include <vcl/morebtn.hxx>
      24                 :            : #include <svtools/svmedit.hxx>
      25                 :            : #include <svl/itemset.hxx>
      26                 :            : #include <svl/eitem.hxx>
      27                 :            : #include <svtools/sfxecode.hxx>
      28                 :            : #include <svtools/ehdl.hxx>
      29                 :            : #include <tools/urlobj.hxx>
      30                 :            : #include <unotools/localfilehelper.hxx>
      31                 :            : 
      32                 :            : #include "new.hrc"
      33                 :            : #include "doc.hrc"
      34                 :            : #include <sfx2/app.hxx>
      35                 :            : #include <sfx2/objsh.hxx>
      36                 :            : #include "sfx2/sfxresid.hxx"
      37                 :            : #include <sfx2/docfile.hxx>
      38                 :            : #include "preview.hxx"
      39                 :            : #include <sfx2/printer.hxx>
      40                 :            : #include <vcl/waitobj.hxx>
      41                 :            : 
      42                 :            : // Draw modes
      43                 :            : #define OUTPUT_DRAWMODE_COLOR       (DRAWMODE_DEFAULT)
      44                 :            : #define OUTPUT_DRAWMODE_GRAYSCALE   (DRAWMODE_GRAYLINE | DRAWMODE_GRAYFILL | DRAWMODE_BLACKTEXT | DRAWMODE_GRAYBITMAP | DRAWMODE_GRAYGRADIENT)
      45                 :            : #define OUTPUT_DRAWMODE_BLACKWHITE  (DRAWMODE_BLACKLINE | DRAWMODE_BLACKTEXT | DRAWMODE_WHITEFILL | DRAWMODE_GRAYBITMAP | DRAWMODE_WHITEGRADIENT)
      46                 :            : #define OUTPUT_DRAWMODE_CONTRAST    (DRAWMODE_SETTINGSLINE | DRAWMODE_SETTINGSFILL | DRAWMODE_SETTINGSTEXT | DRAWMODE_SETTINGSGRADIENT)
      47                 :            : 
      48                 :            : //========================================================================
      49                 :            : 
      50                 :            : #define MORE_BTN(x) pMoreBt->x
      51                 :            : 
      52                 :            : //========================================================================
      53                 :            : 
      54                 :          0 : void SfxPreviewBase_Impl::SetObjectShell( SfxObjectShell* pObj )
      55                 :            : {
      56                 :            :     ::boost::shared_ptr<GDIMetaFile> pFile = pObj
      57                 :          0 :         ? pObj->GetPreviewMetaFile()
      58 [ #  # ][ #  # ]:          0 :         : ::boost::shared_ptr<GDIMetaFile>();
                 [ #  # ]
      59         [ #  # ]:          0 :     pMetaFile = pFile;
      60 [ #  # ][ #  # ]:          0 :     Invalidate();
      61                 :          0 : }
      62                 :            : 
      63                 :          0 : SfxPreviewBase_Impl::SfxPreviewBase_Impl(
      64                 :            :     Window* pParent, const ResId& rResId )
      65         [ #  # ]:          0 :     : Window(pParent, rResId), pMetaFile()
      66                 :            : {
      67                 :          0 : }
      68                 :            : 
      69         [ #  # ]:          0 : SfxPreviewBase_Impl::~SfxPreviewBase_Impl()
      70                 :            : {
      71         [ #  # ]:          0 : }
      72                 :            : 
      73                 :          0 : void SfxPreviewBase_Impl::Resize()
      74                 :            : {
      75                 :          0 :     Invalidate();
      76                 :          0 : }
      77                 :            : 
      78                 :          0 : void SfxPreviewWin_Impl::ImpPaint(
      79                 :            :     const Rectangle&, GDIMetaFile* pFile, Window* pWindow )
      80                 :            : {
      81         [ #  # ]:          0 :     Size aTmpSize = pFile ? pFile->GetPrefSize() : Size(1,1 );
      82                 :            :     DBG_ASSERT( aTmpSize.Height()*aTmpSize.Width(),
      83                 :            :                 "size of first page is 0, overload GetFirstPageSize or set vis-area!" );
      84                 :            : #define FRAME 4
      85         [ #  # ]:          0 :     long nWidth = pWindow->GetOutputSize().Width() - 2*FRAME;
      86         [ #  # ]:          0 :     long nHeight = pWindow->GetOutputSize().Height() - 2*FRAME;
      87         [ #  # ]:          0 :     if( nWidth < 0 ) nWidth = 0;
      88         [ #  # ]:          0 :     if( nHeight < 0 ) nHeight = 0;
      89                 :            : 
      90                 :          0 :     double dRatio=((double)aTmpSize.Width())/aTmpSize.Height();
      91                 :          0 :     double dRatioPreV=((double) nWidth ) / nHeight;
      92                 :          0 :     Size aSize;
      93                 :          0 :     Point aPoint;
      94         [ #  # ]:          0 :     if (dRatio>dRatioPreV)
      95                 :            :     {
      96                 :          0 :         aSize=Size(nWidth, (sal_uInt16)(nWidth/dRatio));
      97                 :          0 :         aPoint=Point( 0, (sal_uInt16)((nHeight-aSize.Height())/2));
      98                 :            :     }
      99                 :            :     else
     100                 :            :     {
     101                 :          0 :         aSize=Size((sal_uInt16)(nHeight*dRatio), nHeight);
     102                 :          0 :         aPoint=Point((sal_uInt16)((nWidth-aSize.Width())/2),0);
     103                 :            :     }
     104                 :          0 :     Point bPoint=Point(nWidth,nHeight)-aPoint;
     105                 :            : 
     106                 :            : 
     107         [ #  # ]:          0 :     pWindow->SetLineColor();
     108                 :          0 :     Color aLightGrayCol( COL_LIGHTGRAY );
     109         [ #  # ]:          0 :     pWindow->SetFillColor( aLightGrayCol );
     110 [ #  # ][ #  # ]:          0 :     pWindow->DrawRect( Rectangle( Point( 0,0 ), pWindow->GetOutputSize() ) );
                 [ #  # ]
     111         [ #  # ]:          0 :     if ( pFile )
     112                 :            :     {
     113                 :          0 :         Color aBlackCol( COL_BLACK );
     114                 :          0 :         Color aWhiteCol( COL_WHITE );
     115         [ #  # ]:          0 :         pWindow->SetLineColor( aBlackCol );
     116         [ #  # ]:          0 :         pWindow->SetFillColor( aWhiteCol );
     117 [ #  # ][ #  # ]:          0 :         pWindow->DrawRect( Rectangle( aPoint + Point( FRAME, FRAME ), bPoint + Point( FRAME, FRAME ) ) );
     118         [ #  # ]:          0 :         pFile->WindStart();
     119         [ #  # ]:          0 :         pFile->Play( pWindow, aPoint + Point( FRAME, FRAME ), aSize  );
     120                 :            :     }
     121                 :          0 : }
     122                 :            : 
     123                 :          0 : void SfxPreviewWin_Impl::Paint( const Rectangle& rRect )
     124                 :            : {
     125                 :          0 :     ImpPaint( rRect, pMetaFile.get(), this );
     126                 :          0 : }
     127                 :            : 
     128                 :            : class SfxNewFileDialog_Impl
     129                 :            : {
     130                 :            :     FixedText aRegionFt;
     131                 :            :     ListBox aRegionLb;
     132                 :            :     FixedText aTemplateFt;
     133                 :            :     ListBox aTemplateLb;
     134                 :            : 
     135                 :            :     CheckBox aPreviewBtn;
     136                 :            :     SfxPreviewWin_Impl aPreviewWin;
     137                 :            : 
     138                 :            :     FixedText aTitleFt;
     139                 :            :     Edit aTitleEd;
     140                 :            :     FixedText aThemaFt;
     141                 :            :     Edit aThemaEd;
     142                 :            :     FixedText aKeywordsFt;
     143                 :            :     Edit aKeywordsEd;
     144                 :            :     FixedText aDescFt;
     145                 :            :     MultiLineEdit aDescEd;
     146                 :            :     FixedLine aDocinfoGb;
     147                 :            : 
     148                 :            :     CheckBox aTextStyleCB;
     149                 :            :     CheckBox aFrameStyleCB;
     150                 :            :     CheckBox aPageStyleCB;
     151                 :            :     CheckBox aNumStyleCB;
     152                 :            :     CheckBox aMergeStyleCB;
     153                 :            :     PushButton aLoadFilePB;
     154                 :            : 
     155                 :            :     OKButton aOkBt;
     156                 :            :     CancelButton aCancelBt;
     157                 :            :     HelpButton aHelpBt;
     158                 :            :     MoreButton* pMoreBt;
     159                 :            :     Timer aPrevTimer;
     160                 :            :     String aNone;
     161                 :            :     String sLoadTemplate;
     162                 :            : 
     163                 :            :     sal_uInt16 nFlags;
     164                 :            :     SfxDocumentTemplates aTemplates;
     165                 :            :     SfxObjectShellLock xDocShell;
     166                 :            :     SfxNewFileDialog* pAntiImpl;
     167                 :            : 
     168                 :            :     void ClearInfo();
     169                 :            :     DECL_LINK( Update, void * );
     170                 :            : 
     171                 :            :     DECL_LINK( RegionSelect, ListBox * );
     172                 :            :     DECL_LINK(TemplateSelect, void *);
     173                 :            :     DECL_LINK( DoubleClick, ListBox * );
     174                 :            :     void TogglePreview(CheckBox *);
     175                 :            :     DECL_LINK( Expand, void * );
     176                 :            :     DECL_LINK( PreviewClick, CheckBox * );
     177                 :            :     DECL_LINK(LoadFile, void *);
     178                 :            :     sal_uInt16  GetSelectedTemplatePos() const;
     179                 :            : 
     180                 :            : public:
     181                 :            : 
     182                 :            :     SfxNewFileDialog_Impl( SfxNewFileDialog* pAntiImplP, sal_uInt16 nFlags );
     183                 :            :     ~SfxNewFileDialog_Impl();
     184                 :            : 
     185                 :            :         // Returns sal_False if '- No -' is set as a template
     186                 :            :         // Template name can only be obtained if IsTemplate() is TRUE
     187                 :            :         // erfragt werden
     188                 :            :     sal_Bool IsTemplate() const;
     189                 :            :     String GetTemplateFileName() const;
     190                 :            : 
     191                 :            :     sal_uInt16  GetTemplateFlags()const;
     192                 :            :     void    SetTemplateFlags(sal_uInt16 nSet);
     193                 :            : };
     194                 :            : 
     195                 :            : 
     196                 :            : //-------------------------------------------------------------------------
     197                 :            : 
     198                 :          0 : void SfxNewFileDialog_Impl::ClearInfo()
     199                 :            : {
     200         [ #  # ]:          0 :     const String aNo;
     201         [ #  # ]:          0 :     aTitleEd.SetText(aNo);
     202         [ #  # ]:          0 :     aThemaEd.SetText(aNo);
     203         [ #  # ]:          0 :     aKeywordsEd.SetText(aNo);
     204 [ #  # ][ #  # ]:          0 :     aDescEd.SetText(aNo);
     205                 :          0 : }
     206                 :            : 
     207                 :            : //-------------------------------------------------------------------------
     208                 :            : 
     209                 :          0 : IMPL_LINK_NOARG(SfxNewFileDialog_Impl, Update)
     210                 :            : {
     211         [ #  # ]:          0 :     if ( xDocShell.Is() )
     212                 :            :     {
     213         [ #  # ]:          0 :         if ( xDocShell->GetProgress() )
     214                 :          0 :             return sal_False;
     215                 :          0 :         xDocShell.Clear();
     216                 :            :     }
     217                 :            : 
     218                 :          0 :     const sal_uInt16 nEntry = GetSelectedTemplatePos();
     219         [ #  # ]:          0 :     if(!nEntry)
     220                 :            :     {
     221                 :          0 :         ClearInfo();
     222                 :          0 :         aPreviewWin.Invalidate();
     223                 :          0 :         aPreviewWin.SetObjectShell( 0);
     224                 :          0 :         return 0;
     225                 :            :     }
     226                 :            : 
     227 [ #  # ][ #  # ]:          0 :     if ( aPreviewBtn.IsChecked() && (nFlags & SFXWB_PREVIEW) == SFXWB_PREVIEW)
                 [ #  # ]
     228                 :            :     {
     229                 :            : 
     230 [ #  # ][ #  # ]:          0 :         String aFileName = aTemplates.GetPath( aRegionLb.GetSelectEntryPos(), nEntry-1);
     231 [ #  # ][ #  # ]:          0 :         INetURLObject aTestObj( aFileName );
     232         [ #  # ]:          0 :         if( aTestObj.GetProtocol() == INET_PROT_NOT_VALID )
     233                 :            :         {
     234                 :            :             // temp. fix until Templates are managed by UCB compatible service
     235                 :            :             // does NOT work with locally cached components !
     236                 :          0 :             rtl::OUString aTemp;
     237 [ #  # ][ #  # ]:          0 :             utl::LocalFileHelper::ConvertPhysicalNameToURL( aFileName, aTemp );
     238         [ #  # ]:          0 :             aFileName = aTemp;
     239                 :            :         }
     240                 :            : 
     241 [ #  # ][ #  # ]:          0 :         INetURLObject aObj( aFileName );
     242 [ #  # ][ #  # ]:          0 :         for ( SfxObjectShell* pTmp = SfxObjectShell::GetFirst();
                 [ #  # ]
     243                 :            :               pTmp;
     244                 :            :               pTmp = SfxObjectShell::GetNext(*pTmp) )
     245                 :            :         {
     246                 :            :             //! fsys bug op==
     247         [ #  # ]:          0 :             if ( pTmp->GetMedium())
     248                 :            :                 // ??? HasName() MM
     249 [ #  # ][ #  # ]:          0 :                 if( INetURLObject( pTmp->GetMedium()->GetName() ) == aObj )
         [ #  # ][ #  # ]
                 [ #  # ]
     250                 :            :                 {
     251         [ #  # ]:          0 :                     xDocShell = pTmp;
     252                 :          0 :                     break;
     253                 :            :                 }
     254                 :            :         }
     255                 :            : 
     256         [ #  # ]:          0 :         if ( !xDocShell.Is() )
     257                 :            :         {
     258         [ #  # ]:          0 :             Window *pParent = Application::GetDefDialogParent();
     259         [ #  # ]:          0 :             Application::SetDefDialogParent( pAntiImpl );
     260         [ #  # ]:          0 :             SfxErrorContext eEC(ERRCTX_SFX_LOADTEMPLATE,pAntiImpl);
     261         [ #  # ]:          0 :             SfxApplication *pSfxApp = SFX_APP();
     262                 :            :             sal_uIntPtr lErr;
     263 [ #  # ][ #  # ]:          0 :             SfxItemSet* pSet = new SfxAllItemSet( pSfxApp->GetPool() );
     264 [ #  # ][ #  # ]:          0 :             pSet->Put( SfxBoolItem( SID_TEMPLATE, sal_True ) );
                 [ #  # ]
     265 [ #  # ][ #  # ]:          0 :             pSet->Put( SfxBoolItem( SID_PREVIEW, sal_True ) );
                 [ #  # ]
     266         [ #  # ]:          0 :             lErr = pSfxApp->LoadTemplate( xDocShell, aFileName, sal_True, pSet );
     267         [ #  # ]:          0 :             if( lErr )
     268         [ #  # ]:          0 :                 ErrorHandler::HandleError(lErr);
     269         [ #  # ]:          0 :             Application::SetDefDialogParent( pParent );
     270         [ #  # ]:          0 :             if ( !xDocShell.Is() )
     271                 :            :             {
     272         [ #  # ]:          0 :                 aPreviewWin.SetObjectShell( 0 );
     273                 :          0 :                 return sal_False;
     274 [ #  # ][ #  # ]:          0 :             }
     275                 :            :         }
     276                 :            : 
     277 [ #  # ][ #  # ]:          0 :         aPreviewWin.SetObjectShell( xDocShell );
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
                 [ #  # ]
     278                 :            :     }
     279                 :          0 :     return sal_True;
     280                 :            : }
     281                 :            : 
     282                 :            : //-------------------------------------------------------------------------
     283                 :            : 
     284                 :          0 : IMPL_LINK( SfxNewFileDialog_Impl, RegionSelect, ListBox *, pBox )
     285                 :            : {
     286 [ #  # ][ #  # ]:          0 :     if ( xDocShell.Is() && xDocShell->GetProgress() )
         [ #  # ][ #  # ]
     287                 :          0 :         return 0;
     288                 :            : 
     289         [ #  # ]:          0 :     const sal_uInt16 nRegion = pBox->GetSelectEntryPos();
     290 [ #  # ][ #  # ]:          0 :     const sal_uInt16 nCount = aTemplates.GetRegionCount()? aTemplates.GetCount(nRegion): 0;
                 [ #  # ]
     291         [ #  # ]:          0 :     aTemplateLb.SetUpdateMode(sal_False);
     292         [ #  # ]:          0 :     aTemplateLb.Clear();
     293         [ #  # ]:          0 :     String aSel=aRegionLb.GetSelectEntry();
     294         [ #  # ]:          0 :     sal_uInt16 nc=aSel.Search('(');
     295 [ #  # ][ #  # ]:          0 :     if (nc-1&&nc!=STRING_NOTFOUND)
     296         [ #  # ]:          0 :         aSel.Erase(nc-1);
     297 [ #  # ][ #  # ]:          0 :     if (aSel.CompareIgnoreCaseToAscii( SfxResId(STR_STANDARD).toString() )==COMPARE_EQUAL)
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
     298         [ #  # ]:          0 :         aTemplateLb.InsertEntry(aNone);
     299         [ #  # ]:          0 :     for (sal_uInt16 i = 0; i < nCount; ++i)
     300 [ #  # ][ #  # ]:          0 :         aTemplateLb.InsertEntry(aTemplates.GetName(nRegion, i));
     301         [ #  # ]:          0 :     aTemplateLb.SelectEntryPos(0);
     302         [ #  # ]:          0 :     aTemplateLb.SetUpdateMode(sal_True);
     303         [ #  # ]:          0 :     aTemplateLb.Invalidate();
     304         [ #  # ]:          0 :     aTemplateLb.Update();
     305         [ #  # ]:          0 :     TemplateSelect(&aTemplateLb);
     306         [ #  # ]:          0 :     return 0;
     307                 :            : }
     308                 :            : 
     309                 :            : //-------------------------------------------------------------------------
     310                 :            : 
     311                 :          0 : IMPL_LINK_NOARG_INLINE_START(SfxNewFileDialog_Impl, Expand)
     312                 :            : {
     313                 :          0 :     TemplateSelect(&aTemplateLb);
     314                 :          0 :     return 0;
     315                 :            : }
     316                 :          0 : IMPL_LINK_NOARG_INLINE_END(SfxNewFileDialog_Impl, Expand)
     317                 :            : 
     318                 :            : //-------------------------------------------------------------------------
     319                 :            : 
     320                 :          0 : IMPL_LINK( SfxNewFileDialog_Impl, PreviewClick, CheckBox *, pBox )
     321                 :            : {
     322 [ #  # ][ #  # ]:          0 :     if ( xDocShell.Is() && xDocShell->GetProgress() )
                 [ #  # ]
     323                 :          0 :         return 0;
     324                 :            : 
     325                 :          0 :     sal_uInt16 nEntry = GetSelectedTemplatePos();
     326 [ #  # ][ #  # ]:          0 :     if ( nEntry && pBox->IsChecked() )
                 [ #  # ]
     327                 :            :     {
     328         [ #  # ]:          0 :         if(!Update(0))
     329                 :          0 :             aPreviewWin.Invalidate();
     330                 :            :     }
     331                 :            :     else
     332                 :            :     {
     333         [ #  # ]:          0 :         if (xDocShell.Is())
     334                 :          0 :             xDocShell.Clear();
     335                 :          0 :         aPreviewWin.SetObjectShell( 0 );
     336                 :            :     }
     337                 :          0 :     return 0;
     338                 :            : }
     339                 :            : 
     340                 :            : //-------------------------------------------------------------------------
     341                 :            : 
     342                 :          0 : IMPL_LINK_NOARG(SfxNewFileDialog_Impl, TemplateSelect)
     343                 :            : {
     344                 :            :     // Still loading
     345 [ #  # ][ #  # ]:          0 :     if ( xDocShell && xDocShell->GetProgress() )
                 [ #  # ]
     346                 :          0 :         return 0;
     347                 :            : 
     348         [ #  # ]:          0 :     if ( !MORE_BTN(GetState()) )
     349                 :            :         // Dialog is not opened
     350                 :          0 :         return 0;
     351                 :            : 
     352                 :          0 :     aPrevTimer.Start();
     353                 :          0 :     return 0;
     354                 :            : }
     355                 :            : 
     356                 :            : //-------------------------------------------------------------------------
     357                 :            : 
     358                 :          0 : IMPL_LINK_INLINE_START( SfxNewFileDialog_Impl, DoubleClick, ListBox *, pListBox )
     359                 :            : {
     360                 :            :     (void)pListBox;
     361                 :            :     // Still loadning
     362 [ #  # ][ #  # ]:          0 :     if ( !xDocShell.Is() || !xDocShell->GetProgress() )
                 [ #  # ]
     363                 :          0 :         pAntiImpl->EndDialog(RET_OK);
     364                 :          0 :     return 0;
     365                 :            : }
     366                 :          0 : IMPL_LINK_INLINE_END( SfxNewFileDialog_Impl, DoubleClick, ListBox *, pListBox )
     367                 :            : 
     368                 :            : //-------------------------------------------------------------------------
     369                 :            : 
     370                 :          0 : IMPL_LINK_NOARG_INLINE_START(SfxNewFileDialog_Impl, LoadFile)
     371                 :            : {
     372                 :          0 :     pAntiImpl->EndDialog(RET_TEMPLATE_LOAD);
     373                 :          0 :     return 0;
     374                 :            : }
     375                 :          0 : IMPL_LINK_NOARG_INLINE_END(SfxNewFileDialog_Impl, LoadFile)
     376                 :            : //-------------------------------------------------------------------------
     377                 :            : 
     378                 :          0 : sal_uInt16  SfxNewFileDialog_Impl::GetSelectedTemplatePos() const
     379                 :            : {
     380         [ #  # ]:          0 :     sal_uInt16 nEntry=aTemplateLb.GetSelectEntryPos();
     381 [ #  # ][ #  # ]:          0 :     String aSel=aRegionLb.GetSelectEntry().Copy();
                 [ #  # ]
     382         [ #  # ]:          0 :     sal_uInt16 nc=aSel.Search('(');
     383 [ #  # ][ #  # ]:          0 :     if (nc-1&&nc!=STRING_NOTFOUND)
     384         [ #  # ]:          0 :         aSel.Erase(nc-1);
     385 [ #  # ][ #  # ]:          0 :     if (aSel.CompareIgnoreCaseToAscii(SfxResId(STR_STANDARD).toString())!=COMPARE_EQUAL)
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
     386                 :          0 :         nEntry++;
     387 [ #  # ][ #  # ]:          0 :     if (!aTemplateLb.GetSelectEntryCount())
     388                 :          0 :         nEntry=0;
     389         [ #  # ]:          0 :     return nEntry;
     390                 :            : }
     391                 :            : 
     392                 :            : //-------------------------------------------------------------------------
     393                 :            : 
     394                 :          0 : sal_Bool SfxNewFileDialog_Impl::IsTemplate() const
     395                 :            : {
     396                 :          0 :     return GetSelectedTemplatePos()!=0;
     397                 :            : 
     398                 :            : }
     399                 :            : 
     400                 :            : //-------------------------------------------------------------------------
     401                 :            : 
     402                 :          0 : String SfxNewFileDialog_Impl::GetTemplateFileName() const
     403                 :            : {
     404 [ #  # ][ #  # ]:          0 :     if(!IsTemplate() || !aTemplates.GetRegionCount())
                 [ #  # ]
     405                 :          0 :         return String();
     406                 :          0 :     return aTemplates.GetPath(aRegionLb.GetSelectEntryPos(),
     407                 :          0 :                               GetSelectedTemplatePos()-1);
     408                 :            : }
     409                 :            : 
     410                 :            : //-------------------------------------------------------------------------
     411                 :            : 
     412                 :          0 : void AdjustPosSize_Impl(Window *pWin, short nMoveOffset, short nSizeOffset)
     413                 :            : {
     414         [ #  # ]:          0 :     Point aPos(pWin->GetPosPixel());
     415         [ #  # ]:          0 :     Size aSize(pWin->GetSizePixel());
     416                 :          0 :     aPos.X() -= nMoveOffset;
     417                 :          0 :     aSize.Width() += nSizeOffset;
     418         [ #  # ]:          0 :     pWin->SetPosSizePixel(aPos, aSize);
     419                 :          0 : }
     420                 :            : //-------------------------------------------------------------------------
     421                 :          0 : sal_uInt16  SfxNewFileDialog_Impl::GetTemplateFlags()const
     422                 :            : {
     423         [ #  # ]:          0 :     sal_uInt16 nRet = aTextStyleCB.IsChecked() ? SFX_LOAD_TEXT_STYLES : 0;
     424         [ #  # ]:          0 :     if(aFrameStyleCB.IsChecked())
     425                 :          0 :         nRet |= SFX_LOAD_FRAME_STYLES;
     426         [ #  # ]:          0 :     if(aPageStyleCB.IsChecked())
     427                 :          0 :         nRet |= SFX_LOAD_PAGE_STYLES;
     428         [ #  # ]:          0 :     if(aNumStyleCB.IsChecked())
     429                 :          0 :         nRet |= SFX_LOAD_NUM_STYLES;
     430         [ #  # ]:          0 :     if(aMergeStyleCB.IsChecked())
     431                 :          0 :         nRet |= SFX_MERGE_STYLES;
     432                 :          0 :     return nRet;
     433                 :            : }
     434                 :            : //-------------------------------------------------------------------------
     435                 :          0 : void    SfxNewFileDialog_Impl::SetTemplateFlags(sal_uInt16 nSet)
     436                 :            : {
     437                 :          0 :     aTextStyleCB.Check(  0 != (nSet&SFX_LOAD_TEXT_STYLES ));
     438                 :          0 :     aFrameStyleCB.Check( 0 != (nSet&SFX_LOAD_FRAME_STYLES));
     439                 :          0 :     aPageStyleCB.Check(  0 != (nSet&SFX_LOAD_PAGE_STYLES ));
     440                 :          0 :     aNumStyleCB.Check(   0 != (nSet&SFX_LOAD_NUM_STYLES  ));
     441                 :          0 :     aMergeStyleCB.Check( 0 != (nSet&SFX_MERGE_STYLES     ));
     442                 :          0 : }
     443                 :            : 
     444                 :            : //-------------------------------------------------------------------------
     445                 :            : 
     446                 :          0 : SfxNewFileDialog_Impl::SfxNewFileDialog_Impl(
     447                 :            :     SfxNewFileDialog* pAntiImplP, sal_uInt16 nFl)
     448                 :            :     :   aRegionFt( pAntiImplP, SfxResId( FT_REGION ) ),
     449                 :            :         aRegionLb( pAntiImplP, SfxResId( LB_REGION ) ),
     450                 :            :         aTemplateFt( pAntiImplP, SfxResId( FT_TEMPLATE ) ),
     451                 :            :         aTemplateLb( pAntiImplP, SfxResId( LB_TEMPLATE ) ),
     452                 :            :         aPreviewBtn( pAntiImplP, SfxResId( BTN_PREVIEW ) ),
     453                 :            :         aPreviewWin( pAntiImplP, SfxResId( WIN_PREVIEW ) ),
     454                 :            :         aTitleFt( pAntiImplP, SfxResId( FT_TITLE ) ),
     455                 :            :         aTitleEd( pAntiImplP, SfxResId( ED_TITLE ) ),
     456                 :            :         aThemaFt( pAntiImplP, SfxResId( FT_THEMA ) ),
     457                 :            :         aThemaEd( pAntiImplP, SfxResId( ED_THEMA ) ),
     458                 :            :         aKeywordsFt( pAntiImplP, SfxResId( FT_KEYWORDS ) ),
     459                 :            :         aKeywordsEd( pAntiImplP, SfxResId( ED_KEYWORDS ) ),
     460                 :            :         aDescFt( pAntiImplP, SfxResId( FT_DESC ) ),
     461                 :            :         aDescEd( pAntiImplP, SfxResId( ED_DESC ) ),
     462                 :            :         aDocinfoGb( pAntiImplP, SfxResId( GB_DOCINFO ) ),
     463                 :            :         aTextStyleCB( pAntiImplP, SfxResId(  CB_TEXT_STYLE )),
     464                 :            :         aFrameStyleCB( pAntiImplP, SfxResId( CB_FRAME_STYLE )),
     465                 :            :         aPageStyleCB( pAntiImplP, SfxResId(  CB_PAGE_STYLE )),
     466                 :            :         aNumStyleCB( pAntiImplP, SfxResId(   CB_NUM_STYLE  )),
     467                 :            :         aMergeStyleCB( pAntiImplP, SfxResId( CB_MERGE_STYLE )),
     468                 :            :         aLoadFilePB( pAntiImplP, SfxResId(   PB_LOAD_FILE )),
     469                 :            :         aOkBt( pAntiImplP, SfxResId( BT_OK ) ),
     470                 :            :         aCancelBt( pAntiImplP, SfxResId( BT_CANCEL ) ),
     471                 :            :         aHelpBt( pAntiImplP, SfxResId( BT_HELP ) ),
     472         [ #  # ]:          0 :         pMoreBt( new MoreButton( pAntiImplP, SfxResId( BT_MORE ) ) ),
     473                 :            :         aNone(SfxResId(STR_NONE).toString()),
     474                 :            :         sLoadTemplate(SfxResId(STR_LOAD_TEMPLATE).toString()),
     475                 :            :         nFlags(nFl),
     476 [ #  # ][ #  # ]:          0 :         pAntiImpl( pAntiImplP )
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
                 [ #  # ]
     477                 :            : {
     478         [ #  # ]:          0 :     short nMoveOffset = *(short *)pAntiImplP->GetClassRes();
     479         [ #  # ]:          0 :     pAntiImplP->IncrementRes(sizeof(short));
     480         [ #  # ]:          0 :     short nExpandSize= *(short *)pAntiImplP->GetClassRes();
     481         [ #  # ]:          0 :     pAntiImplP->IncrementRes(sizeof(short));
     482         [ #  # ]:          0 :     pAntiImplP->FreeResource();
     483                 :            : 
     484         [ #  # ]:          0 :     if (!nFlags)
     485         [ #  # ]:          0 :         MORE_BTN(Hide());
     486         [ #  # ]:          0 :     else if(SFXWB_LOAD_TEMPLATE == nFlags)
     487                 :            :     {
     488         [ #  # ]:          0 :         aLoadFilePB.SetClickHdl(LINK(this, SfxNewFileDialog_Impl, LoadFile));
     489         [ #  # ]:          0 :         aLoadFilePB.Show();
     490         [ #  # ]:          0 :         aTextStyleCB.Show();
     491         [ #  # ]:          0 :         aFrameStyleCB.Show();
     492         [ #  # ]:          0 :         aPageStyleCB.Show();
     493         [ #  # ]:          0 :         aNumStyleCB.Show();
     494         [ #  # ]:          0 :         aMergeStyleCB.Show();
     495                 :          0 :         Size aSize(pAntiImplP->GetOutputSizePixel());
     496 [ #  # ][ #  # ]:          0 :         Size aTmp(pAntiImplP->LogicToPixel(Size(16, 16), MAP_APPFONT));
                 [ #  # ]
     497                 :          0 :         aSize.Height() += aTmp.Height();
     498         [ #  # ]:          0 :         pAntiImplP->SetOutputSizePixel(aSize);
     499         [ #  # ]:          0 :         pMoreBt->Hide();
     500         [ #  # ]:          0 :         aTextStyleCB.Check();
     501         [ #  # ]:          0 :         pAntiImplP->SetText(sLoadTemplate);
     502                 :            :     }
     503                 :            :     else
     504                 :            :     {
     505         [ #  # ]:          0 :         MORE_BTN(SetClickHdl(LINK(this, SfxNewFileDialog_Impl, Expand)));
     506         [ #  # ]:          0 :         if((nFlags & SFXWB_PREVIEW) == SFXWB_PREVIEW)
     507                 :            :         {
     508         [ #  # ]:          0 :             MORE_BTN(AddWindow(&aPreviewBtn));
     509         [ #  # ]:          0 :             MORE_BTN(AddWindow(&aPreviewWin));
     510         [ #  # ]:          0 :             aPreviewBtn.SetClickHdl(LINK(this, SfxNewFileDialog_Impl, PreviewClick));
     511                 :            :         }
     512                 :            :         else
     513                 :            :         {
     514         [ #  # ]:          0 :             aPreviewBtn.Hide();
     515         [ #  # ]:          0 :             aPreviewWin.Hide();
     516                 :            :             nMoveOffset = (short)pAntiImplP->LogicToPixel(
     517 [ #  # ][ #  # ]:          0 :                 Size(nMoveOffset, nMoveOffset), MAP_APPFONT).Width();
                 [ #  # ]
     518                 :            :             nExpandSize = (short)pAntiImplP->LogicToPixel(
     519 [ #  # ][ #  # ]:          0 :                 Size(nExpandSize, nExpandSize), MAP_APPFONT).Width();
                 [ #  # ]
     520         [ #  # ]:          0 :             AdjustPosSize_Impl(&aTitleFt, nMoveOffset, 0);
     521         [ #  # ]:          0 :             AdjustPosSize_Impl(&aTitleEd, nMoveOffset, nExpandSize);
     522         [ #  # ]:          0 :             AdjustPosSize_Impl(&aThemaFt, nMoveOffset, 0);
     523         [ #  # ]:          0 :             AdjustPosSize_Impl(&aThemaEd, nMoveOffset, nExpandSize);
     524         [ #  # ]:          0 :             AdjustPosSize_Impl(&aKeywordsFt, nMoveOffset, 0);
     525         [ #  # ]:          0 :             AdjustPosSize_Impl(&aKeywordsEd, nMoveOffset, nExpandSize);
     526         [ #  # ]:          0 :             AdjustPosSize_Impl(&aDescFt , nMoveOffset, 0);
     527         [ #  # ]:          0 :             AdjustPosSize_Impl(&aDescEd , nMoveOffset, nExpandSize);
     528         [ #  # ]:          0 :             AdjustPosSize_Impl(&aDocinfoGb, nMoveOffset, nExpandSize);
     529                 :            :         }
     530                 :            :     }
     531                 :            : 
     532                 :          0 :     String &rExtra = pAntiImplP->GetExtraData();
     533 [ #  # ][ #  # ]:          0 :     sal_Int32 nTokCount = comphelper::string::getTokenCount(rExtra, '|');
     534 [ #  # ][ #  # ]:          0 :     if( nTokCount > 0 && nFlags )
     535 [ #  # ][ #  # ]:          0 :         MORE_BTN(SetState(comphelper::string::equals(rExtra.GetToken( 0, '|'), 'Y')));
         [ #  # ][ #  # ]
     536 [ #  # ][ #  # ]:          0 :     if( nTokCount > 1 && nFlags )
     537 [ #  # ][ #  # ]:          0 :         aPreviewBtn.Check(comphelper::string::equals(rExtra.GetToken( 1 ,'|'), 'Y'));
         [ #  # ][ #  # ]
     538                 :            : 
     539         [ #  # ]:          0 :     aTemplateLb.SetSelectHdl(LINK(this, SfxNewFileDialog_Impl, TemplateSelect));
     540         [ #  # ]:          0 :     aTemplateLb.SetDoubleClickHdl(LINK(this, SfxNewFileDialog_Impl, DoubleClick));
     541                 :            : 
     542                 :            :     // update the template configuration if necessary
     543                 :            :     {
     544 [ #  # ][ #  # ]:          0 :         WaitObject aWaitCursor( pAntiImplP->GetParent() );
     545 [ #  # ][ #  # ]:          0 :         aTemplates.Update( sal_True /* be smart */ );
     546                 :            :     }
     547                 :            :     // fill the list boxes
     548         [ #  # ]:          0 :     const sal_uInt16 nCount = aTemplates.GetRegionCount();
     549         [ #  # ]:          0 :     if (nCount)
     550                 :            :     {
     551         [ #  # ]:          0 :         for(sal_uInt16 i = 0; i < nCount; ++i)
     552 [ #  # ][ #  # ]:          0 :             aRegionLb.InsertEntry(aTemplates.GetFullRegionName(i));
                 [ #  # ]
     553         [ #  # ]:          0 :         aRegionLb.SetSelectHdl(LINK(this, SfxNewFileDialog_Impl, RegionSelect));
     554                 :            :     }
     555                 :            : 
     556         [ #  # ]:          0 :     aPrevTimer.SetTimeout( 500 );
     557         [ #  # ]:          0 :     aPrevTimer.SetTimeoutHdl( LINK( this, SfxNewFileDialog_Impl, Update));
     558                 :            : 
     559         [ #  # ]:          0 :     aRegionLb.SelectEntryPos(0);
     560         [ #  # ]:          0 :     RegionSelect(&aRegionLb);
     561                 :          0 : }
     562                 :            : 
     563                 :            : //-------------------------------------------------------------------------
     564                 :            : 
     565 [ #  # ][ #  # ]:          0 : SfxNewFileDialog_Impl::~SfxNewFileDialog_Impl()
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
     566                 :            : {
     567                 :          0 :     String &rExtra = pAntiImpl->GetExtraData();
     568 [ #  # ][ #  # ]:          0 :     rExtra = MORE_BTN(GetState()) ? 'Y' : 'N';
     569         [ #  # ]:          0 :     rExtra += '|';
     570 [ #  # ][ #  # ]:          0 :     rExtra += aPreviewBtn.IsChecked() ? 'Y' : 'N';
                 [ #  # ]
     571                 :            : 
     572 [ #  # ][ #  # ]:          0 :     delete pMoreBt;
     573                 :          0 : }
     574                 :            : //-------------------------------------------------------------------------
     575                 :          0 : SfxNewFileDialog::SfxNewFileDialog(Window *pParent, sal_uInt16 nFlags)
     576         [ #  # ]:          0 :     : SfxModalDialog( pParent, SfxResId( DLG_NEW_FILE ) )
     577                 :            : {
     578 [ #  # ][ #  # ]:          0 :     pImpl = new SfxNewFileDialog_Impl( this, nFlags );
     579                 :          0 : }
     580                 :            : //-------------------------------------------------------------------------
     581                 :          0 : SfxNewFileDialog::~SfxNewFileDialog()
     582                 :            : {
     583 [ #  # ][ #  # ]:          0 :     delete pImpl;
     584         [ #  # ]:          0 : }
     585                 :            : //-------------------------------------------------------------------------
     586                 :          0 : sal_Bool SfxNewFileDialog::IsTemplate() const
     587                 :            : {
     588                 :          0 :     return pImpl->IsTemplate();
     589                 :            : }
     590                 :            : //-------------------------------------------------------------------------
     591                 :          0 : String SfxNewFileDialog::GetTemplateFileName() const
     592                 :            : {
     593                 :          0 :     return pImpl->GetTemplateFileName();
     594                 :            : }
     595                 :            : //-------------------------------------------------------------------------
     596                 :          0 : sal_uInt16 SfxNewFileDialog::GetTemplateFlags()const
     597                 :            : {
     598                 :          0 :     return pImpl->GetTemplateFlags();
     599                 :            : 
     600                 :            : }
     601                 :            : //-------------------------------------------------------------------------
     602                 :          0 : void    SfxNewFileDialog::SetTemplateFlags(sal_uInt16 nSet)
     603                 :            : {
     604                 :          0 :     pImpl->SetTemplateFlags(nSet);
     605                 :          0 : }
     606                 :            : 
     607                 :            : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10