Find the answer to your Linux question:
Results 1 to 9 of 9
Hi All, Anyone up for a challenge I'm trying to find the bug in this damn code that's causing incorrect behavior in LibreOffice (this has been a problem since way ...
  1. #1
    Linux Guru jmadero's Avatar
    Join Date
    Jul 2007
    Location
    California
    Posts
    1,958

    Help Finding/Fixing LibreOffice Bullet Code Bug

    Hi All,

    Anyone up for a challenge

    I'm trying to find the bug in this damn code that's causing incorrect behavior in LibreOffice (this has been a problem since way back in OpenOffice, devs haven't prioritized it so I decided to check it out myself).

    Bug: Type I II III (three separate lines, let auto bullets start), highlight, go to format --> bullets & number. Select 1st column, 2nd row (ie, Uppercase roman, uppercase letters, lowercase roman, lowercase letters, etc...).

    As you can see there is now a weird tab on the III bullet, the first two are fine. The funny thing is EVERY THIRD BULLET is now screwed up.

    Here is the source for outline.cxx, outline.src & outline.hrc (in that order)

    Code:
    /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
    /*************************************************************************
     *
     * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
     * 
     * Copyright 2000, 2010 Oracle and/or its affiliates.
     *
     * OpenOffice.org - a multi-platform office productivity suite
     *
     * This file is part of OpenOffice.org.
     *
     * OpenOffice.org is free software: you can redistribute it and/or modify
     * it under the terms of the GNU Lesser General Public License version 3
     * only, as published by the Free Software Foundation.
     *
     * OpenOffice.org is distributed in the hope that it will be useful,
     * but WITHOUT ANY WARRANTY; without even the implied warranty of
     * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
     * GNU Lesser General Public License version 3 for more details
     * (a copy is included in the LICENSE file that accompanied this code).
     *
     * You should have received a copy of the GNU Lesser General Public License
     * version 3 along with OpenOffice.org.  If not, see
     * <http://www.openoffice.org/license.html>
     * for a copy of the LGPLv3 License.
     *
     ************************************************************************/
    
    // MARKER(update_precomp.py): autogen include statement, do not remove
    #include "precompiled_sw.hxx"
    #ifdef SW_DLLIMPLEMENTATION
    #undef SW_DLLIMPLEMENTATION
    #endif
    #include <hintids.hxx>
    #include <tools/shl.hxx>
    #include <vcl/menu.hxx>
    #include <vcl/msgbox.hxx>
    #include <sfx2/tabdlg.hxx>
    #include <editeng/brshitem.hxx>
    #include <unotools/configmgr.hxx>
    #include <SwStyleNameMapper.hxx>
    
    #ifndef _NUM_HXX //autogen
    #define USE_NUMTABPAGES
    #include <num.hxx>
    #endif
    #include <view.hxx>
    #include <docsh.hxx>
    #include <uitool.hxx>
    #include <wrtsh.hxx>
    #include <swmodule.hxx>
    #include <fmtcol.hxx>
    #include <outline.hxx>
    #include <uinums.hxx>
    #include <poolfmt.hxx>
    #include <shellres.hxx>
    #include <svl/style.hxx>
    #include <charfmt.hxx>
    #include <docstyle.hxx>
    #include <viewopt.hxx>
    #include <svtools/ctrlbox.hxx>
    #include <helpid.h>
    #include <globals.hrc>		// fuer Vorlagenname 'keins'
    #include <misc.hrc>
    #include <outline.hrc>
    #include <paratr.hxx>
    
    #include <unomid.h>
    
    #include <IDocumentOutlineNodes.hxx>
    #include <app.hrc>
    
    #ifndef _COM_SUN_STAR_ACCESSIBILITY_ACCESSIBLEROLE_HPP_
    #include <com/sun/star/accessibility/AccessibleRole.hpp>
    #endif
    
    using namespace ::com::sun::star;
    
    DBG_NAME(outlinehdl)
    
    class SwNumNamesDlg: public ModalDialog
    {
        FixedLine    aFormFL;
        Edit         aFormEdit;
        ListBox      aFormBox;
        OKButton     aOKBtn;
        CancelButton aCancelBtn;
        HelpButton   aHelpBtn;
    
        DECL_LINK( ModifyHdl, Edit * );
        DECL_LINK( SelectHdl, ListBox * );
        DECL_LINK( DoubleClickHdl, ListBox * );
    
    public:
        SwNumNamesDlg(Window *pParent);
        ~SwNumNamesDlg();
        void SetUserNames(const String *pList[]);
        String GetName() const { return aFormEdit.GetText(); }
        sal_uInt16 GetCurEntryPos() const { return aFormBox.GetSelectEntryPos(); }
    };
    
    /*------------------------------------------------------------------------
     Beschreibung:  selektierten Eintrag merken
    ------------------------------------------------------------------------*/
    IMPL_LINK_INLINE_START( SwNumNamesDlg, SelectHdl, ListBox *, pBox )
    {
        aFormEdit.SetText(pBox->GetSelectEntry());
        aFormEdit.SetSelection(Selection(0, SELECTION_MAX));
        return 0;
    }
    IMPL_LINK_INLINE_END( SwNumNamesDlg, SelectHdl, ListBox *, pBox )
    
    /*------------------------------------------------------------------------
     Beschreibung:  Setzen der vom Benutzer vergebenen Namen
     Parameter:     Liste der vom Benutzer vergebenen Namen;
                    nicht vom Benutzer benannte Positionen sind 0.
    ------------------------------------------------------------------------*/
    void SwNumNamesDlg::SetUserNames(const String *pList[])
    {
        sal_uInt16 nSelect = 0;
        for(sal_uInt16 i = 0; i < SwBaseNumRules::nMaxRules; ++i)
        {
            if(pList[i])
            {
                aFormBox.RemoveEntry(i);
                aFormBox.InsertEntry(*pList[i], i);
                if(i == nSelect && nSelect < SwBaseNumRules::nMaxRules)
                    nSelect++;
            }
        }
        aFormBox.SelectEntryPos(nSelect);
        SelectHdl(&aFormBox);
    }
    
    /*------------------------------------------------------------------------
     Beschreibung:  OK-Button freischalten, wenn Text im Edit steht.
    ------------------------------------------------------------------------*/
    IMPL_LINK_INLINE_START( SwNumNamesDlg, ModifyHdl, Edit *, pBox )
    {
        aOKBtn.Enable(0 != pBox->GetText().Len());
        return 0;
    }
    IMPL_LINK_INLINE_END( SwNumNamesDlg, ModifyHdl, Edit *, pBox )
    
    /*------------------------------------------------------------------------
     Beschreibung:  DoubleClickHdl
    ------------------------------------------------------------------------*/
    IMPL_LINK_INLINE_START( SwNumNamesDlg, DoubleClickHdl, ListBox *, EMPTYARG )
    {
        EndDialog(RET_OK);
        return 0;
    }
    IMPL_LINK_INLINE_END( SwNumNamesDlg, DoubleClickHdl, ListBox *, EMPTYARG )
    
    SwNumNamesDlg::SwNumNamesDlg(Window *pParent)
        : ModalDialog(pParent, SW_RES(DLG_NUM_NAMES)),
        aFormFL(this, SW_RES(FL_FORM)),
        aFormEdit(this, SW_RES(ED_FORM)),
        aFormBox(this, SW_RES(LB_FORM)),
        aOKBtn(this, SW_RES(BT_OK)),
        aCancelBtn(this, SW_RES(BT_CANCEL)),
        aHelpBtn(this, SW_RES(BT_HELP))
    {
        FreeResource();
        aFormEdit.SetModifyHdl(LINK(this, SwNumNamesDlg, ModifyHdl));
        aFormBox.SetSelectHdl(LINK(this, SwNumNamesDlg, SelectHdl));
        aFormBox.SetDoubleClickHdl(LINK(this, SwNumNamesDlg, DoubleClickHdl));
        SelectHdl(&aFormBox);
    }
    
    SwNumNamesDlg::~SwNumNamesDlg() {}
    
    sal_uInt16 lcl_BitToLevel(sal_uInt16 nActLevel)
    {
        sal_uInt16 nTmp = nActLevel;
        sal_uInt16 nTmpLevel = 0;
        while( 0 != (nTmp >>= 1) )
            nTmpLevel++;
        return nTmpLevel;
    }
    
    sal_uInt16 SwOutlineTabDialog::nNumLevel = 1;
    SwOutlineTabDialog::SwOutlineTabDialog(Window* pParent,
                        const SfxItemSet* pSwItemSet,
                        SwWrtShell &rSh) :
                                        //der UserString wird danach richtig gesetzt
            SfxTabDialog(pParent, SW_RES(DLG_TAB_OUTLINE), pSwItemSet, sal_False, &aEmptyStr),
            aNullStr(C2S("____")),
            aFormMenu(SW_RES(MN_FORM)),
            rWrtSh(rSh),
            pChapterNumRules(SW_MOD()->GetChapterNumRules()),
            bModified(rWrtSh.IsModified())
    {
        // --> OD 2008-04-14 #outlinelevel#
        SetText( SW_RES( STR_OUTLINE_NUMBERING ) );
        // <--
        PushButton* pUserButton = GetUserButton();
        pUserButton->SetText(SW_RES(ST_FORM));
        pUserButton->SetHelpId(HID_OUTLINE_FORM);
        pUserButton->SetClickHdl(LINK(this, SwOutlineTabDialog, FormHdl));
        pUserButton->SetAccessibleRole( com::sun::star::accessibility::AccessibleRole::BUTTON_MENU );
    
        FreeResource();
        pNumRule = new SwNumRule( *rSh.GetOutlineNumRule() );
        GetCancelButton().SetClickHdl(LINK(this, SwOutlineTabDialog, CancelHdl));
    
        AddTabPage(TP_NUM_POSITION	 , &SwNumPositionTabPage::Create, 0);
        AddTabPage(TP_OUTLINE_NUM	 , &SwOutlineSettingsTabPage::Create, 0);
    
        String sHeadline;
        sal_uInt16 i;
    
        for( i = 0; i < MAXLEVEL; ++i )
        {
            // wurde die Vorlage noch nicht angelegt, dann ist sie noch an dieserPosition
            if( !rWrtSh.GetParaStyle( sHeadline =
                SwStyleNameMapper::GetUIName( static_cast< sal_uInt16 >(RES_POOLCOLL_HEADLINE1 + i),
                                              sHeadline )) )
                aCollNames[i] = sHeadline;
        }
    
        // Erfragen der Gliederungsebenen der Textvorlagen
        const sal_uInt16 nCount = rWrtSh.GetTxtFmtCollCount();
        for(i = 0; i < nCount; ++i )
        {
            SwTxtFmtColl &rTxtColl = rWrtSh.GetTxtFmtColl(i);
            if(!rTxtColl.IsDefault())
            {
                //->added by zhaojianwei
                if(rTxtColl.IsAssignedToListLevelOfOutlineStyle())
                {
                    int nOutLevel = rTxtColl.GetAssignedOutlineStyleLevel();
                    aCollNames[ nOutLevel ] = rTxtColl.GetName();
                }
                //<-end
            }
        }
    }
    
    SwOutlineTabDialog::~SwOutlineTabDialog()
    {
        delete pNumRule;
    }
    
    void 	SwOutlineTabDialog::PageCreated(sal_uInt16 nPageId, SfxTabPage& rPage)
    {
        switch ( nPageId )
        {
            case TP_NUM_POSITION:
                    ((SwNumPositionTabPage&)rPage).SetWrtShell(&rWrtSh);
                    ((SwNumPositionTabPage&)rPage).SetOutlineTabDialog(this);
            break;
            case TP_OUTLINE_NUM:
                    ((SwOutlineSettingsTabPage&)rPage).SetWrtShell(&rWrtSh);
            break;
        }
    }
    
    IMPL_LINK( SwOutlineTabDialog, CancelHdl, Button *, EMPTYARG )
    {
        if (!bModified)
            rWrtSh.ResetModified();
        EndDialog(RET_CANCEL);
        return 0;
    }
    
    IMPL_LINK( SwOutlineTabDialog, FormHdl, Button *, pBtn )
    {
        //PopupMenu auffuellen
        for( sal_uInt16 i = 0; i < SwChapterNumRules::nMaxRules; ++i )
        {
            const SwNumRulesWithName *pRules = pChapterNumRules->GetRules(i);
            if( pRules )
                aFormMenu.SetItemText(i + MN_FORMBASE, pRules->GetName());
        }
        aFormMenu.SetSelectHdl(LINK(this, SwOutlineTabDialog, MenuSelectHdl));
        aFormMenu.Execute(pBtn, Rectangle(Point(0,0), pBtn->GetSizePixel()), POPUPMENU_EXECUTE_DOWN);
        return 0;
    }
    
    IMPL_LINK( SwOutlineTabDialog, MenuSelectHdl, Menu *, pMenu )
    {
        sal_uInt8 nLevelNo = 0;
        switch(pMenu->GetCurItemId())
        {
            case MN_FORM1: nLevelNo = 1;	break;
            case MN_FORM2: nLevelNo = 2;	break;
            case MN_FORM3: nLevelNo = 3;	break;
            case MN_FORM4: nLevelNo = 4;	break;
            case MN_FORM5: nLevelNo = 5;	break;
            case MN_FORM6: nLevelNo = 6;	break;
            case MN_FORM7: nLevelNo = 7;	break;
            case MN_FORM8: nLevelNo = 8;	break;
            case MN_FORM9: nLevelNo = 9;	break;
    
            case MN_SAVE:
            {
                SwNumNamesDlg *pDlg = new SwNumNamesDlg(this);
                const String *aStrArr[SwChapterNumRules::nMaxRules];
                for(sal_uInt16 i = 0; i < SwChapterNumRules::nMaxRules; ++i)
                {
                    const SwNumRulesWithName *pRules = pChapterNumRules->GetRules(i);
                    if(pRules)
                        aStrArr[i] = &pRules->GetName();
                    else
                        aStrArr[i] = 0;
                }
                pDlg->SetUserNames(aStrArr);
                if(RET_OK == pDlg->Execute())
                {
                    const String aName(pDlg->GetName());
                    pChapterNumRules->ApplyNumRules( SwNumRulesWithName(
                            *pNumRule, aName ), pDlg->GetCurEntryPos() );
                    pMenu->SetItemText(
                            pDlg->GetCurEntryPos() + MN_FORMBASE, aName);
                }
                delete pDlg;
                return 0;
    
            }
    
        }
        if( nLevelNo-- )
        {
            const SwNumRulesWithName *pRules = pChapterNumRules->GetRules( nLevelNo );
            if( pRules )
            {
                pRules->MakeNumRule( rWrtSh, *pNumRule );
                pNumRule->SetRuleType( OUTLINE_RULE );
            }
            else
                *pNumRule = *rWrtSh.GetOutlineNumRule();
        }
    
        sal_uInt16	nPageId = GetCurPageId();
        SfxTabPage*	pPage = GetTabPage( nPageId );
        pPage->Reset(*GetOutputItemSet());
    
        return 0;
    }
    
    sal_uInt16 	SwOutlineTabDialog::GetLevel(const String &rFmtName) const
    {
        for(sal_uInt16 i = 0; i < MAXLEVEL; ++i)
        {
            if(aCollNames[i] == rFmtName)
                return i;
        }
        return MAXLEVEL;//NO_NUMBERING;	//#outline level,zhaojianwei
    
    }
    
    short SwOutlineTabDialog::Ok()
    {
        SfxTabDialog::Ok();
        // bei allen erzeugten Vorlagen die Ebenen setzen, muss
        // geschehen, um evtl. aufgehobene Zuordnungen
        // auch wieder zu loeschen
    
        // --> OD 2006-12-11 #130443#
        // encapsulate changes into a action to avoid effects on the current cursor
        // position during the changes.
        rWrtSh.StartAction();
        // <--
    
        const SwNumRule * pOutlineRule = rWrtSh.GetOutlineNumRule();
    
        sal_uInt16 i, nCount = rWrtSh.GetTxtFmtCollCount();
        for( i = 0; i < nCount; ++i )
        {
            SwTxtFmtColl &rTxtColl = rWrtSh.GetTxtFmtColl(i);
            if( !rTxtColl.IsDefault() )
            {
    
                const SfxPoolItem & rItem =
                    rTxtColl.GetFmtAttr(RES_PARATR_NUMRULE, sal_False);
    
               if ((sal_uInt8)GetLevel(rTxtColl.GetName()) == MAXLEVEL) //add by zhaojianwei
                {
                    if(rTxtColl.IsAssignedToListLevelOfOutlineStyle())
                    {
                        rTxtColl.DeleteAssignmentToListLevelOfOutlineStyle();
                    }
                    if (static_cast<const SwNumRuleItem &>(rItem).GetValue() ==
                        pOutlineRule->GetName())
                    {
                        rTxtColl.ResetFmtAttr(RES_PARATR_NUMRULE);
                    }
                }
                else
                {
                    rTxtColl.AssignToListLevelOfOutlineStyle(GetLevel(rTxtColl.GetName()));	
    
                    if (static_cast<const SwNumRuleItem &>(rItem).GetValue() !=
                        pOutlineRule->GetName())
                    {
                        SwNumRuleItem aItem(pOutlineRule->GetName());
                        rTxtColl.SetFmtAttr(aItem);
                    }
                }							//<-end,zhaojianwei
            }
        }
    
        for(i = 0; i < MAXLEVEL; ++i )
        {
            String sHeadline;
            ::SwStyleNameMapper::FillUIName( static_cast< sal_uInt16 >(RES_POOLCOLL_HEADLINE1 + i),
                                             sHeadline );
            SwTxtFmtColl* pColl = rWrtSh.FindTxtFmtCollByName( sHeadline );
            if( !pColl )
            {
                if(aCollNames[i] != sHeadline)//->added by zhaojianwei
                {
                    SwTxtFmtColl* pTxtColl = rWrtSh.GetTxtCollFromPool(
                        static_cast< sal_uInt16 >(RES_POOLCOLL_HEADLINE1 + i) );
                    pTxtColl->DeleteAssignmentToListLevelOfOutlineStyle();	
                    pTxtColl->ResetFmtAttr(RES_PARATR_NUMRULE);
    
                    if( aCollNames[i].Len() )
                    {
                        pTxtColl = rWrtSh.GetParaStyle(
                                    aCollNames[i], SwWrtShell::GETSTYLE_CREATESOME);
                        if(pTxtColl)
                        {
                            pTxtColl->AssignToListLevelOfOutlineStyle(i);	
                            SwNumRuleItem aItem(pOutlineRule->GetName());
                            pTxtColl->SetFmtAttr(aItem);
                        }
                    }
                }//<--end,zhaojianwei
            }
        }
    
        rWrtSh.SetOutlineNumRule( *pNumRule);
    
        // --> OD 2006-12-11 #130443#
        rWrtSh.EndAction();
        // <--
    
        return RET_OK;
    }
    
    SwOutlineSettingsTabPage::SwOutlineSettingsTabPage(Window* pParent, const SfxItemSet& rSet) :
        SfxTabPage(pParent, SW_RES(TP_OUTLINE_NUM), rSet),
        aLevelFL(       this, SW_RES(FL_LEVEL    )),
        aLevelLB(       this, SW_RES(LB_LEVEL   )),
        aNumberFL(this, SW_RES(FL_NUMBER)),
        aCollLbl(this, SW_RES(FT_COLL)),
        aCollBox(this, SW_RES(LB_COLL)),
        aNumberLbl(this, SW_RES(FT_NUMBER)),
        aNumberBox(this, SW_RES(LB_NUMBER), INSERT_NUM_TYPE_NO_NUMBERING|INSERT_NUM_EXTENDED_TYPES),
        aCharFmtFT(this, SW_RES(FT_CHARFMT)),
        aCharFmtLB(this, SW_RES(LB_CHARFMT)),
        aAllLevelFT(	this, SW_RES(FT_ALL_LEVEL)),
        aAllLevelNF(	this, SW_RES(NF_ALL_LEVEL)),
        aDelim(this, SW_RES(FT_DELIM)),
        aPrefixFT(this, SW_RES(FT_PREFIX)),
        aPrefixED(this, SW_RES(ED_PREFIX)),
        aSuffixFT(this, SW_RES(FT_SUFFIX)),
        aSuffixED(this, SW_RES(ED_SUFFIX)),
        aStartLbl(this, SW_RES(FT_START)),
        aStartEdit(this, SW_RES(ED_START)),
        aPreviewWIN(    this, SW_RES(WIN_PREVIEW )),
    
        aNoFmtName(SW_RES(ST_NO_COLL)),
        pSh(0),
        pCollNames(0),
        nActLevel(1)
    {
        FreeResource();
        SetExchangeSupport();
    
        aCollBox.InsertEntry(aNoFmtName);
        aLevelLB.SetSelectHdl(LINK(this, 	SwOutlineSettingsTabPage, LevelHdl));
        aAllLevelNF.SetModifyHdl(LINK(this, SwOutlineSettingsTabPage, ToggleComplete));
        aCollBox.SetSelectHdl(LINK(this, 	SwOutlineSettingsTabPage, CollSelect));
        aCollBox.SetGetFocusHdl(LINK(this, 	SwOutlineSettingsTabPage, CollSelectGetFocus));
        aNumberBox.SetSelectHdl(LINK(this, 	SwOutlineSettingsTabPage, NumberSelect));
        aPrefixED.SetModifyHdl(LINK(this, 	SwOutlineSettingsTabPage, DelimModify));
        aSuffixED.SetModifyHdl(LINK(this, 	SwOutlineSettingsTabPage, DelimModify));
        aStartEdit.SetModifyHdl(LINK(this, 	SwOutlineSettingsTabPage, StartModified));
        aCharFmtLB.SetSelectHdl(LINK(this, 	SwOutlineSettingsTabPage, CharFmtHdl));
    
    }
    
    void   	SwOutlineSettingsTabPage::Update()
    {
            // falls eine Vorlage fuer diese Ebene bereits selektiert wurde,
            // diese in der ListBox auswaehlean
        aCollBox.Enable(USHRT_MAX != nActLevel);
        if(USHRT_MAX == nActLevel)
        {
            sal_Bool bSamePrefix = sal_True;
            sal_Bool bSameSuffix = sal_True;
            sal_Bool bSameType = sal_True;
            sal_Bool bSameComplete = sal_True;
            sal_Bool bSameStart = sal_True;
            sal_Bool bSameCharFmt = sal_True;
    
            const SwNumFmt* aNumFmtArr[MAXLEVEL];
            const SwCharFmt* pFirstFmt = 0;
    
            for(sal_uInt16 i = 0; i < MAXLEVEL; i++)
            {
    
                aNumFmtArr[ i ] = &pNumRule->Get(i);
                if(i == 0)
                    pFirstFmt = aNumFmtArr[i]->GetCharFmt();
                else
                {
                    bSameType 	&= aNumFmtArr[i]->GetNumberingType() == aNumFmtArr[0]->GetNumberingType();
                    bSameStart	&= aNumFmtArr[i]->GetStart() == aNumFmtArr[0]->GetStart();
                    bSamePrefix &= aNumFmtArr[i]->GetPrefix() == aNumFmtArr[0]->GetPrefix();
                    bSameSuffix &= aNumFmtArr[i]->GetSuffix() == aNumFmtArr[0]->GetSuffix();
                    bSameComplete &= aNumFmtArr[i]->GetIncludeUpperLevels() == aNumFmtArr[0]->GetIncludeUpperLevels();
                    const SwCharFmt* pFmt = aNumFmtArr[i]->GetCharFmt();
                    bSameCharFmt &= 	(!pFirstFmt && !pFmt)
                                        || (pFirstFmt && pFmt && pFmt->GetName() == pFirstFmt->GetName());
                }
            }
            CheckForStartValue_Impl(aNumFmtArr[0]->GetNumberingType());
            if(bSameType)
                aNumberBox.SelectNumberingType( aNumFmtArr[0]->GetNumberingType() );
            else
                aNumberBox.SetNoSelection();
            if(bSameStart)
                aStartEdit.SetValue(aNumFmtArr[0]->GetStart());
            else
                aStartEdit.SetText(aEmptyStr);
            if(bSamePrefix)
                aPrefixED.SetText(aNumFmtArr[0]->GetPrefix());
            else
                aPrefixED.SetText(aEmptyStr);
            if(bSameSuffix)
                aSuffixED.SetText(aNumFmtArr[0]->GetSuffix());
            else
                aSuffixED.SetText(aEmptyStr);
    
            if(bSameCharFmt)
            {
                if(pFirstFmt)
                    aCharFmtLB.SelectEntry(pFirstFmt->GetName());
                else
                    aCharFmtLB.SelectEntry( ViewShell::GetShellRes()->aStrNone );
            }
            else
                aCharFmtLB.SetNoSelection();
    
            aAllLevelFT.Enable(sal_True);
            aAllLevelNF.Enable(sal_True);
            aAllLevelNF.SetMax(MAXLEVEL);
            if(bSameComplete)
            {
                aAllLevelNF.SetValue(aNumFmtArr[0]->GetIncludeUpperLevels());
            }
            else
            {
                aAllLevelNF.SetText(aEmptyStr);
            }
        }
        else
        {
            sal_uInt16 nTmpLevel = lcl_BitToLevel(nActLevel);
            String aColl(pCollNames[nTmpLevel]);
            if(aColl.Len())
                aCollBox.SelectEntry(aColl);
            else
                aCollBox.SelectEntry(aNoFmtName);
            const SwNumFmt &rFmt = pNumRule->Get(nTmpLevel);
    
            aNumberBox.SelectNumberingType( rFmt.GetNumberingType() );
            aPrefixED.SetText(rFmt.GetPrefix());
            aSuffixED.SetText(rFmt.GetSuffix());
            const SwCharFmt* pFmt = rFmt.GetCharFmt();
            if(pFmt)
                aCharFmtLB.SelectEntry(pFmt->GetName());
            else
                aCharFmtLB.SelectEntry( ViewShell::GetShellRes()->aStrNone );
    
            if(nTmpLevel)
            {
                aAllLevelFT.Enable(sal_True);
                aAllLevelNF.Enable(sal_True);
                aAllLevelNF.SetMax(nTmpLevel + 1);
                aAllLevelNF.SetValue(rFmt.GetIncludeUpperLevels());
            }
            else
            {
                aAllLevelNF.SetText(aEmptyStr);
                aAllLevelNF.Enable(sal_False);
                aAllLevelFT.Enable(sal_False);
            }
            CheckForStartValue_Impl(rFmt.GetNumberingType());
            aStartEdit.SetValue( rFmt.GetStart() );
        }
        SetModified();
    }
    
    IMPL_LINK( SwOutlineSettingsTabPage, LevelHdl, ListBox *, pBox )
    {
        nActLevel = 0;
        if(pBox->IsEntryPosSelected( MAXLEVEL ))
        {
            nActLevel = 0xFFFF;
        }
        else
        {
            sal_uInt16 nMask = 1;
            for( sal_uInt16 i = 0; i < MAXLEVEL; i++ )
            {
                if(pBox->IsEntryPosSelected( i ))
                    nActLevel |= nMask;
                nMask <<= 1;
            }
        }
        Update();
        return 0;
    }
    
    IMPL_LINK( SwOutlineSettingsTabPage, ToggleComplete, NumericField *, pFld )
    {
        sal_uInt16 nMask = 1;
        for(sal_uInt16 i = 0; i < MAXLEVEL; i++)
        {
            if(nActLevel & nMask)
            {
                SwNumFmt aNumFmt(pNumRule->Get(i));
                aNumFmt.SetIncludeUpperLevels( Min( (sal_uInt8)pFld->GetValue(),
                                                    (sal_uInt8)(i + 1)) );
                pNumRule->Set(i, aNumFmt);
            }
            nMask <<= 1;
        }
        SetModified();
        return 0;
    }
    
    IMPL_LINK( SwOutlineSettingsTabPage, CollSelect, ListBox *, pBox )
    {
        sal_uInt8 i;
    
        const String aCollName(pBox->GetSelectEntry());
        //0xFFFF darf hier nicht sein (disable)
        sal_uInt16 nTmpLevel = lcl_BitToLevel(nActLevel);
        String sOldName( pCollNames[nTmpLevel] );
    
        for( i = 0; i < MAXLEVEL; ++i)
            pCollNames[i] = aSaveCollNames[i];
    
        if(aCollName == aNoFmtName)
            pCollNames[nTmpLevel] = aEmptyStr;
        else
        {
            pCollNames[nTmpLevel] = aCollName;
                    // wird die Vorlage bereits verwendet ?
            for( i = 0; i < MAXLEVEL; ++i)
                if(i != nTmpLevel && pCollNames[i] == aCollName )
                    pCollNames[i] = aEmptyStr;
        }
    
        // search the oldname and put it into the current entries
        if( sOldName.Len() )
            for( i = 0; i < MAXLEVEL; ++i)
                if( aSaveCollNames[ i ] == sOldName && i != nTmpLevel &&
                    !pCollNames[ i ].Len() )
                {
                    sal_uInt8 n;
                    for( n = 0; n < MAXLEVEL; ++n )
                        if( pCollNames[ n ] == sOldName )
                            break;
    
                    if( MAXLEVEL == n )
                        // it was a outline leveld name and the current entries is zero.
                        pCollNames[ i ] = sOldName;
                }
    
        SetModified();
        return 0;
    }
    
    IMPL_LINK( SwOutlineSettingsTabPage, CollSelectGetFocus, ListBox *, EMPTYARG )
    {
        for( sal_uInt8 i = 0; i < MAXLEVEL; ++i)
            aSaveCollNames[i] =  pCollNames[i];
        return 0;
    }
    
    IMPL_LINK( SwOutlineSettingsTabPage, NumberSelect, SwNumberingTypeListBox *, pBox )
    {
        sal_uInt16 nMask = 1;
        sal_Int16 nNumberType = pBox->GetSelectedNumberingType();
        for(sal_uInt16 i = 0; i < MAXLEVEL; i++)
        {
            if(nActLevel & nMask)
            {
                SwNumFmt aNumFmt(pNumRule->Get(i));
                aNumFmt.SetNumberingType(nNumberType);
                pNumRule->Set(i, aNumFmt);
                CheckForStartValue_Impl(nNumberType);
            }
            nMask <<= 1;
        }
        SetModified();
        return 0;
    }
    
    IMPL_LINK( SwOutlineSettingsTabPage, DelimModify, Edit *, EMPTYARG )
    {
        sal_uInt16 nMask = 1;
        for(sal_uInt16 i = 0; i < MAXLEVEL; i++)
        {
            if(nActLevel & nMask)
            {
                SwNumFmt aNumFmt(pNumRule->Get(i));
                aNumFmt.SetPrefix( aPrefixED.GetText() );
                aNumFmt.SetSuffix( aSuffixED.GetText() );
                pNumRule->Set(i, aNumFmt);
            }
            nMask <<= 1;
        }
        SetModified();
        return 0;
    }
    
    IMPL_LINK( SwOutlineSettingsTabPage, StartModified, NumericField *, pFld )
    {
        sal_uInt16 nMask = 1;
        for(sal_uInt16 i = 0; i < MAXLEVEL; i++)
        {
            if(nActLevel & nMask)
            {
                SwNumFmt aNumFmt(pNumRule->Get(i));
                aNumFmt.SetStart( (sal_uInt16)pFld->GetValue() );
                pNumRule->Set(i, aNumFmt);
            }
            nMask <<= 1;
        }
        SetModified();
        return 0;
    }
    
    IMPL_LINK( SwOutlineSettingsTabPage, CharFmtHdl, ListBox *, EMPTYARG )
    {
        String sEntry = aCharFmtLB.GetSelectEntry();
        sal_uInt16 nMask = 1;
        sal_Bool bFormatNone = sEntry == ViewShell::GetShellRes()->aStrNone;
        SwCharFmt* pFmt = 0;
        if(!bFormatNone)
        {
            sal_uInt16 nChCount = pSh->GetCharFmtCount();
            for(sal_uInt16 i = 0; i < nChCount; i++)
            {
                SwCharFmt& rChFmt = pSh->GetCharFmt(i);
                if(rChFmt.GetName() == sEntry)
                {
                    pFmt = &rChFmt;
                    break;
                }
            }
            if(!pFmt)
            {
                SfxStyleSheetBasePool* pPool = pSh->GetView().GetDocShell()->GetStyleSheetPool();
                SfxStyleSheetBase* pBase;
                pBase = pPool->Find(sEntry, SFX_STYLE_FAMILY_CHAR);
                if(!pBase)
                    pBase = &pPool->Make(sEntry, SFX_STYLE_FAMILY_PAGE);
                pFmt = ((SwDocStyleSheet*)pBase)->GetCharFmt();
    
            }
        }
    
        for(sal_uInt16 i = 0; i < MAXLEVEL; i++)
        {
            if(nActLevel & nMask)
            {
                SwNumFmt aNumFmt(pNumRule->Get(i));
                if(bFormatNone)
                    aNumFmt.SetCharFmt(0);
                else
                    aNumFmt.SetCharFmt(pFmt);
                pNumRule->Set(i, aNumFmt);
            }
            nMask <<= 1;
        }
        return RET_OK;
    }
    
    SwOutlineSettingsTabPage::~SwOutlineSettingsTabPage()
    {
    }
    
    void SwOutlineSettingsTabPage::SetWrtShell(SwWrtShell* pShell)
    {
        pSh = pShell;
        // Erfragen der NumRules dieses Dokumentes
        pNumRule = ((SwOutlineTabDialog*)GetTabDialog())->GetNumRule();
        pCollNames = ((SwOutlineTabDialog*)GetTabDialog())->GetCollNames();
    
        aPreviewWIN.SetNumRule(pNumRule);
        aPreviewWIN.SetOutlineNames(pCollNames);
        // Startwert setzen - nActLevel muss hier 1 sein
        sal_uInt16 nTmpLevel = lcl_BitToLevel(nActLevel);
        const SwNumFmt& rNumFmt = pNumRule->Get( nTmpLevel );
        aStartEdit.SetValue( rNumFmt.GetStart() );
    
        // Poolformate fuer Ueberschriften anlegen
        String sStr;
        sal_uInt16 i;
        for( i = 0; i < MAXLEVEL; ++i )
        {
            aCollBox.InsertEntry( SwStyleNameMapper::GetUIName(
                                        static_cast< sal_uInt16 >(RES_POOLCOLL_HEADLINE1 + i), aEmptyStr ));
            aLevelLB.InsertEntry( String::CreateFromInt32(i + 1) );
        }
        sStr.AssignAscii( RTL_CONSTASCII_STRINGPARAM( "1 - " ));
        sStr += String::CreateFromInt32(MAXLEVEL);
        aLevelLB.InsertEntry( sStr );
    
        // Erfragen der Gliederungsebenen der Textvorlagen
        const sal_uInt16 nCount = pSh->GetTxtFmtCollCount();
        for( i = 0; i < nCount; ++i )
        {
            SwTxtFmtColl &rTxtColl = pSh->GetTxtFmtColl(i);
            if(!rTxtColl.IsDefault())
            {
                sStr = rTxtColl.GetName();
                if(LISTBOX_ENTRY_NOTFOUND == aCollBox.GetEntryPos( sStr ))
                    aCollBox.InsertEntry( sStr );
            }
        }
    
        aNumberBox.SelectNumberingType(rNumFmt.GetNumberingType());
        sal_uInt16 nOutlinePos = pSh->GetOutlinePos(MAXLEVEL);
        sal_uInt16 nTmp = 0;
        if(nOutlinePos != USHRT_MAX)
        {
            nTmp = static_cast<sal_uInt16>(pSh->getIDocumentOutlineNodesAccess()->getOutlineLevel(nOutlinePos));
        }
        aLevelLB.SelectEntryPos(nTmp-1);//nTmp);//#outline level,zhaojianwei
    
        // Zeichenvorlagen sammeln
        aCharFmtLB.Clear();
        aCharFmtLB.InsertEntry( ViewShell::GetShellRes()->aStrNone );
    
        // Zeichenvorlagen
        ::FillCharStyleListBox(aCharFmtLB,
                            pSh->GetView().GetDocShell());
        Update();
    }
    
    void    SwOutlineSettingsTabPage::ActivatePage(const SfxItemSet& )
    {
        nActLevel = SwOutlineTabDialog::GetActNumLevel();
        if(nActLevel != USHRT_MAX)
            aLevelLB.SelectEntryPos(lcl_BitToLevel(nActLevel));
        else
            aLevelLB.SelectEntryPos(MAXLEVEL);
        LevelHdl(&aLevelLB);
    }
    
    int     SwOutlineSettingsTabPage::DeactivatePage(SfxItemSet*)
    {
        SwOutlineTabDialog::SetActNumLevel(nActLevel);
        return LEAVE_PAGE;
    }
    
    sal_Bool    SwOutlineSettingsTabPage::FillItemSet( SfxItemSet&  )
    {
        return sal_True;
    }
    
    void 	SwOutlineSettingsTabPage::Reset( const SfxItemSet& rSet )
    {
        ActivatePage(rSet);
    }
    
    SfxTabPage*	SwOutlineSettingsTabPage::Create( Window* pParent,
                                    const SfxItemSet& rAttrSet)
    {
        return new SwOutlineSettingsTabPage(pParent, rAttrSet);
    }
    
    void SwOutlineSettingsTabPage::CheckForStartValue_Impl(sal_uInt16 nNumberingType)
    {
        sal_Bool bIsNull = aStartEdit.GetValue() == 0;
        sal_Bool bNoZeroAllowed = nNumberingType < SVX_NUM_ARABIC ||
                            SVX_NUM_CHARS_UPPER_LETTER_N == nNumberingType ||
                            SVX_NUM_CHARS_LOWER_LETTER_N == nNumberingType;
        aStartEdit.SetMin(bNoZeroAllowed ? 1 : 0);
        if(bIsNull && bNoZeroAllowed)
            aStartEdit.GetModifyHdl().Call(&aStartEdit);
    }
    
    sal_uInt16 lcl_DrawBullet(VirtualDevice* pVDev,
                const SwNumFmt& rFmt, sal_uInt16 nXStart,
                sal_uInt16 nYStart, const Size& rSize)
    {
        Font aTmpFont(pVDev->GetFont());
    
        Font aFont(*rFmt.GetBulletFont());
        aFont.SetSize(rSize);
        aFont.SetTransparent(sal_True);
        pVDev->SetFont( aFont );
        String aText(rFmt.GetBulletChar());
        pVDev->DrawText( Point(nXStart, nYStart), aText );
        sal_uInt16 nRet = (sal_uInt16)pVDev->GetTextWidth(aText);
    
        pVDev->SetFont(aTmpFont);
        return nRet;
    }
    
    sal_uInt16 lcl_DrawGraphic(VirtualDevice* pVDev, const SwNumFmt &rFmt, sal_uInt16 nXStart,
                            sal_uInt16 nYStart, sal_uInt16 nDivision)
    {
        const SvxBrushItem* pBrushItem = rFmt.GetBrush();
        sal_uInt16 nRet = 0;
        if(pBrushItem)
        {
            const Graphic* pGrf = pBrushItem->GetGraphic();
            if(pGrf)
            {
                Size aGSize( rFmt.GetGraphicSize());
                aGSize.Width() /= nDivision;
                nRet = (sal_uInt16)aGSize.Width();
                aGSize.Height() /= nDivision;
                pGrf->Draw( pVDev, Point(nXStart,nYStart),
                        pVDev->PixelToLogic( aGSize ) );
            }
        }
        return nRet;
    
    }
    
    /*--------------------------------------------------
        Vorschau der Numerierung painten
    --------------------------------------------------*/
    void    NumberingPreview::Paint( const Rectangle& /*rRect*/ )
    {
        Size aSize(PixelToLogic(GetOutputSizePixel()));
        Rectangle aRect(Point(0,0), aSize);
    
        VirtualDevice* pVDev = new VirtualDevice(*this);
        pVDev->SetMapMode(GetMapMode());
        pVDev->SetOutputSize( aSize );
    
        // #101524# OJ
        pVDev->SetFillColor( GetSettings().GetStyleSettings().GetWindowColor() );
        pVDev->SetLineColor( GetSettings().GetStyleSettings().GetButtonTextColor() );
        pVDev->DrawRect(aRect);
    
        if(pActNum)
        {
            sal_uInt16 nWidthRelation;
            if(nPageWidth)
            {
                nWidthRelation = sal_uInt16 (nPageWidth / aSize.Width());
                if(bPosition)
                    nWidthRelation = nWidthRelation * 2 / 3;
                else
                    nWidthRelation = nWidthRelation / 4;
            }
            else
                nWidthRelation = 30; // Kapiteldialog
    
            //Hoehe pro Ebene
            sal_uInt16 nXStep = sal_uInt16(aSize.Width() / (3 * MAXLEVEL));
            if(MAXLEVEL < 10)
                nXStep /= 2;
            sal_uInt16 nYStart = 4;
            sal_uInt16 nYStep = sal_uInt16((aSize.Height() - 6)/ MAXLEVEL);
            aStdFont = OutputDevice::GetDefaultFont(
                                        DEFAULTFONT_UI_SANS, (LanguageType)GetAppLanguage(),
                                        DEFAULTFONT_FLAGS_ONLYONE, this );
            // #101524# OJ
            aStdFont.SetColor( SwViewOption::GetFontColor() );
    
            sal_uInt16 nFontHeight = nYStep * 6 / 10;
            if(bPosition)
                nFontHeight = nYStep * 15 / 10;
            aStdFont.SetSize(Size( 0, nFontHeight ));
    
            sal_uInt16 nPreNum = pActNum->Get(0).GetStart();
    
            if(bPosition)
            {
                sal_uInt16 nLineHeight = nFontHeight * 8 / 7;
                sal_uInt8 nStart = 0;
                while( !(nActLevel & (1<<nStart)) )
                {
                    nStart++;
                }
                if(nStart) // damit moeglichs Vorgaenger und Nachfolger gezeigt werden
                    nStart--;
    
                SwNumberTree::tNumberVector aNumVector;
                sal_uInt8 nEnd = Min( (sal_uInt8)(nStart + 3), MAXLEVEL );
                for( sal_uInt8 nLevel = nStart; nLevel < nEnd; ++nLevel )
                {
                    const SwNumFmt &rFmt = pActNum->Get(nLevel);
                    aNumVector.push_back(rFmt.GetStart());
    
                    sal_uInt16 nXStart( 0 );
                    short nTextOffset( 0 );
                    sal_uInt16 nNumberXPos( 0 );
                    if ( rFmt.GetPositionAndSpaceMode() == SvxNumberFormat::LABEL_WIDTH_AND_POSITION )
                    {
                        nXStart = rFmt.GetAbsLSpace() / nWidthRelation;
                        nTextOffset = rFmt.GetCharTextDistance() / nWidthRelation;
                        nNumberXPos = nXStart;
                        sal_uInt16 nFirstLineOffset = (-rFmt.GetFirstLineOffset()) / nWidthRelation;
    
                        if(nFirstLineOffset <= nNumberXPos)
                            nNumberXPos = nNumberXPos - nFirstLineOffset;
                        else
                            nNumberXPos = 0;
                    }
                    else if ( rFmt.GetPositionAndSpaceMode() == SvxNumberFormat::LABEL_ALIGNMENT )
                    {
                        const long nTmpNumberXPos( ( rFmt.GetIndentAt() +
                                                     rFmt.GetFirstLineIndent() ) /
                                                   nWidthRelation );
                        if ( nTmpNumberXPos < 0 )
                        {
                            nNumberXPos = 0;
                        }
                        else
                        {
                            nNumberXPos = static_cast<sal_uInt16>(nTmpNumberXPos);
                        }
                    }
    
                    sal_uInt16 nBulletWidth = 0;
                    if( SVX_NUM_BITMAP == rFmt.GetNumberingType() )
                    {
                        nBulletWidth = lcl_DrawGraphic(pVDev, rFmt,
                                            nNumberXPos,
                                                nYStart, nWidthRelation);
                    }
                    else if( SVX_NUM_CHAR_SPECIAL == rFmt.GetNumberingType() )
                    {
                        nBulletWidth =  lcl_DrawBullet(pVDev, rFmt, nNumberXPos, nYStart, aStdFont.GetSize());
                    }
                    else
                    {
                        pVDev->SetFont(aStdFont);
                        if(pActNum->IsContinusNum())
                            aNumVector[nLevel] = nPreNum;
                        // --> OD 2005-11-17 #128041#
                        String aText(pActNum->MakeNumString( aNumVector ));
                        // <--
                        pVDev->DrawText( Point(nNumberXPos, nYStart), aText );
                        nBulletWidth = (sal_uInt16)pVDev->GetTextWidth(aText);
                        nPreNum++;
                    }
                    if ( rFmt.GetPositionAndSpaceMode() == SvxNumberFormat::LABEL_ALIGNMENT &&
                         rFmt.GetLabelFollowedBy() == SvxNumberFormat::SPACE )
                    {
                        pVDev->SetFont(aStdFont);
                        String aText(' ');
                        pVDev->DrawText( Point(nNumberXPos, nYStart), aText );
                        nBulletWidth = nBulletWidth + (sal_uInt16)pVDev->GetTextWidth(aText);
                    }
    
                    sal_uInt16 nTextXPos( 0 );
                    if ( rFmt.GetPositionAndSpaceMode() == SvxNumberFormat::LABEL_WIDTH_AND_POSITION )
                    {
                        nTextXPos = nXStart;
                        if(nTextOffset < 0)
                             nTextXPos = nTextXPos + nTextOffset;
                        if(nNumberXPos + nBulletWidth + nTextOffset > nTextXPos )
                            nTextXPos = nNumberXPos + nBulletWidth + nTextOffset;
                    }
                    else if ( rFmt.GetPositionAndSpaceMode() == SvxNumberFormat::LABEL_ALIGNMENT )
                    {
                        switch ( rFmt.GetLabelFollowedBy() )
                        {
                            case SvxNumberFormat::LISTTAB:
                            {
                                nTextXPos = static_cast<sal_uInt16>(
                                                rFmt.GetListtabPos() / nWidthRelation );
                                if ( nTextXPos < nNumberXPos + nBulletWidth )
                                {
                                    nTextXPos = nNumberXPos + nBulletWidth;
                                }
                            }
                            break;
                            case SvxNumberFormat::SPACE:
                            case SvxNumberFormat::NOTHING:
                            {
                                nTextXPos = nNumberXPos + nBulletWidth;
                            }
                            break;
                        }
    
                        nXStart = static_cast<sal_uInt16>( rFmt.GetIndentAt() / nWidthRelation );
                    }
    
    
                    Rectangle aRect1(Point(nTextXPos, nYStart + nFontHeight / 2), Size(aSize.Width() / 2, 2));
                    pVDev->SetFillColor( GetSettings().GetStyleSettings().GetWindowColor() ); // Color( COL_BLACK ) );
                    pVDev->DrawRect( aRect1 );
    
                    Rectangle aRect2(Point(nXStart, nYStart + nLineHeight + nFontHeight / 2 ), Size(aSize.Width() / 2, 2));
                    pVDev->DrawRect( aRect2 );
                    nYStart += 2 * nLineHeight;
                }
            }
            else
            {
                SwNumberTree::tNumberVector aNumVector;
                sal_uInt16 nLineHeight = nFontHeight * 3 / 2;
                for( sal_uInt8 nLevel = 0; nLevel < MAXLEVEL;
                                ++nLevel, nYStart = nYStart + nYStep )
                {
                    const SwNumFmt &rFmt = pActNum->Get(nLevel);
                    aNumVector.push_back(rFmt.GetStart());
                    sal_uInt16 nXStart( 0 );
                    if ( rFmt.GetPositionAndSpaceMode() == SvxNumberFormat::LABEL_WIDTH_AND_POSITION )
                    {
                        nXStart = rFmt.GetAbsLSpace() / nWidthRelation;
                    }
                    else if ( rFmt.GetPositionAndSpaceMode() == SvxNumberFormat::LABEL_ALIGNMENT )
                    {
                        const long nTmpXStart( ( rFmt.GetIndentAt() +
                                                 rFmt.GetFirstLineIndent() ) /
                                               nWidthRelation );
                        if ( nTmpXStart < 0 )
                        {
                            nXStart = 0;
                        }
                        else
                        {
                            nXStart = static_cast<sal_uInt16>(nTmpXStart);
                        }
                    }
                    nXStart /= 2;
                    nXStart += 2;
                    sal_uInt16 nTextOffset = 2 * nXStep;
                    if( SVX_NUM_BITMAP == rFmt.GetNumberingType() )
                    {
                        lcl_DrawGraphic(pVDev, rFmt, nXStart, nYStart, nWidthRelation);
                        nTextOffset = nLineHeight + nXStep;
                    }
                    else if( SVX_NUM_CHAR_SPECIAL == rFmt.GetNumberingType() )
                    {
                        nTextOffset =  lcl_DrawBullet(pVDev, rFmt, nXStart, nYStart, aStdFont.GetSize());
                        nTextOffset = nTextOffset + nXStep;
                    }
                    else
                    {
                        pVDev->SetFont(aStdFont);
                        if(pActNum->IsContinusNum())
                            aNumVector[nLevel] = nPreNum;
                        // --> OD 2005-11-17 #128041#
                        String aText(pActNum->MakeNumString( aNumVector ));
                        // <--
                        pVDev->DrawText( Point(nXStart, nYStart), aText );
                        nTextOffset = (sal_uInt16)pVDev->GetTextWidth(aText);
                        nTextOffset = nTextOffset + nXStep;
                        nPreNum++;
                    }
                    pVDev->SetFont(aStdFont);
    
                    // Changed as per BugID 79541 Branding/Configuration
                    uno::Any MyAny = ::utl::ConfigManager::GetConfigManager().
                            GetDirectConfigProperty( ::utl::ConfigManager::PRODUCTNAME );
                    ::rtl::OUString aProductName;
    
                    MyAny >>= aProductName;
                    String sMsg(C2S("%PRODUCTNAME"));
                    sMsg.SearchAndReplaceAscii( "%PRODUCTNAME" , aProductName );
    
                    if(pOutlineNames)
                        sMsg = pOutlineNames[nLevel];
                    pVDev->DrawText( Point(nXStart + nTextOffset, nYStart), sMsg );
                }
            }
        }
        DrawOutDev(	Point(0,0), aSize,
                    Point(0,0), aSize,
                            *pVDev );
        delete pVDev;
    
    }
    
    NumberingPreview::~NumberingPreview()
    {
    }
    
    /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

    Code:
    /*************************************************************************
     *
     * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
     * 
     * Copyright 2000, 2010 Oracle and/or its affiliates.
     *
     * OpenOffice.org - a multi-platform office productivity suite
     *
     * This file is part of OpenOffice.org.
     *
     * OpenOffice.org is free software: you can redistribute it and/or modify
     * it under the terms of the GNU Lesser General Public License version 3
     * only, as published by the Free Software Foundation.
     *
     * OpenOffice.org is distributed in the hope that it will be useful,
     * but WITHOUT ANY WARRANTY; without even the implied warranty of
     * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
     * GNU Lesser General Public License version 3 for more details
     * (a copy is included in the LICENSE file that accompanied this code).
     *
     * You should have received a copy of the GNU Lesser General Public License
     * version 3 along with OpenOffice.org.  If not, see
     * <http://www.openoffice.org/license.html>
     * for a copy of the LGPLv3 License.
     *
     ************************************************************************/
    
    #include "misc.hrc"
    #include "outline.hrc"
    #include "globals.hrc"
    #include "cmdid.h"
    #include "helpid.h"
    ModalDialog DLG_NUM_NAMES
    {
        HelpID = HID_NUM_NAMES ;
        OutputSize = TRUE ;
        SVLook = TRUE ;
        Size = MAP_APPFONT ( 164 , 82 ) ;
        Text [ en-US ] = "Save As";
        Moveable = TRUE ;
        OKButton BT_OK
        {
            Pos = MAP_APPFONT ( 108 , 6 ) ;
            Size = MAP_APPFONT ( 50 , 14 ) ;
            TabStop = TRUE ;
            DefButton = TRUE ;
        };
        CancelButton BT_CANCEL
        {
            Pos = MAP_APPFONT ( 108 , 23 ) ;
            Size = MAP_APPFONT ( 50 , 14 ) ;
            TabStop = TRUE ;
        };
        HelpButton BT_HELP
        {
            Pos = MAP_APPFONT ( 108 , 43 ) ;
            Size = MAP_APPFONT ( 50 , 14 ) ;
            TabStop = TRUE ;
        };
        FixedLine FL_FORM
        {
            Pos = MAP_APPFONT ( 6 , 3 ) ;
            Size = MAP_APPFONT ( 96 , 8 ) ;
            Text [ en-US ] = "Format" ;
        };
        ListBox LB_FORM
        {
            HelpID = "sw:ListBox:DLG_NUM_NAMES:LB_FORM";
            Border = TRUE ;
            Pos = MAP_APPFONT ( 12 , 29 ) ;
            Size = MAP_APPFONT ( 84 , 42 ) ;
            TabStop = TRUE ;
            CurPos = 0 ;
            StringList [ en-US ] =
            {
                < "Untitled 1" ; > ;
                < "Untitled 2" ; > ;
                < "Untitled 3" ; > ;
                < "Untitled 4" ; > ;
                < "Untitled 5" ; > ;
                < "Untitled 6" ; > ;
                < "Untitled 7" ; > ;
                < "Untitled 8" ; > ;
                < "Untitled 9" ; > ;
            };
        };
        Edit ED_FORM
        {
            HelpID = "sw:Edit:DLG_NUM_NAMES:ED_FORM";
            Border = TRUE ;
            Pos = MAP_APPFONT ( 12 , 14 ) ;
            Size = MAP_APPFONT ( 84 , 12 ) ;
            TabStop = TRUE ;
            Left = TRUE ;
        };
    };
    /**************************************************************************/
    /*                                                                        */
    /*                                                                        */
    /*                                                                        */
    /**************************************************************************/
    TabDialog DLG_TAB_OUTLINE
    {
        OutputSize = TRUE ;
        SVLook = TRUE ;
        // --> OD 2008-04-14 #outlinelevel#
        // dialog title is now given by resource STR_OUTLINE_NUMBERING
    //    Text [ en-US ] = "Outline Numbering" ;
        // <--
        Moveable = TRUE ;
        TabControl 1
        {
            SVLook = TRUE ;
            PageList =
            {
                PageItem
                {
                    Identifier = TP_OUTLINE_NUM ;
                    Text [ en-US ] = "Numbering" ;
                };
                PageItem
                {
                    Identifier = TP_NUM_POSITION ;
                    Text [ en-US ] = "Position" ;
                };
            };
        };
        String ST_FORM
        {
            Text [ en-US ] = "~Format" ;
        };
        Menu MN_FORM
        {
            ItemList =
            {
                MenuItem
                {
                    Identifier = MN_FORM1 ;
                    Text [ en-US ] = "Untitled 1" ;
                    HelpID = HID_NUM_OUTL_NAMED_NUMS ;
                };
                MenuItem
                {
                    Identifier = MN_FORM2 ;
                    Text [ en-US ] = "Untitled 2" ;
                    HelpID = HID_NUM_OUTL_NAMED_NUMS ;
                };
                MenuItem
                {
                    Identifier = MN_FORM3 ;
                    Text [ en-US ] = "Untitled 3" ;
                    HelpID = HID_NUM_OUTL_NAMED_NUMS ;
                };
                MenuItem
                {
                    Identifier = MN_FORM4 ;
                    Text [ en-US ] = "Untitled 4" ;
                    HelpID = HID_NUM_OUTL_NAMED_NUMS ;
                };
                MenuItem
                {
                    Identifier = MN_FORM5 ;
                    Text [ en-US ] = "Untitled 5" ;
                    HelpID = HID_NUM_OUTL_NAMED_NUMS ;
                };
                MenuItem
                {
                    Identifier = MN_FORM6 ;
                    Text [ en-US ] = "Untitled 6" ;
                    HelpID = HID_NUM_OUTL_NAMED_NUMS ;
                };
                MenuItem
                {
                    Identifier = MN_FORM7 ;
                    Text [ en-US ] = "Untitled 7" ;
                    HelpID = HID_NUM_OUTL_NAMED_NUMS ;
                };
                MenuItem
                {
                    Identifier = MN_FORM8 ;
                    Text [ en-US ] = "Untitled 8" ;
                    HelpID = HID_NUM_OUTL_NAMED_NUMS ;
                };
                MenuItem
                {
                    Identifier = MN_FORM9 ;
                    Text [ en-US ] = "Untitled 9" ;
                    HelpID = HID_NUM_OUTL_NAMED_NUMS ;
                };
                MenuItem
                {
                    Separator = TRUE ;
                };
                MenuItem
                {
                    Identifier = MN_SAVE ;
                    Text [ en-US ] = "Save ~As...";
                    HelpID = HID_NUM_OUTL_NUM_SAVEAS ;
                };
            };
        };
    };
    /**************************************************************************/
    /*                                                                        */
    /* 	TabPage                                                               */
    /*                                                                        */
    /**************************************************************************/
    TabPage TP_OUTLINE_NUM
    {
        HelpID = HID_TP_OUTLINE_NUM ;
        SVLook = TRUE ;
        Size = MAP_APPFONT ( 260 , 185 ) ;
            Hide = TRUE;
        ListBox LB_LEVEL
        {
            HelpID = "sw:ListBox:TP_OUTLINE_NUM:LB_LEVEL";
            Pos = MAP_APPFONT ( 12 , 14 ) ;
            Size = MAP_APPFONT ( 23 , 129 ) ;
            TabStop = TRUE ;
            DropDown = FALSE ;
            Border = TRUE ;
        };
        FixedLine FL_LEVEL
        {
            Pos = MAP_APPFONT ( 6 , 3 ) ;
            Size = MAP_APPFONT ( 32 , 8 ) ;
            Text [ en-US ] = "Level" ;
        };
        FixedText FT_COLL
        {
            Pos = MAP_APPFONT ( 50 , 14 ) ;
            Size = MAP_APPFONT ( 120 , 8 ) ;
            Text [ en-US ] = "~Paragraph Style" ;
            Group = TRUE ;
            Left = TRUE ;
        };
        ListBox LB_COLL
        {
            HelpID = "sw:ListBox:TP_OUTLINE_NUM:LB_COLL";
            Border = TRUE ;
            Pos = MAP_APPFONT ( 50 , 25 ) ;
            Size = MAP_APPFONT ( 120 , 75 ) ;
            TabStop = TRUE ;
            Group = TRUE ;
            Sort = TRUE ;
            DropDown = TRUE ;
            CurPos = 0 ;
        };
        FixedText FT_NUMBER
        {
            Pos = MAP_APPFONT ( 50 , 43 ) ;
            Size = MAP_APPFONT ( 52 , 8 ) ;
            Text [ en-US ] = "~Number" ;
            Left = TRUE ;
        };
        ListBox LB_NUMBER
        {
            HelpID = "sw:ListBox:TP_OUTLINE_NUM:LB_NUMBER";
            Pos = MAP_APPFONT ( 104 , 41 ) ;
            Size = MAP_APPFONT ( 66 , 65 ) ;
            TabStop = TRUE ;
            Group = TRUE ;
            DropDown = TRUE ;
            CurPos = 0 ;
        };
        FixedText FT_CHARFMT
        {
            Pos = MAP_APPFONT ( 50 , 59 ) ;
            Size = MAP_APPFONT ( 52 , 8 ) ;
            Text [ en-US ] = "~Character Style" ;
        };
        ListBox LB_CHARFMT
        {
            HelpID = "sw:ListBox:TP_OUTLINE_NUM:LB_CHARFMT";
            TabStop = TRUE ;
            DropDown = TRUE ;
            Pos = MAP_APPFONT ( 104 , 57 ) ;
            Size = MAP_APPFONT ( 66 , 65 ) ;
        };
        FixedText FT_ALL_LEVEL
        {
            Pos = MAP_APPFONT ( 50 , 75 ) ;
            Size = MAP_APPFONT ( 52 , 8 ) ;
            Text [ en-US ] = "Sho~w sublevels" ;
        };
        NumericField NF_ALL_LEVEL
        {
            HelpID = "sw:NumericField:TP_OUTLINE_NUM:NF_ALL_LEVEL";
            Border = TRUE ;
            Pos = MAP_APPFONT ( 104 , 73 ) ;
            Size = MAP_APPFONT ( 66 , 12 ) ;
            TabStop = TRUE ;
            Left = TRUE ;
            Repeat = TRUE ;
            Spin = TRUE ;
            Minimum = 1 ;
            Maximum = 10 ;
            Value = 1 ;
            First = 1 ;
            Last = 10 ;
        };
        FixedText FT_DELIM
        {
            Pos = MAP_APPFONT ( 50 , 89 ) ;
            Size = MAP_APPFONT ( 52 , 8 ) ;
            Text [ en-US ] = "Separator" ;
            Left = TRUE ;
        };
        FixedText FT_PREFIX
        {
            Pos = MAP_APPFONT ( 56 , 102 ) ;
            Size = MAP_APPFONT ( 46 , 8 ) ;
            Text [ en-US ] = "~Before" ;
            Left = TRUE ;
        };
        Edit ED_PREFIX
        {
            HelpID = "sw:Edit:TP_OUTLINE_NUM:ED_PREFIX";
            Border = TRUE ;
            Pos = MAP_APPFONT ( 104 , 100 ) ;
            Size = MAP_APPFONT ( 66 , 12 ) ;
            TabStop = TRUE ;
            Group = TRUE ;
            Left = TRUE ;
        };
        FixedText FT_SUFFIX
        {
            Pos = MAP_APPFONT ( 56 , 117 ) ;
            Size = MAP_APPFONT ( 46 , 8 ) ;
            Text [ en-US ] = "~After" ;
            Left = TRUE ;
        };
        Edit ED_SUFFIX
        {
            HelpID = "sw:Edit:TP_OUTLINE_NUM:ED_SUFFIX";
            Border = TRUE ;
            Pos = MAP_APPFONT ( 104 , 115 ) ;
            Size = MAP_APPFONT ( 66 , 12 ) ;
            TabStop = TRUE ;
            Group = TRUE ;
            Left = TRUE ;
        };
        FixedText FT_START
        {
            Pos = MAP_APPFONT ( 50 , 133 ) ;
            Size = MAP_APPFONT ( 52 , 8 ) ;
            Text [ en-US ] = "~Start at" ;
            Left = TRUE ;
        };
        NumericField ED_START
        {
            HelpID = "sw:NumericField:TP_OUTLINE_NUM:ED_START";
            Border = TRUE ;
            Pos = MAP_APPFONT ( 104 , 131 ) ;
            Size = MAP_APPFONT ( 66 , 12 ) ;
            TabStop = TRUE ;
            Left = TRUE ;
            Spin = TRUE ;
            Repeat = TRUE ;
            Maximum = 999 ;
            Value = 0 ;
            First = 0 ;
            Last = 99 ;
            SpinSize = 1 ;
        };
        FixedLine FL_NUMBER
        {
            Pos = MAP_APPFONT ( 44 , 3 ) ;
            Size = MAP_APPFONT ( 210 , 8 ) ;
            Text [ en-US ] = "Numbering" ;
            Group = TRUE ;
        };
        Window WIN_PREVIEW
        {
            Pos = MAP_APPFONT ( 179 , 14 ) ;
            Size = MAP_APPFONT ( 72 , 129 ) ;
        };
        String ST_NO_COLL
        {
            Text [ en-US ] = "(none)" ;
        };
    };
    Code:
    /*************************************************************************
     *
     * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
     * 
     * Copyright 2000, 2010 Oracle and/or its affiliates.
     *
     * OpenOffice.org - a multi-platform office productivity suite
     *
     * This file is part of OpenOffice.org.
     *
     * OpenOffice.org is free software: you can redistribute it and/or modify
     * it under the terms of the GNU Lesser General Public License version 3
     * only, as published by the Free Software Foundation.
     *
     * OpenOffice.org is distributed in the hope that it will be useful,
     * but WITHOUT ANY WARRANTY; without even the implied warranty of
     * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
     * GNU Lesser General Public License version 3 for more details
     * (a copy is included in the LICENSE file that accompanied this code).
     *
     * You should have received a copy of the GNU Lesser General Public License
     * version 3 along with OpenOffice.org.  If not, see
     * <http://www.openoffice.org/license.html>
     * for a copy of the LGPLv3 License.
     *
     ************************************************************************/
    #define RB_1            1
    #define RB_2            2
    #define RB_3            3
    #define RB_4            4
    #define RB_5            5
    #define FT_1            6
    #define FT_2            7
    #define FT_3            8
    #define FT_4            9
    #define FT_5            10
    #define FI_1            11
    #define FI_2            12
    #define FI_3            13
    #define FI_4            14
    #define FI_5            15
    //#define FL_LEVEL        16
    
    #define FT_COLL         20
    #define LB_COLL         21
    #define FT_NUMBER       22
    #define LB_NUMBER       23
    #define FT_DELIM        24
    #define FT_DELIM_BEVOR  25
    #define FT_DELIM_AFTER  26
    #define ED_DELIM_BEVOR  27
    #define ED_DELIM_AFTER  28
    #define CB_COMPLETE     29
    #define FL_NUMBER       30
    
    #define LB_ALIGN       	31
    #define FL_ALIGN        33
    
    #define FT_START        40
    #define ED_START        41
    #define FL_START        42
    
    #define BT_OK           100
    #define BT_CANCEL       101
    #define BT_HELP         102
    #define BT_FORM         103
    #define BT_RESET        104
    #define FL_FORM         105
    #define LB_FORM         106
    #define ED_FORM         107
    #define FT_ALL_LEVEL    108
    #define NF_ALL_LEVEL    109
    
    #define MN_FORM		110
    #define MN_FORM1        111
    #define MN_FORMBASE     MN_FORM1
    #define MN_FORM2        112
    #define MN_FORM3        113
    #define MN_FORM4        114
    #define MN_FORM5        115
    #define MN_FORM6        116
    #define MN_FORM7        117
    #define MN_FORM8        118
    #define MN_FORM9        119
    #define MN_SAVE         120
    
    #define FL_LEVEL                130
    #define LB_LEVEL	    131
    #define WIN_PREVIEW     132
    #define FT_SUFFIX	    134
    #define ED_SUFFIX	    135
    #define FT_PREFIX	    136
    #define ED_PREFIX	    137
    #define ST_NO_COLL 		138
    
    #define ST_FORM			140
    #define FT_CHARFMT		141
    #define LB_CHARFMT      141



    I'm trying to find the location of that specific option for outlines, we'll see how it goes, hoping to have it fixed relatively fast as it seems like an obvious bug
    Bodhi 1.3 & Bodhi 1.4 using E17
    Dell Studio 17, Intel Graphics card, 4 gigs of RAM, E17

    "The beauty in life can only be found by moving past the materialism which defines human nature and into the higher realm of thought and knowledge"

  2. #2
    Linux Enthusiast Kloschüssel's Avatar
    Join Date
    Oct 2005
    Location
    Italy
    Posts
    718
    (before reading the source)

    How comes that you know the buggy code must be in those three files? If the bug is known since long time, I would bisect it on the repository to determine which revision introduced it. That normally yields a small subset of lines of code to check. Just reading through pages over pages of sourcecode is not exactly what I would call "efficiency".

  3. #3
    Linux Guru jmadero's Avatar
    Join Date
    Jul 2007
    Location
    California
    Posts
    1,958
    Quote Originally Posted by Kloschüssel View Post
    (before reading the source)

    How comes that you know the buggy code must be in those three files? If the bug is known since long time, I would bisect it on the repository to determine which revision introduced it. That normally yields a small subset of lines of code to check. Just reading through pages over pages of sourcecode is not exactly what I would call "efficiency".
    Thanks for the input. Honestly this is the first time I've ever tried to delve into the code to fix a problem so I'm kind of just guessing and checking at this point. Any advice really appreciated.

    As for your suggestion, as far as I know this has always been a bug so there's nothing to compare it to where the bug didn't exist. I could be wrong and I'll go through OpenOffice 2 to see if I can find a place where it didn't exist but I remember years have gone by with my wife and I getting ticked off at the devs for not prioritizing the issue as we tried to outline through college and the auto bullets would screw everything up and make it look wack.

    I'll back track through the OOo version to see if I find any version which doesn't have the bug. Any other suggestions really appreciated, this seems like such a minor bug but it is oh so annoying
    Bodhi 1.3 & Bodhi 1.4 using E17
    Dell Studio 17, Intel Graphics card, 4 gigs of RAM, E17

    "The beauty in life can only be found by moving past the materialism which defines human nature and into the higher realm of thought and knowledge"

  4. #4
    Linux Enthusiast Kloschüssel's Avatar
    Join Date
    Oct 2005
    Location
    Italy
    Posts
    718
    Since OO is written with java, you should be able to debug the code step by step?

  5. #5
    Linux Guru jmadero's Avatar
    Join Date
    Jul 2007
    Location
    California
    Posts
    1,958
    Quote Originally Posted by Kloschüssel View Post
    Since OO is written with java, you should be able to debug the code step by step?
    It's my understanding it's written in C++, only some components of Base are written in java
    Bodhi 1.3 & Bodhi 1.4 using E17
    Dell Studio 17, Intel Graphics card, 4 gigs of RAM, E17

    "The beauty in life can only be found by moving past the materialism which defines human nature and into the higher realm of thought and knowledge"

  6. #6
    Just Joined!
    Join Date
    Mar 2009
    Posts
    2
    I think that's true; certainly most of the LO source I've looked at is C++. Can't say where Java comes into it (apart from the regex engine), but I understand a lot of the work done in LO since the fork has been extricating superfluous Java cruft.

    jmadero, I can't reproduce your bug. When I type
    I
    II
    III
    ... auto-numbering doesn't start, even though "Apply numbering - symbol *" is checked on the Tools > AutoCorrect Options > Options tab. I fiddled about making the lines numbered by hand for a bit, but couldn't see the issue you described. In any case, I wouldn't be much help in figuring it out. My own forays into the LO source (to try and make character styles applied to headings show up in the table of contents, for chemical subscripts and the like) weren't very successful.

    But I'm very interested to see how you get on. Never seen anyone perform a 'public' bughunt in a forum before. Also I'm always keen to learn more about the LO source (in case I ever get time to finish what I started!) so thanks in advance for sharing your experiences here

  7. #7
    Linux Guru jmadero's Avatar
    Join Date
    Jul 2007
    Location
    California
    Posts
    1,958
    So far I've had absolutely no luck finding older versions of OOo source, kind of frustrating that I can't find one mirror that just has all of the source (I want from 2.0 - Current). I've only found current and I think one subversion prior. Without it I think it'll be incredibly hard to find the bug.

    As for reproducing the bug, you can manually turn on the bullets and you'll see it. Under format -> bullets & number, click on outline tab and then select the second row, first column (I., A., i., a., dot). The bug has been reproduced and confirmed in launchpad but I suspect unless I can fix it, it'll be really low priority.

    If anyone knows where I can find old source for OOo I'd really appreciate it. My bughunt has come to a bit of a hault because I couldn't find it after googling for about an hour (couldn't believe I couldn't just type "OOo 2.0 source").
    Bodhi 1.3 & Bodhi 1.4 using E17
    Dell Studio 17, Intel Graphics card, 4 gigs of RAM, E17

    "The beauty in life can only be found by moving past the materialism which defines human nature and into the higher realm of thought and knowledge"

  8. #8
    Trusted Penguin elija's Avatar
    Join Date
    Jul 2004
    Location
    Either at home or at work or down the pub
    Posts
    2,301
    You could try installing Debian Lenny and then using the apt-get source command. That should grab you the source of V2.x of Open Office if available.
    If we hit that bullseye, the rest of the dominoes will fall like a house of cards. Checkmate! (Zapp Brannigan)


    My new blog. It's probably not as good as I think it is.

  9. #9
    drl
    drl is offline
    Linux Engineer drl's Avatar
    Join Date
    Apr 2006
    Location
    Saint Paul, MN, USA / CentOS, Debian, Solaris, SuSE
    Posts
    1,117
    Hi.

    I don't think one needs to install Debian, although that might help with dependencies, etc.

    Searching for openoffice in the lenny packages, one finds a series of links:

    Debian -- Package Search Results -- openoffice ->

    Debian -- Details of package openoffice.org in lenny ->

    Debian -- Details of package openoffice.org-writer in lenny ->

    on which, noting the right-hand side of the page:

    http://security.debian.org/debian-se...sg.orig.tar.gz 266MB

    If it's not in the writer, then start at the first link and look at the other parts of OO.

    Good luck ... cheers, drl
    Welcome - get the most out of the forum by reading forum basics and guidelines: click here.
    90% of questions can be answered by using man pages, Quick Search, Advanced Search, Google search, Wikipedia.
    We look forward to helping you with the challenge of the other 10%.
    ( Mn, 2.6.n, AMD-64 3000+, ASUS A8V Deluxe, 1 GB, SATA + IDE, Matrox G400 AGP )

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
...