Related: fdo#78151 force outliners in master view to be read-only text

because these contain place-holder text and it doesn't make sense
to be able to edit them (unless some-day we support custom place-holder
prompts)

because they are now read-only add a pair of "show next level" and "hide
last level" features so on right clicking the last outline paragraph
you can make the next one visible, or make the last one invisible

Change-Id: Iea24d810f298156cfe2f32aa53d0515da45e08eb
This commit is contained in:
Caolán McNamara 2014-06-06 15:13:26 +01:00
parent 5d1e22d52a
commit 7e600aca08
11 changed files with 255 additions and 4 deletions

View File

@ -584,6 +584,16 @@
<value xml:lang="en-US">H~yperlink...</value>
</prop>
</node>
<node oor:name=".uno:HideLastLevel" oor:op="replace">
<prop oor:name="Label" oor:type="xs:string">
<value xml:lang="en-US">~Hide Last Level</value>
</prop>
</node>
<node oor:name=".uno:ShowNextLevel" oor:op="replace">
<prop oor:name="Label" oor:type="xs:string">
<value xml:lang="en-US">~Show Next Level</value>
</prop>
</node>
<node oor:name=".uno:PageSetup" oor:op="replace">
<prop oor:name="Label" oor:type="xs:string">
<value xml:lang="en-US">~Page...</value>

View File

@ -447,9 +447,10 @@
#define SID_ADD_MOTION_PATH (SID_SD_START+442)
#define SID_TABLE_TOOLBOX (SID_SD_START+443)
// free
#define SID_PRESENTATION_MINIMIZER (SID_SD_START+450)
#define SID_HIDE_LAST_LEVEL (SID_SD_START+448)
#define SID_SHOW_NEXT_LEVEL (SID_SD_START+449)
#define SID_PRESENTATION_MINIMIZER (SID_SD_START+450)
#endif
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */

View File

@ -119,6 +119,8 @@
#define CMD_SID_INSERTPAGE_LAYOUT_MENU ".uno:TaskPaneInsertPage"
#define CMD_SID_PHOTOALBUM ".uno:PhotoAlbumDialog"
#define CMD_SID_PRESENTATION_MINIMIZER ".uno:PresentationMinimizer"
#define CMD_SID_HIDE_LAST_LEVEL ".uno:HideLastLevel"
#define CMD_SID_SHOW_NEXT_LEVEL ".uno:ShowNextLevel"
#endif

View File

@ -2309,6 +2309,16 @@ interface DrawView
ExecMethod = FuTemporary ;
StateMethod = GetMenuState ;
]
SID_HIDE_LAST_LEVEL // ole : no, status : ?
[
ExecMethod = FuTemporary ;
StateMethod = GetMenuState ;
]
SID_SHOW_NEXT_LEVEL // ole : no, status : ?
[
ExecMethod = FuTemporary ;
StateMethod = GetMenuState ;
]
SID_TRANSLITERATE_UPPER // ole : no, status : ?
[
ExecMethod = FuSupport ;

View File

@ -7025,3 +7025,51 @@ SfxVoidItem PresentationMinimizer SID_PRESENTATION_MINIMIZER
ToolBoxConfig = TRUE,
GroupId = GID_OPTIONS;
]
SfxVoidItem HideLastLevel SID_HIDE_LAST_LEVEL
()
[
/* flags: */
AutoUpdate = FALSE,
Cachable = Cachable,
FastCall = FALSE,
HasCoreId = FALSE,
HasDialog = TRUE,
ReadOnlyDoc = FALSE,
Toggle = FALSE,
Container = FALSE,
RecordAbsolute = FALSE,
RecordPerSet;
Synchron;
/* config: */
AccelConfig = FALSE,
MenuConfig = FALSE,
StatusBarConfig = FALSE,
ToolBoxConfig = FALSE,
GroupId = GID_OPTIONS;
]
SfxVoidItem ShowNextLevel SID_SHOW_NEXT_LEVEL
()
[
/* flags: */
AutoUpdate = FALSE,
Cachable = Cachable,
FastCall = FALSE,
HasCoreId = FALSE,
HasDialog = TRUE,
ReadOnlyDoc = FALSE,
Toggle = FALSE,
Container = FALSE,
RecordAbsolute = FALSE,
RecordPerSet;
Synchron;
/* config: */
AccelConfig = FALSE,
MenuConfig = FALSE,
StatusBarConfig = FALSE,
ToolBoxConfig = FALSE,
GroupId = GID_OPTIONS;
]

View File

