diff options
author | Oliver-Rainer Wittmann <orw@apache.org> | 2013-04-10 08:20:16 +0000 |
---|---|---|
committer | Oliver-Rainer Wittmann <orw@apache.org> | 2013-04-10 08:20:16 +0000 |
commit | 0a0a9b32aa5bf1ce2554ad37cbba3c7a105db2b5 (patch) | |
tree | f5c258d25d3719c8f719a944043b5220377e9f9c /sd/source/ui/view/sdview.cxx | |
parent | bcfee75544246db6788715d98efd6d33c12f933d (diff) |
121420: merge sidebar feature from branch into trunk
Notes
merged as: d50ce284c9674c45acd40d017cc44c260da722a2
Diffstat (limited to 'sd/source/ui/view/sdview.cxx')
-rw-r--r-- | sd/source/ui/view/sdview.cxx | 190 |
1 files changed, 186 insertions, 4 deletions
diff --git a/sd/source/ui/view/sdview.cxx b/sd/source/ui/view/sdview.cxx index cf096a396b27..8b2a8a888f7c 100644 --- a/sd/source/ui/view/sdview.cxx +++ b/sd/source/ui/view/sdview.cxx @@ -51,11 +51,13 @@ #include <svx/dialogs.hrc> #include <sfx2/viewfrm.hxx> +#include <sfx2/sidebar/EnumContext.hxx> #include <svx/svdopage.hxx> #include <toolkit/helper/vclunohelper.hxx> #include <svx/xlndsit.hxx> #include <svx/xlineit0.hxx> #include <svx/xlnclit.hxx> +#include <svx/sidebar/ContextChangeEventMultiplexer.hxx> #include <vcl/virdev.hxx> #include "app.hrc" @@ -79,6 +81,7 @@ #include <svx/sdr/contact/viewobjectcontact.hxx> #include <svx/sdr/contact/viewcontact.hxx> #include <svx/sdr/contact/displayinfo.hxx> +#include <svx/svdotable.hxx> #include "EventMultiplexer.hxx" #include "ViewShellBase.hxx" #include "ViewShellManager.hxx" @@ -89,6 +92,7 @@ #include <drawinglayer/primitive2d/textlayoutdevice.hxx> #include <drawinglayer/primitive2d/groupprimitive2d.hxx> #include <svx/sdr/contact/objectcontact.hxx> +#include <svx/sdr/table/tablecontroller.hxx> #include <basegfx/matrix/b2dhommatrix.hxx> #include <drawinglayer/primitive2d/textprimitive2d.hxx> #include <svx/unoapi.hxx> @@ -98,6 +102,7 @@ using namespace com::sun::star; using namespace com::sun::star::uno; +using namespace sdr::table; namespace sd { #ifndef SO2_DECL_SVINPLACEOBJECT_DEFINED @@ -775,6 +780,10 @@ sal_Bool View::SdrBeginTextEdit( pGivenOutlinerView, bDontDeleteOutliner, bOnlyOneView, bGrabFocus); + ContextChangeEventMultiplexer::NotifyContextChange( + &GetViewShell()->GetViewShellBase(), + ::sfx2::sidebar::EnumContext::Context_DrawText); + if (bReturn) { ::Outliner* pOL = GetTextEditOutliner(); @@ -790,11 +799,15 @@ sal_Bool View::SdrBeginTextEdit( { aBackground = pObj->GetPage()->GetPageBackgroundColor(pPV); } - pOL->SetBackgroundColor( aBackground ); + if (pOL != NULL) + pOL->SetBackgroundColor( aBackground ); } - pOL->SetParaInsertedHdl(LINK(this, View, OnParagraphInsertedHdl)); - pOL->SetParaRemovingHdl(LINK(this, View, OnParagraphRemovingHdl)); + if (pOL != NULL) + { + pOL->SetParaInsertedHdl(LINK(this, View, OnParagraphInsertedHdl)); + pOL->SetParaRemovingHdl(LINK(this, View, OnParagraphRemovingHdl)); + } } return(bReturn); @@ -831,10 +844,16 @@ SdrEndTextEditKind View::SdrEndTextEdit(sal_Bool bDontDeleteReally ) } } - GetViewShell()->GetViewShellBase().GetEventMultiplexer()->MultiplexEvent(sd::tools::EventMultiplexerEvent::EID_END_TEXT_EDIT, (void*)xObj.get() ); + GetViewShell()->GetViewShellBase().GetEventMultiplexer()->MultiplexEvent( + sd::tools::EventMultiplexerEvent::EID_END_TEXT_EDIT, + (void*)xObj.get() ); if( xObj.is() ) { + ContextChangeEventMultiplexer::NotifyContextChange( + &GetViewShell()->GetViewShellBase(), + ::sfx2::sidebar::EnumContext::Context_Default); + SdPage* pPage = dynamic_cast< SdPage* >( xObj->GetPage() ); if( pPage ) pPage->onEndTextEdit( xObj.get() ); @@ -1314,4 +1333,167 @@ void View::OnEndPasteOrDrop( PasteOrDropInfos* pInfos ) } } +sal_Bool View::ShouldToggleOn(sal_Bool bBulletOnOffMode, sal_Bool bNormalBullet) +{ + // If setting bullets/numbering by the dialog, always should toggle on. + if (!bBulletOnOffMode) + return sal_True; + SdrModel* pSdrModel = GetModel(); + if (!pSdrModel) + return sal_False; + + sal_Bool bToggleOn = sal_False; + SdrOutliner* pOutliner = SdrMakeOutliner(OUTLINERMODE_TEXTOBJECT, pSdrModel); + sal_uInt32 nMarkCount = GetMarkedObjectCount(); + for (sal_uInt32 nIndex = 0; nIndex < nMarkCount && !bToggleOn; nIndex++) + { + SdrTextObj* pTextObj = dynamic_cast< SdrTextObj* >(GetMarkedObjectByIndex(nIndex)); + if (!pTextObj || pTextObj->IsTextEditActive()) + continue; + if (pTextObj->ISA(SdrTableObj)) + { + SdrTableObj* pTableObj = dynamic_cast< SdrTableObj* >(pTextObj); + if (!pTableObj) + continue; + CellPos aStart, aEnd; + SvxTableController* pTableController = dynamic_cast< SvxTableController* >(getSelectionController().get()); + if (pTableController) + { + pTableController->getSelectedCells(aStart, aEnd); + } + else + { + aStart = pTableObj->getFirstCell(); + aEnd = pTableObj->getLastCell(); + } + sal_Int32 nColCount = pTableObj->getColumnCount(); + for (sal_Int32 nRow = aStart.mnRow; nRow <= aEnd.mnRow && !bToggleOn; nRow++) + { + for (sal_Int32 nCol = aStart.mnCol; nCol <= aEnd.mnCol && !bToggleOn; nCol++) + { + sal_Int32 nIndex = nRow * nColCount + nCol; + SdrText* pText = pTableObj->getText(nIndex); + if (!pText || !pText->GetOutlinerParaObject()) + continue; + pOutliner->SetText(*(pText->GetOutlinerParaObject())); + sal_Int16 nStatus = pOutliner->GetBulletsNumberingStatus(); + bToggleOn = ((bNormalBullet && nStatus != 0) || (!bNormalBullet && nStatus != 1)) ? sal_True : bToggleOn; + pOutliner->Clear(); + } + } + } + else + { + OutlinerParaObject* pParaObj = pTextObj->GetOutlinerParaObject(); + if (!pParaObj) + continue; + pOutliner->SetText(*pParaObj); + sal_Int16 nStatus = pOutliner->GetBulletsNumberingStatus(); + bToggleOn = ((bNormalBullet && nStatus != 0) || (!bNormalBullet && nStatus != 1)) ? sal_True : bToggleOn; + pOutliner->Clear(); + } + } + delete pOutliner; + return bToggleOn; +} + +void View::ToggleMarkedObjectsBullets(sal_Bool bBulletOnOffMode, sal_Bool bNormalBullet, sal_Bool bMasterView, SvxNumRule* pNumRule, sal_Bool bForceBulletOnOff) +{ + SdrModel* pSdrModel = GetModel(); + Window* pWindow = dynamic_cast< Window* >(GetFirstOutputDevice()); + if (!pSdrModel || !pWindow) + return; + + sal_Bool bUndoEnabled = pSdrModel->IsUndoEnabled(); + sal_Bool bToggleOn = ShouldToggleOn(bBulletOnOffMode, bNormalBullet); + if ( bForceBulletOnOff ) { + bToggleOn = bBulletOnOffMode; + } + SdrUndoGroup* pUndoGroup = new SdrUndoGroup(*pSdrModel); + SdrOutliner* pOutliner = SdrMakeOutliner(OUTLINERMODE_TEXTOBJECT, pSdrModel); + OutlinerView* pOutlinerView = new OutlinerView(pOutliner, pWindow); + + sal_uInt32 nMarkCount = GetMarkedObjectCount(); + for (sal_uInt32 nIndex = 0; nIndex < nMarkCount; nIndex++) + { + SdrTextObj* pTextObj = dynamic_cast< SdrTextObj* >(GetMarkedObjectByIndex(nIndex)); + if (!pTextObj || pTextObj->IsTextEditActive()) + continue; + if (pTextObj->ISA(SdrTableObj)) + { + SdrTableObj* pTableObj = dynamic_cast< SdrTableObj* >(pTextObj); + if (!pTableObj) + continue; + CellPos aStart, aEnd; + SvxTableController* pTableController = dynamic_cast< SvxTableController* >(getSelectionController().get()); + if (pTableController) + { + pTableController->getSelectedCells(aStart, aEnd); + } + else + { + aStart = pTableObj->getFirstCell(); + aEnd = pTableObj->getLastCell(); + } + sal_Int32 nColCount = pTableObj->getColumnCount(); + for (sal_Int32 nRow = aStart.mnRow; nRow <= aEnd.mnRow; nRow++) + { + for (sal_Int32 nCol = aStart.mnCol; nCol <= aEnd.mnCol; nCol++) + { + sal_Int32 nIndex = nRow * nColCount + nCol; + SdrText* pText = pTableObj->getText(nIndex); + if (!pText || !pText->GetOutlinerParaObject()) + continue; + + pOutliner->SetText(*(pText->GetOutlinerParaObject())); + if (bUndoEnabled) + { + SdrUndoObjSetText* pTxtUndo = dynamic_cast< SdrUndoObjSetText* >(pSdrModel->GetSdrUndoFactory().CreateUndoObjectSetText(*pTextObj, nIndex)); + pUndoGroup->AddAction(pTxtUndo); + } + pOutlinerView->ToggleAllParagraphsBullets(bBulletOnOffMode, bNormalBullet, bToggleOn, bMasterView, pNumRule); + sal_uInt32 nParaCount = pOutliner->GetParagraphCount(); + pText->SetOutlinerParaObject(pOutliner->CreateParaObject(0, (sal_uInt16)nParaCount)); + pOutliner->Clear(); + } + } + // Broadcast the object change event. + if (!pTextObj->AdjustTextFrameWidthAndHeight()) + { + pTextObj->SetChanged(); + pTextObj->BroadcastObjectChange(); + } + } + else + { + OutlinerParaObject* pParaObj = pTextObj->GetOutlinerParaObject(); + if (!pParaObj) + continue; + pOutliner->SetText(*pParaObj); + if (bUndoEnabled) + { + SdrUndoObjSetText* pTxtUndo = dynamic_cast< SdrUndoObjSetText* >(pSdrModel->GetSdrUndoFactory().CreateUndoObjectSetText(*pTextObj, 0)); + pUndoGroup->AddAction(pTxtUndo); + } + pOutlinerView->ToggleAllParagraphsBullets(bBulletOnOffMode, bNormalBullet, bToggleOn, bMasterView, pNumRule); + sal_uInt32 nParaCount = pOutliner->GetParagraphCount(); + pTextObj->SetOutlinerParaObject(pOutliner->CreateParaObject(0, (sal_uInt16)nParaCount)); + pOutliner->Clear(); + } + } + + if (pUndoGroup->GetActionCount() > 0 && bUndoEnabled) + { + pSdrModel->BegUndo(); + pSdrModel->AddUndo(pUndoGroup); + pSdrModel->EndUndo(); + } + else + { + delete pUndoGroup; + } + delete pOutliner; + delete pOutlinerView; +} + } // end of namespace sd |