@ -33,6 +33,19 @@ Menu RID_DRAW_TEXTOBJ_INSIDE_POPUP
{
ItemList =
{
MenuItem
{
Identifier = SID_HIDE_LAST_LEVEL;
Command = CMD_SID_HIDE_LAST_LEVEL;
Text [ en-US ] = "~Hide Last Level";
};
MenuItem
{
Identifier = SID_SHOW_NEXT_LEVEL;
Command = CMD_SID_SHOW_NEXT_LEVEL;
Text [ en-US ] = "~Show Next Level";
};
SEPARATOR
MN_SET_DEFAULT
SEPARATOR
MN_TEXTATTR

View File

@ -31,6 +31,7 @@
#include <com/sun/star/scanner/XScannerManager2.hpp>
#include <unotools/caserotate.hxx>
class Outliner;
class SdPage;
class DrawDocShell;
class TabBar;
@ -41,6 +42,7 @@ class TransferableClipboardListener;
class AbstractSvxNameDialog;
class SdrLayer;
class SvxClipboardFmtItem;
struct ESelection;
namespace sd {
@ -161,6 +163,10 @@ public:
virtual OUString GetSelectionText( bool bCompleteWords = false );
virtual bool HasSelection( bool bText = true ) const;
//If we are editing an PRESOBJ_OUTLINE return the Outliner and fill rSel
//with the current selection
::Outliner* GetOutlinerForMasterPageOutlineTextObj(ESelection &rSel);
void ExecCtrl(SfxRequest& rReq);
void GetCtrlState(SfxItemSet& rSet);
void GetDrawAttrState(SfxItemSet& rSet);

View File

@ -63,6 +63,24 @@ struct SdViewRedrawRec
Rectangle aRect;
};
//For master view we want to force that master
//textboxes have readonly text, because the
//text is the auto-generated click-here-to-edit
//and it doesn't help to change it
class OutlinerMasterViewFilter
{
private:
SdrOutliner *m_pOutl;
bool m_bReadOnly;
public:
OutlinerMasterViewFilter()
: m_pOutl(0)
, m_bReadOnly(false)
{
}
void Start(SdrOutliner *pOutl);
void End();
};
class View : public FmFormView
{
@ -272,6 +290,7 @@ protected:
private:
::std::auto_ptr<ViewClipboard> mpClipboard;
OutlinerMasterViewFilter maMasterViewFilter;
};

View File

@ -1815,6 +1815,56 @@ void DrawViewShell::FuTemporary(SfxRequest& rReq)
}
break;
case SID_HIDE_LAST_LEVEL:
{
ESelection aSel;
// fdo#78151 editing a PRESOBJ_OUTLINE in a master page ?
::Outliner* pOL = GetOutlinerForMasterPageOutlineTextObj(aSel);
if (pOL)
{
//we are on the last paragraph
aSel.Adjust();
if (aSel.nEndPara == pOL->GetParagraphCount() - 1)
{
sal_uInt16 nDepth = pOL->GetDepth(aSel.nEndPara);
//there exists a previous numbering level
if (nDepth != sal_uInt16(-1) && nDepth > 0)
{
Paragraph* pPara = pOL->GetParagraph(aSel.nEndPara);
pOL->Remove(pPara, 1);
}
}
}
Cancel();
rReq.Done ();
}
break;
case SID_SHOW_NEXT_LEVEL:
{
ESelection aSel;
// fdo#78151 editing a PRESOBJ_OUTLINE in a master page ?
::Outliner* pOL = GetOutlinerForMasterPageOutlineTextObj(aSel);
if (pOL)
{
//we are on the last paragraph
aSel.Adjust();
if (aSel.nEndPara == pOL->GetParagraphCount() - 1)
{
sal_uInt16 nDepth = pOL->GetDepth(aSel.nEndPara);
//there exists a previous numbering level
if (nDepth != sal_uInt16(-1) && nDepth < 8)
{
sal_uInt16 nNewDepth = nDepth+1;
pOL->Insert(SD_RESSTR(STR_PRESOBJ_MPOUTLINE+nNewDepth), EE_PARA_APPEND, nNewDepth);
}
}
}
Cancel();
rReq.Done ();
}
break;
case SID_INSERT_FLD_DATE_FIX:
case SID_INSERT_FLD_DATE_VAR:
case SID_INSERT_FLD_TIME_FIX:

View File

@ -210,6 +210,37 @@ void DrawViewShell::GetDrawAttrState(SfxItemSet& rSet)
rSet.Put(aSet,false);
}
::Outliner* DrawViewShell::GetOutlinerForMasterPageOutlineTextObj(ESelection &rSel)
{
if( !mpDrawView )
return NULL;
//when there is one object selected
if (!mpDrawView->AreObjectsMarked() || (mpDrawView->GetMarkedObjectList().GetMarkCount() != 1))
return NULL;
//and we are editing the outline object
if (!mpDrawView->IsTextEdit())
return NULL;
SdrPageView* pPageView = mpDrawView->GetSdrPageView();
if (!pPageView)
return NULL;
SdPage* pPage = (SdPage*)pPageView->GetPage();
//only show these in a normal master page
if (!pPage || (pPage->GetPageKind() != PK_STANDARD) || !pPage->IsMasterPage())
return NULL;
OutlinerView* pOLV = mpDrawView->GetTextEditOutlinerView();
::Outliner* pOL = pOLV ? pOLV->GetOutliner() : NULL;
if (!pOL)
return NULL;
rSel = pOLV->GetSelection();
return pOL;
}
void DrawViewShell::GetMenuState( SfxItemSet &rSet )
{
if (mpDrawView == NULL)
@ -1563,6 +1594,41 @@ void DrawViewShell::GetMenuState( SfxItemSet &rSet )
if ( bDisableEditHyperlink )
rSet.DisableItem( SID_OPEN_HYPERLINK );
//fdo#78151 enable show next level/hide last level if editing a master page
//PRESOBJ_OUTLINE object and the current selection allow that to happen
{
bool bDisableShowNextLevel = true;
bool bDisableHideLastLevel = true;
ESelection aSel;
::Outliner* pOL = GetOutlinerForMasterPageOutlineTextObj(aSel);
if (pOL)
{
//and are on the last paragraph
aSel.Adjust();
if (aSel.nEndPara == pOL->GetParagraphCount() - 1)
{
sal_uInt16 nDepth = pOL->GetDepth(aSel.nEndPara);
if (nDepth != sal_uInt16(-1))
{
//there exists another numbering level that
//is currently hidden
if (nDepth < 8)
bDisableShowNextLevel = false;
//there exists a previous numbering level
if (nDepth > 0)
bDisableHideLastLevel = false;
}
}
}
if (bDisableShowNextLevel)
rSet.DisableItem(SID_SHOW_NEXT_LEVEL);
if (bDisableHideLastLevel)
rSet.DisableItem(SID_HIDE_LAST_LEVEL);
}
#if defined WNT || defined UNX
if( !mxScannerManager.is() )
{

View File

@ -654,12 +654,33 @@ static void SetSpellOptions( const SdDrawDocument& rDoc, sal_uLong& rCntrl )
rCntrl &= ~EE_CNTRL_ONLINESPELLING;
}
void OutlinerMasterViewFilter::Start(SdrOutliner *pOutl)
{
m_pOutl = pOutl;
OutlinerView* pOutlView = m_pOutl->GetView(0);
m_bReadOnly = pOutlView->IsReadOnly();
pOutlView->SetReadOnly(true);
}
void OutlinerMasterViewFilter::End()
{
if (m_pOutl)
{
OutlinerView* pOutlView = m_pOutl->GetView(0);
pOutlView->SetReadOnly(m_bReadOnly);
m_pOutl = NULL;
}
}
bool View::SdrBeginTextEdit(
SdrObject* pObj, SdrPageView* pPV, ::Window* pWin,
bool bIsNewObj,
SdrOutliner* pOutl, OutlinerView* pGivenOutlinerView,
bool bDontDeleteOutliner, bool bOnlyOneView, bool bGrabFocus )
{
SdrPage* pPage = pObj->GetPage();
bool bMasterPage = pPage && pPage->IsMasterPage();
GetViewShell()->GetViewShellBase().GetEventMultiplexer()->MultiplexEvent(
sd::tools::EventMultiplexerEvent::EID_BEGIN_TEXT_EDIT, (void*)pObj );
@ -732,12 +753,17 @@ bool View::SdrBeginTextEdit(
}
}
return(bReturn);
if (bMasterPage && bReturn)
maMasterViewFilter.Start(pOutl);
return bReturn;
}
/** ends current text editing */
SdrEndTextEditKind View::SdrEndTextEdit(bool bDontDeleteReally )
SdrEndTextEditKind View::SdrEndTextEdit(bool bDontDeleteReally)
{
maMasterViewFilter.End();
SdrObjectWeakRef xObj( GetTextEditObject() );
bool bDefaultTextRestored = RestoreDefaultText( dynamic_cast< SdrTextObj* >( GetTextEditObject() ) );